PageRenderTime 88ms CodeModel.GetById 18ms app.highlight 63ms RepoModel.GetById 1ms app.codeStats 0ms

/hudson-war/src/main/webapp/scripts/yui/element/element-beta-debug.js

http://github.com/hudson/hudson
JavaScript | 1006 lines | 460 code | 132 blank | 414 comment | 92 complexity | e9c208e2514c75b0b2bd62dbe48f30e1 MD5 | raw file
   1/*
   2Copyright (c) 2008, Yahoo! Inc. All rights reserved.
   3Code licensed under the BSD License:
   4http://developer.yahoo.net/yui/license.txt
   5version: 2.5.1
   6*/
   7/**
   8 * Provides Attribute configurations.
   9 * @namespace YAHOO.util
  10 * @class Attribute
  11 * @constructor
  12 * @param hash {Object} The intial Attribute.
  13 * @param {YAHOO.util.AttributeProvider} The owner of the Attribute instance.
  14 */
  15
  16YAHOO.util.Attribute = function(hash, owner) {
  17    if (owner) { 
  18        this.owner = owner;
  19        this.configure(hash, true);
  20    }
  21};
  22
  23YAHOO.util.Attribute.prototype = {
  24	/**
  25     * The name of the attribute.
  26	 * @property name
  27	 * @type String
  28	 */
  29    name: undefined,
  30    
  31	/**
  32     * The value of the attribute.
  33	 * @property value
  34	 * @type String
  35	 */
  36    value: null,
  37    
  38	/**
  39     * The owner of the attribute.
  40	 * @property owner
  41	 * @type YAHOO.util.AttributeProvider
  42	 */
  43    owner: null,
  44    
  45	/**
  46     * Whether or not the attribute is read only.
  47	 * @property readOnly
  48	 * @type Boolean
  49	 */
  50    readOnly: false,
  51    
  52	/**
  53     * Whether or not the attribute can only be written once.
  54	 * @property writeOnce
  55	 * @type Boolean
  56	 */
  57    writeOnce: false,
  58
  59	/**
  60     * The attribute's initial configuration.
  61     * @private
  62	 * @property _initialConfig
  63	 * @type Object
  64	 */
  65    _initialConfig: null,
  66    
  67	/**
  68     * Whether or not the attribute's value has been set.
  69     * @private
  70	 * @property _written
  71	 * @type Boolean
  72	 */
  73    _written: false,
  74    
  75	/**
  76     * The method to use when setting the attribute's value.
  77     * The method recieves the new value as the only argument.
  78	 * @property method
  79	 * @type Function
  80	 */
  81    method: null,
  82    
  83	/**
  84     * The validator to use when setting the attribute's value.
  85	 * @property validator
  86	 * @type Function
  87     * @return Boolean
  88	 */
  89    validator: null,
  90    
  91    /**
  92     * Retrieves the current value of the attribute.
  93     * @method getValue
  94     * @return {any} The current value of the attribute.
  95     */
  96    getValue: function() {
  97        return this.value;
  98    },
  99    
 100    /**
 101     * Sets the value of the attribute and fires beforeChange and change events.
 102     * @method setValue
 103     * @param {Any} value The value to apply to the attribute.
 104     * @param {Boolean} silent If true the change events will not be fired.
 105     * @return {Boolean} Whether or not the value was set.
 106     */
 107    setValue: function(value, silent) {
 108        var beforeRetVal;
 109        var owner = this.owner;
 110        var name = this.name;
 111        
 112        var event = {
 113            type: name, 
 114            prevValue: this.getValue(),
 115            newValue: value
 116        };
 117        
 118        if (this.readOnly || ( this.writeOnce && this._written) ) {
 119            YAHOO.log( 'setValue ' + name + ', ' +  value +
 120                    ' failed: read only', 'error', 'Attribute');
 121            return false; // write not allowed
 122        }
 123        
 124        if (this.validator && !this.validator.call(owner, value) ) {
 125            YAHOO.log( 'setValue ' + name + ', ' + value +
 126                    ' validation failed', 'error', 'Attribute');
 127            return false; // invalid value
 128        }
 129
 130        if (!silent) {
 131            beforeRetVal = owner.fireBeforeChangeEvent(event);
 132            if (beforeRetVal === false) {
 133                YAHOO.log('setValue ' + name + 
 134                        ' cancelled by beforeChange event', 'info', 'Attribute');
 135                return false;
 136            }
 137        }
 138
 139        if (this.method) {
 140            this.method.call(owner, value);
 141        }
 142        
 143        this.value = value;
 144        this._written = true;
 145        
 146        event.type = name;
 147        
 148        if (!silent) {
 149            this.owner.fireChangeEvent(event);
 150        }
 151        
 152        return true;
 153    },
 154    
 155    /**
 156     * Allows for configuring the Attribute's properties.
 157     * @method configure
 158     * @param {Object} map A key-value map of Attribute properties.
 159     * @param {Boolean} init Whether or not this should become the initial config.
 160     */
 161    configure: function(map, init) {
 162        map = map || {};
 163        this._written = false; // reset writeOnce
 164        this._initialConfig = this._initialConfig || {};
 165        
 166        for (var key in map) {
 167            if ( key && YAHOO.lang.hasOwnProperty(map, key) ) {
 168                this[key] = map[key];
 169                if (init) {
 170                    this._initialConfig[key] = map[key];
 171                }
 172            }
 173        }
 174    },
 175    
 176    /**
 177     * Resets the value to the initial config value.
 178     * @method resetValue
 179     * @return {Boolean} Whether or not the value was set.
 180     */
 181    resetValue: function() {
 182        return this.setValue(this._initialConfig.value);
 183    },
 184    
 185    /**
 186     * Resets the attribute config to the initial config state.
 187     * @method resetConfig
 188     */
 189    resetConfig: function() {
 190        this.configure(this._initialConfig);
 191    },
 192    
 193    /**
 194     * Resets the value to the current value.
 195     * Useful when values may have gotten out of sync with actual properties.
 196     * @method refresh
 197     * @return {Boolean} Whether or not the value was set.
 198     */
 199    refresh: function(silent) {
 200        this.setValue(this.value, silent);
 201    }
 202};
 203
 204(function() {
 205    var Lang = YAHOO.util.Lang;
 206
 207    /*
 208    Copyright (c) 2006, Yahoo! Inc. All rights reserved.
 209    Code licensed under the BSD License:
 210    http://developer.yahoo.net/yui/license.txt
 211    */
 212    
 213    /**
 214     * Provides and manages YAHOO.util.Attribute instances
 215     * @namespace YAHOO.util
 216     * @class AttributeProvider
 217     * @uses YAHOO.util.EventProvider
 218     */
 219    YAHOO.util.AttributeProvider = function() {};
 220
 221    YAHOO.util.AttributeProvider.prototype = {
 222        
 223        /**
 224         * A key-value map of Attribute configurations
 225         * @property _configs
 226         * @protected (may be used by subclasses and augmentors)
 227         * @private
 228         * @type {Object}
 229         */
 230        _configs: null,
 231        /**
 232         * Returns the current value of the attribute.
 233         * @method get
 234         * @param {String} key The attribute whose value will be returned.
 235         */
 236        get: function(key){
 237            this._configs = this._configs || {};
 238            var config = this._configs[key];
 239            
 240            if (!config) {
 241                YAHOO.log(key + ' not found', 'error', 'AttributeProvider');
 242                return undefined;
 243            }
 244            
 245            return config.value;
 246        },
 247        
 248        /**
 249         * Sets the value of a config.
 250         * @method set
 251         * @param {String} key The name of the attribute
 252         * @param {Any} value The value to apply to the attribute
 253         * @param {Boolean} silent Whether or not to suppress change events
 254         * @return {Boolean} Whether or not the value was set.
 255         */
 256        set: function(key, value, silent){
 257            this._configs = this._configs || {};
 258            var config = this._configs[key];
 259            
 260            if (!config) {
 261                YAHOO.log('set failed: ' + key + ' not found',
 262                        'error', 'AttributeProvider');
 263                return false;
 264            }
 265            
 266            return config.setValue(value, silent);
 267        },
 268    
 269        /**
 270         * Returns an array of attribute names.
 271         * @method getAttributeKeys
 272         * @return {Array} An array of attribute names.
 273         */
 274        getAttributeKeys: function(){
 275            this._configs = this._configs;
 276            var keys = [];
 277            var config;
 278            for (var key in this._configs) {
 279                config = this._configs[key];
 280                if ( Lang.hasOwnProperty(this._configs, key) && 
 281                        !Lang.isUndefined(config) ) {
 282                    keys[keys.length] = key;
 283                }
 284            }
 285            
 286            return keys;
 287        },
 288        
 289        /**
 290         * Sets multiple attribute values.
 291         * @method setAttributes
 292         * @param {Object} map  A key-value map of attributes
 293         * @param {Boolean} silent Whether or not to suppress change events
 294         */
 295        setAttributes: function(map, silent){
 296            for (var key in map) {
 297                if ( Lang.hasOwnProperty(map, key) ) {
 298                    this.set(key, map[key], silent);
 299                }
 300            }
 301        },
 302    
 303        /**
 304         * Resets the specified attribute's value to its initial value.
 305         * @method resetValue
 306         * @param {String} key The name of the attribute
 307         * @param {Boolean} silent Whether or not to suppress change events
 308         * @return {Boolean} Whether or not the value was set
 309         */
 310        resetValue: function(key, silent){
 311            this._configs = this._configs || {};
 312            if (this._configs[key]) {
 313                this.set(key, this._configs[key]._initialConfig.value, silent);
 314                return true;
 315            }
 316            return false;
 317        },
 318    
 319        /**
 320         * Sets the attribute's value to its current value.
 321         * @method refresh
 322         * @param {String | Array} key The attribute(s) to refresh
 323         * @param {Boolean} silent Whether or not to suppress change events
 324         */
 325        refresh: function(key, silent){
 326            this._configs = this._configs;
 327            
 328            key = ( ( Lang.isString(key) ) ? [key] : key ) || 
 329                    this.getAttributeKeys();
 330            
 331            for (var i = 0, len = key.length; i < len; ++i) { 
 332                if ( // only set if there is a value and not null
 333                    this._configs[key[i]] && 
 334                    ! Lang.isUndefined(this._configs[key[i]].value) &&
 335                    ! Lang.isNull(this._configs[key[i]].value) ) {
 336                    this._configs[key[i]].refresh(silent);
 337                }
 338            }
 339        },
 340    
 341        /**
 342         * Adds an Attribute to the AttributeProvider instance. 
 343         * @method register
 344         * @param {String} key The attribute's name
 345         * @param {Object} map A key-value map containing the
 346         * attribute's properties.
 347         * @deprecated Use setAttributeConfig
 348         */
 349        register: function(key, map) {
 350            this.setAttributeConfig(key, map);
 351        },
 352        
 353        
 354        /**
 355         * Returns the attribute's properties.
 356         * @method getAttributeConfig
 357         * @param {String} key The attribute's name
 358         * @private
 359         * @return {object} A key-value map containing all of the
 360         * attribute's properties.
 361         */
 362        getAttributeConfig: function(key) {
 363            this._configs = this._configs || {};
 364            var config = this._configs[key] || {};
 365            var map = {}; // returning a copy to prevent overrides
 366            
 367            for (key in config) {
 368                if ( Lang.hasOwnProperty(config, key) ) {
 369                    map[key] = config[key];
 370                }
 371            }
 372    
 373            return map;
 374        },
 375        
 376        /**
 377         * Sets or updates an Attribute instance's properties. 
 378         * @method setAttributeConfig
 379         * @param {String} key The attribute's name.
 380         * @param {Object} map A key-value map of attribute properties
 381         * @param {Boolean} init Whether or not this should become the intial config.
 382         */
 383        setAttributeConfig: function(key, map, init) {
 384            this._configs = this._configs || {};
 385            map = map || {};
 386            if (!this._configs[key]) {
 387                map.name = key;
 388                this._configs[key] = this.createAttribute(map);
 389            } else {
 390                this._configs[key].configure(map, init);
 391            }
 392        },
 393        
 394        /**
 395         * Sets or updates an Attribute instance's properties. 
 396         * @method configureAttribute
 397         * @param {String} key The attribute's name.
 398         * @param {Object} map A key-value map of attribute properties
 399         * @param {Boolean} init Whether or not this should become the intial config.
 400         * @deprecated Use setAttributeConfig
 401         */
 402        configureAttribute: function(key, map, init) {
 403            this.setAttributeConfig(key, map, init);
 404        },
 405        
 406        /**
 407         * Resets an attribute to its intial configuration. 
 408         * @method resetAttributeConfig
 409         * @param {String} key The attribute's name.
 410         * @private
 411         */
 412        resetAttributeConfig: function(key){
 413            this._configs = this._configs || {};
 414            this._configs[key].resetConfig();
 415        },
 416        
 417        // wrapper for EventProvider.subscribe
 418        // to create events on the fly
 419        subscribe: function(type, callback) {
 420            this._events = this._events || {};
 421
 422            if ( !(type in this._events) ) {
 423                this._events[type] = this.createEvent(type);
 424            }
 425
 426            YAHOO.util.EventProvider.prototype.subscribe.apply(this, arguments);
 427        },
 428
 429        on: function() {
 430            this.subscribe.apply(this, arguments);
 431        },
 432
 433        addListener: function() {
 434            this.subscribe.apply(this, arguments);
 435        },
 436
 437        /**
 438         * Fires the attribute's beforeChange event. 
 439         * @method fireBeforeChangeEvent
 440         * @param {String} key The attribute's name.
 441         * @param {Obj} e The event object to pass to handlers.
 442         */
 443        fireBeforeChangeEvent: function(e) {
 444            var type = 'before';
 445            type += e.type.charAt(0).toUpperCase() + e.type.substr(1) + 'Change';
 446            e.type = type;
 447            return this.fireEvent(e.type, e);
 448        },
 449        
 450        /**
 451         * Fires the attribute's change event. 
 452         * @method fireChangeEvent
 453         * @param {String} key The attribute's name.
 454         * @param {Obj} e The event object to pass to the handlers.
 455         */
 456        fireChangeEvent: function(e) {
 457            e.type += 'Change';
 458            return this.fireEvent(e.type, e);
 459        },
 460
 461        createAttribute: function(map) {
 462            return new YAHOO.util.Attribute(map, this);
 463        }
 464    };
 465    
 466    YAHOO.augment(YAHOO.util.AttributeProvider, YAHOO.util.EventProvider);
 467})();
 468
 469(function() {
 470// internal shorthand
 471var Dom = YAHOO.util.Dom,
 472    AttributeProvider = YAHOO.util.AttributeProvider;
 473
 474/**
 475 * Element provides an wrapper object to simplify adding
 476 * event listeners, using dom methods, and managing attributes. 
 477 * @module element
 478 * @namespace YAHOO.util
 479 * @requires yahoo, dom, event
 480 * @beta
 481 */
 482
 483/**
 484 * Element provides an wrapper object to simplify adding
 485 * event listeners, using dom methods, and managing attributes. 
 486 * @class Element
 487 * @uses YAHOO.util.AttributeProvider
 488 * @constructor
 489 * @param el {HTMLElement | String} The html element that 
 490 * represents the Element.
 491 * @param {Object} map A key-value map of initial config names and values
 492 */
 493YAHOO.util.Element = function(el, map) {
 494    if (arguments.length) {
 495        this.init(el, map);
 496    }
 497};
 498
 499YAHOO.util.Element.prototype = {
 500    /**
 501     * Dom events supported by the Element instance.
 502     * @property DOM_EVENTS
 503     * @type Object
 504     */
 505    DOM_EVENTS: null,
 506
 507    /**
 508     * Wrapper for HTMLElement method.
 509     * @method appendChild
 510     * @param {YAHOO.util.Element || HTMLElement} child The element to append. 
 511     */
 512    appendChild: function(child) {
 513        child = child.get ? child.get('element') : child;
 514        this.get('element').appendChild(child);
 515    },
 516    
 517    /**
 518     * Wrapper for HTMLElement method.
 519     * @method getElementsByTagName
 520     * @param {String} tag The tagName to collect
 521     */
 522    getElementsByTagName: function(tag) {
 523        return this.get('element').getElementsByTagName(tag);
 524    },
 525    
 526    /**
 527     * Wrapper for HTMLElement method.
 528     * @method hasChildNodes
 529     * @return {Boolean} Whether or not the element has childNodes
 530     */
 531    hasChildNodes: function() {
 532        return this.get('element').hasChildNodes();
 533    },
 534    
 535    /**
 536     * Wrapper for HTMLElement method.
 537     * @method insertBefore
 538     * @param {HTMLElement} element The HTMLElement to insert
 539     * @param {HTMLElement} before The HTMLElement to insert
 540     * the element before.
 541     */
 542    insertBefore: function(element, before) {
 543        element = element.get ? element.get('element') : element;
 544        before = (before && before.get) ? before.get('element') : before;
 545        
 546        this.get('element').insertBefore(element, before);
 547    },
 548    
 549    /**
 550     * Wrapper for HTMLElement method.
 551     * @method removeChild
 552     * @param {HTMLElement} child The HTMLElement to remove
 553     */
 554    removeChild: function(child) {
 555        child = child.get ? child.get('element') : child;
 556        this.get('element').removeChild(child);
 557        return true;
 558    },
 559    
 560    /**
 561     * Wrapper for HTMLElement method.
 562     * @method replaceChild
 563     * @param {HTMLElement} newNode The HTMLElement to insert
 564     * @param {HTMLElement} oldNode The HTMLElement to replace
 565     */
 566    replaceChild: function(newNode, oldNode) {
 567        newNode = newNode.get ? newNode.get('element') : newNode;
 568        oldNode = oldNode.get ? oldNode.get('element') : oldNode;
 569        return this.get('element').replaceChild(newNode, oldNode);
 570    },
 571
 572    
 573    /**
 574     * Registers Element specific attributes.
 575     * @method initAttributes
 576     * @param {Object} map A key-value map of initial attribute configs
 577     */
 578    initAttributes: function(map) {
 579    },
 580
 581    /**
 582     * Adds a listener for the given event.  These may be DOM or 
 583     * customEvent listeners.  Any event that is fired via fireEvent
 584     * can be listened for.  All handlers receive an event object. 
 585     * @method addListener
 586     * @param {String} type The name of the event to listen for
 587     * @param {Function} fn The handler to call when the event fires
 588     * @param {Any} obj A variable to pass to the handler
 589     * @param {Object} scope The object to use for the scope of the handler 
 590     */
 591    addListener: function(type, fn, obj, scope) {
 592        var el = this.get('element');
 593        scope = scope || this;
 594        
 595        el = this.get('id') || el;
 596        var self = this; 
 597        if (!this._events[type]) { // create on the fly
 598            if ( this.DOM_EVENTS[type] ) {
 599                YAHOO.util.Event.addListener(el, type, function(e) {
 600                    if (e.srcElement && !e.target) { // supplement IE with target
 601                        e.target = e.srcElement;
 602                    }
 603                    self.fireEvent(type, e);
 604                }, obj, scope);
 605            }
 606            
 607            this.createEvent(type, this);
 608        }
 609        
 610        YAHOO.util.EventProvider.prototype.subscribe.apply(this, arguments); // notify via customEvent
 611    },
 612    
 613    
 614    /**
 615     * Alias for addListener
 616     * @method on
 617     * @param {String} type The name of the event to listen for
 618     * @param {Function} fn The function call when the event fires
 619     * @param {Any} obj A variable to pass to the handler
 620     * @param {Object} scope The object to use for the scope of the handler 
 621     */
 622    on: function() { this.addListener.apply(this, arguments); },
 623    
 624    /**
 625     * Alias for addListener
 626     * @method subscribe
 627     * @param {String} type The name of the event to listen for
 628     * @param {Function} fn The function call when the event fires
 629     * @param {Any} obj A variable to pass to the handler
 630     * @param {Object} scope The object to use for the scope of the handler 
 631     */
 632    subscribe: function() { this.addListener.apply(this, arguments); },
 633    
 634    /**
 635     * Remove an event listener
 636     * @method removeListener
 637     * @param {String} type The name of the event to listen for
 638     * @param {Function} fn The function call when the event fires
 639     */
 640    removeListener: function(type, fn) {
 641        this.unsubscribe.apply(this, arguments);
 642    },
 643    
 644    /**
 645     * Wrapper for Dom method.
 646     * @method addClass
 647     * @param {String} className The className to add
 648     */
 649    addClass: function(className) {
 650        Dom.addClass(this.get('element'), className);
 651    },
 652    
 653    /**
 654     * Wrapper for Dom method.
 655     * @method getElementsByClassName
 656     * @param {String} className The className to collect
 657     * @param {String} tag (optional) The tag to use in
 658     * conjunction with class name
 659     * @return {Array} Array of HTMLElements
 660     */
 661    getElementsByClassName: function(className, tag) {
 662        return Dom.getElementsByClassName(className, tag,
 663                this.get('element') );
 664    },
 665    
 666    /**
 667     * Wrapper for Dom method.
 668     * @method hasClass
 669     * @param {String} className The className to add
 670     * @return {Boolean} Whether or not the element has the class name
 671     */
 672    hasClass: function(className) {
 673        return Dom.hasClass(this.get('element'), className); 
 674    },
 675    
 676    /**
 677     * Wrapper for Dom method.
 678     * @method removeClass
 679     * @param {String} className The className to remove
 680     */
 681    removeClass: function(className) {
 682        return Dom.removeClass(this.get('element'), className);
 683    },
 684    
 685    /**
 686     * Wrapper for Dom method.
 687     * @method replaceClass
 688     * @param {String} oldClassName The className to replace
 689     * @param {String} newClassName The className to add
 690     */
 691    replaceClass: function(oldClassName, newClassName) {
 692        return Dom.replaceClass(this.get('element'), 
 693                oldClassName, newClassName);
 694    },
 695    
 696    /**
 697     * Wrapper for Dom method.
 698     * @method setStyle
 699     * @param {String} property The style property to set
 700     * @param {String} value The value to apply to the style property
 701     */
 702    setStyle: function(property, value) {
 703        var el = this.get('element');
 704        if (!el) {
 705            return this._queue[this._queue.length] = ['setStyle', arguments];
 706        }
 707
 708        return Dom.setStyle(el,  property, value); // TODO: always queuing?
 709    },
 710    
 711    /**
 712     * Wrapper for Dom method.
 713     * @method getStyle
 714     * @param {String} property The style property to retrieve
 715     * @return {String} The current value of the property
 716     */
 717    getStyle: function(property) {
 718        return Dom.getStyle(this.get('element'),  property);
 719    },
 720    
 721    /**
 722     * Apply any queued set calls.
 723     * @method fireQueue
 724     */
 725    fireQueue: function() {
 726        var queue = this._queue;
 727        for (var i = 0, len = queue.length; i < len; ++i) {
 728            this[queue[i][0]].apply(this, queue[i][1]);
 729        }
 730    },
 731    
 732    /**
 733     * Appends the HTMLElement into either the supplied parentNode.
 734     * @method appendTo
 735     * @param {HTMLElement | Element} parentNode The node to append to
 736     * @param {HTMLElement | Element} before An optional node to insert before
 737     */
 738    appendTo: function(parent, before) {
 739        parent = (parent.get) ?  parent.get('element') : Dom.get(parent);
 740        
 741        this.fireEvent('beforeAppendTo', {
 742            type: 'beforeAppendTo',
 743            target: parent
 744        });
 745        
 746        
 747        before = (before && before.get) ? 
 748                before.get('element') : Dom.get(before);
 749        var element = this.get('element');
 750        
 751        if (!element) {
 752            YAHOO.log('appendTo failed: element not available',
 753                    'error', 'Element');
 754            return false;
 755        }
 756        
 757        if (!parent) {
 758            YAHOO.log('appendTo failed: parent not available',
 759                    'error', 'Element');
 760            return false;
 761        }
 762        
 763        if (element.parent != parent) {
 764            if (before) {
 765                parent.insertBefore(element, before);
 766            } else {
 767                parent.appendChild(element);
 768            }
 769        }
 770        
 771        YAHOO.log(element + 'appended to ' + parent);
 772        
 773        this.fireEvent('appendTo', {
 774            type: 'appendTo',
 775            target: parent
 776        });
 777    },
 778    
 779    get: function(key) {
 780        var configs = this._configs || {};
 781        var el = configs.element; // avoid loop due to 'element'
 782        if (el && !configs[key] && !YAHOO.lang.isUndefined(el.value[key]) ) {
 783            return el.value[key];
 784        }
 785
 786        return AttributeProvider.prototype.get.call(this, key);
 787    },
 788
 789    setAttributes: function(map, silent){
 790        var el = this.get('element');
 791        for (var key in map) {
 792            // need to configure if setting unconfigured HTMLElement attribute 
 793            if ( !this._configs[key] && !YAHOO.lang.isUndefined(el[key]) ) {
 794                this.setAttributeConfig(key);
 795            }
 796        }
 797
 798        // set based on configOrder
 799        for (var i = 0, len = this._configOrder.length; i < len; ++i) {
 800            if (map[this._configOrder[i]] !== undefined) {
 801                this.set(this._configOrder[i], map[this._configOrder[i]], silent);
 802            }
 803        }
 804    },
 805
 806    set: function(key, value, silent) {
 807        var el = this.get('element');
 808        if (!el) {
 809            this._queue[this._queue.length] = ['set', arguments];
 810            if (this._configs[key]) {
 811                this._configs[key].value = value; // so "get" works while queueing
 812            
 813            }
 814            return;
 815        }
 816        
 817        // set it on the element if not configured and is an HTML attribute
 818        if ( !this._configs[key] && !YAHOO.lang.isUndefined(el[key]) ) {
 819            _registerHTMLAttr.call(this, key);
 820        }
 821
 822        return AttributeProvider.prototype.set.apply(this, arguments);
 823    },
 824    
 825    setAttributeConfig: function(key, map, init) {
 826        var el = this.get('element');
 827
 828        if (el && !this._configs[key] && !YAHOO.lang.isUndefined(el[key]) ) {
 829            _registerHTMLAttr.call(this, key, map);
 830        } else {
 831            AttributeProvider.prototype.setAttributeConfig.apply(this, arguments);
 832        }
 833        this._configOrder.push(key);
 834    },
 835    
 836    getAttributeKeys: function() {
 837        var el = this.get('element');
 838        var keys = AttributeProvider.prototype.getAttributeKeys.call(this);
 839        
 840        //add any unconfigured element keys
 841        for (var key in el) {
 842            if (!this._configs[key]) {
 843                keys[key] = keys[key] || el[key];
 844            }
 845        }
 846        
 847        return keys;
 848    },
 849
 850    createEvent: function(type, scope) {
 851        this._events[type] = true;
 852        AttributeProvider.prototype.createEvent.apply(this, arguments);
 853    },
 854    
 855    init: function(el, attr) {
 856        _initElement.apply(this, arguments); 
 857    }
 858};
 859
 860var _initElement = function(el, attr) {
 861    this._queue = this._queue || [];
 862    this._events = this._events || {};
 863    this._configs = this._configs || {};
 864    this._configOrder = []; 
 865    attr = attr || {};
 866    attr.element = attr.element || el || null;
 867
 868    this.DOM_EVENTS = {
 869        'click': true,
 870        'dblclick': true,
 871        'keydown': true,
 872        'keypress': true,
 873        'keyup': true,
 874        'mousedown': true,
 875        'mousemove': true,
 876        'mouseout': true, 
 877        'mouseover': true, 
 878        'mouseup': true,
 879        'focus': true,
 880        'blur': true,
 881        'submit': true
 882    };
 883
 884    var isReady = false;  // to determine when to init HTMLElement and content
 885
 886    if (YAHOO.lang.isString(el) ) { // defer until available/ready
 887        _registerHTMLAttr.call(this, 'id', { value: attr.element });
 888    }
 889
 890    if (Dom.get(el)) {
 891        isReady = true;
 892        _initHTMLElement.call(this, attr);
 893        _initContent.call(this, attr);
 894    } 
 895
 896    YAHOO.util.Event.onAvailable(attr.element, function() {
 897        if (!isReady) { // otherwise already done
 898            _initHTMLElement.call(this, attr);
 899        }
 900
 901        this.fireEvent('available', { type: 'available', target: attr.element });  
 902    }, this, true);
 903    
 904    YAHOO.util.Event.onContentReady(attr.element, function() {
 905        if (!isReady) { // otherwise already done
 906            _initContent.call(this, attr);
 907        }
 908        this.fireEvent('contentReady', { type: 'contentReady', target: attr.element });  
 909    }, this, true);
 910};
 911
 912var _initHTMLElement = function(attr) {
 913    /**
 914     * The HTMLElement the Element instance refers to.
 915     * @attribute element
 916     * @type HTMLElement
 917     */
 918    this.setAttributeConfig('element', {
 919        value: Dom.get(attr.element),
 920        readOnly: true
 921     });
 922};
 923
 924var _initContent = function(attr) {
 925    this.initAttributes(attr);
 926    this.setAttributes(attr, true);
 927    this.fireQueue();
 928
 929};
 930
 931/**
 932 * Sets the value of the property and fires beforeChange and change events.
 933 * @private
 934 * @method _registerHTMLAttr
 935 * @param {YAHOO.util.Element} element The Element instance to
 936 * register the config to.
 937 * @param {String} key The name of the config to register
 938 * @param {Object} map A key-value map of the config's params
 939 */
 940var _registerHTMLAttr = function(key, map) {
 941    var el = this.get('element');
 942    map = map || {};
 943    map.name = key;
 944    map.method = map.method || function(value) {
 945        el[key] = value;
 946    };
 947    map.value = map.value || el[key];
 948    this._configs[key] = new YAHOO.util.Attribute(map, this);
 949};
 950
 951/**
 952 * Fires when the Element's HTMLElement can be retrieved by Id.
 953 * <p>See: <a href="#addListener">Element.addListener</a></p>
 954 * <p><strong>Event fields:</strong><br>
 955 * <code>&lt;String&gt; type</code> available<br>
 956 * <code>&lt;HTMLElement&gt;
 957 * target</code> the HTMLElement bound to this Element instance<br>
 958 * <p><strong>Usage:</strong><br>
 959 * <code>var handler = function(e) {var target = e.target};<br>
 960 * myTabs.addListener('available', handler);</code></p>
 961 * @event available
 962 */
 963 
 964/**
 965 * Fires when the Element's HTMLElement subtree is rendered.
 966 * <p>See: <a href="#addListener">Element.addListener</a></p>
 967 * <p><strong>Event fields:</strong><br>
 968 * <code>&lt;String&gt; type</code> contentReady<br>
 969 * <code>&lt;HTMLElement&gt;
 970 * target</code> the HTMLElement bound to this Element instance<br>
 971 * <p><strong>Usage:</strong><br>
 972 * <code>var handler = function(e) {var target = e.target};<br>
 973 * myTabs.addListener('contentReady', handler);</code></p>
 974 * @event contentReady
 975 */
 976
 977/**
 978 * Fires before the Element is appended to another Element.
 979 * <p>See: <a href="#addListener">Element.addListener</a></p>
 980 * <p><strong>Event fields:</strong><br>
 981 * <code>&lt;String&gt; type</code> beforeAppendTo<br>
 982 * <code>&lt;HTMLElement/Element&gt;
 983 * target</code> the HTMLElement/Element being appended to 
 984 * <p><strong>Usage:</strong><br>
 985 * <code>var handler = function(e) {var target = e.target};<br>
 986 * myTabs.addListener('beforeAppendTo', handler);</code></p>
 987 * @event beforeAppendTo
 988 */
 989
 990/**
 991 * Fires after the Element is appended to another Element.
 992 * <p>See: <a href="#addListener">Element.addListener</a></p>
 993 * <p><strong>Event fields:</strong><br>
 994 * <code>&lt;String&gt; type</code> appendTo<br>
 995 * <code>&lt;HTMLElement/Element&gt;
 996 * target</code> the HTMLElement/Element being appended to 
 997 * <p><strong>Usage:</strong><br>
 998 * <code>var handler = function(e) {var target = e.target};<br>
 999 * myTabs.addListener('appendTo', handler);</code></p>
1000 * @event appendTo
1001 */
1002
1003YAHOO.augment(YAHOO.util.Element, AttributeProvider);
1004})();
1005
1006YAHOO.register("element", YAHOO.util.Element, {version: "2.5.1", build: "984"});