Show More
@@ -184,6 +184,10 b' var IPython = (function (IPython) {' | |||||
184 | CellToolbar.register_preset = function(name, preset_list) { |
|
184 | CellToolbar.register_preset = function(name, preset_list) { | |
185 | CellToolbar._presets[name] = preset_list; |
|
185 | CellToolbar._presets[name] = preset_list; | |
186 | $([IPython.events]).trigger('preset_added.CellToolbar', {name: name}); |
|
186 | $([IPython.events]).trigger('preset_added.CellToolbar', {name: name}); | |
|
187 | // When "register_callback" is called by a custom extension, it may be executed after notebook is loaded. | |||
|
188 | // In that case, activate the preset if needed. | |||
|
189 | if (IPython.notebook && IPython.notebook.metadata && IPython.notebook.metadata.celltoolbar === name) | |||
|
190 | this.activate_preset(name); | |||
187 | }; |
|
191 | }; | |
188 |
|
192 | |||
189 |
|
193 | |||
@@ -223,6 +227,8 b' var IPython = (function (IPython) {' | |||||
223 | CellToolbar._ui_controls_list = preset; |
|
227 | CellToolbar._ui_controls_list = preset; | |
224 | CellToolbar.rebuild_all(); |
|
228 | CellToolbar.rebuild_all(); | |
225 | } |
|
229 | } | |
|
230 | ||||
|
231 | $([IPython.events]).trigger('preset_activated.CellToolbar', {name: preset_name}); | |||
226 | }; |
|
232 | }; | |
227 |
|
233 | |||
228 |
|
234 |
@@ -20,7 +20,7 b' var IPython = (function (IPython) {' | |||||
20 | this.bind_events(); |
|
20 | this.bind_events(); | |
21 | }; |
|
21 | }; | |
22 |
|
22 | |||
23 |
MainToolBar.prototype = new IPython.ToolBar(); |
|
23 | MainToolBar.prototype = new IPython.ToolBar(); | |
24 |
|
24 | |||
25 | MainToolBar.prototype.construct = function () { |
|
25 | MainToolBar.prototype.construct = function () { | |
26 | this.add_buttons_group([ |
|
26 | this.add_buttons_group([ | |
@@ -92,7 +92,7 b' var IPython = (function (IPython) {' | |||||
92 | } |
|
92 | } | |
93 | } |
|
93 | } | |
94 | ],'move_up_down'); |
|
94 | ],'move_up_down'); | |
95 |
|
95 | |||
96 |
|
96 | |||
97 | this.add_buttons_group([ |
|
97 | this.add_buttons_group([ | |
98 | { |
|
98 | { | |
@@ -170,12 +170,17 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 | |||
176 | MainToolBar.prototype.bind_events = function () { |
|
181 | MainToolBar.prototype.bind_events = function () { | |
177 | var that = this; |
|
182 | var that = this; | |
178 |
|
183 | |||
179 | this.element.find('#cell_type').change(function () { |
|
184 | this.element.find('#cell_type').change(function () { | |
180 | var cell_type = $(this).val(); |
|
185 | var cell_type = $(this).val(); | |
181 | if (cell_type === 'code') { |
|
186 | if (cell_type === 'code') { |
@@ -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