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,7 +11,11 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 | |||
|
17 | // Require.js define call added by IPython team. | |||
|
18 | define([], function() { | |||
15 | var dateFormat = function () { |
|
19 | var dateFormat = function () { | |
16 | var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g, |
|
20 | 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, |
|
21 | timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, | |
@@ -123,3 +127,6 b' dateFormat.i18n = {' | |||||
123 | Date.prototype.format = function (mask, utc) { |
|
127 | Date.prototype.format = function (mask, utc) { | |
124 | return dateFormat(this, mask, utc); |
|
128 | return dateFormat(this, mask, utc); | |
125 | }; |
|
129 | }; | |
|
130 | ||||
|
131 | return dateFormat; | |||
|
132 | }); No newline at end of file |
@@ -3,35 +3,15 b'' | |||||
3 |
|
3 | |||
4 | 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 | if (this.events) { | |||
223 | this.events.trigger('preset_activated.CellToolbar', {name: preset_name}); |
|
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,13 +31,13 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 |
|
|
34 | 'magic_javascript' :{'reg':[/^%%javascript/]}, | |
54 |
|
|
35 | 'magic_perl' :{'reg':[/^%%perl/]}, | |
55 |
|
|
36 | 'magic_ruby' :{'reg':[/^%%ruby/]}, | |
56 |
|
|
37 | 'magic_python' :{'reg':[/^%%python3?/]}, | |
57 |
|
|
38 | 'magic_shell' :{'reg':[/^%%bash/]}, | |
58 |
|
|
39 | 'magic_r' :{'reg':[/^%%R/]}, | |
59 |
|
|
40 | 'magic_text/x-cython' :{'reg':[/^%%cython/]}, | |
60 |
|
|
41 | }, | |
61 |
|
42 | |||
62 | /** |
|
43 | /** | |
@@ -66,14 +47,9 b' var IPython = (function (IPython) {' | |||||
66 | raw_cell_highlight : { |
|
47 | raw_cell_highlight : { | |
67 |
|
|
48 | 'diff' :{'reg':[/^diff/]} | |
68 |
|
|
49 | }, | |
69 |
|
||||
70 |
|
|
50 | }; | |
71 |
|
51 | |||
72 | // use the same method to merge user configuration |
|
52 | return { | |
73 | IPython.config = {}; |
|
53 | 'default_config': default_config, | |
74 | $.extend(IPython.config, default_config); |
|
54 | }; | |
75 |
|
55 | }); | ||
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 |
|
|
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 |
|
|
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 = |
|
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,10 +43,10 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) { | |
@@ -71,7 +74,7 b'' | |||||
71 |
|
|
74 | // of interest. Add it to the list of possible completions. | |
72 |
|
|
75 | // we could skip token of ClassName 'comment' | |
73 |
|
|
76 | // or 'number' and 'operator' | |
74 |
|
|
77 | if (tk.className !== null) { | |
75 |
|
|
78 | maybeAdd(tk.string); | |
76 |
|
|
79 | } | |
77 |
|
|
80 | // jump to char after end of current token | |
@@ -79,16 +82,17 b'' | |||||
79 |
|
|
82 | } | |
80 |
|
|
83 | } | |
81 |
|
|
84 | return found; | |
82 |
|
|
85 | }; | |
83 |
|
||||
84 |
|
86 | |||
85 |
|
|
87 | var getCompletions = function(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 |
|
|
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 |
Tool |
|
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 Tool |
|
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 = th |
|
57 | var i = that.notebook.get_selected_index(); | |
57 |
th |
|
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 = |
|
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, |
|
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 |
|
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 |
|
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 |
|
||||
8 | //============================================================================ |
|
|||
9 | // Notification widget |
|
|||
10 | //============================================================================ |
|
|||
11 |
|
3 | |||
12 | var IPython = (function (IPython) { |
|
4 | define([ | |
|
5 | 'base/js/namespace', | |||
|
6 | 'jquery', | |||
|
7 | ], 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 |
|
|
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 |
|
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,12 +22,14 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, |
|
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. | |
|
30 | this.notebook = notebook; | |||
|
31 | this.events = events; | |||
|
32 | this.config = config; | |||
29 |
|
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 = { | |
@@ -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 |
|
|
42 | mathjaxutils = mathjaxutils; | |
39 |
|
43 | |||
40 |
Cell.apply(this, [options |
|
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 = |
|
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 = |
|
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 = |
|
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 = |
|
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 Tool |
|
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, |
|
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 |
|
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 |
|
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, |
|
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