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_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",

View File

@ -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");

View File

@ -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<fileList.length && i<5; i++) files[i] = fileList[i];
@ -148,8 +148,10 @@ var imageExts = ["png","jpg","jpe","jpeg","jif","jfi","jfif","svg","bmp","gif","
}
}
addInitHook("start_init", () => {
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<selectedTopics.length; i++){
if(selectedTopics[i]===tid) selectedTopics.splice(i, 1);
}
} else {
selectedTopics.push(tid);
}
} else selectedTopics.push(tid);
if(selectedTopics.length==1) {
var msg = phraseBox["topic_list"]["topic_list.what_to_do_single"];
} else {
@ -304,6 +324,7 @@ var imageExts = ["png","jpg","jpe","jpeg","jif","jfi","jfif","svg","bmp","gif","
log("move action");
let modTopicMover = $("#mod_topic_mover");
$("#mod_topic_mover").removeClass("auto_hide");
$("#mod_topic_mover .pane_row").unbind("click");
$("#mod_topic_mover .pane_row").click(function(){
modTopicMover.find(".pane_row").removeClass("pane_selected");
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,"");
});
});
}
//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;
}
.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;

View File

@ -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;
}