Skip to content

Commit 67a3831

Browse files
author
minjk-bl
committed
disable esc shortcut for popup apps when jupyter focused
1 parent e9d3658 commit 67a3831

File tree

5 files changed

+58
-25
lines changed

5 files changed

+58
-25
lines changed

src/api_block/blockContainer.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -621,11 +621,11 @@ define([
621621
*/
622622
BlockContainer.prototype.setFocusedPageType = function(focusedPageType) {
623623
// 추가: FOCUSED_PAGE_TYPE = NULL일 경우 주피터 단축키 활성화 / 아닐 경우 비활성화
624-
if (focusedPageType == FOCUSED_PAGE_TYPE.NULL) {
625-
// Jupyter.notebook.keyboard_manager.enable();
626-
} else {
627-
// Jupyter.notebook.keyboard_manager.disable();
628-
}
624+
// if (focusedPageType == FOCUSED_PAGE_TYPE.NULL) {
625+
// Jupyter.notebook.keyboard_manager.enable();
626+
// } else {
627+
// Jupyter.notebook.keyboard_manager.disable();
628+
// }
629629
this.focusedPageType = focusedPageType;
630630
}
631631
BlockContainer.prototype.getFocusedPageType = function() {

src/api_block/init.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,8 @@ define([
519519
// blockContainer.resetOptionPage();
520520
blockContainer.setFocusedPageType(FOCUSED_PAGE_TYPE.NULL);
521521
});
522+
523+
$(vpCommon.wrapSelector(''))
522524

523525
/** Create block buttons page를 클릭했을 때 */
524526
$(vpCommon.wrapSelector(VP_CLASS_PREFIX + VP_CLASS_APIBLOCK_BUTTONS)).click(function(event) {
@@ -574,7 +576,8 @@ define([
574576
ctrlKey = 17,
575577
cmdKey = 91,
576578
vKey = 86,
577-
cKey = 67;
579+
cKey = 67,
580+
escKey = 27;
578581

579582
$(document).keydown(function(e) {
580583
if (e.keyCode == ctrlKey || e.keyCode == cmdKey) {
@@ -583,12 +586,43 @@ define([
583586
}).keyup(function(e) {
584587
if (e.keyCode == ctrlKey || e.keyCode == cmdKey) {
585588
ctrlDown = false;
589+
console.log(blockContainer.getFocusedPageType());
590+
}
591+
if (e.keyCode == escKey) {
592+
// close popup on esc
593+
if (blockContainer.getFocusedPageType() != FOCUSED_PAGE_TYPE.NULL) {
594+
blockContainer.appsMenu.close();
595+
}
586596
}
587597
}).click(function(e) {
598+
// click event on jupyter side
599+
if ($('#notebook').has(e.target).length > 0) {
600+
blockContainer.setFocusedPageType(FOCUSED_PAGE_TYPE.NULL);
601+
}
602+
// click event on visual python menu tab & button box
603+
if ($(vpCommon.wrapSelector('.vp-apiblock-tab-header')).has(e.target).length > 0
604+
|| $(vpCommon.wrapSelector('.vp-apiblock-board-button-container')).has(e.target).length > 0) {
605+
blockContainer.setFocusedPageType(FOCUSED_PAGE_TYPE.BUTTONS);
606+
}
607+
// click event on popup menu
608+
if ($(vpCommon.wrapSelector('.vp-ds')).has(e.target).length > 0
609+
|| $(vpCommon.wrapSelector('.vp-fe')).has(e.target).length > 0
610+
|| $(vpCommon.wrapSelector('.vp-pp')).has(e.target).length > 0
611+
|| $(vpCommon.wrapSelector('.vp-ds-btn-box')).has(e.target).length > 0
612+
|| $(vpCommon.wrapSelector('.vp-fe-btn-box')).has(e.target).length > 0
613+
|| $(vpCommon.wrapSelector('.vp-pp-btn-box')).has(e.target).length > 0) {
614+
blockContainer.setFocusedPageType(FOCUSED_PAGE_TYPE.OPTION);
615+
}
616+
588617
// check modified
589618
blockContainer.checkModified();
590619
});
591620

621+
// focus event on codemirror of jupyter side
622+
$(document).on('focus', '#notebook .CodeMirror', function(e){
623+
blockContainer.setFocusedPageType(FOCUSED_PAGE_TYPE.NULL);
624+
});
625+
592626
$(document).change($(vpCommon.wrapSelector('.vp-apiblock-option input')), function() {
593627
// check modified
594628
blockContainer.checkModified();

src/common/vpFrameEditor.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ define([
182182
FrameEditor.prototype.close = function() {
183183
this.unbindEvent();
184184
$(this.wrapSelector()).remove();
185+
$(vpCommon.formatString('.{0}.{1}', VP_FE_BTN, this.uuid)).remove();
185186
}
186187

187188
FrameEditor.prototype.init = function(state = undefined) {
@@ -1282,8 +1283,6 @@ define([
12821283
// close popup
12831284
$(document).on('click', this.wrapSelector('.' + VP_FE_CLOSE), function(event) {
12841285
that.close();
1285-
1286-
$(vpCommon.formatString('.{0}.{1}', VP_FE_BTN, this.uuid)).remove();
12871286
// vpCommon.removeHeadScript("vpSubsetEditor");
12881287
});
12891288

@@ -1622,7 +1621,7 @@ define([
16221621

16231622
// click preview
16241623
$(document).on('click', this.wrapSelector('.' + VP_FE_BUTTON_PREVIEW), function(evt) {
1625-
evt.stopPropagation();
1624+
// evt.stopPropagation();
16261625
if (that.previewOpened) {
16271626
that.closePreview();
16281627
} else {
@@ -1632,7 +1631,7 @@ define([
16321631

16331632
// click dataview
16341633
$(document).on('click', this.wrapSelector('.' + VP_FE_BUTTON_DATAVIEW), function(evt) {
1635-
evt.stopPropagation();
1634+
// evt.stopPropagation();
16361635
if (that.dataviewOpened) {
16371636
that.closeDataview();
16381637
} else {
@@ -1714,10 +1713,10 @@ define([
17141713
if (e.keyCode == keyCode.shiftKey) {
17151714
that.keyboardManager.keyCheck.shiftKey = false;
17161715
}
1717-
if (e.keyCode == keyCode.escKey) {
1718-
// close on esc
1719-
that.close();
1720-
}
1716+
// if (e.keyCode == keyCode.escKey) {
1717+
// // close on esc
1718+
// that.close();
1719+
// }
17211720
});
17221721
}
17231722

src/common/vpPopupPage.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ define([
213213

214214
// click preview
215215
$(document).on('click', this.wrapSelector('.' + VP_PP_BUTTON_PREVIEW), function(evt) {
216-
evt.stopPropagation();
216+
// evt.stopPropagation();
217217
if (that.previewOpened) {
218218
that.closePreview();
219219
} else {
@@ -291,10 +291,10 @@ define([
291291
if (e.keyCode == keyCode.shiftKey) {
292292
that.keyboardManager.keyCheck.shiftKey = false;
293293
}
294-
if (e.keyCode == keyCode.escKey) {
295-
// close on esc
296-
that.close();
297-
}
294+
// if (e.keyCode == keyCode.escKey) {
295+
// // close on esc
296+
// that.close();
297+
// }
298298
});
299299
}
300300

src/common/vpSubsetEditor.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,7 +1823,7 @@ define([
18231823

18241824
// click preview
18251825
$(document).on('click', this.wrapSelector('.' + VP_DS_BUTTON_PREVIEW), function(evt) {
1826-
evt.stopPropagation();
1826+
// evt.stopPropagation();
18271827
if (that.previewOpened) {
18281828
that.closePreview();
18291829
} else {
@@ -1833,7 +1833,7 @@ define([
18331833

18341834
// click dataview
18351835
$(document).on('click', this.wrapSelector('.' + VP_DS_BUTTON_DATAVIEW), function(evt) {
1836-
evt.stopPropagation();
1836+
// evt.stopPropagation();
18371837
if (that.dataviewOpened) {
18381838
that.closeDataview();
18391839
} else {
@@ -1893,10 +1893,10 @@ define([
18931893
if (e.keyCode == keyCode.shiftKey) {
18941894
that.keyboardManager.keyCheck.shiftKey = false;
18951895
}
1896-
if (e.keyCode == keyCode.escKey) {
1897-
// close on esc
1898-
that.close();
1899-
}
1896+
// if (e.keyCode == keyCode.escKey) {
1897+
// // close on esc
1898+
// that.close();
1899+
// }
19001900
});
19011901
}
19021902

0 commit comments

Comments
 (0)