From 101b045000f2f0cdf10a4d629e67618b80c3ee72 Mon Sep 17 00:00:00 2001 From: Azareal Date: Thu, 23 Jul 2020 21:13:55 +1000 Subject: [PATCH] bulk mod: cancel bulk mod mode bulk mod: fix init binding bulk mod: cancel bulk mod mode during page transitions js: more logging js: add before_init_bind_page hook js: add end_unbind_page hook js: change end_bind_page to init hook js: change end_bind_topic to init hook nox: add padding to no alerts alert phrases: add topic_list.cancel_mod --- langs/english.json | 1 + public/global.js | 15 ++++++++-- public/member.js | 53 +++++++++++++++++++++++++++-------- themes/nox/public/main.css | 7 +++-- themes/shadow/public/main.css | 3 ++ 5 files changed, 64 insertions(+), 15 deletions(-) diff --git a/langs/english.json b/langs/english.json index 4559db67..4e96694c 100644 --- a/langs/english.json +++ b/langs/english.json @@ -645,6 +645,7 @@ "topic_list.moderate_short":"Mod", "topic_list.moderate_tooltip":"Moderate", "topic_list.moderate_aria":"Moderate Posts", + "topic_list.cancel_mod":"Cancel Mod", "topic_list.what_to_do":"What do you want to do with these {0} topics?", "topic_list.what_to_do_single":"What do you want to do with this topic?", "topic_list.moderate_delete":"Delete them", diff --git a/public/global.js b/public/global.js index cab64a00..12b32fc8 100644 --- a/public/global.js +++ b/public/global.js @@ -375,6 +375,7 @@ function getExt(name) { runInitHook("pre_global"); log("before notify on alert") // We can only get away with this because template_alert has no phrases, otherwise it too would have to be part of the "dance", I miss Go concurrency :( + log("noAlerts:",noAlerts); if(!noAlerts) { notifyOnScriptW("tmpl_alert", e => { if(e!=undefined) log("failed alert? why?",e) @@ -383,6 +384,7 @@ function getExt(name) { addInitHook("after_phrases", () => { // TODO: The load part of loadAlerts could be done asynchronously while the update of the DOM could be deferred $(document).ready(() => { + log("checking local storage cache"); alertsInitted = true; let al = document.getElementsByClassName("menu_alerts"); let sAlertList = localStorage.getItem("alertList"); @@ -452,6 +454,7 @@ function Paginate(currentPage,lastPage,maxPages) { } function mainInit(){ + log("enter mainInit"); runInitHook("start_init"); $(".more_topics").click(ev => { @@ -613,6 +616,8 @@ function mainInit(){ }); that.classList.add("filter_selected"); $(".topic_list_title h1").text(that.innerText); + unbindPage(); + bindPage(); }).catch(e => { log("Unable to get script '"+url+"&js=1"+"'",e); console.trace(); @@ -664,6 +669,7 @@ function mainInit(){ }); }); + runInitHook("before_init_bind_page"); bindPage(); runInitHook("after_init_bind_page"); @@ -937,6 +943,7 @@ function mainInit(){ } function bindPage() { + log("enter bindPage"); $(".create_topic_link").click(ev => { ev.preventDefault(); $(".topic_create_form").removeClass("auto_hide"); @@ -947,16 +954,19 @@ function bindPage() { }); bindTopic(); - runHook("end_bind_page") + runInitHook("end_bind_page") } function unbindPage() { + log("enter unbindPage"); $(".create_topic_link").unbind("click"); $(".topic_create_form .close_form").unbind("click"); unbindTopic(); + runHook("end_unbind_page") } function bindTopic() { + log("enter bindTopic"); $(".open_edit").click(ev => { ev.preventDefault(); $('.hide_on_edit').addClass("edit_opened"); @@ -1112,10 +1122,11 @@ function bindTopic() { }) }); - runHook("end_bind_topic"); + runInitHook("end_bind_topic"); } function unbindTopic() { + log("enter unbindTopic"); $(".open_edit").unbind("click"); $(".topic_item .submit_edit").unbind("click"); $(".delete_item").unbind("click"); diff --git a/public/member.js b/public/member.js index cc58368a..17c4ab3a 100644 --- a/public/member.js +++ b/public/member.js @@ -14,7 +14,7 @@ var imageExts = ["png","jpg","jpe","jpeg","jif","jfi","jfif","svg","bmp","gif"," document.body.removeChild(el); } - function uploadFileHandler(fileList, maxFiles = 5, step1 = () => {}, step2 = () => {}) { + function uploadFileHandler(fileList, maxFiles=5, step1 = () => {}, step2 = () => {}) { let files = []; for(var i=0; i { - addHook("end_bind_topic", () => { + //addInitHook("before_init_bind_page", () => { + //log("in member.js before_init_bind_page") + addInitHook("end_bind_topic", () => { + log("in member.js end_bind_topic") let changeListener = (files,handler) => { if(files!=null) { @@ -238,18 +240,38 @@ var imageExts = ["png","jpg","jpe","jpeg","jif","jfi","jfif","svg","bmp","gif"," $(".pollinputinput").click(addPollInput); }); }); - }); - //addInitHook("after_init_bind_page", () => { - addHook("end_bind_page", () => { + //}); + function modCancel() { + log("enter modCancel"); if(!$(".mod_floater").hasClass("auto_hide")) $(".mod_floater").addClass("auto_hide") $(".moderate_link").unbind("click"); + $(".moderate_link").removeClass("moderate_open"); + $(".pre_opt").addClass("auto_hide"); $(".mod_floater_submit").unbind("click"); - selectedTopics=[]; - $("topic_selected").removeClass("topic_selected"); + $("#topicsItemList,#forumItemList").removeClass("topics_moderate"); + $(".topic_selected").removeClass("topic_selected"); + // ! Be careful not to trample bindings elsewhere + $(".topic_row").unbind("click"); + $("#mod_topic_mover").addClass("auto_hide"); + } + function modCancelBind() { + log("enter modCancelBind") + $(".moderate_link").unbind("click"); + $(".moderate_open").click(ev => { + modCancel(); + $(".moderate_open").unbind("click"); + modLinkBind(); + }); + } + function modLinkBind() { + log("enter modLinkBind"); $(".moderate_link").click(ev => { + log("enter .moderate_link"); ev.preventDefault(); $(".pre_opt").removeClass("auto_hide"); $(".moderate_link").addClass("moderate_open"); + selectedTopics=[]; + modCancelBind(); $("#topicsItemList,#forumItemList").addClass("topics_moderate"); $(".topic_row").each(function(){ $(this).click(function(){ @@ -260,9 +282,7 @@ var imageExts = ["png","jpg","jpe","jpeg","jif","jfi","jfif","svg","bmp","gif"," for(var i=0; i { + //addInitHook("before_init_bind_page", () => { + //log("in member.js before_init_bind_page 2") + addInitHook("end_bind_page", () => { + log("in member.js end_bind_page") + modCancel(); + modLinkBind(); }); + addInitHook("after_init_bind_page", () => addHook("end_unbind_page", () => modCancel())) + //}); })() \ No newline at end of file diff --git a/themes/nox/public/main.css b/themes/nox/public/main.css index 00459ba9..d51a6112 100644 --- a/themes/nox/public/main.css +++ b/themes/nox/public/main.css @@ -82,8 +82,8 @@ li a { padding-right: 8px; } .alertItem:not(.withAvatar) { - padding-top: 0px; - padding-bottom: 0px; + padding-top: 6px; + padding-bottom: 6px; } .alertItem:not(.withAvatar) a { padding-top: 14px; @@ -498,6 +498,9 @@ h2 { .topic_list_title_block .mod_opt a:before { content: "{{lang "topic_list.moderate" . }}"; } +.topic_list_title_block .moderate_link.moderate_open:before { + content: "{{lang "topic_list.cancel_mod" . }}"; +} .filter_opt, .dummy_opt { margin-right: auto; diff --git a/themes/shadow/public/main.css b/themes/shadow/public/main.css index cbec7cb9..46d657f6 100644 --- a/themes/shadow/public/main.css +++ b/themes/shadow/public/main.css @@ -782,6 +782,9 @@ input[type=checkbox]:checked + label.poll_option_label .sel { content: "{{lang "topics_moderate" . }}"; padding-left: 1px; } +.topic_list_title_block .moderate_link.moderate_open:after { + content: "{{lang "topic_list.cancel_mod" . }}"; +} .create_topic_opt { order: 1; }