@@ -17,38 +17,62 @@ api.spinner.progress.timeout = 0;
17
17
/**
18
18
* Show the Overlay and start the Spinner
19
19
*/
20
- api . spinner . start = function ( ) {
21
- if ( ! api . spinner . count ++ ) {
20
+ api . spinner . start = function ( pItemSpinner = null ) {
21
+ if ( pItemSpinner != null ) {
22
+ //remove existing div
23
+ $ ( pItemSpinner ) . find ( ".item-spinner" ) . remove ( ) ;
24
+ var item = $ ( '#spinner-holder' ) . find ( '.item-spinner' ) . clone ( ) ;
25
+ $ ( pItemSpinner ) . prepend ( $ ( item ) ) ;
26
+
27
+ $ ( item ) . removeClass ( "d-none" ) ;
28
+ $ ( pItemSpinner ) . find ( ".item-spinner" ) . show ( ) ;
29
+
30
+ /** if element changes size then reposition the loader */
31
+ let resizeObserver = new ResizeObserver ( ( ) => {
32
+ //15px is half the circle height
33
+ $ ( pItemSpinner ) . find ( item ) . find ( '.item-loader' ) . css ( 'margin-top' , ( $ ( pItemSpinner ) . height ( ) * 0.5 ) - 15 ) ;
34
+ } ) ;
35
+
36
+ resizeObserver . observe ( $ ( pItemSpinner ) [ 0 ] ) ;
37
+ /**** end of resizing listener */
38
+
39
+ } else if ( ! api . spinner . count ++ ) {
22
40
$ ( "#spinner" ) . show ( ) ;
23
41
}
24
42
} ;
25
43
26
44
/**
27
45
* Hide the Overlay and stop the Spinner
28
46
*/
29
- api . spinner . stop = function ( ) {
30
- if ( api . spinner . count ) {
31
- // Do not go negative
32
- api . spinner . count -- ;
33
- }
47
+ api . spinner . stop = function ( pItemSpinner = null ) {
48
+ if ( pItemSpinner != null ) {
49
+ $ ( pItemSpinner ) . find ( ".item-spinner" ) . find ( '.item-loader' ) . addClass ( 'd-none' ) ;
50
+ $ ( pItemSpinner ) . find ( ".item-spinner" ) . remove ( ) ;
51
+ } else {
52
+ if ( api . spinner . count ) {
53
+ // Do not go negative
54
+ api . spinner . count -- ;
55
+ }
34
56
35
- if ( ! api . spinner . count ) {
36
- if ( api . spinner . progress . instance ) {
37
- // End the progress bar
38
- api . spinner . progress . stop ( ) ;
57
+ if ( ! api . spinner . count ) {
58
+ if ( api . spinner . progress . instance ) {
59
+ // End the progress bar
60
+ api . spinner . progress . stop ( ) ;
39
61
40
- // Close the spinner after 1 second to show 100% in the progress bar
41
- setTimeout ( function ( ) {
62
+ // Close the spinner after 1 second to show 100% in the progress bar
63
+ setTimeout ( function ( ) {
64
+ $ ( "#spinner" ) . fadeOut ( 'slow' ) ;
65
+ } , 1000 ) ;
66
+ }
67
+ else {
68
+ // Close the spinner immediatelly
42
69
$ ( "#spinner" ) . fadeOut ( 'slow' ) ;
43
- } , 1000 ) ;
44
- }
45
- else {
46
- // Close the spinner immediatelly
47
- $ ( "#spinner" ) . fadeOut ( 'slow' ) ;
70
+ }
48
71
}
49
72
}
50
73
} ;
51
74
75
+
52
76
/**
53
77
* Start the iterative Timeout method for the progress bar
54
78
*/
@@ -366,7 +390,7 @@ api.ajax.jsonrpc = {};
366
390
* @param {* } callbackParams_onError
367
391
* @param {* } pAJAX_Params
368
392
*/
369
- api . ajax . jsonrpc . request = function ( pAPI_URL , pAPI_Method , pAPI_Params , callbackFunctionName_onSuccess , callbackParams_onSuccess , callbackFunctionName_onError , callbackParams_onError , pAJAX_Params ) {
393
+ api . ajax . jsonrpc . request = function ( pAPI_URL , pAPI_Method , pAPI_Params , callbackFunctionName_onSuccess , callbackParams_onSuccess , callbackFunctionName_onError , callbackParams_onError , pAJAX_Params , pItemSpinner = null ) {
370
394
// Default API parameters
371
395
pAPI_Params = pAPI_Params || { } ;
372
396
@@ -468,7 +492,7 @@ api.ajax.jsonrpc.request = function (pAPI_URL, pAPI_Method, pAPI_Params, callbac
468
492
complete : function ( ) {
469
493
// Simulate sync behaviour
470
494
if ( simulateSync )
471
- api . spinner . stop ( ) ;
495
+ api . spinner . stop ( pItemSpinner ) ;
472
496
473
497
// Stop the nav loader
474
498
$ ( "#nav-loader" ) . removeClass ( 'text-yellow fa-spin' ) . addClass ( 'text-navbar' ) ;
@@ -486,7 +510,7 @@ api.ajax.jsonrpc.request = function (pAPI_URL, pAPI_Method, pAPI_Params, callbac
486
510
487
511
// Simulate sync behaviour
488
512
if ( simulateSync )
489
- api . spinner . start ( ) ;
513
+ api . spinner . start ( pItemSpinner ) ;
490
514
// Extend the session if any
491
515
api . cookie . session . extend ( ) ;
492
516
0 commit comments