Show More
@@ -0,0 +1,214 | |||
|
1 | ||
|
2 | //============================================================================ | |
|
3 | // Cell | |
|
4 | //============================================================================ | |
|
5 | ||
|
6 | var IPython = (function (IPython) { | |
|
7 | ||
|
8 | var utils = IPython.utils; | |
|
9 | ||
|
10 | // Base PanelSection class | |
|
11 | ||
|
12 | var PanelSection = function () { | |
|
13 | if (this.section_name === undefined) { | |
|
14 | this.section_name = 'section'; | |
|
15 | }; | |
|
16 | this.create_element(); | |
|
17 | if (this.element !== undefined) { | |
|
18 | this.bind_events(); | |
|
19 | } | |
|
20 | this.expanded = true; | |
|
21 | }; | |
|
22 | ||
|
23 | ||
|
24 | PanelSection.prototype.bind_events = function () { | |
|
25 | var that = this; | |
|
26 | this.header.click(function () { | |
|
27 | that.toggle(); | |
|
28 | }); | |
|
29 | this.header.hover(function () { | |
|
30 | that.header.toggleClass('ui-state-hover'); | |
|
31 | }); | |
|
32 | }; | |
|
33 | ||
|
34 | ||
|
35 | PanelSection.prototype.create_element = function () { | |
|
36 | this.element = $('<div/>').attr('id',this.id()); | |
|
37 | this.header = $('<h3>'+this.section_name+'</h3>'). | |
|
38 | addClass('ui-widget ui-state-default section_header'); | |
|
39 | this.content = $('<div/>'). | |
|
40 | addClass('ui-widget section_content'); | |
|
41 | this.element.append(this.header).append(this.content); | |
|
42 | this.create_children(); | |
|
43 | }; | |
|
44 | ||
|
45 | ||
|
46 | PanelSection.prototype.id = function () { | |
|
47 | return this.section_name.toLowerCase() + "_section"; | |
|
48 | }; | |
|
49 | ||
|
50 | ||
|
51 | PanelSection.prototype.expand = function () { | |
|
52 | if (!this.expanded) { | |
|
53 | this.content.slideDown('fast'); | |
|
54 | // this.header.addClass('ui-state-active'); | |
|
55 | // this.header.removeClass('ui-state-default'); | |
|
56 | this.expanded = true; | |
|
57 | }; | |
|
58 | }; | |
|
59 | ||
|
60 | ||
|
61 | PanelSection.prototype.collapse = function () { | |
|
62 | if (this.expanded) { | |
|
63 | this.content.slideUp('fast'); | |
|
64 | // this.header.removeClass('ui-state-active'); | |
|
65 | // this.header.addClass('ui-state-default'); | |
|
66 | this.expanded = false; | |
|
67 | }; | |
|
68 | }; | |
|
69 | ||
|
70 | ||
|
71 | PanelSection.prototype.toggle = function () { | |
|
72 | if (this.expanded === true) { | |
|
73 | this.collapse(); | |
|
74 | } else { | |
|
75 | this.expand(); | |
|
76 | }; | |
|
77 | }; | |
|
78 | ||
|
79 | ||
|
80 | PanelSection.prototype.create_children = function () {}; | |
|
81 | ||
|
82 | ||
|
83 | // NotebookSection | |
|
84 | ||
|
85 | var NotebookSection = function () { | |
|
86 | this.section_name = "Notebook"; | |
|
87 | PanelSection.apply(this, arguments); | |
|
88 | }; | |
|
89 | ||
|
90 | ||
|
91 | NotebookSection.prototype = new PanelSection(); | |
|
92 | ||
|
93 | ||
|
94 | // CellSection | |
|
95 | ||
|
96 | var CellSection = function () { | |
|
97 | this.section_name = "Cell"; | |
|
98 | PanelSection.apply(this, arguments); | |
|
99 | }; | |
|
100 | ||
|
101 | ||
|
102 | CellSection.prototype = new PanelSection(); | |
|
103 | ||
|
104 | ||
|
105 | CellSection.prototype.bind_events = function () { | |
|
106 | PanelSection.prototype.bind_events.apply(this); | |
|
107 | this.content.find('#collapse_cell').click(function () { | |
|
108 | IPython.notebook.collapse(); | |
|
109 | }); | |
|
110 | this.content.find('#expand_cell').click(function () { | |
|
111 | IPython.notebook.expand(); | |
|
112 | }); | |
|
113 | this.content.find('#delete_cell').click(function () { | |
|
114 | IPython.notebook.delete_cell(); | |
|
115 | }); | |
|
116 | this.content.find('#insert_cell_above').click(function () { | |
|
117 | IPython.notebook.insert_code_cell_before(); | |
|
118 | }); | |
|
119 | this.content.find('#insert_cell_below').click(function () { | |
|
120 | IPython.notebook.insert_code_cell_after(); | |
|
121 | }); | |
|
122 | this.content.find('#move_cell_up').click(function () { | |
|
123 | IPython.notebook.move_cell_up(); | |
|
124 | }); | |
|
125 | this.content.find('#move_cell_down').click(function () { | |
|
126 | IPython.notebook.move_cell_down(); | |
|
127 | }); | |
|
128 | this.content.find('#to_code').click(function () { | |
|
129 | IPython.notebook.text_to_code(); | |
|
130 | }); | |
|
131 | this.content.find('#to_text').click(function () { | |
|
132 | IPython.notebook.code_to_text(); | |
|
133 | }); | |
|
134 | }; | |
|
135 | ||
|
136 | ||
|
137 | CellSection.prototype.create_children = function () { | |
|
138 | var row0 = $('<div>'). | |
|
139 | append($('<span/>').attr('id','toggle'). | |
|
140 | append( $('<button>Collapse</button>').attr('id','collapse_cell') ). | |
|
141 | append( $('<button>Expand</button>').attr('id','expand_cell') ) ). | |
|
142 | append($('<span/>'). | |
|
143 | append($('<button>X</button>').attr('id','delete_cell'))); | |
|
144 | row0.find('#toggle').buttonset(); | |
|
145 | row0.find('button#delete_cell').button(); | |
|
146 | this.content.append(row0); | |
|
147 | ||
|
148 | var row1 = $('<div>'). | |
|
149 | append($('<span/>').html('Insert').addClass('button_label')). | |
|
150 | append($('<span/>').attr('id','insert'). | |
|
151 | append( $('<button>Above</button>').attr('id','insert_cell_above') ). | |
|
152 | append( $('<button>Below</button>').attr('id','insert_cell_below') ) ); | |
|
153 | row1.find('#insert').buttonset(); | |
|
154 | this.content.append(row1); | |
|
155 | ||
|
156 | var row2 = $('<div>'). | |
|
157 | append($('<span/>').html('Move').addClass('button_label')). | |
|
158 | append($('<span/>').attr('id','move'). | |
|
159 | append( $('<button>Up</button>').attr('id','move_cell_up') ). | |
|
160 | append( $('<button>Down</button>').attr('id','move_cell_down') ) ); | |
|
161 | row2.find('#move').buttonset(); | |
|
162 | this.content.append(row2); | |
|
163 | ||
|
164 | var row3 = $('<div>'). | |
|
165 | append($('<span/>').html('Cell Type').addClass('button_label')). | |
|
166 | append($('<span/>').attr('id','cell_type'). | |
|
167 | append( $('<button>Code</button>').attr('id','to_code') ). | |
|
168 | append( $('<button>Text</button>').attr('id','to_text') ) ); | |
|
169 | row3.find('#cell_type').buttonset(); | |
|
170 | this.content.append(row3) | |
|
171 | }; | |
|
172 | // <span id="move_cell"> | |
|
173 | // <button id="move_up">Move up</button> | |
|
174 | // <button id="move_down">Move down</button> | |
|
175 | // </span> | |
|
176 | // <span id="insert_delete"> | |
|
177 | // <button id="insert_cell_before">Before</button> | |
|
178 | // <button id="insert_cell_after">After</button> | |
|
179 | // <button id="delete_cell">Delete</button> | |
|
180 | // </span> | |
|
181 | // <span id="cell_type"> | |
|
182 | // <button id="to_code">Code</button> | |
|
183 | // <button id="to_text">Text</button> | |
|
184 | // </span> | |
|
185 | // <span id="sort"> | |
|
186 | // <button id="sort_cells">Sort</button> | |
|
187 | // </span> | |
|
188 | // <span id="toggle"> | |
|
189 | // <button id="collapse">Collapse</button> | |
|
190 | // <button id="expand">Expand</button> | |
|
191 | // </span> | |
|
192 | // </span> | |
|
193 | ||
|
194 | ||
|
195 | // KernelSection | |
|
196 | ||
|
197 | var KernelSection = function () { | |
|
198 | this.section_name = "Kernel"; | |
|
199 | PanelSection.apply(this, arguments); | |
|
200 | }; | |
|
201 | ||
|
202 | ||
|
203 | KernelSection.prototype = new PanelSection(); | |
|
204 | ||
|
205 | ||
|
206 | IPython.PanelSection = PanelSection; | |
|
207 | IPython.NotebookSection = NotebookSection; | |
|
208 | IPython.CellSection = CellSection; | |
|
209 | IPython.KernelSection = KernelSection; | |
|
210 | ||
|
211 | return IPython; | |
|
212 | ||
|
213 | }(IPython)); | |
|
214 |
@@ -115,6 +115,25 div#left_panel { | |||
|
115 | 115 | position: absolute; |
|
116 | 116 | } |
|
117 | 117 | |
|
118 | h3.section_header { | |
|
119 | padding: 5px; | |
|
120 | } | |
|
121 | ||
|
122 | div.section_content { | |
|
123 | padding: 5px; | |
|
124 | } | |
|
125 | ||
|
126 | ||
|
127 | span.button_label { | |
|
128 | padding: 0.3em 1em; | |
|
129 | font-size: 0.8em; | |
|
130 | } | |
|
131 | ||
|
132 | .ui-button .ui-button-text { | |
|
133 | padding: 0.3em 0.9em; | |
|
134 | font-size: 0.7em; | |
|
135 | } | |
|
136 | ||
|
118 | 137 | div#left_panel_splitter { |
|
119 | 138 | width: 8px; |
|
120 | 139 | top: 0px; |
@@ -46,7 +46,6 var IPython = (function (IPython) { | |||
|
46 | 46 | } else { |
|
47 | 47 | $('div#notebook').height(app_height-pager_splitter_height); |
|
48 | 48 | } |
|
49 | console.log('resize: ', app_height); | |
|
50 | 49 | }; |
|
51 | 50 | |
|
52 | 51 | IPython.LayoutManager = LayoutManager |
@@ -15,6 +15,7 var IPython = (function (IPython) { | |||
|
15 | 15 | this.width = 250; |
|
16 | 16 | this.style(); |
|
17 | 17 | this.bind_events(); |
|
18 | this.create_children(); | |
|
18 | 19 | }; |
|
19 | 20 | |
|
20 | 21 | |
@@ -55,6 +56,15 var IPython = (function (IPython) { | |||
|
55 | 56 | }; |
|
56 | 57 | |
|
57 | 58 | |
|
59 | LeftPanel.prototype.create_children = function () { | |
|
60 | this.notebook_section = new IPython.NotebookSection(); | |
|
61 | this.left_panel_element.append(this.notebook_section.element); | |
|
62 | this.cell_section = new IPython.CellSection(); | |
|
63 | this.left_panel_element.append(this.cell_section.element); | |
|
64 | this.kernel_section = new IPython.KernelSection(); | |
|
65 | this.left_panel_element.append(this.kernel_section.element); | |
|
66 | } | |
|
67 | ||
|
58 | 68 | LeftPanel.prototype.collapse = function () { |
|
59 | 69 | if (this.expanded === true) { |
|
60 | 70 | this.left_panel_element.add($('div#notebook')).trigger('collapse_left_panel'); |
@@ -121,7 +121,6 var IPython = (function (IPython) { | |||
|
121 | 121 | var splitter_width = $('div#left_panel_splitter').outerWidth(true); |
|
122 | 122 | var left_panel_width = IPython.left_panel.width; |
|
123 | 123 | var new_margin = splitter_width + left_panel_width; |
|
124 | console.log('expand', splitter_width, left_panel_width, new_margin); | |
|
125 | 124 | $('div#notebook_panel').animate({marginLeft : new_margin + 'px'}, 'fast'); |
|
126 | 125 | }); |
|
127 | 126 | }; |
@@ -433,7 +432,7 var IPython = (function (IPython) { | |||
|
433 | 432 | var header = reply.header; |
|
434 | 433 | var content = reply.content; |
|
435 | 434 | var msg_type = header.msg_type; |
|
436 | console.log(reply); | |
|
435 | // console.log(reply); | |
|
437 | 436 | var cell = this.cell_for_msg(reply.parent_header.msg_id); |
|
438 | 437 | if (msg_type === "execute_reply") { |
|
439 | 438 | cell.set_input_prompt(content.execution_count); |
@@ -56,6 +56,7 | |||
|
56 | 56 | <script src="static/js/kernel.js" type="text/javascript" charset="utf-8"></script> |
|
57 | 57 | <script src="static/js/layout.js" type="text/javascript" charset="utf-8"></script> |
|
58 | 58 | <script src="static/js/pager.js" type="text/javascript" charset="utf-8"></script> |
|
59 | <script src="static/js/panelsection.js" type="text/javascript" charset="utf-8"></script> | |
|
59 | 60 | <script src="static/js/leftpanel.js" type="text/javascript" charset="utf-8"></script> |
|
60 | 61 | <script src="static/js/notebook.js" type="text/javascript" charset="utf-8"></script> |
|
61 | 62 | <script src="static/js/notebook_main.js" type="text/javascript" charset="utf-8"></script> |
General Comments 0
You need to be logged in to leave comments.
Login now