Show More
@@ -185,6 +185,10 b' var IPython = (function (IPython) {' | |||||
185 | CellToolbar.register_preset = function(name, preset_list) { |
|
185 | CellToolbar.register_preset = function(name, preset_list) { | |
186 | CellToolbar._presets[name] = preset_list; |
|
186 | CellToolbar._presets[name] = preset_list; | |
187 | $([IPython.events]).trigger('preset_added.CellToolbar', {name: name}); |
|
187 | $([IPython.events]).trigger('preset_added.CellToolbar', {name: name}); | |
|
188 | // When "register_callback" is called by a custom extension, it may be executed after notebook is loaded. | |||
|
189 | // In that case, activate the preset if needed. | |||
|
190 | if (IPython.notebook && IPython.notebook.metadata && IPython.notebook.metadata.celltoolbar === name) | |||
|
191 | this.activate_preset(name); | |||
188 | }; |
|
192 | }; | |
189 |
|
193 | |||
190 |
|
194 | |||
@@ -224,6 +228,8 b' var IPython = (function (IPython) {' | |||||
224 | CellToolbar._ui_controls_list = preset; |
|
228 | CellToolbar._ui_controls_list = preset; | |
225 | CellToolbar.rebuild_all(); |
|
229 | CellToolbar.rebuild_all(); | |
226 | } |
|
230 | } | |
|
231 | ||||
|
232 | $([IPython.events]).trigger('preset_activated.CellToolbar', {name: preset_name}); | |||
227 | }; |
|
233 | }; | |
228 |
|
234 | |||
229 |
|
235 |
@@ -170,6 +170,11 b' var IPython = (function (IPython) {' | |||||
170 | var name = data.name; |
|
170 | var name = data.name; | |
171 | select.append($('<option/>').attr('value', name).text(name)); |
|
171 | select.append($('<option/>').attr('value', name).text(name)); | |
172 | }); |
|
172 | }); | |
|
173 | // Update select value when a preset is activated. | |||
|
174 | $([IPython.events]).on('preset_activated.CellToolbar', function (event, data) { | |||
|
175 | if (select.val() !== data.name) | |||
|
176 | select.val(data.name); | |||
|
177 | }); | |||
173 | }; |
|
178 | }; | |
174 |
|
179 | |||
175 |
|
180 |
@@ -2106,6 +2106,8 b' var IPython = (function (IPython) {' | |||||
2106 | if (this.metadata.celltoolbar) { |
|
2106 | if (this.metadata.celltoolbar) { | |
2107 | IPython.CellToolbar.global_show(); |
|
2107 | IPython.CellToolbar.global_show(); | |
2108 | IPython.CellToolbar.activate_preset(this.metadata.celltoolbar); |
|
2108 | IPython.CellToolbar.activate_preset(this.metadata.celltoolbar); | |
|
2109 | } else { | |||
|
2110 | IPython.CellToolbar.global_hide(); | |||
2109 | } |
|
2111 | } | |
2110 |
|
2112 | |||
2111 | // now that we're fully loaded, it is safe to restore save functionality |
|
2113 | // now that we're fully loaded, it is safe to restore save functionality |
General Comments 0
You need to be logged in to leave comments.
Login now