/*
Copyright (c) 2007, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
version: 2.3.0
*/
/**
* Provides Attribute configurations.
* @namespace YAHOO.util
* @class Attribute
* @constructor
* @param hash {Object} The intial Attribute.
* @param {YAHOO.util.AttributeProvider} The owner of the Attribute instance.
*/
if (owner) {
}
};
/**
* The name of the attribute.
* @property name
* @type String
*/
/**
* The value of the attribute.
* @property value
* @type String
*/
value: null,
/**
* The owner of the attribute.
* @property owner
* @type YAHOO.util.AttributeProvider
*/
owner: null,
/**
* Whether or not the attribute is read only.
* @property readOnly
* @type Boolean
*/
readOnly: false,
/**
* Whether or not the attribute can only be written once.
* @property writeOnce
* @type Boolean
*/
writeOnce: false,
/**
* The attribute's initial configuration.
* @private
* @property _initialConfig
* @type Object
*/
_initialConfig: null,
/**
* Whether or not the attribute's value has been set.
* @private
* @property _written
* @type Boolean
*/
_written: false,
/**
* The method to use when setting the attribute's value.
* The method recieves the new value as the only argument.
* @property method
* @type Function
*/
method: null,
/**
* The validator to use when setting the attribute's value.
* @property validator
* @type Function
* @return Boolean
*/
validator: null,
/**
* Retrieves the current value of the attribute.
* @method getValue
* @return {any} The current value of the attribute.
*/
getValue: function() {
return this.value;
},
/**
* Sets the value of the attribute and fires beforeChange and change events.
* @method setValue
* @param {Any} value The value to apply to the attribute.
* @param {Boolean} silent If true the change events will not be fired.
* @return {Boolean} Whether or not the value was set.
*/
var beforeRetVal;
var event = {
};
return false; // write not allowed
}
return false; // invalid value
}
if (!silent) {
if (beforeRetVal === false) {
return false;
}
}
if (this.method) {
}
this._written = true;
if (!silent) {
}
return true;
},
/**
* Allows for configuring the Attribute's properties.
* @method configure
* @param {Object} map A key-value map of Attribute properties.
* @param {Boolean} init Whether or not this should become the initial config.
*/
this._written = false; // reset writeOnce
this._initialConfig = this._initialConfig || {};
if (init) {
}
}
}
},
/**
* Resets the value to the initial config value.
* @method resetValue
* @return {Boolean} Whether or not the value was set.
*/
resetValue: function() {
},
/**
* Resets the attribute config to the initial config state.
* @method resetConfig
*/
resetConfig: function() {
this.configure(this._initialConfig);
},
/**
* Resets the value to the current value.
* Useful when values may have gotten out of sync with actual properties.
* @method refresh
* @return {Boolean} Whether or not the value was set.
*/
}
};
(function() {
/*
Copyright (c) 2006, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
*/
/**
* Provides and manages YAHOO.util.Attribute instances
* @namespace YAHOO.util
* @class AttributeProvider
* @uses YAHOO.util.EventProvider
*/
/**
* A key-value map of Attribute configurations
* @property _configs
* @protected (may be used by subclasses and augmentors)
* @private
* @type {Object}
*/
_configs: null,
/**
* Returns the current value of the attribute.
* @method get
* @param {String} key The attribute whose value will be returned.
*/
if (!config) {
return undefined;
}
},
/**
* Sets the value of a config.
* @method set
* @param {String} key The name of the attribute
* @param {Any} value The value to apply to the attribute
* @param {Boolean} silent Whether or not to suppress change events
* @return {Boolean} Whether or not the value was set.
*/
if (!config) {
return false;
}
},
/**
* Returns an array of attribute names.
* @method getAttributeKeys
* @return {Array} An array of attribute names.
*/
getAttributeKeys: function(){
var keys = [];
var config;
}
}
return keys;
},
/**
* Sets multiple attribute values.
* @method setAttributes
* @param {Object} map A key-value map of attributes
* @param {Boolean} silent Whether or not to suppress change events
*/
}
}
},
/**
* Resets the specified attribute's value to its initial value.
* @method resetValue
* @param {String} key The name of the attribute
* @param {Boolean} silent Whether or not to suppress change events
* @return {Boolean} Whether or not the value was set
*/
return true;
}
return false;
},
/**
* Sets the attribute's value to its current value.
* @method refresh
* @param {String | Array} key The attribute(s) to refresh
* @param {Boolean} silent Whether or not to suppress change events
*/
this.getAttributeKeys();
if ( // only set if there is a value and not null
}
}
},
/**
* Adds an Attribute to the AttributeProvider instance.
* @method register
* @param {String} key The attribute's name
* @param {Object} map A key-value map containing the
* attribute's properties.
* @deprecated Use setAttributeConfig
*/
},
/**
* Returns the attribute's properties.
* @method getAttributeConfig
* @param {String} key The attribute's name
* @private
* @return {object} A key-value map containing all of the
* attribute's properties.
*/
getAttributeConfig: function(key) {
var map = {}; // returning a copy to prevent overrides
}
}
return map;
},
/**
* Sets or updates an Attribute instance's properties.
* @method setAttributeConfig
* @param {String} key The attribute's name.
* @param {Object} map A key-value map of attribute properties
* @param {Boolean} init Whether or not this should become the intial config.
*/
} else {
}
},
/**
* Sets or updates an Attribute instance's properties.
* @method configureAttribute
* @param {String} key The attribute's name.
* @param {Object} map A key-value map of attribute properties
* @param {Boolean} init Whether or not this should become the intial config.
* @deprecated Use setAttributeConfig
*/
},
/**
* Resets an attribute to its intial configuration.
* @method resetAttributeConfig
* @param {String} key The attribute's name.
* @private
*/
resetAttributeConfig: function(key){
},
/**
* Fires the attribute's beforeChange event.
* @method fireBeforeChangeEvent
* @param {String} key The attribute's name.
* @param {Obj} e The event object to pass to handlers.
*/
fireBeforeChangeEvent: function(e) {
var type = 'before';
},
/**
* Fires the attribute's change event.
* @method fireChangeEvent
* @param {String} key The attribute's name.
* @param {Obj} e The event object to pass to the handlers.
*/
fireChangeEvent: function(e) {
e.type += 'Change';
}
};
})();
(function() {
// internal shorthand
/**
* Element provides an wrapper object to simplify adding
* event listeners, using dom methods, and managing attributes.
* @module element
* @namespace YAHOO.util
* @requires yahoo, dom, event
* @beta
*/
/**
* Element provides an wrapper object to simplify adding
* event listeners, using dom methods, and managing attributes.
* @class Element
* @uses YAHOO.util.AttributeProvider
* @constructor
* @param el {HTMLElement | String} The html element that
* represents the Element.
* @param {Object} map A key-value map of initial config names and values
*/
}
};
/**
* Dom events supported by the Element instance.
* @property DOM_EVENTS
* @type Object
*/
DOM_EVENTS: null,
/**
* Wrapper for HTMLElement method.
* @method appendChild
* @param {YAHOO.util.Element || HTMLElement} child The element to append.
*/
appendChild: function(child) {
},
/**
* Wrapper for HTMLElement method.
* @method getElementsByTagName
* @param {String} tag The tagName to collect
*/
getElementsByTagName: function(tag) {
},
/**
* Wrapper for HTMLElement method.
* @method hasChildNodes
* @return {Boolean} Whether or not the element has childNodes
*/
hasChildNodes: function() {
},
/**
* Wrapper for HTMLElement method.
* @method insertBefore
* @param {HTMLElement} element The HTMLElement to insert
* @param {HTMLElement} before The HTMLElement to insert
* the element before.
*/
},
/**
* Wrapper for HTMLElement method.
* @method removeChild
* @param {HTMLElement} child The HTMLElement to remove
*/
removeChild: function(child) {
return true;
},
/**
* Wrapper for HTMLElement method.
* @method replaceChild
* @param {HTMLElement} newNode The HTMLElement to insert
* @param {HTMLElement} oldNode The HTMLElement to replace
*/
},
/**
* Registers Element specific attributes.
* @method initAttributes
* @param {Object} map A key-value map of initial attribute configs
*/
initAttributes: function(map) {
},
/**
* Adds a listener for the given event. These may be DOM or
* customEvent listeners. Any event that is fired via fireEvent
* can be listened for. All handlers receive an event object.
* @method addListener
* @param {String} type The name of the event to listen for
* @param {Function} fn The handler to call when the event fires
* @param {Any} obj A variable to pass to the handler
* @param {Object} scope The object to use for the scope of the handler
*/
var self = this;
if ( this.DOM_EVENTS[type] ) {
e.target = e.srcElement;
}
}
this.createEvent(type, this);
}
},
/**
* Alias for addListener
* @method on
* @param {String} type The name of the event to listen for
* @param {Function} fn The function call when the event fires
* @param {Any} obj A variable to pass to the handler
* @param {Object} scope The object to use for the scope of the handler
*/
/**
* Alias for addListener
* @method subscribe
* @param {String} type The name of the event to listen for
* @param {Function} fn The function call when the event fires
* @param {Any} obj A variable to pass to the handler
* @param {Object} scope The object to use for the scope of the handler
*/
/**
* Remove an event listener
* @method removeListener
* @param {String} type The name of the event to listen for
* @param {Function} fn The function call when the event fires
*/
},
/**
* Wrapper for Dom method.
* @method addClass
* @param {String} className The className to add
*/
},
/**
* Wrapper for Dom method.
* @method getElementsByClassName
* @param {String} className The className to collect
* @param {String} tag (optional) The tag to use in
* conjunction with class name
* @return {Array} Array of HTMLElements
*/
this.get('element') );
},
/**
* Wrapper for Dom method.
* @method hasClass
* @param {String} className The className to add
* @return {Boolean} Whether or not the element has the class name
*/
},
/**
* Wrapper for Dom method.
* @method removeClass
* @param {String} className The className to remove
*/
removeClass: function(className) {
},
/**
* Wrapper for Dom method.
* @method replaceClass
* @param {String} oldClassName The className to replace
* @param {String} newClassName The className to add
*/
},
/**
* Wrapper for Dom method.
* @method setStyle
* @param {String} property The style property to set
* @param {String} value The value to apply to the style property
*/
if (!el) {
}
},
/**
* Wrapper for Dom method.
* @method getStyle
* @param {String} property The style property to retrieve
* @return {String} The current value of the property
*/
},
/**
* Apply any queued set calls.
* @method fireQueue
*/
fireQueue: function() {
}
},
/**
* Appends the HTMLElement into either the supplied parentNode.
* @method appendTo
* @param {HTMLElement | Element} parentNode The node to append to
* @param {HTMLElement | Element} before An optional node to insert before
*/
this.fireEvent('beforeAppendTo', {
type: 'beforeAppendTo',
});
if (!element) {
return false;
}
if (!parent) {
return false;
}
if (before) {
} else {
}
}
this.fireEvent('appendTo', {
type: 'appendTo',
});
},
}
},
// need to configure if setting unconfigured HTMLElement attribute
this.setAttributeConfig(key);
}
}
// set based on configOrder
if (map[this._configOrder[i]]) {
}
}
},
if (!el) {
}
return;
}
// set it on the element if not configured and is an HTML attribute
}
},
} else {
}
},
getAttributeKeys: function() {
//add any unconfigured element keys
}
}
return keys;
},
},
}
};
this._configOrder = [];
this.DOM_EVENTS = {
'click': true,
'dblclick': true,
'keydown': true,
'keypress': true,
'keyup': true,
'mousedown': true,
'mousemove': true,
'mouseout': true,
'mouseover': true,
'mouseup': true,
'focus': true,
'blur': true,
'submit': true
};
var isReady = false; // to determine when to init HTMLElement and content
}
isReady = true;
}
if (!isReady) { // otherwise already done
}
}, this, true);
if (!isReady) { // otherwise already done
}
}, this, true);
};
/**
* The HTMLElement the Element instance refers to.
* @config element
* @type HTMLElement
*/
this.setAttributeConfig('element', {
readOnly: true
});
};
this.initAttributes(attr);
this.setAttributes(attr, true);
this.fireQueue();
};
/**
* Sets the value of the property and fires beforeChange and change events.
* @private
* @method _registerHTMLAttr
* @param {YAHOO.util.Element} element The Element instance to
* register the config to.
* @param {String} key The name of the config to register
* @param {Object} map A key-value map of the config's params
*/
};
};
/**
* Fires when the Element's HTMLElement can be retrieved by Id.
* <p>See: <a href="#addListener">Element.addListener</a></p>
* <p><strong>Event fields:</strong><br>
* <code><String> type</code> available<br>
* <code><HTMLElement>
* target</code> the HTMLElement bound to this Element instance<br>
* <p><strong>Usage:</strong><br>
* <code>var handler = function(e) {var target = e.target};<br>
* myTabs.addListener('available', handler);</code></p>
* @event available
*/
/**
* Fires when the Element's HTMLElement subtree is rendered.
* <p>See: <a href="#addListener">Element.addListener</a></p>
* <p><strong>Event fields:</strong><br>
* <code><String> type</code> contentReady<br>
* <code><HTMLElement>
* target</code> the HTMLElement bound to this Element instance<br>
* <p><strong>Usage:</strong><br>
* <code>var handler = function(e) {var target = e.target};<br>
* myTabs.addListener('contentReady', handler);</code></p>
* @event contentReady
*/
})();