@@ -19,7 +19,7 @@ api.spinner.progress.timeout = 0;
19
19
*/
20
20
api . spinner . start = function ( ) {
21
21
if ( ! api . spinner . count ++ ) {
22
- $ ( C_API_SELECTOR_SPINNER ) . show ( ) ;
22
+ $ ( "#spinner" ) . show ( ) ;
23
23
}
24
24
} ;
25
25
@@ -39,12 +39,12 @@ api.spinner.stop = function () {
39
39
40
40
// Close the spinner after 1 second to show 100% in the progress bar
41
41
setTimeout ( function ( ) {
42
- $ ( C_API_SELECTOR_SPINNER ) . fadeOut ( 'slow' ) ;
42
+ $ ( "#spinner" ) . fadeOut ( 'slow' ) ;
43
43
} , 1000 ) ;
44
44
}
45
45
else {
46
46
// Close the spinner immediatelly
47
- $ ( C_API_SELECTOR_SPINNER ) . fadeOut ( 'slow' ) ;
47
+ $ ( "#spinner" ) . fadeOut ( 'slow' ) ;
48
48
}
49
49
}
50
50
} ;
@@ -60,9 +60,9 @@ api.spinner.progress.start = function (progressTimeout) {
60
60
api . spinner . progress . timeout = progressTimeout ;
61
61
62
62
// Set progress to 0%
63
- $ ( C_API_SELECTOR_SPINNER + " .progress") . find ( "[name=bar]" ) . css ( 'width' , '1%' ) . attr ( 'aria-valuenow' , 1 ) ;
64
- $ ( C_API_SELECTOR_SPINNER + " .progress") . find ( "[name=percentage]" ) . text ( "1%" ) ;
65
- $ ( C_API_SELECTOR_SPINNER + " .progress") . show ( ) ;
63
+ $ ( "#spinner .progress") . find ( "[name=bar]" ) . css ( 'width' , '1%' ) . attr ( 'aria-valuenow' , 1 ) ;
64
+ $ ( "#spinner .progress") . find ( "[name=percentage]" ) . text ( "1%" ) ;
65
+ $ ( "#spinner .progress") . show ( ) ;
66
66
67
67
// Initiate the progress by setting the timeout
68
68
api . spinner . progress . setTimeout ( ) ;
@@ -76,9 +76,9 @@ api.spinner.progress.stop = function () {
76
76
clearTimeout ( api . spinner . progress . instance ) ;
77
77
78
78
// Set progress to 100%
79
- $ ( C_API_SELECTOR_SPINNER + " .progress") . find ( "[name=bar]" ) . css ( 'width' , '100%' ) . attr ( 'aria-valuenow' , 100 ) ;
80
- $ ( C_API_SELECTOR_SPINNER + " .progress") . find ( "[name=percentage]" ) . text ( "100%" ) ;
81
- $ ( C_API_SELECTOR_SPINNER + " .progress") . fadeOut ( 'slow' ) ;
79
+ $ ( "#spinner .progress") . find ( "[name=bar]" ) . css ( 'width' , '100%' ) . attr ( 'aria-valuenow' , 100 ) ;
80
+ $ ( "#spinner .progress") . find ( "[name=percentage]" ) . text ( "100%" ) ;
81
+ $ ( "#spinner .progress") . fadeOut ( 'slow' ) ;
82
82
} ;
83
83
84
84
/**
@@ -99,9 +99,9 @@ api.spinner.progress.setTimeout = function () {
99
99
100
100
api . spinner . progress . instance = setTimeout ( function ( ) {
101
101
// Never display 100% as it may need longer than expected to complete
102
- var percentage = Math . min ( parseInt ( $ ( C_API_SELECTOR_SPINNER + " .progress") . find ( "[name=bar]" ) . attr ( 'aria-valuenow' ) ) + 1 , 99 ) ;
103
- $ ( C_API_SELECTOR_SPINNER + " .progress") . find ( "[name=bar]" ) . css ( 'width' , percentage + '%' ) . attr ( 'aria-valuenow' , percentage ) ;
104
- $ ( C_API_SELECTOR_SPINNER + " .progress") . find ( "[name=percentage]" ) . text ( percentage + "%" ) ;
102
+ var percentage = Math . min ( parseInt ( $ ( "#spinner .progress") . find ( "[name=bar]" ) . attr ( 'aria-valuenow' ) ) + 1 , 99 ) ;
103
+ $ ( "#spinner .progress") . find ( "[name=bar]" ) . css ( 'width' , percentage + '%' ) . attr ( 'aria-valuenow' , percentage ) ;
104
+ $ ( "#spinner .progress") . find ( "[name=percentage]" ) . text ( percentage + "%" ) ;
105
105
// Loop in
106
106
api . spinner . progress . setTimeout ( ) ;
107
107
} , api . spinner . progress . timeout ) ;
@@ -187,14 +187,14 @@ api.content.navigate = function (pNavSelector, pRelativeURL, pNav_link_SelectorT
187
187
url : pRelativeURL ,
188
188
async : false ,
189
189
success : function ( response ) {
190
- $ ( C_API_SELECTOR_BODY ) . hide ( ) . empty ( ) . html ( response ) . fadeIn ( ) ;
190
+ $ ( '#body' ) . hide ( ) . empty ( ) . html ( response ) . fadeIn ( ) ;
191
191
}
192
192
} ) ;
193
193
194
194
// "show" is a Bootstrap property
195
- $ ( C_API_SELECTOR_NAVIGATION ) . find ( "*" ) . removeClass ( "show" ) ;
195
+ $ ( "#navigation" ) . find ( "*" ) . removeClass ( "show" ) ;
196
196
// "active" is a Bootstrap property
197
- $ ( C_API_SELECTOR_NAVIGATION ) . find ( "*" ) . removeClass ( "active" ) ;
197
+ $ ( "#navigation" ) . find ( "*" ) . removeClass ( "active" ) ;
198
198
199
199
if ( pNav_link_SelectorToHighlight )
200
200
// "active" is a Bootstrap property
@@ -235,16 +235,16 @@ api.content.goTo = function (pRelativeURL, pNav_link_SelectorToHighlight, pNav_m
235
235
async : false ,
236
236
success : function ( response ) {
237
237
api . content . params = pParams ;
238
- $ ( C_API_SELECTOR_BODY ) . hide ( ) . empty ( ) . html ( response ) . fadeIn ( ) . promise ( ) . done ( function ( ) {
238
+ $ ( '#body' ) . hide ( ) . empty ( ) . html ( response ) . fadeIn ( ) . promise ( ) . done ( function ( ) {
239
239
api . content . params = { } ;
240
240
} ) ;
241
241
}
242
242
} ) ;
243
243
244
244
// "show" is a Bootstrap property
245
- $ ( C_API_SELECTOR_NAVIGATION ) . find ( "*" ) . removeClass ( "show" ) ;
245
+ $ ( "#navigation" ) . find ( "*" ) . removeClass ( "show" ) ;
246
246
// "active" is a Bootstrap property
247
- $ ( C_API_SELECTOR_NAVIGATION ) . find ( "*" ) . removeClass ( "active" ) ;
247
+ $ ( "#navigation" ) . find ( "*" ) . removeClass ( "active" ) ;
248
248
249
249
if ( pNav_link_SelectorToHighlight )
250
250
// "active" is a Bootstrap property
@@ -469,7 +469,7 @@ api.ajax.jsonrpc.request = function (pAPI_URL, pAPI_Method, pAPI_Params, callbac
469
469
api . spinner . stop ( ) ;
470
470
471
471
// Stop the nav loader
472
- $ ( C_API_SELECTOR_NAV_LOADER ) . removeClass ( 'text-yellow fa-spin' ) . addClass ( 'text-navbar' ) ;
472
+ $ ( "#nav-loader" ) . removeClass ( 'text-yellow fa-spin' ) . addClass ( 'text-navbar' ) ;
473
473
$ ( "body" ) . css ( "cursor" , "default" ) ;
474
474
}
475
475
}
@@ -479,7 +479,7 @@ api.ajax.jsonrpc.request = function (pAPI_URL, pAPI_Method, pAPI_Params, callbac
479
479
480
480
try {
481
481
// Start the nav loader
482
- $ ( C_API_SELECTOR_NAV_LOADER ) . removeClass ( 'text-navbar' ) . addClass ( 'text-yellow fa-spin' ) ;
482
+ $ ( "#nav-loader" ) . removeClass ( 'text-navbar' ) . addClass ( 'text-yellow fa-spin' ) ;
483
483
$ ( "body" ) . css ( "cursor" , "progress" ) ;
484
484
485
485
// Simulate sync behaviour
@@ -507,25 +507,19 @@ api.modal = {};
507
507
* @param {* } pCallbackParams
508
508
*/
509
509
api . modal . confirm = function ( pMessage , pCallbackMethod , pCallbackParams ) {
510
-
511
510
// Set the body of the Modal - Empty the container first
512
- $ ( C_API_SELECTOR_MODAL_CONFIRM ) . find ( C_API_SELECTOR_MODAL_BODY ) . empty ( ) . html ( pMessage ) ;
513
-
514
- $ ( C_API_SELECTOR_MODAL_BUTTON_CONFIRM ) . on ( "click" , function ( ) {
515
- // Run the Callback function
516
- pCallbackMethod ( pCallbackParams ) ;
511
+ $ ( "#modal-confirm" ) . find ( ".modal-body > p" ) . empty ( ) . html ( pMessage ) ;
517
512
513
+ $ ( "#modal-confirm" ) . find ( "[name=submit]" ) . once ( "click" , function ( ) {
518
514
// Close the Modal
519
- $ ( C_API_SELECTOR_MODAL_CONFIRM ) . modal ( 'hide' ) ;
515
+ $ ( "#modal-confirm" ) . modal ( 'hide' ) ;
516
+ // Must wait for the async transition to finsh before invoking the callback function that may be a cascade confirm
517
+ // Consider refactoring by cloning the confir modal instead.
518
+ new Promise ( resolve => setTimeout ( resolve , 100 ) ) . then ( ( ) => { pCallbackMethod ( pCallbackParams ) ; } ) ;
520
519
} ) ;
521
520
522
- $ ( C_API_SELECTOR_MODAL_CONFIRM ) . on ( 'hide.bs.modal' , function ( e ) {
523
- // Unbind to avoid the callback to loop
524
- $ ( C_API_SELECTOR_MODAL_BUTTON_CONFIRM ) . unbind ( "click" ) ;
525
- } )
526
-
527
521
// Force the modal to re-initialise before displaying in case of cascade confirm modals
528
- $ ( C_API_SELECTOR_MODAL_CONFIRM ) . data ( 'bs. modal' , null ) . modal ( ) ;
522
+ $ ( "# modal-confirm" ) . modal ( ) ;
529
523
} ;
530
524
531
525
/**
@@ -535,10 +529,10 @@ api.modal.confirm = function (pMessage, pCallbackMethod, pCallbackParams) {
535
529
api . modal . success = function ( pMessage ) {
536
530
537
531
// Set the body of the Modal
538
- $ ( C_API_SELECTOR_MODAL_SUCCESS ) . find ( C_API_SELECTOR_MODAL_BODY ) . empty ( ) . html ( pMessage ) ;
532
+ $ ( "#modal-success" ) . find ( ".modal-body > p" ) . empty ( ) . html ( pMessage ) ;
539
533
540
534
// Display the Modal
541
- $ ( C_API_SELECTOR_MODAL_SUCCESS ) . modal ( ) ;
535
+ $ ( "#modal-success" ) . modal ( ) ;
542
536
} ;
543
537
544
538
/**
@@ -548,10 +542,10 @@ api.modal.success = function (pMessage) {
548
542
api . modal . error = function ( pMessage ) {
549
543
550
544
// Set the body of the Modal
551
- $ ( C_API_SELECTOR_MODAL_ERROR ) . find ( C_API_SELECTOR_MODAL_BODY ) . empty ( ) . html ( pMessage ) ;
545
+ $ ( "#modal-error" ) . find ( ".modal-body > p" ) . empty ( ) . html ( pMessage ) ;
552
546
553
547
// Display the Modal
554
- $ ( C_API_SELECTOR_MODAL_ERROR ) . modal ( ) ;
548
+ $ ( "#modal-error" ) . modal ( ) ;
555
549
} ;
556
550
557
551
/**
@@ -561,10 +555,10 @@ api.modal.error = function (pMessage) {
561
555
api . modal . information = function ( pMessage ) {
562
556
563
557
// Set the body of the Modal
564
- $ ( C_API_SELECTOR_MODAL_INFORMATION ) . find ( C_API_SELECTOR_MODAL_BODY ) . empty ( ) . html ( pMessage ) ;
558
+ $ ( "#modal-information" ) . find ( ".modal-body > p" ) . empty ( ) . html ( pMessage ) ;
565
559
566
560
// Display the Modal
567
- $ ( C_API_SELECTOR_MODAL_INFORMATION ) . modal ( ) ;
561
+ $ ( "#modal-information" ) . modal ( ) ;
568
562
} ;
569
563
570
564
/**
@@ -574,10 +568,10 @@ api.modal.information = function (pMessage) {
574
568
api . modal . exception = function ( pMessage ) {
575
569
576
570
// Set the body of the Modal
577
- $ ( C_API_SELECTOR_MODAL_EXCEPTION ) . find ( C_API_SELECTOR_MODAL_BODY ) . empty ( ) . html ( pMessage ) ;
571
+ $ ( "#modal-exception" ) . find ( ".modal-body > p" ) . empty ( ) . html ( pMessage ) ;
578
572
579
573
// Display the Modal
580
- $ ( C_API_SELECTOR_MODAL_EXCEPTION ) . modal ( ) ;
574
+ $ ( "#modal-exception" ) . modal ( ) ;
581
575
} ;
582
576
583
577
0 commit comments