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