##// END OF EJS Templates
Start of work to make notebook.html requirejs friendly.
Jonathan Frederic -
Show More
@@ -1,21 +1,9 b''
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
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 //----------------------------------------------------------------------------
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
7 3
8 //============================================================================
9 // On document ready
10 //============================================================================
11
12
13 $(document).ready(function () {
14
15 IPython.page = new IPython.Page();
4 require(['base/js/namespace', 'base/js/page'], function(IPython, Page) {
5 IPython.page = new Page();
16 6 $('button#login_submit').addClass("btn btn-default");
17 7 IPython.page.show();
18 8 $('input#password_input').focus();
19
20 9 });
21
@@ -1,20 +1,8 b''
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
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 //----------------------------------------------------------------------------
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
7 3
8 //============================================================================
9 // On document ready
10 //============================================================================
11
12
13 $(document).ready(function () {
14
15 IPython.page = new IPython.Page();
4 require(['base/js/namespace', 'base/js/page'], function(IPython, Page) {
5 IPython.page = new Page();
16 6 $('#ipython-main-app').addClass('border-box-sizing');
17 7 IPython.page.show();
18
19 8 });
20
@@ -1,3 +1,22 b''
1 "components/codemirror/lib/codemirror.js",
2 // Set codemirror version.
3 // CodeMirror.modeURL = "{{ static_url("components/codemirror/mode/%N/%N.js", include_version=False) }}";
4 "components/codemirror/addon/mode/loadmode.js",
5 "components/codemirror/addon/mode/multiplex.js",
6 "components/codemirror/addon/mode/overlay.js",
7 "components/codemirror/addon/edit/matchbrackets.js",
8 "components/codemirror/addon/edit/closebrackets.js",
9 "components/codemirror/addon/comment/comment.js",
10 "components/codemirror/mode/htmlmixed/htmlmixed.js",
11 "components/codemirror/mode/xml/xml.js",
12 "components/codemirror/mode/javascript/javascript.js",
13 "components/codemirror/mode/css/css.js",
14 "components/codemirror/mode/rst/rst.js",
15 "components/codemirror/mode/markdown/markdown.js",
16 "components/codemirror/mode/python/python.js",
17 "notebook/js/codemirror-ipython.js",
18 "notebook/js/codemirror-ipythongfm.js",
19
1 20 //----------------------------------------------------------------------------
2 21 // Copyright (C) 2008-2011 The IPython Development Team
3 22 //
@@ -1,19 +1,15 b''
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2011 The IPython Development Team
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
8 //============================================================================
9 // Layout
10 //============================================================================
11
12 var IPython = (function (IPython) {
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
3
4 define([
5 'base/js/namespace',
6 'components/jquery/jquery.min',
7 ], function(IPython, $) {
13 8 "use strict";
14 9
15 var LayoutManager = function () {
10 var LayoutManager = function (pager) {
16 11 this.bind_events();
12 this.pager = pager;
17 13 };
18 14
19 15 LayoutManager.prototype.bind_events = function () {
@@ -44,18 +40,18 b' var IPython = (function (IPython) {'
44 40
45 41 $('#ipython-main-app').height(app_height); // content+padding+border height
46 42
47 var pager_height = IPython.pager.percentage_height*app_height;
43 var pager_height = this.pager.percentage_height*app_height;
48 44 var pager_splitter_height = $('div#pager_splitter').outerHeight(true);
49 45 $('div#pager').outerHeight(pager_height);
50 if (IPython.pager.expanded) {
46 if (this.pager.expanded) {
51 47 $('div#notebook').outerHeight(app_height-pager_height-pager_splitter_height);
52 48 } else {
53 49 $('div#notebook').outerHeight(app_height-pager_splitter_height);
54 50 }
55 51 };
56 52
53 // Backwards compatability.
57 54 IPython.LayoutManager = LayoutManager;
58 55
59 return IPython;
60
61 }(IPython));
56 return LayoutManager;
57 });
@@ -1,78 +1,57 b''
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2011 The IPython Development Team
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 //----------------------------------------------------------------------------
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
7 3
8 //============================================================================
9 // On document ready
10 //============================================================================
11
12 // for the time beeing, we have to pass marked as a parameter here,
13 // as injecting require.js make marked not to put itself in the globals,
14 // which make both this file fail at setting marked configuration, and textcell.js
15 // which search marked into global.
16 require(['components/marked/lib/marked',
17 'widgets/js/init',
18 'components/bootstrap-tour/build/js/bootstrap-tour.min'],
19
20 function (marked) {
4 require([
5 'base/js/namespace',
6 'notebook/js/notebook',
7 'base/js/utils',
8 'base/js/page',
9 'notebook/js/layoutmanager',
10 'base/js/events',
11 'auth/js/loginwidget',
12 'notebook/js/maintoolbar',
13 'notebook/js/pager',
14 'notebook/js/quickhelp',
15 'notebook/js/menubar',
16 'notebook/js/notificationarea',
17 ], function(
18 IPython,
19 Notebook,
20 Utils,
21 Page,
22 LayoutManager,
23 Events,
24 LoginWidget,
25 MainToolBar,
26 Pager,
27 QuickHelp,
28 MenuBar,
29 NotificationArea
30 ) {
21 31 "use strict";
22 32
23 window.marked = marked;
24
25 // monkey patch CM to be able to syntax highlight cell magics
26 // bug reported upstream,
27 // see https://github.com/marijnh/CodeMirror2/issues/670
28 if(CodeMirror.getMode(1,'text/plain').indent === undefined ){
29 console.log('patching CM for undefined indent');
30 CodeMirror.modes.null = function() {
31 return {token: function(stream) {stream.skipToEnd();},indent : function(){return 0;}};
32 };
33 }
34
35 CodeMirror.patchedGetMode = function(config, mode){
36 var cmmode = CodeMirror.getMode(config, mode);
37 if(cmmode.indent === null) {
38 console.log('patch mode "' , mode, '" on the fly');
39 cmmode.indent = function(){return 0;};
40 }
41 return cmmode;
42 };
43 // end monkey patching CodeMirror
44
45 IPython.mathjaxutils.init();
46
47 33 $('#ipython-main-app').addClass('border-box-sizing');
48 34 $('div#notebook_panel').addClass('border-box-sizing');
49 35
50 36 var opts = {
51 base_url : IPython.utils.get_body_data("baseUrl"),
52 notebook_path : IPython.utils.get_body_data("notebookPath"),
53 notebook_name : IPython.utils.get_body_data('notebookName')
37 base_url : Utils.get_body_data("baseUrl"),
38 notebook_path : Utils.get_body_data("notebookPath"),
39 notebook_name : Utils.get_body_data('notebookName')
54 40 };
55 41
56 IPython.page = new IPython.Page();
57 IPython.layout_manager = new IPython.LayoutManager();
58 IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter');
59 IPython.quick_help = new IPython.QuickHelp();
60 try {
61 IPython.tour = new IPython.NotebookTour();
62 } catch (e) {
63 console.log("Failed to instantiate Notebook Tour", e);
64 }
65 IPython.login_widget = new IPython.LoginWidget('span#login_widget', opts);
66 IPython.notebook = new IPython.Notebook('div#notebook', opts);
67 IPython.keyboard_manager = new IPython.KeyboardManager();
68 IPython.save_widget = new IPython.SaveWidget('span#save_widget');
69 IPython.menubar = new IPython.MenuBar('#menubar', opts);
70 IPython.toolbar = new IPython.MainToolBar('#maintoolbar-container');
71 IPython.tooltip = new IPython.Tooltip();
72 IPython.notification_area = new IPython.NotificationArea('#notification_area');
73 IPython.notification_area.init_notification_widgets();
42 page = new Page();
43 pager = new Pager('div#pager', 'div#pager_splitter');
44 layout_manager = new LayoutManager(pager);
45 notebook = new Notebook('div#notebook', opts);
46 login_widget = new LoginWidget('span#login_widget', opts);
47 toolbar = new MainToolBar('#maintoolbar-container');
48 quick_help = new QuickHelp();
49 menubar = new MenuBar('#menubar', opts);
74 50
75 IPython.layout_manager.do_resize();
51 notification_area = new NotificationArea('#notification_area');
52 notification_area.init_notification_widgets();
53
54 layout_manager.do_resize();
76 55
77 56 $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+
78 57 '<span id="test2" style="font-weight: bold;">x</span>'+
@@ -85,43 +64,34 b' function (marked) {'
85 64 }
86 65 $('#fonttest').remove();
87 66
88 IPython.page.show();
67 page.show();
89 68
90 IPython.layout_manager.do_resize();
69 layout_manager.do_resize();
91 70 var first_load = function () {
92 IPython.layout_manager.do_resize();
71 layout_manager.do_resize();
93 72 var hash = document.location.hash;
94 73 if (hash) {
95 74 document.location.hash = '';
96 75 document.location.hash = hash;
97 76 }
98 IPython.notebook.set_autosave_interval(IPython.notebook.minimum_autosave_interval);
77 notebook.set_autosave_interval(notebook.minimum_autosave_interval);
99 78 // only do this once
100 $([IPython.events]).off('notebook_loaded.Notebook', first_load);
79 $([Events]).off('notebook_loaded.Notebook', first_load);
101 80 };
102 81
103 $([IPython.events]).on('notebook_loaded.Notebook', first_load);
104 $([IPython.events]).trigger('app_initialized.NotebookApp');
105 IPython.notebook.load_notebook(opts.notebook_name, opts.notebook_path);
82 $([Events]).on('notebook_loaded.Notebook', first_load);
83 $([Events]).trigger('app_initialized.NotebookApp');
84 notebook.load_notebook(opts.notebook_name, opts.notebook_path);
106 85
107 if (marked) {
108 marked.setOptions({
109 gfm : true,
110 tables: true,
111 langPrefix: "language-",
112 highlight: function(code, lang) {
113 if (!lang) {
114 // no language, no highlight
115 return code;
116 }
117 var highlighted;
118 try {
119 highlighted = hljs.highlight(lang, code, false);
120 } catch(err) {
121 highlighted = hljs.highlightAuto(code);
122 }
123 return highlighted.value;
124 }
125 });
126 }
86 // Backwards compatability.
87 IPython.page = page;
88 IPython.layout_manager = layout_manager;
89 IPython.notebook = notebook;
90 IPython.pager = pager;
91 IPython.quick_help = quick_help;
92 IPython.login_widget = login_widget;
93 IPython.menubar = menubar;
94 IPython.toolbar = toolbar;
95 IPython.notification_area = notification_area;
96 IPython.notification_area = notification_area;
127 97 });
@@ -1,26 +1,23 b''
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2011 The IPython Development Team
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
8 //============================================================================
9 // ToolBar
10 //============================================================================
11
12 var IPython = (function (IPython) {
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
3
4 define([
5 'base/js/namespace',
6 'components/jquery/jquery.min',
7 'notebook/js/toolbar',
8 ], function(IPython, $, Toolbar) {
13 9 "use strict";
14 10
15 var MainToolBar = function (selector) {
16 IPython.ToolBar.apply(this, arguments);
11 var MainToolBar = function (selector, notebook) {
12 ToolBar.apply(this, arguments);
13 this.notebook = notebook;
17 14 this.construct();
18 15 this.add_celltype_list();
19 16 this.add_celltoolbar_list();
20 17 this.bind_events();
21 18 };
22 19
23 MainToolBar.prototype = new IPython.ToolBar();
20 MainToolBar.prototype = new ToolBar();
24 21
25 22 MainToolBar.prototype.construct = function () {
26 23 this.add_buttons_group([
@@ -29,7 +26,7 b' var IPython = (function (IPython) {'
29 26 label : 'Save and Checkpoint',
30 27 icon : 'icon-save',
31 28 callback : function () {
32 IPython.notebook.save_checkpoint();
29 this.notebook.save_checkpoint();
33 30 }
34 31 }
35 32 ]);
@@ -40,9 +37,9 b' var IPython = (function (IPython) {'
40 37 label : 'Insert Cell Below',
41 38 icon : 'icon-plus-sign',
42 39 callback : function () {
43 IPython.notebook.insert_cell_below('code');
44 IPython.notebook.select_next();
45 IPython.notebook.focus_cell();
40 this.notebook.insert_cell_below('code');
41 this.notebook.select_next();
42 this.notebook.focus_cell();
46 43 }
47 44 }
48 45 ],'insert_above_below');
@@ -53,7 +50,7 b' var IPython = (function (IPython) {'
53 50 label : 'Cut Cell',
54 51 icon : 'icon-cut',
55 52 callback : function () {
56 IPython.notebook.cut_cell();
53 this.notebook.cut_cell();
57 54 }
58 55 },
59 56 {
@@ -61,7 +58,7 b' var IPython = (function (IPython) {'
61 58 label : 'Copy Cell',
62 59 icon : 'icon-copy',
63 60 callback : function () {
64 IPython.notebook.copy_cell();
61 this.notebook.copy_cell();
65 62 }
66 63 },
67 64 {
@@ -69,7 +66,7 b' var IPython = (function (IPython) {'
69 66 label : 'Paste Cell Below',
70 67 icon : 'icon-paste',
71 68 callback : function () {
72 IPython.notebook.paste_cell_below();
69 this.notebook.paste_cell_below();
73 70 }
74 71 }
75 72 ],'cut_copy_paste');
@@ -80,7 +77,7 b' var IPython = (function (IPython) {'
80 77 label : 'Move Cell Up',
81 78 icon : 'icon-arrow-up',
82 79 callback : function () {
83 IPython.notebook.move_cell_up();
80 this.notebook.move_cell_up();
84 81 }
85 82 },
86 83 {
@@ -88,7 +85,7 b' var IPython = (function (IPython) {'
88 85 label : 'Move Cell Down',
89 86 icon : 'icon-arrow-down',
90 87 callback : function () {
91 IPython.notebook.move_cell_down();
88 this.notebook.move_cell_down();
92 89 }
93 90 }
94 91 ],'move_up_down');
@@ -101,7 +98,7 b' var IPython = (function (IPython) {'
101 98 icon : 'icon-play',
102 99 callback : function () {
103 100 // emulate default shift-enter behavior
104 IPython.notebook.execute_cell_and_select_below();
101 this.notebook.execute_cell_and_select_below();
105 102 }
106 103 },
107 104 {
@@ -109,7 +106,7 b' var IPython = (function (IPython) {'
109 106 label : 'Interrupt',
110 107 icon : 'icon-stop',
111 108 callback : function () {
112 IPython.notebook.session.interrupt_kernel();
109 this.notebook.session.interrupt_kernel();
113 110 }
114 111 },
115 112 {
@@ -117,7 +114,7 b' var IPython = (function (IPython) {'
117 114 label : 'Restart Kernel',
118 115 icon : 'icon-repeat',
119 116 callback : function () {
120 IPython.notebook.restart_kernel();
117 this.notebook.restart_kernel();
121 118 }
122 119 }
123 120 ],'run_int');
@@ -151,14 +148,14 b' var IPython = (function (IPython) {'
151 148 .append($('<option/>').attr('value', '').text('None'));
152 149 this.element.append(label).append(select);
153 150 select.change(function() {
154 var val = $(this).val()
155 if (val =='') {
151 var val = $(this).val();
152 if (val ==='') {
156 153 IPython.CellToolbar.global_hide();
157 delete IPython.notebook.metadata.celltoolbar;
154 delete this.notebook.metadata.celltoolbar;
158 155 } else {
159 156 IPython.CellToolbar.global_show();
160 157 IPython.CellToolbar.activate_preset(val);
161 IPython.notebook.metadata.celltoolbar = val;
158 this.notebook.metadata.celltoolbar = val;
162 159 }
163 160 });
164 161 // Setup the currently registered presets.
@@ -186,23 +183,23 b' var IPython = (function (IPython) {'
186 183 this.element.find('#cell_type').change(function () {
187 184 var cell_type = $(this).val();
188 185 if (cell_type === 'code') {
189 IPython.notebook.to_code();
186 this.notebook.to_code();
190 187 } else if (cell_type === 'markdown') {
191 IPython.notebook.to_markdown();
188 this.notebook.to_markdown();
192 189 } else if (cell_type === 'raw') {
193 IPython.notebook.to_raw();
190 this.notebook.to_raw();
194 191 } else if (cell_type === 'heading1') {
195 IPython.notebook.to_heading(undefined, 1);
192 this.notebook.to_heading(undefined, 1);
196 193 } else if (cell_type === 'heading2') {
197 IPython.notebook.to_heading(undefined, 2);
194 this.notebook.to_heading(undefined, 2);
198 195 } else if (cell_type === 'heading3') {
199 IPython.notebook.to_heading(undefined, 3);
196 this.notebook.to_heading(undefined, 3);
200 197 } else if (cell_type === 'heading4') {
201 IPython.notebook.to_heading(undefined, 4);
198 this.notebook.to_heading(undefined, 4);
202 199 } else if (cell_type === 'heading5') {
203 IPython.notebook.to_heading(undefined, 5);
200 this.notebook.to_heading(undefined, 5);
204 201 } else if (cell_type === 'heading6') {
205 IPython.notebook.to_heading(undefined, 6);
202 this.notebook.to_heading(undefined, 6);
206 203 }
207 204 });
208 205 $([IPython.events]).on('selected_cell_type_changed.Notebook', function (event, data) {
@@ -214,8 +211,8 b' var IPython = (function (IPython) {'
214 211 });
215 212 };
216 213
214 // Backwards compatability.
217 215 IPython.MainToolBar = MainToolBar;
218 216
219 return IPython;
220
221 }(IPython));
217 return MainToolBar;
218 });
@@ -1,18 +1,135 b''
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2011 The IPython Development Team
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
8 //============================================================================
9 // Notebook
10 //============================================================================
11
12 var IPython = (function (IPython) {
13 "use strict";
14
15 var utils = IPython.utils;
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
3
4
5 "components/google-caja/html-css-sanitizer-minified",
6
7 "components/highlight.js/build/highlight.pack",
8 "dateformat/date.format",
9 "base/js/security",
10 "services/kernels/js/kernel",
11 "services/kernels/js/comm",
12 "notebook/js/mathjaxutils",
13 "notebook/js/outputarea",
14 "notebook/js/cell",
15 "notebook/js/codecell",
16 "notebook/js/completer",
17 "notebook/js/notificationwidget",
18 "notebook/js/notificationarea",
19 "notebook/js/tooltip",
20 "notebook/js/config",
21 "notebook/js/main",
22 "notebook/js/contexthint",
23 "notebook/js/celltoolbarpresets/default",
24 "notebook/js/celltoolbarpresets/rawcell",
25 "notebook/js/celltoolbarpresets/slideshow"
26
27 IPython.mathjaxutils.init();
28
29 'components/marked/lib/marked',
30 'widgets/js/init',
31 'components/bootstrap-tour/build/js/bootstrap-tour.min'
32
33 window.marked = marked;
34
35 if (marked) {
36 marked.setOptions({
37 gfm : true,
38 tables: true,
39 langPrefix: "language-",
40 highlight: function(code, lang) {
41 if (!lang) {
42 // no language, no highlight
43 return code;
44 }
45 var highlighted;
46 try {
47 highlighted = hljs.highlight(lang, code, false);
48 } catch(err) {
49 highlighted = hljs.highlightAuto(code);
50 }
51 return highlighted.value;
52 }
53 });
54 }
55
56 // monkey patch CM to be able to syntax highlight cell magics
57 // bug reported upstream,
58 // see https://github.com/marijnh/CodeMirror2/issues/670
59 if(CodeMirror.getMode(1,'text/plain').indent === undefined ){
60 console.log('patching CM for undefined indent');
61 CodeMirror.modes.null = function() {
62 return {token: function(stream) {stream.skipToEnd();},indent : function(){return 0;}};
63 };
64 }
65
66 CodeMirror.patchedGetMode = function(config, mode){
67 var cmmode = CodeMirror.getMode(config, mode);
68 if(cmmode.indent === null) {
69 console.log('patch mode "' , mode, '" on the fly');
70 cmmode.indent = function(){return 0;};
71 }
72 return cmmode;
73 };
74 // end monkey patching CodeMirror
75
76
77 "notebook/js/tour",
78 Tour,
79
80 try {
81 tour = new Tour();
82 } catch (e) {
83 tour = undefined;
84 console.log("Failed to instantiate Notebook Tour", e);
85 }
86
87 IPython.tour = tour;
88
89 "notebook/js/tooltip",
90 Tooltip,
91 tooltip = new Tooltip();
92 IPython.tooltip = tooltip;
93
94
95 define([
96 "base/js/namespace",
97 "components/jquery/jquery.min",
98 "base/js/utils",
99 "notebook/js/keyboardmanager",
100 "notebook/js/savewidget",
101 "base/js/events",
102 "base/js/dialog",
103 "notebook/js/textcell",
104 "notebook/js/codecell",
105 "services/sessions/js/session",
106 "notebook/js/celltoolbar",
107 "base/js/keyboard",
108 "components/jquery-ui/ui/minified/jquery-ui.min",
109 "components/bootstrap/js/bootstrap.min",
110 ], function (
111 IPython,
112 $,
113 Utils,
114 KeyboardManager,
115 SaveWidget,
116 Events,
117 Dialog,
118 Cells,
119 CodeCell,
120 Session,
121 CellToolbar,
122 Keyboard
123 ) {
124
125 keyboard_manager = new KeyboardManager();
126 save_widget = new SaveWidget('span#save_widget');
127 keyboard = new Keyboard();
128
129 // Backwards compatability.
130 IPython.keyboard_manager = keyboard_manager;
131 IPython.save_widget = save_widget;
132 IPython.keyboard = keyboard;
16 133
17 134 /**
18 135 * A notebook contains and manages cells.
@@ -102,36 +219,36 b' var IPython = (function (IPython) {'
102 219 Notebook.prototype.bind_events = function () {
103 220 var that = this;
104 221
105 $([IPython.events]).on('set_next_input.Notebook', function (event, data) {
222 $([Events]).on('set_next_input.Notebook', function (event, data) {
106 223 var index = that.find_cell_index(data.cell);
107 224 var new_cell = that.insert_cell_below('code',index);
108 225 new_cell.set_text(data.text);
109 226 that.dirty = true;
110 227 });
111 228
112 $([IPython.events]).on('set_dirty.Notebook', function (event, data) {
229 $([Events]).on('set_dirty.Notebook', function (event, data) {
113 230 that.dirty = data.value;
114 231 });
115 232
116 $([IPython.events]).on('trust_changed.Notebook', function (event, data) {
233 $([Events]).on('trust_changed.Notebook', function (event, data) {
117 234 that.trusted = data.value;
118 235 });
119 236
120 $([IPython.events]).on('select.Cell', function (event, data) {
237 $([Events]).on('select.Cell', function (event, data) {
121 238 var index = that.find_cell_index(data.cell);
122 239 that.select(index);
123 240 });
124 241
125 $([IPython.events]).on('edit_mode.Cell', function (event, data) {
242 $([Events]).on('edit_mode.Cell', function (event, data) {
126 243 that.handle_edit_mode(data.cell);
127 244 });
128 245
129 $([IPython.events]).on('command_mode.Cell', function (event, data) {
246 $([Events]).on('command_mode.Cell', function (event, data) {
130 247 that.handle_command_mode(data.cell);
131 248 });
132 249
133 $([IPython.events]).on('status_autorestarting.Kernel', function () {
134 IPython.dialog.modal({
250 $([Events]).on('status_autorestarting.Kernel', function () {
251 Dialog.modal({
135 252 title: "Kernel Restarting",
136 253 body: "The kernel appears to have died. It will restart automatically.",
137 254 buttons: {
@@ -211,7 +328,7 b' var IPython = (function (IPython) {'
211 328 if (this.dirty == value) {
212 329 return;
213 330 }
214 $([IPython.events]).trigger('set_dirty.Notebook', {value: value});
331 $([Events]).trigger('set_dirty.Notebook', {value: value});
215 332 };
216 333
217 334 /**
@@ -254,7 +371,7 b' var IPython = (function (IPython) {'
254 371
255 372 Notebook.prototype.edit_metadata = function () {
256 373 var that = this;
257 IPython.dialog.edit_metadata(this.metadata, function (md) {
374 Dialog.edit_metadata(this.metadata, function (md) {
258 375 that.metadata = md;
259 376 }, 'Notebook');
260 377 };
@@ -295,7 +412,7 b' var IPython = (function (IPython) {'
295 412 * @return {Cell} Cell or null if no cell was found.
296 413 */
297 414 Notebook.prototype.get_msg_cell = function (msg_id) {
298 return IPython.CodeCell.msg_cells[msg_id] || null;
415 return CodeCell.msg_cells[msg_id] || null;
299 416 };
300 417
301 418 /**
@@ -474,11 +591,11 b' var IPython = (function (IPython) {'
474 591 var cell = this.get_cell(index);
475 592 cell.select();
476 593 if (cell.cell_type === 'heading') {
477 $([IPython.events]).trigger('selected_cell_type_changed.Notebook',
594 $([Events]).trigger('selected_cell_type_changed.Notebook',
478 595 {'cell_type':cell.cell_type,level:cell.level}
479 596 );
480 597 } else {
481 $([IPython.events]).trigger('selected_cell_type_changed.Notebook',
598 $([Events]).trigger('selected_cell_type_changed.Notebook',
482 599 {'cell_type':cell.cell_type}
483 600 );
484 601 }
@@ -540,8 +657,8 b' var IPython = (function (IPython) {'
540 657 if (this.mode !== 'command') {
541 658 cell.command_mode();
542 659 this.mode = 'command';
543 $([IPython.events]).trigger('command_mode.Notebook');
544 IPython.keyboard_manager.command_mode();
660 $([Events]).trigger('command_mode.Notebook');
661 keyboard_manager.command_mode();
545 662 }
546 663 };
547 664
@@ -570,8 +687,8 b' var IPython = (function (IPython) {'
570 687 if (cell && this.mode !== 'edit') {
571 688 cell.edit_mode();
572 689 this.mode = 'edit';
573 $([IPython.events]).trigger('edit_mode.Notebook');
574 IPython.keyboard_manager.edit_mode();
690 $([Events]).trigger('edit_mode.Notebook');
691 keyboard_manager.edit_mode();
575 692 }
576 693 };
577 694
@@ -686,7 +803,7 b' var IPython = (function (IPython) {'
686 803 this.undelete_index = i;
687 804 this.undelete_below = false;
688 805 }
689 $([IPython.events]).trigger('delete.Cell', {'cell': cell, 'index': i});
806 $([Events]).trigger('delete.Cell', {'cell': cell, 'index': i});
690 807 this.set_dirty(true);
691 808 }
692 809 return this;
@@ -754,19 +871,19 b' var IPython = (function (IPython) {'
754 871
755 872 if (ncells === 0 || this.is_valid_cell_index(index) || index === ncells) {
756 873 if (type === 'code') {
757 cell = new IPython.CodeCell(this.kernel);
874 cell = new CodeCell(this.kernel);
758 875 cell.set_input_prompt();
759 876 } else if (type === 'markdown') {
760 cell = new IPython.MarkdownCell();
877 cell = new Cells.MarkdownCell();
761 878 } else if (type === 'raw') {
762 cell = new IPython.RawCell();
879 cell = new Cells.RawCell();
763 880 } else if (type === 'heading') {
764 cell = new IPython.HeadingCell();
881 cell = new Cells.HeadingCell();
765 882 }
766 883
767 884 if(this._insert_element_at_index(cell.element,index)) {
768 885 cell.render();
769 $([IPython.events]).trigger('create.Cell', {'cell': cell, 'index': index});
886 $([Events]).trigger('create.Cell', {'cell': cell, 'index': index});
770 887 cell.refresh();
771 888 // We used to select the cell after we refresh it, but there
772 889 // are now cases were this method is called where select is
@@ -876,7 +993,7 b' var IPython = (function (IPython) {'
876 993 if (this.is_valid_cell_index(i)) {
877 994 var source_element = this.get_cell_element(i);
878 995 var source_cell = source_element.data("cell");
879 if (!(source_cell instanceof IPython.CodeCell)) {
996 if (!(source_cell instanceof CodeCell)) {
880 997 var target_cell = this.insert_cell_below('code',i);
881 998 var text = source_cell.get_text();
882 999 if (text === source_cell.placeholder) {
@@ -906,7 +1023,7 b' var IPython = (function (IPython) {'
906 1023 if (this.is_valid_cell_index(i)) {
907 1024 var source_element = this.get_cell_element(i);
908 1025 var source_cell = source_element.data("cell");
909 if (!(source_cell instanceof IPython.MarkdownCell)) {
1026 if (!(source_cell instanceof Cells.MarkdownCell)) {
910 1027 var target_cell = this.insert_cell_below('markdown',i);
911 1028 var text = source_cell.get_text();
912 1029 if (text === source_cell.placeholder) {
@@ -920,7 +1037,7 b' var IPython = (function (IPython) {'
920 1037 target_cell.code_mirror.clearHistory();
921 1038 source_element.remove();
922 1039 this.select(i);
923 if ((source_cell instanceof IPython.TextCell) && source_cell.rendered) {
1040 if ((source_cell instanceof Cells.TextCell) && source_cell.rendered) {
924 1041 target_cell.render();
925 1042 }
926 1043 var cursor = source_cell.code_mirror.getCursor();
@@ -942,7 +1059,7 b' var IPython = (function (IPython) {'
942 1059 var source_element = this.get_cell_element(i);
943 1060 var source_cell = source_element.data("cell");
944 1061 var target_cell = null;
945 if (!(source_cell instanceof IPython.RawCell)) {
1062 if (!(source_cell instanceof Cells.RawCell)) {
946 1063 target_cell = this.insert_cell_below('raw',i);
947 1064 var text = source_cell.get_text();
948 1065 if (text === source_cell.placeholder) {
@@ -977,7 +1094,7 b' var IPython = (function (IPython) {'
977 1094 var source_element = this.get_cell_element(i);
978 1095 var source_cell = source_element.data("cell");
979 1096 var target_cell = null;
980 if (source_cell instanceof IPython.HeadingCell) {
1097 if (source_cell instanceof Cells.HeadingCell) {
981 1098 source_cell.set_level(level);
982 1099 } else {
983 1100 target_cell = this.insert_cell_below('heading',i);
@@ -996,12 +1113,12 b' var IPython = (function (IPython) {'
996 1113 this.select(i);
997 1114 var cursor = source_cell.code_mirror.getCursor();
998 1115 target_cell.code_mirror.setCursor(cursor);
999 if ((source_cell instanceof IPython.TextCell) && source_cell.rendered) {
1116 if ((source_cell instanceof Cells.TextCell) && source_cell.rendered) {
1000 1117 target_cell.render();
1001 1118 }
1002 1119 }
1003 1120 this.set_dirty(true);
1004 $([IPython.events]).trigger('selected_cell_type_changed.Notebook',
1121 $([Events]).trigger('selected_cell_type_changed.Notebook',
1005 1122 {'cell_type':'heading',level:level}
1006 1123 );
1007 1124 }
@@ -1115,13 +1232,13 b' var IPython = (function (IPython) {'
1115 1232 * @method split_cell
1116 1233 */
1117 1234 Notebook.prototype.split_cell = function () {
1118 var mdc = IPython.MarkdownCell;
1119 var rc = IPython.RawCell;
1235 var mdc = Cells.MarkdownCell;
1236 var rc = Cells.RawCell;
1120 1237 var cell = this.get_selected_cell();
1121 1238 if (cell.is_splittable()) {
1122 1239 var texta = cell.get_pre_cursor();
1123 1240 var textb = cell.get_post_cursor();
1124 if (cell instanceof IPython.CodeCell) {
1241 if (cell instanceof CodeCell) {
1125 1242 // In this case the operations keep the notebook in its existing mode
1126 1243 // so we don't need to do any post-op mode changes.
1127 1244 cell.set_text(textb);
@@ -1144,8 +1261,8 b' var IPython = (function (IPython) {'
1144 1261 * @method merge_cell_above
1145 1262 */
1146 1263 Notebook.prototype.merge_cell_above = function () {
1147 var mdc = IPython.MarkdownCell;
1148 var rc = IPython.RawCell;
1264 var mdc = Cells.MarkdownCell;
1265 var rc = Cells.RawCell;
1149 1266 var index = this.get_selected_index();
1150 1267 var cell = this.get_cell(index);
1151 1268 var render = cell.rendered;
@@ -1159,7 +1276,7 b' var IPython = (function (IPython) {'
1159 1276 }
1160 1277 var upper_text = upper_cell.get_text();
1161 1278 var text = cell.get_text();
1162 if (cell instanceof IPython.CodeCell) {
1279 if (cell instanceof CodeCell) {
1163 1280 cell.set_text(upper_text+'\n'+text);
1164 1281 } else if ((cell instanceof mdc) || (cell instanceof rc)) {
1165 1282 cell.unrender(); // Must unrender before we set_text.
@@ -1181,8 +1298,8 b' var IPython = (function (IPython) {'
1181 1298 * @method merge_cell_below
1182 1299 */
1183 1300 Notebook.prototype.merge_cell_below = function () {
1184 var mdc = IPython.MarkdownCell;
1185 var rc = IPython.RawCell;
1301 var mdc = Cells.MarkdownCell;
1302 var rc = Cells.RawCell;
1186 1303 var index = this.get_selected_index();
1187 1304 var cell = this.get_cell(index);
1188 1305 var render = cell.rendered;
@@ -1196,7 +1313,7 b' var IPython = (function (IPython) {'
1196 1313 }
1197 1314 var lower_text = lower_cell.get_text();
1198 1315 var text = cell.get_text();
1199 if (cell instanceof IPython.CodeCell) {
1316 if (cell instanceof CodeCell) {
1200 1317 cell.set_text(text+'\n'+lower_text);
1201 1318 } else if ((cell instanceof mdc) || (cell instanceof rc)) {
1202 1319 cell.unrender(); // Must unrender before we set_text.
@@ -1224,7 +1341,7 b' var IPython = (function (IPython) {'
1224 1341 Notebook.prototype.collapse_output = function (index) {
1225 1342 var i = this.index_or_selected(index);
1226 1343 var cell = this.get_cell(i);
1227 if (cell !== null && (cell instanceof IPython.CodeCell)) {
1344 if (cell !== null && (cell instanceof CodeCell)) {
1228 1345 cell.collapse_output();
1229 1346 this.set_dirty(true);
1230 1347 }
@@ -1237,7 +1354,7 b' var IPython = (function (IPython) {'
1237 1354 */
1238 1355 Notebook.prototype.collapse_all_output = function () {
1239 1356 $.map(this.get_cells(), function (cell, i) {
1240 if (cell instanceof IPython.CodeCell) {
1357 if (cell instanceof CodeCell) {
1241 1358 cell.collapse_output();
1242 1359 }
1243 1360 });
@@ -1254,7 +1371,7 b' var IPython = (function (IPython) {'
1254 1371 Notebook.prototype.expand_output = function (index) {
1255 1372 var i = this.index_or_selected(index);
1256 1373 var cell = this.get_cell(i);
1257 if (cell !== null && (cell instanceof IPython.CodeCell)) {
1374 if (cell !== null && (cell instanceof CodeCell)) {
1258 1375 cell.expand_output();
1259 1376 this.set_dirty(true);
1260 1377 }
@@ -1267,7 +1384,7 b' var IPython = (function (IPython) {'
1267 1384 */
1268 1385 Notebook.prototype.expand_all_output = function () {
1269 1386 $.map(this.get_cells(), function (cell, i) {
1270 if (cell instanceof IPython.CodeCell) {
1387 if (cell instanceof CodeCell) {
1271 1388 cell.expand_output();
1272 1389 }
1273 1390 });
@@ -1284,7 +1401,7 b' var IPython = (function (IPython) {'
1284 1401 Notebook.prototype.clear_output = function (index) {
1285 1402 var i = this.index_or_selected(index);
1286 1403 var cell = this.get_cell(i);
1287 if (cell !== null && (cell instanceof IPython.CodeCell)) {
1404 if (cell !== null && (cell instanceof CodeCell)) {
1288 1405 cell.clear_output();
1289 1406 this.set_dirty(true);
1290 1407 }
@@ -1297,7 +1414,7 b' var IPython = (function (IPython) {'
1297 1414 */
1298 1415 Notebook.prototype.clear_all_output = function () {
1299 1416 $.map(this.get_cells(), function (cell, i) {
1300 if (cell instanceof IPython.CodeCell) {
1417 if (cell instanceof CodeCell) {
1301 1418 cell.clear_output();
1302 1419 }
1303 1420 });
@@ -1313,7 +1430,7 b' var IPython = (function (IPython) {'
1313 1430 Notebook.prototype.scroll_output = function (index) {
1314 1431 var i = this.index_or_selected(index);
1315 1432 var cell = this.get_cell(i);
1316 if (cell !== null && (cell instanceof IPython.CodeCell)) {
1433 if (cell !== null && (cell instanceof CodeCell)) {
1317 1434 cell.scroll_output();
1318 1435 this.set_dirty(true);
1319 1436 }
@@ -1326,7 +1443,7 b' var IPython = (function (IPython) {'
1326 1443 */
1327 1444 Notebook.prototype.scroll_all_output = function () {
1328 1445 $.map(this.get_cells(), function (cell, i) {
1329 if (cell instanceof IPython.CodeCell) {
1446 if (cell instanceof CodeCell) {
1330 1447 cell.scroll_output();
1331 1448 }
1332 1449 });
@@ -1342,7 +1459,7 b' var IPython = (function (IPython) {'
1342 1459 Notebook.prototype.toggle_output = function (index) {
1343 1460 var i = this.index_or_selected(index);
1344 1461 var cell = this.get_cell(i);
1345 if (cell !== null && (cell instanceof IPython.CodeCell)) {
1462 if (cell !== null && (cell instanceof CodeCell)) {
1346 1463 cell.toggle_output();
1347 1464 this.set_dirty(true);
1348 1465 }
@@ -1355,7 +1472,7 b' var IPython = (function (IPython) {'
1355 1472 */
1356 1473 Notebook.prototype.toggle_all_output = function () {
1357 1474 $.map(this.get_cells(), function (cell, i) {
1358 if (cell instanceof IPython.CodeCell) {
1475 if (cell instanceof CodeCell) {
1359 1476 cell.toggle_output();
1360 1477 }
1361 1478 });
@@ -1372,7 +1489,7 b' var IPython = (function (IPython) {'
1372 1489 Notebook.prototype.toggle_output_scroll = function (index) {
1373 1490 var i = this.index_or_selected(index);
1374 1491 var cell = this.get_cell(i);
1375 if (cell !== null && (cell instanceof IPython.CodeCell)) {
1492 if (cell !== null && (cell instanceof CodeCell)) {
1376 1493 cell.toggle_output_scroll();
1377 1494 this.set_dirty(true);
1378 1495 }
@@ -1385,7 +1502,7 b' var IPython = (function (IPython) {'
1385 1502 */
1386 1503 Notebook.prototype.toggle_all_output_scroll = function () {
1387 1504 $.map(this.get_cells(), function (cell, i) {
1388 if (cell instanceof IPython.CodeCell) {
1505 if (cell instanceof CodeCell) {
1389 1506 cell.toggle_output_scroll();
1390 1507 }
1391 1508 });
@@ -1412,7 +1529,7 b' var IPython = (function (IPython) {'
1412 1529 * @method start_session
1413 1530 */
1414 1531 Notebook.prototype.start_session = function () {
1415 this.session = new IPython.Session(this, this.options);
1532 this.session = new Session(this, this.options);
1416 1533 this.session.start($.proxy(this._session_started, this));
1417 1534 };
1418 1535
@@ -1427,7 +1544,7 b' var IPython = (function (IPython) {'
1427 1544 var ncells = this.ncells();
1428 1545 for (var i=0; i<ncells; i++) {
1429 1546 var cell = this.get_cell(i);
1430 if (cell instanceof IPython.CodeCell) {
1547 if (cell instanceof CodeCell) {
1431 1548 cell.set_kernel(this.session.kernel);
1432 1549 }
1433 1550 }
@@ -1440,7 +1557,7 b' var IPython = (function (IPython) {'
1440 1557 */
1441 1558 Notebook.prototype.restart_kernel = function () {
1442 1559 var that = this;
1443 IPython.dialog.modal({
1560 Dialog.modal({
1444 1561 title : "Restart kernel or continue running?",
1445 1562 body : $("<p/>").text(
1446 1563 'Do you want to restart the current kernel? You will lose all variables defined in it.'
@@ -1660,10 +1777,10 b' var IPython = (function (IPython) {'
1660 1777 }
1661 1778 if (trusted != this.trusted) {
1662 1779 this.trusted = trusted;
1663 $([IPython.events]).trigger("trust_changed.Notebook", trusted);
1780 $([Events]).trigger("trust_changed.Notebook", trusted);
1664 1781 }
1665 1782 if (content.worksheets.length > 1) {
1666 IPython.dialog.modal({
1783 Dialog.modal({
1667 1784 title : "Multiple worksheets",
1668 1785 body : "This notebook has " + data.worksheets.length + " worksheets, " +
1669 1786 "but this version of IPython can only handle the first. " +
@@ -1705,7 +1822,7 b' var IPython = (function (IPython) {'
1705 1822 };
1706 1823 if (trusted != this.trusted) {
1707 1824 this.trusted = trusted;
1708 $([IPython.events]).trigger("trust_changed.Notebook", trusted);
1825 $([Events]).trigger("trust_changed.Notebook", trusted);
1709 1826 }
1710 1827 return data;
1711 1828 };
@@ -1730,10 +1847,10 b' var IPython = (function (IPython) {'
1730 1847 that.save_notebook();
1731 1848 }
1732 1849 }, interval);
1733 $([IPython.events]).trigger("autosave_enabled.Notebook", interval);
1850 $([Events]).trigger("autosave_enabled.Notebook", interval);
1734 1851 } else {
1735 1852 this.autosave_timer = null;
1736 $([IPython.events]).trigger("autosave_disabled.Notebook");
1853 $([Events]).trigger("autosave_disabled.Notebook");
1737 1854 }
1738 1855 };
1739 1856
@@ -1768,7 +1885,7 b' var IPython = (function (IPython) {'
1768 1885 settings[key] = extra_settings[key];
1769 1886 }
1770 1887 }
1771 $([IPython.events]).trigger('notebook_saving.Notebook');
1888 $([Events]).trigger('notebook_saving.Notebook');
1772 1889 var url = utils.url_join_encode(
1773 1890 this.base_url,
1774 1891 'api/notebooks',
@@ -1789,7 +1906,7 b' var IPython = (function (IPython) {'
1789 1906 */
1790 1907 Notebook.prototype.save_notebook_success = function (start, data, status, xhr) {
1791 1908 this.set_dirty(false);
1792 $([IPython.events]).trigger('notebook_saved.Notebook');
1909 $([Events]).trigger('notebook_saved.Notebook');
1793 1910 this._update_autosave_interval(start);
1794 1911 if (this._checkpoint_after_save) {
1795 1912 this.create_checkpoint();
@@ -1826,7 +1943,7 b' var IPython = (function (IPython) {'
1826 1943 * @param {String} error HTTP error message
1827 1944 */
1828 1945 Notebook.prototype.save_notebook_error = function (xhr, status, error) {
1829 $([IPython.events]).trigger('notebook_save_failed.Notebook', [xhr, status, error]);
1946 $([Events]).trigger('notebook_save_failed.Notebook', [xhr, status, error]);
1830 1947 };
1831 1948
1832 1949 /**
@@ -1851,7 +1968,7 b' var IPython = (function (IPython) {'
1851 1968 );
1852 1969
1853 1970 var nb = this;
1854 IPython.dialog.modal({
1971 Dialog.modal({
1855 1972 title: "Trust this notebook?",
1856 1973 body: body,
1857 1974
@@ -1867,7 +1984,7 b' var IPython = (function (IPython) {'
1867 1984 cell.output_area.trusted = true;
1868 1985 }
1869 1986 }
1870 $([IPython.events]).on('notebook_saved.Notebook', function () {
1987 $([Events]).on('notebook_saved.Notebook', function () {
1871 1988 window.location.reload();
1872 1989 });
1873 1990 nb.save_notebook();
@@ -1953,7 +2070,7 b' var IPython = (function (IPython) {'
1953 2070 success : $.proxy(that.rename_success, this),
1954 2071 error : $.proxy(that.rename_error, this)
1955 2072 };
1956 $([IPython.events]).trigger('rename_notebook.Notebook', data);
2073 $([Events]).trigger('rename_notebook.Notebook', data);
1957 2074 var url = utils.url_join_encode(
1958 2075 this.base_url,
1959 2076 'api/notebooks',
@@ -1986,7 +2103,7 b' var IPython = (function (IPython) {'
1986 2103 var name = this.notebook_name = json.name;
1987 2104 var path = json.path;
1988 2105 this.session.rename_notebook(name, path);
1989 $([IPython.events]).trigger('notebook_renamed.Notebook', json);
2106 $([Events]).trigger('notebook_renamed.Notebook', json);
1990 2107 };
1991 2108
1992 2109 Notebook.prototype.rename_error = function (xhr, status, error) {
@@ -1995,8 +2112,8 b' var IPython = (function (IPython) {'
1995 2112 $("<p/>").addClass("rename-message")
1996 2113 .text('This notebook name already exists.')
1997 2114 );
1998 $([IPython.events]).trigger('notebook_rename_failed.Notebook', [xhr, status, error]);
1999 IPython.dialog.modal({
2115 $([Events]).trigger('notebook_rename_failed.Notebook', [xhr, status, error]);
2116 Dialog.modal({
2000 2117 title: "Notebook Rename Error!",
2001 2118 body: dialog,
2002 2119 buttons : {
@@ -2004,14 +2121,14 b' var IPython = (function (IPython) {'
2004 2121 "OK": {
2005 2122 class: "btn-primary",
2006 2123 click: function () {
2007 IPython.save_widget.rename_notebook();
2124 save_widget.rename_notebook();
2008 2125 }}
2009 2126 },
2010 2127 open : function (event, ui) {
2011 2128 var that = $(this);
2012 2129 // Upon ENTER, click the OK button.
2013 2130 that.find('input[type="text"]').keydown(function (event, ui) {
2014 if (event.which === IPython.keyboard.keycodes.enter) {
2131 if (event.which === keyboard.keycodes.enter) {
2015 2132 that.find('.btn-primary').first().click();
2016 2133 }
2017 2134 });
@@ -2039,7 +2156,7 b' var IPython = (function (IPython) {'
2039 2156 success : $.proxy(this.load_notebook_success,this),
2040 2157 error : $.proxy(this.load_notebook_error,this),
2041 2158 };
2042 $([IPython.events]).trigger('notebook_loading.Notebook');
2159 $([Events]).trigger('notebook_loading.Notebook');
2043 2160 var url = utils.url_join_encode(
2044 2161 this.base_url,
2045 2162 'api/notebooks',
@@ -2077,7 +2194,7 b' var IPython = (function (IPython) {'
2077 2194 "newer notebook format will be used and older versions of IPython " +
2078 2195 "may not be able to read it. To keep the older version, close the " +
2079 2196 "notebook without saving it.";
2080 IPython.dialog.modal({
2197 Dialog.modal({
2081 2198 title : "Notebook converted",
2082 2199 body : msg,
2083 2200 buttons : {
@@ -2094,7 +2211,7 b' var IPython = (function (IPython) {'
2094 2211 this_vs + ". You can still work with this notebook, but some features " +
2095 2212 "introduced in later notebook versions may not be available.";
2096 2213
2097 IPython.dialog.modal({
2214 Dialog.modal({
2098 2215 title : "Newer Notebook",
2099 2216 body : msg,
2100 2217 buttons : {
@@ -2116,15 +2233,15 b' var IPython = (function (IPython) {'
2116 2233
2117 2234 // load toolbar state
2118 2235 if (this.metadata.celltoolbar) {
2119 IPython.CellToolbar.global_show();
2120 IPython.CellToolbar.activate_preset(this.metadata.celltoolbar);
2236 CellToolbar.global_show();
2237 CellToolbar.activate_preset(this.metadata.celltoolbar);
2121 2238 } else {
2122 IPython.CellToolbar.global_hide();
2239 CellToolbar.global_hide();
2123 2240 }
2124 2241
2125 2242 // now that we're fully loaded, it is safe to restore save functionality
2126 2243 delete(this.save_notebook);
2127 $([IPython.events]).trigger('notebook_loaded.Notebook');
2244 $([Events]).trigger('notebook_loaded.Notebook');
2128 2245 };
2129 2246
2130 2247 /**
@@ -2136,7 +2253,7 b' var IPython = (function (IPython) {'
2136 2253 * @param {String} error HTTP error message
2137 2254 */
2138 2255 Notebook.prototype.load_notebook_error = function (xhr, status, error) {
2139 $([IPython.events]).trigger('notebook_load_failed.Notebook', [xhr, status, error]);
2256 $([Events]).trigger('notebook_load_failed.Notebook', [xhr, status, error]);
2140 2257 var msg;
2141 2258 if (xhr.status === 400) {
2142 2259 msg = error;
@@ -2145,7 +2262,7 b' var IPython = (function (IPython) {'
2145 2262 "This version can load notebook formats " +
2146 2263 "v" + this.nbformat + " or earlier.";
2147 2264 }
2148 IPython.dialog.modal({
2265 Dialog.modal({
2149 2266 title: "Error loading notebook",
2150 2267 body : msg,
2151 2268 buttons : {
@@ -2224,7 +2341,7 b' var IPython = (function (IPython) {'
2224 2341 } else {
2225 2342 this.last_checkpoint = null;
2226 2343 }
2227 $([IPython.events]).trigger('checkpoints_listed.Notebook', [data]);
2344 $([Events]).trigger('checkpoints_listed.Notebook', [data]);
2228 2345 };
2229 2346
2230 2347 /**
@@ -2236,7 +2353,7 b' var IPython = (function (IPython) {'
2236 2353 * @param {String} error_msg HTTP error message
2237 2354 */
2238 2355 Notebook.prototype.list_checkpoints_error = function (xhr, status, error_msg) {
2239 $([IPython.events]).trigger('list_checkpoints_failed.Notebook');
2356 $([Events]).trigger('list_checkpoints_failed.Notebook');
2240 2357 };
2241 2358
2242 2359 /**
@@ -2270,7 +2387,7 b' var IPython = (function (IPython) {'
2270 2387 Notebook.prototype.create_checkpoint_success = function (data, status, xhr) {
2271 2388 data = $.parseJSON(data);
2272 2389 this.add_checkpoint(data);
2273 $([IPython.events]).trigger('checkpoint_created.Notebook', data);
2390 $([Events]).trigger('checkpoint_created.Notebook', data);
2274 2391 };
2275 2392
2276 2393 /**
@@ -2282,7 +2399,7 b' var IPython = (function (IPython) {'
2282 2399 * @param {String} error_msg HTTP error message
2283 2400 */
2284 2401 Notebook.prototype.create_checkpoint_error = function (xhr, status, error_msg) {
2285 $([IPython.events]).trigger('checkpoint_failed.Notebook');
2402 $([Events]).trigger('checkpoint_failed.Notebook');
2286 2403 };
2287 2404
2288 2405 Notebook.prototype.restore_checkpoint_dialog = function (checkpoint) {
@@ -2309,7 +2426,7 b' var IPython = (function (IPython) {'
2309 2426 ).css("text-align", "center")
2310 2427 );
2311 2428
2312 IPython.dialog.modal({
2429 Dialog.modal({
2313 2430 title : "Revert notebook to checkpoint",
2314 2431 body : body,
2315 2432 buttons : {
@@ -2331,7 +2448,7 b' var IPython = (function (IPython) {'
2331 2448 * @param {String} checkpoint ID
2332 2449 */
2333 2450 Notebook.prototype.restore_checkpoint = function (checkpoint) {
2334 $([IPython.events]).trigger('notebook_restoring.Notebook', checkpoint);
2451 $([Events]).trigger('notebook_restoring.Notebook', checkpoint);
2335 2452 var url = utils.url_join_encode(
2336 2453 this.base_url,
2337 2454 'api/notebooks',
@@ -2356,7 +2473,7 b' var IPython = (function (IPython) {'
2356 2473 * @param {jqXHR} xhr jQuery Ajax object
2357 2474 */
2358 2475 Notebook.prototype.restore_checkpoint_success = function (data, status, xhr) {
2359 $([IPython.events]).trigger('checkpoint_restored.Notebook');
2476 $([Events]).trigger('checkpoint_restored.Notebook');
2360 2477 this.load_notebook(this.notebook_name, this.notebook_path);
2361 2478 };
2362 2479
@@ -2369,7 +2486,7 b' var IPython = (function (IPython) {'
2369 2486 * @param {String} error_msg HTTP error message
2370 2487 */
2371 2488 Notebook.prototype.restore_checkpoint_error = function (xhr, status, error_msg) {
2372 $([IPython.events]).trigger('checkpoint_restore_failed.Notebook');
2489 $([Events]).trigger('checkpoint_restore_failed.Notebook');
2373 2490 };
2374 2491
2375 2492 /**
@@ -2379,7 +2496,7 b' var IPython = (function (IPython) {'
2379 2496 * @param {String} checkpoint ID
2380 2497 */
2381 2498 Notebook.prototype.delete_checkpoint = function (checkpoint) {
2382 $([IPython.events]).trigger('notebook_restoring.Notebook', checkpoint);
2499 $([Events]).trigger('notebook_restoring.Notebook', checkpoint);
2383 2500 var url = utils.url_join_encode(
2384 2501 this.base_url,
2385 2502 'api/notebooks',
@@ -2404,7 +2521,7 b' var IPython = (function (IPython) {'
2404 2521 * @param {jqXHR} xhr jQuery Ajax object
2405 2522 */
2406 2523 Notebook.prototype.delete_checkpoint_success = function (data, status, xhr) {
2407 $([IPython.events]).trigger('checkpoint_deleted.Notebook', data);
2524 $([Events]).trigger('checkpoint_deleted.Notebook', data);
2408 2525 this.load_notebook(this.notebook_name, this.notebook_path);
2409 2526 };
2410 2527
@@ -2417,14 +2534,12 b' var IPython = (function (IPython) {'
2417 2534 * @param {String} error_msg HTTP error message
2418 2535 */
2419 2536 Notebook.prototype.delete_checkpoint_error = function (xhr, status, error_msg) {
2420 $([IPython.events]).trigger('checkpoint_delete_failed.Notebook');
2537 $([Events]).trigger('checkpoint_delete_failed.Notebook');
2421 2538 };
2422 2539
2423 2540
2541 // For backwards compatability.
2424 2542 IPython.Notebook = Notebook;
2425 2543
2426
2427 return IPython;
2428
2429 }(IPython));
2430
2544 return Notebook;
2545 });
@@ -446,6 +446,7 b' var IPython = (function (IPython) {'
446 446 return cont;
447 447 };
448 448
449 // TODO: RETURN IN THIS NAMESPACE!
449 450 IPython.TextCell = TextCell;
450 451 IPython.MarkdownCell = MarkdownCell;
451 452 IPython.RawCell = RawCell;
@@ -294,69 +294,6 b' class="notebook_app"'
294 294
295 295 {% block script %}
296 296
297 {{super()}}
298
299 <script src="{{ static_url("components/google-caja/html-css-sanitizer-minified.js") }}" charset="utf-8"></script>
300 <script src="{{ static_url("components/codemirror/lib/codemirror.js") }}" charset="utf-8"></script>
301 <script type="text/javascript">
302 CodeMirror.modeURL = "{{ static_url("components/codemirror/mode/%N/%N.js", include_version=False) }}";
303 </script>
304 <script src="{{ static_url("components/codemirror/addon/mode/loadmode.js") }}" charset="utf-8"></script>
305 <script src="{{ static_url("components/codemirror/addon/mode/multiplex.js") }}" charset="utf-8"></script>
306 <script src="{{ static_url("components/codemirror/addon/mode/overlay.js") }}" charset="utf-8"></script>
307 <script src="{{ static_url("components/codemirror/addon/edit/matchbrackets.js") }}" charset="utf-8"></script>
308 <script src="{{ static_url("components/codemirror/addon/edit/closebrackets.js") }}" charset="utf-8"></script>
309 <script src="{{ static_url("components/codemirror/addon/comment/comment.js") }}" charset="utf-8"></script>
310 <script src="{{ static_url("components/codemirror/mode/htmlmixed/htmlmixed.js") }}" charset="utf-8"></script>
311 <script src="{{ static_url("components/codemirror/mode/xml/xml.js") }}" charset="utf-8"></script>
312 <script src="{{ static_url("components/codemirror/mode/javascript/javascript.js") }}" charset="utf-8"></script>
313 <script src="{{ static_url("components/codemirror/mode/css/css.js") }}" charset="utf-8"></script>
314 <script src="{{ static_url("components/codemirror/mode/rst/rst.js") }}" charset="utf-8"></script>
315 <script src="{{ static_url("components/codemirror/mode/markdown/markdown.js") }}" charset="utf-8"></script>
316 <script src="{{ static_url("components/codemirror/mode/python/python.js") }}" charset="utf-8"></script>
317 <script src="{{ static_url("notebook/js/codemirror-ipython.js") }}" charset="utf-8"></script>
318 <script src="{{ static_url("notebook/js/codemirror-ipythongfm.js") }}" charset="utf-8"></script>
319
320 <script src="{{ static_url("components/highlight.js/build/highlight.pack.js") }}" charset="utf-8"></script>
321
322 <script src="{{ static_url("dateformat/date.format.js") }}" charset="utf-8"></script>
323
324 <script src="{{ static_url("base/js/events.js") }}" type="text/javascript" charset="utf-8"></script>
325 <script src="{{ static_url("base/js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
326 <script src="{{ static_url("base/js/keyboard.js") }}" type="text/javascript" charset="utf-8"></script>
327 <script src="{{ static_url("base/js/security.js") }}" type="text/javascript" charset="utf-8"></script>
328 <script src="{{ static_url("base/js/dialog.js") }}" type="text/javascript" charset="utf-8"></script>
329 <script src="{{ static_url("services/kernels/js/kernel.js") }}" type="text/javascript" charset="utf-8"></script>
330 <script src="{{ static_url("services/kernels/js/comm.js") }}" type="text/javascript" charset="utf-8"></script>
331 <script src="{{ static_url("services/sessions/js/session.js") }}" type="text/javascript" charset="utf-8"></script>
332 <script src="{{ static_url("notebook/js/layoutmanager.js") }}" type="text/javascript" charset="utf-8"></script>
333 <script src="{{ static_url("notebook/js/mathjaxutils.js") }}" type="text/javascript" charset="utf-8"></script>
334 <script src="{{ static_url("notebook/js/outputarea.js") }}" type="text/javascript" charset="utf-8"></script>
335 <script src="{{ static_url("notebook/js/cell.js") }}" type="text/javascript" charset="utf-8"></script>
336 <script src="{{ static_url("notebook/js/celltoolbar.js") }}" type="text/javascript" charset="utf-8"></script>
337 <script src="{{ static_url("notebook/js/codecell.js") }}" type="text/javascript" charset="utf-8"></script>
338 <script src="{{ static_url("notebook/js/completer.js") }}" type="text/javascript" charset="utf-8"></script>
339 <script src="{{ static_url("notebook/js/textcell.js") }}" type="text/javascript" charset="utf-8"></script>
340 <script src="{{ static_url("notebook/js/savewidget.js") }}" type="text/javascript" charset="utf-8"></script>
341 <script src="{{ static_url("notebook/js/quickhelp.js") }}" type="text/javascript" charset="utf-8"></script>
342 <script src="{{ static_url("notebook/js/pager.js") }}" type="text/javascript" charset="utf-8"></script>
343 <script src="{{ static_url("notebook/js/menubar.js") }}" type="text/javascript" charset="utf-8"></script>
344 <script src="{{ static_url("notebook/js/toolbar.js") }}" type="text/javascript" charset="utf-8"></script>
345 <script src="{{ static_url("notebook/js/maintoolbar.js") }}" type="text/javascript" charset="utf-8"></script>
346 <script src="{{ static_url("notebook/js/notebook.js") }}" type="text/javascript" charset="utf-8"></script>
347 <script src="{{ static_url("notebook/js/keyboardmanager.js") }}" type="text/javascript" charset="utf-8"></script>
348 <script src="{{ static_url("notebook/js/notificationwidget.js") }}" type="text/javascript" charset="utf-8"></script>
349 <script src="{{ static_url("notebook/js/notificationarea.js") }}" type="text/javascript" charset="utf-8"></script>
350 <script src="{{ static_url("notebook/js/tooltip.js") }}" type="text/javascript" charset="utf-8"></script>
351 <script src="{{ static_url("notebook/js/tour.js") }}" type="text/javascript" charset="utf-8"></script>
352
353 <script src="{{ static_url("notebook/js/config.js") }}" type="text/javascript" charset="utf-8"></script>
354 <script src="{{ static_url("notebook/js/main.js") }}" type="text/javascript" charset="utf-8"></script>
355
356 <script src="{{ static_url("notebook/js/contexthint.js") }}" charset="utf-8"></script>
357
358 <script src="{{ static_url("notebook/js/celltoolbarpresets/default.js") }}" type="text/javascript" charset="utf-8"></script>
359 <script src="{{ static_url("notebook/js/celltoolbarpresets/rawcell.js") }}" type="text/javascript" charset="utf-8"></script>
360 <script src="{{ static_url("notebook/js/celltoolbarpresets/slideshow.js") }}" type="text/javascript" charset="utf-8"></script>
297 <script src="{{ static_url("notebook/js/main.js") }}" charset="utf-8"></script>
361 298
362 299 {% endblock %}
General Comments 0
You need to be logged in to leave comments. Login now