-
-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathVpPanel.js
More file actions
120 lines (103 loc) · 3.07 KB
/
VpPanel.js
File metadata and controls
120 lines (103 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
define([
'@jupyterlab/ui-components',
'@lumino/widgets',
'../style/icon.svg',
'text',
'css',
'jquery',
'jquery-ui',
'jquery-ui-css',
'codemirror/lib/codemirror',
'vp_base/lib/codemirror/lib/codemirror.css', // INTEGRATION: unified version of css loader
'vp_base/js/loadVisualpython',
'vp_base/js/com/com_Config'
], function(
{ LabIcon }, { Panel, Widget },
vpIcon,
text, css, $,
ui, uiCss,
codemirror,
cmCss,
loadVisualpython, com_Config) {
const {
JUPYTER_HEADER_SPACING,
VP_MIN_WIDTH,
MENU_MIN_WIDTH,
BOARD_MIN_WIDTH,
MENU_BOARD_SPACING
} = com_Config;
class VpPanel extends Panel {
/**
* Constructor
*/
constructor(app) {
super();
// codemirror
global.codemirror = codemirror;
this.app = app;
this.vpFrame = loadVisualpython.initVisualpython();
this.id = 'jupyterlab-visualpython:panel';
// LabIcon with svg : @jupyterlab/ui-components/lib/icon/labicon.js
this.title.icon = new LabIcon({ name: 'jupyterlab-visualpython:toggle-icon', svgstr: vpIcon });
this.title.caption = 'Visual Python';
// register node using jquery to element
this.node = this.vpFrame.renderMainFrame().get(4);
}
onResize(msg) {
super.onResize(msg);
var { type, width, height } = msg;
this._resizeVp(width);
$('#vp_wrapper').css({'left': '', 'height': ''});
}
_resizeVp(currentWidth) {
// calculate inner frame width
var menuWidth = $('#vp_menuFrame').width();
var boardWidth = 0;
var showBoard = $('#vp_boardFrame').is(':visible');
if (showBoard) {
boardWidth = currentWidth - menuWidth - MENU_BOARD_SPACING;
if (boardWidth < BOARD_MIN_WIDTH + MENU_BOARD_SPACING) {
boardWidth = BOARD_MIN_WIDTH;
menuWidth = currentWidth - (BOARD_MIN_WIDTH + MENU_BOARD_SPACING);
}
} else {
// resize menuWidth if board is hidden
menuWidth = currentWidth - MENU_BOARD_SPACING;
}
$('#vp_menuFrame').width(menuWidth);
$('#vp_boardFrame').width(boardWidth);
vpLog.display(VP_LOG_TYPE.DEVELOP, 'resizing wrapper to ', currentWidth, 'with', menuWidth, boardWidth);
$('#vp_wrapper').width(currentWidth);
// save current page info
vpConfig.setMetadata({
vp_position: { width: currentWidth },
vp_menu_width: menuWidth,
vp_note_width: boardWidth
});
}
onBeforeShow() {
// show #vp_wrapper
$(this.node).show();
this.vpFrame.openVp();
// LAB: FIXME: select which is not toggled to task bar
// $('.vp-popup-frame').show();
}
onAfterHide() {
// hide #vp_wrapper
$(this.node).hide();
// LAB: FIXME: select which is not toggled to task bar
// hide .vp-popup-frame
// $('.vp-popup-frame').hide();
}
onAfterAttach() {
this.vpFrame.afterAttach();
}
onAfterDetach() {
}
onCloseRequest(msg) {
super.onCloseRequest(msg);
this.dispose();
}
}
return VpPanel;
});