mirror of
https://github.com/jupyter/notebook.git
synced 2025-03-19 13:20:36 +08:00
Merge pull request #7251 from Carreau/unregister-preset
add ability to unregister a preset
This commit is contained in:
commit
d94479ad29
IPython/html/static/notebook/js
@ -190,6 +190,22 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* unregister the selected preset,
|
||||
*
|
||||
* return true if preset successfully unregistered
|
||||
* false otherwise
|
||||
*
|
||||
**/
|
||||
CellToolbar.unregister_preset = function(name){
|
||||
if(CellToolbar._presets[name]){
|
||||
delete CellToolbar._presets[name];
|
||||
events.trigger('unregistered_preset.CellToolbar', {name: name});
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* List the names of the presets that are currently registered.
|
||||
|
@ -134,10 +134,19 @@ define([
|
||||
var name = data.name;
|
||||
select.append($('<option/>').attr('value', name).text(name));
|
||||
});
|
||||
this.events.on('unregistered_preset.CellToolbar', function (event, data) {
|
||||
if (select.val() === data.name){
|
||||
select.val('');
|
||||
celltoolbar.CellToolbar.global_hide();
|
||||
delete that.notebook.metadata.celltoolbar;
|
||||
}
|
||||
select.find("option[value='"+name+"']" ).remove();
|
||||
});
|
||||
// Update select value when a preset is activated.
|
||||
this.events.on('preset_activated.CellToolbar', function (event, data) {
|
||||
if (select.val() !== data.name)
|
||||
if (select.val() !== data.name){
|
||||
select.val(data.name);
|
||||
}
|
||||
});
|
||||
|
||||
var wrapper = $('<div/>').addClass('btn-group');
|
||||
|
Loading…
x
Reference in New Issue
Block a user