separate selecting default kernel from new notebook with specified kernel

adds checkmark to indicate selection
This commit is contained in:
Min RK 2014-11-17 12:34:11 -08:00
parent 0cfd8731a0
commit d9767e8c94
4 changed files with 54 additions and 9 deletions

View File

@ -8168,6 +8168,17 @@ ul#new-notebook-menu {
left: auto;
right: 0;
}
.kernel-menu-icon {
padding-right: 12px;
width: 24px;
content: "\f096";
}
.kernel-menu-icon:before {
content: "\f096";
}
.kernel-menu-icon-current:before {
content: "\f00c";
}
/*!
*
* IPython notebook

View File

@ -43,13 +43,21 @@ define([
for (var i = 0; i < data.length; i++) {
var ks = data[i];
this.kernelspecs[ks.name] = ks;
var ksentry = $("<li>").attr("id", "kernel-" +ks.name).append($('<a>')
.attr('href', '#')
.click($.proxy(this.new_with_kernel, this, ks.name))
.text(ks.display_name)
.attr('title', 'Create a new notebook with ' + ks.display_name)
var li = $("<li>")
.attr("id", "kernel-" +ks.name)
.data('kernelspec', ks).append(
$('<a>').attr('href', '#').append($('<i>')
.addClass('kernel-menu-icon fa')
.attr('href', '#')
.click($.proxy(this.select_kernel, this, ks.name))
).append($('<span>')
.attr('href', '#')
.click($.proxy(this.new_notebook, this, ks.name))
.text(ks.display_name)
.attr('title', 'Create a new notebook with ' + ks.display_name)
)
);
menu.append(ksentry);
menu.append(li);
}
this._load_default_kernelspec();
};
@ -75,11 +83,23 @@ define([
this.element.find("#new_notebook").attr('title',
'Create a new notebook with ' + display_name
);
this.element.find("li").map(function (i, li) {
li = $(li);
var ks = li.data('kernelspec');
if (ks.name == kernel_name) {
li.find(".kernel-menu-icon")
.attr('title', display_name + ' is the default kernel')
.addClass("kernel-menu-icon-current");
} else {
li.find(".kernel-menu-icon")
.attr('title', 'Make ' + ks.display_name + ' the default kernel')
.removeClass("kernel-menu-icon-current");
}
});
};
NewNotebookWidget.prototype.new_with_kernel = function (kernel_name) {
/** record current selection and open a new notebook */
this.select_kernel(kernel_name);
this.new_notebook(kernel_name);
};

View File

@ -159,4 +159,18 @@ ul#new-notebook-menu {
// align right instead of left
left: auto;
right: 0;
}
}
.kernel-menu-icon {
padding-right: 12px;
width: 24px;
content: @fa-var-square-o;
}
.kernel-menu-icon:before {
content: @fa-var-square-o;
}
.kernel-menu-icon-current:before {
content: @fa-var-check;
}

View File

@ -49,7 +49,7 @@ data-terminals-available="{{terminals_available}}"
New Notebook
</button>
<button class="dropdown-toggle btn btn-default btn-xs" data-toggle="dropdown">
<span id="current-kernel"></span>
<span id="current-kernel">Loading...</span>
<span class="caret"></span>
</button>
<ul id="new-notebook-menu" class="dropdown-menu"></ul>