1 /**
  2  * @author Gillis Haasnoot <gillis.haasnoot@gmail.com>
  3  * @package Banana.Controls
  4  * @summary Label decorator TODO merge this or extend this from regular label decorator
  5  */
  6 
  7 goog.provide('Banana.Controls.Decorators.LabelDecoratorRight');
  8 
  9 /** @namespace Banana.Controls.Decorators.LabelDecoratorRight  */
 10 namespace('Banana.Controls.Decorators').LabelDecoratorRight = Banana.Controls.Decorators.Decorator.extend(
 11 /** @lends Banana.Controls.Decorators.LabelDecoratorRight.prototype */
 12 {
 13 	/**
 14 	 * decorates a custom control with a label positioned at the rightside
 15 	 * 
 16 	 * @param {Banana.UiControl} customControl
 17 	 * @constructs
 18 	 * @extends Banana.Controls.Decorators.Decorator
 19 	 */
 20 	init : function(customControl)
 21 	{
 22 		this._super(customControl);
 23 
 24 		this.addCssClass('BLabelDecoratorRight');
 25 		
 26 		this.customControl = customControl;
 27 		
 28 		this.label = new Banana.Controls.Label();
 29 		this.position = 'left';
 30 		this.label.addCssClass('BLabelDecoratorRightLabel');
 31 		this.addControl(customControl);
 32 		this.addControl(this.label);
 33 		
 34 		//when custom control becomes visible or invisible so does this control
 35 		customControl.bind('onSetVisible',this.getProxy(this.onSetVisible));
 36 	},
 37 
 38 	/**
 39 	 * Invoked when setVisible is called
 40 	 * @param {Event} event 
 41 	 * @param {Mixed} data
 42 	 * @ignore
 43 	 */
 44 	onSetVisible : function(event,data)
 45 	{
 46 		this.setVisible(data);
 47 	},
 48 	
 49 	/**
 50 	 * @override
 51 	 */
 52 	updateDisplay : function()
 53 	{
 54 		this._super();
 55 		this.label.setForControl(this.customControl);
 56 	},
 57 	
 58 	/**
 59 	 * Sets style on label
 60 	 * @param {Object} css
 61 	 */
 62 	setLabelCss : function(css)
 63 	{
 64 		this.label.setCss(css);
 65 		return this;
 66 	},
 67 
 68 	/**
 69 	 * sets data which will be set on the label
 70 	 *
 71 	 * @param {String} d
 72 	 * @return {this} 
 73 	 */
 74 	setData : function(d)
 75 	{
 76 		this.label.setData(d);
 77 		return this;
 78 	},
 79 
 80 	/**
 81 	 * returns data text of label;
 82 	 *
 83 	 * @return {String}
 84 	 */
 85 	getData : function()
 86 	{
 87 		return this.label.getData();
 88 	}
 89 });