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,115 +11,122 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 | |
|
15 | var dateFormat = function () { | |
|
16 | var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g, | |
|
17 | timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, | |
|
18 | timezoneClip = /[^-+\dA-Z]/g, | |
|
19 | pad = function (val, len) { | |
|
20 | val = String(val); | |
|
21 | len = len || 2; | |
|
22 | while (val.length < len) val = "0" + val; | |
|
23 |
|
|
|
24 | }; | |
|
17 | // Require.js define call added by IPython team. | |
|
18 | define([], function() { | |
|
19 | var dateFormat = function () { | |
|
20 | var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g, | |
|
21 | timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, | |
|
22 | timezoneClip = /[^-+\dA-Z]/g, | |
|
23 | pad = function (val, len) { | |
|
24 | val = String(val); | |
|
25 | len = len || 2; | |
|
26 | while (val.length < len) val = "0" + val; | |
|
27 | return val; | |
|
28 | }; | |
|
25 | 29 | |
|
26 | // Regexes and supporting functions are cached through closure | |
|
27 | return function (date, mask, utc) { | |
|
28 | var dF = dateFormat; | |
|
30 | // Regexes and supporting functions are cached through closure | |
|
31 | return function (date, mask, utc) { | |
|
32 | var dF = dateFormat; | |
|
29 | 33 | |
|
30 | // You can't provide utc if you skip other args (use the "UTC:" mask prefix) | |
|
31 | if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) { | |
|
32 | mask = date; | |
|
33 | date = undefined; | |
|
34 | } | |
|
34 | // You can't provide utc if you skip other args (use the "UTC:" mask prefix) | |
|
35 | if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) { | |
|
36 | mask = date; | |
|
37 | date = undefined; | |
|
38 | } | |
|
35 | 39 | |
|
36 | // Passing date through Date applies Date.parse, if necessary | |
|
37 | date = date ? new Date(date) : new Date; | |
|
38 | if (isNaN(date)) throw SyntaxError("invalid date"); | |
|
40 | // Passing date through Date applies Date.parse, if necessary | |
|
41 | date = date ? new Date(date) : new Date; | |
|
42 | if (isNaN(date)) throw SyntaxError("invalid date"); | |
|
39 | 43 | |
|
40 | mask = String(dF.masks[mask] || mask || dF.masks["default"]); | |
|
44 | mask = String(dF.masks[mask] || mask || dF.masks["default"]); | |
|
41 | 45 | |
|
42 | // Allow setting the utc argument via the mask | |
|
43 | if (mask.slice(0, 4) == "UTC:") { | |
|
44 | mask = mask.slice(4); | |
|
45 | utc = true; | |
|
46 | } | |
|
46 | // Allow setting the utc argument via the mask | |
|
47 | if (mask.slice(0, 4) == "UTC:") { | |
|
48 | mask = mask.slice(4); | |
|
49 | utc = true; | |
|
50 | } | |
|
47 | 51 | |
|
48 | var _ = utc ? "getUTC" : "get", | |
|
49 | d = date[_ + "Date"](), | |
|
50 | D = date[_ + "Day"](), | |
|
51 | m = date[_ + "Month"](), | |
|
52 | y = date[_ + "FullYear"](), | |
|
53 | H = date[_ + "Hours"](), | |
|
54 | M = date[_ + "Minutes"](), | |
|
55 | s = date[_ + "Seconds"](), | |
|
56 | L = date[_ + "Milliseconds"](), | |
|
57 | o = utc ? 0 : date.getTimezoneOffset(), | |
|
58 | flags = { | |
|
59 | d: d, | |
|
60 | dd: pad(d), | |
|
61 | ddd: dF.i18n.dayNames[D], | |
|
62 | dddd: dF.i18n.dayNames[D + 7], | |
|
63 | m: m + 1, | |
|
64 | mm: pad(m + 1), | |
|
65 | mmm: dF.i18n.monthNames[m], | |
|
66 | mmmm: dF.i18n.monthNames[m + 12], | |
|
67 | yy: String(y).slice(2), | |
|
68 | yyyy: y, | |
|
69 | h: H % 12 || 12, | |
|
70 | hh: pad(H % 12 || 12), | |
|
71 | H: H, | |
|
72 | HH: pad(H), | |
|
73 | M: M, | |
|
74 | MM: pad(M), | |
|
75 | s: s, | |
|
76 | ss: pad(s), | |
|
77 | l: pad(L, 3), | |
|
78 | L: pad(L > 99 ? Math.round(L / 10) : L), | |
|
79 | t: H < 12 ? "a" : "p", | |
|
80 | tt: H < 12 ? "am" : "pm", | |
|
81 | T: H < 12 ? "A" : "P", | |
|
82 | TT: H < 12 ? "AM" : "PM", | |
|
83 | Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""), | |
|
84 | o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), | |
|
85 | S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10] | |
|
86 | }; | |
|
52 | var _ = utc ? "getUTC" : "get", | |
|
53 | d = date[_ + "Date"](), | |
|
54 | D = date[_ + "Day"](), | |
|
55 | m = date[_ + "Month"](), | |
|
56 | y = date[_ + "FullYear"](), | |
|
57 | H = date[_ + "Hours"](), | |
|
58 | M = date[_ + "Minutes"](), | |
|
59 | s = date[_ + "Seconds"](), | |
|
60 | L = date[_ + "Milliseconds"](), | |
|
61 | o = utc ? 0 : date.getTimezoneOffset(), | |
|
62 | flags = { | |
|
63 | d: d, | |
|
64 | dd: pad(d), | |
|
65 | ddd: dF.i18n.dayNames[D], | |
|
66 | dddd: dF.i18n.dayNames[D + 7], | |
|
67 | m: m + 1, | |
|
68 | mm: pad(m + 1), | |
|
69 | mmm: dF.i18n.monthNames[m], | |
|
70 | mmmm: dF.i18n.monthNames[m + 12], | |
|
71 | yy: String(y).slice(2), | |
|
72 | yyyy: y, | |
|
73 | h: H % 12 || 12, | |
|
74 | hh: pad(H % 12 || 12), | |
|
75 | H: H, | |
|
76 | HH: pad(H), | |
|
77 | M: M, | |
|
78 | MM: pad(M), | |
|
79 | s: s, | |
|
80 | ss: pad(s), | |
|
81 | l: pad(L, 3), | |
|
82 | L: pad(L > 99 ? Math.round(L / 10) : L), | |
|
83 | t: H < 12 ? "a" : "p", | |
|
84 | tt: H < 12 ? "am" : "pm", | |
|
85 | T: H < 12 ? "A" : "P", | |
|
86 | TT: H < 12 ? "AM" : "PM", | |
|
87 | Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""), | |
|
88 | o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), | |
|
89 | S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10] | |
|
90 | }; | |
|
87 | 91 | |
|
88 | return mask.replace(token, function ($0) { | |
|
89 | return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); | |
|
90 | }); | |
|
92 | return mask.replace(token, function ($0) { | |
|
93 | return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); | |
|
94 | }); | |
|
95 | }; | |
|
96 | }(); | |
|
97 | ||
|
98 | // Some common format strings | |
|
99 | dateFormat.masks = { | |
|
100 | "default": "ddd mmm dd yyyy HH:MM:ss", | |
|
101 | shortDate: "m/d/yy", | |
|
102 | mediumDate: "mmm d, yyyy", | |
|
103 | longDate: "mmmm d, yyyy", | |
|
104 | fullDate: "dddd, mmmm d, yyyy", | |
|
105 | shortTime: "h:MM TT", | |
|
106 | mediumTime: "h:MM:ss TT", | |
|
107 | longTime: "h:MM:ss TT Z", | |
|
108 | isoDate: "yyyy-mm-dd", | |
|
109 | isoTime: "HH:MM:ss", | |
|
110 | isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", | |
|
111 | isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" | |
|
91 | 112 | }; |
|
92 | }(); | |
|
93 | 113 | |
|
94 | // Some common format strings | |
|
95 |
dateFormat. |
|
|
96 | "default": "ddd mmm dd yyyy HH:MM:ss", | |
|
97 | shortDate: "m/d/yy", | |
|
98 | mediumDate: "mmm d, yyyy", | |
|
99 | longDate: "mmmm d, yyyy", | |
|
100 | fullDate: "dddd, mmmm d, yyyy", | |
|
101 | shortTime: "h:MM TT", | |
|
102 | mediumTime: "h:MM:ss TT", | |
|
103 | longTime: "h:MM:ss TT Z", | |
|
104 | isoDate: "yyyy-mm-dd", | |
|
105 | isoTime: "HH:MM:ss", | |
|
106 | isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", | |
|
107 | isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" | |
|
108 | }; | |
|
114 | // Internationalization strings | |
|
115 | dateFormat.i18n = { | |
|
116 | dayNames: [ | |
|
117 | "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", | |
|
118 | "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" | |
|
119 | ], | |
|
120 | monthNames: [ | |
|
121 | "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", | |
|
122 | "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" | |
|
123 | ] | |
|
124 | }; | |
|
109 | 125 | |
|
110 | // Internationalization strings | |
|
111 | dateFormat.i18n = { | |
|
112 | dayNames: [ | |
|
113 | "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", | |
|
114 | "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" | |
|
115 | ], | |
|
116 | monthNames: [ | |
|
117 | "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", | |
|
118 | "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" | |
|
119 | ] | |
|
120 | }; | |
|
126 | // For convenience... | |
|
127 | Date.prototype.format = function (mask, utc) { | |
|
128 | return dateFormat(this, mask, utc); | |
|
129 | }; | |
|
121 | 130 | |
|
122 | // For convenience... | |
|
123 | Date.prototype.format = function (mask, utc) { | |
|
124 | return dateFormat(this, mask, utc); | |
|
125 | }; | |
|
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 | this.events.trigger('preset_activated.CellToolbar', {name: preset_name}); | |
|
223 | if (this.events) { | |
|
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,30 +31,25 b' var IPython = (function (IPython) {' | |||
|
50 | 31 | * cell_magic_highlight['javascript'] = {'reg':[/^var/]} |
|
51 | 32 | */ |
|
52 | 33 | cell_magic_highlight : { |
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
|
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/]}, | |
|
41 | }, | |
|
61 | 42 | |
|
62 | 43 | /** |
|
63 | 44 | * same as `cell_magic_highlight` but for raw cells |
|
64 | 45 | * @attribute raw_cell_highlight |
|
65 | 46 | */ |
|
66 | 47 | raw_cell_highlight : { |
|
67 |
|
|
|
68 |
|
|
|
69 | ||
|
70 | }; | |
|
71 | ||
|
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 | ||
|
48 | 'diff' :{'reg':[/^diff/]} | |
|
49 | }, | |
|
50 | }; | |
|
51 | ||
|
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 |
|
|
|
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 |
|
|
|
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 = |
|
|
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,55 +43,56 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) { |
|
50 |
|
|
|
53 | var found = []; | |
|
51 | 54 | |
|
52 |
|
|
|
55 | // add to found if not already in it | |
|
53 | 56 | |
|
54 | 57 | |
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 | function maybeAdd(str) { | |
|
59 | if (!arrayContains(found, str)) found.push(str); | |
|
60 | } | |
|
58 | 61 | |
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
|
76 | } | |
|
77 | // jump to char after end of current token | |
|
78 | c = tk.end; | |
|
62 | // loop through all token on all lines | |
|
63 | var lineCount = editor.lineCount(); | |
|
64 | // loop on line | |
|
65 | for (var l = 0; l < lineCount; l++) { | |
|
66 | var line = editor.getLine(l); | |
|
67 | //loop on char | |
|
68 | for (var c = 1; c < line.length; c++) { | |
|
69 | var tk = editor.getTokenAt({ | |
|
70 | line: l, | |
|
71 | ch: c | |
|
72 | }); | |
|
73 | // if token has a class, it has geat chances of beeing | |
|
74 | // of interest. Add it to the list of possible completions. | |
|
75 | // we could skip token of ClassName 'comment' | |
|
76 | // or 'number' and 'operator' | |
|
77 | if (tk.className !== null) { | |
|
78 | maybeAdd(tk.string); | |
|
79 | 79 | } |
|
80 | // jump to char after end of current token | |
|
81 | c = tk.end; | |
|
80 | 82 | } |
|
81 | return found; | |
|
82 | 83 | } |
|
84 | return found; | |
|
85 | }; | |
|
83 | 86 | |
|
84 | ||
|
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 |
|
|
|
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 |
Tool |
|
|
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 Tool |
|
|
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 = th |
|
|
57 |
th |
|
|
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 = |
|
|
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, |
|
|
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 |
|
|
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 |
|
|
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 | //---------------------------------------------------------------------------- | |
|
1 | // Copyright (c) IPython Development Team. | |
|
2 | // Distributed under the terms of the Modified BSD License. | |
|
7 | 3 | |
|
8 | //============================================================================ | |
|
9 | // Notification widget | |
|
10 | //============================================================================ | |
|
11 | ||
|
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 |
|
|
|
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 |
|
|
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,13 +22,15 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, |
|
|
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. |
|
29 | ||
|
30 | this.notebook = notebook; | |
|
31 | this.events = events; | |
|
32 | this.config = config; | |
|
33 | ||
|
30 | 34 | // we cannot put this as a class key as it has handle to "this". |
|
31 | 35 | var cm_overwrite_options = { |
|
32 | 36 | onKeyEvent: $.proxy(this.handle_keyevent,this) |
@@ -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 |
|
|
|
42 | mathjaxutils = mathjaxutils; | |
|
39 | 43 | |
|
40 |
Cell.apply(this, [options |
|
|
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 = |
|
|
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 = |
|
|
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 = |
|
|
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 = |
|
|
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 Tool |
|
|
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, |
|
|
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 |
|
|
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 |
|
|
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, |
|
|
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 %} |
General Comments 0
You need to be logged in to leave comments.
Login now