etiquette/frontends/etiquette_flask/static/js/spinner.js
Ethan Dalool c7e4bf16d2 Pull spinner code into own file spinner.js.
For the purposes of editor.js this does not bring much improvement,
but now I can easily make spinners for other things.
2019-04-27 15:42:02 -07:00

31 lines
663 B
JavaScript

var spinner = {};
spinner.Spinner =
function Spinner(element)
{
this.show = function(delay)
{
clearTimeout(this.delayed_showing_timeout);
this.delayed_showing_timeout = null;
if (! delay)
{
this.element.classList.remove("hidden");
}
else
{
this.delayed_showing_timeout = setTimeout(this.show, delay);
}
}
this.hide = function()
{
clearTimeout(this.delayed_showing_timeout);
this.delayed_showing_timeout = null;
this.element.classList.add("hidden");
}
this.delayed_showing_timeout = null;
this.element = element;
}