Index: openacs-4/packages/ajaxhelper/www/resources/yui/container/container-debug.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/resources/yui/container/container-debug.js,v diff -u -r1.1 -r1.2 --- openacs-4/packages/ajaxhelper/www/resources/yui/container/container-debug.js 21 Oct 2006 06:14:57 -0000 1.1 +++ openacs-4/packages/ajaxhelper/www/resources/yui/container/container-debug.js 25 Dec 2006 16:40:01 -0000 1.2 @@ -2,13 +2,15 @@ Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt -Version 0.11.3 +version 0.12.1 */ /** -* Config is a utility used within an object to allow the implementer to maintain a list of local configuration properties and listen for changes to those properties dynamically using CustomEvent. The initial values are also maintained so that the configuration can be reset at any given point to its initial state. -* @param {object} owner The owner object to which this Config object belongs +* Config is a utility used within an Object to allow the implementer to maintain a list of local configuration properties and listen for changes to those properties dynamically using CustomEvent. The initial values are also maintained so that the configuration can be reset at any given point to its initial state. +* @namespace YAHOO.util +* @class Config * @constructor +* @param {Object} owner The owner Object to which this Config Object belongs */ YAHOO.util.Config = function(owner) { if (owner) { @@ -19,116 +21,28 @@ }; YAHOO.util.Config.prototype = { - + /** - * Object reference to the owner of this Config object - * @type object + * Object reference to the owner of this Config Object + * @property owner + * @type Object */ owner : null, /** - * Object reference to the owner of this Config object - * args: key, value - * @type YAHOO.util.CustomEvent - */ - configChangedEvent : null, - - /** * Boolean flag that specifies whether a queue is currently being executed - * @type boolean + * @property queueInProgress + * @type Boolean */ queueInProgress : false, - /** - * Adds a property to the Config object's private config hash. - * @param {string} key The configuration property's name - * @param {object} propertyObject The object containing all of this property's arguments - */ - addProperty : function(key, propertyObject){}, /** - * Returns a key-value configuration map of the values currently set in the Config object. - * @return {object} The current config, represented in a key-value map + * Validates that the value passed in is a Boolean. + * @method checkBoolean + * @param {Object} val The value to validate + * @return {Boolean} true, if the value is valid */ - getConfig : function(){}, - - /** - * Returns the value of specified property. - * @param {key} The name of the property - * @return {object} The value of the specified property - */ - getProperty : function(key){}, - - /** - * Resets the specified property's value to its initial value. - * @param {key} The name of the property - */ - resetProperty : function(key){}, - - /** - * Sets the value of a property. If the silent property is passed as true, the property's event will not be fired. - * @param {key} The name of the property - * @param {value} The value to set the property to - * @param {boolean} Whether the value should be set silently, without firing the property event. - * @return {boolean} true, if the set was successful, false if it failed. - */ - setProperty : function(key,value,silent){}, - - /** - * Sets the value of a property and queues its event to execute. If the event is already scheduled to execute, it is - * moved from its current position to the end of the queue. - * @param {key} The name of the property - * @param {value} The value to set the property to - * @return {boolean} true, if the set was successful, false if it failed. - */ - queueProperty : function(key,value){}, - - /** - * Fires the event for a property using the property's current value. - * @param {key} The name of the property - */ - refireEvent : function(key){}, - - /** - * Applies a key-value object literal to the configuration, replacing any existing values, and queueing the property events. - * Although the values will be set, fireQueue() must be called for their associated events to execute. - * @param {object} userConfig The configuration object literal - * @param {boolean} init When set to true, the initialConfig will be set to the userConfig passed in, so that calling a reset will reset the properties to the passed values. - */ - applyConfig : function(userConfig,init){}, - - /** - * Refires the events for all configuration properties using their current values. - */ - refresh : function(){}, - - /** - * Fires the normalized list of queued property change events - */ - fireQueue : function(){}, - - /** - * Subscribes an external handler to the change event for any given property. - * @param {string} key The property name - * @param {Function} handler The handler function to use subscribe to the property's event - * @param {object} obj The object to use for scoping the event handler (see CustomEvent documentation) - * @param {boolean} override Optional. If true, will override "this" within the handler to map to the scope object passed into the method. - */ - subscribeToConfigEvent : function(key,handler,obj,override){}, - - /** - * Unsubscribes an external handler from the change event for any given property. - * @param {string} key The property name - * @param {Function} handler The handler function to use subscribe to the property's event - * @param {object} obj The object to use for scoping the event handler (see CustomEvent documentation) - */ - unsubscribeFromConfigEvent: function(key,handler,obj){}, - - /** - * Validates that the value passed in is a boolean. - * @param {object} val The value to validate - * @return {boolean} true, if the value is valid - */ checkBoolean: function(val) { if (typeof val == 'boolean') { return true; @@ -139,8 +53,9 @@ /** * Validates that the value passed in is a number. - * @param {object} val The value to validate - * @return {boolean} true, if the value is valid + * @method checkNumber + * @param {Object} val The value to validate + * @return {Boolean} true, if the value is valid */ checkNumber: function(val) { if (isNaN(val)) { @@ -153,43 +68,77 @@ /** -* Initializes the configuration object and all of its local members. -* @param {object} owner The owner object to which this Config object belongs +* Initializes the configuration Object and all of its local members. +* @method init +* @param {Object} owner The owner Object to which this Config Object belongs */ YAHOO.util.Config.prototype.init = function(owner) { this.owner = owner; + + /** + * Object reference to the owner of this Config Object + * @event configChangedEvent + */ this.configChangedEvent = new YAHOO.util.CustomEvent("configChanged"); this.queueInProgress = false; /* Private Members */ + /** + * Maintains the local collection of configuration property objects and their specified values + * @property config + * @private + * @type Object + */ var config = {}; + + /** + * Maintains the local collection of configuration property objects as they were initially applied. + * This object is used when resetting a property. + * @property initialConfig + * @private + * @type Object + */ var initialConfig = {}; + + /** + * Maintains the local, normalized CustomEvent queue + * @property eventQueue + * @private + * @type Object + */ var eventQueue = []; /** + * Fires a configuration property event using the specified value. + * @method fireEvent * @private - * Fires a configuration property event using the specified value. - * @param {string} key The configuration property's name - * @param {value} object The value of the correct type for the property - */ + * @param {String} key The configuration property's name + * @param {value} Object The value of the correct type for the property + */ var fireEvent = function( key, value ) { YAHOO.log("Firing Config event: " + key + "=" + value, "info"); - + key = key.toLowerCase(); var property = config[key]; if (typeof property != 'undefined' && property.event) { property.event.fire(value); - } + } }; /* End Private Members */ + /** + * Adds a property to the Config Object's private config hash. + * @method addProperty + * @param {String} key The configuration property's name + * @param {Object} propertyObject The Object containing all of this property's arguments + */ this.addProperty = function( key, propertyObject ) { key = key.toLowerCase(); - + YAHOO.log("Added property: " + key, "info"); config[key] = propertyObject; @@ -202,25 +151,36 @@ } this.setProperty(key, propertyObject.value, true); - + if (! propertyObject.suppressEvent) { this.queueProperty(key, propertyObject.value); } }; + /** + * Returns a key-value configuration map of the values currently set in the Config Object. + * @method getConfig + * @return {Object} The current config, represented in a key-value map + */ this.getConfig = function() { var cfg = {}; - + for (var prop in config) { var property = config[prop]; if (typeof property != 'undefined' && property.event) { cfg[prop] = property.value; } } - + return cfg; }; + /** + * Returns the value of specified property. + * @method getProperty + * @param {String} key The name of the property + * @return {Object} The value of the specified property + */ this.getProperty = function(key) { key = key.toLowerCase(); @@ -232,24 +192,41 @@ } }; + /** + * Resets the specified property's value to its initial value. + * @method resetProperty + * @param {String} key The name of the property + * @return {Boolean} True is the property was reset, false if not + */ this.resetProperty = function(key) { key = key.toLowerCase(); var property = config[key]; if (typeof property != 'undefined' && property.event) { - this.setProperty(key, initialConfig[key].value); + if (initialConfig[key] && initialConfig[key] != 'undefined') { + this.setProperty(key, initialConfig[key]); + } + return true; } else { - return undefined; + return false; } }; + /** + * Sets the value of a property. If the silent property is passed as true, the property's event will not be fired. + * @method setProperty + * @param {String} key The name of the property + * @param {String} value The value to set the property to + * @param {Boolean} silent Whether the value should be set silently, without firing the property event. + * @return {Boolean} True, if the set was successful, false if it failed. + */ this.setProperty = function(key, value, silent) { key = key.toLowerCase(); - + YAHOO.log("setProperty: " + key + "=" + value, "info"); if (this.queueInProgress && ! silent) { - this.queueProperty(key,value); // Currently running through a queue... + this.queueProperty(key,value); // Currently running through a queue... return true; } else { var property = config[key]; @@ -270,13 +247,21 @@ } }; + /** + * Sets the value of a property and queues its event to execute. If the event is already scheduled to execute, it is + * moved from its current position to the end of the queue. + * @method queueProperty + * @param {String} key The name of the property + * @param {String} value The value to set the property to + * @return {Boolean} true, if the set was successful, false if it failed. + */ this.queueProperty = function(key, value) { key = key.toLowerCase(); YAHOO.log("queueProperty: " + key + "=" + value, "info"); var property = config[key]; - + if (typeof property != 'undefined' && property.event) { if (typeof value != 'undefined' && property.validator && ! property.validator(value)) { // validator return false; @@ -296,7 +281,7 @@ if (queueItem) { var queueItemKey = queueItem[0]; var queueItemValue = queueItem[1]; - + if (queueItemKey.toLowerCase() == key) { // found a dupe... push to end of queue, null current item, and break eventQueue[i] = null; @@ -306,7 +291,7 @@ } } } - + if (! foundDuplicate && typeof value != 'undefined') { // this is a refire, or a new property in the queue eventQueue.push([key, value]); } @@ -322,7 +307,7 @@ if (queueItemCheck) { var queueItemCheckKey = queueItemCheck[0]; var queueItemCheckValue = queueItemCheck[1]; - + if ( queueItemCheckKey.toLowerCase() == supercedesCheck.toLowerCase() ) { eventQueue.push([queueItemCheckKey, queueItemCheckValue]); eventQueue[q] = null; @@ -332,7 +317,7 @@ } } } - + YAHOO.log("Config event queue: " + this.outputEventQueue(), "info"); return true; @@ -341,6 +326,11 @@ } }; + /** + * Fires the event for a property using the property's current value. + * @method refireEvent + * @param {String} key The name of the property + */ this.refireEvent = function(key) { key = key.toLowerCase(); @@ -354,6 +344,13 @@ } }; + /** + * Applies a key-value Object literal to the configuration, replacing any existing values, and queueing the property events. + * Although the values will be set, fireQueue() must be called for their associated events to execute. + * @method applyConfig + * @param {Object} userConfig The configuration Object literal + * @param {Boolean} init When set to true, the initialConfig will be set to the userConfig passed in, so that calling a reset will reset the properties to the passed values. + */ this.applyConfig = function(userConfig, init) { if (init) { initialConfig = userConfig; @@ -363,31 +360,48 @@ } }; + /** + * Refires the events for all configuration properties using their current values. + * @method refresh + */ this.refresh = function() { for (var prop in config) { this.refireEvent(prop); } }; + /** + * Fires the normalized list of queued property change events + * @method fireQueue + */ this.fireQueue = function() { this.queueInProgress = true; for (var i=0;iOR -* @param {Element} el The element representing the Module -* @param {object} userConfig The configuration object literal containing the configuration that should be set for this module. See configuration documentation for more details. +* @namespace YAHOO.widget +* @class Module * @constructor +* @param {String} el The element ID representing the Module OR +* @param {HTMLElement} el The element representing the Module +* @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details. */ YAHOO.widget.Module = function(el, userConfig) { - if (el) { - this.init(el, userConfig); + if (el) { + this.init(el, userConfig); } else { YAHOO.log("No element or element ID specified for Module instantiation", "error"); } }; /** * Constant representing the prefix path to use for non-secure images -* @type string +* @property YAHOO.widget.Module.IMG_ROOT +* @static +* @final +* @type String */ YAHOO.widget.Module.IMG_ROOT = "http://us.i1.yimg.com/us.yimg.com/i/"; /** * Constant representing the prefix path to use for securely served images -* @type string +* @property YAHOO.widget.Module.IMG_ROOT_SSL +* @static +* @final +* @type String */ YAHOO.widget.Module.IMG_ROOT_SSL = "https://a248.e.akamai.net/sec.yimg.com/i/"; /** * Constant for the default CSS class name that represents a Module -* @type string +* @property YAHOO.widget.Module.CSS_MODULE +* @static * @final +* @type String */ YAHOO.widget.Module.CSS_MODULE = "module"; /** * Constant representing the module header -* @type string +* @property YAHOO.widget.Module.CSS_HEADER +* @static * @final +* @type String */ YAHOO.widget.Module.CSS_HEADER = "hd"; /** * Constant representing the module body -* @type string +* @property YAHOO.widget.Module.CSS_BODY +* @static * @final +* @type String */ YAHOO.widget.Module.CSS_BODY = "bd"; /** * Constant representing the module footer -* @type string +* @property YAHOO.widget.Module.CSS_FOOTER +* @static * @final +* @type String */ YAHOO.widget.Module.CSS_FOOTER = "ft"; /** * Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size -* @type string +* @property YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL +* @static * @final +* @type String */ -YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = "javascript:false"; +YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = "javascript:false;"; -YAHOO.widget.Module.prototype = { +/** +* Singleton CustomEvent fired when the font size is changed in the browser. +* Opera's "zoom" functionality currently does not support text size detection. +* @event YAHOO.widget.Module.textResizeEvent +*/ +YAHOO.widget.Module.textResizeEvent = new YAHOO.util.CustomEvent("textResize"); +YAHOO.widget.Module.prototype = { /** * The class's constructor function - * @type function + * @property contructor + * @type Function */ constructor : YAHOO.widget.Module, /** * The main module element that contains the header, body, and footer - * @type Element + * @property element + * @type HTMLElement */ - element : null, + element : null, /** * The header element, denoted with CSS class "hd" - * @type Element + * @property header + * @type HTMLElement */ header : null, /** * The body element, denoted with CSS class "bd" - * @type Element + * @property body + * @type HTMLElement */ body : null, /** * The footer element, denoted with CSS class "ft" - * @type Element + * @property footer + * @type HTMLElement */ footer : null, /** * The id of the element - * @type string + * @property id + * @type String */ id : null, /** - * Array of elements - * @type Element[] + * The String representing the image root + * @property imageRoot + * @type String */ - childNodesInDOM : null, - - /** - * The string representing the image root - * @type string - */ imageRoot : YAHOO.widget.Module.IMG_ROOT, /** - * CustomEvent fired prior to class initalization. - * args: class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module) - * @type YAHOO.util.CustomEvent + * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. + * @method initEvents */ - beforeInitEvent : null, + initEvents : function() { - /** - * CustomEvent fired after class initalization. - * args: class reference of the initializing class, such as this.initEvent.fire(YAHOO.widget.Module) - * @type YAHOO.util.CustomEvent - */ - initEvent : null, + /** + * CustomEvent fired prior to class initalization. + * @event beforeInitEvent + * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module) + */ + this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit"); - /** - * CustomEvent fired when the Module is appended to the DOM - * args: none - * @type YAHOO.util.CustomEvent - */ - appendEvent : null, + /** + * CustomEvent fired after class initalization. + * @event initEvent + * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module) + */ + this.initEvent = new YAHOO.util.CustomEvent("init"); - /** - * CustomEvent fired before the Module is rendered - * args: none - * @type YAHOO.util.CustomEvent - */ - beforeRenderEvent : null, + /** + * CustomEvent fired when the Module is appended to the DOM + * @event appendEvent + */ + this.appendEvent = new YAHOO.util.CustomEvent("append"); - /** - * CustomEvent fired after the Module is rendered - * args: none - * @type YAHOO.util.CustomEvent - */ - renderEvent : null, + /** + * CustomEvent fired before the Module is rendered + * @event beforeRenderEvent + */ + this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender"); - /** - * CustomEvent fired when the header content of the Module is modified - * args: string/element representing the new header content - * @type YAHOO.util.CustomEvent - */ - changeHeaderEvent : null, + /** + * CustomEvent fired after the Module is rendered + * @event renderEvent + */ + this.renderEvent = new YAHOO.util.CustomEvent("render"); - /** - * CustomEvent fired when the body content of the Module is modified - * args: string/element representing the new body content - * @type YAHOO.util.CustomEvent - */ - changeBodyEvent : null, + /** + * CustomEvent fired when the header content of the Module is modified + * @event changeHeaderEvent + * @param {String/HTMLElement} content String/element representing the new header content + */ + this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader"); - /** - * CustomEvent fired when the footer content of the Module is modified - * args: string/element representing the new footer content - * @type YAHOO.util.CustomEvent - */ - changeFooterEvent : null, + /** + * CustomEvent fired when the body content of the Module is modified + * @event changeBodyEvent + * @param {String/HTMLElement} content String/element representing the new body content + */ + this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody"); - /** - * CustomEvent fired when the content of the Module is modified - * args: none - * @type YAHOO.util.CustomEvent - */ - changeContentEvent : null, + /** + * CustomEvent fired when the footer content of the Module is modified + * @event changeFooterEvent + * @param {String/HTMLElement} content String/element representing the new footer content + */ + this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter"); - /** - * CustomEvent fired when the Module is destroyed - * args: none - * @type YAHOO.util.CustomEvent - */ - destroyEvent : null, + /** + * CustomEvent fired when the content of the Module is modified + * @event changeContentEvent + */ + this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent"); - /** - * CustomEvent fired before the Module is shown - * args: none - * @type YAHOO.util.CustomEvent - */ - beforeShowEvent : null, + /** + * CustomEvent fired when the Module is destroyed + * @event destroyEvent + */ + this.destroyEvent = new YAHOO.util.CustomEvent("destroy"); - /** - * CustomEvent fired after the Module is shown - * args: none - * @type YAHOO.util.CustomEvent - */ - showEvent : null, + /** + * CustomEvent fired before the Module is shown + * @event beforeShowEvent + */ + this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow"); - /** - * CustomEvent fired before the Module is hidden - * args: none - * @type YAHOO.util.CustomEvent - */ - beforeHideEvent : null, - - /** - * CustomEvent fired after the Module is hidden - * args: none - * @type YAHOO.util.CustomEvent - */ - hideEvent : null, - - /** - * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. - */ - initEvents : function() { + /** + * CustomEvent fired after the Module is shown + * @event showEvent + */ + this.showEvent = new YAHOO.util.CustomEvent("show"); - this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit"); - this.initEvent = new YAHOO.util.CustomEvent("init"); + /** + * CustomEvent fired before the Module is hidden + * @event beforeHideEvent + */ + this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide"); - this.appendEvent = new YAHOO.util.CustomEvent("append"); + /** + * CustomEvent fired after the Module is hidden + * @event hideEvent + */ + this.hideEvent = new YAHOO.util.CustomEvent("hide"); + }, - this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender"); - this.renderEvent = new YAHOO.util.CustomEvent("render"); - - this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader"); - this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody"); - this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter"); - - this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent"); - - this.destroyEvent = new YAHOO.util.CustomEvent("destroy"); - this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow"); - this.showEvent = new YAHOO.util.CustomEvent("show"); - this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide"); - this.hideEvent = new YAHOO.util.CustomEvent("hide"); - }, - /** * String representing the current user-agent platform - * @type string + * @property platform + * @type String */ platform : function() { var ua = navigator.userAgent.toLowerCase(); @@ -704,7 +742,8 @@ /** * String representing the current user-agent browser - * @type string + * @property browser + * @type String */ browser : function() { var ua = navigator.userAgent.toLowerCase(); @@ -725,7 +764,8 @@ /** * Boolean representing whether or not the current browsing context is secure (https) - * @type boolean + * @property isSecure + * @type Boolean */ isSecure : function() { if (window.location.href.toLowerCase().indexOf("https") === 0) { @@ -741,25 +781,51 @@ initDefaultConfig : function() { // Add properties // + /** + * Specifies whether the Module is visible on the page. + * @config visible + * @type Boolean + * @default true + */ this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } ); + + /** + * Object or array of objects representing the ContainerEffect classes that are active for animating the container. + * @config effect + * @type Object + * @default null + */ this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } ); + + /** + * Specifies whether to create a special proxy iframe to monitor for user font resizing in the document + * @config monitorresize + * @type Boolean + * @default true + */ this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } ); }, /** * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. - * @param {string} el The element ID representing the Module OR - * @param {Element} el The element representing the Module - * @param {object} userConfig The configuration object literal containing the configuration that should be set for this module. See configuration documentation for more details. + * @method init + * @param {String} el The element ID representing the Module OR + * @param {HTMLElement} el The element representing the Module + * @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details. */ init : function(el, userConfig) { this.initEvents(); this.beforeInitEvent.fire(YAHOO.widget.Module); + /** + * The Module's Config object used for monitoring configuration properties. + * @property cfg + * @type YAHOO.util.Config + */ this.cfg = new YAHOO.util.Config(this); - + if (this.isSecure) { this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL; } @@ -775,10 +841,10 @@ } this.element = el; - + if (el.id) { this.id = el.id; - } + } var childNodes = this.element.childNodes; @@ -817,96 +883,111 @@ }, /** - * Initialized an empty DOM element that is placed out of the visible area that can be used to detect text resize. + * Initialized an empty IFRAME that is placed out of the visible area that can be used to detect text resize. + * @method initResizeMonitor */ initResizeMonitor : function() { if(this.browser != "opera") { var resizeMonitor = document.getElementById("_yuiResizeMonitor"); - + if (! resizeMonitor) { - + resizeMonitor = document.createElement("iframe"); - + var bIE = (this.browser.indexOf("ie") === 0); - - if(this.isSecure && - YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL && + + if(this.isSecure && + YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL && bIE) { - - resizeMonitor.src = + + resizeMonitor.src = YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL; - - } + } + resizeMonitor.id = "_yuiResizeMonitor"; resizeMonitor.style.visibility = "hidden"; - + document.body.appendChild(resizeMonitor); - + resizeMonitor.style.width = "10em"; resizeMonitor.style.height = "10em"; resizeMonitor.style.position = "absolute"; - + var nLeft = -1 * resizeMonitor.offsetWidth, nTop = -1 * resizeMonitor.offsetHeight; - + resizeMonitor.style.top = nTop + "px"; resizeMonitor.style.left = nLeft + "px"; resizeMonitor.style.borderStyle = "none"; resizeMonitor.style.borderWidth = "0"; YAHOO.util.Dom.setStyle(resizeMonitor, "opacity", "0"); - + resizeMonitor.style.visibility = "visible"; - + if(!bIE) { - + var doc = resizeMonitor.contentWindow.document; - + doc.open(); doc.close(); - + } - } - + + var fireTextResize = function() { + YAHOO.widget.Module.textResizeEvent.fire(); + }; + if(resizeMonitor && resizeMonitor.contentWindow) { - this.resizeMonitor = resizeMonitor; - - YAHOO.util.Event.addListener(this.resizeMonitor.contentWindow, "resize", this.onDomResize, this, true); - + + YAHOO.widget.Module.textResizeEvent.subscribe(this.onDomResize, this, true); + + if (! YAHOO.widget.Module.textResizeInitialized) { + if (! YAHOO.util.Event.addListener(this.resizeMonitor.contentWindow, "resize", fireTextResize)) { + // This will fail in IE if document.domain has changed, so we must change the listener to + // use the resizeMonitor element instead + YAHOO.util.Event.addListener(this.resizeMonitor, "resize", fireTextResize); + } + YAHOO.widget.Module.textResizeInitialized = true; + } } - + } }, /** * Event handler fired when the resize monitor element is resized. + * @method onDomResize + * @param {DOMEvent} e The DOM resize event + * @param {Object} obj The scope object passed to the handler */ - onDomResize : function(e, obj) { + onDomResize : function(e, obj) { var nLeft = -1 * this.resizeMonitor.offsetWidth, nTop = -1 * this.resizeMonitor.offsetHeight; - + this.resizeMonitor.style.top = nTop + "px"; this.resizeMonitor.style.left = nLeft + "px"; - + }, /** * Sets the Module's header content to the HTML specified, or appends the passed element to the header. If no header is present, one will be automatically created. - * @param {string} headerContent The HTML used to set the header OR - * @param {Element} headerContent The Element to append to the header - */ + * @method setHeader + * @param {String} headerContent The HTML used to set the header OR + * @param {HTMLElement} headerContent The HTMLElement to append to the header + */ setHeader : function(headerContent) { if (! this.header) { this.header = document.createElement("DIV"); this.header.className = YAHOO.widget.Module.CSS_HEADER; } - + if (typeof headerContent == "string") { this.header.innerHTML = headerContent; } else { @@ -920,24 +1001,26 @@ /** * Appends the passed element to the header. If no header is present, one will be automatically created. - * @param {Element} element The element to append to the header - */ + * @method appendToHeader + * @param {HTMLElement} element The element to append to the header + */ appendToHeader : function(element) { if (! this.header) { this.header = document.createElement("DIV"); this.header.className = YAHOO.widget.Module.CSS_HEADER; } - + this.header.appendChild(element); this.changeHeaderEvent.fire(element); this.changeContentEvent.fire(); }, /** * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created. - * @param {string} bodyContent The HTML used to set the body OR - * @param {Element} bodyContent The Element to append to the body - */ + * @method setBody + * @param {String} bodyContent The HTML used to set the body OR + * @param {HTMLElement} bodyContent The HTMLElement to append to the body + */ setBody : function(bodyContent) { if (! this.body) { this.body = document.createElement("DIV"); @@ -958,7 +1041,8 @@ /** * Appends the passed element to the body. If no body is present, one will be automatically created. - * @param {Element} element The element to append to the body + * @method appendToBody + * @param {HTMLElement} element The element to append to the body */ appendToBody : function(element) { if (! this.body) { @@ -973,9 +1057,10 @@ /** * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created. - * @param {string} footerContent The HTML used to set the footer OR - * @param {Element} footerContent The Element to append to the footer - */ + * @method setFooter + * @param {String} footerContent The HTML used to set the footer OR + * @param {HTMLElement} footerContent The HTMLElement to append to the footer + */ setFooter : function(footerContent) { if (! this.footer) { this.footer = document.createElement("DIV"); @@ -995,7 +1080,8 @@ /** * Appends the passed element to the footer. If no footer is present, one will be automatically created. - * @param {Element} element The element to append to the footer + * @method appendToFooter + * @param {HTMLElement} element The element to append to the footer */ appendToFooter : function(element) { if (! this.footer) { @@ -1010,10 +1096,11 @@ /** * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure. - * @param {string} appendToNode The element id to which the Module should be appended to prior to rendering OR - * @param {Element} appendToNode The element to which the Module should be appended to prior to rendering - * @param {Element} moduleElement OPTIONAL. The element that represents the actual Standard Module container. - * @return {boolean} Success or failure of the render + * @method render + * @param {String} appendToNode The element id to which the Module should be appended to prior to rendering OR + * @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering + * @param {HTMLElement} moduleElement OPTIONAL. The element that represents the actual Standard Module container. + * @return {Boolean} Success or failure of the render */ render : function(appendToNode, moduleElement) { this.beforeRenderEvent.fire(); @@ -1027,7 +1114,7 @@ if (typeof element == "string") { element = document.getElementById(element); } - + if (element) { element.appendChild(me.element); me.appendEvent.fire(); @@ -1044,7 +1131,7 @@ } // Need to get everything into the DOM if it isn't already - + if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) { // There is a header, but it's not in the DOM yet... need to add it var firstChild = moduleElement.firstChild; @@ -1075,10 +1162,14 @@ /** * Removes the Module element from the DOM and sets all child elements to null. + * @method destroy */ destroy : function() { + var parent; + if (this.element) { - var parent = this.element.parentNode; + YAHOO.util.Event.purgeElement(this.element, true); + parent = this.element.parentNode; } if (parent) { parent.removeChild(this.element); @@ -1089,18 +1180,28 @@ this.body = null; this.footer = null; + for (var e in this) { + if (e instanceof YAHOO.util.CustomEvent) { + e.unsubscribeAll(); + } + } + + YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this); + this.destroyEvent.fire(); }, /** * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after. + * @method show */ show : function() { this.cfg.setProperty("visible", true); }, /** * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after. + * @method hide */ hide : function() { this.cfg.setProperty("visible", false); @@ -1111,6 +1212,10 @@ /** * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none". * This method is responsible for firing showEvent and hideEvent. + * @param {String} type The CustomEvent type (usually the property name) + * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. + * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. + * @method configVisible */ configVisible : function(type, args, obj) { var visible = args[0]; @@ -1127,6 +1232,10 @@ /** * Default event handler for the "monitorresize" configuration property + * @param {String} type The CustomEvent type (usually the property name) + * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. + * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. + * @method configMonitorResize */ configMonitorResize : function(type, args, obj) { var monitor = args[0]; @@ -1140,19 +1249,22 @@ }; /** -* Returns a string representation of the object. -* @type string -*/ +* Returns a String representation of the Object. +* @method toString +* @return {String} The string representation of the Module +*/ YAHOO.widget.Module.prototype.toString = function() { return "Module " + this.id; }; /** * Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements. +* @namespace YAHOO.widget +* @class Overlay * @extends YAHOO.widget.Module -* @param {string} el The element ID representing the Overlay OR -* @param {Element} el The element representing the Overlay -* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. +* @param {String} el The element ID representing the Overlay OR +* @param {HTMLElement} el The element representing the Overlay +* @param {Object} userConfig The configuration object literal containing 10/23/2006the configuration that should be set for this Overlay. See configuration documentation for more details. * @constructor */ YAHOO.widget.Overlay = function(el, userConfig) { @@ -1162,70 +1274,69 @@ YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module); /** -* The URL of the blank image that will be placed in the iframe -* @type string +* The URL that will be placed in the iframe +* @property YAHOO.widget.Overlay.IFRAME_SRC +* @static * @final +* @type String */ -YAHOO.widget.Overlay.IFRAME_SRC = "promo/m/irs/blank.gif"; +YAHOO.widget.Overlay.IFRAME_SRC = "javascript:false;"; /** * Constant representing the top left corner of an element, used for configuring the context element alignment -* @type string +* @property YAHOO.widget.Overlay.TOP_LEFT +* @static * @final +* @type String */ YAHOO.widget.Overlay.TOP_LEFT = "tl"; /** * Constant representing the top right corner of an element, used for configuring the context element alignment -* @type string +* @property YAHOO.widget.Overlay.TOP_RIGHT +* @static * @final +* @type String */ YAHOO.widget.Overlay.TOP_RIGHT = "tr"; /** * Constant representing the top bottom left corner of an element, used for configuring the context element alignment -* @type string +* @property YAHOO.widget.Overlay.BOTTOM_LEFT +* @static * @final +* @type String */ YAHOO.widget.Overlay.BOTTOM_LEFT = "bl"; /** * Constant representing the bottom right corner of an element, used for configuring the context element alignment -* @type string +* @property YAHOO.widget.Overlay.BOTTOM_RIGHT +* @static * @final +* @type String */ YAHOO.widget.Overlay.BOTTOM_RIGHT = "br"; /** * Constant representing the default CSS class used for an Overlay -* @type string +* @property YAHOO.widget.Overlay.CSS_OVERLAY +* @static * @final +* @type String */ YAHOO.widget.Overlay.CSS_OVERLAY = "overlay"; /** -* CustomEvent fired before the Overlay is moved. -* args: x,y that the Overlay will be moved to -* @type YAHOO.util.CustomEvent -*/ -YAHOO.widget.Overlay.prototype.beforeMoveEvent = null; - -/** -* CustomEvent fired after the Overlay is moved. -* args: x,y that the Overlay was moved to -* @type YAHOO.util.CustomEvent -*/ -YAHOO.widget.Overlay.prototype.moveEvent = null; - -/** * The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. -* @param {string} el The element ID representing the Overlay OR -* @param {Element} el The element representing the Overlay -* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. +* @method init +* @param {String} el The element ID representing the Overlay OR +* @param {HTMLElement} el The element representing the Overlay +* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. */ YAHOO.widget.Overlay.prototype.init = function(el, userConfig) { YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level - + this.beforeInitEvent.fire(YAHOO.widget.Overlay); YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY); @@ -1249,41 +1360,123 @@ /** * Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class. +* @method initEvents */ YAHOO.widget.Overlay.prototype.initEvents = function() { YAHOO.widget.Overlay.superclass.initEvents.call(this); + /** + * CustomEvent fired before the Overlay is moved. + * @event beforeMoveEvent + * @param {Number} x x coordinate + * @param {Number} y y coordinate + */ this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this); + + /** + * CustomEvent fired after the Overlay is moved. + * @event moveEvent + * @param {Number} x x coordinate + * @param {Number} y y coordinate + */ this.moveEvent = new YAHOO.util.CustomEvent("move", this); }; /** * Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg). +* @method initDefaultConfig */ YAHOO.widget.Overlay.prototype.initDefaultConfig = function() { YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this); // Add overlay config properties // + + /** + * The absolute x-coordinate position of the Overlay + * @config x + * @type Number + * @default null + */ this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } ); + + /** + * The absolute y-coordinate position of the Overlay + * @config y + * @type Number + * @default null + */ this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } ); + + /** + * An array with the absolute x and y positions of the Overlay + * @config xy + * @type Number[] + * @default null + */ this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } ); + /** + * The array of context arguments for context-sensitive positioning. The format is: [id or element, element corner, context corner]. For example, setting this property to ["img1", "tl", "bl"] would align the Overlay's top left corner to the context element's bottom left corner. + * @config context + * @type Array + * @default null + */ this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } ); + + /** + * True if the Overlay should be anchored to the center of the viewport. + * @config fixedcenter + * @type Boolean + * @default false + */ this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } ); + /** + * CSS width of the Overlay. + * @config width + * @type String + * @default null + */ this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } ); + + /** + * CSS height of the Overlay. + * @config height + * @type String + * @default null + */ this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } ); + /** + * CSS z-index of the Overlay. + * @config zIndex + * @type Number + * @default null + */ this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } ); + /** + * True if the Overlay should be prevented from being positioned out of the viewport. + * @config constraintoviewport + * @type Boolean + * @default false + */ this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } ); + + /** + * True if the Overlay should have an IFRAME shim (for correcting the select z-index bug in IE6 and below). + * @config iframe + * @type Boolean + * @default true for IE6 and below, false for all others + */ this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } ); }; /** * Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]); -* @param {int} x The Overlay's new x position -* @param {int} y The Overlay's new y position +* @method moveTo +* @param {Number} x The Overlay's new x position +* @param {Number} y The Overlay's new y position */ YAHOO.widget.Overlay.prototype.moveTo = function(x, y) { this.cfg.setProperty("xy",[x,y]); @@ -1292,6 +1485,7 @@ /** * Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where * scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435 +* @method hideMacGeckoScrollbars */ YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() { YAHOO.util.Dom.removeClass(this.element, "show-scrollbars"); @@ -1301,6 +1495,7 @@ /** * Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where * scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435 +* @method showMacGeckoScrollbars */ YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() { YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars"); @@ -1311,11 +1506,27 @@ /** * The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent. +* @method configVisible +* @param {String} type The CustomEvent type (usually the property name) +* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. +* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. */ YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) { var visible = args[0]; var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility"); + if (currentVis == "inherit") { + var e = this.element.parentNode; + while (e.nodeType != 9 && e.nodeType != 11) { + currentVis = YAHOO.util.Dom.getStyle(e, "visibility"); + if (currentVis != "inherit") { break; } + e = e.parentNode; + } + if (currentVis == "inherit") { + currentVis = "visible"; + } + } + var effect = this.cfg.getProperty("effect"); var effectInstances = []; @@ -1335,23 +1546,23 @@ if (visible) { // Show if (isMacGecko) { this.showMacGeckoScrollbars(); - } + } if (effect) { // Animate in if (visible) { // Animate in if not showing - if (currentVis != "visible") { + if (currentVis != "visible" || currentVis === "") { this.beforeShowEvent.fire(); for (var j=0;j rightConstraint) { @@ -1776,6 +2037,7 @@ /** * Centers the container in the viewport. +* @method center */ YAHOO.widget.Overlay.prototype.center = function() { var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; @@ -1789,16 +2051,15 @@ var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX; var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY; - - this.element.style.left = parseInt(x, 10) + "px"; - this.element.style.top = parseInt(y, 10) + "px"; - this.syncPosition(); + this.cfg.setProperty("xy", [parseInt(x, 10), parseInt(y, 10)]); + this.cfg.refireEvent("iframe"); }; /** * Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop. +* @method syncPosition */ YAHOO.widget.Overlay.prototype.syncPosition = function() { var pos = YAHOO.util.Dom.getXY(this.element); @@ -1809,63 +2070,99 @@ /** * Event handler fired when the resize monitor element is resized. +* @method onDomResize +* @param {DOMEvent} e The resize DOM event +* @param {Object} obj The scope object */ YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) { YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj); - this.cfg.refireEvent("iframe"); + var me = this; + setTimeout(function() { + me.syncPosition(); + me.cfg.refireEvent("iframe"); + me.cfg.refireEvent("context"); + }, 0); }; /** * Removes the Overlay element from the DOM and sets all child elements to null. +* @method destroy */ YAHOO.widget.Overlay.prototype.destroy = function() { if (this.iframe) { this.iframe.parentNode.removeChild(this.iframe); } - + this.iframe = null; - YAHOO.widget.Overlay.superclass.destroy.call(this); + YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this); + YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this); + + YAHOO.widget.Overlay.superclass.destroy.call(this); }; /** -* Returns a string representation of the object. -* @type string -*/ +* Returns a String representation of the object. +* @method toString +* @return {String} The string representation of the Overlay. +*/ YAHOO.widget.Overlay.prototype.toString = function() { return "Overlay " + this.id; }; /** * A singleton CustomEvent used for reacting to the DOM event for window scroll -* @type YAHOO.util.CustomEvent +* @event YAHOO.widget.Overlay.windowScrollEvent */ YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll"); /** * A singleton CustomEvent used for reacting to the DOM event for window resize -* @type YAHOO.util.CustomEvent +* @event YAHOO.widget.Overlay.windowResizeEvent */ YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize"); /** * The DOM event handler used to fire the CustomEvent for window scroll -* @type Function +* @method YAHOO.widget.Overlay.windowScrollHandler +* @static +* @param {DOMEvent} e The DOM scroll event */ YAHOO.widget.Overlay.windowScrollHandler = function(e) { - YAHOO.widget.Overlay.windowScrollEvent.fire(); + if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") { + if (! window.scrollEnd) { + window.scrollEnd = -1; + } + clearTimeout(window.scrollEnd); + window.scrollEnd = setTimeout(function() { YAHOO.widget.Overlay.windowScrollEvent.fire(); }, 1); + } else { + YAHOO.widget.Overlay.windowScrollEvent.fire(); + } }; /** * The DOM event handler used to fire the CustomEvent for window resize -* @type Function +* @method YAHOO.widget.Overlay.windowResizeHandler +* @static +* @param {DOMEvent} e The DOM resize event */ YAHOO.widget.Overlay.windowResizeHandler = function(e) { - YAHOO.widget.Overlay.windowResizeEvent.fire(); + if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") { + if (! window.resizeEnd) { + window.resizeEnd = -1; + } + clearTimeout(window.resizeEnd); + window.resizeEnd = setTimeout(function() { YAHOO.widget.Overlay.windowResizeEvent.fire(); }, 100); + } else { + YAHOO.widget.Overlay.windowResizeEvent.fire(); + } }; /** +* A boolean that indicated whether the window resize and scroll events have already been subscribed to. +* @property YAHOO.widget.Overlay._initialized * @private +* @type Boolean */ YAHOO.widget.Overlay._initialized = null; @@ -1876,72 +2173,76 @@ YAHOO.widget.Overlay._initialized = true; } - /** -* OverlayManager is used for maintaining the focus status of multiple Overlays. -* @param {Array} overlays Optional. A collection of Overlays to register with the manager. -* @param {object} userConfig The object literal representing the user configuration of the OverlayManager +* OverlayManager is used for maintaining the focus status of multiple Overlays.* @namespace YAHOO.widget +* @namespace YAHOO.widget +* @class OverlayManager * @constructor +* @param {Array} overlays Optional. A collection of Overlays to register with the manager. +* @param {Object} userConfig The object literal representing the user configuration of the OverlayManager */ YAHOO.widget.OverlayManager = function(userConfig) { this.init(userConfig); }; /** * The CSS class representing a focused Overlay -* @type string +* @property YAHOO.widget.OverlayManager.CSS_FOCUSED +* @static +* @final +* @type String */ YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused"; YAHOO.widget.OverlayManager.prototype = { - + /** + * The class's constructor function + * @property contructor + * @type Function + */ constructor : YAHOO.widget.OverlayManager, /** * The array of Overlays that are currently registered - * @type Array + * @property overlays + * @type YAHOO.widget.Overlay[] */ overlays : null, /** * Initializes the default configuration of the OverlayManager - */ + * @method initDefaultConfig + */ initDefaultConfig : function() { + /** + * The collection of registered Overlays in use by the OverlayManager + * @config overlays + * @type YAHOO.widget.Overlay[] + * @default null + */ this.cfg.addProperty("overlays", { suppressEvent:true } ); + + /** + * The default DOM event that should be used to focus an Overlay + * @config focusevent + * @type String + * @default "mousedown" + */ this.cfg.addProperty("focusevent", { value:"mousedown" } ); - }, + }, /** - * Returns the currently focused Overlay - * @return {Overlay} The currently focused Overlay - */ - getActive : function() {}, - - /** - * Focuses the specified Overlay - * @param {Overlay} The Overlay to focus - * @param {string} The id of the Overlay to focus - */ - focus : function(overlay) {}, - - /** - * Removes the specified Overlay from the manager - * @param {Overlay} The Overlay to remove - * @param {string} The id of the Overlay to remove - */ - remove: function(overlay) {}, - - /** - * Removes focus from all registered Overlays in the manager - */ - blurAll : function() {}, - - /** * Initializes the OverlayManager - * @param {Array} overlays Optional. A collection of Overlays to register with the manager. - * @param {object} userConfig The object literal representing the user configuration of the OverlayManager + * @method init + * @param {YAHOO.widget.Overlay[]} overlays Optional. A collection of Overlays to register with the manager. + * @param {Object} userConfig The object literal representing the user configuration of the OverlayManager */ init : function(userConfig) { + /** + * The OverlayManager's Config object used for monitoring configuration properties. + * @property cfg + * @type YAHOO.util.Config + */ this.cfg = new YAHOO.util.Config(this); this.initDefaultConfig(); @@ -1951,12 +2252,29 @@ } this.cfg.fireQueue(); + /** + * The currently activated Overlay + * @property activeOverlay + * @private + * @type YAHOO.widget.Overlay + */ var activeOverlay = null; + /** + * Returns the currently focused Overlay + * @method getActive + * @return {YAHOO.widget.Overlay} The currently focused Overlay + */ this.getActive = function() { return activeOverlay; }; + /** + * Focuses the specified Overlay + * @method focus + * @param {YAHOO.widget.Overlay} overlay The Overlay to focus + * @param {String} overlay The id of the Overlay to focus + */ this.focus = function(overlay) { var o = this.find(overlay); if (o) { @@ -1972,6 +2290,12 @@ } }; + /** + * Removes the specified Overlay from the manager + * @method remove + * @param {YAHOO.widget.Overlay} overlay The Overlay to remove + * @param {String} overlay The id of the Overlay to remove + */ this.remove = function(overlay) { var o = this.find(overlay); if (o) { @@ -1989,15 +2313,19 @@ } }; + /** + * Removes focus from all registered Overlays in the manager + * @method blurAll + */ this.blurAll = function() { activeOverlay = null; for (var o=0;oOR -* @param {Element} el The element representing the Tooltip -* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. * @constructor +* @param {String} el The element ID representing the Tooltip OR +* @param {HTMLElement} el The element representing the Tooltip +* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. */ YAHOO.widget.Tooltip = function(el, userConfig) { YAHOO.widget.Tooltip.superclass.constructor.call(this, el, userConfig); }; YAHOO.extend(YAHOO.widget.Tooltip, YAHOO.widget.Overlay); -YAHOO.widget.Tooltip.logger = new YAHOO.widget.LogWriter("Tooltip"); - /** * Constant representing the Tooltip CSS class -* @type string +* @property YAHOO.widget.Tooltip.CSS_TOOLTIP +* @static * @final +* @type String */ YAHOO.widget.Tooltip.CSS_TOOLTIP = "tt"; /** * The Tooltip initialization method. This method is automatically called by the constructor. A Tooltip is automatically rendered by the init method, and it also is set to be invisible by default, and constrained to viewport by default as well. -* @param {string} el The element ID representing the Tooltip OR -* @param {Element} el The element representing the Tooltip -* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Tooltip. See configuration documentation for more details. +* @method init +* @param {String} el The element ID representing the Tooltip OR +* @param {HTMLElement} el The element representing the Tooltip +* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Tooltip. See configuration documentation for more details. */ YAHOO.widget.Tooltip.prototype.init = function(el, userConfig) { this.logger = YAHOO.widget.Tooltip.logger; @@ -2325,7 +2683,7 @@ if (userConfig) { this.cfg.applyConfig(userConfig, true); } - + this.cfg.queueProperty("visible",false); this.cfg.queueProperty("constraintoviewport",true); @@ -2338,24 +2696,76 @@ /** * Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg). +* @method initDefaultConfig */ YAHOO.widget.Tooltip.prototype.initDefaultConfig = function() { YAHOO.widget.Tooltip.superclass.initDefaultConfig.call(this); + /** + * Specifies whether the Tooltip should be kept from overlapping its context element. + * @config preventoverlap + * @type Boolean + * @default true + */ this.cfg.addProperty("preventoverlap", { value:true, validator:this.cfg.checkBoolean, supercedes:["x","y","xy"] } ); + /** + * The number of milliseconds to wait before showing a Tooltip on mouseover. + * @config showdelay + * @type Number + * @default 200 + */ this.cfg.addProperty("showdelay", { value:200, handler:this.configShowDelay, validator:this.cfg.checkNumber } ); + + /** + * The number of milliseconds to wait before automatically dismissing a Tooltip after the mouse has been resting on the context element. + * @config autodismissdelay + * @type Number + * @default 5000 + */ this.cfg.addProperty("autodismissdelay", { value:5000, handler:this.configAutoDismissDelay, validator:this.cfg.checkNumber } ); + + /** + * The number of milliseconds to wait before hiding a Tooltip on mouseover. + * @config hidedelay + * @type Number + * @default 250 + */ this.cfg.addProperty("hidedelay", { value:250, handler:this.configHideDelay, validator:this.cfg.checkNumber } ); + /** + * Specifies the Tooltip's text. + * @config text + * @type String + * @default null + */ this.cfg.addProperty("text", { handler:this.configText, suppressEvent:true } ); + + /** + * Specifies the container element that the Tooltip's markup should be rendered into. + * @config container + * @type HTMLElement/String + * @default document.body + */ this.cfg.addProperty("container", { value:document.body, handler:this.configContainer } ); + + /** + * Specifies the element or elements that the Tooltip should be anchored to on mouseover. + * @config context + * @type HTMLElement[]/String[] + * @default null + */ + }; // BEGIN BUILT-IN PROPERTY EVENT HANDLERS // /** * The default event handler fired when the "text" property is changed. +* @method configText +* @param {String} type The CustomEvent type (usually the property name) +* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. +* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. */ YAHOO.widget.Tooltip.prototype.configText = function(type, args, obj) { var text = args[0]; @@ -2366,6 +2776,10 @@ /** * The default event handler fired when the "container" property is changed. +* @method configContainer +* @param {String} type The CustomEvent type (usually the property name) +* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. +* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. */ YAHOO.widget.Tooltip.prototype.configContainer = function(type, args, obj) { var container = args[0]; @@ -2376,11 +2790,15 @@ /** * The default event handler fired when the "context" property is changed. +* @method configContext +* @param {String} type The CustomEvent type (usually the property name) +* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. +* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. */ YAHOO.widget.Tooltip.prototype.configContext = function(type, args, obj) { var context = args[0]; if (context) { - + // Normalize parameter into an array if (! (context instanceof Array)) { if (typeof context == "string") { @@ -2419,8 +2837,9 @@ /** * The default event handler fired when the user moves the mouse while over the context element. +* @method onContextMouseMove * @param {DOMEvent} e The current DOM event -* @param {object} obj The object argument +* @param {Object} obj The object argument */ YAHOO.widget.Tooltip.prototype.onContextMouseMove = function(e, obj) { obj.pageX = YAHOO.util.Event.getPageX(e); @@ -2430,8 +2849,9 @@ /** * The default event handler fired when the user mouses over the context element. +* @method onContextMouseOver * @param {DOMEvent} e The current DOM event -* @param {object} obj The object argument +* @param {Object} obj The object argument */ YAHOO.widget.Tooltip.prototype.onContextMouseOver = function(e, obj) { @@ -2440,7 +2860,7 @@ obj.logger.log("Clearing hide timer: " + obj.hideProcId, "time"); obj.hideProcId = null; } - + var context = this; YAHOO.util.Event.addListener(context, "mousemove", obj.onContextMouseMove, obj); @@ -2459,8 +2879,9 @@ /** * The default event handler fired when the user mouses out of the context element. +* @method onContextMouseOut * @param {DOMEvent} e The current DOM event -* @param {object} obj The object argument +* @param {Object} obj The object argument */ YAHOO.widget.Tooltip.prototype.onContextMouseOut = function(e, obj) { var el = this; @@ -2469,11 +2890,11 @@ el.title = obj._tempTitle; obj._tempTitle = null; } - + if (obj.showProcId) { clearTimeout(obj.showProcId); obj.logger.log("Clearing show timer: " + obj.showProcId, "time"); - obj.showProcId = null; + obj.showProcId = null; } if (obj.hideProcId) { @@ -2492,11 +2913,12 @@ /** * Processes the showing of the Tooltip by setting the timeout delay and offset of the Tooltip. +* @method doShow * @param {DOMEvent} e The current DOM event -* @return {int} The process ID of the timeout function associated with doShow +* @return {Number} The process ID of the timeout function associated with doShow */ YAHOO.widget.Tooltip.prototype.doShow = function(e, context) { - + var yOffset = 25; if (this.browser == "opera" && context.tagName == "A") { yOffset += 12; @@ -2516,7 +2938,7 @@ if (me.cfg.getProperty("preventoverlap")) { me.preventOverlap(me.pageX, me.pageY); } - + YAHOO.util.Event.removeListener(context, "mousemove", me.onContextMouseMove); me.show(); @@ -2528,6 +2950,7 @@ /** * Sets the timeout for the auto-dismiss delay, which by default is 5 seconds, meaning that a tooltip will automatically dismiss itself after 5 seconds of being displayed. +* @method doHide */ YAHOO.widget.Tooltip.prototype.doHide = function() { var me = this; @@ -2542,11 +2965,14 @@ /** * Fired when the Tooltip is moved, this event handler is used to prevent the Tooltip from overlapping with its context element. +* @method preventOverlay +* @param {Number} pageX The x coordinate position of the mouse pointer +* @param {Number} pageY The y coordinate position of the mouse pointer */ YAHOO.widget.Tooltip.prototype.preventOverlap = function(pageX, pageY) { - + var height = this.element.offsetHeight; - + var elementRegion = YAHOO.util.Dom.getRegion(this.element); elementRegion.top -= 5; @@ -2555,7 +2981,7 @@ elementRegion.bottom += 5; var mousePoint = new YAHOO.util.Point(pageX, pageY); - + this.logger.log("context " + elementRegion, "ttip"); this.logger.log("mouse " + mousePoint, "ttip"); @@ -2567,19 +2993,22 @@ /** * Returns a string representation of the object. -* @type string -*/ +* @method toString +* @return {String} The string representation of the Tooltip +*/ YAHOO.widget.Tooltip.prototype.toString = function() { return "Tooltip " + this.id; }; /** * Panel is an implementation of Overlay that behaves like an OS window, with a draggable header and an optional close icon at the top right. +* @namespace YAHOO.widget +* @class Panel * @extends YAHOO.widget.Overlay -* @param {string} el The element ID representing the Panel OR -* @param {Element} el The element representing the Panel -* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Panel. See configuration documentation for more details. * @constructor +* @param {String} el The element ID representing the Panel OR +* @param {HTMLElement} el The element representing the Panel +* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Panel. See configuration documentation for more details. */ YAHOO.widget.Panel = function(el, userConfig) { YAHOO.widget.Panel.superclass.constructor.call(this, el, userConfig); @@ -2589,47 +3018,38 @@ /** * Constant representing the default CSS class used for a Panel -* @type string +* @property YAHOO.widget.Panel.CSS_PANEL +* @static * @final +* @type String */ YAHOO.widget.Panel.CSS_PANEL = "panel"; /** * Constant representing the default CSS class used for a Panel's wrapping container -* @type string +* @property YAHOO.widget.Panel.CSS_PANEL_CONTAINER +* @static * @final +* @type String */ YAHOO.widget.Panel.CSS_PANEL_CONTAINER = "panel-container"; /** -* CustomEvent fired after the modality mask is shown -* args: none -* @type YAHOO.util.CustomEvent -*/ -YAHOO.widget.Panel.prototype.showMaskEvent = null; - -/** -* CustomEvent fired after the modality mask is hidden -* args: none -* @type YAHOO.util.CustomEvent -*/ -YAHOO.widget.Panel.prototype.hideMaskEvent = null; - -/** * The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. -* @param {string} el The element ID representing the Overlay OR -* @param {Element} el The element representing the Overlay -* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. +* @method init +* @param {String} el The element ID representing the Overlay OR +* @param {HTMLElement} el The element representing the Overlay +* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. */ YAHOO.widget.Panel.prototype.init = function(el, userConfig) { YAHOO.widget.Panel.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level - + this.beforeInitEvent.fire(YAHOO.widget.Panel); YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Panel.CSS_PANEL); - this.buildWrapper(); - + this.buildWrapper(); + if (userConfig) { this.cfg.applyConfig(userConfig, true); } @@ -2638,35 +3058,42 @@ var draggable = this.cfg.getProperty("draggable"); if (draggable) { if (! this.header) { - this.setHeader(" "); + this.setHeader(" "); } } }, this, true); var me = this; + var doBlur = function() { + this.blur(); + }; + this.showMaskEvent.subscribe(function() { var checkFocusable = function(el) { - if (el.tagName == "A" || el.tagName == "BUTTON" || el.tagName == "SELECT" || el.tagName == "INPUT" || el.tagName == "TEXTAREA" || el.tagName == "FORM") { + if ((el.tagName == "A" || el.tagName == "BUTTON" || el.tagName == "SELECT" || el.tagName == "INPUT" || el.tagName == "TEXTAREA" || el.tagName == "FORM") && el.type != "hidden") { if (! YAHOO.util.Dom.isAncestor(me.element, el)) { - YAHOO.util.Event.addListener(el, "focus", el.blur); + YAHOO.util.Event.addListener(el, "focus", doBlur, el, true); return true; } } else { return false; } }; - + this.focusableElements = YAHOO.util.Dom.getElementsBy(checkFocusable); }, this, true); this.hideMaskEvent.subscribe(function() { for (var i=0;i