1 /**
  2  * @author Gillis Haasnoot <gillis.haasnoot@gmail.com>
  3  * @package Banana.Controls
  4  * @summary Base input data control. Provides functionality to act as a input data control 
  5  */
  6 
  7 goog.provide('Banana.Controls.DataControls.InputControl');
  8 
  9 goog.require('Banana.Controls.DataControls.DataControl');
 10 
 11 /** @namespace Banana.Controls.InputControl */
 12 namespace('Banana.Controls').InputControl = Banana.Controls.DataControl.extend(
 13 /** @lends Banana.Controls.InputControl.prototype */
 14 {
 15 	/**
 16  	 * Abstract basic input control. will be rendered as <input></input>
 17  	 * Checkbox/radiobutton/text etc extends from this control
 18  	 *
 19 	 * @constructs
 20 	 * @extends Banana.Controls.DataControl
 21 	 */
 22 	init : function()
 23 	{
 24 		this._super();
 25 		this.bind('change',this.getProxy(this.onChange));
 26 	}
 27 });
 28 
 29 /**
 30  * focus the input control
 31  * @return {this}
 32  */
 33 Banana.Controls.InputControl.prototype.focus = function()
 34 {
 35 	jQuery('#'+this.clientId).focus();
 36 	return this;
 37 };
 38 
 39 /**
 40  * this function is called after user changes something in the dom
 41  */
 42 Banana.Controls.InputControl.prototype.onChange = function()
 43 {
 44 	this.setData(this.getDomData(),false,true);
 45 	this.isChanged = true;
 46 };
 47 
 48 /**
 49  * @return {String}
 50  */
 51 Banana.Controls.InputControl.prototype.getTagName = function()
 52 {
 53 	return 'input';
 54 };
 55 
 56 /**
 57  * @param {String} v value of the control
 58  * @return {this}
 59  */
 60 Banana.Controls.InputControl.prototype.setValue = function(v)
 61 {
 62 	this.value = v;
 63 	return this;
 64 };
 65 
 66 /**
 67  * @return {String} value of the control
 68  */
 69 Banana.Controls.InputControl.prototype.getValue = function()
 70 {
 71 	return this.value;
 72 };
 73 
 74 /**
 75  * sets name of the input control. Not required!
 76  * @param {String} n
 77  * @return {this}
 78  */
 79 Banana.Controls.InputControl.prototype.setName = function(n)
 80 {
 81 	this.name = n;
 82 	return this;
 83 };
 84 
 85 /**
 86  * gets name of the input control
 87  * @return {String} 
 88  */
 89 Banana.Controls.InputControl.prototype.getName = function()
 90 {
 91 	return this.name;
 92 };