Show More
@@ -4,7 +4,8 b'' | |||||
4 | define([ |
|
4 | define([ | |
5 | 'base/js/namespace', |
|
5 | 'base/js/namespace', | |
6 | 'jquery', |
|
6 | 'jquery', | |
7 | ], function(IPython, $) { |
|
7 | 'base/js/events' | |
|
8 | ], function(IPython, $, events) { | |||
8 | "use strict"; |
|
9 | "use strict"; | |
9 |
|
10 | |||
10 | var CellToolbar = function (options) { |
|
11 | var CellToolbar = function (options) { | |
@@ -18,7 +19,6 b' define([' | |||||
18 | // notebook: Notebook instance |
|
19 | // notebook: Notebook instance | |
19 | CellToolbar._instances.push(this); |
|
20 | CellToolbar._instances.push(this); | |
20 | this.notebook = options.notebook; |
|
21 | this.notebook = options.notebook; | |
21 | this.events = options.events; |
|
|||
22 | this.cell = options.cell; |
|
22 | this.cell = options.cell; | |
23 | this.create_element(); |
|
23 | this.create_element(); | |
24 | this.rebuild(); |
|
24 | this.rebuild(); | |
@@ -175,13 +175,14 b' define([' | |||||
175 | * CellToolbar.register_preset('foo.foo_preset1', ['foo.c1', 'foo.c2', 'foo.c5']) |
|
175 | * CellToolbar.register_preset('foo.foo_preset1', ['foo.c1', 'foo.c2', 'foo.c5']) | |
176 | * CellToolbar.register_preset('foo.foo_preset2', ['foo.c4', 'foo.c5']) |
|
176 | * CellToolbar.register_preset('foo.foo_preset2', ['foo.c4', 'foo.c5']) | |
177 | */ |
|
177 | */ | |
178 |
CellToolbar.register_preset = function(name, preset_list, notebook |
|
178 | CellToolbar.register_preset = function(name, preset_list, notebook) { | |
179 | CellToolbar._presets[name] = preset_list; |
|
179 | CellToolbar._presets[name] = preset_list; | |
180 | events.trigger('preset_added.CellToolbar', {name: name}); |
|
180 | events.trigger('preset_added.CellToolbar', {name: name}); | |
181 | // When "register_callback" is called by a custom extension, it may be executed after notebook is loaded. |
|
181 | // When "register_callback" is called by a custom extension, it may be executed after notebook is loaded. | |
182 | // In that case, activate the preset if needed. |
|
182 | // In that case, activate the preset if needed. | |
183 | if (notebook && notebook.metadata && notebook.metadata.celltoolbar === name) |
|
183 | if (notebook && notebook.metadata && notebook.metadata.celltoolbar === name){ | |
184 |
CellToolbar.activate_preset(name |
|
184 | CellToolbar.activate_preset(name); | |
|
185 | } | |||
185 | }; |
|
186 | }; | |
186 |
|
187 | |||
187 |
|
188 | |||
@@ -214,7 +215,7 b' define([' | |||||
214 | * |
|
215 | * | |
215 | * CellToolbar.activate_preset('foo.foo_preset1'); |
|
216 | * CellToolbar.activate_preset('foo.foo_preset1'); | |
216 | */ |
|
217 | */ | |
217 |
CellToolbar.activate_preset = function(preset_name |
|
218 | CellToolbar.activate_preset = function(preset_name){ | |
218 | var preset = CellToolbar._presets[preset_name]; |
|
219 | var preset = CellToolbar._presets[preset_name]; | |
219 |
|
220 | |||
220 | if(preset !== undefined){ |
|
221 | if(preset !== undefined){ | |
@@ -222,9 +223,7 b' define([' | |||||
222 | CellToolbar.rebuild_all(); |
|
223 | CellToolbar.rebuild_all(); | |
223 | } |
|
224 | } | |
224 |
|
225 | |||
225 | if (events) { |
|
226 | events.trigger('preset_activated.CellToolbar', {name: preset_name}); | |
226 | events.trigger('preset_activated.CellToolbar', {name: preset_name}); |
|
|||
227 | } |
|
|||
228 | }; |
|
227 | }; | |
229 |
|
228 | |||
230 |
|
229 |
@@ -34,7 +34,7 b' define([' | |||||
34 | button_container.append(button); |
|
34 | button_container.append(button); | |
35 | }; |
|
35 | }; | |
36 |
|
36 | |||
37 |
var register = function (notebook |
|
37 | var register = function (notebook) { | |
38 | CellToolbar.register_callback('default.rawedit', add_raw_edit_button); |
|
38 | CellToolbar.register_callback('default.rawedit', add_raw_edit_button); | |
39 | raw_edit = $.proxy(raw_edit, { |
|
39 | raw_edit = $.proxy(raw_edit, { | |
40 | notebook: notebook, |
|
40 | notebook: notebook, | |
@@ -44,7 +44,7 b' define([' | |||||
44 | var example_preset = []; |
|
44 | var example_preset = []; | |
45 | example_preset.push('default.rawedit'); |
|
45 | example_preset.push('default.rawedit'); | |
46 |
|
46 | |||
47 |
CellToolbar.register_preset('Edit Metadata', example_preset, notebook |
|
47 | CellToolbar.register_preset('Edit Metadata', example_preset, notebook); | |
48 | console.log('Default extension for cell metadata editing loaded.'); |
|
48 | console.log('Default extension for cell metadata editing loaded.'); | |
49 | }; |
|
49 | }; | |
50 | return {'register': register}; |
|
50 | return {'register': register}; |
@@ -137,11 +137,11 b' define([' | |||||
137 | button_container.append(button); |
|
137 | button_container.append(button); | |
138 | }; |
|
138 | }; | |
139 |
|
139 | |||
140 |
var register = function (notebook |
|
140 | var register = function (notebook) { | |
141 | CellToolbar.register_callback('example.help',add_simple_dialog_button); |
|
141 | CellToolbar.register_callback('example.help',add_simple_dialog_button); | |
142 | example_preset.push('example.help'); |
|
142 | example_preset.push('example.help'); | |
143 |
|
143 | |||
144 |
CellToolbar.register_preset('Example',example_preset, notebook |
|
144 | CellToolbar.register_preset('Example',example_preset, notebook); | |
145 | console.log('Example extension for metadata editing loaded.'); |
|
145 | console.log('Example extension for metadata editing loaded.'); | |
146 | }; |
|
146 | }; | |
147 | return {'register': register}; |
|
147 | return {'register': register}; |
@@ -74,11 +74,11 b' define([' | |||||
74 | "Raw NBConvert Format" |
|
74 | "Raw NBConvert Format" | |
75 | ); |
|
75 | ); | |
76 |
|
76 | |||
77 |
var register = function (notebook |
|
77 | var register = function (notebook) { | |
78 | CellToolbar.register_callback('raw_cell.select', select_type, ['raw']); |
|
78 | CellToolbar.register_callback('raw_cell.select', select_type, ['raw']); | |
79 | raw_cell_preset.push('raw_cell.select'); |
|
79 | raw_cell_preset.push('raw_cell.select'); | |
80 |
|
80 | |||
81 |
CellToolbar.register_preset('Raw Cell Format', raw_cell_preset, notebook |
|
81 | CellToolbar.register_preset('Raw Cell Format', raw_cell_preset, notebook); | |
82 | console.log('Raw Cell Format toolbar preset loaded.'); |
|
82 | console.log('Raw Cell Format toolbar preset loaded.'); | |
83 | }; |
|
83 | }; | |
84 | return {'register': register}; |
|
84 | return {'register': register}; |
@@ -35,11 +35,11 b' define([' | |||||
35 | }, |
|
35 | }, | |
36 | "Slide Type"); |
|
36 | "Slide Type"); | |
37 |
|
37 | |||
38 |
var register = function (notebook |
|
38 | var register = function (notebook) { | |
39 | CellToolbar.register_callback('slideshow.select',select_type); |
|
39 | CellToolbar.register_callback('slideshow.select',select_type); | |
40 | slideshow_preset.push('slideshow.select'); |
|
40 | slideshow_preset.push('slideshow.select'); | |
41 |
|
41 | |||
42 |
CellToolbar.register_preset('Slideshow',slideshow_preset, notebook |
|
42 | CellToolbar.register_preset('Slideshow',slideshow_preset, notebook); | |
43 | console.log('Slideshow extension for metadata editing loaded.'); |
|
43 | console.log('Slideshow extension for metadata editing loaded.'); | |
44 | }; |
|
44 | }; | |
45 | return {'register': register}; |
|
45 | return {'register': register}; |
@@ -131,7 +131,6 b' define([' | |||||
131 | var inner_cell = $('<div/>').addClass('inner_cell'); |
|
131 | var inner_cell = $('<div/>').addClass('inner_cell'); | |
132 | this.celltoolbar = new celltoolbar.CellToolbar({ |
|
132 | this.celltoolbar = new celltoolbar.CellToolbar({ | |
133 | cell: this, |
|
133 | cell: this, | |
134 | events: this.events, |
|
|||
135 | notebook: this.notebook}); |
|
134 | notebook: this.notebook}); | |
136 | inner_cell.append(this.celltoolbar.element); |
|
135 | inner_cell.append(this.celltoolbar.element); | |
137 | var input_area = $('<div/>').addClass('input_area'); |
|
136 | var input_area = $('<div/>').addClass('input_area'); |
@@ -130,9 +130,9 b' define([' | |||||
130 | }; |
|
130 | }; | |
131 |
|
131 | |||
132 | // Trigger cell toolbar registration. |
|
132 | // Trigger cell toolbar registration. | |
133 |
default_celltoolbar.register(this |
|
133 | default_celltoolbar.register(this); | |
134 |
rawcell_celltoolbar.register(this |
|
134 | rawcell_celltoolbar.register(this); | |
135 |
slideshow_celltoolbar.register(this |
|
135 | slideshow_celltoolbar.register(this); | |
136 | }; |
|
136 | }; | |
137 |
|
137 | |||
138 | /** |
|
138 | /** | |
@@ -2274,7 +2274,7 b' define([' | |||||
2274 | // load toolbar state |
|
2274 | // load toolbar state | |
2275 | if (this.metadata.celltoolbar) { |
|
2275 | if (this.metadata.celltoolbar) { | |
2276 | celltoolbar.CellToolbar.global_show(); |
|
2276 | celltoolbar.CellToolbar.global_show(); | |
2277 |
celltoolbar.CellToolbar.activate_preset(this.metadata.celltoolbar |
|
2277 | celltoolbar.CellToolbar.activate_preset(this.metadata.celltoolbar); | |
2278 | } else { |
|
2278 | } else { | |
2279 | celltoolbar.CellToolbar.global_hide(); |
|
2279 | celltoolbar.CellToolbar.global_hide(); | |
2280 | } |
|
2280 | } |
@@ -78,7 +78,6 b' define([' | |||||
78 | var inner_cell = $('<div/>').addClass('inner_cell'); |
|
78 | var inner_cell = $('<div/>').addClass('inner_cell'); | |
79 | this.celltoolbar = new celltoolbar.CellToolbar({ |
|
79 | this.celltoolbar = new celltoolbar.CellToolbar({ | |
80 | cell: this, |
|
80 | cell: this, | |
81 | events: this.events, |
|
|||
82 | notebook: this.notebook}); |
|
81 | notebook: this.notebook}); | |
83 | inner_cell.append(this.celltoolbar.element); |
|
82 | inner_cell.append(this.celltoolbar.element); | |
84 | var input_area = $('<div/>').addClass('input_area'); |
|
83 | var input_area = $('<div/>').addClass('input_area'); |
General Comments 0
You need to be logged in to leave comments.
Login now