@@ -26,6 +26,8 @@ import cx from 'classnames';
2626import Levenshtein from 'levenshtein' ;
2727import mousetrap from 'mousetrap' ;
2828import assign from 'object-assign' ;
29+ import NProgress from 'nprogress' ;
30+ import 'nprogress/nprogress.css' ;
2931
3032import UnitAPI from 'api/UnitAPI' ;
3133import cookie from 'utils/cookie' ;
@@ -51,6 +53,10 @@ import ReactEditor from './index';
5153// be the actual entry point, entirely superseding the `app` module.
5254PTL . reactEditor = ReactEditor ;
5355
56+ NProgress . configure ( {
57+ parent : '#js-editor-progress' ,
58+ showSpinner : false ,
59+ } ) ;
5460
5561const CTX_STEP = 1 ;
5662
@@ -135,7 +141,6 @@ PTL.editor = {
135141
136142 /* Cached elements */
137143 this . backToBrowserEl = q ( '.js-back-to-browser' ) ;
138- this . $editorActivity = $ ( '#js-editor-act' ) ;
139144 this . $editorBody = $ ( '.js-editor-body' ) ;
140145 this . editorTableEl = q ( '.js-editor-table' ) ;
141146 this . $filterStatus = $ ( '#js-filter-status' ) ;
@@ -166,8 +171,8 @@ PTL.editor = {
166171
167172 this . isUnitDirty = false ;
168173
169- this . isLoading = true ;
170174 this . showActivity ( ) ;
175+ this . isLoading = true ;
171176
172177 this . fetchingOffsets = [ ] ;
173178
@@ -405,9 +410,7 @@ PTL.editor = {
405410 return ;
406411 }
407412
408- this . delayedActivityTimer = setTimeout ( ( ) => {
409- this . showActivity ( ) ;
410- } , 3000 ) ;
413+ this . showActivity ( ) ;
411414 } ) ;
412415 $ ( document ) . ajaxStop ( ( ) => {
413416 clearTimeout ( this . delayedActivityTimer ) ;
@@ -642,7 +645,6 @@ PTL.editor = {
642645 this . isUnitDirty = false ;
643646 this . keepState = false ;
644647 this . isLoading = false ;
645- this . hideActivity ( ) ;
646648 } ,
647649
648650 /* Things to do when no results are returned */
@@ -1028,11 +1030,18 @@ PTL.editor = {
10281030
10291031 showActivity ( ) {
10301032 this . hideMsg ( ) ;
1031- this . $editorActivity . spin ( ) . fadeIn ( 300 ) ;
1033+ if ( this . isLoading ) {
1034+ return ;
1035+ }
1036+ clearTimeout ( this . delayedActivityTimer ) ;
1037+ this . delayedActivityTimer = setTimeout ( ( ) => NProgress . start ( ) , 2000 ) ;
10321038 } ,
10331039
10341040 hideActivity ( ) {
1035- this . $editorActivity . spin ( false ) . fadeOut ( 300 ) ;
1041+ if ( ! this . isLoading ) {
1042+ clearTimeout ( this . delayedActivityTimer ) ;
1043+ NProgress . done ( ) ;
1044+ }
10361045 } ,
10371046
10381047 /* Displays an informative message */
0 commit comments