try to iron out more ajax topic kinks
This commit is contained in:
parent
64ec820453
commit
e19e478e32
@ -1001,6 +1001,8 @@ function bindTopic() {
|
||||
// For custom / third party text editors
|
||||
quoteItemCallback(src.innerHTML,item);
|
||||
});
|
||||
|
||||
runHook("end_bind_topic");
|
||||
}
|
||||
|
||||
function unbindTopic() {
|
||||
@ -1010,4 +1012,5 @@ function unbindTopic() {
|
||||
$(".edit_item").unbind("click");
|
||||
$(".submit_edit").unbind("click");
|
||||
$(".quote_item").unbind("click");
|
||||
runHook("end_unbind_topic");
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
var imageExts = ["png", "jpg", "jpe","jpeg","jif","jfi","jfif", "svg", "bmp", "gif", "tiff","tif", "webp"];
|
||||
|
||||
(() => {
|
||||
addInitHook("almost_end_init", () => {
|
||||
function copyToClipboard(str) {
|
||||
const el=document.createElement('textarea');
|
||||
el.value=str;
|
||||
@ -16,9 +15,9 @@ var imageExts = ["png", "jpg", "jpe","jpeg","jif","jfi","jfif", "svg", "bmp", "g
|
||||
}
|
||||
|
||||
// TODO: Surely, there's a prettier and more elegant way of doing this?
|
||||
function getExt(filename) {
|
||||
if(!filename.indexOf('.' > -1)) throw("This file doesn't have an extension");
|
||||
return filename.split('.').pop();
|
||||
function getExt(name) {
|
||||
if(!name.indexOf('.' > -1)) throw("This file doesn't have an extension");
|
||||
return name.split('.').pop();
|
||||
}
|
||||
|
||||
function uploadFileHandler(fileList, maxFiles = 5, step1 = () => {}, step2 = () => {}) {
|
||||
@ -30,9 +29,7 @@ var imageExts = ["png", "jpg", "jpe","jpeg","jif","jfi","jfif", "svg", "bmp", "g
|
||||
console.log("files[" + i + "]",files[i]);
|
||||
totalSize += files[i]["size"];
|
||||
}
|
||||
if(totalSize > me.Site.MaxRequestSize) {
|
||||
throw("You can't upload this much at once, max: " + me.Site.MaxRequestSize);
|
||||
}
|
||||
if(totalSize > me.Site.MaxRequestSize) throw("You can't upload this much at once, max: " + me.Site.MaxRequestSize);
|
||||
|
||||
for(let i = 0; i < files.length; i++) {
|
||||
let filename = files[i]["name"];
|
||||
@ -69,7 +66,6 @@ var imageExts = ["png", "jpg", "jpe","jpeg","jif","jfi","jfif", "svg", "bmp", "g
|
||||
uploadFileHandler(this.files, 5, () => {},
|
||||
(e,hash,filename) => {
|
||||
console.log("hash",hash);
|
||||
|
||||
let formData = new FormData();
|
||||
formData.append("s",me.User.S);
|
||||
for(let i = 0; i < this.files.length; i++) formData.append("upload_files",this.files[i]);
|
||||
@ -147,15 +143,6 @@ var imageExts = ["png", "jpg", "jpe","jpeg","jif","jfi","jfif", "svg", "bmp", "g
|
||||
}
|
||||
}
|
||||
|
||||
let uploadFiles = document.getElementById("upload_files");
|
||||
if(uploadFiles != null) {
|
||||
uploadFiles.addEventListener("change", uploadAttachHandler, false);
|
||||
}
|
||||
let uploadFilesOp = document.getElementById("upload_files_op");
|
||||
if(uploadFilesOp != null) {
|
||||
uploadFilesOp.addEventListener("change", uploadAttachHandler2, false);
|
||||
}
|
||||
|
||||
function bindAttachManager() {
|
||||
let uploadFiles = document.getElementsByClassName("upload_files_post");
|
||||
if(uploadFiles==null) return;
|
||||
@ -166,6 +153,20 @@ var imageExts = ["png", "jpg", "jpe","jpeg","jif","jfi","jfif", "svg", "bmp", "g
|
||||
uploader.addEventListener("change", uploadAttachHandler2, false);
|
||||
}
|
||||
}
|
||||
|
||||
addInitHook("start_init", () => {
|
||||
addHook("end_bind_topic", () => {
|
||||
|
||||
let uploadFiles = document.getElementById("upload_files");
|
||||
if(uploadFiles!=null) {
|
||||
uploadFiles.removeEventListener("change", uploadAttachHandler, false);
|
||||
uploadFiles.addEventListener("change", uploadAttachHandler, false);
|
||||
}
|
||||
let uploadFilesOp = document.getElementById("upload_files_op");
|
||||
if(uploadFilesOp!=null) {
|
||||
uploadFilesOp.removeEventListener("change", uploadAttachHandler2, false);
|
||||
uploadFilesOp.addEventListener("change", uploadAttachHandler2, false);
|
||||
}
|
||||
bindAttachManager();
|
||||
|
||||
function bindAttachItems() {
|
||||
@ -184,6 +185,7 @@ var imageExts = ["png", "jpg", "jpe","jpeg","jif","jfi","jfif", "svg", "bmp", "g
|
||||
}
|
||||
bindAttachItems();
|
||||
|
||||
$(".attach_item_delete").unbind("click");
|
||||
$(".attach_item_delete").click(function(){
|
||||
let formData = new URLSearchParams();
|
||||
formData.append("s",me.User.S);
|
||||
@ -217,6 +219,8 @@ var imageExts = ["png", "jpg", "jpe","jpeg","jif","jfi","jfif", "svg", "bmp", "g
|
||||
bindAttachManager();
|
||||
});
|
||||
|
||||
$(".moderate_link").unbind("click");
|
||||
$(".mod_floater_submit").unbind("click");
|
||||
$(".moderate_link").click(ev => {
|
||||
ev.preventDefault();
|
||||
$(".pre_opt").removeClass("auto_hide");
|
||||
@ -248,6 +252,7 @@ var imageExts = ["png", "jpg", "jpe","jpeg","jif","jfi","jfif", "svg", "bmp", "g
|
||||
}
|
||||
});
|
||||
};
|
||||
// TODO: Should we unbind this here to avoid binding multiple listeners to this accidentally?
|
||||
$(".mod_floater_submit").click(function(ev){
|
||||
ev.preventDefault();
|
||||
let selectNode = this.form.querySelector(".mod_floater_options");
|
||||
@ -297,7 +302,8 @@ var imageExts = ["png", "jpg", "jpe","jpeg","jif","jfi","jfif", "svg", "bmp", "g
|
||||
$(".pollinputinput").click(addPollInput);
|
||||
}
|
||||
|
||||
var pollInputIndex = 1;
|
||||
let pollInputIndex = 1;
|
||||
$("#add_poll_button").unbind("click");
|
||||
$("#add_poll_button").click(ev => {
|
||||
ev.preventDefault();
|
||||
$(".poll_content_row").removeClass("auto_hide");
|
||||
@ -305,4 +311,5 @@ var imageExts = ["png", "jpg", "jpe","jpeg","jif","jfi","jfif", "svg", "bmp", "g
|
||||
$(".pollinputinput").click(addPollInput);
|
||||
});
|
||||
});
|
||||
})();
|
||||
});
|
||||
})()
|
Loading…
Reference in New Issue
Block a user