##// END OF EJS Templates
Split metadataui into multiple file...
Matthias BUSSONNIER -
Show More
@@ -0,0 +1,184 b''
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2012 The IPython Development Team
3 //
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
7
8 //============================================================================
9 // MetaUI Example
10 //============================================================================
11
12 /**
13 * Example Use for the MetaUI library
14 * add the following to your custom.js to load
15 * metadata UI for slideshow
16 *
17 * ```
18 * $.getScript('/static/js/examples/metaui.example.js');
19 * ```
20 */
21 // IIFE without asignement, we don't modifiy the IPython namespace
22 (function (IPython) {
23 "use strict";
24
25 var MetaUI = IPython.MetaUI;
26
27
28 var raw_edit = function(cell){
29
30 var md = cell.metadata
31
32 var textarea = $('<textarea/>')
33 .attr('rows','13')
34 .attr('cols','75')
35 .attr('name','metadata')
36 .text(JSON.stringify(md, null,4)||'');
37 var dialogform = $('<div/>').attr('title','Edit the metadata')
38 .append(
39 $('<form/>').append(
40 $('<fieldset/>').append(
41 $('<label/>')
42 .attr('for','metadata')
43 .text("Metadata (I know what I'm dooing and I won't complain if it breaks my notebook)")
44 )
45 .append($('<br/>'))
46 .append(
47 textarea
48 )
49 )
50 );
51 var editor = CodeMirror.fromTextArea(textarea[0], {
52 lineNumbers: true,
53 matchBrackets: true,
54 });
55 $(dialogform).dialog({
56 autoOpen: true,
57 height: 300,
58 width: 650,
59 modal: true,
60 buttons: {
61 "Ok": function() {
62 //validate json and set it
63 try {
64 var json = JSON.parse(editor.getValue());
65 cell.metadata = json;
66 $( this ).dialog( "close" );
67 }
68 catch(e)
69 {
70 alert('invalid json');
71 }
72 },
73 Cancel: function() {
74 $( this ).dialog( "close" );
75 }
76 },
77 close: function() {
78 //cleanup on close
79 $(this).remove();
80 }
81 });
82 editor.refresh();
83 }
84
85 var add_raw_edit_button = function(div, cell) {
86 var button_container = $(div)
87 var button = $('<div/>').button({label:'Raw Edit'})
88 .click(function(){raw_edit(cell); return false;})
89 button_container.append(button);
90 }
91
92 MetaUI.register_callback('example.rawedit',add_raw_edit_button);
93 var example_preset = []
94 example_preset.push('example.rawedit');
95
96
97 var simple_button = function(div, cell) {
98 var button_container = $(div);
99 var button = $('<div/>').button({icons:{primary:'ui-icon-locked'}});
100 var fun = function(value){
101 try{
102 if(value){
103 cell.code_mirror.setOption('readOnly','nocursor')
104 button.button('option','icons',{primary:'ui-icon-locked'})
105 } else {
106 cell.code_mirror.setOption('readOnly','false')
107 button.button('option','icons',{primary:'ui-icon-unlocked'})
108 }
109 } catch(e){}
110
111 }
112 fun(cell.metadata.ro)
113 button.click(function(){
114 var v = cell.metadata.ro;
115 var locked = !v;
116 cell.metadata.ro = locked;
117 fun(locked)
118 })
119 .css('height','16px')
120 .css('width','35px');
121 button_container.append(button);
122 }
123
124 MetaUI.register_callback('example.lock',simple_button);
125 example_preset.push('example.lock');
126
127 var toggle_test = function(div, cell) {
128 var button_container = $(div)
129 var button = $('<div/>').button({label:String(cell.metadata.foo)});
130 button.click(function(){
131 var v = cell.metadata.foo;
132 cell.metadata.foo = !v;
133 button.button("option","label",String(!v));
134 })
135 button_container.append(button);
136 }
137
138 MetaUI.register_callback('example.toggle',toggle_test);
139 example_preset.push('example.toggle');
140
141 var checkbox_test = function(div, cell) {
142 var button_container = $(div)
143
144 var chkb = $('<input/>').attr('type','checkbox');
145 var lbl = $('<label/>').append($('<span/>').text('bar :').css('font-size','77%'));
146 lbl.append(chkb);
147 chkb.attr("checked",cell.metadata.bar);
148 chkb.click(function(){
149 var v = cell.metadata.bar;
150 cell.metadata.bar = !v;
151 chkb.attr("checked",!v);
152 })
153 button_container.append($('<div/>').append(lbl));
154
155 }
156
157 MetaUI.register_callback('example.checkbox',checkbox_test);
158 example_preset.push('example.checkbox');
159
160 var select_test = function(div, cell) {
161 var button_container = $(div)
162
163 var select = $('<select/>');
164
165 select.append($('<option/>').attr('value','foo').text('foo'));
166 select.append($('<option/>').attr('value','bar').text('bar'));
167 select.append($('<option/>').attr('value','qux').text('qux'));
168 select.append($('<option/>').attr('value','zip').text('zip'));
169 select.val(cell.metadata.option);
170 select.change(function(){
171 cell.metadata.option = select.val();
172 });
173 button_container.append($('<div/>').append(select));
174
175 }
176
177 MetaUI.register_callback('example.select',select_test);
178 example_preset.push('example.select');
179
180 MetaUI.register_preset('example',example_preset);
181 MetaUI.set_preset('example');
182 console.log('Example extension for metadata editting loaded.');
183
184 }(IPython));
@@ -0,0 +1,63 b''
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2012 The IPython Development Team
3 //
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
7
8 //============================================================================
9 // MetaUI Example
10 //============================================================================
11
12 /**
13 * Example Use for the MetaUI library
14 * add the following to your custom.js to load
15 * metadata UI for slideshow
16 *
17 * ```
18 * $.getScript('/static/js/examples/metaui.slideshow.js');
19 * ```
20 */
21 // IIFE without asignement, we don't modifiy the IPython namespace
22 (function (IPython) {
23 "use strict";
24
25 var MetaUI = IPython.MetaUI;
26 var slideshow_preset = [];
27
28 var hslide = MetaUI.utils.checkbox_ui_generator('New Section',
29 function(md,value){
30 if (md.slideshow == undefined){md.slideshow = {}}
31 return md.slideshow.new_section = value},
32 function(md){ var ns = md.slideshow;
33 return (ns == undefined)? undefined: ns.new_section});
34
35 var vslide = MetaUI.utils.checkbox_ui_generator('New Subsection',
36 function(md,value){
37 if (md.slideshow == undefined){md.slideshow = {}}
38 return md.slideshow.new_subsection = value},
39 function(md){ var ns = md.slideshow;
40 return (ns == undefined)? undefined: ns.new_subsection});
41
42 var fragment = MetaUI.utils.checkbox_ui_generator('New Fragment',
43 function(md,value){
44 if (md.slideshow == undefined){md.slideshow = {}}
45 return md.slideshow.new_fragment = value},
46 function(md){ var ns = md.slideshow;
47 return (ns == undefined)? undefined: ns.new_fragment});
48
49
50 MetaUI.register_callback('slideshow.hslide',hslide);
51 MetaUI.register_callback('slideshow.vslide',vslide);
52 MetaUI.register_callback('slideshow.fragment',fragment);
53
54 slideshow_preset.push('slideshow.fragment');
55 slideshow_preset.push('slideshow.vslide');
56 slideshow_preset.push('slideshow.hslide');
57
58
59 MetaUI.register_preset('slideshow',slideshow_preset);
60 MetaUI.set_preset('slideshow');
61 console.log('Slideshow extension for metadata editting loaded.');
62
63 }(IPython));
@@ -1,35 +1,47 b''
1 1 // leave at least 2 line with only a star on it below, or doc generation fails
2 2 /**
3 3 *
4 4 *
5 5 * Placeholder for custom user javascript
6 6 * mainly to be overridden in profile/static/js/custom.js
7 7 * This will always be an empty file in IPython
8 8 *
9 9 * User could add any javascript in the `profile/static/js/custom.js` file
10 10 * (and should create it if it does not exist).
11 11 * It will be executed by the ipython notebook at load time.
12 12 *
13 13 * Same thing with `profile/static/css/custom.css` to inject custom css into the notebook.
14 14 *
15 15 * Example :
16 16 *
17 17 * Create a custom button in toolbar that execute `%qtconsole` in kernel
18 18 * and hence open a qtconsole attached to the same kernel as the current notebook
19 19 *
20 20 * $([IPython.events]).on('notebook_loaded.Notebook', function(){
21 21 * IPython.toolbar.add_buttons_group([
22 22 * {
23 23 * 'label' : 'run qtconsole',
24 24 * 'icon' : 'ui-icon-calculator', // select your icon from http://jqueryui.com/themeroller/
25 25 * 'callback': function(){IPython.notebook.kernel.execute('%qtconsole')}
26 26 * }
27 27 * // add more button here if needed.
28 28 * ]);
29 29 * });
30 30 *
31 * Example :
32 *
33 * Use `jQuery.getScript(url [, success(script, textStatus, jqXHR)] );`
34 * to load custom script into the notebook.
35 *
36 * // to load the metadata ui extension example.
37 * $.getScript('/static/js/examples/metaui.example.js');
38 * // or
39 * // to load the metadata ui extension to control slideshow mode / reveal js for nbconvert
40 * $.getScript('/static/js/examples/metaui.slideshow.js');
41 *
42 *
31 43 * @module IPython
32 44 * @namespace IPython
33 45 * @class customjs
34 46 * @static
35 47 */
@@ -1,449 +1,376 b''
1 1 //----------------------------------------------------------------------------
2 2 // Copyright (C) 2012 The IPython Development Team
3 3 //
4 4 // Distributed under the terms of the BSD License. The full license is in
5 5 // the file COPYING, distributed as part of this software.
6 6 //----------------------------------------------------------------------------
7 7
8 8 //============================================================================
9 9 // MetaUI
10 10 //============================================================================
11 11
12 12
13 13 /**
14 14 * A Module to control the per-cell toolbar.
15 15 * @module IPython
16 16 * @namespace IPython
17 17 * @submodule MetaUI
18 18 */
19 19 var IPython = (function (IPython) {
20 20 "use strict";
21 21
22 22
23 23 /**
24 24 * @constructor
25 25 * @class MetaUI
26 26 * @param {The cell to attach the metadata UI to} cell
27 27 */
28 28 var MetaUI = function (cell) {
29 29 MetaUI._instances.push(this);
30 30 this.metainner = $('<div/>');
31 31 this.cell = cell;
32 32 this.element = $('<div/>').addClass('metaedit')
33 33 .append(this.metainner)
34 34 this.rebuild();
35 35 return this;
36 36 };
37 37
38 38 /**
39 39 * Class variable that should contain a dict of all availlable callback
40 40 * we need to think of wether or not we allow nested namespace
41 41 * @property _callback_dict
42 42 * @private
43 43 */
44 44 MetaUI._callback_dict = {};
45 45
46 46 /**
47 47 * Class variable that should contain the reverse order list of the button
48 48 * to add to the toolbar of each cell
49 49 * @property _button_list
50 50 * @private
51 51 */
52 52 MetaUI._button_list = [];
53 53
54 54 /**
55 55 * keep a list of all instances to
56 56 * be able to llop over them...
57 57 * but how to 'destroy' them ?
58 58 * have to think about it...
59 59 * or loop over the cells, and find their MetaUI instances.
60 60 * @private
61 61 * @property _instances
62 62 */
63 63 MetaUI._instances =[]
64 64
65 65 /**
66 66 * keep a list of all the availlabel presets for the toolbar
67 67 * @private
68 68 * @property _presets
69 69 */
70 70 MetaUI._presets ={}
71 71
72 72 // this is by design not a prototype.
73 73 /**
74 74 * Register a callback to create an UI element in a cell toolbar.
75 75 * @method register_callback
76 76 * @param name {String} name to use to refer to the callback. It is advised to use a prefix with the name
77 77 * for easier sorting and avoid collision
78 78 * @param callback {function(div, cell)} callback that will be called to generate the ui element
79 79 *
80 80 *
81 81 * The callback will receive the following element :
82 82 *
83 83 * * a div in which to add element.
84 84 * * the cell it is responsable from
85 85 *
86 86 * @example
87 87 *
88 88 * Example that create callback for a button that toggle between `true` and `false` label,
89 89 * with the metadata under the key 'foo' to reflect the status of the button.
90 90 *
91 91 * // first param reference to a DOM div
92 92 * // second param reference to the cell.
93 93 * var toggle = function(div, cell) {
94 94 * var button_container = $(div)
95 95 *
96 96 * // let's create a button that show the current value of the metadata
97 97 * var button = $('<div/>').button({label:String(cell.metadata.foo)});
98 98 *
99 99 * // On click, change the metadata value and update the button label
100 100 * button.click(function(){
101 101 * var v = cell.metadata.foo;
102 102 * cell.metadata.foo = !v;
103 103 * button.button("option","label",String(!v));
104 104 * })
105 105 *
106 106 * // add the button to the DOM div.
107 107 * button_container.append(button);
108 108 * }
109 109 *
110 110 * // now we register the callback under the name `foo` to give the
111 111 * // user the ability to use it later
112 112 * MetaUI.register_callback('foo',toggle);
113 113 */
114 114 MetaUI.register_callback = function(name, callback){
115 115 // what do we do if name already exist ?
116 116 MetaUI._callback_dict[name] = callback;
117 117 };
118 118
119 119 /**
120 120 * Register a preset of UI element in a cell toolbar.
121 121 * Not supported Yet.
122 122 * @method register_preset
123 123 * @param name {String} name to use to refer to the preset. It is advised to use a prefix with the name
124 124 * for easier sorting and avoid collision
125 125 * @param preset_list {List of String} reverse order of the button in the toolbar. Each String of the list
126 126 * should correspond to a name of a registerd callback.
127 127 *
128 128 * @private
129 129 * @example
130 130 *
131 131 * MetaUI.register_callback('foo.c1',function(div,cell){...});
132 132 * MetaUI.register_callback('foo.c2',function(div,cell){...});
133 133 * MetaUI.register_callback('foo.c3',function(div,cell){...});
134 134 * MetaUI.register_callback('foo.c4',function(div,cell){...});
135 135 * MetaUI.register_callback('foo.c5',function(div,cell){...});
136 136 *
137 137 * MetaUI.register_preset('foo.foo_preset1',['foo.c1','foo.c2','foo.c5'])
138 138 * MetaUI.register_preset('foo.foo_preset2',['foo.c4','foo.c5'])
139 139 */
140 140 MetaUI.register_preset = function(name, preset_list){
141 141 MetaUI._presets[name] = preset_list
142 142 }
143 143 /**
144 144 * set an UI preset from `register_preset`
145 145 * @method set_preset
146 146 * @param preset_name {String} string corresponding to the preset name
147 147 *
148 148 * @static
149 149 * @private
150 150 * @example
151 151 *
152 152 * MetaUI.set_preset('foo.foo_preset1');
153 153 */
154 154 MetaUI.set_preset= function(preset_name){
155 155 var preset = MetaUI._presets[preset_name];
156 156
157 157 if(preset != undefined){
158 158 MetaUI._button_list = preset;
159 159 MetaUI.rebuild_all();
160 160 }
161 161 }
162 162
163 163 // this is by design not a prototype.
164 164 /**
165 165 * This should be called on the class and not on a instance as it will trigger
166 166 * rebuild of all the instances.
167 167 * @method rebuild_all
168 168 * @static
169 169 *
170 170 */
171 171 MetaUI.rebuild_all = function(){
172 172 for(var i in MetaUI._instances){
173 173 MetaUI._instances[i].rebuild();
174 174 }
175 175 }
176 176
177 177 /**
178 178 * Rebuild all the button on the toolbar to update it's state.
179 179 * @method rebuild
180 180 */
181 181 MetaUI.prototype.rebuild = function(){
182 182 // strip evrything from the div
183 183 // which is probabli metainner.
184 184 // or this.element.
185 185 this.metainner.empty();
186 186 //this.add_raw_edit_button()
187 187
188 188
189 189 var cdict = MetaUI._callback_dict;
190 190 var preset = MetaUI._button_list;
191 191 // Yes we iterate on the class varaible, not the instance one.
192 192 for ( var index in MetaUI._button_list){
193 193 var local_div = $('<div/>').addClass('button_container');
194 194 // Note,
195 195 // do this the other way, wrap in try/catch and don't append if any errors.
196 196 this.metainner.append(local_div)
197 197 cdict[preset[index]](local_div,this.cell)
198 198 }
199 199
200 200 }
201 201
202 202 var raw_edit = function(cell){
203 203
204 204 var md = cell.metadata
205 205
206 206 var textarea = $('<textarea/>')
207 207 .attr('rows','13')
208 208 .attr('cols','75')
209 209 .attr('name','metadata')
210 210 .text(JSON.stringify(md, null,4)||'');
211 211 var dialogform = $('<div/>').attr('title','Edit the metadata')
212 212 .append(
213 213 $('<form/>').append(
214 214 $('<fieldset/>').append(
215 215 $('<label/>')
216 216 .attr('for','metadata')
217 217 .text("Metadata (I know what I'm dooing and I won't complain if it breaks my notebook)")
218 218 )
219 219 .append($('<br/>'))
220 220 .append(
221 221 textarea
222 222 )
223 223 )
224 224 );
225 225 var editor = CodeMirror.fromTextArea(textarea[0], {
226 226 lineNumbers: true,
227 227 matchBrackets: true,
228 228 });
229 229 $(dialogform).dialog({
230 230 autoOpen: true,
231 231 height: 300,
232 232 width: 650,
233 233 modal: true,
234 234 buttons: {
235 235 "Ok": function() {
236 236 //validate json and set it
237 237 try {
238 238 var json = JSON.parse(editor.getValue());
239 239 cell.metadata = json;
240 240 $( this ).dialog( "close" );
241 241 }
242 242 catch(e)
243 243 {
244 244 alert('invalid json');
245 245 }
246 246 },
247 247 Cancel: function() {
248 248 $( this ).dialog( "close" );
249 249 }
250 250 },
251 251 close: function() {
252 252 //cleanup on close
253 253 $(this).remove();
254 254 }
255 255 });
256 256 editor.refresh();
257 257 }
258 258
259 259 var add_raw_edit_button = function(div, cell) {
260 260 var button_container = $(div)
261 261 var button = $('<div/>').button({label:'Raw Edit'})
262 262 .click(function(){raw_edit(cell); return false;})
263 263 button_container.append(button);
264 264 }
265 265
266 266 MetaUI.register_callback('example.rawedit',add_raw_edit_button);
267 267 var example_preset = []
268 268 example_preset.push('example.rawedit');
269 269
270 270
271 271 var simple_button = function(div, cell) {
272 272 var button_container = $(div);
273 273 var button = $('<div/>').button({icons:{primary:'ui-icon-locked'}});
274 274 var fun = function(value){
275 275 try{
276 276 if(value){
277 277 cell.code_mirror.setOption('readOnly','nocursor')
278 278 button.button('option','icons',{primary:'ui-icon-locked'})
279 279 } else {
280 280 cell.code_mirror.setOption('readOnly','false')
281 281 button.button('option','icons',{primary:'ui-icon-unlocked'})
282 282 }
283 283 } catch(e){}
284 284
285 285 }
286 286 fun(cell.metadata.ro)
287 287 button.click(function(){
288 288 var v = cell.metadata.ro;
289 289 var locked = !v;
290 290 cell.metadata.ro = locked;
291 291 fun(locked)
292 292 })
293 293 .css('height','16px')
294 294 .css('width','35px');
295 295 button_container.append(button);
296 296 }
297 297
298 298 MetaUI.register_callback('example.lock',simple_button);
299 299 example_preset.push('example.lock');
300 300
301 301 var toggle_test = function(div, cell) {
302 302 var button_container = $(div)
303 303 var button = $('<div/>').button({label:String(cell.metadata.foo)});
304 304 button.click(function(){
305 305 var v = cell.metadata.foo;
306 306 cell.metadata.foo = !v;
307 307 button.button("option","label",String(!v));
308 308 })
309 309 button_container.append(button);
310 310 }
311 311
312 312 MetaUI.register_callback('example.toggle',toggle_test);
313 313 example_preset.push('example.toggle');
314 314
315 315 /**
316 316 */
317 317 MetaUI.utils = {};
318 318
319 319 /**
320 320 * A utility function to generate bindings between a checkbox and metadata
321 321 * @method utils.checkbox_ui_generator
322 322 * @static
323 323 *
324 324 * @param name {string} Label in front of the checkbox
325 325 * @param setter {function( metadata_dict, newValue )} A setter method to set the newValue of the metadata dictionnary
326 326 * @param getter {function( metadata )} A getter methods which return the current value of the metadata.
327 327 *
328 328 * @return callback {function( div, cell )} Callback to be passed to `register_callback`
329 329 *
330 330 * @example
331 331 *
332 332 * An exmple that bind the subkey `slideshow.isSectionStart` to a checkbox with a `New Slide` label
333 333 *
334 334 * var newSlide = MetaUI.utils.checkbox_ui_generator('New Slide',
335 335 * // setter
336 336 * function(metadata,value){
337 337 * // we check that the slideshow namespace exist and create it if needed
338 338 * if (metadata.slideshow == undefined){metadata.slideshow = {}}
339 339 * // set the value
340 340 * metadata.slideshow.isSectionStart = value
341 341 * },
342 342 * //geter
343 343 * function(metadata){ var ns = metadata.slideshow;
344 344 * // if the slideshow namespace does not exist return `undefined`
345 345 * // (will be interpreted as `false` by checkbox) otherwise
346 346 * // return the value
347 347 * return (ns == undefined)? undefined: ns.isSectionStart
348 348 * }
349 349 * );
350 350 *
351 351 * MetaUI.register_callback('newSlide', newSlide);
352 352 *
353 353 */
354 354 MetaUI.utils.checkbox_ui_generator = function(name,setter,getter){
355 355 return function(div, cell) {
356 356 var button_container = $(div)
357 357
358 358 var chkb = $('<input/>').attr('type','checkbox');
359 359 var lbl = $('<label/>').append($('<span/>').text(name).css('font-size','77%'));
360 360 lbl.append(chkb);
361 361 chkb.attr("checked",getter(cell.metadata));
362 362
363 363 chkb.click(function(){
364 364 var v = getter(cell.metadata);
365 365 setter(cell.metadata,!v);
366 366 chkb.attr("checked",!v);
367 367 })
368 368 button_container.append($('<div/>').append(lbl));
369 369
370 370 }
371 371 }
372 var hslide = MetaUI.utils.checkbox_ui_generator('New Section',
373 function(md,value){
374 if (md.slideshow == undefined){md.slideshow = {}}
375 return md.slideshow.new_section = value},
376 function(md){ var ns = md.slideshow;
377 return (ns == undefined)? undefined: ns.new_section});
378
379 var vslide = MetaUI.utils.checkbox_ui_generator('New Subsection',
380 function(md,value){
381 if (md.slideshow == undefined){md.slideshow = {}}
382 return md.slideshow.new_subsection = value},
383 function(md){ var ns = md.slideshow;
384 return (ns == undefined)? undefined: ns.new_subsection});
385
386 var fragment = MetaUI.utils.checkbox_ui_generator('New Fragment',
387 function(md,value){
388 if (md.slideshow == undefined){md.slideshow = {}}
389 return md.slideshow.new_fragment = value},
390 function(md){ var ns = md.slideshow;
391 return (ns == undefined)? undefined: ns.new_fragment});
392
393
394 MetaUI.register_callback('slideshow.hslide',hslide);
395 MetaUI.register_callback('slideshow.vslide',vslide);
396 MetaUI.register_callback('slideshow.fragment',fragment);
397
398 example_preset.push('slideshow.fragment');
399 example_preset.push('slideshow.vslide');
400 example_preset.push('slideshow.hslide');
401
402
403 var checkbox_test = function(div, cell) {
404 var button_container = $(div)
405
406 var chkb = $('<input/>').attr('type','checkbox');
407 var lbl = $('<label/>').append($('<span/>').text('bar :').css('font-size','77%'));
408 lbl.append(chkb);
409 chkb.attr("checked",cell.metadata.bar);
410 chkb.click(function(){
411 var v = cell.metadata.bar;
412 cell.metadata.bar = !v;
413 chkb.attr("checked",!v);
414 })
415 button_container.append($('<div/>').append(lbl));
416
417 }
418
419 MetaUI.register_callback('example.checkbox',checkbox_test);
420 example_preset.push('example.checkbox');
421
422 var select_test = function(div, cell) {
423 var button_container = $(div)
424
425 var select = $('<select/>');
426
427 select.append($('<option/>').attr('value','foo').text('foo'));
428 select.append($('<option/>').attr('value','bar').text('bar'));
429 select.append($('<option/>').attr('value','qux').text('qux'));
430 select.append($('<option/>').attr('value','zip').text('zip'));
431 select.val(cell.metadata.option);
432 select.change(function(){
433 cell.metadata.option = select.val();
434 });
435 button_container.append($('<div/>').append(select));
436
437 }
438
439 MetaUI.register_callback('example.select',select_test);
440 example_preset.push('example.select');
441
442 MetaUI.register_preset('example',example_preset);
443 MetaUI.register_preset('foo',['example.select','example.select']);
444 MetaUI.set_preset('example');
445 372
446 373 IPython.MetaUI = MetaUI;
447 374
448 375 return IPython;
449 376 }(IPython));
General Comments 0
You need to be logged in to leave comments. Login now