##// END OF EJS Templates
MWE,...
Jonathan Frederic -
Show More
@@ -4,7 +4,7 b''
4 4 define([
5 5 'base/js/namespace',
6 6 'base/js/utils',
7 'components/jquery/jquery.min',
7 'jquery',
8 8 ], function(IPython, utils, $){
9 9 "use strict";
10 10
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 ], function(IPython, $) {
8 8 "use strict";
9 9
@@ -146,7 +146,7 b' define(['
146 146 modal.on('shown.bs.modal', function(){ editor.refresh(); });
147 147 };
148 148
149 Dialog = {
149 var Dialog = {
150 150 modal : modal,
151 151 edit_metadata : edit_metadata,
152 152 };
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'base/js/utils',
8 8 ], function(IPython, $, utils) {
9 9 "use strict";
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'components/jquery-ui/ui/minified/jquery-ui.min',
8 8 'components/bootstrap/js/bootstrap.min',
9 9 'auth/js/loginwidget'
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'components/google-caja/html-css-sanitizer-minified',
8 8 ], function(IPython, $) {
9 9 "use strict";
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 ], function(IPython, $){
8 8 "use strict";
9 9
@@ -11,7 +11,11 b''
11 11 * The date defaults to the current date/time.
12 12 * The mask defaults to dateFormat.masks.default.
13 13 */
14 // Copyright (c) IPython Development Team.
15 // Distributed under the terms of the Modified BSD License.
14 16
17 // Require.js define call added by IPython team.
18 define([], function() {
15 19 var dateFormat = function () {
16 20 var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
17 21 timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
@@ -123,3 +127,6 b' dateFormat.i18n = {'
123 127 Date.prototype.format = function (mask, utc) {
124 128 return dateFormat(this, mask, utc);
125 129 };
130
131 return dateFormat;
132 }); No newline at end of file
@@ -3,35 +3,15 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
7 'components/codemirror/lib/codemirror.js',
6 'jquery',
8 7 'base/js/utils',
9
10 // Set codemirror version.
11 // CodeMirror.modeURL = '{{ static_url("components/codemirror/mode/%N/%N.js", include_version=False) }}';
12 'components/codemirror/addon/mode/loadmode.js',
13 'components/codemirror/addon/mode/multiplex.js',
14 'components/codemirror/addon/mode/overlay.js',
15 'components/codemirror/addon/edit/matchbrackets.js',
16 'components/codemirror/addon/edit/closebrackets.js',
17 'components/codemirror/addon/comment/comment.js',
18 'components/codemirror/mode/htmlmixed/htmlmixed.js',
19 'components/codemirror/mode/xml/xml.js',
20 'components/codemirror/mode/javascript/javascript.js',
21 'components/codemirror/mode/css/css.js',
22 'components/codemirror/mode/rst/rst.js',
23 'components/codemirror/mode/markdown/markdown.js',
24 'components/codemirror/mode/python/python.js',
25 'notebook/js/codemirror-ipython.js',
26 'notebook/js/codemirror-ipythongfm.js',
27 ], function(IPython, $, CodeMirror, utils) {
8 ], function(IPython, $, utils) {
28 9 "use strict";
29 10
30 11 // monkey patch CM to be able to syntax highlight cell magics
31 12 // bug reported upstream,
32 13 // see https://github.com/marijnh/CodeMirror2/issues/670
33 14 if(CodeMirror.getMode(1,'text/plain').indent === undefined ){
34 console.log('patching CM for undefined indent');
35 15 CodeMirror.modes.null = function() {
36 16 return {token: function(stream) {stream.skipToEnd();},indent : function(){return 0;}};
37 17 };
@@ -58,8 +38,9 b' define(['
58 38 * @param {object|undefined} [options]
59 39 * @param [options.cm_config] {object} config to pass to CodeMirror, will extend default parameters
60 40 */
61 var Cell = function (keyboard_manager) {
41 var Cell = function (options, keyboard_manager, events) {
62 42 this.keyboard_manager = keyboard_manager;
43 this.events = events;
63 44 options = this.mergeopt(Cell, options);
64 45 // superclass default overwrite our default
65 46
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'notebook/js/textcell',
8 8 ], function(IPython, $, TextCell) {
9 9 "use strict";
@@ -220,7 +220,9 b' define(['
220 220 CellToolbar.rebuild_all();
221 221 }
222 222
223 if (this.events) {
223 224 this.events.trigger('preset_activated.CellToolbar', {name: preset_name});
225 }
224 226 };
225 227
226 228
@@ -3,14 +3,15 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'base/js/utils',
8 8 'notebook/js/tooltip',
9 9 'base/js/keyboard',
10 10 'notebook/js/cell',
11 11 'notebook/js/outputarea',
12 12 'notebook/js/completer',
13 ], function(IPython, $, utils, Tooltip, keyboard, Cell, OutputArea, Completer) {
13 'notebook/js/celltoolbar',
14 ], function(IPython, $, utils, Tooltip, keyboard, Cell, OutputArea, Completer, CellToolbar) {
14 15 "use strict";
15 16
16 17 /* local util for codemirror */
@@ -52,8 +53,9 b' define(['
52 53 * @param {object|undefined} [options]
53 54 * @param [options.cm_config] {object} config to pass to CodeMirror
54 55 */
55 var CodeCell = function (kernel, options, events, config, keyboard_manager) {
56 var CodeCell = function (kernel, options, events, config, keyboard_manager, notebook) {
56 57 this.kernel = kernel || null;
58 this.notebook = notebook;
57 59 this.collapsed = false;
58 60 this.tooltip = new Tooltip(events);
59 61 this.events = events;
@@ -74,7 +76,7 b' define(['
74 76
75 77 options = this.mergeopt(CodeCell, options, {cm_config:cm_overwrite_options});
76 78
77 Cell.apply(this,[options, keyboard_manager]);
79 Cell.apply(this,[options, keyboard_manager, events]);
78 80
79 81 // Attributes we want to override in this subclass.
80 82 this.cell_type = "code";
@@ -123,7 +125,7 b' define(['
123 125 var input = $('<div></div>').addClass('input');
124 126 var prompt = $('<div/>').addClass('prompt input_prompt');
125 127 var inner_cell = $('<div/>').addClass('inner_cell');
126 this.celltoolbar = new CellToolbar(this);
128 this.celltoolbar = new CellToolbar(this, this.events, this.notebook);
127 129 inner_cell.append(this.celltoolbar.element);
128 130 var input_area = $('<div/>').addClass('input_area');
129 131 this.code_mirror = CodeMirror(input_area.get(0), this.cm_config);
@@ -3,9 +3,10 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'base/js/utils',
8 8 'base/js/keyboard',
9 'notebook/js/contexthint',
9 10 ], function(IPython, $, utils, keyboard) {
10 11 "use strict";
11 12
@@ -1,28 +1,9 b''
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2012 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 // Notebook
10 //============================================================================
11
12 /**
13 * @module IPython
14 * @namespace IPython
15 **/
16
17 var IPython = (function (IPython) {
4 define([], function() {
18 5 "use strict";
19 /**
20 * A place where some stuff can be confugured.
21 *
22 * @class config
23 * @static
24 *
25 **/
6
26 7 var default_config = {
27 8 /**
28 9 * Dictionary of object to autodetect highlight mode for code cell.
@@ -50,13 +31,13 b' var IPython = (function (IPython) {'
50 31 * cell_magic_highlight['javascript'] = {'reg':[/^var/]}
51 32 */
52 33 cell_magic_highlight : {
53 'magic_javascript' :{'reg':[/^%%javascript/]}
54 ,'magic_perl' :{'reg':[/^%%perl/]}
55 ,'magic_ruby' :{'reg':[/^%%ruby/]}
56 ,'magic_python' :{'reg':[/^%%python3?/]}
57 ,'magic_shell' :{'reg':[/^%%bash/]}
58 ,'magic_r' :{'reg':[/^%%R/]}
59 ,'magic_text/x-cython' :{'reg':[/^%%cython/]}
34 'magic_javascript' :{'reg':[/^%%javascript/]},
35 'magic_perl' :{'reg':[/^%%perl/]},
36 'magic_ruby' :{'reg':[/^%%ruby/]},
37 'magic_python' :{'reg':[/^%%python3?/]},
38 'magic_shell' :{'reg':[/^%%bash/]},
39 'magic_r' :{'reg':[/^%%R/]},
40 'magic_text/x-cython' :{'reg':[/^%%cython/]},
60 41 },
61 42
62 43 /**
@@ -66,14 +47,9 b' var IPython = (function (IPython) {'
66 47 raw_cell_highlight : {
67 48 'diff' :{'reg':[/^diff/]}
68 49 },
69
70 50 };
71 51
72 // use the same method to merge user configuration
73 IPython.config = {};
74 $.extend(IPython.config, default_config);
75
76 return IPython;
77
78 }(IPython));
79
52 return {
53 'default_config': default_config,
54 };
55 });
@@ -1,12 +1,15 b''
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
3
1 4 // highly adapted for codemiror jshint
2 (function () {
5 define([], function() {
3 6 "use strict";
4 7
5 function forEach(arr, f) {
8 var forEach = function(arr, f) {
6 9 for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
7 }
10 };
8 11
9 function arrayContains(arr, item) {
12 var arrayContains = function(arr, item) {
10 13 if (!Array.prototype.indexOf) {
11 14 var i = arr.length;
12 15 while (i--) {
@@ -17,7 +20,7 b''
17 20 return false;
18 21 }
19 22 return arr.indexOf(item) != -1;
20 }
23 };
21 24
22 25 CodeMirror.contextHint = function (editor) {
23 26 // Find the token at the cursor
@@ -26,7 +29,7 b''
26 29 tprop = token;
27 30 // If it's not a 'word-style' token, ignore the token.
28 31 // If it is a property, find out what it is a property of.
29 var list = new Array();
32 var list = [];
30 33 var clist = getCompletions(token, editor);
31 34 for (var i = 0; i < clist.length; i++) {
32 35 list.push({
@@ -40,10 +43,10 b''
40 43 line: cur.line,
41 44 ch: token.end
42 45 }
43 })
46 });
44 47 }
45 48 return list;
46 }
49 };
47 50
48 51 // find all 'words' of current cell
49 52 var getAllTokens = function (editor) {
@@ -71,7 +74,7 b''
71 74 // of interest. Add it to the list of possible completions.
72 75 // we could skip token of ClassName 'comment'
73 76 // or 'number' and 'operator'
74 if (tk.className != null) {
77 if (tk.className !== null) {
75 78 maybeAdd(tk.string);
76 79 }
77 80 // jump to char after end of current token
@@ -79,16 +82,17 b''
79 82 }
80 83 }
81 84 return found;
82 }
83
85 };
84 86
85 function getCompletions(token, editor) {
87 var getCompletions = function(token, editor) {
86 88 var candidates = getAllTokens(editor);
87 89 // filter all token that have a common start (but nox exactly) the lenght of the current token
88 90 var lambda = function (x) {
89 return (x.indexOf(token.string) == 0 && x != token.string)
91 return (x.indexOf(token.string) === 0 && x != token.string);
90 92 };
91 93 var filterd = candidates.filter(lambda);
92 94 return filterd;
93 }
94 })();
95 };
96
97 return CodeMirror.contextHint;
98 });
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'base/js/utils',
8 8 'base/js/keyboard',
9 9 ], function(IPython, $, utils, keyboard) {
@@ -15,24 +15,24 b' define(['
15 15 // Main keyboard manager for the notebook
16 16 var keycodes = keyboard.keycodes;
17 17
18 var KeyboardManager = function (pager) {
18 var KeyboardManager = function (pager, events) {
19 19 this.mode = 'command';
20 20 this.enabled = true;
21 21 this.pager = pager;
22 22 this.quick_help = undefined;
23 23 this.notebook = undefined;
24 24 this.bind_events();
25 this.command_shortcuts = new keyboard.ShortcutManager();
25 this.command_shortcuts = new keyboard.ShortcutManager(undefined, events);
26 26 this.command_shortcuts.add_shortcuts(this.get_default_common_shortcuts());
27 27 this.command_shortcuts.add_shortcuts(this.get_default_command_shortcuts());
28 this.edit_shortcuts = new keyboard.ShortcutManager();
28 this.edit_shortcuts = new keyboard.ShortcutManager(undefined, events);
29 29 this.edit_shortcuts.add_shortcuts(this.get_default_common_shortcuts());
30 30 this.edit_shortcuts.add_shortcuts(this.get_default_edit_shortcuts());
31 31 };
32 32
33 33 KeyboardManager.prototype.get_default_common_shortcuts = function() {
34 34 var that = this;
35 shortcuts = {
35 var shortcuts = {
36 36 'shift' : {
37 37 help : '',
38 38 help_index : '',
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 ], function(IPython, $) {
8 8 "use strict";
9 9
@@ -4,7 +4,7 b''
4 4 var ipython = ipython || {};
5 5 require([
6 6 'base/js/namespace',
7 'components/jquery/jquery.min',
7 'jquery',
8 8 'notebook/js/notebook',
9 9 'base/js/utils',
10 10 'base/js/page',
@@ -18,6 +18,7 b' require(['
18 18 'notebook/js/notificationarea',
19 19 'notebook/js/savewidget',
20 20 'notebook/js/keyboardmanager',
21 'notebook/js/config',
21 22 ], function(
22 23 IPython,
23 24 $,
@@ -33,32 +34,33 b' require(['
33 34 MenuBar,
34 35 NotificationArea,
35 36 SaveWidget,
36 KeyboardManager
37 KeyboardManager,
38 config
37 39 ) {
38 40 "use strict";
39 41
40 42 $('#ipython-main-app').addClass('border-box-sizing');
41 43 $('div#notebook_panel').addClass('border-box-sizing');
42 44
43 var opts = {
45 var options = {
44 46 base_url : utils.get_body_data("baseUrl"),
45 47 notebook_path : utils.get_body_data("notebookPath"),
46 48 notebook_name : utils.get_body_data('notebookName')
47 49 };
48 50
49 page = new Page();
50 layout_manager = new LayoutManager();
51 events = $([new Events()]);
52 pager = new Pager('div#pager', 'div#pager_splitter', layout_manager, events);
53 keyboard_manager = new KeyboardManager(pager);
54 save_widget = new SaveWidget('span#save_widget', events, keyboard);
55 notebook = new Notebook('div#notebook', opts, events, keyboard_manager, save_widget, keyboard);
56 login_widget = new LoginWidget('span#login_widget', opts);
57 toolbar = new MainToolBar('#maintoolbar-container', notebook, events);
58 quick_help = new QuickHelp(undefined, keyboard_manager, events);
59 menubar = new MenuBar('#menubar', opts, notebook, layout_manager, events, save_widget, quick_help);
60
61 notification_area = new NotificationArea('#notification_area', events, save_widget, notebook);
51 var user_config = $.extend({}, config.default_config);
52 var page = new Page();
53 var layout_manager = new LayoutManager();
54 var events = $([new Events()]);
55 var pager = new Pager('div#pager', 'div#pager_splitter', layout_manager, events);
56 var keyboard_manager = new KeyboardManager(pager, events);
57 var save_widget = new SaveWidget('span#save_widget', events);
58 var notebook = new Notebook('div#notebook', options, events, keyboard_manager, save_widget, user_config);
59 var login_widget = new LoginWidget('span#login_widget', options);
60 var toolbar = new MainToolBar('#maintoolbar-container', layout_manager, notebook, events);
61 var quick_help = new QuickHelp(undefined, keyboard_manager, events);
62 var menubar = new MenuBar('#menubar', options, notebook, layout_manager, events, save_widget, quick_help);
63 var notification_area = new NotificationArea('#notification_area', events, save_widget, notebook);
62 64 notification_area.init_notification_widgets();
63 65
64 66 layout_manager.do_resize();
@@ -91,7 +93,7 b' require(['
91 93
92 94 events.on('notebook_loaded.Notebook', first_load);
93 95 events.trigger('app_initialized.NotebookApp');
94 notebook.load_notebook(opts.notebook_name, opts.notebook_path);
96 notebook.load_notebook(options.notebook_name, options.notebook_path);
95 97
96 98 ipython.page = page;
97 99 ipython.layout_manager = layout_manager;
@@ -105,5 +107,5 b' require(['
105 107 ipython.events = events;
106 108 ipython.keyboard_manager = keyboard_manager;
107 109 ipython.save_widget = save_widget;
108 ipython.keyboard = keyboard;
110 ipython.config = user_config;
109 111 });
@@ -3,14 +3,14 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'notebook/js/toolbar',
8 8 'notebook/js/celltoolbar',
9 9 ], function(IPython, $, Toolbar, CellToolbar) {
10 10 "use strict";
11 11
12 12 var MainToolBar = function (selector, layout_manager, notebook, events) {
13 ToolBar.apply(this, arguments);
13 Toolbar.apply(this, arguments);
14 14 this.events = events;
15 15 this.notebook = notebook;
16 16 this.construct();
@@ -19,7 +19,7 b' define(['
19 19 this.bind_events();
20 20 };
21 21
22 MainToolBar.prototype = new ToolBar();
22 MainToolBar.prototype = new Toolbar();
23 23
24 24 MainToolBar.prototype.construct = function () {
25 25 this.add_buttons_group([
@@ -2,7 +2,7 b''
2 2 // Distributed under the terms of the Modified BSD License.
3 3
4 4 define([
5 'components/jquery/jquery.min',
5 'jquery',
6 6 'base/js/utils',
7 7 'base/js/dialog',
8 8 ], function($, utils, Dialog) {
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'base/js/utils',
8 8 'notebook/js/tour',
9 9 'components/bootstrap-tour/build/js/bootstrap-tour.min',
@@ -49,12 +49,13 b' define(['
49 49 };
50 50
51 51 MenuBar.prototype.style = function () {
52 var that = this;
52 53 this.element.addClass('border-box-sizing');
53 54 this.element.find("li").click(function (event, ui) {
54 55 // The selected cell loses focus when the menu is entered, so we
55 56 // re-select it upon selection.
56 var i = this.notebook.get_selected_index();
57 this.notebook.select(i);
57 var i = that.notebook.get_selected_index();
58 that.notebook.select(i);
58 59 }
59 60 );
60 61 };
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'base/js/utils',
8 8 'base/js/dialog',
9 9 'notebook/js/textcell',
@@ -38,8 +38,8 b' define(['
38 38 * @param {Object} [options] A config object
39 39 * @param {Object} [events] An events object
40 40 */
41 var Notebook = function (selector, options, events, keyboard_manager, save_widget) {
42 this.config = undefined; // TODO
41 var Notebook = function (selector, options, events, keyboard_manager, save_widget, config) {
42 this.config = config;
43 43 this.events = events;
44 44 this.keyboard_manager = keyboard_manager;
45 45 keyboard_manager.notebook = this;
@@ -807,14 +807,14 b' define(['
807 807
808 808 if (ncells === 0 || this.is_valid_cell_index(index) || index === ncells) {
809 809 if (type === 'code') {
810 cell = new CodeCell(this.kernel, undefined, this.events, this.config, this.keyboard_manager);
810 cell = new CodeCell(this.kernel, this.options, this.events, this.config, this.keyboard_manager, this);
811 811 cell.set_input_prompt();
812 812 } else if (type === 'markdown') {
813 cell = new Cells.MarkdownCell();
813 cell = new Cells.MarkdownCell(this.options, this.events, this.config, this.keyboard_manager, this);
814 814 } else if (type === 'raw') {
815 cell = new Cells.RawCell();
815 cell = new Cells.RawCell(this.options, this.events, this.config, this.keyboard_manager, this);
816 816 } else if (type === 'heading') {
817 cell = new Cells.HeadingCell();
817 cell = new Cells.HeadingCell(this.options, this.events, this.config, this.keyboard_manager, this);
818 818 }
819 819
820 820 if(this._insert_element_at_index(cell.element,index)) {
@@ -3,10 +3,11 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'base/js/utils',
8 8 'base/js/dialog',
9 ], function(IPython, $, utils, Dialog) {
9 'notebook/js/notificationwidget',
10 ], function(IPython, $, utils, Dialog, NotificationWidget) {
10 11 "use strict";
11 12
12 13 var NotificationArea = function (selector, events, save_widget, notebook) {
@@ -61,7 +62,7 b' define(['
61 62 }
62 63 var div = $('<div/>').attr('id','notification_'+name);
63 64 $(this.selector).append(div);
64 this.widget_dict[name] = new IPython.NotificationWidget('#notification_'+name);
65 this.widget_dict[name] = new NotificationWidget('#notification_'+name);
65 66 return this.widget_dict[name];
66 67 };
67 68
@@ -228,5 +229,5 b' define(['
228 229
229 230 IPython.NotificationArea = NotificationArea;
230 231
231 return IPython;
232 return NotificationArea;
232 233 });
@@ -1,18 +1,11 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 //----------------------------------------------------------------------------
7
8 //============================================================================
9 // Notification widget
10 //============================================================================
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
11 3
12 var IPython = (function (IPython) {
4 define([
5 'base/js/namespace',
6 'jquery',
7 ], function(IPython, $) {
13 8 "use strict";
14 var utils = IPython.utils;
15
16 9
17 10 var NotificationWidget = function (selector) {
18 11 this.selector = selector;
@@ -31,7 +24,6 b' var IPython = (function (IPython) {'
31 24
32 25 };
33 26
34
35 27 NotificationWidget.prototype.style = function () {
36 28 this.element.addClass('notification_widget pull-right');
37 29 this.element.addClass('border-box-sizing');
@@ -44,7 +36,7 b' var IPython = (function (IPython) {'
44 36 // click_callback : function called if user click on notification
45 37 // could return false to prevent the notification to be dismissed
46 38 NotificationWidget.prototype.set_message = function (msg, timeout, click_callback, opts) {
47 var opts = opts || {};
39 opts = opts || {};
48 40 var callback = click_callback || function() {return false;};
49 41 var that = this;
50 42 this.inner.attr('class', opts.icon);
@@ -62,7 +54,7 b' var IPython = (function (IPython) {'
62 54 }, timeout);
63 55 } else {
64 56 this.element.click(function() {
65 if( callback() != false ) {
57 if( callback() !== false ) {
66 58 that.element.fadeOut(100, function () {that.inner.text('');});
67 59 that.element.unbind('click');
68 60 }
@@ -74,15 +66,12 b' var IPython = (function (IPython) {'
74 66 }
75 67 };
76 68
77
78 69 NotificationWidget.prototype.get_message = function () {
79 70 return this.inner.html();
80 71 };
81 72
82
73 // For backwards compatability.
83 74 IPython.NotificationWidget = NotificationWidget;
84 75
85 return IPython;
86
87 }(IPython));
88
76 return NotificationWidget;
77 });
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'base/js/utils',
8 8 'base/js/security',
9 9 'base/js/keyboard',
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'base/js/utils',
8 8 ], function(IPython, $, utils) {
9 9 "use strict";
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'base/js/utils',
8 8 'base/js/dialog',
9 9 ], function(IPython, $, utils, Dialog) {
@@ -3,10 +3,11 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'base/js/utils',
8 8 'base/js/dialog',
9 9 'base/js/keyboard',
10 'dateformat/date.format',
10 11 ], function(IPython, $, utils, Dialog, keyboard) {
11 12 "use strict";
12 13
@@ -3,10 +3,12 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'notebook/js/cell',
8 8 'base/js/security',
9 ], function(IPython, $, Cell, Security) {
9 'notebook/js/mathjaxutils',
10 'notebook/js/celltoolbar',
11 ], function(IPython, $, Cell, Security, mathjaxutils, CellToolbar) {
10 12 "use strict";
11 13
12 14 /**
@@ -20,12 +22,14 b' define(['
20 22 * @param [options.cm_config] {object} config to pass to CodeMirror, will extend/overwrite default config
21 23 * @param [options.placeholder] {string} default string to use when souce in empty for rendering (only use in some TextCell subclass)
22 24 */
23 var TextCell = function (options, events, config, mathjaxutils) {
24 // TODO: Config is IPython.config
25 var TextCell = function (options, events, config, keyboard_manager, notebook) {
25 26 // in all TextCell/Cell subclasses
26 27 // do not assign most of members here, just pass it down
27 28 // in the options dict potentially overwriting what you wish.
28 29 // they will be assigned in the base class.
30 this.notebook = notebook;
31 this.events = events;
32 this.config = config;
29 33
30 34 // we cannot put this as a class key as it has handle to "this".
31 35 var cm_overwrite_options = {
@@ -35,9 +39,9 b' define(['
35 39 options = this.mergeopt(TextCell,options,{cm_config:cm_overwrite_options});
36 40
37 41 this.cell_type = this.cell_type || 'text';
38 this.mathjaxutils = mathjaxutils;
42 mathjaxutils = mathjaxutils;
39 43
40 Cell.apply(this, [options], events);
44 Cell.apply(this, [options, keyboard_manager, events]);
41 45
42 46 this.rendered = false;
43 47 };
@@ -67,7 +71,7 b' define(['
67 71 var prompt = $('<div/>').addClass('prompt input_prompt');
68 72 cell.append(prompt);
69 73 var inner_cell = $('<div/>').addClass('inner_cell');
70 this.celltoolbar = new CellToolbar(this);
74 this.celltoolbar = new CellToolbar(this, this.events, this.notebook);
71 75 inner_cell.append(this.celltoolbar.element);
72 76 var input_area = $('<div/>').addClass('input_area');
73 77 this.code_mirror = new CodeMirror(input_area.get(0), this.cm_config);
@@ -158,7 +162,6 b' define(['
158 162 /**
159 163 * setter :{{#crossLink "TextCell/set_rendered"}}{{/crossLink}}
160 164 * @method get_rendered
161 * @return {html} html of rendered element
162 165 * */
163 166 TextCell.prototype.get_rendered = function() {
164 167 return this.element.find('div.text_cell_render').html();
@@ -213,11 +216,11 b' define(['
213 216 * @constructor MarkdownCell
214 217 * @extends IPython.HTMLCell
215 218 */
216 var MarkdownCell = function (options) {
219 var MarkdownCell = function (options, events, config, keyboard_manager) {
217 220 options = this.mergeopt(MarkdownCell, options);
218 221
219 222 this.cell_type = 'markdown';
220 TextCell.apply(this, [options]);
223 TextCell.apply(this, [options, events, config, keyboard_manager]);
221 224 };
222 225
223 226 MarkdownCell.options_default = {
@@ -238,11 +241,11 b' define(['
238 241 var text = this.get_text();
239 242 var math = null;
240 243 if (text === "") { text = this.placeholder; }
241 var text_and_math = this.mathjaxutils.remove_math(text);
244 var text_and_math = mathjaxutils.remove_math(text);
242 245 text = text_and_math[0];
243 246 math = text_and_math[1];
244 247 var html = marked.parser(marked.lexer(text));
245 html = this.mathjaxutils.replace_math(html, math);
248 html = mathjaxutils.replace_math(html, math);
246 249 html = Security.sanitize_html(html);
247 250 html = $($.parseHTML(html));
248 251 // links in markdown cells should open in new tabs
@@ -263,10 +266,10 b' define(['
263 266 * @constructor RawCell
264 267 * @extends TextCell
265 268 */
266 var RawCell = function (options) {
269 var RawCell = function (options, events, config, keyboard_manager) {
267 270
268 271 options = this.mergeopt(RawCell,options);
269 TextCell.apply(this, [options]);
272 TextCell.apply(this, [options, events, config, keyboard_manager]);
270 273 this.cell_type = 'raw';
271 274 // RawCell should always hide its rendered div
272 275 this.element.find('div.text_cell_render').hide();
@@ -297,7 +300,7 b' define(['
297 300 * @method auto_highlight
298 301 */
299 302 RawCell.prototype.auto_highlight = function () {
300 this._auto_highlight(config.raw_cell_highlight);
303 this._auto_highlight(this.config.raw_cell_highlight);
301 304 };
302 305
303 306 /** @method render **/
@@ -322,12 +325,12 b' define(['
322 325 * @constructor HeadingCell
323 326 * @extends TextCell
324 327 */
325 var HeadingCell = function (options) {
328 var HeadingCell = function (options, events, config, keyboard_manager) {
326 329 options = this.mergeopt(HeadingCell, options);
327 330
328 331 this.level = 1;
329 332 this.cell_type = 'heading';
330 TextCell.apply(this, [options]);
333 TextCell.apply(this, [options, events, config, keyboard_manager]);
331 334
332 335 /**
333 336 * heading level of the cell, use getter and setter to access
@@ -409,11 +412,11 b' define(['
409 412 text = text.replace(/\n/g, ' ');
410 413 if (text === "") { text = this.placeholder; }
411 414 text = new Array(this.level + 1).join("#") + " " + text;
412 var text_and_math = this.mathjaxutils.remove_math(text);
415 var text_and_math = mathjaxutils.remove_math(text);
413 416 text = text_and_math[0];
414 417 math = text_and_math[1];
415 418 var html = marked.parser(marked.lexer(text));
416 html = this.mathjaxutils.replace_math(html, math);
419 html = mathjaxutils.replace_math(html, math);
417 420 html = Security.sanitize_html(html);
418 421 var h = $($.parseHTML(html));
419 422 // add id and linkback anchor
@@ -439,7 +442,7 b' define(['
439 442 IPython.RawCell = RawCell;
440 443 IPython.HeadingCell = HeadingCell;
441 444
442 Cells = {
445 var Cells = {
443 446 'TextCell': TextCell,
444 447 'MarkdownCell': MarkdownCell,
445 448 'RawCell': RawCell,
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 ], function(IPython, $) {
8 8 "use strict";
9 9
@@ -97,5 +97,5 b' define(['
97 97 // Backwards compatability.
98 98 IPython.ToolBar = ToolBar;
99 99
100 return Toolbar;
100 return ToolBar;
101 101 });
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'base/js/utils',
8 8 ], function(IPython, $, utils) {
9 9 "use strict";
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 ], function(IPython, $) {
8 8 "use strict";
9 9
@@ -129,8 +129,8 b' define(['
129 129 // TODO: remove the onPause/onResume logic once pi's patch has been
130 130 // merged upstream to make this work via data-resume-class and
131 131 // data-resume-text attributes.
132 onPause: toggle_pause_play,
133 onResume: toggle_pause_play,
132 onPause: this.toggle_pause_play,
133 onResume: this.toggle_pause_play,
134 134 steps: this.tour_steps,
135 135 template: tour_style,
136 136 orphan: true
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'base/js/utils',
8 8 ], function(IPython, $, utils) {
9 9 "use strict";
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'base/js/utils',
8 8 'services/kernels/js/comm',
9 9 'widgets/js/init',
@@ -15,8 +15,8 b' define(['
15 15 * A Kernel Class to communicate with the Python kernel
16 16 * @Class Kernel
17 17 */
18 var Kernel = function (kernel_service_url, events) {
19 this.events = events;
18 var Kernel = function (kernel_service_url, notebook) {
19 this.events = notebook.events;
20 20 this.kernel_id = null;
21 21 this.shell_channel = null;
22 22 this.iopub_channel = null;
@@ -39,7 +39,7 b' define(['
39 39 this.bind_events();
40 40 this.init_iopub_handlers();
41 41 this.comm_manager = new comm.CommManager(this);
42 this.widget_manager = new WidgetManager(this.comm_manager);
42 this.widget_manager = new WidgetManager(this.comm_manager, notebook);
43 43
44 44 this.last_msg_id = null;
45 45 this.last_msg_callbacks = {};
@@ -605,8 +605,8 b' define(['
605 605 }
606 606 };
607 607
608
608 // Backwards compatability.
609 609 IPython.Kernel = Kernel;
610 610
611 return IPython;
611 return Kernel;
612 612 });
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'base/js/utils',
8 8 'services/kernels/js/kernel',
9 9 ], function(IPython, $, utils, Kernel) {
@@ -87,7 +87,7 b' define(['
87 87 Session.prototype._handle_start_success = function (data, status, xhr) {
88 88 this.id = data.id;
89 89 var kernel_service_url = utils.url_path_join(this.base_url, "api/kernels");
90 this.kernel = new Kernel(kernel_service_url, notebook.events);
90 this.kernel = new Kernel(kernel_service_url, this.notebook);
91 91 this.kernel._kernel_started(data.kernel);
92 92 };
93 93
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'base/js/utils',
8 8 ], function(IPython, $, utils) {
9 9 "use strict";
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'tree/js/notebooklist',
8 8 ], function(IPython, $, NotebookList) {
9 9 "use strict";
@@ -4,7 +4,7 b''
4 4 var ipython = ipython || {};
5 5 require([
6 6 'base/js/namespace',
7 'components/jquery/jquery.min',
7 'jquery',
8 8 'base/js/events',
9 9 'base/js/page',
10 10 'base/js/utils',
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'base/js/utils',
8 8 'base/js/dialog',
9 9 ], function(IPython, $, utils, Dialog) {
@@ -3,7 +3,7 b''
3 3
4 4 define([
5 5 'base/js/namespace',
6 'components/jquery/jquery.min',
6 'jquery',
7 7 'base/js/utils',
8 8 ], function(IPython, $, utils) {
9 9 "use strict";
@@ -9,12 +9,12 b' define(['
9 9 //--------------------------------------------------------------------
10 10 // WidgetManager class
11 11 //--------------------------------------------------------------------
12 var WidgetManager = function (comm_manager, keyboard_manager, notebook) {
12 var WidgetManager = function (comm_manager, notebook) {
13 13 // Public constructor
14 14 WidgetManager._managers.push(this);
15 15
16 16 // Attach a comm manager to the
17 this.keyboard_manager = keyboard_manager;
17 this.keyboard_manager = notebook.keyboard_manager;
18 18 this.notebook = notebook;
19 19 this.comm_manager = comm_manager;
20 20 this._models = {}; /* Dictionary of model ids and model instances */
@@ -294,6 +294,26 b' class="notebook_app"'
294 294
295 295 {% block script %}
296 296
297 <script src="{{ static_url("components/codemirror/lib/codemirror.js") }}" charset="utf-8"></script>
298 <script type="text/javascript">
299 CodeMirror.modeURL = "{{ static_url("components/codemirror/mode/%N/%N.js", include_version=False) }}";
300 </script>
301 <script src="{{ static_url("components/codemirror/addon/mode/loadmode.js") }}" charset="utf-8"></script>
302 <script src="{{ static_url("components/codemirror/addon/mode/multiplex.js") }}" charset="utf-8"></script>
303 <script src="{{ static_url("components/codemirror/addon/mode/overlay.js") }}" charset="utf-8"></script>
304 <script src="{{ static_url("components/codemirror/addon/edit/matchbrackets.js") }}" charset="utf-8"></script>
305 <script src="{{ static_url("components/codemirror/addon/edit/closebrackets.js") }}" charset="utf-8"></script>
306 <script src="{{ static_url("components/codemirror/addon/comment/comment.js") }}" charset="utf-8"></script>
307 <script src="{{ static_url("components/codemirror/mode/htmlmixed/htmlmixed.js") }}" charset="utf-8"></script>
308 <script src="{{ static_url("components/codemirror/mode/xml/xml.js") }}" charset="utf-8"></script>
309 <script src="{{ static_url("components/codemirror/mode/javascript/javascript.js") }}" charset="utf-8"></script>
310 <script src="{{ static_url("components/codemirror/mode/css/css.js") }}" charset="utf-8"></script>
311 <script src="{{ static_url("components/codemirror/mode/rst/rst.js") }}" charset="utf-8"></script>
312 <script src="{{ static_url("components/codemirror/mode/markdown/markdown.js") }}" charset="utf-8"></script>
313 <script src="{{ static_url("components/codemirror/mode/python/python.js") }}" charset="utf-8"></script>
314 <script src="{{ static_url("notebook/js/codemirror-ipython.js") }}" charset="utf-8"></script>
315 <script src="{{ static_url("notebook/js/codemirror-ipythongfm.js") }}" charset="utf-8"></script>
316
297 317 <script src="{{ static_url("notebook/js/main.js") }}" charset="utf-8"></script>
298 318
299 319 {% endblock %}
@@ -22,6 +22,7 b''
22 22 nbextensions : '{{ base_url }}nbextensions',
23 23 underscore : 'components/underscore/underscore-min',
24 24 backbone : 'components/backbone/backbone-min',
25 jquery: 'components/jquery/jquery.min',
25 26 },
26 27 shim: {
27 28 underscore: {
General Comments 0
You need to be logged in to leave comments. Login now