##// END OF EJS Templates
Removed HTMLCell from UI and added better placeholder logic.
Brian E. Granger -
Show More
@@ -1,251 +1,251 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
2 // Copyright (C) 2008-2011 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // PanelSection
9 // PanelSection
10 //============================================================================
10 //============================================================================
11
11
12 var IPython = (function (IPython) {
12 var IPython = (function (IPython) {
13
13
14 var utils = IPython.utils;
14 var utils = IPython.utils;
15
15
16 // Base PanelSection class
16 // Base PanelSection class
17
17
18 var PanelSection = function (selector) {
18 var PanelSection = function (selector) {
19 this.selector = selector;
19 this.selector = selector;
20 if (this.selector !== undefined) {
20 if (this.selector !== undefined) {
21 this.element = $(selector);
21 this.element = $(selector);
22 this.header = this.element.find('h3.section_header');
22 this.header = this.element.find('h3.section_header');
23 this.content = this.element.find('div.section_content');
23 this.content = this.element.find('div.section_content');
24 this.style();
24 this.style();
25 this.bind_events();
25 this.bind_events();
26 }
26 }
27 this.expanded = true;
27 this.expanded = true;
28 };
28 };
29
29
30
30
31 PanelSection.prototype.style = function () {
31 PanelSection.prototype.style = function () {
32 this.header.addClass('ui-widget ui-state-default');
32 this.header.addClass('ui-widget ui-state-default');
33 this.content.addClass('ui-widget section_content');
33 this.content.addClass('ui-widget section_content');
34 };
34 };
35
35
36
36
37 PanelSection.prototype.bind_events = function () {
37 PanelSection.prototype.bind_events = function () {
38 var that = this;
38 var that = this;
39 this.header.click(function () {
39 this.header.click(function () {
40 that.toggle();
40 that.toggle();
41 });
41 });
42 this.header.hover(function () {
42 this.header.hover(function () {
43 that.header.toggleClass('ui-state-hover');
43 that.header.toggleClass('ui-state-hover');
44 });
44 });
45 };
45 };
46
46
47
47
48 PanelSection.prototype.expand = function () {
48 PanelSection.prototype.expand = function () {
49 if (!this.expanded) {
49 if (!this.expanded) {
50 this.content.slideDown('fast');
50 this.content.slideDown('fast');
51 this.expanded = true;
51 this.expanded = true;
52 };
52 };
53 };
53 };
54
54
55
55
56 PanelSection.prototype.collapse = function () {
56 PanelSection.prototype.collapse = function () {
57 if (this.expanded) {
57 if (this.expanded) {
58 this.content.slideUp('fast');
58 this.content.slideUp('fast');
59 this.expanded = false;
59 this.expanded = false;
60 };
60 };
61 };
61 };
62
62
63
63
64 PanelSection.prototype.toggle = function () {
64 PanelSection.prototype.toggle = function () {
65 if (this.expanded === true) {
65 if (this.expanded === true) {
66 this.collapse();
66 this.collapse();
67 } else {
67 } else {
68 this.expand();
68 this.expand();
69 };
69 };
70 };
70 };
71
71
72
72
73 PanelSection.prototype.create_children = function () {};
73 PanelSection.prototype.create_children = function () {};
74
74
75
75
76 // NotebookSection
76 // NotebookSection
77
77
78 var NotebookSection = function () {
78 var NotebookSection = function () {
79 PanelSection.apply(this, arguments);
79 PanelSection.apply(this, arguments);
80 };
80 };
81
81
82
82
83 NotebookSection.prototype = new PanelSection();
83 NotebookSection.prototype = new PanelSection();
84
84
85
85
86 NotebookSection.prototype.style = function () {
86 NotebookSection.prototype.style = function () {
87 PanelSection.prototype.style.apply(this);
87 PanelSection.prototype.style.apply(this);
88 this.content.addClass('ui-helper-clearfix');
88 this.content.addClass('ui-helper-clearfix');
89 this.content.find('div.section_row').addClass('ui-helper-clearfix');
89 this.content.find('div.section_row').addClass('ui-helper-clearfix');
90 this.content.find('#new_open').buttonset();
90 this.content.find('#new_open').buttonset();
91 this.content.find('#download_notebook').button();
91 this.content.find('#download_notebook').button();
92 this.content.find('#upload_notebook').button();
92 this.content.find('#upload_notebook').button();
93 this.content.find('#download_format').addClass('ui-widget ui-widget-content');
93 this.content.find('#download_format').addClass('ui-widget ui-widget-content');
94 this.content.find('#download_format option').addClass('ui-widget ui-widget-content');
94 this.content.find('#download_format option').addClass('ui-widget ui-widget-content');
95 };
95 };
96
96
97
97
98 NotebookSection.prototype.bind_events = function () {
98 NotebookSection.prototype.bind_events = function () {
99 PanelSection.prototype.bind_events.apply(this);
99 PanelSection.prototype.bind_events.apply(this);
100 var that = this;
100 var that = this;
101 this.content.find('#new_notebook').click(function () {
101 this.content.find('#new_notebook').click(function () {
102 window.open('/new');
102 window.open('/new');
103 });
103 });
104 this.content.find('#open_notebook').click(function () {
104 this.content.find('#open_notebook').click(function () {
105 window.open('/');
105 window.open('/');
106 });
106 });
107 this.content.find('#download_notebook').click(function () {
107 this.content.find('#download_notebook').click(function () {
108 var format = that.content.find('#download_format').val();
108 var format = that.content.find('#download_format').val();
109 var notebook_id = IPython.save_widget.get_notebook_id();
109 var notebook_id = IPython.save_widget.get_notebook_id();
110 var url = '/notebooks/' + notebook_id + '?format=' + format;
110 var url = '/notebooks/' + notebook_id + '?format=' + format;
111 window.open(url,'_newtab');
111 window.open(url,'_newtab');
112 });
112 });
113 };
113 };
114
114
115 // CellSection
115 // CellSection
116
116
117 var CellSection = function () {
117 var CellSection = function () {
118 PanelSection.apply(this, arguments);
118 PanelSection.apply(this, arguments);
119 };
119 };
120
120
121
121
122 CellSection.prototype = new PanelSection();
122 CellSection.prototype = new PanelSection();
123
123
124
124
125 CellSection.prototype.style = function () {
125 CellSection.prototype.style = function () {
126 PanelSection.prototype.style.apply(this);
126 PanelSection.prototype.style.apply(this);
127 this.content.addClass('ui-helper-clearfix');
127 this.content.addClass('ui-helper-clearfix');
128 this.content.find('div.section_row').addClass('ui-helper-clearfix');
128 this.content.find('div.section_row').addClass('ui-helper-clearfix');
129 this.content.find('#delete_cell').button();
129 this.content.find('#delete_cell').button();
130 this.content.find('#insert').buttonset();
130 this.content.find('#insert').buttonset();
131 this.content.find('#move').buttonset();
131 this.content.find('#move').buttonset();
132 this.content.find('#cell_type').buttonset();
132 this.content.find('#cell_type').buttonset();
133 this.content.find('#toggle_output').buttonset();
133 this.content.find('#toggle_output').buttonset();
134 this.content.find('#run_cells').buttonset();
134 this.content.find('#run_cells').buttonset();
135 };
135 };
136
136
137
137
138 CellSection.prototype.bind_events = function () {
138 CellSection.prototype.bind_events = function () {
139 PanelSection.prototype.bind_events.apply(this);
139 PanelSection.prototype.bind_events.apply(this);
140 this.content.find('#collapse_cell').click(function () {
140 this.content.find('#collapse_cell').click(function () {
141 IPython.notebook.collapse();
141 IPython.notebook.collapse();
142 });
142 });
143 this.content.find('#expand_cell').click(function () {
143 this.content.find('#expand_cell').click(function () {
144 IPython.notebook.expand();
144 IPython.notebook.expand();
145 });
145 });
146 this.content.find('#clear_all_output').click(function () {
146 this.content.find('#clear_all_output').click(function () {
147 IPython.notebook.clear_all_output();
147 IPython.notebook.clear_all_output();
148 });
148 });
149 this.content.find('#delete_cell').click(function () {
149 this.content.find('#delete_cell').click(function () {
150 IPython.notebook.delete_cell();
150 IPython.notebook.delete_cell();
151 });
151 });
152 this.content.find('#insert_cell_above').click(function () {
152 this.content.find('#insert_cell_above').click(function () {
153 IPython.notebook.insert_code_cell_before();
153 IPython.notebook.insert_code_cell_before();
154 });
154 });
155 this.content.find('#insert_cell_below').click(function () {
155 this.content.find('#insert_cell_below').click(function () {
156 IPython.notebook.insert_code_cell_after();
156 IPython.notebook.insert_code_cell_after();
157 });
157 });
158 this.content.find('#move_cell_up').click(function () {
158 this.content.find('#move_cell_up').click(function () {
159 IPython.notebook.move_cell_up();
159 IPython.notebook.move_cell_up();
160 });
160 });
161 this.content.find('#move_cell_down').click(function () {
161 this.content.find('#move_cell_down').click(function () {
162 IPython.notebook.move_cell_down();
162 IPython.notebook.move_cell_down();
163 });
163 });
164 this.content.find('#to_code').click(function () {
164 this.content.find('#to_code').click(function () {
165 IPython.notebook.to_code();
165 IPython.notebook.to_code();
166 });
166 });
167 this.content.find('#to_html').click(function () {
167 // this.content.find('#to_html').click(function () {
168 IPython.notebook.to_html();
168 // IPython.notebook.to_html();
169 });
169 // });
170 this.content.find('#to_markdown').click(function () {
170 this.content.find('#to_markdown').click(function () {
171 IPython.notebook.to_markdown();
171 IPython.notebook.to_markdown();
172 });
172 });
173 this.content.find('#run_selected_cell').click(function () {
173 this.content.find('#run_selected_cell').click(function () {
174 IPython.notebook.execute_selected_cell();
174 IPython.notebook.execute_selected_cell();
175 });
175 });
176 this.content.find('#run_all_cells').click(function () {
176 this.content.find('#run_all_cells').click(function () {
177 IPython.notebook.execute_all_cells();
177 IPython.notebook.execute_all_cells();
178 });
178 });
179 this.content.find('#autoindent').change(function () {
179 this.content.find('#autoindent').change(function () {
180 var state = $('#autoindent').prop('checked');
180 var state = $('#autoindent').prop('checked');
181 IPython.notebook.set_autoindent(state);
181 IPython.notebook.set_autoindent(state);
182 });
182 });
183 };
183 };
184
184
185
185
186 // KernelSection
186 // KernelSection
187
187
188 var KernelSection = function () {
188 var KernelSection = function () {
189 PanelSection.apply(this, arguments);
189 PanelSection.apply(this, arguments);
190 };
190 };
191
191
192
192
193 KernelSection.prototype = new PanelSection();
193 KernelSection.prototype = new PanelSection();
194
194
195
195
196 KernelSection.prototype.style = function () {
196 KernelSection.prototype.style = function () {
197 PanelSection.prototype.style.apply(this);
197 PanelSection.prototype.style.apply(this);
198 this.content.addClass('ui-helper-clearfix');
198 this.content.addClass('ui-helper-clearfix');
199 this.content.find('div.section_row').addClass('ui-helper-clearfix');
199 this.content.find('div.section_row').addClass('ui-helper-clearfix');
200 this.content.find('#int_restart').buttonset();
200 this.content.find('#int_restart').buttonset();
201 };
201 };
202
202
203
203
204 KernelSection.prototype.bind_events = function () {
204 KernelSection.prototype.bind_events = function () {
205 PanelSection.prototype.bind_events.apply(this);
205 PanelSection.prototype.bind_events.apply(this);
206 this.content.find('#restart_kernel').click(function () {
206 this.content.find('#restart_kernel').click(function () {
207 IPython.notebook.restart_kernel();
207 IPython.notebook.restart_kernel();
208 });
208 });
209 this.content.find('#int_kernel').click(function () {
209 this.content.find('#int_kernel').click(function () {
210 IPython.notebook.kernel.interrupt();
210 IPython.notebook.kernel.interrupt();
211 });
211 });
212 };
212 };
213
213
214
214
215 // HelpSection
215 // HelpSection
216
216
217 var HelpSection = function () {
217 var HelpSection = function () {
218 PanelSection.apply(this, arguments);
218 PanelSection.apply(this, arguments);
219 };
219 };
220
220
221
221
222 HelpSection.prototype = new PanelSection();
222 HelpSection.prototype = new PanelSection();
223
223
224
224
225 HelpSection.prototype.style = function () {
225 HelpSection.prototype.style = function () {
226 PanelSection.prototype.style.apply(this);
226 PanelSection.prototype.style.apply(this);
227 PanelSection.prototype.style.apply(this);
227 PanelSection.prototype.style.apply(this);
228 this.content.addClass('ui-helper-clearfix');
228 this.content.addClass('ui-helper-clearfix');
229 this.content.find('div.section_row').addClass('ui-helper-clearfix');
229 this.content.find('div.section_row').addClass('ui-helper-clearfix');
230 this.content.find('#help_buttons0').buttonset();
230 this.content.find('#help_buttons0').buttonset();
231 this.content.find('#help_buttons1').buttonset();
231 this.content.find('#help_buttons1').buttonset();
232 };
232 };
233
233
234
234
235 HelpSection.prototype.bind_events = function () {
235 HelpSection.prototype.bind_events = function () {
236 PanelSection.prototype.bind_events.apply(this);
236 PanelSection.prototype.bind_events.apply(this);
237 };
237 };
238
238
239
239
240 // Set module variables
240 // Set module variables
241
241
242 IPython.PanelSection = PanelSection;
242 IPython.PanelSection = PanelSection;
243 IPython.NotebookSection = NotebookSection;
243 IPython.NotebookSection = NotebookSection;
244 IPython.CellSection = CellSection;
244 IPython.CellSection = CellSection;
245 IPython.KernelSection = KernelSection;
245 IPython.KernelSection = KernelSection;
246 IPython.HelpSection = HelpSection;
246 IPython.HelpSection = HelpSection;
247
247
248 return IPython;
248 return IPython;
249
249
250 }(IPython));
250 }(IPython));
251
251
@@ -1,254 +1,257 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
2 // Copyright (C) 2008-2011 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // TextCell
9 // TextCell
10 //============================================================================
10 //============================================================================
11
11
12 var IPython = (function (IPython) {
12 var IPython = (function (IPython) {
13
13
14 // TextCell base class
14 // TextCell base class
15
15
16 var TextCell = function (notebook) {
16 var TextCell = function (notebook) {
17 this.code_mirror_mode = this.code_mirror_mode || 'htmlmixed';
17 this.code_mirror_mode = this.code_mirror_mode || 'htmlmixed';
18 this.placeholder = this.placeholder || '';
18 this.placeholder = this.placeholder || '';
19 IPython.Cell.apply(this, arguments);
19 IPython.Cell.apply(this, arguments);
20 this.rendered = false;
20 this.rendered = false;
21 this.cell_type = this.cell_type || 'text';
21 this.cell_type = this.cell_type || 'text';
22 };
22 };
23
23
24
24
25 TextCell.prototype = new IPython.Cell();
25 TextCell.prototype = new IPython.Cell();
26
26
27
27
28 TextCell.prototype.create_element = function () {
28 TextCell.prototype.create_element = function () {
29 var cell = $("<div>").addClass('cell text_cell border-box-sizing');
29 var cell = $("<div>").addClass('cell text_cell border-box-sizing');
30 var input_area = $('<div/>').addClass('text_cell_input');
30 var input_area = $('<div/>').addClass('text_cell_input');
31 this.code_mirror = CodeMirror(input_area.get(0), {
31 this.code_mirror = CodeMirror(input_area.get(0), {
32 indentUnit : 4,
32 indentUnit : 4,
33 mode: this.code_mirror_mode,
33 mode: this.code_mirror_mode,
34 theme: 'default',
34 theme: 'default',
35 value: this.placeholder
35 value: this.placeholder
36 });
36 });
37 // The tabindex=-1 makes this div focusable.
37 // The tabindex=-1 makes this div focusable.
38 var render_area = $('<div/>').addClass('text_cell_render').
38 var render_area = $('<div/>').addClass('text_cell_render').
39 addClass('rendered_html').attr('tabindex','-1');
39 addClass('rendered_html').attr('tabindex','-1');
40 cell.append(input_area).append(render_area);
40 cell.append(input_area).append(render_area);
41 this.element = cell;
41 this.element = cell;
42 };
42 };
43
43
44
44
45 TextCell.prototype.bind_events = function () {
45 TextCell.prototype.bind_events = function () {
46 IPython.Cell.prototype.bind_events.apply(this);
46 IPython.Cell.prototype.bind_events.apply(this);
47 var that = this;
47 var that = this;
48 this.element.keydown(function (event) {
48 this.element.keydown(function (event) {
49 if (event.which === 13) {
49 if (event.which === 13) {
50 if (that.rendered) {
50 if (that.rendered) {
51 that.edit();
51 that.edit();
52 event.preventDefault();
52 event.preventDefault();
53 };
53 };
54 };
54 };
55 });
55 });
56 };
56 };
57
57
58
58
59 TextCell.prototype.select = function () {
59 TextCell.prototype.select = function () {
60 IPython.Cell.prototype.select.apply(this);
60 IPython.Cell.prototype.select.apply(this);
61 var output = this.element.find("div.text_cell_render");
61 var output = this.element.find("div.text_cell_render");
62 output.trigger('focus');
62 output.trigger('focus');
63 };
63 };
64
64
65
65
66 TextCell.prototype.edit = function () {
66 TextCell.prototype.edit = function () {
67 if (this.rendered === true) {
67 if (this.rendered === true) {
68 var text_cell = this.element;
68 var text_cell = this.element;
69 var output = text_cell.find("div.text_cell_render");
69 var output = text_cell.find("div.text_cell_render");
70 output.hide();
70 output.hide();
71 text_cell.find('div.text_cell_input').show();
71 text_cell.find('div.text_cell_input').show();
72 this.code_mirror.focus();
72 this.code_mirror.focus();
73 this.code_mirror.refresh();
73 this.code_mirror.refresh();
74 this.rendered = false;
74 this.rendered = false;
75 if (this.get_source() === this.placeholder) {
76 this.set_source('');
77 };
75 };
78 };
76 };
79 };
77
80
78
81
79 // Subclasses must define render.
82 // Subclasses must define render.
80 TextCell.prototype.render = function () {};
83 TextCell.prototype.render = function () {};
81
84
82
85
83 TextCell.prototype.config_mathjax = function () {
86 TextCell.prototype.config_mathjax = function () {
84 var text_cell = this.element;
87 var text_cell = this.element;
85 var that = this;
88 var that = this;
86 text_cell.click(function () {
89 text_cell.click(function () {
87 that.edit();
90 that.edit();
88 }).focusout(function () {
91 }).focusout(function () {
89 that.render();
92 that.render();
90 });
93 });
91
94
92 text_cell.trigger("focusout");
95 text_cell.trigger("focusout");
93 };
96 };
94
97
95
98
96 TextCell.prototype.get_source = function() {
99 TextCell.prototype.get_source = function() {
97 return this.code_mirror.getValue();
100 return this.code_mirror.getValue();
98 };
101 };
99
102
100
103
101 TextCell.prototype.set_source = function(text) {
104 TextCell.prototype.set_source = function(text) {
102 this.code_mirror.setValue(text);
105 this.code_mirror.setValue(text);
103 this.code_mirror.refresh();
106 this.code_mirror.refresh();
104 };
107 };
105
108
106
109
107 TextCell.prototype.get_rendered = function() {
110 TextCell.prototype.get_rendered = function() {
108 return this.element.find('div.text_cell_render').html();
111 return this.element.find('div.text_cell_render').html();
109 };
112 };
110
113
111
114
112 TextCell.prototype.set_rendered = function(text) {
115 TextCell.prototype.set_rendered = function(text) {
113 this.element.find('div.text_cell_render').html(text);
116 this.element.find('div.text_cell_render').html(text);
114 };
117 };
115
118
116
119
117 TextCell.prototype.at_top = function () {
120 TextCell.prototype.at_top = function () {
118 if (this.rendered) {
121 if (this.rendered) {
119 return true;
122 return true;
120 } else {
123 } else {
121 return false;
124 return false;
122 }
125 }
123 };
126 };
124
127
125
128
126 TextCell.prototype.at_bottom = function () {
129 TextCell.prototype.at_bottom = function () {
127 if (this.rendered) {
130 if (this.rendered) {
128 return true;
131 return true;
129 } else {
132 } else {
130 return false;
133 return false;
131 }
134 }
132 };
135 };
133
136
134
137
135 TextCell.prototype.fromJSON = function (data) {
138 TextCell.prototype.fromJSON = function (data) {
136 if (data.cell_type === this.cell_type) {
139 if (data.cell_type === this.cell_type) {
137 if (data.source !== undefined) {
140 if (data.source !== undefined) {
138 this.set_source(data.source);
141 this.set_source(data.source);
139 this.set_rendered(data.rendered || '');
142 this.set_rendered(data.rendered || '');
140 this.rendered = false;
143 this.rendered = false;
141 this.render();
144 this.render();
142 };
145 };
143 };
146 };
144 };
147 };
145
148
146
149
147 TextCell.prototype.toJSON = function () {
150 TextCell.prototype.toJSON = function () {
148 var data = {}
151 var data = {}
149 data.cell_type = this.cell_type;
152 data.cell_type = this.cell_type;
150 data.source = this.get_source();
153 data.source = this.get_source();
151 return data;
154 return data;
152 };
155 };
153
156
154
157
155 // HTMLCell
158 // HTMLCell
156
159
157 var HTMLCell = function (notebook) {
160 var HTMLCell = function (notebook) {
158 this.placeholder = "Type <strong>HTML</strong> and LaTeX: $\\alpha^2$";
161 this.placeholder = "Type <strong>HTML</strong> and LaTeX: $\\alpha^2$";
159 IPython.TextCell.apply(this, arguments);
162 IPython.TextCell.apply(this, arguments);
160 this.cell_type = 'html';
163 this.cell_type = 'html';
161 };
164 };
162
165
163
166
164 HTMLCell.prototype = new TextCell();
167 HTMLCell.prototype = new TextCell();
165
168
166
169
167 HTMLCell.prototype.render = function () {
170 HTMLCell.prototype.render = function () {
168 if (this.rendered === false) {
171 if (this.rendered === false) {
169 var text = this.get_source();
172 var text = this.get_source();
170 if (text === "") {text = this.placeholder;};
173 if (text === "") {text = this.placeholder;};
171 this.set_rendered(text);
174 this.set_rendered(text);
172 MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
175 MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
173 this.element.find('div.text_cell_input').hide();
176 this.element.find('div.text_cell_input').hide();
174 this.element.find("div.text_cell_render").show();
177 this.element.find("div.text_cell_render").show();
175 this.rendered = true;
178 this.rendered = true;
176 };
179 };
177 };
180 };
178
181
179
182
180 // MarkdownCell
183 // MarkdownCell
181
184
182 var MarkdownCell = function (notebook) {
185 var MarkdownCell = function (notebook) {
183 this.placeholder = "Type *Markdown* and LaTeX: $\\alpha^2$";
186 this.placeholder = "Type *Markdown* and LaTeX: $\\alpha^2$";
184 IPython.TextCell.apply(this, arguments);
187 IPython.TextCell.apply(this, arguments);
185 this.cell_type = 'markdown';
188 this.cell_type = 'markdown';
186 };
189 };
187
190
188
191
189 MarkdownCell.prototype = new TextCell();
192 MarkdownCell.prototype = new TextCell();
190
193
191
194
192 MarkdownCell.prototype.render = function () {
195 MarkdownCell.prototype.render = function () {
193 if (this.rendered === false) {
196 if (this.rendered === false) {
194 var text = this.get_source();
197 var text = this.get_source();
195 if (text === "") {text = this.placeholder;};
198 if (text === "") {text = this.placeholder;};
196 var html = IPython.markdown_converter.makeHtml(text);
199 var html = IPython.markdown_converter.makeHtml(text);
197 this.set_rendered(html);
200 this.set_rendered(html);
198 MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
201 MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
199 this.element.find('div.text_cell_input').hide();
202 this.element.find('div.text_cell_input').hide();
200 this.element.find("div.text_cell_render").show();
203 this.element.find("div.text_cell_render").show();
201 this.rendered = true;
204 this.rendered = true;
202 };
205 };
203 };
206 };
204
207
205
208
206 // RSTCell
209 // RSTCell
207
210
208 var RSTCell = function (notebook) {
211 var RSTCell = function (notebook) {
209 this.placeholder = "Type *ReStructured Text* and LaTeX: $\\alpha^2$";
212 this.placeholder = "Type *ReStructured Text* and LaTeX: $\\alpha^2$";
210 IPython.TextCell.apply(this, arguments);
213 IPython.TextCell.apply(this, arguments);
211 this.cell_type = 'rst';
214 this.cell_type = 'rst';
212 };
215 };
213
216
214
217
215 RSTCell.prototype = new TextCell();
218 RSTCell.prototype = new TextCell();
216
219
217
220
218 RSTCell.prototype.render = function () {
221 RSTCell.prototype.render = function () {
219 if (this.rendered === false) {
222 if (this.rendered === false) {
220 var text = this.get_source();
223 var text = this.get_source();
221 if (text === "") {text = this.placeholder;};
224 if (text === "") {text = this.placeholder;};
222 var settings = {
225 var settings = {
223 processData : false,
226 processData : false,
224 cache : false,
227 cache : false,
225 type : "POST",
228 type : "POST",
226 data : text,
229 data : text,
227 headers : {'Content-Type': 'application/x-rst'},
230 headers : {'Content-Type': 'application/x-rst'},
228 success : $.proxy(this.handle_render,this)
231 success : $.proxy(this.handle_render,this)
229 };
232 };
230 $.ajax("/rstservice/render", settings);
233 $.ajax("/rstservice/render", settings);
231 this.element.find('div.text_cell_input').hide();
234 this.element.find('div.text_cell_input').hide();
232 this.element.find("div.text_cell_render").show();
235 this.element.find("div.text_cell_render").show();
233 this.set_rendered("Rendering...");
236 this.set_rendered("Rendering...");
234 };
237 };
235 };
238 };
236
239
237
240
238 RSTCell.prototype.handle_render = function (data, status, xhr) {
241 RSTCell.prototype.handle_render = function (data, status, xhr) {
239 this.set_rendered(data);
242 this.set_rendered(data);
240 MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
243 MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
241 this.rendered = true;
244 this.rendered = true;
242 };
245 };
243
246
244
247
245 IPython.TextCell = TextCell;
248 IPython.TextCell = TextCell;
246 IPython.HTMLCell = HTMLCell;
249 IPython.HTMLCell = HTMLCell;
247 IPython.MarkdownCell = MarkdownCell;
250 IPython.MarkdownCell = MarkdownCell;
248 IPython.RSTCell = RSTCell;
251 IPython.RSTCell = RSTCell;
249
252
250
253
251 return IPython;
254 return IPython;
252
255
253 }(IPython));
256 }(IPython));
254
257
@@ -1,224 +1,224 b''
1 <!DOCTYPE HTML>
1 <!DOCTYPE HTML>
2 <html>
2 <html>
3
3
4 <head>
4 <head>
5 <meta charset="utf-8">
5 <meta charset="utf-8">
6
6
7 <title>IPython Notebook</title>
7 <title>IPython Notebook</title>
8
8
9 <link rel="stylesheet" href="static/jquery/css/themes/aristo/jquery-wijmo.css" type="text/css" />
9 <link rel="stylesheet" href="static/jquery/css/themes/aristo/jquery-wijmo.css" type="text/css" />
10 <!-- <link rel="stylesheet" href="static/jquery/css/themes/rocket/jquery-wijmo.css" type="text/css" /> -->
10 <!-- <link rel="stylesheet" href="static/jquery/css/themes/rocket/jquery-wijmo.css" type="text/css" /> -->
11 <!-- <link rel="stylesheet" href="static/jquery/css/themes/smoothness/jquery-ui-1.8.14.custom.css" type="text/css" />-->
11 <!-- <link rel="stylesheet" href="static/jquery/css/themes/smoothness/jquery-ui-1.8.14.custom.css" type="text/css" />-->
12
12
13 <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" charset="utf-8"></script>
13 <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" charset="utf-8"></script>
14 <!-- <script type='text/javascript' src='static/mathjax/MathJax.js?config=TeX-AMS_HTML' charset='utf-8'></script> -->
14 <!-- <script type='text/javascript' src='static/mathjax/MathJax.js?config=TeX-AMS_HTML' charset='utf-8'></script> -->
15 <script type="text/javascript">
15 <script type="text/javascript">
16 if (typeof MathJax == 'undefined') {
16 if (typeof MathJax == 'undefined') {
17 console.log("Trying to load local copy of MathJax");
17 console.log("Trying to load local copy of MathJax");
18 document.write(unescape("%3Cscript type='text/javascript' src='static/mathjax/MathJax.js%3Fconfig=TeX-AMS_HTML' charset='utf-8'%3E%3C/script%3E"));
18 document.write(unescape("%3Cscript type='text/javascript' src='static/mathjax/MathJax.js%3Fconfig=TeX-AMS_HTML' charset='utf-8'%3E%3C/script%3E"));
19 }
19 }
20 </script>
20 </script>
21
21
22 <link rel="stylesheet" href="static/codemirror-2.12/lib/codemirror.css">
22 <link rel="stylesheet" href="static/codemirror-2.12/lib/codemirror.css">
23 <link rel="stylesheet" href="static/codemirror-2.12/mode/rst/rst.css">
23 <link rel="stylesheet" href="static/codemirror-2.12/mode/rst/rst.css">
24 <link rel="stylesheet" href="static/codemirror-2.12/theme/ipython.css">
24 <link rel="stylesheet" href="static/codemirror-2.12/theme/ipython.css">
25 <link rel="stylesheet" href="static/codemirror-2.12/theme/default.css">
25 <link rel="stylesheet" href="static/codemirror-2.12/theme/default.css">
26
26
27 <link rel="stylesheet" href="static/css/boilerplate.css" type="text/css" />
27 <link rel="stylesheet" href="static/css/boilerplate.css" type="text/css" />
28 <link rel="stylesheet" href="static/css/layout.css" type="text/css" />
28 <link rel="stylesheet" href="static/css/layout.css" type="text/css" />
29 <link rel="stylesheet" href="static/css/base.css" type="text/css" />
29 <link rel="stylesheet" href="static/css/base.css" type="text/css" />
30 <link rel="stylesheet" href="static/css/notebook.css" type="text/css" />
30 <link rel="stylesheet" href="static/css/notebook.css" type="text/css" />
31 <link rel="stylesheet" href="static/css/renderedhtml.css" type="text/css" />
31 <link rel="stylesheet" href="static/css/renderedhtml.css" type="text/css" />
32
32
33
33
34 </head>
34 </head>
35
35
36 <body>
36 <body>
37
37
38 <div id="header">
38 <div id="header">
39 <span id="ipython_notebook"><h1>IPython Notebook</h1></span>
39 <span id="ipython_notebook"><h1>IPython Notebook</h1></span>
40 <span id="save_widget">
40 <span id="save_widget">
41 <input type="text" id="notebook_name" size="20"></textarea>
41 <input type="text" id="notebook_name" size="20"></textarea>
42 <span id="notebook_id" style="display:none">{{notebook_id}}</span>
42 <span id="notebook_id" style="display:none">{{notebook_id}}</span>
43 <button id="save_notebook">Save</button>
43 <button id="save_notebook">Save</button>
44 </span>
44 </span>
45 <span id="kernel_status">Idle</span>
45 <span id="kernel_status">Idle</span>
46 </div>
46 </div>
47
47
48 <div id="main_app">
48 <div id="main_app">
49
49
50 <div id="left_panel">
50 <div id="left_panel">
51
51
52 <div id="notebook_section">
52 <div id="notebook_section">
53 <h3 class="section_header">Notebook</h3>
53 <h3 class="section_header">Notebook</h3>
54 <div class="section_content">
54 <div class="section_content">
55 <div class="section_row">
55 <div class="section_row">
56 <span id="new_open" class="section_row_buttons">
56 <span id="new_open" class="section_row_buttons">
57 <button id="new_notebook">New</button>
57 <button id="new_notebook">New</button>
58 <button id="open_notebook">Open</button>
58 <button id="open_notebook">Open</button>
59 </span>
59 </span>
60 <span class="section_row_header">Actions</span>
60 <span class="section_row_header">Actions</span>
61 </div>
61 </div>
62 <div class="section_row">
62 <div class="section_row">
63 <span>
63 <span>
64 <select id="download_format">
64 <select id="download_format">
65 <option value="xml">xml</option>
65 <option value="xml">xml</option>
66 <option value="json">json</option>
66 <option value="json">json</option>
67 <option value="py">py</option>
67 <option value="py">py</option>
68 </select>
68 </select>
69 </span>
69 </span>
70 <span class="section_row_buttons">
70 <span class="section_row_buttons">
71 <button id="download_notebook">Export</button>
71 <button id="download_notebook">Export</button>
72 </span>
72 </span>
73 </div>
73 </div>
74 </div>
74 </div>
75 </div>
75 </div>
76
76
77 <div id="cell_section">
77 <div id="cell_section">
78 <h3 class="section_header">Cell</h3>
78 <h3 class="section_header">Cell</h3>
79 <div class="section_content">
79 <div class="section_content">
80 <div class="section_row">
80 <div class="section_row">
81 <span class="section_row_buttons">
81 <span class="section_row_buttons">
82 <button id="delete_cell">Delete</button>
82 <button id="delete_cell">Delete</button>
83 </span>
83 </span>
84 <span class="section_row_header">Actions</span>
84 <span class="section_row_header">Actions</span>
85 </div>
85 </div>
86 <div class="section_row">
86 <div class="section_row">
87 <span id="cell_type" class="section_row_buttons">
87 <span id="cell_type" class="section_row_buttons">
88 <button id="to_code">Code</button>
88 <button id="to_code">Code</button>
89 <button id="to_html">HTML</button>
89 <!-- <button id="to_html">HTML</button>-->
90 <button id="to_markdown">Markdown</button>
90 <button id="to_markdown">Markdown</button>
91 </span>
91 </span>
92 <span class="button_label">Format</span>
92 <span class="button_label">Format</span>
93 </div>
93 </div>
94 <div class="section_row">
94 <div class="section_row">
95 <span id="toggle_output" class="section_row_buttons">
95 <span id="toggle_output" class="section_row_buttons">
96 <button id="collapse_cell">Collapse</button>
96 <button id="collapse_cell">Collapse</button>
97 <button id="expand_cell">Expand</button>
97 <button id="expand_cell">Expand</button>
98 <button id="clear_all_output">ClearAll</button>
98 <button id="clear_all_output">ClearAll</button>
99 </span>
99 </span>
100 <span class="button_label">Output</span>
100 <span class="button_label">Output</span>
101 </div>
101 </div>
102 <div class="section_row">
102 <div class="section_row">
103 <span id="insert" class="section_row_buttons">
103 <span id="insert" class="section_row_buttons">
104 <button id="insert_cell_above">Above</button>
104 <button id="insert_cell_above">Above</button>
105 <button id="insert_cell_below">Below</button>
105 <button id="insert_cell_below">Below</button>
106 </span>
106 </span>
107 <span class="button_label">Insert</span>
107 <span class="button_label">Insert</span>
108 </div>
108 </div>
109 <div class="section_row">
109 <div class="section_row">
110 <span id="move" class="section_row_buttons">
110 <span id="move" class="section_row_buttons">
111 <button id="move_cell_up">Up</button>
111 <button id="move_cell_up">Up</button>
112 <button id="move_cell_down">Down</button>
112 <button id="move_cell_down">Down</button>
113 </span>
113 </span>
114 <span class="button_label">Move</span>
114 <span class="button_label">Move</span>
115 </div>
115 </div>
116 <div class="section_row">
116 <div class="section_row">
117 <span id="run_cells" class="section_row_buttons">
117 <span id="run_cells" class="section_row_buttons">
118 <button id="run_selected_cell">Selected</button>
118 <button id="run_selected_cell">Selected</button>
119 <button id="run_all_cells">All</button>
119 <button id="run_all_cells">All</button>
120 </span>
120 </span>
121 <span class="button_label">Run</span>
121 <span class="button_label">Run</span>
122 </div>
122 </div>
123 <div class="section_row">
123 <div class="section_row">
124 <span id="autoindent_span">
124 <span id="autoindent_span">
125 <input type="checkbox" id="autoindent" checked="true"></input>
125 <input type="checkbox" id="autoindent" checked="true"></input>
126 </span>
126 </span>
127 <span class="checkbox_label">Autoindent:</span>
127 <span class="checkbox_label">Autoindent:</span>
128 </div>
128 </div>
129 </div>
129 </div>
130 </div>
130 </div>
131
131
132 <div id="kernel_section">
132 <div id="kernel_section">
133 <h3 class="section_header">Kernel</h3>
133 <h3 class="section_header">Kernel</h3>
134 <div class="section_content">
134 <div class="section_content">
135 <div class="section_row">
135 <div class="section_row">
136 <span id="int_restart" class="section_row_buttons">
136 <span id="int_restart" class="section_row_buttons">
137 <button id="int_kernel">Interrupt</button>
137 <button id="int_kernel">Interrupt</button>
138 <button id="restart_kernel">Restart</button>
138 <button id="restart_kernel">Restart</button>
139 </span>
139 </span>
140 <span class="section_row_header">Actions</span>
140 <span class="section_row_header">Actions</span>
141 </div>
141 </div>
142 <div class="section_row">
142 <div class="section_row">
143 <span id="kernel_persist">
143 <span id="kernel_persist">
144 <input type="checkbox" id="kill_kernel"></input>
144 <input type="checkbox" id="kill_kernel"></input>
145 </span>
145 </span>
146 <span class="checkbox_label">Kill kernel upon exit:</span>
146 <span class="checkbox_label">Kill kernel upon exit:</span>
147 </div>
147 </div>
148 </div>
148 </div>
149 </div>
149 </div>
150
150
151 <div id="help_section">
151 <div id="help_section">
152 <h3 class="section_header">Help</h3>
152 <h3 class="section_header">Help</h3>
153 <div class="section_content">
153 <div class="section_content">
154 <div class="section_row">
154 <div class="section_row">
155 <span id="help_buttons0" class="section_row_buttons">
155 <span id="help_buttons0" class="section_row_buttons">
156 <button id="python_help"><a href="http://docs.python.org" target="_blank">Python</a></button>
156 <button id="python_help"><a href="http://docs.python.org" target="_blank">Python</a></button>
157 <button id="ipython_help"><a href="http://ipython.org/documentation.html" target="_blank">IPython</a></button>
157 <button id="ipython_help"><a href="http://ipython.org/documentation.html" target="_blank">IPython</a></button>
158 <button id="numpy_help"><a href="http://docs.scipy.org/doc/numpy/reference/" target="_blank">NumPy</a></button>
158 <button id="numpy_help"><a href="http://docs.scipy.org/doc/numpy/reference/" target="_blank">NumPy</a></button>
159 </span>
159 </span>
160 <span class="section_row_header">Links</span>
160 <span class="section_row_header">Links</span>
161 </div>
161 </div>
162 <div class="section_row">
162 <div class="section_row">
163 <span id="help_buttons1" class="section_row_buttons">
163 <span id="help_buttons1" class="section_row_buttons">
164 <button id="matplotlib_help"><a href="http://matplotlib.sourceforge.net/" target="_blank">MPL</a></button>
164 <button id="matplotlib_help"><a href="http://matplotlib.sourceforge.net/" target="_blank">MPL</a></button>
165 <button id="scipy_help"><a href="http://docs.scipy.org/doc/scipy/reference/" target="_blank">SciPy</a></button>
165 <button id="scipy_help"><a href="http://docs.scipy.org/doc/scipy/reference/" target="_blank">SciPy</a></button>
166 <button id="sympy_help"><a href="http://docs.sympy.org/dev/index.html" target="_blank">SymPy</a></button>
166 <button id="sympy_help"><a href="http://docs.sympy.org/dev/index.html" target="_blank">SymPy</a></button>
167 </span>
167 </span>
168 </div>
168 </div>
169 <div class="section_row">
169 <div class="section_row">
170 <span class="help_string">run selected cell</span>
170 <span class="help_string">run selected cell</span>
171 <span class="help_string_label">Shift-Enter |</span>
171 <span class="help_string_label">Shift-Enter |</span>
172 </div>
172 </div>
173 <div class="section_row">
173 <div class="section_row">
174 <span class="help_string">run in terminal mode</span>
174 <span class="help_string">run in terminal mode</span>
175 <span class="help_string_label">Ctrl-Enter |</span>
175 <span class="help_string_label">Ctrl-Enter |</span>
176 </div>
176 </div>
177 </div>
177 </div>
178 </div>
178 </div>
179
179
180 </div>
180 </div>
181 <div id="left_panel_splitter"></div>
181 <div id="left_panel_splitter"></div>
182 <div id="notebook_panel">
182 <div id="notebook_panel">
183 <div id="notebook"></div>
183 <div id="notebook"></div>
184 <div id="pager_splitter"></div>
184 <div id="pager_splitter"></div>
185 <div id="pager"></div>
185 <div id="pager"></div>
186 </div>
186 </div>
187
187
188 </div>
188 </div>
189
189
190 <script src="static/jquery/js/jquery-1.6.2.min.js" type="text/javascript" charset="utf-8"></script>
190 <script src="static/jquery/js/jquery-1.6.2.min.js" type="text/javascript" charset="utf-8"></script>
191 <script src="static/jquery/js/jquery-ui-1.8.14.custom.min.js" type="text/javascript" charset="utf-8"></script>
191 <script src="static/jquery/js/jquery-ui-1.8.14.custom.min.js" type="text/javascript" charset="utf-8"></script>
192 <script src="static/jquery/js/jquery.autogrow.js" type="text/javascript" charset="utf-8"></script>
192 <script src="static/jquery/js/jquery.autogrow.js" type="text/javascript" charset="utf-8"></script>
193
193
194 <script src="static/codemirror-2.12/lib/codemirror.js" charset="utf-8"></script>
194 <script src="static/codemirror-2.12/lib/codemirror.js" charset="utf-8"></script>
195 <script src="static/codemirror-2.12/mode/python/python.js" charset="utf-8"></script>
195 <script src="static/codemirror-2.12/mode/python/python.js" charset="utf-8"></script>
196 <script src="static/codemirror-2.12/mode/htmlmixed/htmlmixed.js" charset="utf-8"></script>
196 <script src="static/codemirror-2.12/mode/htmlmixed/htmlmixed.js" charset="utf-8"></script>
197 <script src="static/codemirror-2.12/mode/xml/xml.js" charset="utf-8"></script>
197 <script src="static/codemirror-2.12/mode/xml/xml.js" charset="utf-8"></script>
198 <script src="static/codemirror-2.12/mode/javascript/javascript.js" charset="utf-8"></script>
198 <script src="static/codemirror-2.12/mode/javascript/javascript.js" charset="utf-8"></script>
199 <script src="static/codemirror-2.12/mode/css/css.js" charset="utf-8"></script>
199 <script src="static/codemirror-2.12/mode/css/css.js" charset="utf-8"></script>
200 <script src="static/codemirror-2.12/mode/rst/rst.js" charset="utf-8"></script>
200 <script src="static/codemirror-2.12/mode/rst/rst.js" charset="utf-8"></script>
201
201
202 <script src="static/pagedown/Markdown.Converter.js" charset="utf-8"></script>
202 <script src="static/pagedown/Markdown.Converter.js" charset="utf-8"></script>
203
203
204 <script src="static/js/namespace.js" type="text/javascript" charset="utf-8"></script>
204 <script src="static/js/namespace.js" type="text/javascript" charset="utf-8"></script>
205 <script src="static/js/utils.js" type="text/javascript" charset="utf-8"></script>
205 <script src="static/js/utils.js" type="text/javascript" charset="utf-8"></script>
206 <script src="static/js/cell.js" type="text/javascript" charset="utf-8"></script>
206 <script src="static/js/cell.js" type="text/javascript" charset="utf-8"></script>
207 <script src="static/js/codecell.js" type="text/javascript" charset="utf-8"></script>
207 <script src="static/js/codecell.js" type="text/javascript" charset="utf-8"></script>
208 <script src="static/js/textcell.js" type="text/javascript" charset="utf-8"></script>
208 <script src="static/js/textcell.js" type="text/javascript" charset="utf-8"></script>
209 <script src="static/js/kernel.js" type="text/javascript" charset="utf-8"></script>
209 <script src="static/js/kernel.js" type="text/javascript" charset="utf-8"></script>
210 <script src="static/js/kernelstatus.js" type="text/javascript" charset="utf-8"></script>
210 <script src="static/js/kernelstatus.js" type="text/javascript" charset="utf-8"></script>
211 <script src="static/js/layout.js" type="text/javascript" charset="utf-8"></script>
211 <script src="static/js/layout.js" type="text/javascript" charset="utf-8"></script>
212 <script src="static/js/savewidget.js" type="text/javascript" charset="utf-8"></script>
212 <script src="static/js/savewidget.js" type="text/javascript" charset="utf-8"></script>
213 <script src="static/js/pager.js" type="text/javascript" charset="utf-8"></script>
213 <script src="static/js/pager.js" type="text/javascript" charset="utf-8"></script>
214 <script src="static/js/panelsection.js" type="text/javascript" charset="utf-8"></script>
214 <script src="static/js/panelsection.js" type="text/javascript" charset="utf-8"></script>
215 <script src="static/js/leftpanel.js" type="text/javascript" charset="utf-8"></script>
215 <script src="static/js/leftpanel.js" type="text/javascript" charset="utf-8"></script>
216 <script src="static/js/notebook.js" type="text/javascript" charset="utf-8"></script>
216 <script src="static/js/notebook.js" type="text/javascript" charset="utf-8"></script>
217 <script src="static/js/notebook_main.js" type="text/javascript" charset="utf-8"></script>
217 <script src="static/js/notebook_main.js" type="text/javascript" charset="utf-8"></script>
218
218
219
219
220 </body>
220 </body>
221
221
222 </html>
222 </html>
223
223
224
224
General Comments 0
You need to be logged in to leave comments. Login now