@@ -53,33 +53,37 @@ define([
5353 let that = this ;
5454 // open file event for data
5555 $ ( this . wrapSelector ( '#vp_wcOpenFile' ) ) . on ( 'click' , function ( ) {
56- let fileNavi = new FileNavigation ( {
57- type : 'open' ,
58- extensions : [ 'txt' ] ,
59- finish : function ( filesPath , status , error ) {
60- let { file, path} = filesPath [ 0 ] ;
61- that . state . data = path ;
62-
63- that . state . useFile = true ;
64- $ ( that . wrapSelector ( '.vp-wc-file-option' ) ) . show ( ) ;
65- $ ( that . wrapSelector ( '#useFile' ) ) . prop ( 'checked' , true ) ;
66- $ ( that . wrapSelector ( '#useFile' ) ) . trigger ( 'change' ) ;
67-
68- // set text
69- $ ( that . wrapSelector ( '#data' ) ) . val ( path ) ;
70- $ ( that . wrapSelector ( '#data' ) ) . trigger ( 'change' ) ;
71- }
72- } ) ;
73- fileNavi . open ( ) ;
56+ if ( that . state . useFile === true ) {
57+ let fileNavi = new FileNavigation ( {
58+ type : 'open' ,
59+ extensions : [ 'txt' ] ,
60+ finish : function ( filesPath , status , error ) {
61+ let { file, path} = filesPath [ 0 ] ;
62+ that . state . data = path ;
63+
64+ that . state . useFile = true ;
65+ $ ( that . wrapSelector ( '.vp-wc-file-option' ) ) . show ( ) ;
66+ $ ( that . wrapSelector ( '#useFile' ) ) . prop ( 'checked' , true ) ;
67+ $ ( that . wrapSelector ( '#useFile' ) ) . trigger ( 'change' ) ;
68+
69+ // set text
70+ $ ( that . wrapSelector ( '#data' ) ) . val ( path ) ;
71+ $ ( that . wrapSelector ( '#data' ) ) . trigger ( 'change' ) ;
72+ }
73+ } ) ;
74+ fileNavi . open ( ) ;
75+ }
7476 } ) ;
7577
7678 // use file
7779 $ ( this . wrapSelector ( '#useFile' ) ) . on ( 'change' , function ( ) {
7880 let checked = $ ( this ) . prop ( 'checked' ) ;
7981 if ( checked === true ) {
8082 $ ( that . wrapSelector ( '.vp-wc-file-option' ) ) . show ( ) ;
83+ $ ( that . wrapSelector ( '#vp_wcOpenFile' ) ) . show ( ) ;
8184 } else {
8285 $ ( that . wrapSelector ( '.vp-wc-file-option' ) ) . hide ( ) ;
86+ $ ( that . wrapSelector ( '#vp_wcOpenFile' ) ) . hide ( ) ;
8387 }
8488 } ) ;
8589
@@ -116,8 +120,10 @@ define([
116120
117121 if ( this . state . useFile == true ) {
118122 $ ( page ) . find ( '.vp-wc-file-option' ) . show ( ) ;
123+ $ ( page ) . find ( '#vp_wcOpenFile' ) . show ( ) ;
119124 } else {
120125 $ ( page ) . find ( '.vp-wc-file-option' ) . hide ( ) ;
126+ $ ( page ) . find ( '#vp_wcOpenFile' ) . hide ( ) ;
121127 }
122128
123129 let that = this ;
0 commit comments