Show More
@@ -1,19 +1,11 b'' | |||||
1 | //---------------------------------------------------------------------------- |
|
1 | // Copyright (c) IPython Development Team. | |
2 | // Copyright (C) 2014 The IPython Development Team |
|
2 | // Distributed under the terms of the Modified BSD License. | |
3 | // |
|
|||
4 | // Distributed under the terms of the BSD License. The full license is in |
|
|||
5 | // the file COPYING, distributed as part of this software. |
|
|||
6 | //---------------------------------------------------------------------------- |
|
|||
7 |
|
3 | |||
8 | //============================================================================ |
|
4 | define([ | |
9 | // Utilities |
|
5 | 'base/js/namespace', | |
10 | //============================================================================ |
|
6 | 'components/jquery/jquery.min' | |
11 | IPython.namespace('IPython.security'); |
|
7 | ], function(IPython, $) { | |
12 |
|
||||
13 | IPython.security = (function (IPython) { |
|
|||
14 | "use strict"; |
|
8 | "use strict"; | |
15 |
|
||||
16 | var utils = IPython.utils; |
|
|||
17 |
|
9 | |||
18 | var noop = function (x) { return x; }; |
|
10 | var noop = function (x) { return x; }; | |
19 |
|
11 | |||
@@ -121,6 +113,4 b' IPython.security = (function (IPython) {' | |||||
121 | caja: caja, |
|
113 | caja: caja, | |
122 | sanitize_html: sanitize_html |
|
114 | sanitize_html: sanitize_html | |
123 | }; |
|
115 | }; | |
124 |
|
116 | }); | ||
125 | }(IPython)); |
|
|||
126 |
|
@@ -550,7 +550,8 b' define([' | |||||
550 | log_ajax_error : log_ajax_error, |
|
550 | log_ajax_error : log_ajax_error, | |
551 | }; |
|
551 | }; | |
552 |
|
552 | |||
553 | // Register self in the global namespace for convenience. |
|
553 | // Backwards compatability. | |
554 | IPython.Utils = Utils; |
|
554 | IPython.Utils = Utils; | |
|
555 | ||||
555 | return Utils; |
|
556 | return Utils; | |
556 | }); |
|
557 | }); |
@@ -1,73 +1,51 b'' | |||||
1 | "components/codemirror/lib/codemirror.js", |
|
1 | // Copyright (c) IPython Development Team. | |
2 | // Set codemirror version. |
|
2 | // Distributed under the terms of the Modified BSD License. | |
3 | // CodeMirror.modeURL = "{{ static_url("components/codemirror/mode/%N/%N.js", include_version=False) }}"; |
|
3 | ||
4 | "components/codemirror/addon/mode/loadmode.js", |
|
4 | define([ | |
5 | "components/codemirror/addon/mode/multiplex.js", |
|
5 | 'base/js/namespace', | |
6 | "components/codemirror/addon/mode/overlay.js", |
|
6 | 'components/jquery/jquery.min', | |
7 | "components/codemirror/addon/edit/matchbrackets.js", |
|
7 | 'components/codemirror/lib/codemirror.js', | |
8 | "components/codemirror/addon/edit/closebrackets.js", |
|
8 | 'base/js/utils', | |
9 | "components/codemirror/addon/comment/comment.js", |
|
9 | ||
10 | "components/codemirror/mode/htmlmixed/htmlmixed.js", |
|
10 | // Set codemirror version. | |
11 | "components/codemirror/mode/xml/xml.js", |
|
11 | // CodeMirror.modeURL = '{{ static_url("components/codemirror/mode/%N/%N.js", include_version=False) }}'; | |
12 |
|
|
12 | 'components/codemirror/addon/mode/loadmode.js', | |
13 |
|
|
13 | 'components/codemirror/addon/mode/multiplex.js', | |
14 |
|
|
14 | 'components/codemirror/addon/mode/overlay.js', | |
15 |
|
|
15 | 'components/codemirror/addon/edit/matchbrackets.js', | |
16 |
|
|
16 | 'components/codemirror/addon/edit/closebrackets.js', | |
17 | "notebook/js/codemirror-ipython.js", |
|
17 | 'components/codemirror/addon/comment/comment.js', | |
18 | "notebook/js/codemirror-ipythongfm.js", |
|
18 | 'components/codemirror/mode/htmlmixed/htmlmixed.js', | |
19 |
|
19 | 'components/codemirror/mode/xml/xml.js', | ||
20 |
|
20 | 'components/codemirror/mode/javascript/javascript.js', | ||
21 | // monkey patch CM to be able to syntax highlight cell magics |
|
21 | 'components/codemirror/mode/css/css.js', | |
22 | // bug reported upstream, |
|
22 | 'components/codemirror/mode/rst/rst.js', | |
23 | // see https://github.com/marijnh/CodeMirror2/issues/670 |
|
23 | 'components/codemirror/mode/markdown/markdown.js', | |
24 | if(CodeMirror.getMode(1,'text/plain').indent === undefined ){ |
|
24 | 'components/codemirror/mode/python/python.js', | |
25 | console.log('patching CM for undefined indent'); |
|
25 | 'notebook/js/codemirror-ipython.js', | |
26 | CodeMirror.modes.null = function() { |
|
26 | 'notebook/js/codemirror-ipythongfm.js', | |
27 | return {token: function(stream) {stream.skipToEnd();},indent : function(){return 0;}}; |
|
27 | ], function(IPython, $, CodeMirror, Utils) { | |
28 | }; |
|
|||
29 | } |
|
|||
30 |
|
||||
31 | CodeMirror.patchedGetMode = function(config, mode){ |
|
|||
32 | var cmmode = CodeMirror.getMode(config, mode); |
|
|||
33 | if(cmmode.indent === null) { |
|
|||
34 | console.log('patch mode "' , mode, '" on the fly'); |
|
|||
35 | cmmode.indent = function(){return 0;}; |
|
|||
36 | } |
|
|||
37 | return cmmode; |
|
|||
38 | }; |
|
|||
39 | // end monkey patching CodeMirror |
|
|||
40 |
|
||||
41 |
|
||||
42 | "notebook/js/tooltip", |
|
|||
43 | Tooltip, |
|
|||
44 | tooltip = new Tooltip(); |
|
|||
45 | IPython.tooltip = tooltip; |
|
|||
46 |
|
||||
47 |
|
||||
48 |
|
||||
49 | //---------------------------------------------------------------------------- |
|
|||
50 | // Copyright (C) 2008-2011 The IPython Development Team |
|
|||
51 | // |
|
|||
52 | // Distributed under the terms of the BSD License. The full license is in |
|
|||
53 | // the file COPYING, distributed as part of this software. |
|
|||
54 | //---------------------------------------------------------------------------- |
|
|||
55 |
|
||||
56 | //============================================================================ |
|
|||
57 | // Cell |
|
|||
58 | //============================================================================ |
|
|||
59 | /** |
|
|||
60 | * An extendable module that provide base functionnality to create cell for notebook. |
|
|||
61 | * @module IPython |
|
|||
62 | * @namespace IPython |
|
|||
63 | * @submodule Cell |
|
|||
64 | */ |
|
|||
65 |
|
||||
66 | var IPython = (function (IPython) { |
|
|||
67 | "use strict"; |
|
28 | "use strict"; | |
68 |
|
29 | |||
69 | var utils = IPython.utils; |
|
30 | // monkey patch CM to be able to syntax highlight cell magics | |
70 | var keycodes = IPython.keyboard.keycodes; |
|
31 | // bug reported upstream, | |
|
32 | // see https://github.com/marijnh/CodeMirror2/issues/670 | |||
|
33 | if(CodeMirror.getMode(1,'text/plain').indent === undefined ){ | |||
|
34 | console.log('patching CM for undefined indent'); | |||
|
35 | CodeMirror.modes.null = function() { | |||
|
36 | return {token: function(stream) {stream.skipToEnd();},indent : function(){return 0;}}; | |||
|
37 | }; | |||
|
38 | } | |||
|
39 | ||||
|
40 | CodeMirror.patchedGetMode = function(config, mode){ | |||
|
41 | var cmmode = CodeMirror.getMode(config, mode); | |||
|
42 | if(cmmode.indent === null) { | |||
|
43 | console.log('patch mode "' , mode, '" on the fly'); | |||
|
44 | cmmode.indent = function(){return 0;}; | |||
|
45 | } | |||
|
46 | return cmmode; | |||
|
47 | }; | |||
|
48 | // end monkey patching CodeMirror | |||
71 |
|
49 | |||
72 | /** |
|
50 | /** | |
73 | * The Base `Cell` class from which to inherit |
|
51 | * The Base `Cell` class from which to inherit | |
@@ -80,8 +58,8 b' var IPython = (function (IPython) {' | |||||
80 | * @param {object|undefined} [options] |
|
58 | * @param {object|undefined} [options] | |
81 | * @param [options.cm_config] {object} config to pass to CodeMirror, will extend default parameters |
|
59 | * @param [options.cm_config] {object} config to pass to CodeMirror, will extend default parameters | |
82 | */ |
|
60 | */ | |
83 |
var Cell = function ( |
|
61 | var Cell = function (keyboard_manager) { | |
84 |
|
62 | this.keyboard_manager = keyboard_manager; | ||
85 | options = this.mergeopt(Cell, options); |
|
63 | options = this.mergeopt(Cell, options); | |
86 | // superclass default overwrite our default |
|
64 | // superclass default overwrite our default | |
87 |
|
65 | |||
@@ -94,7 +72,7 b' var IPython = (function (IPython) {' | |||||
94 | // load this from metadata later ? |
|
72 | // load this from metadata later ? | |
95 | this.user_highlight = 'auto'; |
|
73 | this.user_highlight = 'auto'; | |
96 | this.cm_config = options.cm_config; |
|
74 | this.cm_config = options.cm_config; | |
97 |
this.cell_id = |
|
75 | this.cell_id = Utils.uuid(); | |
98 | this._options = options; |
|
76 | this._options = options; | |
99 |
|
77 | |||
100 | // For JS VM engines optimization, attributes should be all set (even |
|
78 | // For JS VM engines optimization, attributes should be all set (even | |
@@ -130,7 +108,7 b' var IPython = (function (IPython) {' | |||||
130 | // FIXME: Workaround CM Bug #332 (Safari segfault on drag) |
|
108 | // FIXME: Workaround CM Bug #332 (Safari segfault on drag) | |
131 | // by disabling drag/drop altogether on Safari |
|
109 | // by disabling drag/drop altogether on Safari | |
132 | // https://github.com/marijnh/CodeMirror/issues/332 |
|
110 | // https://github.com/marijnh/CodeMirror/issues/332 | |
133 |
if ( |
|
111 | if (Utils.browser[0] == "Safari") { | |
134 | Cell.options_default.cm_config.dragDrop = false; |
|
112 | Cell.options_default.cm_config.dragDrop = false; | |
135 | } |
|
113 | } | |
136 |
|
114 | |||
@@ -180,27 +158,27 b' var IPython = (function (IPython) {' | |||||
180 | // We trigger events so that Cell doesn't have to depend on Notebook. |
|
158 | // We trigger events so that Cell doesn't have to depend on Notebook. | |
181 | that.element.click(function (event) { |
|
159 | that.element.click(function (event) { | |
182 | if (!that.selected) { |
|
160 | if (!that.selected) { | |
183 |
|
|
161 | that.events.trigger('select.Cell', {'cell':that}); | |
184 | } |
|
162 | } | |
185 | }); |
|
163 | }); | |
186 | that.element.focusin(function (event) { |
|
164 | that.element.focusin(function (event) { | |
187 | if (!that.selected) { |
|
165 | if (!that.selected) { | |
188 |
|
|
166 | that.events.trigger('select.Cell', {'cell':that}); | |
189 | } |
|
167 | } | |
190 | }); |
|
168 | }); | |
191 | if (this.code_mirror) { |
|
169 | if (this.code_mirror) { | |
192 | this.code_mirror.on("change", function(cm, change) { |
|
170 | this.code_mirror.on("change", function(cm, change) { | |
193 |
|
|
171 | that.events.trigger("set_dirty.Notebook", {value: true}); | |
194 | }); |
|
172 | }); | |
195 | } |
|
173 | } | |
196 | if (this.code_mirror) { |
|
174 | if (this.code_mirror) { | |
197 | this.code_mirror.on('focus', function(cm, change) { |
|
175 | this.code_mirror.on('focus', function(cm, change) { | |
198 |
|
|
176 | that.events.trigger('edit_mode.Cell', {cell: that}); | |
199 | }); |
|
177 | }); | |
200 | } |
|
178 | } | |
201 | if (this.code_mirror) { |
|
179 | if (this.code_mirror) { | |
202 | this.code_mirror.on('blur', function(cm, change) { |
|
180 | this.code_mirror.on('blur', function(cm, change) { | |
203 |
|
|
181 | that.events.trigger('command_mode.Cell', {cell: that}); | |
204 | }); |
|
182 | }); | |
205 | } |
|
183 | } | |
206 | }; |
|
184 | }; | |
@@ -219,7 +197,7 b' var IPython = (function (IPython) {' | |||||
219 | */ |
|
197 | */ | |
220 | Cell.prototype.handle_codemirror_keyevent = function (editor, event) { |
|
198 | Cell.prototype.handle_codemirror_keyevent = function (editor, event) { | |
221 | var that = this; |
|
199 | var that = this; | |
222 |
var shortcuts = |
|
200 | var shortcuts = this.keyboard_manager.edit_shortcuts; | |
223 |
|
201 | |||
224 | // if this is an edit_shortcuts shortcut, the global keyboard/shortcut |
|
202 | // if this is an edit_shortcuts shortcut, the global keyboard/shortcut | |
225 | // manager will handle it |
|
203 | // manager will handle it | |
@@ -597,9 +575,9 b' var IPython = (function (IPython) {' | |||||
597 | this.code_mirror.setOption('mode', default_mode); |
|
575 | this.code_mirror.setOption('mode', default_mode); | |
598 | }; |
|
576 | }; | |
599 |
|
577 | |||
|
578 | // Backwards compatability. | |||
600 | IPython.Cell = Cell; |
|
579 | IPython.Cell = Cell; | |
601 |
|
580 | |||
602 |
return |
|
581 | return Cell; | |
603 |
|
||||
604 | }(IPython)); |
|
|||
605 |
|
582 | |||
|
583 | }); |
@@ -1,22 +1,11 b'' | |||||
1 | //---------------------------------------------------------------------------- |
|
1 | // Copyright (c) IPython Development Team. | |
2 | // Copyright (C) 2012 The IPython Development Team |
|
2 | // Distributed under the terms of the Modified BSD License. | |
3 | // |
|
3 | ||
4 | // Distributed under the terms of the BSD License. The full license is in |
|
4 | define([ | |
5 | // the file COPYING, distributed as part of this software. |
|
5 | 'base/js/namespace', | |
6 | //---------------------------------------------------------------------------- |
|
6 | 'components/jquery/jquery.min', | |
7 |
|
7 | 'notebook/js/textcell', | ||
8 | //============================================================================ |
|
8 | ], function(IPython, $, TextCell) { | |
9 | // CellToolbar |
|
|||
10 | //============================================================================ |
|
|||
11 |
|
||||
12 |
|
||||
13 | /** |
|
|||
14 | * A Module to control the per-cell toolbar. |
|
|||
15 | * @module IPython |
|
|||
16 | * @namespace IPython |
|
|||
17 | * @submodule CellToolbar |
|
|||
18 | */ |
|
|||
19 | var IPython = (function (IPython) { |
|
|||
20 | "use strict"; |
|
9 | "use strict"; | |
21 |
|
10 | |||
22 | /** |
|
11 | /** | |
@@ -24,8 +13,10 b' var IPython = (function (IPython) {' | |||||
24 | * @class CellToolbar |
|
13 | * @class CellToolbar | |
25 | * @param {The cell to attach the metadata UI to} cell |
|
14 | * @param {The cell to attach the metadata UI to} cell | |
26 | */ |
|
15 | */ | |
27 | var CellToolbar = function (cell) { |
|
16 | var CellToolbar = function (cell, events, notebook) { | |
28 | CellToolbar._instances.push(this); |
|
17 | CellToolbar._instances.push(this); | |
|
18 | this.notebook = notebook; | |||
|
19 | this.events = events; | |||
29 | this.cell = cell; |
|
20 | this.cell = cell; | |
30 | this.create_element(); |
|
21 | this.create_element(); | |
31 | this.rebuild(); |
|
22 | this.rebuild(); | |
@@ -34,7 +25,7 b' var IPython = (function (IPython) {' | |||||
34 |
|
25 | |||
35 |
|
26 | |||
36 | CellToolbar.prototype.create_element = function () { |
|
27 | CellToolbar.prototype.create_element = function () { | |
37 | this.inner_element = $('<div/>').addClass('celltoolbar') |
|
28 | this.inner_element = $('<div/>').addClass('celltoolbar'); | |
38 | this.element = $('<div/>').addClass('ctb_hideshow') |
|
29 | this.element = $('<div/>').addClass('ctb_hideshow') | |
39 | .append(this.inner_element); |
|
30 | .append(this.inner_element); | |
40 | }; |
|
31 | }; | |
@@ -184,10 +175,10 b' var IPython = (function (IPython) {' | |||||
184 | */ |
|
175 | */ | |
185 | CellToolbar.register_preset = function(name, preset_list) { |
|
176 | CellToolbar.register_preset = function(name, preset_list) { | |
186 | CellToolbar._presets[name] = preset_list; |
|
177 | CellToolbar._presets[name] = preset_list; | |
187 |
|
|
178 | this.events.trigger('preset_added.CellToolbar', {name: name}); | |
188 | // When "register_callback" is called by a custom extension, it may be executed after notebook is loaded. |
|
179 | // When "register_callback" is called by a custom extension, it may be executed after notebook is loaded. | |
189 | // In that case, activate the preset if needed. |
|
180 | // In that case, activate the preset if needed. | |
190 |
if ( |
|
181 | if (this.notebook && this.notebook.metadata && this.notebook.metadata.celltoolbar === name) | |
191 | this.activate_preset(name); |
|
182 | this.activate_preset(name); | |
192 | }; |
|
183 | }; | |
193 |
|
184 | |||
@@ -229,7 +220,7 b' var IPython = (function (IPython) {' | |||||
229 | CellToolbar.rebuild_all(); |
|
220 | CellToolbar.rebuild_all(); | |
230 | } |
|
221 | } | |
231 |
|
222 | |||
232 |
|
|
223 | this.events.trigger('preset_activated.CellToolbar', {name: preset_name}); | |
233 | }; |
|
224 | }; | |
234 |
|
225 | |||
235 |
|
226 | |||
@@ -283,7 +274,7 b' var IPython = (function (IPython) {' | |||||
283 | } |
|
274 | } | |
284 |
|
275 | |||
285 | // If there are no controls or the cell is a rendered TextCell hide the toolbar. |
|
276 | // If there are no controls or the cell is a rendered TextCell hide the toolbar. | |
286 |
if (!this.ui_controls_list.length || (this.cell instanceof |
|
277 | if (!this.ui_controls_list.length || (this.cell instanceof TextCell && this.cell.rendered)) { | |
287 | this.hide(); |
|
278 | this.hide(); | |
288 | } else { |
|
279 | } else { | |
289 | this.show(); |
|
280 | this.show(); | |
@@ -415,8 +406,8 b' var IPython = (function (IPython) {' | |||||
415 | }; |
|
406 | }; | |
416 | }; |
|
407 | }; | |
417 |
|
408 | |||
418 |
|
409 | // Backwards compatability. | ||
419 | IPython.CellToolbar = CellToolbar; |
|
410 | IPython.CellToolbar = CellToolbar; | |
420 |
|
411 | |||
421 |
return |
|
412 | return CellToolbar; | |
422 | }(IPython)); |
|
413 | }); |
@@ -1,3 +1,9 b'' | |||||
|
1 | ||||
|
2 | "notebook/js/tooltip", | |||
|
3 | Tooltip, | |||
|
4 | tooltip = new Tooltip(); | |||
|
5 | IPython.tooltip = tooltip; | |||
|
6 | ||||
1 | //---------------------------------------------------------------------------- |
|
7 | //---------------------------------------------------------------------------- | |
2 | // Copyright (C) 2008-2011 The IPython Development Team |
|
8 | // Copyright (C) 2008-2011 The IPython Development Team | |
3 | // |
|
9 | // |
@@ -7,9 +7,8 b' define([' | |||||
7 | ], function(IPython, $) { |
|
7 | ], function(IPython, $) { | |
8 | "use strict"; |
|
8 | "use strict"; | |
9 |
|
9 | |||
10 |
var LayoutManager = function ( |
|
10 | var LayoutManager = function () { | |
11 | this.bind_events(); |
|
11 | this.bind_events(); | |
12 | this.pager = pager; |
|
|||
13 | }; |
|
12 | }; | |
14 |
|
13 | |||
15 | LayoutManager.prototype.bind_events = function () { |
|
14 | LayoutManager.prototype.bind_events = function () { | |
@@ -39,14 +38,15 b' define([' | |||||
39 | var app_height = this.app_height(); // content height |
|
38 | var app_height = this.app_height(); // content height | |
40 |
|
39 | |||
41 | $('#ipython-main-app').height(app_height); // content+padding+border height |
|
40 | $('#ipython-main-app').height(app_height); // content+padding+border height | |
42 |
|
41 | if (this.pager) { | ||
43 | var pager_height = this.pager.percentage_height*app_height; |
|
42 | var pager_height = this.pager.percentage_height*app_height; | |
44 | var pager_splitter_height = $('div#pager_splitter').outerHeight(true); |
|
43 | var pager_splitter_height = $('div#pager_splitter').outerHeight(true); | |
45 | $('div#pager').outerHeight(pager_height); |
|
44 | $('div#pager').outerHeight(pager_height); | |
46 | if (this.pager.expanded) { |
|
45 | if (this.pager.expanded) { | |
47 | $('div#notebook').outerHeight(app_height-pager_height-pager_splitter_height); |
|
46 | $('div#notebook').outerHeight(app_height-pager_height-pager_splitter_height); | |
48 | } else { |
|
47 | } else { | |
49 | $('div#notebook').outerHeight(app_height-pager_splitter_height); |
|
48 | $('div#notebook').outerHeight(app_height-pager_splitter_height); | |
|
49 | } | |||
50 | } |
|
50 | } | |
51 | }; |
|
51 | }; | |
52 |
|
52 |
@@ -4,6 +4,7 b'' | |||||
4 | var ipython = ipython || {}; |
|
4 | var ipython = ipython || {}; | |
5 | require([ |
|
5 | require([ | |
6 | 'base/js/namespace', |
|
6 | 'base/js/namespace', | |
|
7 | 'components/jquery/jquery.min', | |||
7 | 'notebook/js/notebook', |
|
8 | 'notebook/js/notebook', | |
8 | 'base/js/utils', |
|
9 | 'base/js/utils', | |
9 | 'base/js/page', |
|
10 | 'base/js/page', | |
@@ -17,6 +18,7 b' require([' | |||||
17 | 'notebook/js/notificationarea', |
|
18 | 'notebook/js/notificationarea', | |
18 | ], function( |
|
19 | ], function( | |
19 | IPython, |
|
20 | IPython, | |
|
21 | $, | |||
20 | Notebook, |
|
22 | Notebook, | |
21 | Utils, |
|
23 | Utils, | |
22 | Page, |
|
24 | Page, | |
@@ -41,12 +43,13 b' require([' | |||||
41 | }; |
|
43 | }; | |
42 |
|
44 | |||
43 | page = new Page(); |
|
45 | page = new Page(); | |
44 | pager = new Pager('div#pager', 'div#pager_splitter'); |
|
46 | layout_manager = new LayoutManager(); | |
45 | layout_manager = new LayoutManager(pager); |
|
47 | pager = new Pager('div#pager', 'div#pager_splitter', layout_manager); | |
46 | events = new Events(); |
|
48 | layout_manager.pager = pager; | |
|
49 | events = $([new Events()]); | |||
47 | notebook = new Notebook('div#notebook', opts, events); |
|
50 | notebook = new Notebook('div#notebook', opts, events); | |
48 | login_widget = new LoginWidget('span#login_widget', opts); |
|
51 | login_widget = new LoginWidget('span#login_widget', opts); | |
49 | toolbar = new MainToolBar('#maintoolbar-container'); |
|
52 | toolbar = new MainToolBar('#maintoolbar-container', notebook, events); | |
50 | quick_help = new QuickHelp(); |
|
53 | quick_help = new QuickHelp(); | |
51 | menubar = new MenuBar('#menubar', opts); |
|
54 | menubar = new MenuBar('#menubar', opts); | |
52 |
|
55 |
@@ -5,11 +5,13 b' define([' | |||||
5 | 'base/js/namespace', |
|
5 | 'base/js/namespace', | |
6 | 'components/jquery/jquery.min', |
|
6 | 'components/jquery/jquery.min', | |
7 | 'notebook/js/toolbar', |
|
7 | 'notebook/js/toolbar', | |
8 | ], function(IPython, $, Toolbar) { |
|
8 | 'notebook/js/celltoolbar', | |
|
9 | ], function(IPython, $, Toolbar, CellToolbar) { | |||
9 | "use strict"; |
|
10 | "use strict"; | |
10 |
|
11 | |||
11 | var MainToolBar = function (selector, notebook) { |
|
12 | var MainToolBar = function (selector, layout_manager, notebook, events) { | |
12 | ToolBar.apply(this, arguments); |
|
13 | ToolBar.apply(this, arguments); | |
|
14 | this.events = events; | |||
13 | this.notebook = notebook; |
|
15 | this.notebook = notebook; | |
14 | this.construct(); |
|
16 | this.construct(); | |
15 | this.add_celltype_list(); |
|
17 | this.add_celltype_list(); | |
@@ -150,27 +152,27 b' define([' | |||||
150 | select.change(function() { |
|
152 | select.change(function() { | |
151 | var val = $(this).val(); |
|
153 | var val = $(this).val(); | |
152 | if (val ==='') { |
|
154 | if (val ==='') { | |
153 |
|
|
155 | CellToolbar.global_hide(); | |
154 | delete this.notebook.metadata.celltoolbar; |
|
156 | delete this.notebook.metadata.celltoolbar; | |
155 | } else { |
|
157 | } else { | |
156 |
|
|
158 | CellToolbar.global_show(); | |
157 |
|
|
159 | CellToolbar.activate_preset(val); | |
158 | this.notebook.metadata.celltoolbar = val; |
|
160 | this.notebook.metadata.celltoolbar = val; | |
159 | } |
|
161 | } | |
160 | }); |
|
162 | }); | |
161 | // Setup the currently registered presets. |
|
163 | // Setup the currently registered presets. | |
162 |
var presets = |
|
164 | var presets = CellToolbar.list_presets(); | |
163 | for (var i=0; i<presets.length; i++) { |
|
165 | for (var i=0; i<presets.length; i++) { | |
164 | var name = presets[i]; |
|
166 | var name = presets[i]; | |
165 | select.append($('<option/>').attr('value', name).text(name)); |
|
167 | select.append($('<option/>').attr('value', name).text(name)); | |
166 | } |
|
168 | } | |
167 | // Setup future preset registrations. |
|
169 | // Setup future preset registrations. | |
168 |
|
|
170 | this.events.on('preset_added.CellToolbar', function (event, data) { | |
169 | var name = data.name; |
|
171 | var name = data.name; | |
170 | select.append($('<option/>').attr('value', name).text(name)); |
|
172 | select.append($('<option/>').attr('value', name).text(name)); | |
171 | }); |
|
173 | }); | |
172 | // Update select value when a preset is activated. |
|
174 | // Update select value when a preset is activated. | |
173 |
|
|
175 | this.events.on('preset_activated.CellToolbar', function (event, data) { | |
174 | if (select.val() !== data.name) |
|
176 | if (select.val() !== data.name) | |
175 | select.val(data.name); |
|
177 | select.val(data.name); | |
176 | }); |
|
178 | }); | |
@@ -202,7 +204,7 b' define([' | |||||
202 | this.notebook.to_heading(undefined, 6); |
|
204 | this.notebook.to_heading(undefined, 6); | |
203 | } |
|
205 | } | |
204 | }); |
|
206 | }); | |
205 |
|
|
207 | this.events.on('selected_cell_type_changed.Notebook', function (event, data) { | |
206 | if (data.cell_type === 'heading') { |
|
208 | if (data.cell_type === 'heading') { | |
207 | that.element.find('#cell_type').val(data.cell_type+data.level); |
|
209 | that.element.find('#cell_type').val(data.cell_type+data.level); | |
208 | } else { |
|
210 | } else { |
@@ -46,7 +46,7 b' define([' | |||||
46 | * @param {Object} [events] An events object |
|
46 | * @param {Object} [events] An events object | |
47 | */ |
|
47 | */ | |
48 | var Notebook = function (selector, options, events) { |
|
48 | var Notebook = function (selector, options, events) { | |
49 | this.events = events || new Events(); |
|
49 | this.events = events || $([new Events()]); | |
50 | this.keyboard_manager = new KeyboardManager(); |
|
50 | this.keyboard_manager = new KeyboardManager(); | |
51 | this.keyboard = new Keyboard(); |
|
51 | this.keyboard = new Keyboard(); | |
52 | this.save_widget = new SaveWidget('span#save_widget'); |
|
52 | this.save_widget = new SaveWidget('span#save_widget'); |
@@ -1,16 +1,18 b'' | |||||
1 | // Copyright (c) IPython Development Team. |
|
1 | // Copyright (c) IPython Development Team. | |
2 | // Distributed under the terms of the Modified BSD License. |
|
2 | // Distributed under the terms of the Modified BSD License. | |
3 |
|
3 | |||
4 | //============================================================================ |
|
4 | define([ | |
5 | // Pager |
|
5 | 'base/js/namespace', | |
6 | //============================================================================ |
|
6 | 'components/jquery/jquery.min', | |
7 |
|
7 | 'notebook/js/toolbar', | ||
8 | var IPython = (function (IPython) { |
|
8 | 'notebook/js/celltoolbar', | |
|
9 | ], function(IPython, $, Toolbar, CellToolbar) { | |||
9 | "use strict"; |
|
10 | "use strict"; | |
10 |
|
11 | |||
11 | var utils = IPython.utils; |
|
12 | var utils = IPython.utils; | |
12 |
|
13 | |||
13 | var Pager = function (pager_selector, pager_splitter_selector) { |
|
14 | var Pager = function (pager_selector, pager_splitter_selector, layout_manager, events) { | |
|
15 | this.events = events; | |||
14 | this.pager_element = $(pager_selector); |
|
16 | this.pager_element = $(pager_selector); | |
15 | this.pager_button_area = $('#pager_button_area'); |
|
17 | this.pager_button_area = $('#pager_button_area'); | |
16 | var that = this; |
|
18 | var that = this; | |
@@ -23,7 +25,7 b' var IPython = (function (IPython) {' | |||||
23 | drag: function(event, ui) { |
|
25 | drag: function(event, ui) { | |
24 | // recalculate the amount of space the pager should take |
|
26 | // recalculate the amount of space the pager should take | |
25 | var pheight = ($(document.body).height()-event.clientY-4); |
|
27 | var pheight = ($(document.body).height()-event.clientY-4); | |
26 |
var downprct = pheight/ |
|
28 | var downprct = pheight/layout_manager.app_height(); | |
27 | downprct = Math.min(0.9, downprct); |
|
29 | downprct = Math.min(0.9, downprct); | |
28 | if (downprct < 0.1) { |
|
30 | if (downprct < 0.1) { | |
29 | that.percentage_height = 0.1; |
|
31 | that.percentage_height = 0.1; | |
@@ -32,7 +34,7 b' var IPython = (function (IPython) {' | |||||
32 | that.percentage_height = downprct; |
|
34 | that.percentage_height = downprct; | |
33 | that.expand({'duration':0}); |
|
35 | that.expand({'duration':0}); | |
34 | } |
|
36 | } | |
35 |
|
|
37 | layout_manager.do_resize(); | |
36 | } |
|
38 | } | |
37 | }); |
|
39 | }); | |
38 | this.expanded = false; |
|
40 | this.expanded = false; | |
@@ -47,22 +49,22 b' var IPython = (function (IPython) {' | |||||
47 | $('<a>').attr('role', "button") |
|
49 | $('<a>').attr('role', "button") | |
48 | .attr('title',"Open the pager in an external window") |
|
50 | .attr('title',"Open the pager in an external window") | |
49 | .addClass('ui-button') |
|
51 | .addClass('ui-button') | |
50 | .click(function(){that.detach()}) |
|
52 | .click(function(){that.detach();}) | |
51 | .attr('style','position: absolute; right: 20px;') |
|
53 | .attr('style','position: absolute; right: 20px;') | |
52 | .append( |
|
54 | .append( | |
53 | $('<span>').addClass("ui-icon ui-icon-extlink") |
|
55 | $('<span>').addClass("ui-icon ui-icon-extlink") | |
54 | ) |
|
56 | ) | |
55 | ) |
|
57 | ); | |
56 | this.pager_button_area.append( |
|
58 | this.pager_button_area.append( | |
57 | $('<a>').attr('role', "button") |
|
59 | $('<a>').attr('role', "button") | |
58 | .attr('title',"Close the pager") |
|
60 | .attr('title',"Close the pager") | |
59 | .addClass('ui-button') |
|
61 | .addClass('ui-button') | |
60 | .click(function(){that.collapse()}) |
|
62 | .click(function(){that.collapse();}) | |
61 | .attr('style','position: absolute; right: 5px;') |
|
63 | .attr('style','position: absolute; right: 5px;') | |
62 | .append( |
|
64 | .append( | |
63 | $('<span>').addClass("ui-icon ui-icon-close") |
|
65 | $('<span>').addClass("ui-icon ui-icon-close") | |
64 | ) |
|
66 | ) | |
65 | ) |
|
67 | ); | |
66 | }; |
|
68 | }; | |
67 |
|
69 | |||
68 | Pager.prototype.style = function () { |
|
70 | Pager.prototype.style = function () { | |
@@ -105,7 +107,7 b' var IPython = (function (IPython) {' | |||||
105 | that.toggle(); |
|
107 | that.toggle(); | |
106 | }); |
|
108 | }); | |
107 |
|
109 | |||
108 |
|
|
110 | this.events.on('open_with_text.Pager', function (event, payload) { | |
109 | // FIXME: support other mime types |
|
111 | // FIXME: support other mime types | |
110 | if (payload.data['text/plain'] && payload.data['text/plain'] !== "") { |
|
112 | if (payload.data['text/plain'] && payload.data['text/plain'] !== "") { | |
111 | that.clear(); |
|
113 | that.clear(); | |
@@ -171,10 +173,8 b' var IPython = (function (IPython) {' | |||||
171 | this.pager_element.find(".container").append($('<pre/>').html(utils.fixCarriageReturn(utils.fixConsole(text)))); |
|
173 | this.pager_element.find(".container").append($('<pre/>').html(utils.fixCarriageReturn(utils.fixConsole(text)))); | |
172 | }; |
|
174 | }; | |
173 |
|
175 | |||
174 |
|
176 | // Backwards compatability. | ||
175 | IPython.Pager = Pager; |
|
177 | IPython.Pager = Pager; | |
176 |
|
178 | |||
177 |
return |
|
179 | return Pager; | |
178 |
|
180 | }); | ||
179 | }(IPython)); |
|
|||
180 |
|
@@ -1,40 +1,27 b'' | |||||
1 | //---------------------------------------------------------------------------- |
|
1 | // Copyright (c) IPython Development Team. | |
2 | // Copyright (C) 2008-2012 The IPython Development Team |
|
2 | // Distributed under the terms of the Modified BSD License. | |
3 | // |
|
3 | ||
4 | // Distributed under the terms of the BSD License. The full license is in |
|
4 | define([ | |
5 | // the file COPYING, distributed as part of this software. |
|
5 | 'base/js/namespace', | |
6 | //---------------------------------------------------------------------------- |
|
6 | 'components/jquery/jquery.min', | |
7 |
|
7 | 'notebook/js/cell', | ||
8 | //============================================================================ |
|
8 | 'base/js/security', | |
9 | // TextCell |
|
9 | ], function(IPython, $, Cell, Security) { | |
10 | //============================================================================ |
|
|||
11 |
|
||||
12 |
|
||||
13 |
|
||||
14 | /** |
|
|||
15 | A module that allow to create different type of Text Cell |
|
|||
16 | @module IPython |
|
|||
17 | @namespace IPython |
|
|||
18 | */ |
|
|||
19 | var IPython = (function (IPython) { |
|
|||
20 | "use strict"; |
|
10 | "use strict"; | |
21 |
|
11 | |||
22 | // TextCell base class |
|
|||
23 | var keycodes = IPython.keyboard.keycodes; |
|
|||
24 | var security = IPython.security; |
|
|||
25 |
|
||||
26 | /** |
|
12 | /** | |
27 | * Construct a new TextCell, codemirror mode is by default 'htmlmixed', and cell type is 'text' |
|
13 | * Construct a new TextCell, codemirror mode is by default 'htmlmixed', and cell type is 'text' | |
28 | * cell start as not redered. |
|
14 | * cell start as not redered. | |
29 | * |
|
15 | * | |
30 | * @class TextCell |
|
16 | * @class TextCell | |
31 | * @constructor TextCell |
|
17 | * @constructor TextCell | |
32 |
* @extend |
|
18 | * @extend Cell | |
33 | * @param {object|undefined} [options] |
|
19 | * @param {object|undefined} [options] | |
34 | * @param [options.cm_config] {object} config to pass to CodeMirror, will extend/overwrite default config |
|
20 | * @param [options.cm_config] {object} config to pass to CodeMirror, will extend/overwrite default config | |
35 | * @param [options.placeholder] {string} default string to use when souce in empty for rendering (only use in some TextCell subclass) |
|
21 | * @param [options.placeholder] {string} default string to use when souce in empty for rendering (only use in some TextCell subclass) | |
36 | */ |
|
22 | */ | |
37 | var TextCell = function (options) { |
|
23 | var TextCell = function (options, events, config, mathjaxutils) { | |
|
24 | // TODO: Config is IPython.config | |||
38 | // in all TextCell/Cell subclasses |
|
25 | // in all TextCell/Cell subclasses | |
39 | // do not assign most of members here, just pass it down |
|
26 | // do not assign most of members here, just pass it down | |
40 | // in the options dict potentially overwriting what you wish. |
|
27 | // in the options dict potentially overwriting what you wish. | |
@@ -48,13 +35,14 b' var IPython = (function (IPython) {' | |||||
48 | options = this.mergeopt(TextCell,options,{cm_config:cm_overwrite_options}); |
|
35 | options = this.mergeopt(TextCell,options,{cm_config:cm_overwrite_options}); | |
49 |
|
36 | |||
50 | this.cell_type = this.cell_type || 'text'; |
|
37 | this.cell_type = this.cell_type || 'text'; | |
|
38 | this.mathjaxutils = mathjaxutils; | |||
51 |
|
39 | |||
52 |
|
|
40 | Cell.apply(this, [options], events); | |
53 |
|
41 | |||
54 | this.rendered = false; |
|
42 | this.rendered = false; | |
55 | }; |
|
43 | }; | |
56 |
|
44 | |||
57 |
TextCell.prototype = new |
|
45 | TextCell.prototype = new Cell(); | |
58 |
|
46 | |||
59 | TextCell.options_default = { |
|
47 | TextCell.options_default = { | |
60 | cm_config : { |
|
48 | cm_config : { | |
@@ -71,7 +59,7 b' var IPython = (function (IPython) {' | |||||
71 | * @private |
|
59 | * @private | |
72 | */ |
|
60 | */ | |
73 | TextCell.prototype.create_element = function () { |
|
61 | TextCell.prototype.create_element = function () { | |
74 |
|
|
62 | Cell.prototype.create_element.apply(this, arguments); | |
75 |
|
63 | |||
76 | var cell = $("<div>").addClass('cell text_cell border-box-sizing'); |
|
64 | var cell = $("<div>").addClass('cell text_cell border-box-sizing'); | |
77 | cell.attr('tabindex','2'); |
|
65 | cell.attr('tabindex','2'); | |
@@ -79,7 +67,7 b' var IPython = (function (IPython) {' | |||||
79 | var prompt = $('<div/>').addClass('prompt input_prompt'); |
|
67 | var prompt = $('<div/>').addClass('prompt input_prompt'); | |
80 | cell.append(prompt); |
|
68 | cell.append(prompt); | |
81 | var inner_cell = $('<div/>').addClass('inner_cell'); |
|
69 | var inner_cell = $('<div/>').addClass('inner_cell'); | |
82 |
this.celltoolbar = new |
|
70 | this.celltoolbar = new CellToolbar(this); | |
83 | inner_cell.append(this.celltoolbar.element); |
|
71 | inner_cell.append(this.celltoolbar.element); | |
84 | var input_area = $('<div/>').addClass('input_area'); |
|
72 | var input_area = $('<div/>').addClass('input_area'); | |
85 | this.code_mirror = new CodeMirror(input_area.get(0), this.cm_config); |
|
73 | this.code_mirror = new CodeMirror(input_area.get(0), this.cm_config); | |
@@ -99,12 +87,12 b' var IPython = (function (IPython) {' | |||||
99 | * @method bind_event |
|
87 | * @method bind_event | |
100 | */ |
|
88 | */ | |
101 | TextCell.prototype.bind_events = function () { |
|
89 | TextCell.prototype.bind_events = function () { | |
102 |
|
|
90 | Cell.prototype.bind_events.apply(this); | |
103 | var that = this; |
|
91 | var that = this; | |
104 |
|
92 | |||
105 | this.element.dblclick(function () { |
|
93 | this.element.dblclick(function () { | |
106 | if (that.selected === false) { |
|
94 | if (that.selected === false) { | |
107 |
|
|
95 | this.events.trigger('select.Cell', {'cell':that}); | |
108 | } |
|
96 | } | |
109 | var cont = that.unrender(); |
|
97 | var cont = that.unrender(); | |
110 | if (cont) { |
|
98 | if (cont) { | |
@@ -116,7 +104,7 b' var IPython = (function (IPython) {' | |||||
116 | // Cell level actions |
|
104 | // Cell level actions | |
117 |
|
105 | |||
118 | TextCell.prototype.select = function () { |
|
106 | TextCell.prototype.select = function () { | |
119 |
var cont = |
|
107 | var cont = Cell.prototype.select.apply(this); | |
120 | if (cont) { |
|
108 | if (cont) { | |
121 | if (this.mode === 'edit') { |
|
109 | if (this.mode === 'edit') { | |
122 | this.code_mirror.refresh(); |
|
110 | this.code_mirror.refresh(); | |
@@ -127,7 +115,7 b' var IPython = (function (IPython) {' | |||||
127 |
|
115 | |||
128 | TextCell.prototype.unrender = function () { |
|
116 | TextCell.prototype.unrender = function () { | |
129 | if (this.read_only) return; |
|
117 | if (this.read_only) return; | |
130 |
var cont = |
|
118 | var cont = Cell.prototype.unrender.apply(this); | |
131 | if (cont) { |
|
119 | if (cont) { | |
132 | var text_cell = this.element; |
|
120 | var text_cell = this.element; | |
133 | var output = text_cell.find("div.text_cell_render"); |
|
121 | var output = text_cell.find("div.text_cell_render"); | |
@@ -191,7 +179,7 b' var IPython = (function (IPython) {' | |||||
191 | * @method fromJSON |
|
179 | * @method fromJSON | |
192 | */ |
|
180 | */ | |
193 | TextCell.prototype.fromJSON = function (data) { |
|
181 | TextCell.prototype.fromJSON = function (data) { | |
194 |
|
|
182 | Cell.prototype.fromJSON.apply(this, arguments); | |
195 | if (data.cell_type === this.cell_type) { |
|
183 | if (data.cell_type === this.cell_type) { | |
196 | if (data.source !== undefined) { |
|
184 | if (data.source !== undefined) { | |
197 | this.set_text(data.source); |
|
185 | this.set_text(data.source); | |
@@ -211,7 +199,7 b' var IPython = (function (IPython) {' | |||||
211 | * @return {object} cell data serialised to json |
|
199 | * @return {object} cell data serialised to json | |
212 | */ |
|
200 | */ | |
213 | TextCell.prototype.toJSON = function () { |
|
201 | TextCell.prototype.toJSON = function () { | |
214 |
var data = |
|
202 | var data = Cell.prototype.toJSON.apply(this); | |
215 | data.source = this.get_text(); |
|
203 | data.source = this.get_text(); | |
216 | if (data.source == this.placeholder) { |
|
204 | if (data.source == this.placeholder) { | |
217 | data.source = ""; |
|
205 | data.source = ""; | |
@@ -245,17 +233,17 b' var IPython = (function (IPython) {' | |||||
245 | * @method render |
|
233 | * @method render | |
246 | */ |
|
234 | */ | |
247 | MarkdownCell.prototype.render = function () { |
|
235 | MarkdownCell.prototype.render = function () { | |
248 |
var cont = |
|
236 | var cont = TextCell.prototype.render.apply(this); | |
249 | if (cont) { |
|
237 | if (cont) { | |
250 | var text = this.get_text(); |
|
238 | var text = this.get_text(); | |
251 | var math = null; |
|
239 | var math = null; | |
252 | if (text === "") { text = this.placeholder; } |
|
240 | if (text === "") { text = this.placeholder; } | |
253 |
var text_and_math = |
|
241 | var text_and_math = this.mathjaxutils.remove_math(text); | |
254 | text = text_and_math[0]; |
|
242 | text = text_and_math[0]; | |
255 | math = text_and_math[1]; |
|
243 | math = text_and_math[1]; | |
256 | var html = marked.parser(marked.lexer(text)); |
|
244 | var html = marked.parser(marked.lexer(text)); | |
257 |
html = |
|
245 | html = this.mathjaxutils.replace_math(html, math); | |
258 |
html = |
|
246 | html = Security.sanitize_html(html); | |
259 | html = $($.parseHTML(html)); |
|
247 | html = $($.parseHTML(html)); | |
260 | // links in markdown cells should open in new tabs |
|
248 | // links in markdown cells should open in new tabs | |
261 | html.find("a[href]").not('[href^="#"]').attr("target", "_blank"); |
|
249 | html.find("a[href]").not('[href^="#"]').attr("target", "_blank"); | |
@@ -273,7 +261,7 b' var IPython = (function (IPython) {' | |||||
273 | /** |
|
261 | /** | |
274 | * @class RawCell |
|
262 | * @class RawCell | |
275 | * @constructor RawCell |
|
263 | * @constructor RawCell | |
276 |
* @extends |
|
264 | * @extends TextCell | |
277 | */ |
|
265 | */ | |
278 | var RawCell = function (options) { |
|
266 | var RawCell = function (options) { | |
279 |
|
267 | |||
@@ -309,12 +297,12 b' var IPython = (function (IPython) {' | |||||
309 | * @method auto_highlight |
|
297 | * @method auto_highlight | |
310 | */ |
|
298 | */ | |
311 | RawCell.prototype.auto_highlight = function () { |
|
299 | RawCell.prototype.auto_highlight = function () { | |
312 |
this._auto_highlight( |
|
300 | this._auto_highlight(config.raw_cell_highlight); | |
313 | }; |
|
301 | }; | |
314 |
|
302 | |||
315 | /** @method render **/ |
|
303 | /** @method render **/ | |
316 | RawCell.prototype.render = function () { |
|
304 | RawCell.prototype.render = function () { | |
317 |
var cont = |
|
305 | var cont = TextCell.prototype.render.apply(this); | |
318 | if (cont){ |
|
306 | if (cont){ | |
319 | var text = this.get_text(); |
|
307 | var text = this.get_text(); | |
320 | if (text === "") { text = this.placeholder; } |
|
308 | if (text === "") { text = this.placeholder; } | |
@@ -327,12 +315,12 b' var IPython = (function (IPython) {' | |||||
327 |
|
315 | |||
328 | /** |
|
316 | /** | |
329 | * @class HeadingCell |
|
317 | * @class HeadingCell | |
330 |
* @extends |
|
318 | * @extends TextCell | |
331 | */ |
|
319 | */ | |
332 |
|
320 | |||
333 | /** |
|
321 | /** | |
334 | * @constructor HeadingCell |
|
322 | * @constructor HeadingCell | |
335 |
* @extends |
|
323 | * @extends TextCell | |
336 | */ |
|
324 | */ | |
337 | var HeadingCell = function (options) { |
|
325 | var HeadingCell = function (options) { | |
338 | options = this.mergeopt(HeadingCell, options); |
|
326 | options = this.mergeopt(HeadingCell, options); | |
@@ -412,22 +400,21 b' var IPython = (function (IPython) {' | |||||
412 | return r.children().first().html(); |
|
400 | return r.children().first().html(); | |
413 | }; |
|
401 | }; | |
414 |
|
402 | |||
415 |
|
||||
416 | HeadingCell.prototype.render = function () { |
|
403 | HeadingCell.prototype.render = function () { | |
417 |
var cont = |
|
404 | var cont = TextCell.prototype.render.apply(this); | |
418 | if (cont) { |
|
405 | if (cont) { | |
419 | var text = this.get_text(); |
|
406 | var text = this.get_text(); | |
420 | var math = null; |
|
407 | var math = null; | |
421 | // Markdown headings must be a single line |
|
408 | // Markdown headings must be a single line | |
422 | text = text.replace(/\n/g, ' '); |
|
409 | text = text.replace(/\n/g, ' '); | |
423 | if (text === "") { text = this.placeholder; } |
|
410 | if (text === "") { text = this.placeholder; } | |
424 | text = Array(this.level + 1).join("#") + " " + text; |
|
411 | text = new Array(this.level + 1).join("#") + " " + text; | |
425 |
var text_and_math = |
|
412 | var text_and_math = this.mathjaxutils.remove_math(text); | |
426 | text = text_and_math[0]; |
|
413 | text = text_and_math[0]; | |
427 | math = text_and_math[1]; |
|
414 | math = text_and_math[1]; | |
428 | var html = marked.parser(marked.lexer(text)); |
|
415 | var html = marked.parser(marked.lexer(text)); | |
429 |
html = |
|
416 | html = this.mathjaxutils.replace_math(html, math); | |
430 |
html = |
|
417 | html = Security.sanitize_html(html); | |
431 | var h = $($.parseHTML(html)); |
|
418 | var h = $($.parseHTML(html)); | |
432 | // add id and linkback anchor |
|
419 | // add id and linkback anchor | |
433 | var hash = h.text().replace(/ /g, '-'); |
|
420 | var hash = h.text().replace(/ /g, '-'); | |
@@ -446,14 +433,17 b' var IPython = (function (IPython) {' | |||||
446 | return cont; |
|
433 | return cont; | |
447 | }; |
|
434 | }; | |
448 |
|
435 | |||
449 | // TODO: RETURN IN THIS NAMESPACE! |
|
436 | // Backwards compatability. | |
450 | IPython.TextCell = TextCell; |
|
437 | IPython.TextCell = TextCell; | |
451 | IPython.MarkdownCell = MarkdownCell; |
|
438 | IPython.MarkdownCell = MarkdownCell; | |
452 | IPython.RawCell = RawCell; |
|
439 | IPython.RawCell = RawCell; | |
453 | IPython.HeadingCell = HeadingCell; |
|
440 | IPython.HeadingCell = HeadingCell; | |
454 |
|
441 | |||
455 |
|
442 | Cells = { | ||
456 | return IPython; |
|
443 | 'TextCell': TextCell, | |
457 |
|
444 | 'MarkdownCell': MarkdownCell, | ||
458 | }(IPython)); |
|
445 | 'RawCell': RawCell, | |
459 |
|
446 | 'HeadingCell': HeadingCell, | ||
|
447 | }; | |||
|
448 | return Cells; | |||
|
449 | }); |
@@ -1,20 +1,10 b'' | |||||
1 | //---------------------------------------------------------------------------- |
|
1 | // Copyright (c) IPython Development Team. | |
2 | // Copyright (C) 2008 The IPython Development Team |
|
2 | // Distributed under the terms of the Modified BSD License. | |
3 | // |
|
|||
4 | // Distributed under the terms of the BSD License. The full license is in |
|
|||
5 | // the file COPYING, distributed as part of this software. |
|
|||
6 | //---------------------------------------------------------------------------- |
|
|||
7 |
|
3 | |||
8 | //============================================================================ |
|
4 | define([ | |
9 | // ToolBar |
|
5 | 'base/js/namespace', | |
10 | //============================================================================ |
|
6 | 'components/jquery/jquery.min', | |
11 | /** |
|
7 | ], function(IPython, $) { | |
12 | * @module IPython |
|
|||
13 | * @namespace IPython |
|
|||
14 | * @submodule ToolBar |
|
|||
15 | */ |
|
|||
16 |
|
||||
17 | var IPython = (function (IPython) { |
|
|||
18 | "use strict"; |
|
8 | "use strict"; | |
19 |
|
9 | |||
20 | /** |
|
10 | /** | |
@@ -23,8 +13,9 b' var IPython = (function (IPython) {' | |||||
23 | * @constructor |
|
13 | * @constructor | |
24 | * @param {Dom object} selector |
|
14 | * @param {Dom object} selector | |
25 | */ |
|
15 | */ | |
26 | var ToolBar = function (selector) { |
|
16 | var ToolBar = function (selector, layout_manager) { | |
27 | this.selector = selector; |
|
17 | this.selector = selector; | |
|
18 | this.layout_manager = layout_manager; | |||
28 | if (this.selector !== undefined) { |
|
19 | if (this.selector !== undefined) { | |
29 | this.element = $(selector); |
|
20 | this.element = $(selector); | |
30 | this.style(); |
|
21 | this.style(); | |
@@ -98,14 +89,13 b' var IPython = (function (IPython) {' | |||||
98 | */ |
|
89 | */ | |
99 | ToolBar.prototype.toggle = function () { |
|
90 | ToolBar.prototype.toggle = function () { | |
100 | this.element.toggle(); |
|
91 | this.element.toggle(); | |
101 |
if ( |
|
92 | if (this.layout_manager !== undefined) { | |
102 |
|
|
93 | this.layout_manager.do_resize(); | |
103 | } |
|
94 | } | |
104 | }; |
|
95 | }; | |
105 |
|
96 | |||
106 |
|
97 | // Backwards compatability. | ||
107 | IPython.ToolBar = ToolBar; |
|
98 | IPython.ToolBar = ToolBar; | |
108 |
|
99 | |||
109 |
return |
|
100 | return Toolbar; | |
110 |
|
101 | }); | ||
111 | }(IPython)); |
|
@@ -33,7 +33,7 b' require([' | |||||
33 | base_url: Utils.get_body_data("baseUrl"), |
|
33 | base_url: Utils.get_body_data("baseUrl"), | |
34 | notebook_path: Utils.get_body_data("notebookPath"), |
|
34 | notebook_path: Utils.get_body_data("notebookPath"), | |
35 | }; |
|
35 | }; | |
36 | events = new Events(); |
|
36 | events = $([new Events()]); | |
37 | session_list = new SesssionList(opts, events); |
|
37 | session_list = new SesssionList(opts, events); | |
38 | notebook_list = new NotebookList('#notebook_list', opts, undefined, session_list); |
|
38 | notebook_list = new NotebookList('#notebook_list', opts, undefined, session_list); | |
39 | cluster_list = new ClusterList('#cluster_list', opts); |
|
39 | cluster_list = new ClusterList('#cluster_list', opts); |
General Comments 0
You need to be logged in to leave comments.
Login now