Show More
@@ -350,6 +350,36 b' define([' | |||||
350 |
|
350 | |||
351 |
|
351 | |||
352 | /** |
|
352 | /** | |
|
353 | * A utility function to generate bindings between a input field and cell/metadata | |||
|
354 | * @method utils.input_ui_generator | |||
|
355 | * @static | |||
|
356 | * | |||
|
357 | * @param name {string} Label in front of the input field | |||
|
358 | * @param setter {function( cell, newValue )} | |||
|
359 | * A setter method to set the newValue | |||
|
360 | * @param getter {function( cell )} | |||
|
361 | * A getter methods which return the current value. | |||
|
362 | * | |||
|
363 | * @return callback {function( div, cell )} Callback to be passed to `register_callback` | |||
|
364 | * | |||
|
365 | */ | |||
|
366 | CellToolbar.utils.input_ui_generator = function(name, setter, getter){ | |||
|
367 | return function(div, cell, celltoolbar) { | |||
|
368 | var button_container = $(div); | |||
|
369 | ||||
|
370 | var chkb = $('<input/>').attr('type', 'text'); | |||
|
371 | var lbl = $('<label/>').append($('<span/>').text(name)); | |||
|
372 | lbl.append(chkb); | |||
|
373 | chkb.attr("value", getter(cell)); | |||
|
374 | ||||
|
375 | chkb.keyup(function(){ | |||
|
376 | setter(cell, chkb.val()); | |||
|
377 | }); | |||
|
378 | button_container.append($('<span/>').append(lbl)); | |||
|
379 | }; | |||
|
380 | }; | |||
|
381 | ||||
|
382 | /** | |||
353 | * A utility function to generate bindings between a dropdown list cell |
|
383 | * A utility function to generate bindings between a dropdown list cell | |
354 | * @method utils.select_ui_generator |
|
384 | * @method utils.select_ui_generator | |
355 | * @static |
|
385 | * @static |
General Comments 0
You need to be logged in to leave comments.
Login now