@@ -99,7 +99,7 @@ define([
99
99
this . category = category ;
100
100
101
101
this . config = {
102
- sizeLevel : 0 , // 0: 400x400 / 1: 500x500 / 2: 600x500 / 3: 750x500
102
+ sizeLevel : 0 , // 0: 400x400 / 1: 500x500 / 2: 600x500 / 3: 750x500 / 4:
103
103
executeMode : 'code' , // cell execute mode
104
104
// show header bar buttons
105
105
installButton : false , // install button (#popupInstall) // FIXME: after creating packagemanager, deprecate it
@@ -112,6 +112,8 @@ define([
112
112
// show footer
113
113
runButton : true ,
114
114
footer : true ,
115
+ // run type : run / run-save / add
116
+ runType : 'run' ,
115
117
// position and size
116
118
position : { right : 10 , top : 120 } ,
117
119
size : { width : 400 , height : 550 } ,
@@ -487,15 +489,53 @@ define([
487
489
case 'save' :
488
490
that . save ( ) ;
489
491
break ;
492
+ case 'run-save' :
493
+ var result = that . run ( ) ;
494
+ if ( result ) {
495
+ that . save ( ) ;
496
+ }
497
+ break ;
498
+ case 'add' :
499
+ var result = that . run ( false ) ;
500
+ if ( result ) {
501
+ // that.save();
502
+ that . close ( ) ;
503
+ }
504
+ break ;
505
+ }
506
+ } ) ;
507
+ // Click detail radio
508
+ $ ( this . wrapSelector ( '.vp-popup-run-type' ) ) . on ( 'click' , function ( evt ) {
509
+ let runType = $ ( that . wrapSelector ( '.vp-popup-run-type[name=runType]:checked' ) ) . val ( ) ;
510
+ that . config . runType = runType ;
511
+ // save as vpConfig
512
+ vpConfig . setData ( { runType : runType } , 'vpcfg' ) ;
513
+ $ ( that . wrapSelector ( '.vp-popup-run-button' ) ) . attr ( 'data-type' , runType ) ;
514
+ let runTitle = 'Run code' ;
515
+ switch ( runType ) {
516
+ case 'run-save' :
517
+ runTitle = 'Save to block & Run code' ;
518
+ break ;
519
+ case 'add' :
520
+ runTitle = 'Add code to cell' ;
521
+ break ;
490
522
}
523
+ $ ( that . wrapSelector ( '.vp-popup-run-button' ) ) . prop ( 'title' , runTitle ) ;
491
524
} ) ;
492
525
// Click detail buttons
493
- $ ( this . wrapSelector ( '.vp-popup-detail-button' ) ) . on ( 'click' , function ( evt ) {
526
+ $ ( this . wrapSelector ( '.vp-popup-detail-action- button' ) ) . on ( 'click' , function ( evt ) {
494
527
var btnType = $ ( this ) . data ( 'type' ) ;
495
528
switch ( btnType ) {
496
529
// case 'apply':
497
530
// that.save();
498
531
// break;
532
+ case 'run' :
533
+ var result = that . run ( ) ;
534
+ if ( result ) {
535
+ // that.save();
536
+ that . close ( ) ;
537
+ }
538
+ break ;
499
539
case 'run-save' :
500
540
var result = that . run ( ) ;
501
541
if ( result ) {
@@ -684,7 +724,30 @@ define([
684
724
$ ( this . wrapSelector ( '.vp-popup-body' ) ) . css ( {
685
725
'height' : 'calc(100% - 30px)'
686
726
} )
727
+ } else {
728
+ // set run button
729
+ let that = this ;
730
+ vpConfig . getData ( 'runType' , 'vpcfg' ) . then ( function ( data ) {
731
+ vpLog . display ( VP_LOG_TYPE . DEVELOP , 'Runtype get data' , data ) ;
732
+ if ( data == null || data === '' ) {
733
+ data = 'run' ; // default = run
734
+ }
735
+ that . config . runType = data ;
736
+ $ ( that . wrapSelector ( `.vp-popup-run-type[value="${ data } "]` ) ) . prop ( 'checked' , true ) ;
737
+ $ ( that . wrapSelector ( '.vp-popup-run-button' ) ) . attr ( 'data-type' , data ) ;
738
+ let runTitle = 'Run code' ;
739
+ switch ( data ) {
740
+ case 'run-save' :
741
+ runTitle = 'Save to block & Run code' ;
742
+ break ;
743
+ case 'add' :
744
+ runTitle = 'Add code to cell' ;
745
+ break ;
746
+ }
747
+ $ ( that . wrapSelector ( '.vp-popup-run-button' ) ) . prop ( 'title' , runTitle ) ;
748
+ } ) ;
687
749
}
750
+
688
751
689
752
// popup-frame size
690
753
switch ( sizeLevel ) {
@@ -698,6 +761,9 @@ define([
698
761
this . config . size = { width : 760 , height : 550 } ;
699
762
break ;
700
763
case 4 :
764
+ this . config . size = { width : 840 , height : 550 } ;
765
+ break ;
766
+ case 5 :
701
767
this . config . size = { width : 1064 , height : 550 } ;
702
768
break ;
703
769
}
0 commit comments