##// END OF EJS Templates
Some JS test fixes
Jonathan Frederic -
Show More
@@ -7,7 +7,8 b' define(['
7 ], function(IPython, $) {
7 ], function(IPython, $) {
8 "use strict";
8 "use strict";
9
9
10 var modal = function (options, keyboard_manager, notebook) {
10 var modal = function (options) {
11
11 var modal = $("<div/>")
12 var modal = $("<div/>")
12 .addClass("modal")
13 .addClass("modal")
13 .addClass("fade")
14 .addClass("fade")
@@ -72,16 +73,18 b' define(['
72 });
73 });
73 }
74 }
74 modal.on("hidden.bs.modal", function () {
75 modal.on("hidden.bs.modal", function () {
75 if (notebook) {
76 if (options.notebook) {
76 var cell = notebook.get_selected_cell();
77 var cell = options.notebook.get_selected_cell();
77 if (cell) cell.select();
78 if (cell) cell.select();
78 keyboard_manager.enable();
79 if (options.keyboard_manager) {
79 keyboard_manager.command_mode();
80 options.keyboard_manager.enable();
81 options.keyboard_manager.command_mode();
82 }
80 }
83 }
81 });
84 });
82
85
83 if (keyboard_manager) {
86 if (options.keyboard_manager) {
84 keyboard_manager.disable();
87 options.keyboard_manager.disable();
85 }
88 }
86
89
87 return modal.modal(options);
90 return modal.modal(options);
@@ -110,8 +110,12 b' define(['
110 return sanitized;
110 return sanitized;
111 };
111 };
112
112
113 return {
113 var security = {
114 caja: caja,
114 caja: caja,
115 sanitize_html: sanitize_html
115 sanitize_html: sanitize_html
116 };
116 };
117
118 IPython.security = security;
119
120 return security;
117 });
121 });
@@ -1,12 +1,12 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 var ipython = ipython || {};
5 require([
4 require([
6 'base/js/namespace',
5 'base/js/namespace',
7 'jquery',
6 'jquery',
8 'notebook/js/notebook',
7 'notebook/js/notebook',
9 'base/js/utils',
8 'base/js/utils',
9 'base/js/keyboard',
10 'base/js/page',
10 'base/js/page',
11 'notebook/js/layoutmanager',
11 'notebook/js/layoutmanager',
12 'base/js/events',
12 'base/js/events',
@@ -24,6 +24,7 b' require(['
24 $,
24 $,
25 notebook,
25 notebook,
26 utils,
26 utils,
27 keyboard,
27 page,
28 page,
28 layoutmanager,
29 layoutmanager,
29 events,
30 events,
@@ -71,7 +72,8 b' require(['
71 events: events});
72 events: events});
72 var quick_help = new quickhelp.QuickHelp({
73 var quick_help = new quickhelp.QuickHelp({
73 keyboard_manager: keyboard_manager,
74 keyboard_manager: keyboard_manager,
74 events: events});
75 events: events,
76 notebook: notebook});
75 var menubar = new menubar.MenuBar('#menubar', $.extend({
77 var menubar = new menubar.MenuBar('#menubar', $.extend({
76 notebook: notebook,
78 notebook: notebook,
77 layout_manager: layout_manager,
79 layout_manager: layout_manager,
@@ -83,7 +85,8 b' require(['
83 '#notification_area', {
85 '#notification_area', {
84 events: events,
86 events: events,
85 save_widget: save_widget,
87 save_widget: save_widget,
86 notebook: notebook});
88 notebook: notebook,
89 keyboard_manager: keyboard_manager});
87 notification_area.init_notification_widgets();
90 notification_area.init_notification_widgets();
88
91
89 $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+
92 $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+
@@ -116,17 +119,18 b' require(['
116 events.trigger('app_initialized.NotebookApp');
119 events.trigger('app_initialized.NotebookApp');
117 notebook.load_notebook(common_options.notebook_name, common_options.notebook_path);
120 notebook.load_notebook(common_options.notebook_name, common_options.notebook_path);
118
121
119 ipython.page = page;
122 IPython.page = page;
120 ipython.layout_manager = layout_manager;
123 IPython.layout_manager = layout_manager;
121 ipython.notebook = notebook;
124 IPython.notebook = notebook;
122 ipython.pager = pager;
125 IPython.pager = pager;
123 ipython.quick_help = quick_help;
126 IPython.quick_help = quick_help;
124 ipython.login_widget = login_widget;
127 IPython.login_widget = login_widget;
125 ipython.menubar = menubar;
128 IPython.menubar = menubar;
126 ipython.toolbar = toolbar;
129 IPython.toolbar = toolbar;
127 ipython.notification_area = notification_area;
130 IPython.notification_area = notification_area;
128 ipython.events = events;
131 IPython.events = events;
129 ipython.keyboard_manager = keyboard_manager;
132 IPython.keyboard_manager = keyboard_manager;
130 ipython.save_widget = save_widget;
133 IPython.save_widget = save_widget;
131 ipython.config = user_config;
134 IPython.config = user_config;
135 IPython.keyboard = keyboard;
132 });
136 });
@@ -190,6 +190,8 b' define(['
190
190
191 this.events.on('status_autorestarting.Kernel', function () {
191 this.events.on('status_autorestarting.Kernel', function () {
192 dialog.modal({
192 dialog.modal({
193 notebook: that,
194 keyboard_manager: that.keyboard_manager,
193 title: "Kernel Restarting",
195 title: "Kernel Restarting",
194 body: "The kernel appears to have died. It will restart automatically.",
196 body: "The kernel appears to have died. It will restart automatically.",
195 buttons: {
197 buttons: {
@@ -1476,10 +1478,10 b' define(['
1476 * @method start_session
1478 * @method start_session
1477 */
1479 */
1478 Notebook.prototype.start_session = function () {
1480 Notebook.prototype.start_session = function () {
1479 this.session = new session.Session(this, {
1481 this.session = new session.Session({
1480 base_url: base_url,
1482 base_url: this.base_url,
1481 notebook_path: notebook_path,
1483 notebook_path: this.notebook_path,
1482 notebook_name: notebook_name,
1484 notebook_name: this.notebook_name,
1483 notebook: this});
1485 notebook: this});
1484 this.session.start($.proxy(this._session_started, this));
1486 this.session.start($.proxy(this._session_started, this));
1485 };
1487 };
@@ -1509,6 +1511,8 b' define(['
1509 Notebook.prototype.restart_kernel = function () {
1511 Notebook.prototype.restart_kernel = function () {
1510 var that = this;
1512 var that = this;
1511 dialog.modal({
1513 dialog.modal({
1514 notebook: this,
1515 keyboard_manager: this.keyboard_manager,
1512 title : "Restart kernel or continue running?",
1516 title : "Restart kernel or continue running?",
1513 body : $("<p/>").text(
1517 body : $("<p/>").text(
1514 'Do you want to restart the current kernel? You will lose all variables defined in it.'
1518 'Do you want to restart the current kernel? You will lose all variables defined in it.'
@@ -1732,6 +1736,8 b' define(['
1732 }
1736 }
1733 if (content.worksheets.length > 1) {
1737 if (content.worksheets.length > 1) {
1734 dialog.modal({
1738 dialog.modal({
1739 notebook: this,
1740 keyboard_manager: this.keyboard_manager,
1735 title : "Multiple worksheets",
1741 title : "Multiple worksheets",
1736 body : "This notebook has " + data.worksheets.length + " worksheets, " +
1742 body : "This notebook has " + data.worksheets.length + " worksheets, " +
1737 "but this version of IPython can only handle the first. " +
1743 "but this version of IPython can only handle the first. " +
@@ -1920,6 +1926,8 b' define(['
1920
1926
1921 var nb = this;
1927 var nb = this;
1922 dialog.modal({
1928 dialog.modal({
1929 notebook: this,
1930 keyboard_manager: this.keyboard_manager,
1923 title: "Trust this notebook?",
1931 title: "Trust this notebook?",
1924 body: body,
1932 body: body,
1925
1933
@@ -2065,6 +2073,8 b' define(['
2065 );
2073 );
2066 this.events.trigger('notebook_rename_failed.Notebook', [xhr, status, error]);
2074 this.events.trigger('notebook_rename_failed.Notebook', [xhr, status, error]);
2067 dialog.modal({
2075 dialog.modal({
2076 notebook: this,
2077 keyboard_manager: this.keyboard_manager,
2068 title: "Notebook Rename Error!",
2078 title: "Notebook Rename Error!",
2069 body: dialog_body,
2079 body: dialog_body,
2070 buttons : {
2080 buttons : {
@@ -2146,6 +2156,8 b' define(['
2146 "may not be able to read it. To keep the older version, close the " +
2156 "may not be able to read it. To keep the older version, close the " +
2147 "notebook without saving it.";
2157 "notebook without saving it.";
2148 dialog.modal({
2158 dialog.modal({
2159 notebook: this,
2160 keyboard_manager: this.keyboard_manager,
2149 title : "Notebook converted",
2161 title : "Notebook converted",
2150 body : msg,
2162 body : msg,
2151 buttons : {
2163 buttons : {
@@ -2163,6 +2175,8 b' define(['
2163 "introduced in later notebook versions may not be available.";
2175 "introduced in later notebook versions may not be available.";
2164
2176
2165 dialog.modal({
2177 dialog.modal({
2178 notebook: this,
2179 keyboard_manager: this.keyboard_manager,
2166 title : "Newer Notebook",
2180 title : "Newer Notebook",
2167 body : msg,
2181 body : msg,
2168 buttons : {
2182 buttons : {
@@ -2214,6 +2228,8 b' define(['
2214 "v" + this.nbformat + " or earlier.";
2228 "v" + this.nbformat + " or earlier.";
2215 }
2229 }
2216 dialog.modal({
2230 dialog.modal({
2231 notebook: this,
2232 keyboard_manager: this.keyboard_manager,
2217 title: "Error loading notebook",
2233 title: "Error loading notebook",
2218 body : msg,
2234 body : msg,
2219 buttons : {
2235 buttons : {
@@ -2378,6 +2394,8 b' define(['
2378 );
2394 );
2379
2395
2380 dialog.modal({
2396 dialog.modal({
2397 notebook: this,
2398 keyboard_manager: this.keyboard_manager,
2381 title : "Revert notebook to checkpoint",
2399 title : "Revert notebook to checkpoint",
2382 body : body,
2400 body : body,
2383 buttons : {
2401 buttons : {
@@ -24,6 +24,7 b' define(['
24 this.events = options.events;
24 this.events = options.events;
25 this.save_widget = options.save_widget;
25 this.save_widget = options.save_widget;
26 this.notebook = options.notebook;
26 this.notebook = options.notebook;
27 this.keyboard_manager = options.keyboard_manager;
27 if (this.selector !== undefined) {
28 if (this.selector !== undefined) {
28 this.element = $(selector);
29 this.element = $(selector);
29 }
30 }
@@ -135,6 +136,8 b' define(['
135 dialog.modal({
136 dialog.modal({
136 title: "Dead kernel",
137 title: "Dead kernel",
137 body : msg,
138 body : msg,
139 keyboard_manager: that.keyboard_manager,
140 notebook: that.notebook,
138 buttons : {
141 buttons : {
139 "Manual Restart": {
142 "Manual Restart": {
140 class: "btn-danger",
143 class: "btn-danger",
@@ -167,6 +170,8 b' define(['
167 dialog.modal({
170 dialog.modal({
168 title: "WebSocket connection failed",
171 title: "WebSocket connection failed",
169 body: msg,
172 body: msg,
173 keyboard_manager: that.keyboard_manager,
174 notebook: that.notebook,
170 buttons : {
175 buttons : {
171 "OK": {},
176 "OK": {},
172 "Reconnect": {
177 "Reconnect": {
@@ -18,7 +18,9 b' define(['
18 // Dictionary of keyword arguments.
18 // Dictionary of keyword arguments.
19 // events: $(Events) instance
19 // events: $(Events) instance
20 // keyboard_manager: KeyboardManager instance
20 // keyboard_manager: KeyboardManager instance
21 // notebook: Notebook instance
21 this.keyboard_manager = options.keyboard_manager;
22 this.keyboard_manager = options.keyboard_manager;
23 this.notebook = options.notebook;
22 this.keyboard_manager.quick_help = this;
24 this.keyboard_manager.quick_help = this;
23 this.events = options.events;
25 this.events = options.events;
24 };
26 };
@@ -112,7 +114,9 b' define(['
112 destroy : false,
114 destroy : false,
113 buttons : {
115 buttons : {
114 Close : {}
116 Close : {}
115 }
117 },
118 notebook: this.notebook,
119 keyboard_manager: this.keyboard_manager,
116 });
120 });
117 this.shortcut_dialog.addClass("modal_stretch");
121 this.shortcut_dialog.addClass("modal_stretch");
118
122
@@ -44,7 +44,7 b' define(['
44 Cell.apply(this, [{
44 Cell.apply(this, [{
45 config: config,
45 config: config,
46 keyboard_manager: options.keyboard_manager,
46 keyboard_manager: options.keyboard_manager,
47 events: events}]);
47 events: this.events}]);
48
48
49 this.cell_type = this.cell_type || 'text';
49 this.cell_type = this.cell_type || 'text';
50 mathjaxutils = mathjaxutils;
50 mathjaxutils = mathjaxutils;
@@ -4,7 +4,7 b''
4 define([
4 define([
5 'base/js/namespace',
5 'base/js/namespace',
6 'jquery',
6 'jquery',
7 'components/bootstrap-tour/build/js/bootstrap-tour.min',
7 'bootstraptour',
8 ], function(IPython, $, Tour) {
8 ], function(IPython, $, Tour) {
9 "use strict";
9 "use strict";
10
10
@@ -13,9 +13,9 b' define(['
13 this.kernel = null;
13 this.kernel = null;
14 this.id = null;
14 this.id = null;
15 this.notebook = options.notebook;
15 this.notebook = options.notebook;
16 this.name = notebook.notebook_name;
16 this.name = options.notebook_name;
17 this.path = notebook.notebook_path;
17 this.path = options.notebook_path;
18 this.base_url = notebook.base_url;
18 this.base_url = options.base_url;
19 };
19 };
20
20
21 Session.prototype.start = function(callback) {
21 Session.prototype.start = function(callback) {
@@ -23,6 +23,7 b''
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 jquery: 'components/jquery/jquery.min',
26 bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min',
26 },
27 },
27 shim: {
28 shim: {
28 underscore: {
29 underscore: {
@@ -31,6 +32,9 b''
31 backbone: {
32 backbone: {
32 deps: ["underscore", "jquery"],
33 deps: ["underscore", "jquery"],
33 exports: "Backbone"
34 exports: "Backbone"
35 },
36 bootstraptour: {
37 exports: "Tour"
34 }
38 }
35 }
39 }
36 });
40 });
@@ -12,6 +12,7 b' casper.open_new_notebook = function () {'
12 // Create and open a new notebook.
12 // Create and open a new notebook.
13 var baseUrl = this.get_notebook_server();
13 var baseUrl = this.get_notebook_server();
14 this.start(baseUrl);
14 this.start(baseUrl);
15 this.waitFor(this.page_loaded);
15 this.thenClick('button#new_notebook');
16 this.thenClick('button#new_notebook');
16 this.waitForPopup('');
17 this.waitForPopup('');
17
18
@@ -19,11 +20,13 b' casper.open_new_notebook = function () {'
19 this.then(function () {
20 this.then(function () {
20 this.open(this.popups[0].url);
21 this.open(this.popups[0].url);
21 });
22 });
23 this.waitFor(this.page_loaded);
22
24
23 // Make sure the kernel has started
25 // Make sure the kernel has started
24 this.waitFor( this.kernel_running );
26 this.waitFor(this.kernel_running);
25 // track the IPython busy/idle state
27 // track the IPython busy/idle state
26 this.thenEvaluate(function () {
28 this.thenEvaluate(function () {
29 IPython._status = 'idle';
27 $([IPython.events]).on('status_idle.Kernel',function () {
30 $([IPython.events]).on('status_idle.Kernel',function () {
28 IPython._status = 'idle';
31 IPython._status = 'idle';
29 });
32 });
@@ -42,9 +45,18 b' casper.open_new_notebook = function () {'
42 });
45 });
43 };
46 };
44
47
45 casper.kernel_running = function kernel_running() {
48 casper.page_loaded = function() {
46 // Return whether or not the kernel is running.
49 // Return whether or not the kernel is running.
47 return this.evaluate(function kernel_running() {
50 return this.evaluate(function() {
51 return IPython !== undefined &&
52 IPython.page !== undefined &&
53 IPython.events !== undefined;
54 });
55 };
56
57 casper.kernel_running = function() {
58 // Return whether or not the kernel is running.
59 return this.evaluate(function() {
48 return IPython.notebook.kernel.running;
60 return IPython.notebook.kernel.running;
49 });
61 });
50 };
62 };
@@ -503,6 +515,7 b' casper.open_dashboard = function () {'
503 // Start casper by opening the dashboard page.
515 // Start casper by opening the dashboard page.
504 var baseUrl = this.get_notebook_server();
516 var baseUrl = this.get_notebook_server();
505 this.start(baseUrl);
517 this.start(baseUrl);
518 this.waitFor(this.page_loaded);
506 this.wait_for_dashboard();
519 this.wait_for_dashboard();
507 };
520 };
508
521
General Comments 0
You need to be logged in to leave comments. Login now