gosora/themes/nox/public/misc.js
Azareal 27a4a74840 You can now re-order forums by dragging them in the Forum Manager.
Added some visual and textual hints to make it clearer that Menu Items and Forums can be dragged.
Added a hint to flush the page after pushing the <head>
Added the notice client template and pushNotice client function.

Used a pointer instead of a struct for AnalyticsTimeRange in the analytics routes.
Caught a potential missing error check in InitPhrases.
Use struct{} instead of bool in some of the user mapping maps for WebSockets to save space.
Added the buildUserExprs function to eliminate a bit of duplication.
Fixed a typo in ForumsEdit where it referenced a non-existent notice phrase.
Client hooks can now sort of return things.
Panel phrases are now fetched by init.js, but only in the control panel.
Reduced the number of unused phrases loaded in both the front-end and the control panel.

Plugin hyperdrive should handle Gzip better now.

Added the panel.ForumsOrderSubmit route.

Added the panel_hints_reorder phrase.
Moved the panel_forums phrases into the panel. namespace.
Added the panel.forums_order_updated phrase.
Renamed the panel_themes_menus_item_edit_button_aria phrase to panel_themes_menus_items_edit_button_aria
Renamed the panel_themes_menus_item_delete_button_aria phrase to panel_themes_menus_items_delete_button_aria
Added the panel_themes_menus_items_update_button phrase.

You will need to run the patcher / updater for this commit.
2019-04-27 16:32:26 +10:00

86 lines
2.8 KiB
JavaScript

"use strict";
function noxMenuBind() {
$(".more_menu").remove();
$("#main_menu li:not(.menu_hamburger").removeClass("menu_hide");
let mWidth = $("#main_menu").width();
let iWidth = 0;
let lastElem = null;
$("#main_menu > li:not(.menu_hamburger)").each(function(){
iWidth += $(this).outerWidth();
if(iWidth > (mWidth - 100) && (mWidth - 100) > 0) {
this.classList.add("menu_hide");
if(lastElem!==null) lastElem.classList.add("menu_hide");
}
lastElem = this;
});
if(iWidth > (mWidth - 100) && (mWidth - 100) > 0) $(".menu_hamburger").show();
else $(".menu_hamburger").hide();
let div = document.createElement('div');
div.className = "more_menu";
$("#main_menu > li:not(.menu_hamburger):not(#menu_overview)").each(function(){
if(!this.classList.contains("menu_hide")) return;
let cop = this.cloneNode(true);
cop.classList.remove("menu_hide");
div.appendChild(cop);
});
document.getElementsByClassName("menu_hamburger")[0].appendChild(div);
}
(() => {
function moveAlerts() {
// Move the alerts above the first header
let colSel = $(".colstack_right .colstack_head:first");
let colSelAlt = $(".colstack_right .colstack_item:first");
let colSelAltAlt = $(".colstack_right .coldyn_block:first");
if(colSel.length > 0) $('.alert').insertBefore(colSel);
else if (colSelAlt.length > 0) $('.alert').insertBefore(colSelAlt);
else if (colSelAltAlt.length > 0) $('.alert').insertBefore(colSelAltAlt);
else $('.alert').insertAfter(".rowhead:first");
}
addInitHook("after_update_alert_list", (alertCount) => {
console.log("misc.js");
console.log("alertCount:",alertCount);
if(alertCount==0) {
$(".alerts").html(phraseBox["alerts"]["alerts.no_alerts_short"]);
$(".user_box").removeClass("has_alerts");
} else {
// TODO: Localise this
$(".alerts").html(alertCount + " new alerts");
$(".user_box").addClass("has_alerts");
}
});
addHook("open_edit", () => $('.topic_block').addClass("edithead"));
addHook("close_edit", () => $('.topic_block').removeClass("edithead"));
addInitHook("end_init", () => {
$(".alerts").click((event) => {
event.stopPropagation();
var alerts = $(".menu_alerts")[0];
if($(alerts).hasClass("selectedAlert")) return;
if(!conn) loadAlerts(alerts);
alerts.className += " selectedAlert";
document.getElementById("back").className += " alertActive"
});
$(window).resize(() => noxMenuBind());
noxMenuBind();
moveAlerts();
$(".menu_hamburger").click(function() {
event.stopPropagation();
console.log("hi")
let mm = document.getElementsByClassName("more_menu")[0];
mm.classList.add("more_menu_selected");
let calc = $(this).offset().left - (mm.offsetWidth / 4);
mm.style.left = calc+"px";
});
$(document).click(() => $(".more_menu").removeClass("more_menu_selected"));
});
addInitHook("after_notice", moveAlerts);
})();