diff --git a/frontends/etiquette_flask/static/js/editor.js b/frontends/etiquette_flask/static/js/editor.js index 3d3ce83..07cea3b 100644 --- a/frontends/etiquette_flask/static/js/editor.js +++ b/frontends/etiquette_flask/static/js/editor.js @@ -241,7 +241,7 @@ function Editor(element_argss, on_open, on_save, on_cancel) spinner_element.innerText = "Submitting..."; spinner_element.classList.add("editor_spinner"); spinner_element.classList.add("hidden"); - this.spinner = new spinner.Spinner(spinner_element); + this.spinner = new spinners.Spinner(spinner_element); toolbox.appendChild(spinner_element); for (const element of Object.values(this.elements)) diff --git a/frontends/etiquette_flask/static/js/spinner.js b/frontends/etiquette_flask/static/js/spinners.js similarity index 78% rename from frontends/etiquette_flask/static/js/spinner.js rename to frontends/etiquette_flask/static/js/spinners.js index 1bf92b2..f5ed421 100644 --- a/frontends/etiquette_flask/static/js/spinner.js +++ b/frontends/etiquette_flask/static/js/spinners.js @@ -1,18 +1,18 @@ -const spinner = {}; +const spinners = {}; /* In general, spinners are used for functions that launch a callback, and the callback will close the spinner after it runs. But, if your initial function decides not to launch the callback (insufficient parameters, failed clientside -checks, etc.), you can have it return spinner.BAIL and the spinners will close +checks, etc.), you can have it return spinners.BAIL and the spinners will close immediately. Of course, you're always welcome to use window[button.dataset.spinnerCloser](), but this return value means you don't need to pull the button into a variable, as long as you weren't using the return value anyway. */ -spinner.BAIL = "spinner.BAIL"; +spinners.BAIL = "spinners.BAIL"; -spinner.Spinner = +spinners.Spinner = function Spinner(element) { this.show = function(delay) @@ -42,50 +42,50 @@ function Spinner(element) this.element = element; } -spinner.spinner_button_index = 0; -spinner.button_spinner_groups = {}; +spinners.spinner_button_index = 0; +spinners.button_spinner_groups = {}; /* When a group member is closing, it will call the closer on all other members in the group. Of course, this would recurse forever without some kind of flagging, so this dict will hold group_id:true if a close is in progress, and be empty otherwise. */ -spinner.spinner_group_closing = {}; +spinners.spinner_group_closing = {}; -spinner.add_to_spinner_group = +spinners.add_to_spinner_group = function add_to_spinner_group(group_id, button) { - if (!(group_id in spinner.button_spinner_groups)) + if (!(group_id in spinners.button_spinner_groups)) { - spinner.button_spinner_groups[group_id] = []; + spinners.button_spinner_groups[group_id] = []; } - spinner.button_spinner_groups[group_id].push(button); + spinners.button_spinner_groups[group_id].push(button); } -spinner.close_grouped_spinners = +spinners.close_grouped_spinners = function close_grouped_spinners(group_id) { - if (group_id && !(spinner.spinner_group_closing[group_id])) + if (group_id && !(spinners.spinner_group_closing[group_id])) { - spinner.spinner_group_closing[group_id] = true; - for (const button of spinner.button_spinner_groups[group_id]) + spinners.spinner_group_closing[group_id] = true; + for (const button of spinners.button_spinner_groups[group_id]) { window[button.dataset.spinnerCloser](); } - delete spinner.spinner_group_closing[group_id]; + delete spinners.spinner_group_closing[group_id]; } } -spinner.open_grouped_spinners = +spinners.open_grouped_spinners = function open_grouped_spinners(group_id) { - for (const button of spinner.button_spinner_groups[group_id]) + for (const button of spinners.button_spinner_groups[group_id]) { window[button.dataset.spinnerOpener](); } } -spinner.init_button_with_spinner = +spinners.init_button_with_spinner = function init_button_with_spinner() { /* @@ -126,7 +126,7 @@ function init_button_with_spinner() if (button.dataset.spinnerGroup) { - spinner.add_to_spinner_group(button.dataset.spinnerGroup, button); + spinners.add_to_spinner_group(button.dataset.spinnerGroup, button); } let spinner_element; @@ -143,10 +143,10 @@ function init_button_with_spinner() holder.appendChild(spinner_element); } - const spin = new spinner.Spinner(spinner_element); + const spin = new spinners.Spinner(spinner_element); const spin_delay = parseFloat(button.dataset.spinnerDelay) || 0; - button.dataset.spinnerOpener = "spinner_opener_" + spinner.spinner_button_index; + button.dataset.spinnerOpener = "spinner_opener_" + spinners.spinner_button_index; window[button.dataset.spinnerOpener] = function spinner_opener() { spin.show(spin_delay); @@ -155,10 +155,10 @@ function init_button_with_spinner() // It is expected that the function referenced by onclick will call // window[button.dataset.spinnerCloser]() when appropriate, since from // our perspective we cannot be sure when to close the spinner. - button.dataset.spinnerCloser = "spinner_closer_" + spinner.spinner_button_index; + button.dataset.spinnerCloser = "spinner_closer_" + spinners.spinner_button_index; window[button.dataset.spinnerCloser] = function spinner_closer() { - spinner.close_grouped_spinners(button.dataset.spinnerGroup); + spinners.close_grouped_spinners(button.dataset.spinnerGroup); spin.hide(); button.disabled = false; } @@ -169,27 +169,27 @@ function init_button_with_spinner() { if (button.dataset.spinnerGroup) { - spinner.open_grouped_spinners(button.dataset.spinnerGroup); + spinners.open_grouped_spinners(button.dataset.spinnerGroup); } else { window[button.dataset.spinnerOpener](); } const ret = wrapped_onclick(event); - if (ret === spinner.BAIL) + if (ret === spinners.BAIL) { window[button.dataset.spinnerCloser](); } return ret; } - spinner.spinner_button_index += 1; + spinners.spinner_button_index += 1; } } -spinner.on_pageload = +spinners.on_pageload = function on_pageload() { - spinner.init_button_with_spinner(); + spinners.init_button_with_spinner(); } -document.addEventListener("DOMContentLoaded", spinner.on_pageload); +document.addEventListener("DOMContentLoaded", spinners.on_pageload); diff --git a/frontends/etiquette_flask/templates/album.html b/frontends/etiquette_flask/templates/album.html index 7eb6722..b32ad75 100644 --- a/frontends/etiquette_flask/templates/album.html +++ b/frontends/etiquette_flask/templates/album.html @@ -149,7 +149,7 @@ const ALBUM_ID = undefined; - + diff --git a/frontends/etiquette_flask/templates/bookmarks.html b/frontends/etiquette_flask/templates/bookmarks.html index 89d8dd3..454460f 100644 --- a/frontends/etiquette_flask/templates/bookmarks.html +++ b/frontends/etiquette_flask/templates/bookmarks.html @@ -13,7 +13,7 @@ - +