mirror of
https://github.com/NaN-tic/sao-base.git
synced 2023-12-14 03:13:01 +01:00
Add loading indicator
review10171002
This commit is contained in:
parent
e31f655f9e
commit
cf8fa97b53
|
@ -2374,4 +2374,41 @@
|
|||
}
|
||||
});
|
||||
Sao.common.error = new Sao.common.ErrorDialog();
|
||||
|
||||
Sao.common.Processing = Sao.class_(Object, {
|
||||
queries: 0,
|
||||
timeout: 1000,
|
||||
init: function() {
|
||||
this.el = jQuery('<div/>', {
|
||||
'id': 'processing',
|
||||
'class': 'text-center'
|
||||
});
|
||||
this.el.append(jQuery('<span/>', {
|
||||
'class': 'label label-info',
|
||||
'text': 'Processing…'
|
||||
}));
|
||||
this.el.hide();
|
||||
jQuery(function() {
|
||||
this.el.appendTo('body');
|
||||
}.bind(this));
|
||||
},
|
||||
show: function() {
|
||||
return window.setTimeout(function() {
|
||||
this.queries += 1;
|
||||
this.el.show();
|
||||
}.bind(this), this.timeout);
|
||||
},
|
||||
hide: function(timeoutID) {
|
||||
window.clearTimeout(timeoutID);
|
||||
if (this.queries > 0) {
|
||||
this.queries -= 1;
|
||||
}
|
||||
if (this.queries <= 0) {
|
||||
this.queries = 0;
|
||||
this.hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
Sao.common.processing = new Sao.common.Processing();
|
||||
|
||||
}());
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
var params = jQuery.extend([], args.params);
|
||||
params.push(jQuery.extend({}, session.context, params.pop()));
|
||||
|
||||
var timeoutID = Sao.common.processing.show();
|
||||
var ajax_prm = jQuery.ajax({
|
||||
'contentType': 'application/json',
|
||||
'data': JSON.stringify(Sao.rpc.prepareObject({
|
||||
|
@ -19,7 +20,10 @@
|
|||
})),
|
||||
'dataType': 'json',
|
||||
'url': '/' + (session.database || ''),
|
||||
'type': 'post'
|
||||
'type': 'post',
|
||||
'complete': [function() {
|
||||
Sao.common.processing.hide(timeoutID);
|
||||
}]
|
||||
});
|
||||
|
||||
var ajax_success = function(data) {
|
||||
|
|
|
@ -96,3 +96,10 @@
|
|||
text-align: right;
|
||||
}
|
||||
}
|
||||
|
||||
#processing {
|
||||
position: fixed;
|
||||
top: 0px;
|
||||
width: 100%;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue