Show More
@@ -13,6 +13,7 b' var IPython = (function (IPython) {' | |||||
13 |
|
13 | |||
14 | var utils = IPython.utils; |
|
14 | var utils = IPython.utils; | |
15 |
|
15 | |||
|
16 | ||||
16 | var Cell = function (notebook) { |
|
17 | var Cell = function (notebook) { | |
17 | this.placeholder = this.placeholder || ''; |
|
18 | this.placeholder = this.placeholder || ''; | |
18 | this.notebook = notebook; |
|
19 | this.notebook = notebook; | |
@@ -24,16 +25,17 b' var IPython = (function (IPython) {' | |||||
24 | this.element = null; |
|
25 | this.element = null; | |
25 | this.create_element(); |
|
26 | this.create_element(); | |
26 | if (this.element !== null) { |
|
27 | if (this.element !== null) { | |
27 | this.set_autoindent(true); |
|
|||
28 | this.element.data("cell", this); |
|
28 | this.element.data("cell", this); | |
29 | this.bind_events(); |
|
29 | this.bind_events(); | |
30 | } |
|
30 | } | |
31 | this.cell_id = utils.uuid(); |
|
31 | this.cell_id = utils.uuid(); | |
32 | }; |
|
32 | }; | |
33 |
|
33 | |||
|
34 | ||||
34 | // Subclasses must implement create_element. |
|
35 | // Subclasses must implement create_element. | |
35 | Cell.prototype.create_element = function () {}; |
|
36 | Cell.prototype.create_element = function () {}; | |
36 |
|
37 | |||
|
38 | ||||
37 | Cell.prototype.bind_events = function () { |
|
39 | Cell.prototype.bind_events = function () { | |
38 | var that = this; |
|
40 | var that = this; | |
39 | var nb = that.notebook; |
|
41 | var nb = that.notebook; | |
@@ -49,6 +51,7 b' var IPython = (function (IPython) {' | |||||
49 | }); |
|
51 | }); | |
50 | }; |
|
52 | }; | |
51 |
|
53 | |||
|
54 | ||||
52 | // typeset with MathJax if MathJax is available |
|
55 | // typeset with MathJax if MathJax is available | |
53 | Cell.prototype.typeset = function () { |
|
56 | Cell.prototype.typeset = function () { | |
54 | if (window.MathJax){ |
|
57 | if (window.MathJax){ | |
@@ -121,6 +124,7 b' var IPython = (function (IPython) {' | |||||
121 | return text; |
|
124 | return text; | |
122 | }; |
|
125 | }; | |
123 |
|
126 | |||
|
127 | ||||
124 | Cell.prototype.grow = function(element) { |
|
128 | Cell.prototype.grow = function(element) { | |
125 | // Grow the cell by hand. This is used upon reloading from JSON, when the |
|
129 | // Grow the cell by hand. This is used upon reloading from JSON, when the | |
126 | // autogrow handler is not called. |
|
130 | // autogrow handler is not called. | |
@@ -138,16 +142,6 b' var IPython = (function (IPython) {' | |||||
138 | }; |
|
142 | }; | |
139 |
|
143 | |||
140 |
|
144 | |||
141 | Cell.prototype.set_autoindent = function (state) { |
|
|||
142 | if (state) { |
|
|||
143 | this.code_mirror.setOption('tabMode', 'indent'); |
|
|||
144 | this.code_mirror.setOption('enterMode', 'indent'); |
|
|||
145 | } else { |
|
|||
146 | this.code_mirror.setOption('tabMode', 'shift'); |
|
|||
147 | this.code_mirror.setOption('enterMode', 'flat'); |
|
|||
148 | } |
|
|||
149 | }; |
|
|||
150 |
|
||||
151 | IPython.Cell = Cell; |
|
145 | IPython.Cell = Cell; | |
152 |
|
146 | |||
153 | return IPython; |
|
147 | return IPython; |
@@ -32,7 +32,6 b' var IPython = (function (IPython) {' | |||||
32 | this.set_tooltipontab(true); |
|
32 | this.set_tooltipontab(true); | |
33 | this.set_smartcompleter(true); |
|
33 | this.set_smartcompleter(true); | |
34 | this.set_timebeforetooltip(1200); |
|
34 | this.set_timebeforetooltip(1200); | |
35 | this.set_autoindent(true); |
|
|||
36 | }; |
|
35 | }; | |
37 |
|
36 | |||
38 |
|
37 | |||
@@ -723,6 +722,7 b' var IPython = (function (IPython) {' | |||||
723 | }; |
|
722 | }; | |
724 | }; |
|
723 | }; | |
725 |
|
724 | |||
|
725 | ||||
726 | // Cell collapsing and output clearing |
|
726 | // Cell collapsing and output clearing | |
727 |
|
727 | |||
728 | Notebook.prototype.collapse = function (index) { |
|
728 | Notebook.prototype.collapse = function (index) { | |
@@ -750,22 +750,16 b' var IPython = (function (IPython) {' | |||||
750 | this.time_before_tooltip = time; |
|
750 | this.time_before_tooltip = time; | |
751 | }; |
|
751 | }; | |
752 |
|
752 | |||
|
753 | ||||
753 | Notebook.prototype.set_tooltipontab = function (state) { |
|
754 | Notebook.prototype.set_tooltipontab = function (state) { | |
754 | this.tooltip_on_tab = state; |
|
755 | this.tooltip_on_tab = state; | |
755 | }; |
|
756 | }; | |
756 |
|
757 | |||
|
758 | ||||
757 | Notebook.prototype.set_smartcompleter = function (state) { |
|
759 | Notebook.prototype.set_smartcompleter = function (state) { | |
758 | this.smart_completer = state; |
|
760 | this.smart_completer = state; | |
759 | }; |
|
761 | }; | |
760 |
|
762 | |||
761 | Notebook.prototype.set_autoindent = function (state) { |
|
|||
762 | var cells = this.get_cells(); |
|
|||
763 | len = cells.length; |
|
|||
764 | for (var i=0; i<len; i++) { |
|
|||
765 | cells[i].set_autoindent(state); |
|
|||
766 | }; |
|
|||
767 | }; |
|
|||
768 |
|
||||
769 |
|
763 | |||
770 | Notebook.prototype.clear_all_output = function () { |
|
764 | Notebook.prototype.clear_all_output = function () { | |
771 | var ncells = this.ncells(); |
|
765 | var ncells = this.ncells(); | |
@@ -778,6 +772,7 b' var IPython = (function (IPython) {' | |||||
778 | this.dirty = true; |
|
772 | this.dirty = true; | |
779 | }; |
|
773 | }; | |
780 |
|
774 | |||
|
775 | ||||
781 | // Other cell functions: line numbers, ... |
|
776 | // Other cell functions: line numbers, ... | |
782 |
|
777 | |||
783 | Notebook.prototype.cell_toggle_line_numbers = function() { |
|
778 | Notebook.prototype.cell_toggle_line_numbers = function() { |
General Comments 0
You need to be logged in to leave comments.
Login now