Skip to content

Commit d4e9c34

Browse files
author
minjk-bl
committed
Edit Codeview, DataView not to save its content after hide
1 parent d3434e9 commit d4e9c34

File tree

2 files changed

+46
-6
lines changed

2 files changed

+46
-6
lines changed

visualpython/html/component/popupComponent.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@
9191
<div class="vp-popup-footer">
9292
<!-- Footer -->
9393
<!-- Data view box -->
94-
<div class="vp-popup-dataview-box vp-close-on-blur vp-scrollbar">
94+
<div class="vp-popup-dataview-box vp-scrollbar">
9595

9696
</div>
9797
<!-- Code view box -->
98-
<div class="vp-popup-codeview-box vp-close-on-blur vp-scrollbar">
98+
<div class="vp-popup-codeview-box vp-scrollbar">
9999
<textarea name="code"></textarea>
100100
</div>
101101
<!-- Button box -->

visualpython/js/com/component/PopupComponent.js

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,22 @@ define([
308308

309309
_bindEvent() {
310310
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+
});
311327
// Close popup event
312328
$(this.wrapSelector('.vp-popup-close')).on('click', function(evt) {
313329
if (that.getTaskType() === 'task') {
@@ -514,6 +530,14 @@ define([
514530
}
515531
});
516532

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+
517541
// focus on data selector input
518542
$(this.wrapSelector('.vp-data-selector')).on('focus', function(evt) {
519543

@@ -1154,20 +1178,36 @@ define([
11541178
setTimeout(function() {
11551179
that.cmCodeview.refresh();
11561180
}, 1);
1157-
$(this.wrapSelector('.vp-popup-dataview-box')).hide();
1181+
this.closeView('data');
11581182
$(this.wrapSelector('.vp-popup-codeview-box')).show();
11591183
} else if (viewType === 'data') {
11601184
this.renderDataView();
1161-
$(this.wrapSelector('.vp-popup-codeview-box')).hide();
1185+
this.closeView('code');
11621186
$(this.wrapSelector('.vp-popup-dataview-box')).show();
11631187
} 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');
11661190
this.openHelpView();
11671191
}
11681192
}
11691193

11701194
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
11711211
$(this.wrapSelector('.vp-popup-'+viewType+'view-box')).hide();
11721212
}
11731213

0 commit comments

Comments
 (0)