##// END OF EJS Templates
Finished moving code into final(?) resting modules
Jonathan Frederic -
Show More
@@ -1,7 +1,7 b''
1 // Copyright (c) IPython Development Team.
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
2 // Distributed under the terms of the Modified BSD License.
3 var ipython = ipython || {};
4
3
4 var ipython = ipython || {};
5 require(['base/js/page'], function(Page) {
5 require(['base/js/page'], function(Page) {
6 ipython.page = new Page();
6 ipython.page = new Page();
7 $('#ipython-main-app').addClass('border-box-sizing');
7 $('#ipython-main-app').addClass('border-box-sizing');
@@ -17,6 +17,35 b''
17 "notebook/js/codemirror-ipython.js",
17 "notebook/js/codemirror-ipython.js",
18 "notebook/js/codemirror-ipythongfm.js",
18 "notebook/js/codemirror-ipythongfm.js",
19
19
20
21 // monkey patch CM to be able to syntax highlight cell magics
22 // bug reported upstream,
23 // see https://github.com/marijnh/CodeMirror2/issues/670
24 if(CodeMirror.getMode(1,'text/plain').indent === undefined ){
25 console.log('patching CM for undefined indent');
26 CodeMirror.modes.null = function() {
27 return {token: function(stream) {stream.skipToEnd();},indent : function(){return 0;}};
28 };
29 }
30
31 CodeMirror.patchedGetMode = function(config, mode){
32 var cmmode = CodeMirror.getMode(config, mode);
33 if(cmmode.indent === null) {
34 console.log('patch mode "' , mode, '" on the fly');
35 cmmode.indent = function(){return 0;};
36 }
37 return cmmode;
38 };
39 // end monkey patching CodeMirror
40
41
42 "notebook/js/tooltip",
43 Tooltip,
44 tooltip = new Tooltip();
45 IPython.tooltip = tooltip;
46
47
48
20 //----------------------------------------------------------------------------
49 //----------------------------------------------------------------------------
21 // Copyright (C) 2008-2011 The IPython Development Team
50 // Copyright (C) 2008-2011 The IPython Development Team
22 //
51 //
@@ -11,6 +11,19 b''
11 * @submodule MenuBar
11 * @submodule MenuBar
12 */
12 */
13
13
14 'components/bootstrap-tour/build/js/bootstrap-tour.min'
15 "notebook/js/tour",
16 Tour,
17
18 try {
19 tour = new Tour();
20 } catch (e) {
21 tour = undefined;
22 console.log("Failed to instantiate Notebook Tour", e);
23 }
24
25 IPython.tour = tour;
26
14
27
15 var IPython = (function (IPython) {
28 var IPython = (function (IPython) {
16 "use strict";
29 "use strict";
@@ -1,112 +1,24 b''
1 // Copyright (c) IPython Development Team.
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
2 // Distributed under the terms of the Modified BSD License.
3
3
4
5 "components/google-caja/html-css-sanitizer-minified",
6
7 "components/highlight.js/build/highlight.pack",
8 "dateformat/date.format",
9 "base/js/security",
10 "services/kernels/js/kernel",
11 "services/kernels/js/comm",
12 "notebook/js/mathjaxutils",
13 "notebook/js/outputarea",
14 "notebook/js/cell",
15 "notebook/js/codecell",
16 "notebook/js/completer",
17 "notebook/js/notificationwidget",
18 "notebook/js/notificationarea",
19 "notebook/js/tooltip",
20 "notebook/js/config",
21 "notebook/js/main",
22 "notebook/js/contexthint",
23 "notebook/js/celltoolbarpresets/default",
24 "notebook/js/celltoolbarpresets/rawcell",
25 "notebook/js/celltoolbarpresets/slideshow"
26
27 IPython.mathjaxutils.init();
28
29 'components/marked/lib/marked',
30 'widgets/js/init',
31 'components/bootstrap-tour/build/js/bootstrap-tour.min'
32
33 window.marked = marked;
34
35 if (marked) {
36 marked.setOptions({
37 gfm : true,
38 tables: true,
39 langPrefix: "language-",
40 highlight: function(code, lang) {
41 if (!lang) {
42 // no language, no highlight
43 return code;
44 }
45 var highlighted;
46 try {
47 highlighted = hljs.highlight(lang, code, false);
48 } catch(err) {
49 highlighted = hljs.highlightAuto(code);
50 }
51 return highlighted.value;
52 }
53 });
54 }
55
56 // monkey patch CM to be able to syntax highlight cell magics
57 // bug reported upstream,
58 // see https://github.com/marijnh/CodeMirror2/issues/670
59 if(CodeMirror.getMode(1,'text/plain').indent === undefined ){
60 console.log('patching CM for undefined indent');
61 CodeMirror.modes.null = function() {
62 return {token: function(stream) {stream.skipToEnd();},indent : function(){return 0;}};
63 };
64 }
65
66 CodeMirror.patchedGetMode = function(config, mode){
67 var cmmode = CodeMirror.getMode(config, mode);
68 if(cmmode.indent === null) {
69 console.log('patch mode "' , mode, '" on the fly');
70 cmmode.indent = function(){return 0;};
71 }
72 return cmmode;
73 };
74 // end monkey patching CodeMirror
75
76
77 "notebook/js/tour",
78 Tour,
79
80 try {
81 tour = new Tour();
82 } catch (e) {
83 tour = undefined;
84 console.log("Failed to instantiate Notebook Tour", e);
85 }
86
87 IPython.tour = tour;
88
89 "notebook/js/tooltip",
90 Tooltip,
91 tooltip = new Tooltip();
92 IPython.tooltip = tooltip;
93
94
95 define([
4 define([
96 "base/js/namespace",
5 'base/js/namespace',
97 "components/jquery/jquery.min",
6 'components/jquery/jquery.min',
98 "base/js/utils",
7 'base/js/utils',
99 "notebook/js/keyboardmanager",
8 'notebook/js/keyboardmanager',
100 "notebook/js/savewidget",
9 'notebook/js/savewidget',
101 "base/js/events",
10 'base/js/events',
102 "base/js/dialog",
11 'base/js/dialog',
103 "notebook/js/textcell",
12 'notebook/js/textcell',
104 "notebook/js/codecell",
13 'notebook/js/codecell',
105 "services/sessions/js/session",
14 'services/sessions/js/session',
106 "notebook/js/celltoolbar",
15 'notebook/js/celltoolbar',
107 "base/js/keyboard",
16 'base/js/keyboard',
108 "components/jquery-ui/ui/minified/jquery-ui.min",
17 'components/jquery-ui/ui/minified/jquery-ui.min',
109 "components/bootstrap/js/bootstrap.min",
18 'components/bootstrap/js/bootstrap.min',
19 'components/marked/lib/marked',
20 'widgets/js/init',
21 'notebook/js/mathjaxutils',
110 ], function (
22 ], function (
111 IPython,
23 IPython,
112 $,
24 $,
@@ -119,18 +31,11 b' define(['
119 CodeCell,
31 CodeCell,
120 Session,
32 Session,
121 CellToolbar,
33 CellToolbar,
122 Keyboard
34 Keyboard,
35 marked,
36 MathJax
123 ) {
37 ) {
124
38
125 keyboard_manager = new KeyboardManager();
126 save_widget = new SaveWidget('span#save_widget');
127 keyboard = new Keyboard();
128
129 // Backwards compatability.
130 IPython.keyboard_manager = keyboard_manager;
131 IPython.save_widget = save_widget;
132 IPython.keyboard = keyboard;
133
134 /**
39 /**
135 * A notebook contains and manages cells.
40 * A notebook contains and manages cells.
136 *
41 *
@@ -140,6 +45,41 b' define(['
140 * @param {Object} [options] A config object
45 * @param {Object} [options] A config object
141 */
46 */
142 var Notebook = function (selector, options) {
47 var Notebook = function (selector, options) {
48 this.keyboard_manager = new KeyboardManager();
49 this.keyboard = new Keyboard();
50 this.save_widget = new SaveWidget('span#save_widget');
51
52 this.mathjaxutils = MathJax();
53 this.mathjaxutils.init();
54
55
56 window.marked = window.marked || marked;
57 if (marked) {
58 marked.setOptions({
59 gfm : true,
60 tables: true,
61 langPrefix: "language-",
62 highlight: function(code, lang) {
63 if (!lang) {
64 // no language, no highlight
65 return code;
66 }
67 var highlighted;
68 try {
69 highlighted = hljs.highlight(lang, code, false);
70 } catch(err) {
71 highlighted = hljs.highlightAuto(code);
72 }
73 return highlighted.value;
74 }
75 });
76 }
77
78 // Backwards compatability.
79 IPython.keyboard_manager = this.keyboard_manager;
80 IPython.save_widget = this.save_widget;
81 IPython.keyboard = this.keyboard;
82
143 this.options = options = options || {};
83 this.options = options = options || {};
144 this.base_url = options.base_url;
84 this.base_url = options.base_url;
145 this.notebook_path = options.notebook_path;
85 this.notebook_path = options.notebook_path;
@@ -658,7 +598,7 b' define(['
658 cell.command_mode();
598 cell.command_mode();
659 this.mode = 'command';
599 this.mode = 'command';
660 $([Events]).trigger('command_mode.Notebook');
600 $([Events]).trigger('command_mode.Notebook');
661 keyboard_manager.command_mode();
601 this.keyboard_manager.command_mode();
662 }
602 }
663 };
603 };
664
604
@@ -688,7 +628,7 b' define(['
688 cell.edit_mode();
628 cell.edit_mode();
689 this.mode = 'edit';
629 this.mode = 'edit';
690 $([Events]).trigger('edit_mode.Notebook');
630 $([Events]).trigger('edit_mode.Notebook');
691 keyboard_manager.edit_mode();
631 this.keyboard_manager.edit_mode();
692 }
632 }
693 };
633 };
694
634
@@ -2121,14 +2061,14 b' define(['
2121 "OK": {
2061 "OK": {
2122 class: "btn-primary",
2062 class: "btn-primary",
2123 click: function () {
2063 click: function () {
2124 save_widget.rename_notebook();
2064 this.save_widget.rename_notebook();
2125 }}
2065 }}
2126 },
2066 },
2127 open : function (event, ui) {
2067 open : function (event, ui) {
2128 var that = $(this);
2068 var that = $(this);
2129 // Upon ENTER, click the OK button.
2069 // Upon ENTER, click the OK button.
2130 that.find('input[type="text"]').keydown(function (event, ui) {
2070 that.find('input[type="text"]').keydown(function (event, ui) {
2131 if (event.which === keyboard.keycodes.enter) {
2071 if (event.which === this.keyboard.keycodes.enter) {
2132 that.find('.btn-primary').first().click();
2072 that.find('.btn-primary').first().click();
2133 }
2073 }
2134 });
2074 });
@@ -5,6 +5,9 b''
5 // OutputArea
5 // OutputArea
6 //============================================================================
6 //============================================================================
7
7
8
9 "components/google-caja/html-css-sanitizer-minified",
10
8 /**
11 /**
9 * @module IPython
12 * @module IPython
10 * @namespace IPython
13 * @namespace IPython
General Comments 0
You need to be logged in to leave comments. Login now