js/lists/radiobuttonlist/radiobuttonlist.js in rsence-2.1.11 vs js/lists/radiobuttonlist/radiobuttonlist.js in rsence-2.2.0

- old
+ new

@@ -9,13 +9,14 @@ /*** = Description ** HRadiobuttonList expects the setListItems to be set. See HListItems. ** The value of the instance is the selected key in the listItems. ***/ var//RSence.Lists -HRadioButtonList = HControl.extend({ +HRadioButtonList = HListItemControl.extend({ drawSubviews: function(){ - this.setStyle('border','1px solid #999'); + this.setStyle('border','1px solid #999999'); + this.setStyle('border-radius','3px'); this.setStyle('overflow-y','auto'); }, listItems: [], listItemViews: [], @@ -30,10 +31,11 @@ * The value is mapped to the value of the HRadiobuttonList * instance when its HRadiobutton instance is selected. * **/ setListItems: function(_listItems){ + _listItems = this._cleanListItems(_listItems); var _listItem, _value, _label, _radioButton, i = 0; @@ -59,11 +61,12 @@ createComponent: function( i, _label ){ return HRadiobutton.nu( [ 4, (i*23)+4, null, 23, 4, null ], this, { - label: _label + label: _label, + enabled: this.enabled } ); }, _listItemResponder: null, @@ -81,43 +84,56 @@ this._listItemResponder.die(); this._listItemResponder = null; } this.radioButtonIndexValue && this.radioButtonIndexValue.die(); this.listItems = null; - for(var i=0;i<this.listItemViews.length;i++){ - this.listItemViews[i].die(); + if( this.listItemViews ){ + for(var i=0;i<this.listItemViews.length;i++){ + this.listItemViews[i].die(); + } } this.listItemViews = null; this.radioButtonIndexValue && this.radioButtonIndexValue.die(); this.base(); }, radioButtonIndexValue: false, radioButtonResponder: false, + setEnabled: function(_state){ + this.base(_state); + if(!this['listItemViews']){ return; } + for(var i=0;i<this.listItems.length;i++){ + this.listItemViews[i].setEnabled(_state) + } + }, /** = Description * * **/ RadioButtonIndexResponder: HValueResponder.extend({ constructor: function( _parent, _valueObj ){ this.parent = _parent; }, refresh: function(){ - var _listItems = this.parent.listItems; + var + _listItems = this.parent.listItems, + _value; if(_listItems === undefined || _listItems === null){ return; } if(_listItems[ this.value ] !== undefined){ - this.parent.setValue( _listItems[ this.value ][0] ); + _value = _listItems[ this.value ]; + this.parent.setValue( _value[0] ); } } }), refreshValue: function(){ var _value = this.value; if ( this.listItems && this.listItems.length !== 0 && this['valueMatrix'] !== undefined ) { + // debugger; if ( this.radioButtonResponder === false ){ this.radioButtonIndexValue = HValue.nu( false, 0 ); this.radioButtonIndexValue.bind( this.valueMatrix ); this.radioButtonResponder = this.RadioButtonIndexResponder.nu( this ); this.radioButtonIndexValue.bind( this.radioButtonResponder );