Widget-Stack.js revision 7fac276f7bad8999927d1d86d779393dc7240ce6
2362N/A * Provides stackable (z-index) support for Widgets through an extension. 893N/A * Widget extension, which can be used to add stackable (z-index) support to the 893N/A * base Widget class along with a shimming solution, through the 893N/A * @param {Object} User configuration object 893N/A // WIDGET METHOD OVERLAP 893N/A * Static property used to define the default attribute 893N/A * configuration introduced by WidgetStack. 893N/A * @default false, for all browsers other than IE6, for which a shim is enabled by default. 3471N/A * @description Boolean flag to indicate whether or not a shim should be added to the Widgets 893N/A * boundingBox, to protect it from select box bleedthrough. 3471N/A * @description The z-index to apply to the Widgets boundingBox. Non-numerical values for 893N/A * zIndex will be converted to 0 893N/A * The HTML parsing rules for the WidgetStack class. 893N/A * @property HTML_PARSER 893N/A * Default class used to mark the shim element 893N/A * @property SHIM_CLASS_NAME 893N/A * @default "yui3-widget-shim" 893N/A * Default class used to mark the boundingBox of a stacked widget. 893N/A * @property STACKED_CLASS_NAME 893N/A * @default "yui3-widget-stacked" 893N/A * Default markup template used to generate the shim element. 893N/A * @property SHIM_TEMPLATE 893N/A * Synchronizes the UI to match the Widgets stack state. This method in 893N/A * invoked after syncUI is invoked for the Widget class using YUI's aop infrastructure. 893N/A * Binds event listeners responsible for updating the UI state in response to 893N/A * Widget stack related state changes. 893N/A * This method is invoked after bindUI is invoked for the Widget class 893N/A * using YUI's aop infrastructure. 3471N/A * This method in invoked after renderUI is invoked for the Widget class 893N/A * using YUI's aop infrastructure. 893N/A * @method _renderUIStack 893N/A Parses a `zIndex` attribute value from this widget's `srcNode`. 893N/A @param {Node} srcNode The node to parse a `zIndex` value from. 893N/A @return {Mixed} The parsed `zIndex` value. 3471N/A // Prefers how WebKit handles `z-index` which better matches the 3471N/A // When a node isn't rendered in the document, and/or when a 893N/A // node is not positioned, then it doesn't have a context to derive 893N/A // a valid `z-index` value from. 893N/A // Uses `getComputedStyle()` because it has greater accuracy in 893N/A // more browsers than `getStyle()` does for `z-index`. 3471N/A // This extension adds a stacking context to widgets, therefore a 893N/A // `srcNode` witout a stacking context (i.e. "auto") will return 893N/A // `null` from this DOM parser. This way the widget's default or 893N/A // user provided value for `zIndex` will be used. 893N/A * Default setter for zIndex attribute changes. Normalizes zIndex values to 893N/A * numbers, converting non-numerical values to 0. 893N/A * @param {String | Number} zIndex 893N/A * @return {Number} Normalized zIndex 893N/A * Default attribute change listener for the shim attribute, responsible 893N/A * for updating the UI, in response to attribute changes. 893N/A * @method _afterShimChange 893N/A * @param {EventFacade} e The event facade for the attribute change 893N/A * Default attribute change listener for the zIndex attribute, responsible 893N/A * for updating the UI, in response to attribute changes. 3471N/A * @method _afterZIndexChange 893N/A * @param {EventFacade} e The event facade for the attribute change 893N/A * Updates the UI to reflect the zIndex value passed in. 893N/A * @param {number} zIndex The zindex to be reflected in the UI 893N/A * creation of the shim is deferred until it is made visible, for performance reasons. 3471N/A // Eagerly attach resize handlers 3471N/A // Required because of Event stack behavior, commit ref: cd8dddc 893N/A // Should be revisted after Ticket #2531067 is resolved. 893N/A * until the Widget is made visible. 3471N/A * @method _renderShimDeferred 3471N/A // Depending how how Ticket #2531067 is resolved, a reversal of 893N/A // commit ref: cd8dddc could lead to a more elagent solution, with 893N/A // the addition of this line here: 893N/A // handles.push(this.after(VisibleChange, this.sizeShim)); 893N/A * Sets up event listeners to resize the shim when the size of the Widget changes. 893N/A * NOTE: This method is only used for IE6 currently, since IE6 doesn't support a way to 3471N/A * resize the shim purely through CSS, when the Widget does not have an explicit width/height 893N/A * @method _addShimResizeHandlers 893N/A * Detaches any handles stored for the provided key 3471N/A * @method _detachStackHandles 893N/A * @param String handleKey The key defining the group of handles which should be detached 3471N/A * Creates the shim element and adds it to the DOM 3471N/A * Removes the shim from the DOM, and detaches any related event 3471N/A * For IE6, synchronizes the size and position of iframe shim to that of 893N/A * Widget bounding box which it is protecting. For all other browsers, 893N/A * this method does not do anything. 893N/A * Creates a cloned shim node, using the SHIM_TEMPLATE html template, for use on a new instance. 893N/A * @method _getShimTemplate 893N/A * @return {Node} node A new shim Node instance.