Show More
@@ -22,7 +22,14 var IPython = (function (IPython) { | |||||
22 |
|
22 | |||
23 |
|
23 | |||
24 | MenuBar.prototype.style = function () { |
|
24 | MenuBar.prototype.style = function () { | |
25 |
$('ul#menus').menubar( |
|
25 | $('ul#menus').menubar({ | |
|
26 | select : function (event, ui) { | |||
|
27 | // The selected cell looses focus when the menu is entered, so we | |||
|
28 | // re-select it upon selection. | |||
|
29 | var i = IPython.notebook.selected_index(); | |||
|
30 | IPython.notebook.select(i); | |||
|
31 | } | |||
|
32 | }); | |||
26 | }; |
|
33 | }; | |
27 |
|
34 | |||
28 |
|
35 |
@@ -200,19 +200,6 var IPython = (function (IPython) { | |||||
200 | that.element.animate({height : new_height + 'px'}, 'fast'); |
|
200 | that.element.animate({height : new_height + 'px'}, 'fast'); | |
201 | }); |
|
201 | }); | |
202 |
|
202 | |||
203 | this.element.bind('collapse_left_panel', function () { |
|
|||
204 | var splitter_width = $('div#left_panel_splitter').outerWidth(true); |
|
|||
205 | var new_margin = splitter_width; |
|
|||
206 | $('div#notebook_panel').animate({marginLeft : new_margin + 'px'}, 'fast'); |
|
|||
207 | }); |
|
|||
208 |
|
||||
209 | this.element.bind('expand_left_panel', function () { |
|
|||
210 | var splitter_width = $('div#left_panel_splitter').outerWidth(true); |
|
|||
211 | var left_panel_width = IPython.left_panel.width; |
|
|||
212 | var new_margin = splitter_width + left_panel_width; |
|
|||
213 | $('div#notebook_panel').animate({marginLeft : new_margin + 'px'}, 'fast'); |
|
|||
214 | }); |
|
|||
215 |
|
||||
216 | $(window).bind('beforeunload', function () { |
|
203 | $(window).bind('beforeunload', function () { | |
217 | // TODO: Make killing the kernel configurable. |
|
204 | // TODO: Make killing the kernel configurable. | |
218 | var kill_kernel = false; |
|
205 | var kill_kernel = false; | |
@@ -273,7 +260,16 var IPython = (function (IPython) { | |||||
273 |
|
260 | |||
274 |
|
261 | |||
275 | Notebook.prototype.index_or_selected = function (index) { |
|
262 | Notebook.prototype.index_or_selected = function (index) { | |
276 | return index || this.selected_index() || 0; |
|
263 | var i; | |
|
264 | if (index === undefined) { | |||
|
265 | i = this.selected_index(); | |||
|
266 | if (i === null) { | |||
|
267 | i = 0; | |||
|
268 | } | |||
|
269 | } else { | |||
|
270 | i = index; | |||
|
271 | } | |||
|
272 | return i; | |||
277 | }; |
|
273 | }; | |
278 |
|
274 | |||
279 |
|
275 | |||
@@ -338,7 +334,7 var IPython = (function (IPython) { | |||||
338 | // Cell insertion, deletion and moving. |
|
334 | // Cell insertion, deletion and moving. | |
339 |
|
335 | |||
340 | Notebook.prototype.delete_cell = function (index) { |
|
336 | Notebook.prototype.delete_cell = function (index) { | |
341 |
var i = |
|
337 | var i = this.index_or_selected(index); | |
342 | if (i !== null && i >= 0 && i < this.ncells()) { |
|
338 | if (i !== null && i >= 0 && i < this.ncells()) { | |
343 | this.cell_elements().eq(i).remove(); |
|
339 | this.cell_elements().eq(i).remove(); | |
344 | if (i === (this.ncells())) { |
|
340 | if (i === (this.ncells())) { | |
@@ -664,6 +660,7 var IPython = (function (IPython) { | |||||
664 |
|
660 | |||
665 |
|
661 | |||
666 | Notebook.prototype.split_cell = function () { |
|
662 | Notebook.prototype.split_cell = function () { | |
|
663 | // Todo: implement spliting for other cell types. | |||
667 | var cell = this.selected_cell(); |
|
664 | var cell = this.selected_cell(); | |
668 | if (cell instanceof IPython.CodeCell) { |
|
665 | if (cell instanceof IPython.CodeCell) { | |
669 | var cursor = cell.code_mirror.getCursor(); |
|
666 | var cursor = cell.code_mirror.getCursor(); | |
@@ -680,6 +677,40 var IPython = (function (IPython) { | |||||
680 | }; |
|
677 | }; | |
681 | }; |
|
678 | }; | |
682 |
|
679 | |||
|
680 | ||||
|
681 | Notebook.prototype.merge_cell_above = function () { | |||
|
682 | // Todo: implement merging for other cell types. | |||
|
683 | var cell = this.selected_cell(); | |||
|
684 | var index = this.selected_index(); | |||
|
685 | if (index > 0) { | |||
|
686 | upper_cell = this.cells()[index-1]; | |||
|
687 | lower_cell = this.cells()[index]; | |||
|
688 | if (upper_cell instanceof IPython.CodeCell && lower_cell instanceof IPython.CodeCell) { | |||
|
689 | upper_text = upper_cell.get_code(); | |||
|
690 | lower_text = lower_cell.get_code(); | |||
|
691 | lower_cell.set_code(upper_text+'\n'+lower_text); | |||
|
692 | this.delete_cell(index-1); | |||
|
693 | }; | |||
|
694 | }; | |||
|
695 | }; | |||
|
696 | ||||
|
697 | ||||
|
698 | Notebook.prototype.merge_cell_below = function () { | |||
|
699 | // Todo: implement merging for other cell types. | |||
|
700 | var cell = this.selected_cell(); | |||
|
701 | var index = this.selected_index(); | |||
|
702 | if (index < this.ncells()-1) { | |||
|
703 | upper_cell = this.cells()[index]; | |||
|
704 | lower_cell = this.cells()[index+1]; | |||
|
705 | if (upper_cell instanceof IPython.CodeCell && lower_cell instanceof IPython.CodeCell) { | |||
|
706 | upper_text = upper_cell.get_code(); | |||
|
707 | lower_text = lower_cell.get_code(); | |||
|
708 | upper_cell.set_code(upper_text+'\n'+lower_text); | |||
|
709 | this.delete_cell(index+1); | |||
|
710 | }; | |||
|
711 | }; | |||
|
712 | }; | |||
|
713 | ||||
683 | // Cell collapsing and output clearing |
|
714 | // Cell collapsing and output clearing | |
684 |
|
715 | |||
685 | Notebook.prototype.collapse = function (index) { |
|
716 | Notebook.prototype.collapse = function (index) { |
General Comments 0
You need to be logged in to leave comments.
Login now