Update Compass QoL Enhancer to 1.23.0

- Put the nav bar over or behind masks when necessary
- Fix going to the first tab on hash changes on pages such as
/Organise/Subjects/Subject.aspx
This commit is contained in:
blankie 2023-11-04 14:42:10 +11:00
parent a44f32d37a
commit a0f8954ba4
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
2 changed files with 17 additions and 12 deletions

View File

@ -2,7 +2,7 @@
// @name Compass QoL Enhancer // @name Compass QoL Enhancer
// @namespace blankie-scripts // @namespace blankie-scripts
// @match http*://*.compass.education/* // @match http*://*.compass.education/*
// @version 1.22.0 // @version 1.23.0
// @author blankie // @author blankie
// @description A userscript that adds small but useful features for Compass, such as the ability to close windows by clicking on the background // @description A userscript that adds small but useful features for Compass, such as the ability to close windows by clicking on the background
// @inject-into page // @inject-into page
@ -15,6 +15,7 @@ let qolTabOpened = false;
let qolLearningTaskOpened = false; let qolLearningTaskOpened = false;
let modifyUrlHash = true; let modifyUrlHash = true;
let shownWindows = 0; let shownWindows = 0;
let productNavBar = document.querySelector("#productNavBar");
// needed because .toString() adds a trailing = for empty values // needed because .toString() adds a trailing = for empty values
URLSearchParams.prototype.laxToString = function() { URLSearchParams.prototype.laxToString = function() {
@ -62,15 +63,17 @@ function getPanelItemHash(panelId, isDefault) {
// Prevent scrolling if a window is open // Prevent scrolling if a window is open, and put the nav bar over or behind masks when necessary
function handleWindowShow() { function handleWindowShow() {
shownWindows++; shownWindows++;
document.documentElement.style.overflow = "hidden"; document.documentElement.style.overflow = "hidden";
productNavBar.style.zIndex = "";
} }
function handleWindowClose() { function handleWindowClose() {
shownWindows--; shownWindows--;
if (shownWindows <= 0) { if (shownWindows <= 0) {
document.documentElement.style.overflow = ""; document.documentElement.style.overflow = "";
productNavBar.style.zIndex = 20000;
} }
} }
let Window = getExtClass("Ext.window.Window"); let Window = getExtClass("Ext.window.Window");
@ -83,6 +86,10 @@ if (Window) {
}; };
} }
if (productNavBar) {
productNavBar.style.zIndex = 20000;
}
// Prevent the dashboard tab in the user page being "dsh" // Prevent the dashboard tab in the user page being "dsh"
let UserProfileNewWidget = getExtClass("Compass.widgets.UserProfileNewWidget"); let UserProfileNewWidget = getExtClass("Compass.widgets.UserProfileNewWidget");
if (UserProfileNewWidget) { if (UserProfileNewWidget) {
@ -483,10 +490,9 @@ function handleLearningTaskSubmissionTable(element) {
} }
// Make permissions grid more visible // Make permissions grid more visible
function handlePermissionsWindow(window) { function handlePermissionsWindow(node) {
let grid = window.down("grid"); node.querySelector(".x-mask").remove();
grid.el.dom.querySelector(".x-mask").remove(); node.querySelector(".x-grid-body").style.pointerEvents = "none";
grid.body.dom.style.pointerEvents = "none";
} }
function handleCKEditor(instance) { function handleCKEditor(instance) {
@ -543,11 +549,8 @@ function handleNewNode(node, observer) {
handleLearningTasksTable(node); handleLearningTasksTable(node);
} else if (node.classList.contains("x-grid-view") && unsafeWindow.Ext.getCmp(node.id).up("#submissionsPanel")) { } else if (node.classList.contains("x-grid-view") && unsafeWindow.Ext.getCmp(node.id).up("#submissionsPanel")) {
handleLearningTaskSubmissionTable(node); handleLearningTaskSubmissionTable(node);
} else if (node.classList.contains("x-window")) { } else if (node.classList.contains("x-window") && node.querySelector(".x-window-header-text").innerText.startsWith("View Permissions for ")) {
let window = unsafeWindow.Ext.getCmp(node.id); handlePermissionsWindow(node);
if (window.title.startsWith("View Permissions for ")) {
handlePermissionsWindow(window);
}
} }
if (node.classList.contains("cke")) { if (node.classList.contains("cke")) {
@ -634,7 +637,7 @@ window.addEventListener("hashchange", function(event) {
panel = unsafeWindow.Ext.getCmp(panel.id); panel = unsafeWindow.Ext.getCmp(panel.id);
if (isActivityPage && hashSearch.has("openLearningTaskTab")) { if (isActivityPage && hashSearch.has("openLearningTaskTab")) {
panel.setActiveTab(getLearningTaskTab(panel)); panel.setActiveTab(getLearningTaskTab(panel));
} else if (isActivityPage && hashSearch.size === 1) { } else if (hashSearch.size === 0 || (isActivityPage && hashSearch.size === 1)) {
event.stopImmediatePropagation(); event.stopImmediatePropagation();
panel.setActiveTab(panel.items.items[0]); panel.setActiveTab(panel.items.items[0]);
} else { } else {

View File

@ -60,6 +60,8 @@ A userscript that adds small but useful features for Compass. Features are:
that prevents it from seeing links inside lesson plans and such that prevents it from seeing links inside lesson plans and such
- Files and folders in Resources are now sorted alphabetically - Files and folders in Resources are now sorted alphabetically
- Reopening panel tabs and learning tasks when the URL changes - Reopening panel tabs and learning tasks when the URL changes
- The main navigation bar is no longer hidden behind masks that don't span the
entire viewport
- The option to remember logins is unchecked by default - The option to remember logins is unchecked by default
- The dashboard tab in a user's profile no longer points you to #dsh - The dashboard tab in a user's profile no longer points you to #dsh
- Pages can no longer be scrolled if a window is currently open - Pages can no longer be scrolled if a window is currently open