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