@@ -487,22 +487,7 @@ define([
487
487
// set run button
488
488
vpConfig . getData ( 'runType' , 'vpcfg' ) . then ( function ( data ) {
489
489
vpLog . display ( VP_LOG_TYPE . DEVELOP , 'Runtype get data' , data ) ;
490
- if ( data == undefined || data == null || data === '' ) {
491
- data = 'run' ; // default = run
492
- }
493
- that . config . runType = data ;
494
- $ ( that . wrapSelector ( `.vp-popup-run-type[value="${ data } "]` ) ) . prop ( 'checked' , true ) ;
495
- $ ( that . wrapSelector ( '.vp-popup-run-button' ) ) . attr ( 'data-type' , data ) ;
496
- let runTitle = 'Run code' ;
497
- switch ( data ) {
498
- case 'run-save' :
499
- runTitle = 'Save to block & Run code' ;
500
- break ;
501
- case 'add' :
502
- runTitle = 'Add code to cell' ;
503
- break ;
504
- }
505
- $ ( that . wrapSelector ( '.vp-popup-run-button' ) ) . prop ( 'title' , runTitle ) ;
490
+ that . _setDefaultRunType ( data ) ;
506
491
} ) ;
507
492
evt . stopPropagation ( ) ;
508
493
break ;
@@ -527,24 +512,15 @@ define([
527
512
// Click detail radio
528
513
$ ( this . wrapSelector ( '.vp-popup-run-type' ) ) . on ( 'click' , function ( evt ) {
529
514
let runType = $ ( that . wrapSelector ( '.vp-popup-run-type[name=runType]:checked' ) ) . val ( ) ;
530
- that . config . runType = runType ;
531
515
// save as vpConfig
532
516
vpConfig . setData ( { runType : runType } , 'vpcfg' ) ;
533
- $ ( that . wrapSelector ( '.vp-popup-run-button' ) ) . attr ( 'data-type' , runType ) ;
534
- let runTitle = 'Run code' ;
535
- switch ( runType ) {
536
- case 'run-save' :
537
- runTitle = 'Save to block & Run code' ;
538
- break ;
539
- case 'add' :
540
- runTitle = 'Add code to cell' ;
541
- break ;
542
- }
543
- $ ( that . wrapSelector ( '.vp-popup-run-button' ) ) . prop ( 'title' , runTitle ) ;
517
+ that . _setDefaultRunType ( runType ) ;
544
518
} ) ;
545
519
// Click detail buttons
546
520
$ ( this . wrapSelector ( '.vp-popup-detail-action-button' ) ) . on ( 'click' , function ( evt ) {
547
521
var btnType = $ ( this ) . data ( 'type' ) ;
522
+ vpConfig . setData ( { runType : runType } , 'vpcfg' ) ;
523
+ that . _setDefaultRunType ( btnType ) ; // run, run-save, add
548
524
switch ( btnType ) {
549
525
// case 'apply':
550
526
// that.save();
@@ -749,22 +725,7 @@ define([
749
725
let that = this ;
750
726
vpConfig . getData ( 'runType' , 'vpcfg' ) . then ( function ( data ) {
751
727
vpLog . display ( VP_LOG_TYPE . DEVELOP , 'Runtype get data' , data ) ;
752
- if ( data == undefined || data == null || data === '' ) {
753
- data = 'run' ; // default = run
754
- }
755
- that . config . runType = data ;
756
- $ ( that . wrapSelector ( `.vp-popup-run-type[value="${ data } "]` ) ) . prop ( 'checked' , true ) ;
757
- $ ( that . wrapSelector ( '.vp-popup-run-button' ) ) . attr ( 'data-type' , data ) ;
758
- let runTitle = 'Run code' ;
759
- switch ( data ) {
760
- case 'run-save' :
761
- runTitle = 'Save to block & Run code' ;
762
- break ;
763
- case 'add' :
764
- runTitle = 'Add code to cell' ;
765
- break ;
766
- }
767
- $ ( that . wrapSelector ( '.vp-popup-run-button' ) ) . prop ( 'title' , runTitle ) ;
728
+ that . _setDefaultRunType ( data ) ;
768
729
} ) ;
769
730
}
770
731
@@ -911,6 +872,25 @@ define([
911
872
vpLog . display ( VP_LOG_TYPE . DEVELOP , 'savedState' , that . state ) ;
912
873
}
913
874
875
+ _setDefaultRunType ( runType ) {
876
+ if ( runType == undefined || runType == null || runType === '' ) {
877
+ runType = 'run' ; // default = run
878
+ }
879
+ this . config . runType = runType ;
880
+ $ ( this . wrapSelector ( `.vp-popup-run-type[value="${ runType } "]` ) ) . prop ( 'checked' , true ) ;
881
+ $ ( this . wrapSelector ( '.vp-popup-run-button' ) ) . attr ( 'data-type' , runType ) ;
882
+ let runTitle = 'Run code' ; // when runType is 'run'
883
+ switch ( runType ) {
884
+ case 'run-save' :
885
+ runTitle = 'Save to block & Run code' ;
886
+ break ;
887
+ case 'add' :
888
+ runTitle = 'Add code to cell' ;
889
+ break ;
890
+ }
891
+ $ ( this . wrapSelector ( '.vp-popup-run-button' ) ) . prop ( 'title' , runTitle ) ;
892
+ }
893
+
914
894
_getTagValue ( tag ) {
915
895
let id = tag . id ;
916
896
let tagName = $ ( tag ) . prop ( 'tagName' ) ; // returns with UpperCase
0 commit comments