|
|
|
|
@ -349,6 +349,36 @@ define([
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A utility function to generate bindings between a input field and cell/metadata
|
|
|
|
|
* @method utils.input_ui_generator
|
|
|
|
|
* @static
|
|
|
|
|
*
|
|
|
|
|
* @param name {string} Label in front of the input field
|
|
|
|
|
* @param setter {function( cell, newValue )}
|
|
|
|
|
* A setter method to set the newValue
|
|
|
|
|
* @param getter {function( cell )}
|
|
|
|
|
* A getter methods which return the current value.
|
|
|
|
|
*
|
|
|
|
|
* @return callback {function( div, cell )} Callback to be passed to `register_callback`
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
CellToolbar.utils.input_ui_generator = function(name, setter, getter){
|
|
|
|
|
return function(div, cell, celltoolbar) {
|
|
|
|
|
var button_container = $(div);
|
|
|
|
|
|
|
|
|
|
var chkb = $('<input/>').attr('type', 'text');
|
|
|
|
|
var lbl = $('<label/>').append($('<span/>').text(name));
|
|
|
|
|
lbl.append(chkb);
|
|
|
|
|
chkb.attr("value", getter(cell));
|
|
|
|
|
|
|
|
|
|
chkb.keyup(function(){
|
|
|
|
|
setter(cell, chkb.val());
|
|
|
|
|
});
|
|
|
|
|
button_container.append($('<span/>').append(lbl));
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A utility function to generate bindings between a dropdown list cell
|
|
|
|
|
* @method utils.select_ui_generator
|
|
|
|
|
|