Sha256: 0aa96e8a3344d9fef33d82ed795827d8f56210cef63f2a1bef1b6f94d8ef9484

Contents?: true

Size: 1.96 KB

Versions: 5

Compression:

Stored size: 1.96 KB

Contents

/*   RSence
 *   Copyright 2009 Riassence Inc.
 *   http://riassence.com/
 *
 *   You should have received a copy of the GNU General Public License along
 *   with this software package. If not, contact licensing@riassence.com
 */


/*** = Description
  ** HListItems is uses an array-packed list of hash objects as its value.
  ** Each item in the array should have a 'label' and a 'value' key.
  ** The 'label' key of each item is used as the label for the HRadiobutton in the list.
  ** The 'value' key of each item is the value used for the output.
  ** The parent object of a HListItem needs to be a compatible hash, like HRadiobuttonList.
  ***/
HListItems = HValueResponder.extend({
  
  constructor: function( _rect, _parent, _options ){
    this.parent = _parent;
    if (_options instanceof Object) {
      if (_options['valueObj'] !== undefined) {
        _options.valueObj.bind( this );
      }
      else if(_options['value'] !== undefined) {
        this.value = _options.value;
        this.refresh();
      }
    }
  },
  _warningMessage: function(_messageText){
    console.log("Warning; HListItems: "+_messageText);
  },
  
/** = Description
  * Iterates through this.value array and calls
  * the setListItems function of the parent class.
  *
  **/
  refresh: function(){
    if ( this.value instanceof Array ) {
      var _listItems = [],
          _row,
          _label, _value,
          i = 0;
      for ( ; i < this.value.length ; i++ ){
        _row = this.value[i];
        if ( _row instanceof Object ) {
          _label = _row['label'];
          _value = _row['value'];
          if ( _label === undefined || _value === undefined ){
            this._warningMessage( "The value or label of row "+_row+" is undefined (ignored)" );
          }
          _listItems.push( [_value, _label] );
        }
        else {
          this._warningMessage( "The row "+_row+" is not an object (ignored)" );
        }
      }
      this.parent.setListItems( _listItems );
    }
  }
});


Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rsence-2.0.0.10.pre js/controls/lists/listitems/listitems.js
rsence-2.0.0.9.pre js/controls/lists/listitems/listitems.js
rsence-2.0.0.8.pre js/controls/lists/listitems/listitems.js
rsence-2.0.0.7.pre js/controls/lists/listitems/listitems.js
rsence-2.0.0.6.pre js/controls/lists/listitems/listitems.js