Show More
@@ -43,7 +43,7 b' var IPython = (function (IPython) {' | |||||
43 | var end_space = $('<div class="end_space"></div>').height(150); |
|
43 | var end_space = $('<div class="end_space"></div>').height(150); | |
44 | end_space.dblclick(function (e) { |
|
44 | end_space.dblclick(function (e) { | |
45 | var ncells = that.ncells(); |
|
45 | var ncells = that.ncells(); | |
46 |
that.insert_code_cell_ |
|
46 | that.insert_code_cell_below(ncells-1); | |
47 | }); |
|
47 | }); | |
48 | this.element.append(end_space); |
|
48 | this.element.append(end_space); | |
49 | $('div#notebook').addClass('border-box-sizing'); |
|
49 | $('div#notebook').addClass('border-box-sizing'); | |
@@ -81,13 +81,13 b' var IPython = (function (IPython) {' | |||||
81 | that.control_key_active = false; |
|
81 | that.control_key_active = false; | |
82 | return false; |
|
82 | return false; | |
83 | } else if (event.which === 65 && that.control_key_active) { |
|
83 | } else if (event.which === 65 && that.control_key_active) { | |
84 |
// Insert code cell a |
|
84 | // Insert code cell above selected = a | |
85 |
that.insert_code_cell_a |
|
85 | that.insert_code_cell_above(); | |
86 | that.control_key_active = false; |
|
86 | that.control_key_active = false; | |
87 | return false; |
|
87 | return false; | |
88 | } else if (event.which === 66 && that.control_key_active) { |
|
88 | } else if (event.which === 66 && that.control_key_active) { | |
89 |
// Insert code cell be |
|
89 | // Insert code cell below selected = b | |
90 |
that.insert_code_cell_be |
|
90 | that.insert_code_cell_below(); | |
91 | that.control_key_active = false; |
|
91 | that.control_key_active = false; | |
92 | return false; |
|
92 | return false; | |
93 | } else if (event.which === 67 && that.control_key_active) { |
|
93 | } else if (event.which === 67 && that.control_key_active) { | |
@@ -340,7 +340,7 b' var IPython = (function (IPython) {' | |||||
340 | }; |
|
340 | }; | |
341 |
|
341 | |||
342 |
|
342 | |||
343 |
Notebook.prototype.insert_cell_ |
|
343 | Notebook.prototype.insert_cell_below = function (cell, index) { | |
344 | var ncells = this.ncells(); |
|
344 | var ncells = this.ncells(); | |
345 | if (ncells === 0) { |
|
345 | if (ncells === 0) { | |
346 | this.append_cell(cell); |
|
346 | this.append_cell(cell); | |
@@ -354,7 +354,7 b' var IPython = (function (IPython) {' | |||||
354 | }; |
|
354 | }; | |
355 |
|
355 | |||
356 |
|
356 | |||
357 |
Notebook.prototype.insert_cell_ |
|
357 | Notebook.prototype.insert_cell_above = function (cell, index) { | |
358 | var ncells = this.ncells(); |
|
358 | var ncells = this.ncells(); | |
359 | if (ncells === 0) { |
|
359 | if (ncells === 0) { | |
360 | this.append_cell(cell); |
|
360 | this.append_cell(cell); | |
@@ -420,67 +420,67 b' var IPython = (function (IPython) {' | |||||
420 | }; |
|
420 | }; | |
421 |
|
421 | |||
422 |
|
422 | |||
423 |
Notebook.prototype.insert_code_cell_ |
|
423 | Notebook.prototype.insert_code_cell_above = function (index) { | |
424 | // TODO: Bounds check for i |
|
424 | // TODO: Bounds check for i | |
425 | var i = this.index_or_selected(index); |
|
425 | var i = this.index_or_selected(index); | |
426 | var cell = new IPython.CodeCell(this); |
|
426 | var cell = new IPython.CodeCell(this); | |
427 | cell.set_input_prompt(); |
|
427 | cell.set_input_prompt(); | |
428 |
this.insert_cell_ |
|
428 | this.insert_cell_above(cell, i); | |
429 | this.select(this.find_cell_index(cell)); |
|
429 | this.select(this.find_cell_index(cell)); | |
430 | return cell; |
|
430 | return cell; | |
431 | } |
|
431 | } | |
432 |
|
432 | |||
433 |
|
433 | |||
434 |
Notebook.prototype.insert_code_cell_ |
|
434 | Notebook.prototype.insert_code_cell_below = function (index) { | |
435 | // TODO: Bounds check for i |
|
435 | // TODO: Bounds check for i | |
436 | var i = this.index_or_selected(index); |
|
436 | var i = this.index_or_selected(index); | |
437 | var cell = new IPython.CodeCell(this); |
|
437 | var cell = new IPython.CodeCell(this); | |
438 | cell.set_input_prompt(); |
|
438 | cell.set_input_prompt(); | |
439 |
this.insert_cell_ |
|
439 | this.insert_cell_below(cell, i); | |
440 | this.select(this.find_cell_index(cell)); |
|
440 | this.select(this.find_cell_index(cell)); | |
441 | return cell; |
|
441 | return cell; | |
442 | } |
|
442 | } | |
443 |
|
443 | |||
444 |
|
444 | |||
445 |
Notebook.prototype.insert_html_cell_ |
|
445 | Notebook.prototype.insert_html_cell_above = function (index) { | |
446 | // TODO: Bounds check for i |
|
446 | // TODO: Bounds check for i | |
447 | var i = this.index_or_selected(index); |
|
447 | var i = this.index_or_selected(index); | |
448 | var cell = new IPython.HTMLCell(this); |
|
448 | var cell = new IPython.HTMLCell(this); | |
449 | cell.config_mathjax(); |
|
449 | cell.config_mathjax(); | |
450 |
this.insert_cell_ |
|
450 | this.insert_cell_above(cell, i); | |
451 | this.select(this.find_cell_index(cell)); |
|
451 | this.select(this.find_cell_index(cell)); | |
452 | return cell; |
|
452 | return cell; | |
453 | } |
|
453 | } | |
454 |
|
454 | |||
455 |
|
455 | |||
456 |
Notebook.prototype.insert_html_cell_ |
|
456 | Notebook.prototype.insert_html_cell_below = function (index) { | |
457 | // TODO: Bounds check for i |
|
457 | // TODO: Bounds check for i | |
458 | var i = this.index_or_selected(index); |
|
458 | var i = this.index_or_selected(index); | |
459 | var cell = new IPython.HTMLCell(this); |
|
459 | var cell = new IPython.HTMLCell(this); | |
460 | cell.config_mathjax(); |
|
460 | cell.config_mathjax(); | |
461 |
this.insert_cell_ |
|
461 | this.insert_cell_below(cell, i); | |
462 | this.select(this.find_cell_index(cell)); |
|
462 | this.select(this.find_cell_index(cell)); | |
463 | return cell; |
|
463 | return cell; | |
464 | } |
|
464 | } | |
465 |
|
465 | |||
466 |
|
466 | |||
467 |
Notebook.prototype.insert_markdown_cell_ |
|
467 | Notebook.prototype.insert_markdown_cell_above = function (index) { | |
468 | // TODO: Bounds check for i |
|
468 | // TODO: Bounds check for i | |
469 | var i = this.index_or_selected(index); |
|
469 | var i = this.index_or_selected(index); | |
470 | var cell = new IPython.MarkdownCell(this); |
|
470 | var cell = new IPython.MarkdownCell(this); | |
471 | cell.config_mathjax(); |
|
471 | cell.config_mathjax(); | |
472 |
this.insert_cell_ |
|
472 | this.insert_cell_above(cell, i); | |
473 | this.select(this.find_cell_index(cell)); |
|
473 | this.select(this.find_cell_index(cell)); | |
474 | return cell; |
|
474 | return cell; | |
475 | } |
|
475 | } | |
476 |
|
476 | |||
477 |
|
477 | |||
478 |
Notebook.prototype.insert_markdown_cell_ |
|
478 | Notebook.prototype.insert_markdown_cell_below = function (index) { | |
479 | // TODO: Bounds check for i |
|
479 | // TODO: Bounds check for i | |
480 | var i = this.index_or_selected(index); |
|
480 | var i = this.index_or_selected(index); | |
481 | var cell = new IPython.MarkdownCell(this); |
|
481 | var cell = new IPython.MarkdownCell(this); | |
482 | cell.config_mathjax(); |
|
482 | cell.config_mathjax(); | |
483 |
this.insert_cell_ |
|
483 | this.insert_cell_below(cell, i); | |
484 | this.select(this.find_cell_index(cell)); |
|
484 | this.select(this.find_cell_index(cell)); | |
485 | return cell; |
|
485 | return cell; | |
486 | } |
|
486 | } | |
@@ -493,7 +493,7 b' var IPython = (function (IPython) {' | |||||
493 | var source_cell = source_element.data("cell"); |
|
493 | var source_cell = source_element.data("cell"); | |
494 | if (source_cell instanceof IPython.HTMLCell || |
|
494 | if (source_cell instanceof IPython.HTMLCell || | |
495 | source_cell instanceof IPython.MarkdownCell) { |
|
495 | source_cell instanceof IPython.MarkdownCell) { | |
496 |
this.insert_code_cell_ |
|
496 | this.insert_code_cell_below(i); | |
497 | var target_cell = this.cells()[i+1]; |
|
497 | var target_cell = this.cells()[i+1]; | |
498 | target_cell.set_code(source_cell.get_source()); |
|
498 | target_cell.set_code(source_cell.get_source()); | |
499 | source_element.remove(); |
|
499 | source_element.remove(); | |
@@ -510,11 +510,11 b' var IPython = (function (IPython) {' | |||||
510 | var source_cell = source_element.data("cell"); |
|
510 | var source_cell = source_element.data("cell"); | |
511 | var target_cell = null; |
|
511 | var target_cell = null; | |
512 | if (source_cell instanceof IPython.CodeCell) { |
|
512 | if (source_cell instanceof IPython.CodeCell) { | |
513 |
this.insert_markdown_cell_ |
|
513 | this.insert_markdown_cell_below(i); | |
514 | var target_cell = this.cells()[i+1]; |
|
514 | var target_cell = this.cells()[i+1]; | |
515 | var text = source_cell.get_code(); |
|
515 | var text = source_cell.get_code(); | |
516 | } else if (source_cell instanceof IPython.HTMLCell) { |
|
516 | } else if (source_cell instanceof IPython.HTMLCell) { | |
517 |
this.insert_markdown_cell_ |
|
517 | this.insert_markdown_cell_below(i); | |
518 | var target_cell = this.cells()[i+1]; |
|
518 | var target_cell = this.cells()[i+1]; | |
519 | var text = source_cell.get_source(); |
|
519 | var text = source_cell.get_source(); | |
520 | if (text === source_cell.placeholder) { |
|
520 | if (text === source_cell.placeholder) { | |
@@ -538,11 +538,11 b' var IPython = (function (IPython) {' | |||||
538 | var source_cell = source_element.data("cell"); |
|
538 | var source_cell = source_element.data("cell"); | |
539 | var target_cell = null; |
|
539 | var target_cell = null; | |
540 | if (source_cell instanceof IPython.CodeCell) { |
|
540 | if (source_cell instanceof IPython.CodeCell) { | |
541 |
this.insert_html_cell_ |
|
541 | this.insert_html_cell_below(i); | |
542 | var target_cell = this.cells()[i+1]; |
|
542 | var target_cell = this.cells()[i+1]; | |
543 | var text = source_cell.get_code(); |
|
543 | var text = source_cell.get_code(); | |
544 | } else if (source_cell instanceof IPython.MarkdownCell) { |
|
544 | } else if (source_cell instanceof IPython.MarkdownCell) { | |
545 |
this.insert_html_cell_ |
|
545 | this.insert_html_cell_below(i); | |
546 | var target_cell = this.cells()[i+1]; |
|
546 | var target_cell = this.cells()[i+1]; | |
547 | var text = source_cell.get_source(); |
|
547 | var text = source_cell.get_source(); | |
548 | if (text === source_cell.placeholder) { |
|
548 | if (text === source_cell.placeholder) { | |
@@ -654,7 +654,7 b' var IPython = (function (IPython) {' | |||||
654 | } |
|
654 | } | |
655 | } else if (payload[i].source === 'IPython.zmq.zmqshell.ZMQInteractiveShell.set_next_input') { |
|
655 | } else if (payload[i].source === 'IPython.zmq.zmqshell.ZMQInteractiveShell.set_next_input') { | |
656 | var index = this.find_cell_index(cell); |
|
656 | var index = this.find_cell_index(cell); | |
657 |
var new_cell = this.insert_code_cell_ |
|
657 | var new_cell = this.insert_code_cell_below(index); | |
658 | new_cell.set_code(payload[i].text); |
|
658 | new_cell.set_code(payload[i].text); | |
659 | this.dirty = true; |
|
659 | this.dirty = true; | |
660 | } |
|
660 | } | |
@@ -779,7 +779,7 b' var IPython = (function (IPython) {' | |||||
779 | cell.clear_input(); |
|
779 | cell.clear_input(); | |
780 | } else { |
|
780 | } else { | |
781 | if ((cell_index === (that.ncells()-1)) && default_options.add_new) { |
|
781 | if ((cell_index === (that.ncells()-1)) && default_options.add_new) { | |
782 |
that.insert_code_cell_ |
|
782 | that.insert_code_cell_below(); | |
783 | // If we are adding a new cell at the end, scroll down to show it. |
|
783 | // If we are adding a new cell at the end, scroll down to show it. | |
784 | that.scroll_to_bottom(); |
|
784 | that.scroll_to_bottom(); | |
785 | } else { |
|
785 | } else { | |
@@ -826,13 +826,13 b' var IPython = (function (IPython) {' | |||||
826 | for (var i=0; i<ncells; i++) { |
|
826 | for (var i=0; i<ncells; i++) { | |
827 | cell_data = new_cells[i]; |
|
827 | cell_data = new_cells[i]; | |
828 | if (cell_data.cell_type == 'code') { |
|
828 | if (cell_data.cell_type == 'code') { | |
829 |
new_cell = this.insert_code_cell_ |
|
829 | new_cell = this.insert_code_cell_below(); | |
830 | new_cell.fromJSON(cell_data); |
|
830 | new_cell.fromJSON(cell_data); | |
831 | } else if (cell_data.cell_type === 'html') { |
|
831 | } else if (cell_data.cell_type === 'html') { | |
832 |
new_cell = this.insert_html_cell_ |
|
832 | new_cell = this.insert_html_cell_below(); | |
833 | new_cell.fromJSON(cell_data); |
|
833 | new_cell.fromJSON(cell_data); | |
834 | } else if (cell_data.cell_type === 'markdown') { |
|
834 | } else if (cell_data.cell_type === 'markdown') { | |
835 |
new_cell = this.insert_markdown_cell_ |
|
835 | new_cell = this.insert_markdown_cell_below(); | |
836 | new_cell.fromJSON(cell_data); |
|
836 | new_cell.fromJSON(cell_data); | |
837 | }; |
|
837 | }; | |
838 | }; |
|
838 | }; | |
@@ -908,7 +908,7 b' var IPython = (function (IPython) {' | |||||
908 | Notebook.prototype.notebook_loaded = function (data, status, xhr) { |
|
908 | Notebook.prototype.notebook_loaded = function (data, status, xhr) { | |
909 | this.fromJSON(data); |
|
909 | this.fromJSON(data); | |
910 | if (this.ncells() === 0) { |
|
910 | if (this.ncells() === 0) { | |
911 |
this.insert_code_cell_ |
|
911 | this.insert_code_cell_below(); | |
912 | }; |
|
912 | }; | |
913 | IPython.save_widget.status_save(); |
|
913 | IPython.save_widget.status_save(); | |
914 | IPython.save_widget.set_notebook_name(data.metadata.name); |
|
914 | IPython.save_widget.set_notebook_name(data.metadata.name); |
@@ -147,10 +147,10 b' var IPython = (function (IPython) {' | |||||
147 | IPython.notebook.delete_cell(); |
|
147 | IPython.notebook.delete_cell(); | |
148 | }); |
|
148 | }); | |
149 | this.content.find('#insert_cell_above').click(function () { |
|
149 | this.content.find('#insert_cell_above').click(function () { | |
150 |
IPython.notebook.insert_code_cell_ |
|
150 | IPython.notebook.insert_code_cell_above(); | |
151 | }); |
|
151 | }); | |
152 | this.content.find('#insert_cell_below').click(function () { |
|
152 | this.content.find('#insert_cell_below').click(function () { | |
153 |
IPython.notebook.insert_code_cell_ |
|
153 | IPython.notebook.insert_code_cell_below(); | |
154 | }); |
|
154 | }); | |
155 | this.content.find('#move_cell_up').click(function () { |
|
155 | this.content.find('#move_cell_up').click(function () { | |
156 | IPython.notebook.move_cell_up(); |
|
156 | IPython.notebook.move_cell_up(); |
General Comments 0
You need to be logged in to leave comments.
Login now