Define spinner with a cfg object only once, then hide and show as needed.

Add a 'msg' parameter to the spinner function which adds a message to the spinner on show and a spinnerMsg() function which allows it to be changed while the spinner is showing.
This commit is contained in:
mmcwilliams 2018-01-31 21:45:19 -05:00
parent f3e406dd5d
commit 66d9af42b6
1 changed files with 36 additions and 26 deletions

View File

@ -105,8 +105,7 @@ gui.updateState = function () {
$('#seq_cam_count_2').val(cpos).change();
$('#seq_proj_count_2').val(ppos).change();
};
gui.spinner = function (state) {
var cfg = {
gui.spinnerCfg = {
lines: 11, // The number of lines to draw
length: 15, // The length of each line
width: 7, // The line thickness
@ -123,17 +122,28 @@ gui.spinner = function (state) {
zIndex: 2e9, // The z-index (defaults to 2000000000)
top: '50%', // Top position relative to parent
left: '50%' // Left position relative to parent
},
target,
}
gui.spinner = function (state, msg = '') {
var target,
spinner;
if (state) {
target = document.getElementById('spinner');
spinner = new Spinner(cfg).spin(target);
} else {
$('#spinner').hide();
$('#psinner').empty();
if (msg !== '') {
gui.spinnerMsg(msg)
}
if (state && !$('#spinner').hasClass('created')) {
target = document.getElementById('spinner');
spinner = new Spinner(gui.spinnerCfg).spin(target);
$('#spinner').addClass('created');
} else if (state) {
$('#spinner').show();
} else if (!state) {
$('#spinner').hide();
gui.spinnerMsg('')
}
};
gui.spinnerMsg = function (msg) {
$('#spinnerMsg').text(msg)
}
gui.overlay = function (state) {
if (state) {
$('#overlay').show();