diff --git a/ghost/admin/.jshintrc b/ghost/admin/.jshintrc index 60ed532972..18c4e9e734 100644 --- a/ghost/admin/.jshintrc +++ b/ghost/admin/.jshintrc @@ -29,6 +29,7 @@ "$": true, "validator": true, "ic": true, - "_": true + "_": true, + "NProgress": true } } diff --git a/ghost/admin/mixins/editor-route-base.js b/ghost/admin/mixins/editor-route-base.js index bbf78bc3bc..e31b86273c 100644 --- a/ghost/admin/mixins/editor-route-base.js +++ b/ghost/admin/mixins/editor-route-base.js @@ -1,8 +1,9 @@ import ShortcutsRoute from 'ghost/mixins/shortcuts-route'; import styleBody from 'ghost/mixins/style-body'; - +import loadingIndicator from 'ghost/mixins/loading-indicator'; -var EditorRouteBase = Ember.Mixin.create(styleBody, ShortcutsRoute, { + +var EditorRouteBase = Ember.Mixin.create(styleBody, ShortcutsRoute, loadingIndicator, { actions: { save: function () { this.get('controller').send('save'); @@ -54,4 +55,4 @@ var EditorRouteBase = Ember.Mixin.create(styleBody, ShortcutsRoute, { } }); -export default EditorRouteBase; \ No newline at end of file +export default EditorRouteBase; diff --git a/ghost/admin/mixins/loading-indicator.js b/ghost/admin/mixins/loading-indicator.js new file mode 100644 index 0000000000..3811a47b4d --- /dev/null +++ b/ghost/admin/mixins/loading-indicator.js @@ -0,0 +1,25 @@ +// mixin used for routes to display a loading indicator when there is network activity +var loaderOptions = { + 'showSpinner': false +}; +NProgress.configure(loaderOptions); + +var loadingIndicator = Ember.Mixin.create({ + actions: { + + loading: function () { + NProgress.start(); + this.router.one('didTransition', function () { + NProgress.done(); + }); + return true; + }, + + error: function () { + NProgress.done(); + return true; + } + } +}); + +export default loadingIndicator; \ No newline at end of file diff --git a/ghost/admin/routes/debug.js b/ghost/admin/routes/debug.js index f3983d3bf9..b63eba2f6d 100644 --- a/ghost/admin/routes/debug.js +++ b/ghost/admin/routes/debug.js @@ -1,8 +1,9 @@ import styleBody from 'ghost/mixins/style-body'; import AuthenticatedRoute from 'ghost/routes/authenticated'; import SettingsModel from 'ghost/models/settings'; +import loadingIndicator from 'ghost/mixins/loading-indicator'; -export default AuthenticatedRoute.extend(styleBody, { +export default AuthenticatedRoute.extend(styleBody, loadingIndicator, { classNames: ['settings'], model: function () { diff --git a/ghost/admin/routes/forgotten.js b/ghost/admin/routes/forgotten.js index 77f63825cd..90c816e2ab 100644 --- a/ghost/admin/routes/forgotten.js +++ b/ghost/admin/routes/forgotten.js @@ -1,6 +1,7 @@ import styleBody from 'ghost/mixins/style-body'; +import loadingIndicator from 'ghost/mixins/loading-indicator'; -var ForgottenRoute = Ember.Route.extend(styleBody, { +var ForgottenRoute = Ember.Route.extend(styleBody, loadingIndicator, { classNames: ['ghost-forgotten'] }); diff --git a/ghost/admin/routes/posts.js b/ghost/admin/routes/posts.js index 6d987a8fcd..1d3539d5b4 100644 --- a/ghost/admin/routes/posts.js +++ b/ghost/admin/routes/posts.js @@ -1,6 +1,7 @@ import AuthenticatedRoute from 'ghost/routes/authenticated'; import styleBody from 'ghost/mixins/style-body'; import ShortcutsRoute from 'ghost/mixins/shortcuts-route'; +import loadingIndicator from 'ghost/mixins/loading-indicator'; var paginationSettings = { status: 'all', @@ -8,7 +9,7 @@ var paginationSettings = { page: 1 }; -var PostsRoute = AuthenticatedRoute.extend(ShortcutsRoute, styleBody, { +var PostsRoute = AuthenticatedRoute.extend(ShortcutsRoute, styleBody, loadingIndicator, { classNames: ['manage'], model: function () { diff --git a/ghost/admin/routes/posts/index.js b/ghost/admin/routes/posts/index.js index 532d35218d..03a49e76d4 100644 --- a/ghost/admin/routes/posts/index.js +++ b/ghost/admin/routes/posts/index.js @@ -1,6 +1,7 @@ import AuthenticatedRoute from 'ghost/routes/authenticated'; +import loadingIndicator from 'ghost/mixins/loading-indicator'; -var PostsIndexRoute = AuthenticatedRoute.extend({ +var PostsIndexRoute = AuthenticatedRoute.extend(loadingIndicator, { // redirect to first post subroute beforeModel: function () { var self = this; diff --git a/ghost/admin/routes/posts/post.js b/ghost/admin/routes/posts/post.js index f02bc873b6..a85d0d89c8 100644 --- a/ghost/admin/routes/posts/post.js +++ b/ghost/admin/routes/posts/post.js @@ -1,6 +1,7 @@ import AuthenticatedRoute from 'ghost/routes/authenticated'; +import loadingIndicator from 'ghost/mixins/loading-indicator'; -var PostsPostRoute = AuthenticatedRoute.extend({ +var PostsPostRoute = AuthenticatedRoute.extend(loadingIndicator, { model: function (params) { var self = this, post, diff --git a/ghost/admin/routes/reset.js b/ghost/admin/routes/reset.js index 7aa2b54542..c938105cdc 100644 --- a/ghost/admin/routes/reset.js +++ b/ghost/admin/routes/reset.js @@ -1,6 +1,7 @@ import styleBody from 'ghost/mixins/style-body'; +import loadingIndicator from 'ghost/mixins/loading-indicator'; -var ResetRoute = Ember.Route.extend(styleBody, { +var ResetRoute = Ember.Route.extend(styleBody, loadingIndicator, { classNames: ['ghost-reset'], setupController: function (controller, params) { controller.token = params.token; diff --git a/ghost/admin/routes/settings.js b/ghost/admin/routes/settings.js index df7e782f1e..ee382dc879 100644 --- a/ghost/admin/routes/settings.js +++ b/ghost/admin/routes/settings.js @@ -1,7 +1,8 @@ import styleBody from 'ghost/mixins/style-body'; import AuthenticatedRoute from 'ghost/routes/authenticated'; +import loadingIndicator from 'ghost/mixins/loading-indicator'; -var SettingsRoute = AuthenticatedRoute.extend(styleBody, { +var SettingsRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, { classNames: ['settings'] }); diff --git a/ghost/admin/routes/settings/general.js b/ghost/admin/routes/settings/general.js index bc91262b01..8162322fca 100644 --- a/ghost/admin/routes/settings/general.js +++ b/ghost/admin/routes/settings/general.js @@ -1,6 +1,7 @@ import AuthenticatedRoute from 'ghost/routes/authenticated'; +import loadingIndicator from 'ghost/mixins/loading-indicator'; -var SettingsGeneralRoute = AuthenticatedRoute.extend({ +var SettingsGeneralRoute = AuthenticatedRoute.extend(loadingIndicator, { model: function () { return this.store.find('setting', { type: 'blog,theme' }).then(function (records) { return records.get('firstObject'); diff --git a/ghost/admin/routes/signin.js b/ghost/admin/routes/signin.js index 32b42325aa..d805c1e50c 100644 --- a/ghost/admin/routes/signin.js +++ b/ghost/admin/routes/signin.js @@ -1,9 +1,10 @@ import ajax from 'ghost/utils/ajax'; import styleBody from 'ghost/mixins/style-body'; +import loadingIndicator from 'ghost/mixins/loading-indicator'; var isEmpty = Ember.isEmpty; -var SigninRoute = Ember.Route.extend(styleBody, { +var SigninRoute = Ember.Route.extend(styleBody, loadingIndicator, { classNames: ['ghost-login'], actions: { diff --git a/ghost/admin/routes/signout.js b/ghost/admin/routes/signout.js index 57f1a589b7..6d7e086b36 100644 --- a/ghost/admin/routes/signout.js +++ b/ghost/admin/routes/signout.js @@ -1,8 +1,9 @@ import ajax from 'ghost/utils/ajax'; import styleBody from 'ghost/mixins/style-body'; import AuthenticatedRoute from 'ghost/routes/authenticated'; +import loadingIndicator from 'ghost/mixins/loading-indicator'; -var SignoutRoute = AuthenticatedRoute.extend(styleBody, { +var SignoutRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, { classNames: ['ghost-signout'], beforeModel: function () { diff --git a/ghost/admin/routes/signup.js b/ghost/admin/routes/signup.js index acf7d64cb1..0ae6f2f5f1 100644 --- a/ghost/admin/routes/signup.js +++ b/ghost/admin/routes/signup.js @@ -1,7 +1,8 @@ import ajax from 'ghost/utils/ajax'; import styleBody from 'ghost/mixins/style-body'; +import loadingIndicator from 'ghost/mixins/loading-indicator'; -var SignupRoute = Ember.Route.extend(styleBody, { +var SignupRoute = Ember.Route.extend(styleBody, loadingIndicator, { classNames: ['ghost-signup'], name: null, diff --git a/ghost/admin/templates/loading.hbs b/ghost/admin/templates/loading.hbs deleted file mode 100644 index f415d5595d..0000000000 --- a/ghost/admin/templates/loading.hbs +++ /dev/null @@ -1 +0,0 @@ -