fix
This commit is contained in:
parent
f288e826ff
commit
befa8d1e7a
3 changed files with 49 additions and 47 deletions
|
@ -2,20 +2,20 @@ function initializeBootstrap() {
|
||||||
// tooltips
|
// tooltips
|
||||||
let tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
|
let tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
|
||||||
tooltipTriggerList.map(function(element){
|
tooltipTriggerList.map(function(element){
|
||||||
return new bootstrap.Tooltip(element);
|
return new bootstrap.Tooltip(element);
|
||||||
});
|
});
|
||||||
// popovers
|
// popovers
|
||||||
let popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'));
|
let popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'));
|
||||||
let popoverList = popoverTriggerList.map(function(popoverTriggerEl) {
|
let popoverList = popoverTriggerList.map(function(popoverTriggerEl) {
|
||||||
let popoverId = popoverTriggerEl.getAttribute('data-content-id');
|
let popoverId = popoverTriggerEl.getAttribute('data-content-id');
|
||||||
let contentEl = document.getElementById(popoverId);
|
let contentEl = document.getElementById(popoverId);
|
||||||
if (contentEl) {
|
if (contentEl) {
|
||||||
return new bootstrap.Popover(popoverTriggerEl, {
|
return new bootstrap.Popover(popoverTriggerEl, {
|
||||||
content: contentEl.innerHTML,
|
content: contentEl.innerHTML,
|
||||||
html: true,
|
html: true,
|
||||||
sanitize: false
|
sanitize: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,14 +97,14 @@ makeQuote = function (form) {
|
||||||
|
|
||||||
function autoExpand (field) {
|
function autoExpand (field) {
|
||||||
|
|
||||||
xpos=window.scrollX;
|
xpos=window.scrollX;
|
||||||
ypos=window.scrollY;
|
ypos=window.scrollY;
|
||||||
|
|
||||||
field.style.height = 'inherit';
|
field.style.height = 'inherit';
|
||||||
|
|
||||||
var computed = window.getComputedStyle(field);
|
var computed = window.getComputedStyle(field);
|
||||||
|
|
||||||
var height = parseInt(computed.getPropertyValue('border-top-width'), 10)
|
var height = parseInt(computed.getPropertyValue('border-top-width'), 10)
|
||||||
+ parseInt(computed.getPropertyValue('padding-top'), 10)
|
+ parseInt(computed.getPropertyValue('padding-top'), 10)
|
||||||
+ field.scrollHeight
|
+ field.scrollHeight
|
||||||
+ parseInt(computed.getPropertyValue('padding-bottom'), 10)
|
+ parseInt(computed.getPropertyValue('padding-bottom'), 10)
|
||||||
|
@ -113,7 +113,7 @@ function autoExpand (field) {
|
||||||
|
|
||||||
field.style.height = height + 'px';
|
field.style.height = height + 'px';
|
||||||
|
|
||||||
window.scrollTo(xpos,ypos);
|
window.scrollTo(xpos,ypos);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ function post_toast2(url, button1, button2) {
|
||||||
|
|
||||||
if(typeof data === 'object' && data !== null) {
|
if(typeof data === 'object' && data !== null) {
|
||||||
for(let k of Object.keys(data)) {
|
for(let k of Object.keys(data)) {
|
||||||
form.append(k, data[k]);
|
form.append(k, data[k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ function postToast(url) {
|
||||||
|
|
||||||
if(typeof data === 'object' && data !== null) {
|
if(typeof data === 'object' && data !== null) {
|
||||||
for(let k of Object.keys(data)) {
|
for(let k of Object.keys(data)) {
|
||||||
form.append(k, data[k]);
|
form.append(k, data[k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
form.append("formkey", formkey());
|
form.append("formkey", formkey());
|
||||||
|
@ -228,23 +228,23 @@ function submitFormAjax(e) {
|
||||||
const form = e.target;
|
const form = e.target;
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
formData = new FormData(form);
|
formData = new FormData(form);
|
||||||
|
|
||||||
formData.append("formkey", formkey());
|
formData.append("formkey", formkey());
|
||||||
if(typeof data === 'object' && data !== null) {
|
if(typeof data === 'object' && data !== null) {
|
||||||
for(let k of Object.keys(data)) {
|
for(let k of Object.keys(data)) {
|
||||||
form.append(k, data[k]);
|
form.append(k, data[k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xhr.withCredentials = true;
|
xhr.withCredentials = true;
|
||||||
|
|
||||||
actionPath = form.getAttribute("action");
|
actionPath = form.getAttribute("action");
|
||||||
|
|
||||||
xhr.open("POST", actionPath, true);
|
xhr.open("POST", actionPath, true);
|
||||||
|
|
||||||
xhr.onload = function() {
|
xhr.onload = function() {
|
||||||
data = JSON.parse(xhr.response);
|
data = JSON.parse(xhr.response);
|
||||||
if (xhr.status >= 200 && xhr.status < 300 && !data["error"]) {
|
if (xhr.status >= 200 && xhr.status < 300 && !data["error"]) {
|
||||||
try {
|
try {
|
||||||
|
@ -275,9 +275,9 @@ function submitFormAjax(e) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
xhr.send(formData);
|
xhr.send(formData);
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
function expandDesktopImage(image) {
|
function expandDesktopImage(image) {
|
||||||
|
@ -291,16 +291,27 @@ const messageModal = document.getElementById('directMessageModal')
|
||||||
|
|
||||||
// When message modal opens
|
// When message modal opens
|
||||||
messageModal.addEventListener('show.bs.modal', function (event) {
|
messageModal.addEventListener('show.bs.modal', function (event) {
|
||||||
// Button that triggered the modal
|
// Form that will send the message
|
||||||
const button = event.relatedTarget
|
const form = messageModal.querySelector('form');
|
||||||
// Extract info from data-bs-* attributes
|
// Button that triggered the modal
|
||||||
const recipient = button.getAttribute('data-bs-recipient')
|
const button = event.relatedTarget;
|
||||||
// Update the modal's content.
|
// Extract info from data-bs-* attributes
|
||||||
const modalTitle = messageModal.querySelector('.modal-title')
|
const recipient = button.getAttribute('data-bs-recipient');
|
||||||
//
|
// Update the modal's content.
|
||||||
messageModal.querySelector('form').action = `/@${recipient}/message`
|
const modalTitle = messageModal.querySelector('.modal-title');
|
||||||
|
// Set our form's action
|
||||||
|
form.action = `/@${recipient}/message`
|
||||||
|
|
||||||
|
modalTitle.textContent = 'New message to ' + recipient
|
||||||
|
|
||||||
|
form.addEventListener("submit", function(event) {
|
||||||
|
button.disabled = true;
|
||||||
|
button.textContent = button.getAttribute('data-bs-loading');
|
||||||
|
submitFormAjax(event);
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
modalTitle.textContent = 'New message to ' + recipient
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// When message modal closes
|
// When message modal closes
|
||||||
|
@ -311,13 +322,4 @@ messageModal.addEventListener('hidden.bs.modal', function (event) {
|
||||||
modalBodyInput.value = '';
|
modalBodyInput.value = '';
|
||||||
})
|
})
|
||||||
|
|
||||||
function sendMessage(el) {
|
|
||||||
// Get our input
|
|
||||||
const input = document.getElementById(el)
|
|
||||||
// Extract info from our input
|
|
||||||
const message = input.value;
|
|
||||||
// Send our message
|
|
||||||
postToast(``)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send coins
|
// Send coins
|
|
@ -357,7 +357,7 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<script src="/static/assets/CHRISTMAS/js/default.js?a=9"></script>
|
<script src="/static/assets/CHRISTMAS/js/default.js?a=10"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<!-- Form action loaded by JS -->
|
<!-- Form action loaded by JS -->
|
||||||
<form id="message" action="" method="post" enctype="multipart/form-data" onsubmit="submitFormAjax(event)">
|
<form id="message">
|
||||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||||
<div class="relative rounded border border-gray-300 dark:border-gray-900 bg-white dark:bg-white/[.05] w-full">
|
<div class="relative rounded border border-gray-300 dark:border-gray-900 bg-white dark:bg-white/[.05] w-full">
|
||||||
<textarea maxlength="1000" id="direct-message-input" name="message" form="message" class="rounded-t bg-transparent p-2 shadow-inner w-full" aria-label="With textarea" placeholder="Write your message..." rows="3"></textarea>
|
<textarea maxlength="1000" id="direct-message-input" name="message" form="message" class="rounded-t bg-transparent p-2 shadow-inner w-full" aria-label="With textarea" placeholder="Write your message..." rows="3"></textarea>
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
<button type="button" class="px-4 py-2 text-sm font-bold text-gray-500 hover:text-gray-400" data-bs-dismiss="modal">
|
<button type="button" class="px-4 py-2 text-sm font-bold text-gray-500 hover:text-gray-400" data-bs-dismiss="modal">
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
<button type="submit" form="message" class="btn btn-primary">
|
<button type="submit" form="message" class="btn btn-primary" data-bs-loading="Sending" data-bs-dismiss="modal">
|
||||||
Send message
|
Send message
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue