diff --git a/Gruntfile.js b/Gruntfile.js index 413b0a7440..64fd1d38e4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -512,6 +512,7 @@ var path = require('path'), 'bower_components/jquery-ui/ui/jquery-ui.js', 'bower_components/jquery-file-upload/js/jquery.fileupload.js', + 'bower_components/nprogress/nprogress.js', 'core/shared/lib/showdown/extensions/ghostimagepreview.js', 'core/shared/lib/showdown/extensions/ghostgfm.js', diff --git a/core/client/.jshintrc b/core/client/.jshintrc index 60ed532972..18c4e9e734 100644 --- a/core/client/.jshintrc +++ b/core/client/.jshintrc @@ -29,6 +29,7 @@ "$": true, "validator": true, "ic": true, - "_": true + "_": true, + "NProgress": true } } diff --git a/core/client/mixins/editor-route-base.js b/core/client/mixins/editor-route-base.js index bbf78bc3bc..e31b86273c 100644 --- a/core/client/mixins/editor-route-base.js +++ b/core/client/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/core/client/mixins/loading-indicator.js b/core/client/mixins/loading-indicator.js new file mode 100644 index 0000000000..3811a47b4d --- /dev/null +++ b/core/client/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/core/client/routes/debug.js b/core/client/routes/debug.js index f3983d3bf9..b63eba2f6d 100644 --- a/core/client/routes/debug.js +++ b/core/client/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/core/client/routes/forgotten.js b/core/client/routes/forgotten.js index 77f63825cd..90c816e2ab 100644 --- a/core/client/routes/forgotten.js +++ b/core/client/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/core/client/routes/posts.js b/core/client/routes/posts.js index 6d987a8fcd..1d3539d5b4 100644 --- a/core/client/routes/posts.js +++ b/core/client/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/core/client/routes/posts/index.js b/core/client/routes/posts/index.js index 532d35218d..03a49e76d4 100644 --- a/core/client/routes/posts/index.js +++ b/core/client/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/core/client/routes/posts/post.js b/core/client/routes/posts/post.js index f02bc873b6..a85d0d89c8 100644 --- a/core/client/routes/posts/post.js +++ b/core/client/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/core/client/routes/reset.js b/core/client/routes/reset.js index 7aa2b54542..c938105cdc 100644 --- a/core/client/routes/reset.js +++ b/core/client/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/core/client/routes/settings.js b/core/client/routes/settings.js index df7e782f1e..ee382dc879 100644 --- a/core/client/routes/settings.js +++ b/core/client/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/core/client/routes/settings/general.js b/core/client/routes/settings/general.js index bc91262b01..8162322fca 100644 --- a/core/client/routes/settings/general.js +++ b/core/client/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/core/client/routes/signin.js b/core/client/routes/signin.js index 32b42325aa..d805c1e50c 100644 --- a/core/client/routes/signin.js +++ b/core/client/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/core/client/routes/signout.js b/core/client/routes/signout.js index 57f1a589b7..6d7e086b36 100644 --- a/core/client/routes/signout.js +++ b/core/client/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/core/client/routes/signup.js b/core/client/routes/signup.js index acf7d64cb1..0ae6f2f5f1 100644 --- a/core/client/routes/signup.js +++ b/core/client/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/core/client/templates/loading.hbs b/core/client/templates/loading.hbs deleted file mode 100644 index f415d5595d..0000000000 --- a/core/client/templates/loading.hbs +++ /dev/null @@ -1 +0,0 @@ -

Loading...