@@ -99,7 +99,7 @@ define([
9999 this . category = category ;
100100
101101 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:
103103 executeMode : 'code' , // cell execute mode
104104 // show header bar buttons
105105 installButton : false , // install button (#popupInstall) // FIXME: after creating packagemanager, deprecate it
@@ -112,6 +112,8 @@ define([
112112 // show footer
113113 runButton : true ,
114114 footer : true ,
115+ // run type : run / run-save / add
116+ runType : 'run' ,
115117 // position and size
116118 position : { right : 10 , top : 120 } ,
117119 size : { width : 400 , height : 550 } ,
@@ -487,15 +489,53 @@ define([
487489 case 'save' :
488490 that . save ( ) ;
489491 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 ;
490522 }
523+ $ ( that . wrapSelector ( '.vp-popup-run-button' ) ) . prop ( 'title' , runTitle ) ;
491524 } ) ;
492525 // 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 ) {
494527 var btnType = $ ( this ) . data ( 'type' ) ;
495528 switch ( btnType ) {
496529 // case 'apply':
497530 // that.save();
498531 // break;
532+ case 'run' :
533+ var result = that . run ( ) ;
534+ if ( result ) {
535+ // that.save();
536+ that . close ( ) ;
537+ }
538+ break ;
499539 case 'run-save' :
500540 var result = that . run ( ) ;
501541 if ( result ) {
@@ -684,7 +724,30 @@ define([
684724 $ ( this . wrapSelector ( '.vp-popup-body' ) ) . css ( {
685725 'height' : 'calc(100% - 30px)'
686726 } )
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+ } ) ;
687749 }
750+
688751
689752 // popup-frame size
690753 switch ( sizeLevel ) {
@@ -698,6 +761,9 @@ define([
698761 this . config . size = { width : 760 , height : 550 } ;
699762 break ;
700763 case 4 :
764+ this . config . size = { width : 840 , height : 550 } ;
765+ break ;
766+ case 5 :
701767 this . config . size = { width : 1064 , height : 550 } ;
702768 break ;
703769 }
0 commit comments