@@ -308,6 +308,22 @@ define([
308
308
309
309
_bindEvent ( ) {
310
310
var that = this ;
311
+ // Popup click / focus event
312
+ $ ( this . wrapSelector ( ) ) . on ( 'click focus' , function ( evt ) {
313
+ // Close on blur
314
+ if ( $ ( that . wrapSelector ( '.vp-popup-button' ) ) . find ( evt . target ) . length == 0 ) {
315
+ if ( ! $ ( evt . target ) . hasClass ( 'vp-popup-codeview-box' )
316
+ && $ ( that . wrapSelector ( '.vp-popup-codeview-box' ) ) . find ( evt . target ) . length == 0 ) {
317
+ that . closeView ( 'code' ) ;
318
+ }
319
+ }
320
+ if ( $ ( that . wrapSelector ( '.vp-popup-button' ) ) . find ( evt . target ) . length == 0 ) {
321
+ if ( ! $ ( evt . target ) . hasClass ( 'vp-popup-dataview-box' )
322
+ && $ ( that . wrapSelector ( '.vp-popup-dataview-box' ) ) . find ( evt . target ) . length == 0 ) {
323
+ that . closeView ( 'data' ) ;
324
+ }
325
+ }
326
+ } ) ;
311
327
// Close popup event
312
328
$ ( this . wrapSelector ( '.vp-popup-close' ) ) . on ( 'click' , function ( evt ) {
313
329
if ( that . getTaskType ( ) === 'task' ) {
@@ -514,6 +530,14 @@ define([
514
530
}
515
531
} ) ;
516
532
533
+ // blur on code, dataview
534
+ $ ( this . wrapSelector ( '.vp-popup-codeview-box' ) ) . on ( 'hide' , function ( ) {
535
+ that . closeView ( 'code' ) ;
536
+ } ) ;
537
+ $ ( this . wrapSelector ( '.vp-popup-dataview-box' ) ) . on ( 'hide' , function ( ) {
538
+ that . closeView ( 'data' ) ;
539
+ } ) ;
540
+
517
541
// focus on data selector input
518
542
$ ( this . wrapSelector ( '.vp-data-selector' ) ) . on ( 'focus' , function ( evt ) {
519
543
@@ -1154,20 +1178,36 @@ define([
1154
1178
setTimeout ( function ( ) {
1155
1179
that . cmCodeview . refresh ( ) ;
1156
1180
} , 1 ) ;
1157
- $ ( this . wrapSelector ( '.vp-popup-dataview-box' ) ) . hide ( ) ;
1181
+ this . closeView ( 'data' ) ;
1158
1182
$ ( this . wrapSelector ( '.vp-popup-codeview-box' ) ) . show ( ) ;
1159
1183
} else if ( viewType === 'data' ) {
1160
1184
this . renderDataView ( ) ;
1161
- $ ( this . wrapSelector ( '.vp-popup-codeview-box' ) ) . hide ( ) ;
1185
+ this . closeView ( 'code' ) ;
1162
1186
$ ( this . wrapSelector ( '.vp-popup-dataview-box' ) ) . show ( ) ;
1163
1187
} else if ( viewType === 'help' ) {
1164
- $ ( this . wrapSelector ( '.vp-popup-codeview-box' ) ) . hide ( ) ;
1165
- $ ( this . wrapSelector ( '.vp-popup-dataview-box' ) ) . hide ( ) ;
1188
+ this . closeView ( 'code' ) ;
1189
+ this . closeView ( 'data' ) ;
1166
1190
this . openHelpView ( ) ;
1167
1191
}
1168
1192
}
1169
1193
1170
1194
closeView ( viewType ) {
1195
+ if ( viewType === 'code' ) {
1196
+ // reset codeview
1197
+ if ( this . cmCodeview ) {
1198
+ this . cmCodeview . setValue ( '' ) ;
1199
+ this . cmCodeview . save ( ) ;
1200
+
1201
+ var that = this ;
1202
+ setTimeout ( function ( ) {
1203
+ that . cmCodeview . refresh ( ) ;
1204
+ } , 1 ) ;
1205
+ }
1206
+ } else if ( viewType === 'data' ) {
1207
+ // reset dataview
1208
+ $ ( this . wrapSelector ( '.vp-popup-dataview-box' ) ) . html ( '' ) ;
1209
+ }
1210
+ // hide view
1171
1211
$ ( this . wrapSelector ( '.vp-popup-' + viewType + 'view-box' ) ) . hide ( ) ;
1172
1212
}
1173
1213
0 commit comments