diff --git a/IPython/html/static/notebook/js/celltoolbar.js b/IPython/html/static/notebook/js/celltoolbar.js index 03910b2..23c8d20 100644 --- a/IPython/html/static/notebook/js/celltoolbar.js +++ b/IPython/html/static/notebook/js/celltoolbar.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. diff --git a/IPython/html/static/notebook/js/maintoolbar.js b/IPython/html/static/notebook/js/maintoolbar.js index d4d500a..0d4ae3e 100644 --- a/IPython/html/static/notebook/js/maintoolbar.js +++ b/IPython/html/static/notebook/js/maintoolbar.js @@ -134,10 +134,19 @@ define([ var name = data.name; select.append($('').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 = $('
').addClass('btn-group');