mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-27 04:20:22 +08:00
Merge pull request #5605 from AlbertHilb/CellToolbar
Two cell toolbar fixes.
This commit is contained in:
commit
a540078d8d
@ -185,6 +185,10 @@ var IPython = (function (IPython) {
|
||||
CellToolbar.register_preset = function(name, preset_list) {
|
||||
CellToolbar._presets[name] = preset_list;
|
||||
$([IPython.events]).trigger('preset_added.CellToolbar', {name: name});
|
||||
// When "register_callback" is called by a custom extension, it may be executed after notebook is loaded.
|
||||
// In that case, activate the preset if needed.
|
||||
if (IPython.notebook && IPython.notebook.metadata && IPython.notebook.metadata.celltoolbar === name)
|
||||
this.activate_preset(name);
|
||||
};
|
||||
|
||||
|
||||
@ -224,6 +228,8 @@ var IPython = (function (IPython) {
|
||||
CellToolbar._ui_controls_list = preset;
|
||||
CellToolbar.rebuild_all();
|
||||
}
|
||||
|
||||
$([IPython.events]).trigger('preset_activated.CellToolbar', {name: preset_name});
|
||||
};
|
||||
|
||||
|
||||
|
@ -20,7 +20,7 @@ var IPython = (function (IPython) {
|
||||
this.bind_events();
|
||||
};
|
||||
|
||||
MainToolBar.prototype = new IPython.ToolBar();
|
||||
MainToolBar.prototype = new IPython.ToolBar();
|
||||
|
||||
MainToolBar.prototype.construct = function () {
|
||||
this.add_buttons_group([
|
||||
@ -92,7 +92,7 @@ var IPython = (function (IPython) {
|
||||
}
|
||||
}
|
||||
],'move_up_down');
|
||||
|
||||
|
||||
|
||||
this.add_buttons_group([
|
||||
{
|
||||
@ -170,12 +170,17 @@ var IPython = (function (IPython) {
|
||||
var name = data.name;
|
||||
select.append($('<option/>').attr('value', name).text(name));
|
||||
});
|
||||
// Update select value when a preset is activated.
|
||||
$([IPython.events]).on('preset_activated.CellToolbar', function (event, data) {
|
||||
if (select.val() !== data.name)
|
||||
select.val(data.name);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
MainToolBar.prototype.bind_events = function () {
|
||||
var that = this;
|
||||
|
||||
|
||||
this.element.find('#cell_type').change(function () {
|
||||
var cell_type = $(this).val();
|
||||
if (cell_type === 'code') {
|
||||
|
@ -2106,6 +2106,8 @@ var IPython = (function (IPython) {
|
||||
if (this.metadata.celltoolbar) {
|
||||
IPython.CellToolbar.global_show();
|
||||
IPython.CellToolbar.activate_preset(this.metadata.celltoolbar);
|
||||
} else {
|
||||
IPython.CellToolbar.global_hide();
|
||||
}
|
||||
|
||||
// now that we're fully loaded, it is safe to restore save functionality
|
||||
|
Loading…
Reference in New Issue
Block a user