Add loading indicator

review10171002
This commit is contained in:
Nicolas ?vrard 2015-02-20 11:30:11 +01:00
parent e31f655f9e
commit cf8fa97b53
3 changed files with 49 additions and 1 deletions

View file

@ -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();
}());

View file

@ -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) {

View file

@ -96,3 +96,10 @@
text-align: right;
}
}
#processing {
position: fixed;
top: 0px;
width: 100%;
z-index: 1000;
}