From e8289178eab6ded82575b2b46bb2dc389a1c6257 2015-01-14 19:14:56 From: Min RK Date: 2015-01-14 19:14:56 Subject: [PATCH] fix new-notebook and change-kernel menus recent PR made all of these no-ops also include missing dialog module --- diff --git a/IPython/html/static/notebook/js/kernelselector.js b/IPython/html/static/notebook/js/kernelselector.js index 8a62d0e..1fa777a 100644 --- a/IPython/html/static/notebook/js/kernelselector.js +++ b/IPython/html/static/notebook/js/kernelselector.js @@ -2,10 +2,11 @@ // Distributed under the terms of the Modified BSD License. define([ - 'base/js/namespace', 'jquery', + 'base/js/namespace', + 'base/js/dialog', 'base/js/utils', -], function(IPython, $, utils) { +], function($, IPython, dialog, utils) { "use strict"; var KernelSelector = function(selector, notebook) { @@ -37,6 +38,7 @@ define([ }; KernelSelector.prototype._got_kernelspecs = function(data) { + var that = this; this.kernelspecs = data.kernelspecs; var change_kernel_submenu = $("#menu-change-kernel-submenu"); var new_notebook_submenu = $("#menu-new-notebook-submenu"); @@ -54,32 +56,34 @@ define([ } }); - var i, ks, ks_submenu_entry; - // Create the Kernel > Change kernel submenu - for (i = 0; i < keys.length; i++) { - ks = this.kernelspecs[keys[i]]; - ks_submenu_entry = $("
  • ").attr("id", "kernel-submenu-"+ks.name).append($('') - .attr('href', '#') - .click(function(){ - $.proxy(this.set_kernel, this, ks.name) - event.preventDefault(); - }) - .text(ks.spec.display_name)); - change_kernel_submenu.append(ks_submenu_entry); - } - - // Create the File > New Notebook submenu - for (i = 0; i < keys.length; i++) { - ks = this.kernelspecs[keys[i]]; - ks_submenu_entry = $("
  • ").attr("id", "new-notebook-submenu-"+ks.name).append($('') - .attr('href', '#') - .click(function(){ - $.proxy(this.new_notebook, this, ks.name) - event.preventDefault(); - }) - .text(ks.spec.display_name)); - new_notebook_submenu.append(ks_submenu_entry); - } + keys.map(function (key) { + // Create the Kernel > Change kernel submenu + var ks = data.kernelspecs[key]; + change_kernel_submenu.append( + $("
  • ").attr("id", "kernel-submenu-"+ks.name).append( + $('') + .attr('href', '#') + .click( function () { + that.set_kernel(ks.name); + event.preventDefault(); + }) + .text(ks.spec.display_name) + ) + ); + // Create the File > New Notebook submenu + new_notebook_submenu.append( + $("
  • ").attr("id", "new-notebook-submenu-"+ks.name).append( + $('') + .attr('href', '#') + .click( function () { + that.new_notebook(ks.name); + event.preventDefault(); + }) + .text(ks.spec.display_name) + ) + ); + + }); // trigger loaded promise this._finish_load(); };