mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Have NProgress called for all ajax calls
fixes #2011 - rather than trigger NProgress for fetch calls I’ve moved it to be used for all sync calls - issue #2011 was a result of NProgress only being called during a fetch() call, which when saving is not used - save() is. Sync is used by all ajax calls.
This commit is contained in:
parent
951385ec2d
commit
0ea22ab8d0
1 changed files with 15 additions and 23 deletions
|
@ -4,37 +4,29 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
NProgress.configure({ showSpinner: false });
|
NProgress.configure({ showSpinner: false });
|
||||||
|
|
||||||
Ghost.ProgressModel = Backbone.Model.extend({
|
|
||||||
|
|
||||||
// Adds in a call to start a loading bar
|
// Adds in a call to start a loading bar
|
||||||
// This is sets up a success function which completes the loading bar
|
// This is sets up a success function which completes the loading bar
|
||||||
fetch : function (options) {
|
function wrapSync(method, model, options) {
|
||||||
options = options || {};
|
if (options !== undefined && _.isObject(options)) {
|
||||||
|
|
||||||
NProgress.start();
|
NProgress.start();
|
||||||
|
|
||||||
|
var self = this,
|
||||||
|
oldSuccess = options.success;
|
||||||
|
|
||||||
options.success = function () {
|
options.success = function () {
|
||||||
NProgress.done();
|
NProgress.done();
|
||||||
|
return oldSuccess.apply(self, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
return Backbone.Model.prototype.fetch.call(this, options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Backbone.sync.call(this, method, model, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ghost.ProgressModel = Backbone.Model.extend({
|
||||||
|
sync: wrapSync
|
||||||
});
|
});
|
||||||
|
|
||||||
Ghost.ProgressCollection = Backbone.Collection.extend({
|
Ghost.ProgressCollection = Backbone.Collection.extend({
|
||||||
|
sync: wrapSync
|
||||||
// Adds in a call to start a loading bar
|
|
||||||
// This is sets up a success function which completes the loading bar
|
|
||||||
fetch : function (options) {
|
|
||||||
options = options || {};
|
|
||||||
|
|
||||||
NProgress.start();
|
|
||||||
|
|
||||||
options.success = function () {
|
|
||||||
NProgress.done();
|
|
||||||
};
|
|
||||||
|
|
||||||
return Backbone.Collection.prototype.fetch.call(this, options);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}());
|
}());
|
Loading…
Add table
Reference in a new issue