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
This commit is contained in:
Azareal 2020-07-23 21:13:55 +10:00
parent e814e85daa
commit 101b045000
5 changed files with 64 additions and 15 deletions

View File

@ -645,6 +645,7 @@
"topic_list.moderate_short":"Mod", "topic_list.moderate_short":"Mod",
"topic_list.moderate_tooltip":"Moderate", "topic_list.moderate_tooltip":"Moderate",
"topic_list.moderate_aria":"Moderate Posts", "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":"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.what_to_do_single":"What do you want to do with this topic?",
"topic_list.moderate_delete":"Delete them", "topic_list.moderate_delete":"Delete them",

View File

@ -375,6 +375,7 @@ function getExt(name) {
runInitHook("pre_global"); runInitHook("pre_global");
log("before notify on alert") 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 :( // 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) { if(!noAlerts) {
notifyOnScriptW("tmpl_alert", e => { notifyOnScriptW("tmpl_alert", e => {
if(e!=undefined) log("failed alert? why?",e) if(e!=undefined) log("failed alert? why?",e)
@ -383,6 +384,7 @@ function getExt(name) {
addInitHook("after_phrases", () => { addInitHook("after_phrases", () => {
// TODO: The load part of loadAlerts could be done asynchronously while the update of the DOM could be deferred // TODO: The load part of loadAlerts could be done asynchronously while the update of the DOM could be deferred
$(document).ready(() => { $(document).ready(() => {
log("checking local storage cache");
alertsInitted = true; alertsInitted = true;
let al = document.getElementsByClassName("menu_alerts"); let al = document.getElementsByClassName("menu_alerts");
let sAlertList = localStorage.getItem("alertList"); let sAlertList = localStorage.getItem("alertList");
@ -452,6 +454,7 @@ function Paginate(currentPage,lastPage,maxPages) {
} }
function mainInit(){ function mainInit(){
log("enter mainInit");
runInitHook("start_init"); runInitHook("start_init");
$(".more_topics").click(ev => { $(".more_topics").click(ev => {
@ -613,6 +616,8 @@ function mainInit(){
}); });
that.classList.add("filter_selected"); that.classList.add("filter_selected");
$(".topic_list_title h1").text(that.innerText); $(".topic_list_title h1").text(that.innerText);
unbindPage();
bindPage();
}).catch(e => { }).catch(e => {
log("Unable to get script '"+url+"&js=1"+"'",e); log("Unable to get script '"+url+"&js=1"+"'",e);
console.trace(); console.trace();
@ -664,6 +669,7 @@ function mainInit(){
}); });
}); });
runInitHook("before_init_bind_page");
bindPage(); bindPage();
runInitHook("after_init_bind_page"); runInitHook("after_init_bind_page");
@ -937,6 +943,7 @@ function mainInit(){
} }
function bindPage() { function bindPage() {
log("enter bindPage");
$(".create_topic_link").click(ev => { $(".create_topic_link").click(ev => {
ev.preventDefault(); ev.preventDefault();
$(".topic_create_form").removeClass("auto_hide"); $(".topic_create_form").removeClass("auto_hide");
@ -947,16 +954,19 @@ function bindPage() {
}); });
bindTopic(); bindTopic();
runHook("end_bind_page") runInitHook("end_bind_page")
} }
function unbindPage() { function unbindPage() {
log("enter unbindPage");
$(".create_topic_link").unbind("click"); $(".create_topic_link").unbind("click");
$(".topic_create_form .close_form").unbind("click"); $(".topic_create_form .close_form").unbind("click");
unbindTopic(); unbindTopic();
runHook("end_unbind_page")
} }
function bindTopic() { function bindTopic() {
log("enter bindTopic");
$(".open_edit").click(ev => { $(".open_edit").click(ev => {
ev.preventDefault(); ev.preventDefault();
$('.hide_on_edit').addClass("edit_opened"); $('.hide_on_edit').addClass("edit_opened");
@ -1112,10 +1122,11 @@ function bindTopic() {
}) })
}); });
runHook("end_bind_topic"); runInitHook("end_bind_topic");
} }
function unbindTopic() { function unbindTopic() {
log("enter unbindTopic");
$(".open_edit").unbind("click"); $(".open_edit").unbind("click");
$(".topic_item .submit_edit").unbind("click"); $(".topic_item .submit_edit").unbind("click");
$(".delete_item").unbind("click"); $(".delete_item").unbind("click");

View File

@ -148,8 +148,10 @@ var imageExts = ["png","jpg","jpe","jpeg","jif","jfi","jfif","svg","bmp","gif","
} }
} }
addInitHook("start_init", () => { //addInitHook("before_init_bind_page", () => {
addHook("end_bind_topic", () => { //log("in member.js before_init_bind_page")
addInitHook("end_bind_topic", () => {
log("in member.js end_bind_topic")
let changeListener = (files,handler) => { let changeListener = (files,handler) => {
if(files!=null) { if(files!=null) {
@ -238,18 +240,38 @@ var imageExts = ["png","jpg","jpe","jpeg","jif","jfi","jfif","svg","bmp","gif","
$(".pollinputinput").click(addPollInput); $(".pollinputinput").click(addPollInput);
}); });
}); });
}); //});
//addInitHook("after_init_bind_page", () => { function modCancel() {
addHook("end_bind_page", () => { log("enter modCancel");
if(!$(".mod_floater").hasClass("auto_hide")) $(".mod_floater").addClass("auto_hide") if(!$(".mod_floater").hasClass("auto_hide")) $(".mod_floater").addClass("auto_hide")
$(".moderate_link").unbind("click"); $(".moderate_link").unbind("click");
$(".moderate_link").removeClass("moderate_open");
$(".pre_opt").addClass("auto_hide");
$(".mod_floater_submit").unbind("click"); $(".mod_floater_submit").unbind("click");
selectedTopics=[]; $("#topicsItemList,#forumItemList").removeClass("topics_moderate");
$("topic_selected").removeClass("topic_selected"); $(".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 => { $(".moderate_link").click(ev => {
log("enter .moderate_link");
ev.preventDefault(); ev.preventDefault();
$(".pre_opt").removeClass("auto_hide"); $(".pre_opt").removeClass("auto_hide");
$(".moderate_link").addClass("moderate_open"); $(".moderate_link").addClass("moderate_open");
selectedTopics=[];
modCancelBind();
$("#topicsItemList,#forumItemList").addClass("topics_moderate"); $("#topicsItemList,#forumItemList").addClass("topics_moderate");
$(".topic_row").each(function(){ $(".topic_row").each(function(){
$(this).click(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<selectedTopics.length; i++){ for(var i=0; i<selectedTopics.length; i++){
if(selectedTopics[i]===tid) selectedTopics.splice(i, 1); if(selectedTopics[i]===tid) selectedTopics.splice(i, 1);
} }
} else { } else selectedTopics.push(tid);
selectedTopics.push(tid);
}
if(selectedTopics.length==1) { if(selectedTopics.length==1) {
var msg = phraseBox["topic_list"]["topic_list.what_to_do_single"]; var msg = phraseBox["topic_list"]["topic_list.what_to_do_single"];
} else { } else {
@ -304,6 +324,7 @@ var imageExts = ["png","jpg","jpe","jpeg","jif","jfi","jfif","svg","bmp","gif","
log("move action"); log("move action");
let modTopicMover = $("#mod_topic_mover"); let modTopicMover = $("#mod_topic_mover");
$("#mod_topic_mover").removeClass("auto_hide"); $("#mod_topic_mover").removeClass("auto_hide");
$("#mod_topic_mover .pane_row").unbind("click");
$("#mod_topic_mover .pane_row").click(function(){ $("#mod_topic_mover .pane_row").click(function(){
modTopicMover.find(".pane_row").removeClass("pane_selected"); modTopicMover.find(".pane_row").removeClass("pane_selected");
let fid = this.getAttribute("data-fid"); let fid = this.getAttribute("data-fid");
@ -324,5 +345,15 @@ var imageExts = ["png","jpg","jpe","jpeg","jif","jfi","jfif","svg","bmp","gif","
bulkActionSender(action,selectedTopics,""); bulkActionSender(action,selectedTopics,"");
}); });
}); });
}
//addInitHook("after_init_bind_page", () => {
//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()))
//});
})() })()

View File

@ -82,8 +82,8 @@ li a {
padding-right: 8px; padding-right: 8px;
} }
.alertItem:not(.withAvatar) { .alertItem:not(.withAvatar) {
padding-top: 0px; padding-top: 6px;
padding-bottom: 0px; padding-bottom: 6px;
} }
.alertItem:not(.withAvatar) a { .alertItem:not(.withAvatar) a {
padding-top: 14px; padding-top: 14px;
@ -498,6 +498,9 @@ h2 {
.topic_list_title_block .mod_opt a:before { .topic_list_title_block .mod_opt a:before {
content: "{{lang "topic_list.moderate" . }}"; content: "{{lang "topic_list.moderate" . }}";
} }
.topic_list_title_block .moderate_link.moderate_open:before {
content: "{{lang "topic_list.cancel_mod" . }}";
}
.filter_opt, .dummy_opt { .filter_opt, .dummy_opt {
margin-right: auto; margin-right: auto;

View File

@ -782,6 +782,9 @@ input[type=checkbox]:checked + label.poll_option_label .sel {
content: "{{lang "topics_moderate" . }}"; content: "{{lang "topics_moderate" . }}";
padding-left: 1px; padding-left: 1px;
} }
.topic_list_title_block .moderate_link.moderate_open:after {
content: "{{lang "topic_list.cancel_mod" . }}";
}
.create_topic_opt { .create_topic_opt {
order: 1; order: 1;
} }