2013-10-08 19:39:07 +04:00
|
|
|
/*global window, document, setTimeout, Ghost, $, _, Backbone, JST, shortcut, NProgress */
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
"use strict";
|
|
|
|
NProgress.configure({ showSpinner: false });
|
|
|
|
|
2014-01-26 08:46:28 +04:00
|
|
|
// Adds in a call to start a loading bar
|
|
|
|
// This is sets up a success function which completes the loading bar
|
|
|
|
function wrapSync(method, model, options) {
|
|
|
|
if (options !== undefined && _.isObject(options)) {
|
2013-11-23 01:47:03 +04:00
|
|
|
NProgress.start();
|
|
|
|
|
2014-01-26 08:46:28 +04:00
|
|
|
var self = this,
|
|
|
|
oldSuccess = options.success;
|
|
|
|
|
2013-11-23 01:47:03 +04:00
|
|
|
options.success = function () {
|
|
|
|
NProgress.done();
|
2014-01-26 08:46:28 +04:00
|
|
|
return oldSuccess.apply(self, arguments);
|
2013-11-23 01:47:03 +04:00
|
|
|
};
|
|
|
|
}
|
2013-10-08 19:39:07 +04:00
|
|
|
|
2014-01-26 08:46:28 +04:00
|
|
|
return Backbone.sync.call(this, method, model, options);
|
|
|
|
}
|
2013-10-08 19:39:07 +04:00
|
|
|
|
2014-01-26 08:46:28 +04:00
|
|
|
Ghost.ProgressModel = Backbone.Model.extend({
|
|
|
|
sync: wrapSync
|
|
|
|
});
|
2013-10-08 19:39:07 +04:00
|
|
|
|
2014-01-26 08:46:28 +04:00
|
|
|
Ghost.ProgressCollection = Backbone.Collection.extend({
|
|
|
|
sync: wrapSync
|
2013-10-08 19:39:07 +04:00
|
|
|
});
|
|
|
|
}());
|