Show More
@@ -2,10 +2,11 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 | 'base/js/namespace', |
|
|||
6 | 'jquery', |
|
5 | 'jquery', | |
|
6 | 'base/js/namespace', | |||
|
7 | 'base/js/dialog', | |||
7 | 'base/js/utils', |
|
8 | 'base/js/utils', | |
8 |
], function(IPython, |
|
9 | ], function($, IPython, dialog, utils) { | |
9 | "use strict"; |
|
10 | "use strict"; | |
10 |
|
11 | |||
11 | var KernelSelector = function(selector, notebook) { |
|
12 | var KernelSelector = function(selector, notebook) { | |
@@ -37,6 +38,7 b' define([' | |||||
37 | }; |
|
38 | }; | |
38 |
|
39 | |||
39 | KernelSelector.prototype._got_kernelspecs = function(data) { |
|
40 | KernelSelector.prototype._got_kernelspecs = function(data) { | |
|
41 | var that = this; | |||
40 | this.kernelspecs = data.kernelspecs; |
|
42 | this.kernelspecs = data.kernelspecs; | |
41 | var change_kernel_submenu = $("#menu-change-kernel-submenu"); |
|
43 | var change_kernel_submenu = $("#menu-change-kernel-submenu"); | |
42 | var new_notebook_submenu = $("#menu-new-notebook-submenu"); |
|
44 | var new_notebook_submenu = $("#menu-new-notebook-submenu"); | |
@@ -54,32 +56,34 b' define([' | |||||
54 | } |
|
56 | } | |
55 | }); |
|
57 | }); | |
56 |
|
58 | |||
57 | var i, ks, ks_submenu_entry; |
|
59 | keys.map(function (key) { | |
58 | // Create the Kernel > Change kernel submenu |
|
60 | // Create the Kernel > Change kernel submenu | |
59 | for (i = 0; i < keys.length; i++) { |
|
61 | var ks = data.kernelspecs[key]; | |
60 | ks = this.kernelspecs[keys[i]]; |
|
62 | change_kernel_submenu.append( | |
61 |
|
|
63 | $("<li>").attr("id", "kernel-submenu-"+ks.name).append( | |
62 |
|
|
64 | $('<a>') | |
63 | .click(function(){ |
|
65 | .attr('href', '#') | |
64 | $.proxy(this.set_kernel, this, ks.name) |
|
66 | .click( function () { | |
65 |
|
|
67 | that.set_kernel(ks.name); | |
66 | }) |
|
68 | event.preventDefault(); | |
67 | .text(ks.spec.display_name)); |
|
69 | }) | |
68 | change_kernel_submenu.append(ks_submenu_entry); |
|
70 | .text(ks.spec.display_name) | |
69 |
|
|
71 | ) | |
70 |
|
72 | ); | ||
71 | // Create the File > New Notebook submenu |
|
73 | // Create the File > New Notebook submenu | |
72 | for (i = 0; i < keys.length; i++) { |
|
74 | new_notebook_submenu.append( | |
73 | ks = this.kernelspecs[keys[i]]; |
|
75 | $("<li>").attr("id", "new-notebook-submenu-"+ks.name).append( | |
74 | ks_submenu_entry = $("<li>").attr("id", "new-notebook-submenu-"+ks.name).append($('<a>') |
|
76 | $('<a>') | |
75 | .attr('href', '#') |
|
77 | .attr('href', '#') | |
76 | .click(function(){ |
|
78 | .click( function () { | |
77 |
|
|
79 | that.new_notebook(ks.name); | |
78 | event.preventDefault(); |
|
80 | event.preventDefault(); | |
79 | }) |
|
81 | }) | |
80 |
.text(ks.spec.display_name) |
|
82 | .text(ks.spec.display_name) | |
81 | new_notebook_submenu.append(ks_submenu_entry); |
|
83 | ) | |
82 |
|
|
84 | ); | |
|
85 | ||||
|
86 | }); | |||
83 | // trigger loaded promise |
|
87 | // trigger loaded promise | |
84 | this._finish_load(); |
|
88 | this._finish_load(); | |
85 | }; |
|
89 | }; |
General Comments 0
You need to be logged in to leave comments.
Login now