66 * Note : Popup Components for rendering objects
77 * License : GNU GPLv3 with Visual Python special exception
88 * Date : 2021. 11. 18
9- * Change Date :
9+ * Change Date : 2022. 09. 24
1010 */
1111
1212//============================================================================
@@ -21,7 +21,9 @@ define([
2121 '../com_interface' ,
2222 './Component' ,
2323 './DataSelector' ,
24-
24+
25+ // helpview boolean 판단
26+ 'json!vp_base/data/help_data.json' ,
2527
2628
2729 /** codemirror */
@@ -31,7 +33,7 @@ define([
3133 'codemirror/addon/display/placeholder' ,
3234 'codemirror/addon/display/autorefresh'
3335] , function ( popupComponentHtml , popupComponentCss
34- , com_util , com_Const , com_String , com_interface , Component , DataSelector , codemirror
36+ , com_util , com_Const , com_String , com_interface , Component , DataSelector , helpData , codemirror
3537) {
3638 'use strict' ;
3739
@@ -52,7 +54,7 @@ define([
5254 this . name = this . state . config . name ;
5355 this . path = this . state . config . path ;
5456
55-
57+
5658 this . config = {
5759 sizeLevel : 0 , // 0: 400x400 / 1: 500x500 / 2: 600x500 / 3: 750x500
5860 executeMode : 'code' , // cell execute mode
@@ -65,7 +67,7 @@ define([
6567 dataview : true ,
6668
6769 // 220919
68- helpview : true ,
70+ helpview : helpData [ this . name ] ,
6971
7072 // show footer
7173 runButton : true ,
@@ -95,14 +97,40 @@ define([
9597 theme : "ipython" ,
9698 extraKeys : { "Enter" : "newlineAndIndentContinueMarkdownList" }
9799 }
100+
101+ // makrdown codemirror 위한 config 추가
102+ this . cmMarkdownConfig = {
103+ mode : {
104+ name : 'markdown' ,
105+ version : 3 ,
106+ singleLineStringErrors : false
107+ } ,
108+ height : '100%' ,
109+ width : '100%' ,
110+ indentUnit : 4 ,
111+ lineNumbers : true ,
112+ matchBrackets : true ,
113+ autoRefresh : true ,
114+ theme : "markdown" ,
115+ extraKeys : { "Enter" : "newlineAndIndentContinueMarkdownList" }
116+ }
117+
98118 this . cmReadonlyConfig = {
99119 ...this . cmPythonConfig ,
100120 readOnly : true ,
101121 lineNumbers : false ,
102122 scrollbarStyle : "null"
103123 }
104124
125+ this . cmReadonlyHelpConfig = {
126+ ...this . cmMarkdownConfig ,
127+ readOnly : true ,
128+ lineNumbers : false ,
129+ scrollbarStyle : "null"
130+ }
131+
105132 this . cmCodeview = null ;
133+ this . helpViewText = null ;
106134
107135 this . cmCodeList = [ ] ;
108136 }
@@ -185,18 +213,20 @@ define([
185213 } else {
186214 this . cmCodeview . refresh ( ) ;
187215 }
188- } else {
189- if ( ! this . cmCodeview ) {
216+ }
217+
218+ if ( this . config . helpview ) {
219+ if ( ! this . helpViewText ) {
190220 // codemirror setting
191221 let selector = this . wrapSelector ( '.vp-popup-helpview-box textarea' ) ;
192222 let textarea = $ ( selector ) ;
193223 if ( textarea && textarea . length > 0 ) {
194- this . cmCodeview = codemirror . fromTextArea ( textarea [ 0 ] , this . cmReadonlyConfig ) ;
224+ this . helpViewText = codemirror . fromTextArea ( textarea [ 0 ] , this . cmReadonlyHelpConfig ) ;
195225 } else {
196226 vpLog . display ( VP_LOG_TYPE . ERROR , 'No text area to create codemirror. (selector: ' + selector + ')' ) ;
197227 }
198228 } else {
199- this . cmCodeview . refresh ( ) ;
229+ this . helpViewText . refresh ( ) ;
200230 }
201231
202232
@@ -695,9 +725,12 @@ define([
695725 }
696726
697727 generateHelp ( ) {
698- /** Implementation needed */
699- return '' ;
700- }
728+ var helpTextObj = new com_String ( ) ;
729+ var helpComment = helpData [ this . name ] ;
730+ helpTextObj . append ( helpComment ) ;
731+
732+ return helpTextObj . toString ( ) ;
733+ }
701734
702735 load ( ) {
703736
@@ -971,6 +1004,8 @@ define([
9711004 that . cmCodeview . refresh ( ) ;
9721005 } , 1 ) ;
9731006 $ ( this . wrapSelector ( '.vp-popup-dataview-box' ) ) . hide ( ) ;
1007+ $ ( this . wrapSelector ( '.vp-popup-helpview-box' ) ) . hide ( ) ;
1008+
9741009 } else if ( viewType == 'help' ) { // 220919
9751010 this . saveState ( ) ;
9761011 var code = this . generateHelp ( ) ;
@@ -980,17 +1015,23 @@ define([
9801015 } else {
9811016 codeText = code ;
9821017 }
983- this . cmCodeview . setValue ( codeText ) ;
984- this . cmCodeview . save ( ) ;
1018+
1019+ this . helpViewText . setValue ( codeText ) ;
1020+ this . helpViewText . save ( ) ;
9851021
9861022 var that = this ;
9871023 setTimeout ( function ( ) {
988- that . cmCodeview . refresh ( ) ;
1024+ that . helpViewText . refresh ( ) ;
9891025 } , 1 ) ;
990- $ ( this . wrapSelector ( '.vp-popup-helpview-box' ) ) . hide ( ) ;
1026+
1027+ // button 클릭 시, 하나의 팝업만 나타나도록
1028+ $ ( this . wrapSelector ( '.vp-popup-dataview-box' ) ) . hide ( ) ;
1029+ $ ( this . wrapSelector ( '.vp-popup-codeview-box' ) ) . hide ( ) ;
1030+
9911031 } else {
9921032 this . renderDataView ( ) ;
9931033 $ ( this . wrapSelector ( '.vp-popup-codeview-box' ) ) . hide ( ) ;
1034+ $ ( this . wrapSelector ( '.vp-popup-helpview-box' ) ) . hide ( ) ;
9941035 }
9951036
9961037 $ ( this . wrapSelector ( '.vp-popup-' + viewType + 'view-box' ) ) . show ( ) ;
0 commit comments