From c320a2278ab1321d7fef927abd46e67fad138a17 Mon Sep 17 00:00:00 2001 From: YUI Builder Date: Fri, 2 Apr 2010 10:27:49 -0700 Subject: [PATCH] Gallery Build Tag: gallery-2010.04.02-17-26 --- .../assets/skins/sam/gallery-accordion.css | 2 +- .../gallery-accordion-debug.js | 1655 ++++++++--------- .../gallery-accordion-min.js | 8 +- build/gallery-accordion/gallery-accordion.js | 1655 ++++++++--------- .../gallery-formmgr/gallery-formmgr-debug.js | 18 +- build/gallery-formmgr/gallery-formmgr-min.js | 2 +- build/gallery-formmgr/gallery-formmgr.js | 18 +- .../skins/sam/gallery-node-accordion.css | 2 +- .../gallery-node-accordion-debug.js | 7 +- .../gallery-node-accordion-min.js | 2 +- .../gallery-node-accordion.js | 7 +- .../assets/skins/sam/gallery-paginator.css | 2 +- .../gallery-paginator-debug.js | 2 +- .../gallery-paginator-min.js | 2 +- build/gallery-paginator/gallery-paginator.js | 2 +- build/gallery-resize/gallery-resize-debug.js | 91 +- build/gallery-resize/gallery-resize-min.js | 4 +- build/gallery-resize/gallery-resize.js | 91 +- .../gallery-stalker/gallery-stalker-debug.js | 163 ++ build/gallery-stalker/gallery-stalker-min.js | 1 + build/gallery-stalker/gallery-stalker.js | 160 ++ 21 files changed, 2118 insertions(+), 1776 deletions(-) create mode 100644 build/gallery-stalker/gallery-stalker-debug.js create mode 100644 build/gallery-stalker/gallery-stalker-min.js create mode 100644 build/gallery-stalker/gallery-stalker.js diff --git a/build/gallery-accordion/assets/skins/sam/gallery-accordion.css b/build/gallery-accordion/assets/skins/sam/gallery-accordion.css index 80d9d8be7b..9eb3f5d561 100644 --- a/build/gallery-accordion/assets/skins/sam/gallery-accordion.css +++ b/build/gallery-accordion/assets/skins/sam/gallery-accordion.css @@ -1 +1 @@ -.yui-accordion{width:100%;height:100%;overflow:hidden;position:relative;}.yui-accordion-item{position:relative;cursor:pointer;width:100%;}.yui-accordion-item .yui-widget-hd{overflow:hidden;}.yui-accordion-item .yui-widget-bd{cursor:default;overflow:hidden;position:relative;}.yui-accordion-item-icons{position:relative;float:right;overflow:hidden;padding:1px;height:25px;}.yui-accordion-item-icon,.yui-accordion-item-iconexpanded,.yui-accordion-item-iconalwaysvisible,.yui-accordion-item-iconclose{width:22px;height:22px;}.yui-accordion-item-icon,.yui-accordion-item-label{float:left;}.yui-accordion-item-label{position:relative;top:4px;_height:22px;}.yui-accordion-item-iconexpanded,.yui-accordion-item-iconalwaysvisible,.yui-accordion-item-iconclose{float:left;}.yui-accordion-item-iconclose-hidden{display:none;}.yui-skin-sam .yui-accordion{border:1px solid #93B2CC;}.yui-skin-sam .yui-accordion-item .yui-widget-hd{background-image:url(accordion_sprite.png);background-position:0 0;border:1px solid #93B2CC;height:25px;}.yui-skin-sam .yui-accordion-item-icon,.yui-skin-sam .yui-accordion-item-iconexpanded,.yui-skin-sam .yui-accordion-item-iconalwaysvisible,.yui-skin-sam .yui-accordion-item-iconclose{background-repeat:no-repeat;}.yui-skin-sam .yui-accordion-item-icon{background-image:url(accordion_sprite.png);background-position:center -25px;_background-position:center -27px;}.yui-skin-sam .yui-accordion-item-label{color:#444;}.yui-skin-sam .yui-accordion-item-label{text-decoration:none;background:transparent;overflow:hidden;color:#444;font-weight:bold;}.yui-skin-sam .yui-accordion-item-label:hover{text-decoration:underline;}.yui-skin-sam .yui-accordion-item-iconalwaysvisible,.yui-skin-sam .yui-accordion-item-iconalwaysvisible-off{background-image:url(accordion_sprite.png);background-position:0 -85px;_background-position:0 -87px;}.yui-skin-sam .yui-accordion-item-iconalwaysvisible-on{background-image:url(accordion_sprite.png);background-position:0 -55px;_background-position:0 -57px;}.yui-skin-sam .yui-accordion-item-iconexpanded,.yui-skin-sam .yui-accordion-item-iconexpanded-off{background-image:url(accordion_sprite.png);background-position:0 -175px;_background-position:0 -177px;}.yui-skin-sam .yui-accordion-item-iconexpanded-off:hover{background-image:url(accordion_sprite.png);background-position:0 -205px;}.yui-skin-sam .yui-accordion-item-iconexpanded-on{background-image:url(accordion_sprite.png);background-position:0 -115px;_background-position:0 -117px;}.yui-skin-sam .yui-accordion-item-iconexpanded-on:hover{background-image:url(accordion_sprite.png);background-position:0 -145px;}.yui-skin-sam .yui-accordion-item-iconexpanded-expanding{background-image:url(wait_expand.gif);background-position:0 center;}.yui-skin-sam .yui-accordion-item-iconexpanded-collapsing{background-image:url(wait_collapse.gif);background-position:0 center;}.yui-skin-sam .yui-accordion-item-iconclose{background-image:url(accordion_sprite.png);background-position:0 -235px;_background-position:0 -237px;}.yui-skin-sam .yui-accordion-proxyel-visible{border-color:blue;color:white;font-weight:bold;background-color:red;opacity:.7;filter:alpha(opacity = 70);} +.yui3-accordion{width:100%;height:100%;overflow:hidden;position:relative;}.yui3-accordion-item{position:relative;cursor:pointer;width:100%;}.yui3-accordion-item .yui3-widget-hd{overflow:hidden;}.yui3-accordion-item .yui3-widget-bd{cursor:default;overflow:hidden;position:relative;}.yui3-accordion-item-icons{position:relative;float:right;overflow:hidden;padding:1px;height:25px;}.yui3-accordion-item-icon,.yui3-accordion-item-iconexpanded,.yui3-accordion-item-iconalwaysvisible,.yui3-accordion-item-iconclose{width:22px;height:22px;}.yui3-accordion-item-icon,.yui3-accordion-item-label{float:left;}.yui3-accordion-item-label{position:relative;top:4px;_height:22px;}.yui3-accordion-item-iconexpanded,.yui3-accordion-item-iconalwaysvisible,.yui3-accordion-item-iconclose{float:left;}.yui3-accordion-item-iconclose-hidden{display:none;}.yui3-skin-sam .yui3-accordion{border:1px solid #93B2CC;}.yui3-skin-sam .yui3-accordion-item .yui3-widget-hd{background-image:url(accordion_sprite.png);background-position:0 0;border:1px solid #93B2CC;height:25px;}.yui3-skin-sam .yui3-accordion-item-icon,.yui3-skin-sam .yui3-accordion-item-iconexpanded,.yui3-skin-sam .yui3-accordion-item-iconalwaysvisible,.yui3-skin-sam .yui3-accordion-item-iconclose{background-repeat:no-repeat;}.yui3-skin-sam .yui3-accordion-item-icon{background-image:url(accordion_sprite.png);background-position:center -25px;_background-position:center -27px;}.yui3-skin-sam .yui3-accordion-item-label{color:#444;}.yui3-skin-sam .yui3-accordion-item-label{text-decoration:none;background:transparent;overflow:hidden;color:#444;font-weight:bold;}.yui3-skin-sam .yui3-accordion-item-label:hover{text-decoration:underline;}.yui3-skin-sam .yui3-accordion-item-iconalwaysvisible,.yui3-skin-sam .yui3-accordion-item-iconalwaysvisible-off{background-image:url(accordion_sprite.png);background-position:0 -85px;_background-position:0 -87px;}.yui3-skin-sam .yui3-accordion-item-iconalwaysvisible-on{background-image:url(accordion_sprite.png);background-position:0 -55px;_background-position:0 -57px;}.yui3-skin-sam .yui3-accordion-item-iconexpanded,.yui3-skin-sam .yui3-accordion-item-iconexpanded-off{background-image:url(accordion_sprite.png);background-position:0 -175px;_background-position:0 -177px;}.yui3-skin-sam .yui3-accordion-item-iconexpanded-off:hover{background-image:url(accordion_sprite.png);background-position:0 -205px;}.yui3-skin-sam .yui3-accordion-item-iconexpanded-on{background-image:url(accordion_sprite.png);background-position:0 -115px;_background-position:0 -117px;}.yui3-skin-sam .yui3-accordion-item-iconexpanded-on:hover{background-image:url(accordion_sprite.png);background-position:0 -145px;}.yui3-skin-sam .yui3-accordion-item-iconexpanded-expanding{background-image:url(wait_expand.gif);background-position:0 center;}.yui3-skin-sam .yui3-accordion-item-iconexpanded-collapsing{background-image:url(wait_collapse.gif);background-position:0 center;}.yui3-skin-sam .yui3-accordion-item-iconclose{background-image:url(accordion_sprite.png);background-position:0 -235px;_background-position:0 -237px;}.yui3-skin-sam .yui3-accordion-proxyel-visible{border-color:blue;color:white;font-weight:bold;background-color:red;opacity:.7;filter:alpha(opacity = 70);} diff --git a/build/gallery-accordion/gallery-accordion-debug.js b/build/gallery-accordion/gallery-accordion-debug.js index 353de5c7ff..9fd3d5768b 100644 --- a/build/gallery-accordion/gallery-accordion-debug.js +++ b/build/gallery-accordion/gallery-accordion-debug.js @@ -8,21 +8,6 @@ YUI.add('gallery-accordion', function(Y) { (function(){ -/** - * Accordion creates an widget, consists of one or more items, which can be collapsed, expanded, - * set as always visible and reordered by using Drag&Drop. Collapsing/expanding might be animated. - * - * @param config {Object} Object literal specifying Accordion configuration properties. - * - * @class Accordion - * @constructor - * @extends Widget - */ - -function Accordion( config ){ - Accordion.superclass.constructor.apply( this, arguments ); -} - // Local constants var Lang = Y.Lang, Node = Y.Node, @@ -35,7 +20,7 @@ var Lang = Y.Lang, COLLAPSE_HEIGHT = IEQuirksMode ? 1 : 0, getCN = Y.ClassNameManager.getClassName, - C_ITEM = "yui-accordion-item", + C_ITEM = "yui3-accordion-item", C_PROXY_VISIBLE = getCN( AccName, "proxyel", "visible" ), DRAGGROUP = getCN( AccName, "graggroup" ), @@ -77,157 +62,14 @@ var Lang = Y.Lang, /** - * Static property provides a string to identify the class. + * Accordion creates an widget, consists of one or more items, which can be collapsed, expanded, + * set as always visible and reordered by using Drag&Drop. Collapsing/expanding might be animated. * - * @property Accordion.NAME - * @type String - * @static - */ -Accordion.NAME = AccName; - -/** - * Static property used to define the default attribute - * configuration for the Accordion. - * - * @property Accordion.ATTRS - * @type Object - * @static + * @class Accordion + * @extends Widget */ -Accordion.ATTRS = { - /** - * @description The event on which Accordion should listen for user interactions. - * The value can be also mousedown or mouseup. Mousedown event can be used if - * drag&drop is not enabled - * - * @attribute itemChosen - * @default click - * @type String - */ - itemChosen: { - value: "click", - validator: Lang.isString - }, - - /** - * @description Contains the items, currently added to Accordion - * - * @attribute items - * @readOnly - * @default [] - * @type Array - */ - items: { - value: [], - readOnly: true, - validator: Lang.isArray - }, - - /** - * @attribute resizeEvent - * - * @description The event on which Accordion should listen for resizing. - * The value must be one of these: - * - * For example, if we are using LayoutManager's instance as sourceObject, we will have to use its "resize" event as resizeEvent - * - * @default "default" - * @type String or Object - */ - - resizeEvent: { - value: DEFAULT, - validator: function( value ){ - if( value === DEFAULT ){ - return true; - } else if( Lang.isObject(value) ){ - if( Lang.isValue( value.sourceObject ) && Lang.isValue( value.resizeEvent ) ){ - return true; - } - } - - return false; - } - }, - - /** - * @attribute useAnimation - * @description Boolean indicating that Accordion should use animation when expanding or collapsing items. - * - * @default true - * @type Boolean - */ - useAnimation: { - value: true, - validator: Lang.isBoolean - }, - - /** - * @attribute animation - * @description Animation config values, see Y.Animation - * - * @default { - * duration: 1, - * easing: Easing.easeOutStrong - * } - * - * - * @type Object - */ - animation: { - value: { - duration: 1, - easing: Easing.easeOutStrong - }, - validator: function( value ){ - return Lang.isObject( value ) && Lang.isNumber( value.duration ) && - Lang.isFunction( value.easing ); - } - }, - - /** - * @attribute reorderItems - * @description Boolean indicating that items can be reordered via drag and drop.
- * - * Enabling items reordering requires also including the optional drag and drop modules in YUI instance:
- * 'dd-constrain', 'dd-proxy', 'dd-drop', or just 'dd' - * - * @default false - * @type Boolean - */ - reorderItems: { - value: false, - validator: function(value){ - return Lang.isBoolean(value) && !Lang.isUndefined( Y.DD ); - } - }, - - /** - * @attribute collapseOthersOnExpand - * @description If true, on item expanding, all other expanded and not set as always visible items, will be collapsed - * Otherwise, they will stay open - * - * @default true - * @type Boolean - */ - collapseOthersOnExpand: { - value: true, - validator: Lang.isBoolean - } -}; - -// Accordion extends Widget - -Y.extend( Accordion, Y.Widget, { +Y.Accordion = Y.Base.create( AccName, Y.Widget, [], { /** * Initializer lifecycle implementation for the Accordion class. Publishes events, * initializes internal properties and subscribes for resize event. @@ -242,7 +84,7 @@ Y.extend( Accordion, Y.Widget, { this.after( "render", Y.bind( this._afterRender, this ) ); }, - + /** * Destructor lifecycle implementation for the Accordion class. * Removes and destroys all registered items. @@ -252,22 +94,22 @@ Y.extend( Accordion, Y.Widget, { */ destructor: function() { var items, item, i, length; - + items = this.get( ITEMS ); length = items.length; - + for( i = length - 1; i >= 0; i-- ){ item = items[ i ]; - + items.splice( i, 1 ); - + this._removeItemHandles( item ); - + item.destroy(); } }, - + /** * Publishes Accordion's events * @@ -275,7 +117,7 @@ Y.extend( Accordion, Y.Widget, { * @protected */ _initEvents: function(){ - + /** * Signals the beginning of adding an item to the Accordion. * @@ -287,7 +129,7 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( BEFOREITEMADD ); - + /** * Signals an item has been added to the Accordion. * @@ -299,7 +141,7 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( ITEMADDED ); - + /** * Signals the beginning of removing an item. * @@ -311,7 +153,7 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( BEFOREITEMREMOVE ); - + /** * Signals an item has been removed from Accordion. * @@ -335,7 +177,7 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( BEFOREITEMERESIZED ); - + /** * Signals an item has been resized. * @@ -359,7 +201,7 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( BEFOREITEMEXPAND ); - + /** * Signals the beginning of collapsing an item * @@ -371,8 +213,8 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( BEFOREITEMCOLLAPSE ); - - + + /** * Signals an item has been expanded * @@ -384,7 +226,7 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( ITEMEXPANDED ); - + /** * Signals an item has been collapsed * @@ -396,7 +238,7 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( ITEMCOLLAPSED ); - + /** * Signals the beginning of reordering an item * @@ -408,7 +250,7 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( BEFOREITEMREORDER ); - + /** * Fires before the end of item reordering * @@ -420,8 +262,8 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( BEFOREENDITEMREORDER ); - - + + /** * Signals an item has been reordered * @@ -462,7 +304,7 @@ Y.extend( Accordion, Y.Widget, { */ _animations : {}, - + /** * Collection of items handles. * Keeps track of each items's event handle, as returned from Y.on or Y.after. @@ -471,8 +313,8 @@ Y.extend( Accordion, Y.Widget, { * @type Object */ _itemsHandles: {}, - - + + /** * Removes all handles, attched to given item * @@ -482,7 +324,7 @@ Y.extend( Accordion, Y.Widget, { */ _removeItemHandles: function( item ){ var itemHandles, itemHandle; - + itemHandles = this._itemsHandles[ item ]; for( itemHandle in itemHandles ){ @@ -494,7 +336,7 @@ Y.extend( Accordion, Y.Widget, { delete this._itemsHandles[ item ]; }, - + /** * Obtains the precise height of the node provided, including padding and border. * @@ -557,7 +399,7 @@ Y.extend( Accordion, Y.Widget, { } }, - + /** * Updates user interface of an item and marks it as expanded, alwaysVisible or both * @@ -604,10 +446,10 @@ Y.extend( Accordion, Y.Widget, { this._setUpResizing( params.newVal ); }, - + /** * Distributes the involved items as result of user interaction on item header. - * Some items might be stored in the list for collapsing, other in the list for expanding. + * Some items might be stored in the list for collapsing, other in the list for expanding. * Finally, invokes _processItems function, except if item has been expanded and * user has clicked on always visible icon. * If the user clicked on close icon, the item will be closed. @@ -621,7 +463,7 @@ Y.extend( Accordion, Y.Widget, { _onItemChosen: function( item, srcIconAlwaysVisible, srcIconClose ){ var toBeExcluded, alwaysVisible, expanded, collapseOthersOnExpand; - toBeExcluded = {}; + toBeExcluded = {}; collapseOthersOnExpand = this.get( COLLAPSEOTHERSONEXPAND ); alwaysVisible = item.get( ALWAYSVISIBLE ); expanded = item.get( EXPANDED ); @@ -679,11 +521,11 @@ Y.extend( Accordion, Y.Widget, { this._processItems(); }, - + /** * Helper method to adjust the height of all items, which contentHeight property is set as "stretch". * If some item has animation running, it will be stopped before running another one. - * + * * @method adjustStretchItems * @protected * @return {Number} The calculated height per strech item @@ -692,7 +534,7 @@ Y.extend( Accordion, Y.Widget, { var items = this.get( ITEMS ), heightPerStretchItem; heightPerStretchItem = this._getHeightPerStretchItem(); - + Y.Array.each( items, function( item, index, items ){ var body, bodyHeight, anim, heightSettings, expanded; @@ -723,7 +565,7 @@ Y.extend( Accordion, Y.Widget, { /** * Calculates the height per strech item. - * + * * @method _getHeightPerStretchItem * @protected * @return {Number} The calculated height per strech item @@ -739,7 +581,7 @@ Y.extend( Accordion, Y.Widget, { header = item.getStdModNode( WidgetStdMod.HEADER ); heightSettings = item.get( CONTENT_HEIGHT ); - + headerHeight = this._getNodeOffsetHeight( header ); height -= headerHeight; @@ -769,10 +611,10 @@ Y.extend( Accordion, Y.Widget, { return height; }, - + /** * Calculates the height of given item depending on its "contentHeight" property. - * + * * @method _getItemContentHeight * @protected * @param item {Y.AccordionItem} The item, which height should be calculated @@ -796,11 +638,11 @@ Y.extend( Accordion, Y.Widget, { return height; }, - + /** * Stores all items, which are expanded and not set as always visible in list * in order to be collapsed later. - * + * * @method _storeItemsForCollapsing * @protected * @param itemsToBeExcluded {Object} (optional) Contains one or more Y.AccordionItem instances, @@ -826,10 +668,10 @@ Y.extend( Accordion, Y.Widget, { }, this ); }, - + /** * Expands an item to given height. This includes also an update to item's user interface - * + * * @method _expandItem * @protected * @param item {Y.AccordionItem} The item, which should be expanded. @@ -842,12 +684,12 @@ Y.extend( Accordion, Y.Widget, { this._setItemUI( item, true, alwaysVisible ); }, - + /** - * Expands an item to given height. Depending on the useAnimation setting, + * Expands an item to given height. Depending on the useAnimation setting, * the process of expanding might be animated. This setting will be ignored, if forceSkipAnimation param * is true. - * + * * @method _processExpanding * @protected * @param item {Y.AccordionItem} An Y.AccordionItem instance to be expanded @@ -858,14 +700,14 @@ Y.extend( Accordion, Y.Widget, { _processExpanding: function( item, height, forceSkipAnimation ){ var anim, curAnim, animSettings, notifyOthers = false, accAnimationSettings, body; - + body = item.getStdModNode( WidgetStdMod.BODY ); this.fire( BEFOREITEMERESIZED, { 'item': item }); - if( body.get( "clientHeight" ) <= 0 ){ + if( body.get( "clientHeight" ) <= COLLAPSE_HEIGHT ){ notifyOthers = true; this.fire( BEFOREITEMEXPAND, { 'item': item @@ -888,9 +730,9 @@ Y.extend( Accordion, Y.Widget, { anim.set( "duration", animSettings.duration || accAnimationSettings.duration ); anim.set( "easing" , animSettings.easing || accAnimationSettings.easing ); - + curAnim = this._animations[ item ]; - + if( curAnim ){ curAnim.stop(); } @@ -940,10 +782,10 @@ Y.extend( Accordion, Y.Widget, { } }, - + /** * Collapse an item and update its user interface - * + * * @method _collapseItem * @protected * @param item {Y.AccordionItem} The item, which should be collapsed @@ -953,12 +795,12 @@ Y.extend( Accordion, Y.Widget, { this._setItemUI( item, false, false ); }, - + /** - * Collapse an item to given height. Depending on the useAnimation setting, + * Collapse an item to given height. Depending on the useAnimation setting, * the process of collapsing might be animated. This setting will be ignored, if forceSkipAnimation param * is true. - * + * * @method _processCollapsing * @protected * @param item {Y.AccordionItem} An Y.AccordionItem instance to be collapsed @@ -967,12 +809,12 @@ Y.extend( Accordion, Y.Widget, { * without taking in consideration Accordion's useAnimation setting */ _processCollapsing: function( item, height, forceSkipAnimation ){ - var anim, curAnim, animSettings, accAnimationSettings, body, + var anim, curAnim, animSettings, accAnimationSettings, body, notifyOthers = (height === COLLAPSE_HEIGHT); - + body = item.getStdModNode( WidgetStdMod.BODY ); - + this.fire( BEFOREITEMERESIZED, { 'item': item }); @@ -1001,11 +843,11 @@ Y.extend( Accordion, Y.Widget, { anim.set( "easing" , animSettings.easing || accAnimationSettings.easing ); curAnim = this._animations[ item ]; - + if( curAnim ){ curAnim.stop(); } - + item.markAsCollapsing( true ); this._animations[ item ] = anim; @@ -1051,10 +893,10 @@ Y.extend( Accordion, Y.Widget, { } }, - + /** * Make an item draggable. The item can be reordered later. - * + * * @method _initItemDragDrop * @protected * @param item {Y.AccordionItem} An Y.AccordionItem instance to be set as draggable @@ -1213,7 +1055,7 @@ Y.extend( Accordion, Y.Widget, { return true; }, - + /** * Process items as result of user interaction or properties change. * This includes four steps: @@ -1221,12 +1063,12 @@ Y.extend( Accordion, Y.Widget, { * 2. Collapse all items stored in the list for collapsing * 3. Adjust all stretch items * 4. Expand items stored in the list for expanding - * + * * @method _processItems * @protected */ _processItems: function(){ - var forCollapsing, forExpanding, itemCont, heightPerStretchItem, + var forCollapsing, forExpanding, itemCont, heightPerStretchItem, height, heightSettings, item; forCollapsing = this._forCollapsing; @@ -1263,10 +1105,10 @@ Y.extend( Accordion, Y.Widget, { this._forExpanding = {}; }, - + /** * Update properties of items, which were stored in the lists for collapsing or expanding - * + * * @method _setItemsProperties * @protected */ @@ -1294,7 +1136,7 @@ Y.extend( Accordion, Y.Widget, { /** * Handles the change of "expand" property of given item - * + * * @method _afterItemExpand * @protected * @param params {EventFacade} The event facade for the attribute change @@ -1305,18 +1147,18 @@ Y.extend( Accordion, Y.Widget, { if( params.internalCall ){ return; } - + expanded = params.newVal; item = params.currentTarget; alwaysVisible = item.get( ALWAYSVISIBLE ); collapseOthersOnExpand = this.get( COLLAPSEOTHERSONEXPAND ); - + if( expanded ){ this._forExpanding[ item ] = { 'item': item, 'alwaysVisible': alwaysVisible }; - + if( collapseOthersOnExpand ){ this._storeItemsForCollapsing(); } @@ -1325,20 +1167,20 @@ Y.extend( Accordion, Y.Widget, { 'item': item }; } - + this._processItems(); }, /** * Handles the change of "alwaysVisible" property of given item - * + * * @method _afterItemAlwaysVisible * @protected * @param params {EventFacade} The event facade for the attribute change */ _afterItemAlwaysVisible: function( params ){ var item, alwaysVisible, expanded; - + if( params.internalCall ){ return; } @@ -1368,32 +1210,32 @@ Y.extend( Accordion, Y.Widget, { return; } } - + this._processItems(); }, - - + + /** * Handles the change of "contentHeight" property of given item - * + * * @method _afterContentHeight * @protected * @param params {EventFacade} The event facade for the attribute change */ _afterContentHeight: function( params ){ var item, itemContentHeight, body, bodyHeight, expanded; - + item = params.currentTarget; - + this._adjustStretchItems(); - + if( params.newVal.method !== STRETCH ){ expanded = item.get( EXPANDED ); itemContentHeight = this._getItemContentHeight( item ); - + body = item.getStdModNode( WidgetStdMod.BODY ); bodyHeight = this._getNodeOffsetHeight( body ); - + if( itemContentHeight < bodyHeight ){ this._processCollapsing( item, itemContentHeight, !expanded ); } else if( itemContentHeight > bodyHeight ){ @@ -1401,7 +1243,7 @@ Y.extend( Accordion, Y.Widget, { } } }, - + /** * Handles the change of "contentUpdate" property of given item @@ -1443,13 +1285,13 @@ Y.extend( Accordion, Y.Widget, { } ); } }, - - + + /** * Subscribe for resize event, which could be provided from the browser or from an arbitrary object. * For example, if there is LayoutManager in the page, it is preferable to subscribe to its resize event, * instead to those, which browser provides. - * + * * @method _setUpResizing * @protected * @param value {String|Object} String "default" or object with the following properties: @@ -1472,25 +1314,26 @@ Y.extend( Accordion, Y.Widget, { } }, - + /** * Creates one or more items found in Accordion's contentBox - * + * * @method renderUI * @protected */ renderUI: function(){ - var cb, itemsDom; + var srcNode, itemsDom; - cb = this.get( CONTENT_BOX ); - itemsDom = cb.queryAll( "> div." + C_ITEM ); + srcNode = this.get( "srcNode" ); + itemsDom = srcNode.queryAll( "> ." + C_ITEM ); itemsDom.each( function( itemNode, index, itemsDom ){ var newItem; if( !this.getItem( itemNode ) ){ newItem = new Y.AccordionItem({ - contentBox: itemNode + srcNode: itemNode, + id : itemNode.get( "id" ) }); this.addItem( newItem ); @@ -1498,10 +1341,10 @@ Y.extend( Accordion, Y.Widget, { }, this ); }, - + /** * Add listener to itemChosen event in Accordion's content box - * + * * @method bindUI * @protected */ @@ -1510,8 +1353,8 @@ Y.extend( Accordion, Y.Widget, { contentBox = this.get( CONTENT_BOX ); itemChosenEvent = this.get( 'itemChosen' ); - - contentBox.delegate( itemChosenEvent, Y.bind( this._onItemChosenEvent, this ), 'div.yui-widget-hd' ); + + contentBox.delegate( itemChosenEvent, Y.bind( this._onItemChosenEvent, this ), '.yui3-widget-hd' ); }, @@ -1521,7 +1364,7 @@ Y.extend( Accordion, Y.Widget, { * * @method _onItemChosenEvent * @protected - * + * * @param e {Event} The itemChosen event */ _onItemChosenEvent: function(e){ @@ -1543,23 +1386,23 @@ Y.extend( Accordion, Y.Widget, { /** * Add an item to Accordion. Items could be added/removed multiple times and they * will be rendered in the process of adding, if not. - * The item will be expanded, collapsed, or set as always visible depending on the + * The item will be expanded, collapsed, or set as always visible depending on the * settings. Item's properties will be also updated, if they are incomplete. * For example, if alwaysVisible is true, but expanded * property is false, it will be set to true also. - * + * * If the second param, parentItem is an Y.AccordionItem instance, * registered in Accordion, the item will be added as child of the parentItem - * + * * @method addItem * @param item {Y.AccordionItem} The item to be added in Accordion * @param parentItem {Y.AccordionItem} (optional) This item will be the parent of the item being added - * + * * @return {Boolean} True in case of successfully added item, false otherwise */ addItem: function( item, parentItem ){ - var expanded, alwaysVisible, bodyContent, itemIndex, items, contentBox, - itemHandles, itemContentBox, res, cb, children, itemBoundingBox; + var expanded, alwaysVisible, itemBody, itemBodyContent, itemIndex, items, contentBox, + itemHandles, itemContentBox, res, children; res = this.fire( BEFOREITEMADD, { 'item': item @@ -1572,8 +1415,7 @@ Y.extend( Accordion, Y.Widget, { items = this.get( ITEMS ); contentBox = this.get( CONTENT_BOX ); - itemContentBox = item.get( CONTENT_BOX ); - itemBoundingBox = item.get( BOUNDING_BOX ); + itemContentBox = item.get( CONTENT_BOX ); if( !itemContentBox.inDoc() ){ if( parentItem ){ @@ -1584,24 +1426,13 @@ Y.extend( Accordion, Y.Widget, { } items.splice( itemIndex, 0, item ); - - if( item.get( RENDERED ) ){ - contentBox.insertBefore( itemBoundingBox, parentItem.get( BOUNDING_BOX ) ); - } else { - contentBox.insertBefore( itemContentBox, parentItem.get( BOUNDING_BOX ) ); - } + contentBox.insertBefore( itemContentBox, parentItem.get( BOUNDING_BOX ) ); } else { items.push( item ); - - if( item.get( RENDERED ) ){ - contentBox.insertBefore( itemBoundingBox, null ); - } else { - contentBox.insertBefore( itemContentBox, null ); - } + contentBox.insertBefore( itemContentBox, null ); } } else { - cb = this.get( CONTENT_BOX ); - children = cb.get( CHILDREN ); + children = contentBox.get( CHILDREN ); res = children.some( function( node, index, nodeList ){ if( node === itemContentBox ){ @@ -1617,16 +1448,17 @@ Y.extend( Accordion, Y.Widget, { } } - bodyContent = item.get( BODYCONTENT ); + itemBody = item.getStdModNode( WidgetStdMod.BODY ); + itemBodyContent = item.get( BODYCONTENT ); - if( !bodyContent ){ - item.set( BODYCONTENT, " " ); + if( !itemBody && !itemBodyContent ){ + item.set( BODYCONTENT, "" ); } if( !item.get( RENDERED ) ){ item.render(); } - + expanded = item.get( EXPANDED ); alwaysVisible = item.get( ALWAYSVISIBLE ); @@ -1648,20 +1480,20 @@ Y.extend( Accordion, Y.Widget, { if( this.get( "reorderItems" ) ){ this._initItemDragDrop( item ); } - + itemHandles = this._itemsHandles[ item ]; - + if( !itemHandles ){ itemHandles = {}; } - + itemHandles = { "expandedChange" : item.after( "expandedChange", Y.bind( this._afterItemExpand, this ) ), "alwaysVisibleChange" : item.after( "alwaysVisibleChange", Y.bind( this._afterItemAlwaysVisible, this ) ), "contentHeightChange" : item.after( "contentHeightChange", Y.bind( this._afterContentHeight, this ) ), "contentUpdate" : item.after( "contentUpdate", Y.bind( this._afterContentUpdate, this ) ) }; - + this._itemsHandles[ item ] = itemHandles; this.fire( ITEMADDED, { @@ -1671,19 +1503,19 @@ Y.extend( Accordion, Y.Widget, { return true; }, - + /** * Removes an previously registered item in Accordion - * + * * @method removeItem * @param p_item {Y.AccordionItem|Number} The item to be removed, or its index * @return {Y.AccordionItem} The removed item or null if not found */ removeItem: function( p_item ){ var items, bb, item = null, itemIndex; - + items = this.get( ITEMS ); - + if( Lang.isNumber( p_item ) ){ itemIndex = p_item; } else if( p_item instanceof Y.AccordionItem ){ @@ -1693,7 +1525,7 @@ Y.extend( Accordion, Y.Widget, { } if( itemIndex >= 0 ){ - + this.fire( BEFOREITEMREMOVE, { item: p_item }); @@ -1701,12 +1533,12 @@ Y.extend( Accordion, Y.Widget, { item = items.splice( itemIndex, 1 )[0]; this._removeItemHandles( item ); - + bb = item.get( BOUNDING_BOX ); bb.remove(); this._adjustStretchItems(); - + this.fire( ITEMREMOVED, { item: p_item }); @@ -1715,14 +1547,14 @@ Y.extend( Accordion, Y.Widget, { return item; }, - + /** * Searching for item, previously registered in Accordion - * + * * @method getItem * @param param {Number|Y.Node} If number, this must be item's index. * If Node, it should be the value of item's contentBox or boundingBox properties - * + * * @return {Y.AccordionItem} The found item or null */ getItem: function( param ){ @@ -1736,7 +1568,7 @@ Y.extend( Accordion, Y.Widget, { Y.Array.some( items, function( tmpItem, index, items ){ var contentBox, boundingBox; - + contentBox = tmpItem.get( CONTENT_BOX ); boundingBox = tmpItem.get( BOUNDING_BOX ); @@ -1755,10 +1587,10 @@ Y.extend( Accordion, Y.Widget, { return item; }, - + /** * Looking for the index of previously registered item - * + * * @method getItemIndex * @param item {Y.AccordionItem} The item which index should be returned * @return {Number} Item index or -1 if item has been not found @@ -1781,10 +1613,155 @@ Y.extend( Accordion, Y.Widget, { return res; } - -}); +}, { + /** + * Static property provides a string to identify the class. + * + * @property Accordion.NAME + * @type String + * @static + */ + NAME : AccName, + + /** + * Static property used to define the default attribute + * configuration for the Accordion. + * + * @property Accordion.ATTRS + * @type Object + * @static + */ + ATTRS : { + /** + * @description The event on which Accordion should listen for user interactions. + * The value can be also mousedown or mouseup. Mousedown event can be used if + * drag&drop is not enabled + * + * @attribute itemChosen + * @default click + * @type String + */ + itemChosen: { + value: "click", + validator: Lang.isString + }, + + /** + * @description Contains the items, currently added to Accordion + * + * @attribute items + * @readOnly + * @default [] + * @type Array + */ + items: { + value: [], + readOnly: true, + validator: Lang.isArray + }, + + /** + * @attribute resizeEvent + * + * @description The event on which Accordion should listen for resizing. + * The value must be one of these: + * + * For example, if we are using LayoutManager's instance as sourceObject, we will have to use its "resize" event as resizeEvent + * + * @default "default" + * @type String or Object + */ + + resizeEvent: { + value: DEFAULT, + validator: function( value ){ + if( value === DEFAULT ){ + return true; + } else if( Lang.isObject(value) ){ + if( Lang.isValue( value.sourceObject ) && Lang.isValue( value.resizeEvent ) ){ + return true; + } + } + + return false; + } + }, + + /** + * @attribute useAnimation + * @description Boolean indicating that Accordion should use animation when expanding or collapsing items. + * + * @default true + * @type Boolean + */ + useAnimation: { + value: true, + validator: Lang.isBoolean + }, + + /** + * @attribute animation + * @description Animation config values, see Y.Animation + * + * @default { + * duration: 1, + * easing: Easing.easeOutStrong + * } + * + * + * @type Object + */ + animation: { + value: { + duration: 1, + easing: Easing.easeOutStrong + }, + validator: function( value ){ + return Lang.isObject( value ) && Lang.isNumber( value.duration ) && + Lang.isFunction( value.easing ); + } + }, + + /** + * @attribute reorderItems + * @description Boolean indicating that items can be reordered via drag and drop.
+ * + * Enabling items reordering requires also including the optional drag and drop modules in YUI instance:
+ * 'dd-constrain', 'dd-proxy', 'dd-drop', or just 'dd' + * + * @default false + * @type Boolean + */ + reorderItems: { + value: false, + validator: function(value){ + return Lang.isBoolean(value) && !Lang.isUndefined( Y.DD ); + } + }, -Y.Accordion = Accordion; + /** + * @attribute collapseOthersOnExpand + * @description If true, on item expanding, all other expanded and not set as always visible items, will be collapsed + * Otherwise, they will stay open + * + * @default true + * @type Boolean + */ + collapseOthersOnExpand: { + value: true, + validator: Lang.isBoolean + } + } +}); }()); @@ -1796,23 +1773,8 @@ Y.Accordion = Accordion; (function(){ -/** - * Create an AccordionItem widget. - * - * @param config {Object} Object literal specifying AccordionItem configuration properties. - * - * @class AccordionItem - * @constructor - * @extends Widget - */ - -function AccordionItem( config ){ - AccordionItem.superclass.constructor.apply( this, arguments ); -} - // Local constants var Lang = Y.Lang, - Base = Y.Base, Node = Y.Node, JSON = Y.JSON, WidgetStdMod = Y.WidgetStdMod, @@ -1843,15 +1805,14 @@ var Lang = Y.Lang, TITLE = "title", STRINGS = "strings", - CONTENT_BOX = "contentBox", RENDERED = "rendered", CLASS_NAME = "className", AUTO = "auto", STRETCH = "stretch", FIXED = "fixed", - HEADER_SELECTOR = ".yui-widget-hd", + HEADER_SELECTOR = ".yui3-widget-hd", DOT = ".", - HEADER_SELECTOR_SUB = ".yui-widget-hd " + DOT, + HEADER_SELECTOR_SUB = ".yui3-widget-hd " + DOT, INNER_HTML = "innerHTML", ICONS_CONTAINER = "iconsContainer", ICON = "icon", @@ -1862,7 +1823,6 @@ var Lang = Y.Lang, HREF = "href", HREF_VALUE = "#", YUICONFIG = "yuiConfig", - HEADER_CONTENT = "headerContent", REGEX_TRUE = /^(?:true|yes|1)$/, REGEX_AUTO = /^auto\s*/, @@ -1870,447 +1830,13 @@ var Lang = Y.Lang, REGEX_FIXED = /^fixed-\d+/; /** - * Static property provides a string to identify the class. - * - * @property AccordionItem.NAME - * @type String - * @static - */ -AccordionItem.NAME = AccItemName; - -/** - * Static property used to define the default attribute - * configuration for the Accordion. - * - * @property Accordion.ATTRS - * @type Object - * @static - */ -AccordionItem.ATTRS = { - - /** - * @description The Node, representing item's icon - * - * @attribute icon - * @default null - * @type Node - */ - icon: { - value: null, - validator: function( value ){ - return this._validateIcon( value ); - }, - setter : function( value ) { - return this._setIcon( value ); - } - }, - - /** - * @description The label of item - * - * @attribute label - * @default " " - * @type String - */ - label: { - value: " ", - validator: Lang.isString - }, - - /** - * @description The node, which contains item's label - * - * @attribute nodeLabel - * @default null - * @type Node - */ - nodeLabel: { - value: null, - validator: function( value ){ - return this._validateNodeLabel( value ); - }, - setter : function( value ) { - return this._setNodeLabel( value ); - } - }, - - - /** - * @description The container of iconAlwaysVisible, iconExpanded and iconClose - * - * @attribute iconsContainer - * @default null - * @type Node - */ - iconsContainer: { - value: null, - validator: function( value ){ - return this._validateIconsContainer( value ); - }, - setter : function( value ) { - return this._setIconsContainer( value ); - } - }, - - /** - * @description The Node, representing icon expanded - * - * @attribute iconExpanded - * @default null - * @type Node - */ - iconExpanded: { - value: null, - validator: function( value ){ - return this._validateIconExpanded( value ); - }, - setter : function( value ) { - return this._setIconExpanded( value ); - } - }, - - - /** - * @description The Node, representing icon always visible - * - * @attribute iconAlwaysVisible - * @default null - * @type Node - */ - iconAlwaysVisible: { - value: null, - validator: function( value ){ - return this._validateIconAlwaysVisible( value ); - }, - setter : function( value ) { - return this._setIconAlwaysVisible( value ); - } - }, - - - /** - * @description The Node, representing icon close, or null if the item is not closable - * - * @attribute iconClose - * @default null - * @type Node - */ - iconClose: { - value: null, - validator: function( value ){ - return this._validateIconClose( value ); - }, - setter : function( value ) { - return this._setIconClose( value ); - } - }, - - /** - * @description Get/Set expanded status of the item - * - * @attribute expanded - * @default false - * @type Boolean - */ - expanded: { - value: false, - validator: Lang.isBoolean - }, - - /** - * @description Describe the method, which will be used when expanding/collapsing - * the item. The value should be an object with at least one property ("method"): - *
- *
method
- *
The method can be one of these: "auto", "fixed" and "stretch"
- *
height
- *
Must be set only if method's value is "fixed"
- *
- * - * @attribute contentHeight - * @default auto - * @type Object - */ - contentHeight: { - value: { - method: AUTO - }, - validator: function( value ){ - if( Lang.isObject( value ) ){ - if( value.method === AUTO ){ - return true; - } else if( value.method === STRETCH ){ - return true; - } else if( value.method === FIXED && Lang.isNumber( value.height ) && - value.height >= 0 ){ - return true; - } - } - - return false; - } - }, - - /** - * @description Get/Set always visible status of the item - * - * @attribute alwaysVisible - * @default false - * @type Boolean - */ - alwaysVisible: { - value: false, - validator: Lang.isBoolean - }, - - - /** - * @description Get/Set the animaton specific settings. By default there are no any settings. - * If set, they will overwrite Accordion's animation settings - * - * @attribute animation - * @default {} - * @type Object - */ - animation: { - value: {}, - validator: Lang.isObject - }, - - /** - * @description Provides client side string localization support. - * - * @attribute strings - * @default Object English messages - * @type Object - */ - strings: { - value: { - title_always_visible_off: "Click to set always visible on", - title_always_visible_on: "Click to set always visible off", - title_iconexpanded_off: "Click to expand", - title_iconexpanded_on: "Click to collapse", - title_iconclose: "Click to close" - } - }, - - /** - * @description Boolean indicating that the item can be closed by user. - * If true, there will be placed close icon, otherwise not - * - * @attribute closable - * @default false - * @type Boolean - */ - closable: { - value: false, - validator: Lang.isBoolean - } -}; - - -/** - * Static Object hash used to capture existing markup for progressive - * enhancement. Keys correspond to config attribute names and values - * are selectors used to inspect the contentBox for an existing node - * structure. + * Create an AccordionItem widget. * - * @property AccordionItem.HTML_PARSER - * @type Object - * @protected - * @static + * @class AccordionItem + * @extends Widget */ -AccordionItem.HTML_PARSER = { - - icon: HEADER_SELECTOR_SUB + C_ICON, - - label: function( contentBox ){ - var node, labelSelector, yuiConfig, label; - - yuiConfig = this._getConfigDOMAttribute( contentBox ); - - if( yuiConfig && Lang.isValue( yuiConfig.label ) ){ - return yuiConfig.label; - } - - label = contentBox.getAttribute( "data-label" ); - - if( label ){ - return label; - } - - labelSelector = HEADER_SELECTOR_SUB + C_LABEL; - node = contentBox.query( labelSelector ); - - return (node) ? node.get( INNER_HTML ) : null; - }, - - nodeLabel: HEADER_SELECTOR_SUB + C_LABEL, - - iconsContainer: HEADER_SELECTOR_SUB + C_ICONSCONTAINER, - - iconAlwaysVisible: HEADER_SELECTOR_SUB + C_ICONALWAYSVISIBLE, - - iconExpanded: HEADER_SELECTOR_SUB + C_ICONEXPANDED, - - iconClose: HEADER_SELECTOR_SUB + C_ICONCLOSE, - - expanded: function( contentBox ){ - var yuiConfig, expanded; - - yuiConfig = this._getConfigDOMAttribute( contentBox ); - - if( yuiConfig && Lang.isBoolean( yuiConfig.expanded ) ){ - return yuiConfig.expanded; - } - - expanded = contentBox.getAttribute( "data-expanded" ); - - if( expanded ) { - return REGEX_TRUE.test( expanded ); - } - - return contentBox.hasClass( C_EXPANDED ); - }, - - alwaysVisible: function( contentBox ){ - var yuiConfig, alwaysVisible; - - yuiConfig = this._getConfigDOMAttribute( contentBox ); - - if( yuiConfig && Lang.isBoolean( yuiConfig.alwaysVisible ) ){ - alwaysVisible = yuiConfig.alwaysVisible; - } else { - alwaysVisible = contentBox.getAttribute( "data-alwaysvisible" ); - - if( alwaysVisible ) { - alwaysVisible = REGEX_TRUE.test( alwaysVisible ); - } else { - alwaysVisible = contentBox.hasClass( C_ALWAYSVISIBLE ); - } - } - - if( alwaysVisible ){ - this.set( "expanded", true, { - internalCall: true - } ); - } - - return alwaysVisible; - }, - - closable: function( contentBox ){ - var yuiConfig, closable; - - yuiConfig = this._getConfigDOMAttribute( contentBox ); - - if( yuiConfig && Lang.isBoolean( yuiConfig.closable ) ){ - return yuiConfig.closable; - } - - closable = contentBox.getAttribute( "data-closable" ); - - if( closable ) { - return REGEX_TRUE.test( closable ); - } - - return contentBox.hasClass( C_CLOSABLE ); - }, - - contentHeight: function( contentBox ){ - var contentHeightClass, classValue, height = 0, index, yuiConfig, - contentHeight; - - yuiConfig = this._getConfigDOMAttribute( contentBox ); - - if( yuiConfig && yuiConfig.contentHeight ){ - return yuiConfig.contentHeight; - } - - contentHeight = contentBox.getAttribute( "data-contentheight" ); - - if( REGEX_AUTO.test( contentHeight ) ){ - return { - method: AUTO - }; - } else if( REGEX_STRETCH.test( contentHeight ) ){ - return { - method: STRETCH - }; - } else if( REGEX_FIXED.test( contentHeight ) ){ - height = this._extractFixedMethodValue( contentHeight ); - - return { - method: FIXED, - height: height - }; - } - - - classValue = contentBox.get( CLASS_NAME ); - - contentHeightClass = C_CONTENTHEIGHT + '-'; - - index = classValue.indexOf( contentHeightClass, 0); - - if( index >= 0 ){ - index += contentHeightClass.length; - - classValue = classValue.substring( index ); - - if( REGEX_AUTO.test( classValue ) ){ - return { - method: AUTO - }; - } else if( REGEX_STRETCH.test( classValue ) ){ - return { - method: STRETCH - }; - } else if( REGEX_FIXED.test( classValue ) ){ - height = this._extractFixedMethodValue( classValue ); - - return { - method: FIXED, - height: height - }; - } - } - - return null; - } -}; - - - /** - * The template HTML strings for each of header components. - * e.g. - *
-  *    {
-  *       icon : '<a class="yui-accordion-item-icon"></a>',
-  *       label: '<a href="#" class="yui-accordion-item-label"></a>',
-  *       iconsContainer: '<div class="yui-accordion-item-icons"></div>',
-  *       iconAlwaysVisible: '<a href="#" class="yui-accordion-item-iconalwaysvisible"></a>',
-  *       iconExpanded: '<a href="#" class="yui-accordion-item-iconexpanded"></a>',
-  *       iconClose: '<a href="#" class="yui-accordion-item-iconclose yui-accordion-item-iconclose-hidden"></a>'
-  *    }
-  * 
- * @property WidgetStdMod.TEMPLATES - * @type Object - */ -AccordionItem.TEMPLATES = { - icon : '', - label: '', - iconsContainer: '
', - iconExpanded: [''].join(''), - iconAlwaysVisible: [''].join(''), - iconClose: [''].join('') -}; - - -// AccordionItem extends Widget - -Y.extend( AccordionItem, Y.Widget, { +Y.AccordionItem = Y.Base.create( AccItemName, Y.Widget, [Y.WidgetStdMod], { /** * Creates the header content * @@ -2327,11 +1853,11 @@ Y.extend( AccordionItem, Y.Widget, { iconAlwaysVisible = this.get( ICON_ALWAYSVISIBLE ); iconClose = this.get( ICON_CLOSE ); iconsContainer = this.get( ICONS_CONTAINER ); - + strings = this.get( STRINGS ); closable = this.get( "closable" ); - templates = AccordionItem.TEMPLATES; - + templates = Y.AccordionItem.TEMPLATES; + if( !icon ){ icon = Node.create( templates.icon ); this.set( ICON, icon ); @@ -2360,7 +1886,7 @@ Y.extend( AccordionItem, Y.Widget, { iconAlwaysVisible.setAttribute( HREF, HREF_VALUE ); } - + if( !iconExpanded ){ iconExpanded = Node.create( templates.iconExpanded ); iconExpanded.setAttribute( TITLE, strings.title_iconexpanded_off ); @@ -2368,8 +1894,8 @@ Y.extend( AccordionItem, Y.Widget, { } else if( !iconExpanded.hasAttribute( HREF ) ){ iconExpanded.setAttribute( HREF, HREF_VALUE ); } - - + + if( !iconClose ){ iconClose = Node.create( templates.iconClose ); iconClose.setAttribute( TITLE, strings.title_iconclose ); @@ -2377,7 +1903,7 @@ Y.extend( AccordionItem, Y.Widget, { } else if( !iconClose.hasAttribute( HREF ) ){ iconClose.setAttribute( HREF, HREF_VALUE ); } - + if( closable ){ iconClose.removeClass( C_ICONCLOSE_HIDDEN ); } else { @@ -2404,7 +1930,7 @@ Y.extend( AccordionItem, Y.Widget, { iconClose = this.get( ICON_CLOSE ); iconsContainer = this.get( ICONS_CONTAINER ); - header = this.get( HEADER_CONTENT ); + header = this.getStdModNode( WidgetStdMod.HEADER ); if( !header ){ header = new Node( document.createDocumentFragment() ); @@ -2450,14 +1976,14 @@ Y.extend( AccordionItem, Y.Widget, { /** * Handles the change of "labelChanged" property. Updates item's UI with the label provided - * + * * @method _labelChanged * @protected * @param params {EventFacade} The event facade for the attribute change */ _labelChanged: function( params ){ var label; - + if( this.get( RENDERED ) ){ label = this.get( NODE_LABEL ); label.set( INNER_HTML, params.newVal ); @@ -2498,8 +2024,8 @@ Y.extend( AccordionItem, Y.Widget, { this.after( "labelChange", Y.bind( this._labelChanged, this ) ); this.after( "closableChange", Y.bind( this._closableChanged, this ) ); }, - - + + /** * Destructor lifecycle implementation for the AccordionItem class. * @@ -2510,17 +2036,17 @@ Y.extend( AccordionItem, Y.Widget, { // EMPTY }, - + /** * Creates AccordionItem's header. - * + * * @method renderUI * @protected */ renderUI: function(){ this._createHeader(); }, - + /** * Configures/Sets up listeners to bind Widget State to UI/DOM * @@ -2528,10 +2054,8 @@ Y.extend( AccordionItem, Y.Widget, { * @protected */ bindUI: function(){ - var contentBox; - - contentBox = this.get( CONTENT_BOX ); - + var contentBox = this.get( "contentBox" ); + contentBox.delegate( "click", Y.bind( this._onLinkClick, this ), HEADER_SELECTOR + ' a' ); }, @@ -2548,11 +2072,11 @@ Y.extend( AccordionItem, Y.Widget, { _onLinkClick: function( e ){ e.preventDefault(); }, - + /** * Marks the item as always visible by adding class to always visible icon. * The icon will be updated only if needed. - * + * * @method markAsAlwaysVisible * @param alwaysVisible {Boolean} If true, the item should be marked as always visible. * @return {Boolean} Return true if the icon has been updated, false if there was no need to update @@ -2576,22 +2100,22 @@ Y.extend( AccordionItem, Y.Widget, { return true; } } - + return false; }, - + /** * Marks the item as expanded by adding class to expand icon. * The icon will be updated only if needed. - * + * * @method markAsExpanded * @param expanded {Boolean} Boolean indicating that item should be marked as expanded. * @return {Boolean} Return true if the icon has been updated, false if there was no need to update */ markAsExpanded: function( expanded ){ var strings, iconExpanded; - + iconExpanded = this.get( ICON_EXPANDED ); strings = this.get( STRINGS ); @@ -2608,22 +2132,22 @@ Y.extend( AccordionItem, Y.Widget, { return true; } } - + return false; }, - + /** * Marks the item as expanding by adding class to expand icon. * The method will update icon only if needed. - * + * * @method markAsExpanding * @param expanding {Boolean} Boolean indicating that the item should be marked as expanding. * @return {Boolean} Return true if the icon has been updated, false if there was no need to update */ markAsExpanding: function( expanding ){ var iconExpanded = this.get( ICON_EXPANDED ); - + if( expanding ){ if( !iconExpanded.hasClass( C_ICONEXPANDED_EXPANDING ) ){ iconExpanded.addClass( C_ICONEXPANDED_EXPANDING ); @@ -2635,15 +2159,15 @@ Y.extend( AccordionItem, Y.Widget, { return true; } } - + return false; }, - + /** * Marks the item as collapsing by adding class to expand icon. * The method will update icon only if needed. - * + * * @method markAsCollapsing * @param collapsing {Boolean} Boolean indicating that the item should be marked as collapsing. * @return {Boolean} Return true if the icon has been updated, false if there was no need to update @@ -2662,7 +2186,7 @@ Y.extend( AccordionItem, Y.Widget, { return true; } } - + return false; }, @@ -2678,28 +2202,6 @@ Y.extend( AccordionItem, Y.Widget, { }, - /** - * Parses and returns the yuiConfig attribute from contentBox. It must be stringified JSON object. - * This function will be replaced with more clever solution when YUI 3.1 becomes available - * - * @method _getConfigDOMAttribute - * @param contentBox {Node} Widget's contentBox - * @return {Object} The parsed yuiConfig value - * @private - */ - _getConfigDOMAttribute: function( contentBox ) { - if( !this._parsedCfg ){ - this._parsedCfg = contentBox.getAttribute( YUICONFIG ); - - if( this._parsedCfg ){ - this._parsedCfg = JSON.parse( this._parsedCfg ); - } - } - - return this._parsedCfg; - }, - - /** * Parses and returns the value of contentHeight property, if set method "fixed". * The value must be in this format: fixed-X, where X is integer @@ -2725,8 +2227,8 @@ Y.extend( AccordionItem, Y.Widget, { return height; }, - - + + /** * Validator applied to the icon attribute. Setting new value is not allowed if Accordion has been rendered. * @@ -2738,8 +2240,8 @@ Y.extend( AccordionItem, Y.Widget, { _validateIcon: function( value ) { return !this.get(RENDERED) || value; }, - - + + /** * Validator applied to the nodeLabel attribute. Setting new value is not allowed if Accordion has been rendered. * @@ -2751,8 +2253,8 @@ Y.extend( AccordionItem, Y.Widget, { _validateNodeLabel: function( value ) { return !this.get(RENDERED) || value; }, - - + + /** * Validator applied to the iconsContainer attribute. Setting new value is not allowed if Accordion has been rendered. * @@ -2764,8 +2266,8 @@ Y.extend( AccordionItem, Y.Widget, { _validateIconsContainer: function( value ) { return !this.get(RENDERED) || value; }, - - + + /** * Validator applied to the iconExpanded attribute. Setting new value is not allowed if Accordion has been rendered. * @@ -2777,8 +2279,8 @@ Y.extend( AccordionItem, Y.Widget, { _validateIconExpanded: function( value ) { return !this.get(RENDERED) || value; }, - - + + /** * Validator applied to the iconAlwaysVisible attribute. Setting new value is not allowed if Accordion has been rendered. * @@ -2790,8 +2292,8 @@ Y.extend( AccordionItem, Y.Widget, { _validateIconAlwaysVisible: function( value ) { return !this.get(RENDERED) || value; }, - - + + /** * Validator applied to the iconClose attribute. Setting new value is not allowed if Accordion has been rendered. * @@ -2803,8 +2305,8 @@ Y.extend( AccordionItem, Y.Widget, { _validateIconClose: function( value ) { return !this.get(RENDERED) || value; }, - - + + /** * Setter applied to the input when updating the icon attribute. Input can * be a Node, raw HTMLElement, or a selector string to locate it. @@ -2817,8 +2319,8 @@ Y.extend( AccordionItem, Y.Widget, { _setIcon: function( value ){ return Y.get( value ) || null; }, - - + + /** * Setter applied to the input when updating the nodeLabel attribute. Input can * be a Node, raw HTMLElement, or a selector string to locate it. @@ -2831,8 +2333,8 @@ Y.extend( AccordionItem, Y.Widget, { _setNodeLabel: function( value ){ return Y.get( value ) || null; }, - - + + /** * Setter applied to the input when updating the iconsContainer attribute. Input can * be a Node, raw HTMLElement, or a selector string to locate it. @@ -2845,8 +2347,8 @@ Y.extend( AccordionItem, Y.Widget, { _setIconsContainer: function( value ){ return Y.get( value ) || null; }, - - + + /** * Setter applied to the input when updating the iconExpanded attribute. Input can * be a Node, raw HTMLElement, or a selector string to locate it. @@ -2859,8 +2361,8 @@ Y.extend( AccordionItem, Y.Widget, { _setIconExpanded: function( value ){ return Y.get( value ) || null; }, - - + + /** * Setter applied to the input when updating the iconAlwaysVisible attribute. Input can * be a Node, raw HTMLElement, or a selector string to locate it. @@ -2873,8 +2375,8 @@ Y.extend( AccordionItem, Y.Widget, { _setIconAlwaysVisible: function( value ){ return Y.get( value ) || null; }, - - + + /** * Setter applied to the input when updating the iconClose attribute. Input can * be a Node, raw HTMLElement, or a selector string to locate it. @@ -2886,18 +2388,475 @@ Y.extend( AccordionItem, Y.Widget, { */ _setIconClose: function( value ){ return Y.get( value ) || null; + }, + + + /** + * Overwrites Widget's _applyParser method in order to parse yuiConfig attribute before entering in HTML_PARSER attributes + * + * @method _applyParser + * @protected + * @param config {Object} User configuration object (will be populated with values from Node) + */ + _applyParser : function(config) { + var srcNode; + + srcNode = this.get( "srcNode" ); + + if( srcNode ){ + this._parsedYUIConfig = srcNode.getAttribute( YUICONFIG ); + + if( this._parsedYUIConfig ){ + this._parsedYUIConfig = JSON.parse( this._parsedYUIConfig ); + } + } + + Y.AccordionItem.superclass._applyParser.apply( this, arguments ); + + delete this._parsedYUIConfig; } -}); +}, { + /** + * Static property provides a string to identify the class. + * + * @property NAME + * @type String + * @static + */ + NAME : AccItemName, -// Add WidgetStdMod's functionality to AccordionItem -Base.build( AccordionItem.NAME, AccordionItem, [ WidgetStdMod ], { - dynamic: false -}); + /** + * Static property used to define the default attribute + * configuration for the Accordion. + * + * @property Accordion.ATTRS + * @type Object + * @static + */ + ATTRS : { + + /** + * @description The Node, representing item's icon + * + * @attribute icon + * @default null + * @type Node + */ + icon: { + value: null, + validator: function( value ){ + return this._validateIcon( value ); + }, + setter : function( value ) { + return this._setIcon( value ); + } + }, + + /** + * @description The label of item + * + * @attribute label + * @default " " + * @type String + */ + label: { + value: " ", + validator: Lang.isString + }, -Y.AccordionItem = AccordionItem; + /** + * @description The node, which contains item's label + * + * @attribute nodeLabel + * @default null + * @type Node + */ + nodeLabel: { + value: null, + validator: function( value ){ + return this._validateNodeLabel( value ); + }, + setter : function( value ) { + return this._setNodeLabel( value ); + } + }, + + + /** + * @description The container of iconAlwaysVisible, iconExpanded and iconClose + * + * @attribute iconsContainer + * @default null + * @type Node + */ + iconsContainer: { + value: null, + validator: function( value ){ + return this._validateIconsContainer( value ); + }, + setter : function( value ) { + return this._setIconsContainer( value ); + } + }, + + /** + * @description The Node, representing icon expanded + * + * @attribute iconExpanded + * @default null + * @type Node + */ + iconExpanded: { + value: null, + validator: function( value ){ + return this._validateIconExpanded( value ); + }, + setter : function( value ) { + return this._setIconExpanded( value ); + } + }, + + + /** + * @description The Node, representing icon always visible + * + * @attribute iconAlwaysVisible + * @default null + * @type Node + */ + iconAlwaysVisible: { + value: null, + validator: function( value ){ + return this._validateIconAlwaysVisible( value ); + }, + setter : function( value ) { + return this._setIconAlwaysVisible( value ); + } + }, + + + /** + * @description The Node, representing icon close, or null if the item is not closable + * + * @attribute iconClose + * @default null + * @type Node + */ + iconClose: { + value: null, + validator: function( value ){ + return this._validateIconClose( value ); + }, + setter : function( value ) { + return this._setIconClose( value ); + } + }, + + /** + * @description Get/Set expanded status of the item + * + * @attribute expanded + * @default false + * @type Boolean + */ + expanded: { + value: false, + validator: Lang.isBoolean + }, + + /** + * @description Describe the method, which will be used when expanding/collapsing + * the item. The value should be an object with at least one property ("method"): + *
+ *
method
+ *
The method can be one of these: "auto", "fixed" and "stretch"
+ *
height
+ *
Must be set only if method's value is "fixed"
+ *
+ * + * @attribute contentHeight + * @default auto + * @type Object + */ + contentHeight: { + value: { + method: AUTO + }, + validator: function( value ){ + if( Lang.isObject( value ) ){ + if( value.method === AUTO ){ + return true; + } else if( value.method === STRETCH ){ + return true; + } else if( value.method === FIXED && Lang.isNumber( value.height ) && + value.height >= 0 ){ + return true; + } + } + + return false; + } + }, + + /** + * @description Get/Set always visible status of the item + * + * @attribute alwaysVisible + * @default false + * @type Boolean + */ + alwaysVisible: { + value: false, + validator: Lang.isBoolean + }, + + + /** + * @description Get/Set the animaton specific settings. By default there are no any settings. + * If set, they will overwrite Accordion's animation settings + * + * @attribute animation + * @default {} + * @type Object + */ + animation: { + value: {}, + validator: Lang.isObject + }, + + /** + * @description Provides client side string localization support. + * + * @attribute strings + * @default Object English messages + * @type Object + */ + strings: { + value: { + title_always_visible_off: "Click to set always visible on", + title_always_visible_on: "Click to set always visible off", + title_iconexpanded_off: "Click to expand", + title_iconexpanded_on: "Click to collapse", + title_iconclose: "Click to close" + } + }, + + /** + * @description Boolean indicating that the item can be closed by user. + * If true, there will be placed close icon, otherwise not + * + * @attribute closable + * @default false + * @type Boolean + */ + closable: { + value: false, + validator: Lang.isBoolean + } + }, + + + /** + * Static Object hash used to capture existing markup for progressive + * enhancement. Keys correspond to config attribute names and values + * are selectors used to inspect the srcNode for an existing node + * structure. + * + * @property HTML_PARSER + * @type Object + * @protected + * @static + */ + HTML_PARSER : { + + icon: HEADER_SELECTOR_SUB + C_ICON, + + label: function( srcNode ){ + var node, labelSelector, yuiConfig, label; + + yuiConfig = this._parsedYUIConfig; + + if( yuiConfig && Lang.isValue( yuiConfig.label ) ){ + return yuiConfig.label; + } + + label = srcNode.getAttribute( "data-label" ); + + if( label ){ + return label; + } + + labelSelector = HEADER_SELECTOR_SUB + C_LABEL; + node = srcNode.query( labelSelector ); + + return (node) ? node.get( INNER_HTML ) : null; + }, + + nodeLabel: HEADER_SELECTOR_SUB + C_LABEL, + + iconsContainer: HEADER_SELECTOR_SUB + C_ICONSCONTAINER, + + iconAlwaysVisible: HEADER_SELECTOR_SUB + C_ICONALWAYSVISIBLE, + + iconExpanded: HEADER_SELECTOR_SUB + C_ICONEXPANDED, + + iconClose: HEADER_SELECTOR_SUB + C_ICONCLOSE, + + expanded: function( srcNode ){ + var yuiConfig, expanded; + + yuiConfig = this._parsedYUIConfig; + + if( yuiConfig && Lang.isBoolean( yuiConfig.expanded ) ){ + return yuiConfig.expanded; + } + + expanded = srcNode.getAttribute( "data-expanded" ); + + if( expanded ) { + return REGEX_TRUE.test( expanded ); + } + + return srcNode.hasClass( C_EXPANDED ); + }, + + alwaysVisible: function( srcNode ){ + var yuiConfig, alwaysVisible; + + yuiConfig = this._parsedYUIConfig; + + if( yuiConfig && Lang.isBoolean( yuiConfig.alwaysVisible ) ){ + alwaysVisible = yuiConfig.alwaysVisible; + } else { + alwaysVisible = srcNode.getAttribute( "data-alwaysvisible" ); + + if( alwaysVisible ) { + alwaysVisible = REGEX_TRUE.test( alwaysVisible ); + } else { + alwaysVisible = srcNode.hasClass( C_ALWAYSVISIBLE ); + } + } + + if( alwaysVisible ){ + this.set( "expanded", true, { + internalCall: true + } ); + } + + return alwaysVisible; + }, + + closable: function( srcNode ){ + var yuiConfig, closable; + + yuiConfig = this._parsedYUIConfig; + + if( yuiConfig && Lang.isBoolean( yuiConfig.closable ) ){ + return yuiConfig.closable; + } + + closable = srcNode.getAttribute( "data-closable" ); + + if( closable ) { + return REGEX_TRUE.test( closable ); + } + + return srcNode.hasClass( C_CLOSABLE ); + }, + + contentHeight: function( srcNode ){ + var contentHeightClass, classValue, height = 0, index, yuiConfig, + contentHeight; + + yuiConfig = this._parsedYUIConfig; + + if( yuiConfig && yuiConfig.contentHeight ){ + return yuiConfig.contentHeight; + } + + contentHeight = srcNode.getAttribute( "data-contentheight" ); + + if( REGEX_AUTO.test( contentHeight ) ){ + return { + method: AUTO + }; + } else if( REGEX_STRETCH.test( contentHeight ) ){ + return { + method: STRETCH + }; + } else if( REGEX_FIXED.test( contentHeight ) ){ + height = this._extractFixedMethodValue( contentHeight ); + + return { + method: FIXED, + height: height + }; + } + + + classValue = srcNode.get( CLASS_NAME ); + + contentHeightClass = C_CONTENTHEIGHT + '-'; + + index = classValue.indexOf( contentHeightClass, 0); + + if( index >= 0 ){ + index += contentHeightClass.length; + + classValue = classValue.substring( index ); + + if( REGEX_AUTO.test( classValue ) ){ + return { + method: AUTO + }; + } else if( REGEX_STRETCH.test( classValue ) ){ + return { + method: STRETCH + }; + } else if( REGEX_FIXED.test( classValue ) ){ + height = this._extractFixedMethodValue( classValue ); + + return { + method: FIXED, + height: height + }; + } + } + + return null; + } + }, + + + /** + * The template HTML strings for each of header components. + * e.g. + *
+      *    {
+      *       icon : '<a class="yui3-accordion-item-icon"></a>',
+      *       label: '<a href="#" class="yui3-accordion-item-label"></a>',
+      *       iconsContainer: '<div class="yui3-accordion-item-icons"></div>',
+      *       iconAlwaysVisible: '<a href="#" class="yui3-accordion-item-iconalwaysvisible"></a>',
+      *       iconExpanded: '<a href="#" class="yui3-accordion-item-iconexpanded"></a>',
+      *       iconClose: '<a href="#" class="yui3-accordion-item-iconclose yui3-accordion-item-iconclose-hidden"></a>'
+      *    }
+      * 
+ * @property WidgetStdMod.TEMPLATES + * @type Object + */ + TEMPLATES : { + icon : '', + label: '', + iconsContainer: '
', + iconExpanded: [''].join(''), + iconAlwaysVisible: [''].join(''), + iconClose: [''].join('') + } + +}); }()); -}, 'gallery-2010.03.02-18' ,{requires:['event', 'anim-easing', 'widget', 'widget-stdmod', 'json-parse'], optional:['dd-constrain', 'dd-proxy', 'dd-drop']}); +}, 'gallery-2010.04.02-17-26' ,{optional:['dd-constrain', 'dd-proxy', 'dd-drop'], requires:['event', 'anim-easing', 'widget', 'widget-stdmod', 'json-parse']}); diff --git a/build/gallery-accordion/gallery-accordion-min.js b/build/gallery-accordion/gallery-accordion-min.js index 84e1f20c33..ee531a40aa 100644 --- a/build/gallery-accordion/gallery-accordion-min.js +++ b/build/gallery-accordion/gallery-accordion-min.js @@ -1,4 +1,4 @@ -YUI.add("gallery-accordion",function(A){(function(){function M(v){M.superclass.constructor.apply(this,arguments);}var u=A.Lang,V=A.Node,Z=A.Anim,H=A.Easing,N="accordion",X=A.WidgetStdMod,s=document.compatMode=="BackCompat",T=s&&A.UA.ie>0,U=T?1:0,I=A.ClassNameManager.getClassName,W="yui-accordion-item",f=I(N,"proxyel","visible"),h=I(N,"graggroup"),b="beforeItemAdd",e="itemAdded",D="beforeItemRemove",i="itemRemoved",C="beforeItemResized",p="itemResized",d="beforeItemExpand",g="beforeItemCollapse",J="itemExpanded",m="itemCollapsed",j="beforeItemReorder",R="beforeEndItemReorder",S="itemReordered",k="default",O="animation",P="alwaysVisible",E="expanded",c="collapseOthersOnExpand",Y="items",t="contentHeight",B="iconClose",F="iconAlwaysVisible",G="stretch",r="px",a="contentBox",n="boundingBox",l="rendered",o="bodyContent",Q="children",K="parentNode",q="node",L="data";M.NAME=N;M.ATTRS={itemChosen:{value:"click",validator:u.isString},items:{value:[],readOnly:true,validator:u.isArray},resizeEvent:{value:k,validator:function(v){if(v===k){return true;}else{if(u.isObject(v)){if(u.isValue(v.sourceObject)&&u.isValue(v.resizeEvent)){return true;}}}return false;}},useAnimation:{value:true,validator:u.isBoolean},animation:{value:{duration:1,easing:H.easeOutStrong},validator:function(v){return u.isObject(v)&&u.isNumber(v.duration)&&u.isFunction(v.easing);}},reorderItems:{value:false,validator:function(v){return u.isBoolean(v)&&!u.isUndefined(A.DD);}},collapseOthersOnExpand:{value:true,validator:u.isBoolean}};A.extend(M,A.Widget,{initializer:function(v){this._initEvents();this.after("render",A.bind(this._afterRender,this));},destructor:function(){var v,y,w,x;v=this.get(Y);x=v.length;for(w=x-1;w>=0;w--){y=v[w];v.splice(w,1);this._removeItemHandles(y);y.destroy();}},_initEvents:function(){this.publish(b);this.publish(e);this.publish(D);this.publish(i);this.publish(C);this.publish(p);this.publish(d);this.publish(g);this.publish(J);this.publish(m);this.publish(j);this.publish(R);this.publish(S);},_forCollapsing:{},_forExpanding:{},_animations:{},_itemsHandles:{},_removeItemHandles:function(x){var w,v;w=this._itemsHandles[x];for(v in w){if(w.hasOwnProperty(v)){v=w[v];v.detach();}}delete this._itemsHandles[x];},_getNodeOffsetHeight:function(x){var v,w;if(x instanceof V){if(x.hasMethod("getBoundingClientRect")){w=x.invoke("getBoundingClientRect");if(w){v=w.bottom-w.top;return v;}}else{v=x.get("offsetHeight");return A.Lang.isValue(v)?v:0;}}else{if(x){v=x.offsetHeight;return A.Lang.isValue(v)?v:0;}}return 0;},_setItemProperties:function(x,z,w){var v,y;v=x.get(P);y=x.get(E);if(z!=y){x.set(E,z,{internalCall:true});}if(w!==v){x.set(P,w,{internalCall:true});}},_setItemUI:function(w,x,v){w.markAsExpanded(x);w.markAsAlwaysVisible(v);},_afterRender:function(w){var v;v=this.get("resizeEvent");this._setUpResizing(v);this.after("resizeEventChange",A.bind(this._afterResizeEventChange,this));},_afterResizeEventChange:function(v){this._setUpResizing(v.newVal);},_onItemChosen:function(AA,AB,v){var z,x,y,w;z={};w=this.get(c);x=AA.get(P);y=AA.get(E);if(v){this.removeItem(AA);return;}else{if(AB){if(y){x=!x;y=x?true:y;this._setItemProperties(AA,y,x);this._setItemUI(AA,y,x);return;}else{this._forExpanding[AA]={"item":AA,alwaysVisible:true};if(w){z[AA]={"item":AA};this._storeItemsForCollapsing(z);}}}else{if(y){this._forCollapsing[AA]={"item":AA};}else{this._forExpanding[AA]={"item":AA,"alwaysVisible":x};if(w){z[AA]={"item":AA};this._storeItemsForCollapsing(z);}}}}this._processItems();},_adjustStretchItems:function(){var v=this.get(Y),w;w=this._getHeightPerStretchItem();A.Array.each(v,function(AB,AA,z){var x,AD,AC,AE,y;AE=AB.get(t);y=AB.get(E);if(AE.method===G&&y){AC=this._animations[AB];if(AC){AC.stop();}x=AB.getStdModNode(X.BODY);AD=this._getNodeOffsetHeight(x);if(wAD){this._processExpanding(AB,w);}}}},this);return w;},_getHeightPerStretchItem:function(){var v,x,w=0;x=this.get(Y);v=this.get(n).get("clientHeight");A.Array.each(x,function(AC,AB,AA){var AD,z,AF,AE,y;AF=AC.getStdModNode(X.HEADER);AE=AC.get(t);y=this._getNodeOffsetHeight(AF);v-=y;AD=!AC.get(E);if(AD){v-=U;return;}if(AE.method===G){w++;}else{z=this._getItemContentHeight(AC);v-=z;}},this);if(w>0){v/=w;}if(v<0){v=0;}return v;},_getItemContentHeight:function(x){var z,w=0,v,y;z=x.get(t);if(z.method==="auto"){v=x.getStdModNode(X.BODY);y=v.get(Q).item(0);w=y?this._getNodeOffsetHeight(y):0;}else{if(z.method==="fixed"){w=z.height;}else{w=this._getHeightPerStretchItem();}}return w;},_storeItemsForCollapsing:function(w){var v;w=w||{};v=this.get(Y);A.Array.each(v,function(AB,AA,z){var y,x;y=AB.get(E);x=AB.get(P);if(y&&!x&&!w[AB]){this._forCollapsing[AB]={"item":AB};}},this);},_expandItem:function(x,v){var w=x.get(P);this._processExpanding(x,v);this._setItemUI(x,true,w);},_processExpanding:function(AC,AB,v){var w,x,z,AD=false,AA,y;y=AC.getStdModNode(X.BODY);this.fire(C,{"item":AC});if(y.get("clientHeight")<=0){AD=true;this.fire(d,{"item":AC});}if(!v&&this.get("useAnimation")){z=AC.get(O)||{};w=new Z({node:y,to:{"height":AB}});w.on("end",A.bind(this._onExpandComplete,this,AC,AD));AA=this.get(O);w.set("duration",z.duration||AA.duration);w.set("easing",z.easing||AA.easing);x=this._animations[AC];if(x){x.stop();}AC.markAsExpanding(true);this._animations[AC]=w;w.run();}else{y.setStyle("height",AB+r);this.fire(p,{"item":AC});if(AD){this.fire(J,{"item":AC});}}},_onExpandComplete:function(v,w){delete this._animations[v];v.markAsExpanding(false);this.fire(p,{"item":v});if(w){this.fire(J,{"item":v});}},_collapseItem:function(v){this._processCollapsing(v,U);this._setItemUI(v,false,false);},_processCollapsing:function(AC,AB,v){var w,x,z,AA,y,AD=(AB===U);y=AC.getStdModNode(X.BODY);this.fire(C,{"item":AC});if(AD){this.fire(g,{"item":AC});}if(!v&&this.get("useAnimation")){z=AC.get(O)||{};w=new Z({node:y,to:{"height":AB}});w.on("end",A.bind(this._onCollapseComplete,this,AC,AD));AA=this.get(O);w.set("duration",z.duration||AA.duration);w.set("easing",z.easing||AA.easing); -x=this._animations[AC];if(x){x.stop();}AC.markAsCollapsing(true);this._animations[AC]=w;w.run();}else{y.setStyle("height",AB+r);this.fire(p,{"item":AC});if(AD){this.fire(m,{"item":AC});}}},_onCollapseComplete:function(v,w){delete this._animations[v];v.markAsCollapsing(false);this.fire(p,{item:v});if(w){this.fire(m,{"item":v});}},_initItemDragDrop:function(w){var AA,v,z,x,y;AA=w.getStdModNode(X.HEADER);if(AA.dd){return;}z=this.get(n);x=w.get(n);v=new A.DD.Drag({node:AA,groups:[h]}).plug(A.Plugin.DDProxy,{moveOnEnd:false}).plug(A.Plugin.DDConstrained,{constrain2node:z});y=new A.DD.Drop({node:x,groups:[h]});v.on("drag:start",A.bind(this._onDragStart,this,v));v.on("drag:end",A.bind(this._onDragEnd,this,v));v.after("drag:end",A.bind(this._afterDragEnd,this,v));v.on("drag:drophit",A.bind(this._onDropHit,this,v));},_onDragStart:function(v,y){var x,w;w=this.getItem(v.get(q).get(K));x=v.get("dragNode");x.addClass(f);x.set("innerHTML",w.get("label"));return this.fire(j,{"item":w});},_onDragEnd:function(v,y){var x,w;x=v.get("dragNode");x.removeClass(f);x.set("innerHTML","");w=this.getItem(v.get(q).get(K));return this.fire(R,{"item":w});},_afterDragEnd:function(v,y){var w,x;x=v.get(L);if(x.drophit){w=this.getItem(v.get(q).get(K));v.set(L,{drophit:false});return this.fire(S,{"item":w});}return true;},_onDropHit:function(AE,AA){var z,AD,w,AC,y,v,AB,x,AF;AF=this.getItem(AE.get(q).get(K));x=this.getItem(AA.drop.get(q));if(x===AF){return false;}z=this.getItemIndex(AF);AD=this.getItemIndex(x);w=x.get(n);AC=AF.get(n);y=this.get(a);v=false;AB=this.get(Y);if(ADz){this._processExpanding(y,w,!x);}}}},_afterContentUpdate:function(AB){var y,w,v,AA,x,AC,z;y=AB.currentTarget;AC=y.get("contentHeight").method==="auto";x=y.get(E);if(AC&&x&&AB.src!==A.Widget.UI_SRC){A.later(0,this,function(){w=this._getItemContentHeight(y);v=y.getStdModNode(X.BODY);AA=this._getNodeOffsetHeight(v);if(w!==AA){z=this._animations[y];if(z){z.stop();}this._adjustStretchItems();if(wAA){this._processExpanding(y,w,!x);}}}});}},_setUpResizing:function(v){if(this._resizeEventHandle){this._resizeEventHandle.detach();}if(v===k){this._resizeEventHandle=A.on("windowresize",A.bind(this._adjustStretchItems,this));}else{this._resizeEventHandle=v.sourceObject.on(v.resizeEvent,A.bind(this._adjustStretchItems,this));}},renderUI:function(){var v,w;v=this.get(a);w=v.queryAll("> div."+W);w.each(function(AA,x,z){var y;if(!this.getItem(AA)){y=new A.AccordionItem({contentBox:AA});this.addItem(y);}},this);},bindUI:function(){var v,w;v=this.get(a);w=this.get("itemChosen");v.delegate(w,A.bind(this._onItemChosenEvent,this),"div.yui-widget-hd");},_onItemChosenEvent:function(AA){var AC,AB,x,y,w,z,v;AC=AA.currentTarget;AB=AC.get(K);x=this.getItem(AB);y=x.get(F);w=x.get(B);z=(y===AA.target);v=(w===AA.target);this._onItemChosen(x,z,v);},addItem:function(AI,y){var AB,AG,AF,v,AD,AE,AH,AA,AC,z,x,w;AC=this.fire(b,{"item":AI});if(!AC){return false;}AD=this.get(Y);AE=this.get(a);AA=AI.get(a);w=AI.get(n);if(!AA.inDoc()){if(y){v=this.getItemIndex(y);if(v<0){return false;}AD.splice(v,0,AI);if(AI.get(l)){AE.insertBefore(w,y.get(n));}else{AE.insertBefore(AA,y.get(n));}}else{AD.push(AI);if(AI.get(l)){AE.insertBefore(w,null);}else{AE.insertBefore(AA,null);}}}else{z=this.get(a);x=z.get(Q);AC=x.some(function(AL,AK,AJ){if(AL===AA){AD.splice(AK,0,AI);return true;}else{return false;}},this);if(!AC){return false;}}AF=AI.get(o);if(!AF){AI.set(o," ");}if(!AI.get(l)){AI.render();}AB=AI.get(E);AG=AI.get(P);AB=AB||AG;if(AB){this._forExpanding[AI]={"item":AI,"alwaysVisible":AG};}else{this._forCollapsing[AI]={"item":AI};}this._processItems();if(this.get("reorderItems")){this._initItemDragDrop(AI);}AH=this._itemsHandles[AI];if(!AH){AH={};}AH={"expandedChange":AI.after("expandedChange",A.bind(this._afterItemExpand,this)),"alwaysVisibleChange":AI.after("alwaysVisibleChange",A.bind(this._afterItemAlwaysVisible,this)),"contentHeightChange":AI.after("contentHeightChange",A.bind(this._afterContentHeight,this)),"contentUpdate":AI.after("contentUpdate",A.bind(this._afterContentUpdate,this))};this._itemsHandles[AI]=AH;this.fire(e,{"item":AI});return true;},removeItem:function(w){var v,z,y=null,x; -v=this.get(Y);if(u.isNumber(w)){x=w;}else{if(w instanceof A.AccordionItem){x=this.getItemIndex(w);}else{return null;}}if(x>=0){this.fire(D,{item:w});y=v.splice(x,1)[0];this._removeItemHandles(y);z=y.get(n);z.remove();this._adjustStretchItems();this.fire(i,{item:w});}return y;},getItem:function(x){var v=this.get(Y),w=null;if(u.isNumber(x)){w=v[x];return(w instanceof A.AccordionItem)?w:null;}else{if(x instanceof V){A.Array.some(v,function(AC,AB,z){var y,AA;y=AC.get(a);AA=AC.get(n);if(y===x){w=AC;return true;}else{if(AA===x){w=AC;return true;}else{return false;}}},this);}}return w;},getItemIndex:function(x){var w=-1,v;if(x instanceof A.AccordionItem){v=this.get(Y);A.Array.some(v,function(AA,z,y){if(AA===x){w=z;return true;}else{return false;}},this);}return w;}});A.Accordion=M;}());(function(){function c(AA){c.superclass.constructor.apply(this,arguments);}var y=A.Lang,S=A.Base,e=A.Node,Q=A.JSON,f=A.WidgetStdMod,h="accordion-item",O=A.ClassNameManager.getClassName,D=O(h,"iconexpanded","expanding"),w=O(h,"iconexpanded","collapsing"),P=O(h,"icon"),L=O(h,"label"),s=O(h,"iconalwaysvisible"),j=O(h,"icons"),q=O(h,"iconexpanded"),n=O(h,"iconclose"),R=O(h,"iconclose","hidden"),U=O(h,"iconexpanded","on"),M=O(h,"iconexpanded","off"),E=O(h,"iconalwaysvisible","on"),o=O(h,"iconalwaysvisible","off"),a=O(h,"expanded"),X=O(h,"closable"),l=O(h,"alwaysvisible"),m=O(h,"contentheight"),p="title",C="strings",g="contentBox",u="rendered",I="className",i="auto",K="stretch",Y="fixed",V=".yui-widget-hd",b=".",r=".yui-widget-hd "+b,v="innerHTML",x="iconsContainer",k="icon",T="nodeLabel",H="iconAlwaysVisible",d="iconExpanded",B="iconClose",t="href",W="#",G="yuiConfig",F="headerContent",J=/^(?:true|yes|1)$/,N=/^auto\s*/,z=/^stretch\s*/,Z=/^fixed-\d+/;c.NAME=h;c.ATTRS={icon:{value:null,validator:function(AA){return this._validateIcon(AA);},setter:function(AA){return this._setIcon(AA);}},label:{value:" ",validator:y.isString},nodeLabel:{value:null,validator:function(AA){return this._validateNodeLabel(AA);},setter:function(AA){return this._setNodeLabel(AA);}},iconsContainer:{value:null,validator:function(AA){return this._validateIconsContainer(AA);},setter:function(AA){return this._setIconsContainer(AA);}},iconExpanded:{value:null,validator:function(AA){return this._validateIconExpanded(AA);},setter:function(AA){return this._setIconExpanded(AA);}},iconAlwaysVisible:{value:null,validator:function(AA){return this._validateIconAlwaysVisible(AA);},setter:function(AA){return this._setIconAlwaysVisible(AA);}},iconClose:{value:null,validator:function(AA){return this._validateIconClose(AA);},setter:function(AA){return this._setIconClose(AA);}},expanded:{value:false,validator:y.isBoolean},contentHeight:{value:{method:i},validator:function(AA){if(y.isObject(AA)){if(AA.method===i){return true;}else{if(AA.method===K){return true;}else{if(AA.method===Y&&y.isNumber(AA.height)&&AA.height>=0){return true;}}}}return false;}},alwaysVisible:{value:false,validator:y.isBoolean},animation:{value:{},validator:y.isObject},strings:{value:{title_always_visible_off:"Click to set always visible on",title_always_visible_on:"Click to set always visible off",title_iconexpanded_off:"Click to expand",title_iconexpanded_on:"Click to collapse",title_iconclose:"Click to close"}},closable:{value:false,validator:y.isBoolean}};c.HTML_PARSER={icon:r+P,label:function(AA){var AD,AE,AC,AB;AC=this._getConfigDOMAttribute(AA);if(AC&&y.isValue(AC.label)){return AC.label;}AB=AA.getAttribute("data-label");if(AB){return AB;}AE=r+L;AD=AA.query(AE);return(AD)?AD.get(v):null;},nodeLabel:r+L,iconsContainer:r+j,iconAlwaysVisible:r+s,iconExpanded:r+q,iconClose:r+n,expanded:function(AA){var AC,AB;AC=this._getConfigDOMAttribute(AA);if(AC&&y.isBoolean(AC.expanded)){return AC.expanded;}AB=AA.getAttribute("data-expanded");if(AB){return J.test(AB);}return AA.hasClass(a);},alwaysVisible:function(AB){var AC,AA;AC=this._getConfigDOMAttribute(AB);if(AC&&y.isBoolean(AC.alwaysVisible)){AA=AC.alwaysVisible;}else{AA=AB.getAttribute("data-alwaysvisible");if(AA){AA=J.test(AA);}else{AA=AB.hasClass(l);}}if(AA){this.set("expanded",true,{internalCall:true});}return AA;},closable:function(AA){var AC,AB;AC=this._getConfigDOMAttribute(AA);if(AC&&y.isBoolean(AC.closable)){return AC.closable;}AB=AA.getAttribute("data-closable");if(AB){return J.test(AB);}return AA.hasClass(X);},contentHeight:function(AB){var AF,AG,AA=0,AC,AE,AD;AE=this._getConfigDOMAttribute(AB);if(AE&&AE.contentHeight){return AE.contentHeight;}AD=AB.getAttribute("data-contentheight");if(N.test(AD)){return{method:i};}else{if(z.test(AD)){return{method:K};}else{if(Z.test(AD)){AA=this._extractFixedMethodValue(AD);return{method:Y,height:AA};}}}AG=AB.get(I);AF=m+"-";AC=AG.indexOf(AF,0);if(AC>=0){AC+=AF.length;AG=AG.substring(AC);if(N.test(AG)){return{method:i};}else{if(z.test(AG)){return{method:K};}else{if(Z.test(AG)){AA=this._extractFixedMethodValue(AG);return{method:Y,height:AA};}}}}return null;}};c.TEMPLATES={icon:'',label:'',iconsContainer:'
',iconExpanded:[''].join(""),iconAlwaysVisible:[''].join(""),iconClose:[''].join("")};A.extend(c,A.Widget,{_createHeader:function(){var AI,AG,AH,AE,AF,AD,AB,AA,AC;AF=this.get(k);AD=this.get(T);AB=this.get(d);AA=this.get(H);AC=this.get(B);AE=this.get(x);AH=this.get(C);AI=this.get("closable");AG=c.TEMPLATES;if(!AF){AF=e.create(AG.icon);this.set(k,AF);}if(!AD){AD=e.create(AG.label);this.set(T,AD);}else{if(!AD.hasAttribute(t)){AD.setAttribute(t,W);}}AD.setContent(this.get("label"));if(!AE){AE=e.create(AG.iconsContainer);this.set(x,AE);}if(!AA){AA=e.create(AG.iconAlwaysVisible);AA.setAttribute(p,AH.title_always_visible_off);this.set(H,AA);}else{if(!AA.hasAttribute(t)){AA.setAttribute(t,W);}}if(!AB){AB=e.create(AG.iconExpanded);AB.setAttribute(p,AH.title_iconexpanded_off);this.set(d,AB);}else{if(!AB.hasAttribute(t)){AB.setAttribute(t,W); -}}if(!AC){AC=e.create(AG.iconClose);AC.setAttribute(p,AH.title_iconclose);this.set(B,AC);}else{if(!AC.hasAttribute(t)){AC.setAttribute(t,W);}}if(AI){AC.removeClass(R);}else{AC.addClass(R);}this._addHeaderComponents();},_addHeaderComponents:function(){var AG,AB,AF,AC,AE,AD,AA;AB=this.get(k);AF=this.get(T);AE=this.get(d);AD=this.get(H);AA=this.get(B);AC=this.get(x);AG=this.get(F);if(!AG){AG=new e(document.createDocumentFragment());AG.appendChild(AB);AG.appendChild(AF);AG.appendChild(AC);AC.appendChild(AD);AC.appendChild(AE);AC.appendChild(AA);this.setStdModContent(f.HEADER,AG,f.REPLACE);}else{if(!AG.contains(AB)){if(AG.contains(AF)){AG.insertBefore(AB,AF);}else{AG.appendChild(AB);}}if(!AG.contains(AF)){AG.appendChild(AF);}if(!AG.contains(AC)){AG.appendChild(AC);}if(!AC.contains(AD)){AC.appendChild(AD);}if(!AC.contains(AE)){AC.appendChild(AE);}if(!AC.contains(AA)){AC.appendChild(AA);}}},_labelChanged:function(AB){var AA;if(this.get(u)){AA=this.get(T);AA.set(v,AB.newVal);}},_closableChanged:function(AB){var AA;if(this.get(u)){AA=this.get(B);if(AB.newVal){AA.removeClass(R);}else{AA.addClass(R);}}},initializer:function(AA){this.after("labelChange",A.bind(this._labelChanged,this));this.after("closableChange",A.bind(this._closableChanged,this));},destructor:function(){},renderUI:function(){this._createHeader();},bindUI:function(){var AA;AA=this.get(g);AA.delegate("click",A.bind(this._onLinkClick,this),V+" a");},_onLinkClick:function(AA){AA.preventDefault();},markAsAlwaysVisible:function(AB){var AC,AA;AC=this.get(H);AA=this.get(C);if(AB){if(!AC.hasClass(E)){AC.replaceClass(o,E);AC.set(p,AA.title_always_visible_on);return true;}}else{if(AC.hasClass(E)){AC.replaceClass(E,o);AC.set(p,AA.title_always_visible_off);return true;}}return false;},markAsExpanded:function(AB){var AA,AC;AC=this.get(d);AA=this.get(C);if(AB){if(!AC.hasClass(U)){AC.replaceClass(M,U);AC.set(p,AA.title_iconexpanded_on);return true;}}else{if(AC.hasClass(U)){AC.replaceClass(U,M);AC.set(p,AA.title_iconexpanded_off);return true;}}return false;},markAsExpanding:function(AB){var AA=this.get(d);if(AB){if(!AA.hasClass(D)){AA.addClass(D);return true;}}else{if(AA.hasClass(D)){AA.removeClass(D);return true;}}return false;},markAsCollapsing:function(AA){var AB=this.get(d);if(AA){if(!AB.hasClass(w)){AB.addClass(w);return true;}}else{if(AB.hasClass(w)){AB.removeClass(w);return true;}}return false;},resize:function(){this.fire("contentUpdate");},_getConfigDOMAttribute:function(AA){if(!this._parsedCfg){this._parsedCfg=AA.getAttribute(G);if(this._parsedCfg){this._parsedCfg=Q.parse(this._parsedCfg);}}return this._parsedCfg;},_extractFixedMethodValue:function(AE){var AB,AD,AC,AA=null;for(AB=6,AD=AE.length;AB0,T=S?1:0,I=A.ClassNameManager.getClassName,V="yui3-accordion-item",e=I(M,"proxyel","visible"),g=I(M,"graggroup"),a="beforeItemAdd",d="itemAdded",D="beforeItemRemove",h="itemRemoved",C="beforeItemResized",o="itemResized",c="beforeItemExpand",f="beforeItemCollapse",J="itemExpanded",l="itemCollapsed",i="beforeItemReorder",Q="beforeEndItemReorder",R="itemReordered",j="default",N="animation",O="alwaysVisible",E="expanded",b="collapseOthersOnExpand",X="items",s="contentHeight",B="iconClose",F="iconAlwaysVisible",G="stretch",q="px",Z="contentBox",m="boundingBox",k="rendered",n="bodyContent",P="children",K="parentNode",p="node",L="data";A.Accordion=A.Base.create(M,A.Widget,[],{initializer:function(u){this._initEvents();this.after("render",A.bind(this._afterRender,this));},destructor:function(){var u,x,v,w;u=this.get(X);w=u.length;for(v=w-1;v>=0;v--){x=u[v];u.splice(v,1);this._removeItemHandles(x);x.destroy();}},_initEvents:function(){this.publish(a);this.publish(d);this.publish(D);this.publish(h);this.publish(C);this.publish(o);this.publish(c);this.publish(f);this.publish(J);this.publish(l);this.publish(i);this.publish(Q);this.publish(R);},_forCollapsing:{},_forExpanding:{},_animations:{},_itemsHandles:{},_removeItemHandles:function(w){var v,u;v=this._itemsHandles[w];for(u in v){if(v.hasOwnProperty(u)){u=v[u];u.detach();}}delete this._itemsHandles[w];},_getNodeOffsetHeight:function(w){var u,v;if(w instanceof U){if(w.hasMethod("getBoundingClientRect")){v=w.invoke("getBoundingClientRect");if(v){u=v.bottom-v.top;return u;}}else{u=w.get("offsetHeight");return A.Lang.isValue(u)?u:0;}}else{if(w){u=w.offsetHeight;return A.Lang.isValue(u)?u:0;}}return 0;},_setItemProperties:function(w,y,v){var u,x;u=w.get(O);x=w.get(E);if(y!=x){w.set(E,y,{internalCall:true});}if(v!==u){w.set(O,v,{internalCall:true});}},_setItemUI:function(v,w,u){v.markAsExpanded(w);v.markAsAlwaysVisible(u);},_afterRender:function(v){var u;u=this.get("resizeEvent");this._setUpResizing(u);this.after("resizeEventChange",A.bind(this._afterResizeEventChange,this));},_afterResizeEventChange:function(u){this._setUpResizing(u.newVal);},_onItemChosen:function(z,AA,u){var y,w,x,v;y={};v=this.get(b);w=z.get(O);x=z.get(E);if(u){this.removeItem(z);return;}else{if(AA){if(x){w=!w;x=w?true:x;this._setItemProperties(z,x,w);this._setItemUI(z,x,w);return;}else{this._forExpanding[z]={"item":z,alwaysVisible:true};if(v){y[z]={"item":z};this._storeItemsForCollapsing(y);}}}else{if(x){this._forCollapsing[z]={"item":z};}else{this._forExpanding[z]={"item":z,"alwaysVisible":w};if(v){y[z]={"item":z};this._storeItemsForCollapsing(y);}}}}this._processItems();},_adjustStretchItems:function(){var u=this.get(X),v;v=this._getHeightPerStretchItem();A.Array.each(u,function(AA,z,y){var w,AC,AB,AD,x;AD=AA.get(s);x=AA.get(E);if(AD.method===G&&x){AB=this._animations[AA];if(AB){AB.stop();}w=AA.getStdModNode(W.BODY);AC=this._getNodeOffsetHeight(w);if(vAC){this._processExpanding(AA,v);}}}},this);return v;},_getHeightPerStretchItem:function(){var u,w,v=0;w=this.get(X);u=this.get(m).get("clientHeight");A.Array.each(w,function(AB,AA,z){var AC,y,AE,AD,x;AE=AB.getStdModNode(W.HEADER);AD=AB.get(s);x=this._getNodeOffsetHeight(AE);u-=x;AC=!AB.get(E);if(AC){u-=T;return;}if(AD.method===G){v++;}else{y=this._getItemContentHeight(AB);u-=y;}},this);if(v>0){u/=v;}if(u<0){u=0;}return u;},_getItemContentHeight:function(w){var y,v=0,u,x;y=w.get(s);if(y.method==="auto"){u=w.getStdModNode(W.BODY);x=u.get(P).item(0);v=x?this._getNodeOffsetHeight(x):0;}else{if(y.method==="fixed"){v=y.height;}else{v=this._getHeightPerStretchItem();}}return v;},_storeItemsForCollapsing:function(v){var u;v=v||{};u=this.get(X);A.Array.each(u,function(AA,z,y){var x,w;x=AA.get(E);w=AA.get(O);if(x&&!w&&!v[AA]){this._forCollapsing[AA]={"item":AA};}},this);},_expandItem:function(w,u){var v=w.get(O);this._processExpanding(w,u);this._setItemUI(w,true,v);},_processExpanding:function(AB,AA,u){var v,w,y,AC=false,z,x;x=AB.getStdModNode(W.BODY);this.fire(C,{"item":AB});if(x.get("clientHeight")<=T){AC=true;this.fire(c,{"item":AB});}if(!u&&this.get("useAnimation")){y=AB.get(N)||{};v=new Y({node:x,to:{"height":AA}});v.on("end",A.bind(this._onExpandComplete,this,AB,AC));z=this.get(N);v.set("duration",y.duration||z.duration);v.set("easing",y.easing||z.easing);w=this._animations[AB];if(w){w.stop();}AB.markAsExpanding(true);this._animations[AB]=v;v.run();}else{x.setStyle("height",AA+q);this.fire(o,{"item":AB});if(AC){this.fire(J,{"item":AB});}}},_onExpandComplete:function(u,v){delete this._animations[u];u.markAsExpanding(false);this.fire(o,{"item":u});if(v){this.fire(J,{"item":u});}},_collapseItem:function(u){this._processCollapsing(u,T);this._setItemUI(u,false,false);},_processCollapsing:function(AB,AA,u){var v,w,y,z,x,AC=(AA===T);x=AB.getStdModNode(W.BODY);this.fire(C,{"item":AB});if(AC){this.fire(f,{"item":AB});}if(!u&&this.get("useAnimation")){y=AB.get(N)||{};v=new Y({node:x,to:{"height":AA}});v.on("end",A.bind(this._onCollapseComplete,this,AB,AC));z=this.get(N);v.set("duration",y.duration||z.duration);v.set("easing",y.easing||z.easing);w=this._animations[AB];if(w){w.stop();}AB.markAsCollapsing(true);this._animations[AB]=v;v.run();}else{x.setStyle("height",AA+q);this.fire(o,{"item":AB});if(AC){this.fire(l,{"item":AB});}}},_onCollapseComplete:function(u,v){delete this._animations[u];u.markAsCollapsing(false);this.fire(o,{item:u});if(v){this.fire(l,{"item":u});}},_initItemDragDrop:function(v){var z,u,y,w,x;z=v.getStdModNode(W.HEADER);if(z.dd){return;}y=this.get(m);w=v.get(m);u=new A.DD.Drag({node:z,groups:[g]}).plug(A.Plugin.DDProxy,{moveOnEnd:false}).plug(A.Plugin.DDConstrained,{constrain2node:y});x=new A.DD.Drop({node:w,groups:[g]});u.on("drag:start",A.bind(this._onDragStart,this,u));u.on("drag:end",A.bind(this._onDragEnd,this,u)); +u.after("drag:end",A.bind(this._afterDragEnd,this,u));u.on("drag:drophit",A.bind(this._onDropHit,this,u));},_onDragStart:function(u,x){var w,v;v=this.getItem(u.get(p).get(K));w=u.get("dragNode");w.addClass(e);w.set("innerHTML",v.get("label"));return this.fire(i,{"item":v});},_onDragEnd:function(u,x){var w,v;w=u.get("dragNode");w.removeClass(e);w.set("innerHTML","");v=this.getItem(u.get(p).get(K));return this.fire(Q,{"item":v});},_afterDragEnd:function(u,x){var v,w;w=u.get(L);if(w.drophit){v=this.getItem(u.get(p).get(K));u.set(L,{drophit:false});return this.fire(R,{"item":v});}return true;},_onDropHit:function(AD,z){var y,AC,v,AB,x,u,AA,w,AE;AE=this.getItem(AD.get(p).get(K));w=this.getItem(z.drop.get(p));if(w===AE){return false;}y=this.getItemIndex(AE);AC=this.getItemIndex(w);v=w.get(m);AB=AE.get(m);x=this.get(Z);u=false;AA=this.get(X);if(ACy){this._processExpanding(x,v,!w);}}}},_afterContentUpdate:function(AA){var x,v,u,z,w,AB,y;x=AA.currentTarget;AB=x.get("contentHeight").method==="auto";w=x.get(E);if(AB&&w&&AA.src!==A.Widget.UI_SRC){A.later(0,this,function(){v=this._getItemContentHeight(x);u=x.getStdModNode(W.BODY);z=this._getNodeOffsetHeight(u);if(v!==z){y=this._animations[x];if(y){y.stop();}this._adjustStretchItems();if(vz){this._processExpanding(x,v,!w);}}}});}},_setUpResizing:function(u){if(this._resizeEventHandle){this._resizeEventHandle.detach();}if(u===j){this._resizeEventHandle=A.on("windowresize",A.bind(this._adjustStretchItems,this));}else{this._resizeEventHandle=u.sourceObject.on(u.resizeEvent,A.bind(this._adjustStretchItems,this));}},renderUI:function(){var v,u;v=this.get("srcNode");u=v.queryAll("> ."+V);u.each(function(z,w,y){var x;if(!this.getItem(z)){x=new A.AccordionItem({srcNode:z,id:z.get("id")});this.addItem(x);}},this);},bindUI:function(){var u,v;u=this.get(Z);v=this.get("itemChosen");u.delegate(v,A.bind(this._onItemChosenEvent,this),".yui3-widget-hd");},_onItemChosenEvent:function(z){var AB,AA,w,x,v,y,u;AB=z.currentTarget;AA=AB.get(K);w=this.getItem(AA);x=w.get(F);v=w.get(B);y=(x===z.target);u=(v===z.target);this._onItemChosen(w,y,u);},addItem:function(AG,w){var AA,AE,y,z,u,AD,AC,AF,x,AB,v;AB=this.fire(a,{"item":AG});if(!AB){return false;}AD=this.get(X);AC=this.get(Z);x=AG.get(Z);if(!x.inDoc()){if(w){u=this.getItemIndex(w);if(u<0){return false;}AD.splice(u,0,AG);AC.insertBefore(x,w.get(m));}else{AD.push(AG);AC.insertBefore(x,null);}}else{v=AC.get(P);AB=v.some(function(AJ,AI,AH){if(AJ===x){AD.splice(AI,0,AG);return true;}else{return false;}},this);if(!AB){return false;}}y=AG.getStdModNode(W.BODY);z=AG.get(n);if(!y&&!z){AG.set(n,"");}if(!AG.get(k)){AG.render();}AA=AG.get(E);AE=AG.get(O);AA=AA||AE;if(AA){this._forExpanding[AG]={"item":AG,"alwaysVisible":AE};}else{this._forCollapsing[AG]={"item":AG};}this._processItems();if(this.get("reorderItems")){this._initItemDragDrop(AG);}AF=this._itemsHandles[AG];if(!AF){AF={};}AF={"expandedChange":AG.after("expandedChange",A.bind(this._afterItemExpand,this)),"alwaysVisibleChange":AG.after("alwaysVisibleChange",A.bind(this._afterItemAlwaysVisible,this)),"contentHeightChange":AG.after("contentHeightChange",A.bind(this._afterContentHeight,this)),"contentUpdate":AG.after("contentUpdate",A.bind(this._afterContentUpdate,this))};this._itemsHandles[AG]=AF;this.fire(d,{"item":AG});return true;},removeItem:function(v){var u,y,x=null,w;u=this.get(X);if(t.isNumber(v)){w=v;}else{if(v instanceof A.AccordionItem){w=this.getItemIndex(v);}else{return null;}}if(w>=0){this.fire(D,{item:v});x=u.splice(w,1)[0];this._removeItemHandles(x);y=x.get(m);y.remove();this._adjustStretchItems();this.fire(h,{item:v});}return x;},getItem:function(w){var u=this.get(X),v=null;if(t.isNumber(w)){v=u[w];return(v instanceof A.AccordionItem)?v:null;}else{if(w instanceof U){A.Array.some(u,function(AB,AA,y){var x,z;x=AB.get(Z);z=AB.get(m);if(x===w){v=AB;return true;}else{if(z===w){v=AB;return true;}else{return false;}}},this);}}return v;},getItemIndex:function(w){var v=-1,u;if(w instanceof A.AccordionItem){u=this.get(X);A.Array.some(u,function(z,y,x){if(z===w){v=y;return true;}else{return false;}},this);}return v;}},{NAME:M,ATTRS:{itemChosen:{value:"click",validator:t.isString},items:{value:[],readOnly:true,validator:t.isArray},resizeEvent:{value:j,validator:function(u){if(u===j){return true; +}else{if(t.isObject(u)){if(t.isValue(u.sourceObject)&&t.isValue(u.resizeEvent)){return true;}}}return false;}},useAnimation:{value:true,validator:t.isBoolean},animation:{value:{duration:1,easing:H.easeOutStrong},validator:function(u){return t.isObject(u)&&t.isNumber(u.duration)&&t.isFunction(u.easing);}},reorderItems:{value:false,validator:function(u){return t.isBoolean(u)&&!t.isUndefined(A.DD);}},collapseOthersOnExpand:{value:true,validator:t.isBoolean}}});}());(function(){var u=A.Lang,b=A.Node,P=A.JSON,c=A.WidgetStdMod,d="accordion-item",N=A.ClassNameManager.getClassName,D=N(d,"iconexpanded","expanding"),s=N(d,"iconexpanded","collapsing"),O=N(d,"icon"),K=N(d,"label"),o=N(d,"iconalwaysvisible"),f=N(d,"icons"),m=N(d,"iconexpanded"),j=N(d,"iconclose"),Q=N(d,"iconclose","hidden"),S=N(d,"iconexpanded","on"),L=N(d,"iconexpanded","off"),E=N(d,"iconalwaysvisible","on"),k=N(d,"iconalwaysvisible","off"),Y=N(d,"expanded"),V=N(d,"closable"),h=N(d,"alwaysvisible"),i=N(d,"contentheight"),l="title",C="strings",q="rendered",H="className",e="auto",J="stretch",W="fixed",T=".yui3-widget-hd",Z=".",n=".yui3-widget-hd "+Z,r="innerHTML",t="iconsContainer",g="icon",R="nodeLabel",G="iconAlwaysVisible",a="iconExpanded",B="iconClose",p="href",U="#",F="yuiConfig",I=/^(?:true|yes|1)$/,M=/^auto\s*/,v=/^stretch\s*/,X=/^fixed-\d+/;A.AccordionItem=A.Base.create(d,A.Widget,[A.WidgetStdMod],{_createHeader:function(){var AE,AC,AD,AA,AB,z,x,w,y;AB=this.get(g);z=this.get(R);x=this.get(a);w=this.get(G);y=this.get(B);AA=this.get(t);AD=this.get(C);AE=this.get("closable");AC=A.AccordionItem.TEMPLATES;if(!AB){AB=b.create(AC.icon);this.set(g,AB);}if(!z){z=b.create(AC.label);this.set(R,z);}else{if(!z.hasAttribute(p)){z.setAttribute(p,U);}}z.setContent(this.get("label"));if(!AA){AA=b.create(AC.iconsContainer);this.set(t,AA);}if(!w){w=b.create(AC.iconAlwaysVisible);w.setAttribute(l,AD.title_always_visible_off);this.set(G,w);}else{if(!w.hasAttribute(p)){w.setAttribute(p,U);}}if(!x){x=b.create(AC.iconExpanded);x.setAttribute(l,AD.title_iconexpanded_off);this.set(a,x);}else{if(!x.hasAttribute(p)){x.setAttribute(p,U);}}if(!y){y=b.create(AC.iconClose);y.setAttribute(l,AD.title_iconclose);this.set(B,y);}else{if(!y.hasAttribute(p)){y.setAttribute(p,U);}}if(AE){y.removeClass(Q);}else{y.addClass(Q);}this._addHeaderComponents();},_addHeaderComponents:function(){var AC,x,AB,y,AA,z,w;x=this.get(g);AB=this.get(R);AA=this.get(a);z=this.get(G);w=this.get(B);y=this.get(t);AC=this.getStdModNode(c.HEADER);if(!AC){AC=new b(document.createDocumentFragment());AC.appendChild(x);AC.appendChild(AB);AC.appendChild(y);y.appendChild(z);y.appendChild(AA);y.appendChild(w);this.setStdModContent(c.HEADER,AC,c.REPLACE);}else{if(!AC.contains(x)){if(AC.contains(AB)){AC.insertBefore(x,AB);}else{AC.appendChild(x);}}if(!AC.contains(AB)){AC.appendChild(AB);}if(!AC.contains(y)){AC.appendChild(y);}if(!y.contains(z)){y.appendChild(z);}if(!y.contains(AA)){y.appendChild(AA);}if(!y.contains(w)){y.appendChild(w);}}},_labelChanged:function(x){var w;if(this.get(q)){w=this.get(R);w.set(r,x.newVal);}},_closableChanged:function(x){var w;if(this.get(q)){w=this.get(B);if(x.newVal){w.removeClass(Q);}else{w.addClass(Q);}}},initializer:function(w){this.after("labelChange",A.bind(this._labelChanged,this));this.after("closableChange",A.bind(this._closableChanged,this));},destructor:function(){},renderUI:function(){this._createHeader();},bindUI:function(){var w=this.get("contentBox");w.delegate("click",A.bind(this._onLinkClick,this),T+" a");},_onLinkClick:function(w){w.preventDefault();},markAsAlwaysVisible:function(x){var y,w;y=this.get(G);w=this.get(C);if(x){if(!y.hasClass(E)){y.replaceClass(k,E);y.set(l,w.title_always_visible_on);return true;}}else{if(y.hasClass(E)){y.replaceClass(E,k);y.set(l,w.title_always_visible_off);return true;}}return false;},markAsExpanded:function(x){var w,y;y=this.get(a);w=this.get(C);if(x){if(!y.hasClass(S)){y.replaceClass(L,S);y.set(l,w.title_iconexpanded_on);return true;}}else{if(y.hasClass(S)){y.replaceClass(S,L);y.set(l,w.title_iconexpanded_off);return true;}}return false;},markAsExpanding:function(x){var w=this.get(a);if(x){if(!w.hasClass(D)){w.addClass(D);return true;}}else{if(w.hasClass(D)){w.removeClass(D);return true;}}return false;},markAsCollapsing:function(w){var x=this.get(a);if(w){if(!x.hasClass(s)){x.addClass(s);return true;}}else{if(x.hasClass(s)){x.removeClass(s);return true;}}return false;},resize:function(){this.fire("contentUpdate");},_extractFixedMethodValue:function(AA){var x,z,y,w=null;for(x=6,z=AA.length;x=0){return true;}}}}return false;}},alwaysVisible:{value:false,validator:u.isBoolean},animation:{value:{},validator:u.isObject},strings:{value:{title_always_visible_off:"Click to set always visible on",title_always_visible_on:"Click to set always visible off",title_iconexpanded_off:"Click to expand",title_iconexpanded_on:"Click to collapse",title_iconclose:"Click to close"}},closable:{value:false,validator:u.isBoolean}},HTML_PARSER:{icon:n+O,label:function(z){var y,AA,x,w;x=this._parsedYUIConfig;if(x&&u.isValue(x.label)){return x.label;}w=z.getAttribute("data-label");if(w){return w;}AA=n+K;y=z.query(AA);return(y)?y.get(r):null;},nodeLabel:n+K,iconsContainer:n+f,iconAlwaysVisible:n+o,iconExpanded:n+m,iconClose:n+j,expanded:function(y){var x,w;x=this._parsedYUIConfig;if(x&&u.isBoolean(x.expanded)){return x.expanded;}w=y.getAttribute("data-expanded");if(w){return I.test(w);}return y.hasClass(Y);},alwaysVisible:function(y){var x,w;x=this._parsedYUIConfig;if(x&&u.isBoolean(x.alwaysVisible)){w=x.alwaysVisible;}else{w=y.getAttribute("data-alwaysvisible");if(w){w=I.test(w);}else{w=y.hasClass(h);}}if(w){this.set("expanded",true,{internalCall:true});}return w;},closable:function(y){var x,w;x=this._parsedYUIConfig;if(x&&u.isBoolean(x.closable)){return x.closable;}w=y.getAttribute("data-closable");if(w){return I.test(w);}return y.hasClass(V);},contentHeight:function(AC){var AA,AB,w=0,x,z,y;z=this._parsedYUIConfig;if(z&&z.contentHeight){return z.contentHeight;}y=AC.getAttribute("data-contentheight");if(M.test(y)){return{method:e};}else{if(v.test(y)){return{method:J};}else{if(X.test(y)){w=this._extractFixedMethodValue(y);return{method:W,height:w};}}}AB=AC.get(H);AA=i+"-";x=AB.indexOf(AA,0);if(x>=0){x+=AA.length;AB=AB.substring(x);if(M.test(AB)){return{method:e};}else{if(v.test(AB)){return{method:J};}else{if(X.test(AB)){w=this._extractFixedMethodValue(AB);return{method:W,height:w};}}}}return null;}},TEMPLATES:{icon:'',label:'',iconsContainer:'
',iconExpanded:[''].join(""),iconAlwaysVisible:[''].join(""),iconClose:[''].join("")}});}());},"gallery-2010.04.02-17-26",{optional:["dd-constrain","dd-proxy","dd-drop"],requires:["event","anim-easing","widget","widget-stdmod","json-parse"]}); \ No newline at end of file diff --git a/build/gallery-accordion/gallery-accordion.js b/build/gallery-accordion/gallery-accordion.js index 353de5c7ff..9fd3d5768b 100644 --- a/build/gallery-accordion/gallery-accordion.js +++ b/build/gallery-accordion/gallery-accordion.js @@ -8,21 +8,6 @@ YUI.add('gallery-accordion', function(Y) { (function(){ -/** - * Accordion creates an widget, consists of one or more items, which can be collapsed, expanded, - * set as always visible and reordered by using Drag&Drop. Collapsing/expanding might be animated. - * - * @param config {Object} Object literal specifying Accordion configuration properties. - * - * @class Accordion - * @constructor - * @extends Widget - */ - -function Accordion( config ){ - Accordion.superclass.constructor.apply( this, arguments ); -} - // Local constants var Lang = Y.Lang, Node = Y.Node, @@ -35,7 +20,7 @@ var Lang = Y.Lang, COLLAPSE_HEIGHT = IEQuirksMode ? 1 : 0, getCN = Y.ClassNameManager.getClassName, - C_ITEM = "yui-accordion-item", + C_ITEM = "yui3-accordion-item", C_PROXY_VISIBLE = getCN( AccName, "proxyel", "visible" ), DRAGGROUP = getCN( AccName, "graggroup" ), @@ -77,157 +62,14 @@ var Lang = Y.Lang, /** - * Static property provides a string to identify the class. + * Accordion creates an widget, consists of one or more items, which can be collapsed, expanded, + * set as always visible and reordered by using Drag&Drop. Collapsing/expanding might be animated. * - * @property Accordion.NAME - * @type String - * @static - */ -Accordion.NAME = AccName; - -/** - * Static property used to define the default attribute - * configuration for the Accordion. - * - * @property Accordion.ATTRS - * @type Object - * @static + * @class Accordion + * @extends Widget */ -Accordion.ATTRS = { - /** - * @description The event on which Accordion should listen for user interactions. - * The value can be also mousedown or mouseup. Mousedown event can be used if - * drag&drop is not enabled - * - * @attribute itemChosen - * @default click - * @type String - */ - itemChosen: { - value: "click", - validator: Lang.isString - }, - - /** - * @description Contains the items, currently added to Accordion - * - * @attribute items - * @readOnly - * @default [] - * @type Array - */ - items: { - value: [], - readOnly: true, - validator: Lang.isArray - }, - - /** - * @attribute resizeEvent - * - * @description The event on which Accordion should listen for resizing. - * The value must be one of these: - *
    - *
  • String "default" - the Accordion will subscribe to Y.windowresize event - *
  • - *
  • An object in the following form: - * { - * sourceObject: some_javascript_object, - * resizeEvent: an_event_to_subscribe - * } - *
  • - *
- * For example, if we are using LayoutManager's instance as sourceObject, we will have to use its "resize" event as resizeEvent - * - * @default "default" - * @type String or Object - */ - - resizeEvent: { - value: DEFAULT, - validator: function( value ){ - if( value === DEFAULT ){ - return true; - } else if( Lang.isObject(value) ){ - if( Lang.isValue( value.sourceObject ) && Lang.isValue( value.resizeEvent ) ){ - return true; - } - } - - return false; - } - }, - - /** - * @attribute useAnimation - * @description Boolean indicating that Accordion should use animation when expanding or collapsing items. - * - * @default true - * @type Boolean - */ - useAnimation: { - value: true, - validator: Lang.isBoolean - }, - - /** - * @attribute animation - * @description Animation config values, see Y.Animation - * - * @default { - * duration: 1, - * easing: Easing.easeOutStrong - * } - * - * - * @type Object - */ - animation: { - value: { - duration: 1, - easing: Easing.easeOutStrong - }, - validator: function( value ){ - return Lang.isObject( value ) && Lang.isNumber( value.duration ) && - Lang.isFunction( value.easing ); - } - }, - - /** - * @attribute reorderItems - * @description Boolean indicating that items can be reordered via drag and drop.
- * - * Enabling items reordering requires also including the optional drag and drop modules in YUI instance:
- * 'dd-constrain', 'dd-proxy', 'dd-drop', or just 'dd' - * - * @default false - * @type Boolean - */ - reorderItems: { - value: false, - validator: function(value){ - return Lang.isBoolean(value) && !Lang.isUndefined( Y.DD ); - } - }, - - /** - * @attribute collapseOthersOnExpand - * @description If true, on item expanding, all other expanded and not set as always visible items, will be collapsed - * Otherwise, they will stay open - * - * @default true - * @type Boolean - */ - collapseOthersOnExpand: { - value: true, - validator: Lang.isBoolean - } -}; - -// Accordion extends Widget - -Y.extend( Accordion, Y.Widget, { +Y.Accordion = Y.Base.create( AccName, Y.Widget, [], { /** * Initializer lifecycle implementation for the Accordion class. Publishes events, * initializes internal properties and subscribes for resize event. @@ -242,7 +84,7 @@ Y.extend( Accordion, Y.Widget, { this.after( "render", Y.bind( this._afterRender, this ) ); }, - + /** * Destructor lifecycle implementation for the Accordion class. * Removes and destroys all registered items. @@ -252,22 +94,22 @@ Y.extend( Accordion, Y.Widget, { */ destructor: function() { var items, item, i, length; - + items = this.get( ITEMS ); length = items.length; - + for( i = length - 1; i >= 0; i-- ){ item = items[ i ]; - + items.splice( i, 1 ); - + this._removeItemHandles( item ); - + item.destroy(); } }, - + /** * Publishes Accordion's events * @@ -275,7 +117,7 @@ Y.extend( Accordion, Y.Widget, { * @protected */ _initEvents: function(){ - + /** * Signals the beginning of adding an item to the Accordion. * @@ -287,7 +129,7 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( BEFOREITEMADD ); - + /** * Signals an item has been added to the Accordion. * @@ -299,7 +141,7 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( ITEMADDED ); - + /** * Signals the beginning of removing an item. * @@ -311,7 +153,7 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( BEFOREITEMREMOVE ); - + /** * Signals an item has been removed from Accordion. * @@ -335,7 +177,7 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( BEFOREITEMERESIZED ); - + /** * Signals an item has been resized. * @@ -359,7 +201,7 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( BEFOREITEMEXPAND ); - + /** * Signals the beginning of collapsing an item * @@ -371,8 +213,8 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( BEFOREITEMCOLLAPSE ); - - + + /** * Signals an item has been expanded * @@ -384,7 +226,7 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( ITEMEXPANDED ); - + /** * Signals an item has been collapsed * @@ -396,7 +238,7 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( ITEMCOLLAPSED ); - + /** * Signals the beginning of reordering an item * @@ -408,7 +250,7 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( BEFOREITEMREORDER ); - + /** * Fires before the end of item reordering * @@ -420,8 +262,8 @@ Y.extend( Accordion, Y.Widget, { * */ this.publish( BEFOREENDITEMREORDER ); - - + + /** * Signals an item has been reordered * @@ -462,7 +304,7 @@ Y.extend( Accordion, Y.Widget, { */ _animations : {}, - + /** * Collection of items handles. * Keeps track of each items's event handle, as returned from Y.on or Y.after. @@ -471,8 +313,8 @@ Y.extend( Accordion, Y.Widget, { * @type Object */ _itemsHandles: {}, - - + + /** * Removes all handles, attched to given item * @@ -482,7 +324,7 @@ Y.extend( Accordion, Y.Widget, { */ _removeItemHandles: function( item ){ var itemHandles, itemHandle; - + itemHandles = this._itemsHandles[ item ]; for( itemHandle in itemHandles ){ @@ -494,7 +336,7 @@ Y.extend( Accordion, Y.Widget, { delete this._itemsHandles[ item ]; }, - + /** * Obtains the precise height of the node provided, including padding and border. * @@ -557,7 +399,7 @@ Y.extend( Accordion, Y.Widget, { } }, - + /** * Updates user interface of an item and marks it as expanded, alwaysVisible or both * @@ -604,10 +446,10 @@ Y.extend( Accordion, Y.Widget, { this._setUpResizing( params.newVal ); }, - + /** * Distributes the involved items as result of user interaction on item header. - * Some items might be stored in the list for collapsing, other in the list for expanding. + * Some items might be stored in the list for collapsing, other in the list for expanding. * Finally, invokes _processItems function, except if item has been expanded and * user has clicked on always visible icon. * If the user clicked on close icon, the item will be closed. @@ -621,7 +463,7 @@ Y.extend( Accordion, Y.Widget, { _onItemChosen: function( item, srcIconAlwaysVisible, srcIconClose ){ var toBeExcluded, alwaysVisible, expanded, collapseOthersOnExpand; - toBeExcluded = {}; + toBeExcluded = {}; collapseOthersOnExpand = this.get( COLLAPSEOTHERSONEXPAND ); alwaysVisible = item.get( ALWAYSVISIBLE ); expanded = item.get( EXPANDED ); @@ -679,11 +521,11 @@ Y.extend( Accordion, Y.Widget, { this._processItems(); }, - + /** * Helper method to adjust the height of all items, which contentHeight property is set as "stretch". * If some item has animation running, it will be stopped before running another one. - * + * * @method adjustStretchItems * @protected * @return {Number} The calculated height per strech item @@ -692,7 +534,7 @@ Y.extend( Accordion, Y.Widget, { var items = this.get( ITEMS ), heightPerStretchItem; heightPerStretchItem = this._getHeightPerStretchItem(); - + Y.Array.each( items, function( item, index, items ){ var body, bodyHeight, anim, heightSettings, expanded; @@ -723,7 +565,7 @@ Y.extend( Accordion, Y.Widget, { /** * Calculates the height per strech item. - * + * * @method _getHeightPerStretchItem * @protected * @return {Number} The calculated height per strech item @@ -739,7 +581,7 @@ Y.extend( Accordion, Y.Widget, { header = item.getStdModNode( WidgetStdMod.HEADER ); heightSettings = item.get( CONTENT_HEIGHT ); - + headerHeight = this._getNodeOffsetHeight( header ); height -= headerHeight; @@ -769,10 +611,10 @@ Y.extend( Accordion, Y.Widget, { return height; }, - + /** * Calculates the height of given item depending on its "contentHeight" property. - * + * * @method _getItemContentHeight * @protected * @param item {Y.AccordionItem} The item, which height should be calculated @@ -796,11 +638,11 @@ Y.extend( Accordion, Y.Widget, { return height; }, - + /** * Stores all items, which are expanded and not set as always visible in list * in order to be collapsed later. - * + * * @method _storeItemsForCollapsing * @protected * @param itemsToBeExcluded {Object} (optional) Contains one or more Y.AccordionItem instances, @@ -826,10 +668,10 @@ Y.extend( Accordion, Y.Widget, { }, this ); }, - + /** * Expands an item to given height. This includes also an update to item's user interface - * + * * @method _expandItem * @protected * @param item {Y.AccordionItem} The item, which should be expanded. @@ -842,12 +684,12 @@ Y.extend( Accordion, Y.Widget, { this._setItemUI( item, true, alwaysVisible ); }, - + /** - * Expands an item to given height. Depending on the useAnimation setting, + * Expands an item to given height. Depending on the useAnimation setting, * the process of expanding might be animated. This setting will be ignored, if forceSkipAnimation param * is true. - * + * * @method _processExpanding * @protected * @param item {Y.AccordionItem} An Y.AccordionItem instance to be expanded @@ -858,14 +700,14 @@ Y.extend( Accordion, Y.Widget, { _processExpanding: function( item, height, forceSkipAnimation ){ var anim, curAnim, animSettings, notifyOthers = false, accAnimationSettings, body; - + body = item.getStdModNode( WidgetStdMod.BODY ); this.fire( BEFOREITEMERESIZED, { 'item': item }); - if( body.get( "clientHeight" ) <= 0 ){ + if( body.get( "clientHeight" ) <= COLLAPSE_HEIGHT ){ notifyOthers = true; this.fire( BEFOREITEMEXPAND, { 'item': item @@ -888,9 +730,9 @@ Y.extend( Accordion, Y.Widget, { anim.set( "duration", animSettings.duration || accAnimationSettings.duration ); anim.set( "easing" , animSettings.easing || accAnimationSettings.easing ); - + curAnim = this._animations[ item ]; - + if( curAnim ){ curAnim.stop(); } @@ -940,10 +782,10 @@ Y.extend( Accordion, Y.Widget, { } }, - + /** * Collapse an item and update its user interface - * + * * @method _collapseItem * @protected * @param item {Y.AccordionItem} The item, which should be collapsed @@ -953,12 +795,12 @@ Y.extend( Accordion, Y.Widget, { this._setItemUI( item, false, false ); }, - + /** - * Collapse an item to given height. Depending on the useAnimation setting, + * Collapse an item to given height. Depending on the useAnimation setting, * the process of collapsing might be animated. This setting will be ignored, if forceSkipAnimation param * is true. - * + * * @method _processCollapsing * @protected * @param item {Y.AccordionItem} An Y.AccordionItem instance to be collapsed @@ -967,12 +809,12 @@ Y.extend( Accordion, Y.Widget, { * without taking in consideration Accordion's useAnimation setting */ _processCollapsing: function( item, height, forceSkipAnimation ){ - var anim, curAnim, animSettings, accAnimationSettings, body, + var anim, curAnim, animSettings, accAnimationSettings, body, notifyOthers = (height === COLLAPSE_HEIGHT); - + body = item.getStdModNode( WidgetStdMod.BODY ); - + this.fire( BEFOREITEMERESIZED, { 'item': item }); @@ -1001,11 +843,11 @@ Y.extend( Accordion, Y.Widget, { anim.set( "easing" , animSettings.easing || accAnimationSettings.easing ); curAnim = this._animations[ item ]; - + if( curAnim ){ curAnim.stop(); } - + item.markAsCollapsing( true ); this._animations[ item ] = anim; @@ -1051,10 +893,10 @@ Y.extend( Accordion, Y.Widget, { } }, - + /** * Make an item draggable. The item can be reordered later. - * + * * @method _initItemDragDrop * @protected * @param item {Y.AccordionItem} An Y.AccordionItem instance to be set as draggable @@ -1213,7 +1055,7 @@ Y.extend( Accordion, Y.Widget, { return true; }, - + /** * Process items as result of user interaction or properties change. * This includes four steps: @@ -1221,12 +1063,12 @@ Y.extend( Accordion, Y.Widget, { * 2. Collapse all items stored in the list for collapsing * 3. Adjust all stretch items * 4. Expand items stored in the list for expanding - * + * * @method _processItems * @protected */ _processItems: function(){ - var forCollapsing, forExpanding, itemCont, heightPerStretchItem, + var forCollapsing, forExpanding, itemCont, heightPerStretchItem, height, heightSettings, item; forCollapsing = this._forCollapsing; @@ -1263,10 +1105,10 @@ Y.extend( Accordion, Y.Widget, { this._forExpanding = {}; }, - + /** * Update properties of items, which were stored in the lists for collapsing or expanding - * + * * @method _setItemsProperties * @protected */ @@ -1294,7 +1136,7 @@ Y.extend( Accordion, Y.Widget, { /** * Handles the change of "expand" property of given item - * + * * @method _afterItemExpand * @protected * @param params {EventFacade} The event facade for the attribute change @@ -1305,18 +1147,18 @@ Y.extend( Accordion, Y.Widget, { if( params.internalCall ){ return; } - + expanded = params.newVal; item = params.currentTarget; alwaysVisible = item.get( ALWAYSVISIBLE ); collapseOthersOnExpand = this.get( COLLAPSEOTHERSONEXPAND ); - + if( expanded ){ this._forExpanding[ item ] = { 'item': item, 'alwaysVisible': alwaysVisible }; - + if( collapseOthersOnExpand ){ this._storeItemsForCollapsing(); } @@ -1325,20 +1167,20 @@ Y.extend( Accordion, Y.Widget, { 'item': item }; } - + this._processItems(); }, /** * Handles the change of "alwaysVisible" property of given item - * + * * @method _afterItemAlwaysVisible * @protected * @param params {EventFacade} The event facade for the attribute change */ _afterItemAlwaysVisible: function( params ){ var item, alwaysVisible, expanded; - + if( params.internalCall ){ return; } @@ -1368,32 +1210,32 @@ Y.extend( Accordion, Y.Widget, { return; } } - + this._processItems(); }, - - + + /** * Handles the change of "contentHeight" property of given item - * + * * @method _afterContentHeight * @protected * @param params {EventFacade} The event facade for the attribute change */ _afterContentHeight: function( params ){ var item, itemContentHeight, body, bodyHeight, expanded; - + item = params.currentTarget; - + this._adjustStretchItems(); - + if( params.newVal.method !== STRETCH ){ expanded = item.get( EXPANDED ); itemContentHeight = this._getItemContentHeight( item ); - + body = item.getStdModNode( WidgetStdMod.BODY ); bodyHeight = this._getNodeOffsetHeight( body ); - + if( itemContentHeight < bodyHeight ){ this._processCollapsing( item, itemContentHeight, !expanded ); } else if( itemContentHeight > bodyHeight ){ @@ -1401,7 +1243,7 @@ Y.extend( Accordion, Y.Widget, { } } }, - + /** * Handles the change of "contentUpdate" property of given item @@ -1443,13 +1285,13 @@ Y.extend( Accordion, Y.Widget, { } ); } }, - - + + /** * Subscribe for resize event, which could be provided from the browser or from an arbitrary object. * For example, if there is LayoutManager in the page, it is preferable to subscribe to its resize event, * instead to those, which browser provides. - * + * * @method _setUpResizing * @protected * @param value {String|Object} String "default" or object with the following properties: @@ -1472,25 +1314,26 @@ Y.extend( Accordion, Y.Widget, { } }, - + /** * Creates one or more items found in Accordion's contentBox - * + * * @method renderUI * @protected */ renderUI: function(){ - var cb, itemsDom; + var srcNode, itemsDom; - cb = this.get( CONTENT_BOX ); - itemsDom = cb.queryAll( "> div." + C_ITEM ); + srcNode = this.get( "srcNode" ); + itemsDom = srcNode.queryAll( "> ." + C_ITEM ); itemsDom.each( function( itemNode, index, itemsDom ){ var newItem; if( !this.getItem( itemNode ) ){ newItem = new Y.AccordionItem({ - contentBox: itemNode + srcNode: itemNode, + id : itemNode.get( "id" ) }); this.addItem( newItem ); @@ -1498,10 +1341,10 @@ Y.extend( Accordion, Y.Widget, { }, this ); }, - + /** * Add listener to itemChosen event in Accordion's content box - * + * * @method bindUI * @protected */ @@ -1510,8 +1353,8 @@ Y.extend( Accordion, Y.Widget, { contentBox = this.get( CONTENT_BOX ); itemChosenEvent = this.get( 'itemChosen' ); - - contentBox.delegate( itemChosenEvent, Y.bind( this._onItemChosenEvent, this ), 'div.yui-widget-hd' ); + + contentBox.delegate( itemChosenEvent, Y.bind( this._onItemChosenEvent, this ), '.yui3-widget-hd' ); }, @@ -1521,7 +1364,7 @@ Y.extend( Accordion, Y.Widget, { * * @method _onItemChosenEvent * @protected - * + * * @param e {Event} The itemChosen event */ _onItemChosenEvent: function(e){ @@ -1543,23 +1386,23 @@ Y.extend( Accordion, Y.Widget, { /** * Add an item to Accordion. Items could be added/removed multiple times and they * will be rendered in the process of adding, if not. - * The item will be expanded, collapsed, or set as always visible depending on the + * The item will be expanded, collapsed, or set as always visible depending on the * settings. Item's properties will be also updated, if they are incomplete. * For example, if alwaysVisible is true, but expanded * property is false, it will be set to true also. - * + * * If the second param, parentItem is an Y.AccordionItem instance, * registered in Accordion, the item will be added as child of the parentItem - * + * * @method addItem * @param item {Y.AccordionItem} The item to be added in Accordion * @param parentItem {Y.AccordionItem} (optional) This item will be the parent of the item being added - * + * * @return {Boolean} True in case of successfully added item, false otherwise */ addItem: function( item, parentItem ){ - var expanded, alwaysVisible, bodyContent, itemIndex, items, contentBox, - itemHandles, itemContentBox, res, cb, children, itemBoundingBox; + var expanded, alwaysVisible, itemBody, itemBodyContent, itemIndex, items, contentBox, + itemHandles, itemContentBox, res, children; res = this.fire( BEFOREITEMADD, { 'item': item @@ -1572,8 +1415,7 @@ Y.extend( Accordion, Y.Widget, { items = this.get( ITEMS ); contentBox = this.get( CONTENT_BOX ); - itemContentBox = item.get( CONTENT_BOX ); - itemBoundingBox = item.get( BOUNDING_BOX ); + itemContentBox = item.get( CONTENT_BOX ); if( !itemContentBox.inDoc() ){ if( parentItem ){ @@ -1584,24 +1426,13 @@ Y.extend( Accordion, Y.Widget, { } items.splice( itemIndex, 0, item ); - - if( item.get( RENDERED ) ){ - contentBox.insertBefore( itemBoundingBox, parentItem.get( BOUNDING_BOX ) ); - } else { - contentBox.insertBefore( itemContentBox, parentItem.get( BOUNDING_BOX ) ); - } + contentBox.insertBefore( itemContentBox, parentItem.get( BOUNDING_BOX ) ); } else { items.push( item ); - - if( item.get( RENDERED ) ){ - contentBox.insertBefore( itemBoundingBox, null ); - } else { - contentBox.insertBefore( itemContentBox, null ); - } + contentBox.insertBefore( itemContentBox, null ); } } else { - cb = this.get( CONTENT_BOX ); - children = cb.get( CHILDREN ); + children = contentBox.get( CHILDREN ); res = children.some( function( node, index, nodeList ){ if( node === itemContentBox ){ @@ -1617,16 +1448,17 @@ Y.extend( Accordion, Y.Widget, { } } - bodyContent = item.get( BODYCONTENT ); + itemBody = item.getStdModNode( WidgetStdMod.BODY ); + itemBodyContent = item.get( BODYCONTENT ); - if( !bodyContent ){ - item.set( BODYCONTENT, " " ); + if( !itemBody && !itemBodyContent ){ + item.set( BODYCONTENT, "" ); } if( !item.get( RENDERED ) ){ item.render(); } - + expanded = item.get( EXPANDED ); alwaysVisible = item.get( ALWAYSVISIBLE ); @@ -1648,20 +1480,20 @@ Y.extend( Accordion, Y.Widget, { if( this.get( "reorderItems" ) ){ this._initItemDragDrop( item ); } - + itemHandles = this._itemsHandles[ item ]; - + if( !itemHandles ){ itemHandles = {}; } - + itemHandles = { "expandedChange" : item.after( "expandedChange", Y.bind( this._afterItemExpand, this ) ), "alwaysVisibleChange" : item.after( "alwaysVisibleChange", Y.bind( this._afterItemAlwaysVisible, this ) ), "contentHeightChange" : item.after( "contentHeightChange", Y.bind( this._afterContentHeight, this ) ), "contentUpdate" : item.after( "contentUpdate", Y.bind( this._afterContentUpdate, this ) ) }; - + this._itemsHandles[ item ] = itemHandles; this.fire( ITEMADDED, { @@ -1671,19 +1503,19 @@ Y.extend( Accordion, Y.Widget, { return true; }, - + /** * Removes an previously registered item in Accordion - * + * * @method removeItem * @param p_item {Y.AccordionItem|Number} The item to be removed, or its index * @return {Y.AccordionItem} The removed item or null if not found */ removeItem: function( p_item ){ var items, bb, item = null, itemIndex; - + items = this.get( ITEMS ); - + if( Lang.isNumber( p_item ) ){ itemIndex = p_item; } else if( p_item instanceof Y.AccordionItem ){ @@ -1693,7 +1525,7 @@ Y.extend( Accordion, Y.Widget, { } if( itemIndex >= 0 ){ - + this.fire( BEFOREITEMREMOVE, { item: p_item }); @@ -1701,12 +1533,12 @@ Y.extend( Accordion, Y.Widget, { item = items.splice( itemIndex, 1 )[0]; this._removeItemHandles( item ); - + bb = item.get( BOUNDING_BOX ); bb.remove(); this._adjustStretchItems(); - + this.fire( ITEMREMOVED, { item: p_item }); @@ -1715,14 +1547,14 @@ Y.extend( Accordion, Y.Widget, { return item; }, - + /** * Searching for item, previously registered in Accordion - * + * * @method getItem * @param param {Number|Y.Node} If number, this must be item's index. * If Node, it should be the value of item's contentBox or boundingBox properties - * + * * @return {Y.AccordionItem} The found item or null */ getItem: function( param ){ @@ -1736,7 +1568,7 @@ Y.extend( Accordion, Y.Widget, { Y.Array.some( items, function( tmpItem, index, items ){ var contentBox, boundingBox; - + contentBox = tmpItem.get( CONTENT_BOX ); boundingBox = tmpItem.get( BOUNDING_BOX ); @@ -1755,10 +1587,10 @@ Y.extend( Accordion, Y.Widget, { return item; }, - + /** * Looking for the index of previously registered item - * + * * @method getItemIndex * @param item {Y.AccordionItem} The item which index should be returned * @return {Number} Item index or -1 if item has been not found @@ -1781,10 +1613,155 @@ Y.extend( Accordion, Y.Widget, { return res; } - -}); +}, { + /** + * Static property provides a string to identify the class. + * + * @property Accordion.NAME + * @type String + * @static + */ + NAME : AccName, + + /** + * Static property used to define the default attribute + * configuration for the Accordion. + * + * @property Accordion.ATTRS + * @type Object + * @static + */ + ATTRS : { + /** + * @description The event on which Accordion should listen for user interactions. + * The value can be also mousedown or mouseup. Mousedown event can be used if + * drag&drop is not enabled + * + * @attribute itemChosen + * @default click + * @type String + */ + itemChosen: { + value: "click", + validator: Lang.isString + }, + + /** + * @description Contains the items, currently added to Accordion + * + * @attribute items + * @readOnly + * @default [] + * @type Array + */ + items: { + value: [], + readOnly: true, + validator: Lang.isArray + }, + + /** + * @attribute resizeEvent + * + * @description The event on which Accordion should listen for resizing. + * The value must be one of these: + *
    + *
  • String "default" - the Accordion will subscribe to Y.windowresize event + *
  • + *
  • An object in the following form: + * { + * sourceObject: some_javascript_object, + * resizeEvent: an_event_to_subscribe + * } + *
  • + *
+ * For example, if we are using LayoutManager's instance as sourceObject, we will have to use its "resize" event as resizeEvent + * + * @default "default" + * @type String or Object + */ + + resizeEvent: { + value: DEFAULT, + validator: function( value ){ + if( value === DEFAULT ){ + return true; + } else if( Lang.isObject(value) ){ + if( Lang.isValue( value.sourceObject ) && Lang.isValue( value.resizeEvent ) ){ + return true; + } + } + + return false; + } + }, + + /** + * @attribute useAnimation + * @description Boolean indicating that Accordion should use animation when expanding or collapsing items. + * + * @default true + * @type Boolean + */ + useAnimation: { + value: true, + validator: Lang.isBoolean + }, + + /** + * @attribute animation + * @description Animation config values, see Y.Animation + * + * @default { + * duration: 1, + * easing: Easing.easeOutStrong + * } + * + * + * @type Object + */ + animation: { + value: { + duration: 1, + easing: Easing.easeOutStrong + }, + validator: function( value ){ + return Lang.isObject( value ) && Lang.isNumber( value.duration ) && + Lang.isFunction( value.easing ); + } + }, + + /** + * @attribute reorderItems + * @description Boolean indicating that items can be reordered via drag and drop.
+ * + * Enabling items reordering requires also including the optional drag and drop modules in YUI instance:
+ * 'dd-constrain', 'dd-proxy', 'dd-drop', or just 'dd' + * + * @default false + * @type Boolean + */ + reorderItems: { + value: false, + validator: function(value){ + return Lang.isBoolean(value) && !Lang.isUndefined( Y.DD ); + } + }, -Y.Accordion = Accordion; + /** + * @attribute collapseOthersOnExpand + * @description If true, on item expanding, all other expanded and not set as always visible items, will be collapsed + * Otherwise, they will stay open + * + * @default true + * @type Boolean + */ + collapseOthersOnExpand: { + value: true, + validator: Lang.isBoolean + } + } +}); }()); @@ -1796,23 +1773,8 @@ Y.Accordion = Accordion; (function(){ -/** - * Create an AccordionItem widget. - * - * @param config {Object} Object literal specifying AccordionItem configuration properties. - * - * @class AccordionItem - * @constructor - * @extends Widget - */ - -function AccordionItem( config ){ - AccordionItem.superclass.constructor.apply( this, arguments ); -} - // Local constants var Lang = Y.Lang, - Base = Y.Base, Node = Y.Node, JSON = Y.JSON, WidgetStdMod = Y.WidgetStdMod, @@ -1843,15 +1805,14 @@ var Lang = Y.Lang, TITLE = "title", STRINGS = "strings", - CONTENT_BOX = "contentBox", RENDERED = "rendered", CLASS_NAME = "className", AUTO = "auto", STRETCH = "stretch", FIXED = "fixed", - HEADER_SELECTOR = ".yui-widget-hd", + HEADER_SELECTOR = ".yui3-widget-hd", DOT = ".", - HEADER_SELECTOR_SUB = ".yui-widget-hd " + DOT, + HEADER_SELECTOR_SUB = ".yui3-widget-hd " + DOT, INNER_HTML = "innerHTML", ICONS_CONTAINER = "iconsContainer", ICON = "icon", @@ -1862,7 +1823,6 @@ var Lang = Y.Lang, HREF = "href", HREF_VALUE = "#", YUICONFIG = "yuiConfig", - HEADER_CONTENT = "headerContent", REGEX_TRUE = /^(?:true|yes|1)$/, REGEX_AUTO = /^auto\s*/, @@ -1870,447 +1830,13 @@ var Lang = Y.Lang, REGEX_FIXED = /^fixed-\d+/; /** - * Static property provides a string to identify the class. - * - * @property AccordionItem.NAME - * @type String - * @static - */ -AccordionItem.NAME = AccItemName; - -/** - * Static property used to define the default attribute - * configuration for the Accordion. - * - * @property Accordion.ATTRS - * @type Object - * @static - */ -AccordionItem.ATTRS = { - - /** - * @description The Node, representing item's icon - * - * @attribute icon - * @default null - * @type Node - */ - icon: { - value: null, - validator: function( value ){ - return this._validateIcon( value ); - }, - setter : function( value ) { - return this._setIcon( value ); - } - }, - - /** - * @description The label of item - * - * @attribute label - * @default " " - * @type String - */ - label: { - value: " ", - validator: Lang.isString - }, - - /** - * @description The node, which contains item's label - * - * @attribute nodeLabel - * @default null - * @type Node - */ - nodeLabel: { - value: null, - validator: function( value ){ - return this._validateNodeLabel( value ); - }, - setter : function( value ) { - return this._setNodeLabel( value ); - } - }, - - - /** - * @description The container of iconAlwaysVisible, iconExpanded and iconClose - * - * @attribute iconsContainer - * @default null - * @type Node - */ - iconsContainer: { - value: null, - validator: function( value ){ - return this._validateIconsContainer( value ); - }, - setter : function( value ) { - return this._setIconsContainer( value ); - } - }, - - /** - * @description The Node, representing icon expanded - * - * @attribute iconExpanded - * @default null - * @type Node - */ - iconExpanded: { - value: null, - validator: function( value ){ - return this._validateIconExpanded( value ); - }, - setter : function( value ) { - return this._setIconExpanded( value ); - } - }, - - - /** - * @description The Node, representing icon always visible - * - * @attribute iconAlwaysVisible - * @default null - * @type Node - */ - iconAlwaysVisible: { - value: null, - validator: function( value ){ - return this._validateIconAlwaysVisible( value ); - }, - setter : function( value ) { - return this._setIconAlwaysVisible( value ); - } - }, - - - /** - * @description The Node, representing icon close, or null if the item is not closable - * - * @attribute iconClose - * @default null - * @type Node - */ - iconClose: { - value: null, - validator: function( value ){ - return this._validateIconClose( value ); - }, - setter : function( value ) { - return this._setIconClose( value ); - } - }, - - /** - * @description Get/Set expanded status of the item - * - * @attribute expanded - * @default false - * @type Boolean - */ - expanded: { - value: false, - validator: Lang.isBoolean - }, - - /** - * @description Describe the method, which will be used when expanding/collapsing - * the item. The value should be an object with at least one property ("method"): - *
- *
method
- *
The method can be one of these: "auto", "fixed" and "stretch"
- *
height
- *
Must be set only if method's value is "fixed"
- *
- * - * @attribute contentHeight - * @default auto - * @type Object - */ - contentHeight: { - value: { - method: AUTO - }, - validator: function( value ){ - if( Lang.isObject( value ) ){ - if( value.method === AUTO ){ - return true; - } else if( value.method === STRETCH ){ - return true; - } else if( value.method === FIXED && Lang.isNumber( value.height ) && - value.height >= 0 ){ - return true; - } - } - - return false; - } - }, - - /** - * @description Get/Set always visible status of the item - * - * @attribute alwaysVisible - * @default false - * @type Boolean - */ - alwaysVisible: { - value: false, - validator: Lang.isBoolean - }, - - - /** - * @description Get/Set the animaton specific settings. By default there are no any settings. - * If set, they will overwrite Accordion's animation settings - * - * @attribute animation - * @default {} - * @type Object - */ - animation: { - value: {}, - validator: Lang.isObject - }, - - /** - * @description Provides client side string localization support. - * - * @attribute strings - * @default Object English messages - * @type Object - */ - strings: { - value: { - title_always_visible_off: "Click to set always visible on", - title_always_visible_on: "Click to set always visible off", - title_iconexpanded_off: "Click to expand", - title_iconexpanded_on: "Click to collapse", - title_iconclose: "Click to close" - } - }, - - /** - * @description Boolean indicating that the item can be closed by user. - * If true, there will be placed close icon, otherwise not - * - * @attribute closable - * @default false - * @type Boolean - */ - closable: { - value: false, - validator: Lang.isBoolean - } -}; - - -/** - * Static Object hash used to capture existing markup for progressive - * enhancement. Keys correspond to config attribute names and values - * are selectors used to inspect the contentBox for an existing node - * structure. + * Create an AccordionItem widget. * - * @property AccordionItem.HTML_PARSER - * @type Object - * @protected - * @static + * @class AccordionItem + * @extends Widget */ -AccordionItem.HTML_PARSER = { - - icon: HEADER_SELECTOR_SUB + C_ICON, - - label: function( contentBox ){ - var node, labelSelector, yuiConfig, label; - - yuiConfig = this._getConfigDOMAttribute( contentBox ); - - if( yuiConfig && Lang.isValue( yuiConfig.label ) ){ - return yuiConfig.label; - } - - label = contentBox.getAttribute( "data-label" ); - - if( label ){ - return label; - } - - labelSelector = HEADER_SELECTOR_SUB + C_LABEL; - node = contentBox.query( labelSelector ); - - return (node) ? node.get( INNER_HTML ) : null; - }, - - nodeLabel: HEADER_SELECTOR_SUB + C_LABEL, - - iconsContainer: HEADER_SELECTOR_SUB + C_ICONSCONTAINER, - - iconAlwaysVisible: HEADER_SELECTOR_SUB + C_ICONALWAYSVISIBLE, - - iconExpanded: HEADER_SELECTOR_SUB + C_ICONEXPANDED, - - iconClose: HEADER_SELECTOR_SUB + C_ICONCLOSE, - - expanded: function( contentBox ){ - var yuiConfig, expanded; - - yuiConfig = this._getConfigDOMAttribute( contentBox ); - - if( yuiConfig && Lang.isBoolean( yuiConfig.expanded ) ){ - return yuiConfig.expanded; - } - - expanded = contentBox.getAttribute( "data-expanded" ); - - if( expanded ) { - return REGEX_TRUE.test( expanded ); - } - - return contentBox.hasClass( C_EXPANDED ); - }, - - alwaysVisible: function( contentBox ){ - var yuiConfig, alwaysVisible; - - yuiConfig = this._getConfigDOMAttribute( contentBox ); - - if( yuiConfig && Lang.isBoolean( yuiConfig.alwaysVisible ) ){ - alwaysVisible = yuiConfig.alwaysVisible; - } else { - alwaysVisible = contentBox.getAttribute( "data-alwaysvisible" ); - - if( alwaysVisible ) { - alwaysVisible = REGEX_TRUE.test( alwaysVisible ); - } else { - alwaysVisible = contentBox.hasClass( C_ALWAYSVISIBLE ); - } - } - - if( alwaysVisible ){ - this.set( "expanded", true, { - internalCall: true - } ); - } - - return alwaysVisible; - }, - - closable: function( contentBox ){ - var yuiConfig, closable; - - yuiConfig = this._getConfigDOMAttribute( contentBox ); - - if( yuiConfig && Lang.isBoolean( yuiConfig.closable ) ){ - return yuiConfig.closable; - } - - closable = contentBox.getAttribute( "data-closable" ); - - if( closable ) { - return REGEX_TRUE.test( closable ); - } - - return contentBox.hasClass( C_CLOSABLE ); - }, - - contentHeight: function( contentBox ){ - var contentHeightClass, classValue, height = 0, index, yuiConfig, - contentHeight; - - yuiConfig = this._getConfigDOMAttribute( contentBox ); - - if( yuiConfig && yuiConfig.contentHeight ){ - return yuiConfig.contentHeight; - } - - contentHeight = contentBox.getAttribute( "data-contentheight" ); - - if( REGEX_AUTO.test( contentHeight ) ){ - return { - method: AUTO - }; - } else if( REGEX_STRETCH.test( contentHeight ) ){ - return { - method: STRETCH - }; - } else if( REGEX_FIXED.test( contentHeight ) ){ - height = this._extractFixedMethodValue( contentHeight ); - - return { - method: FIXED, - height: height - }; - } - - - classValue = contentBox.get( CLASS_NAME ); - - contentHeightClass = C_CONTENTHEIGHT + '-'; - - index = classValue.indexOf( contentHeightClass, 0); - - if( index >= 0 ){ - index += contentHeightClass.length; - - classValue = classValue.substring( index ); - - if( REGEX_AUTO.test( classValue ) ){ - return { - method: AUTO - }; - } else if( REGEX_STRETCH.test( classValue ) ){ - return { - method: STRETCH - }; - } else if( REGEX_FIXED.test( classValue ) ){ - height = this._extractFixedMethodValue( classValue ); - - return { - method: FIXED, - height: height - }; - } - } - - return null; - } -}; - - - /** - * The template HTML strings for each of header components. - * e.g. - *
-  *    {
-  *       icon : '<a class="yui-accordion-item-icon"></a>',
-  *       label: '<a href="#" class="yui-accordion-item-label"></a>',
-  *       iconsContainer: '<div class="yui-accordion-item-icons"></div>',
-  *       iconAlwaysVisible: '<a href="#" class="yui-accordion-item-iconalwaysvisible"></a>',
-  *       iconExpanded: '<a href="#" class="yui-accordion-item-iconexpanded"></a>',
-  *       iconClose: '<a href="#" class="yui-accordion-item-iconclose yui-accordion-item-iconclose-hidden"></a>'
-  *    }
-  * 
- * @property WidgetStdMod.TEMPLATES - * @type Object - */ -AccordionItem.TEMPLATES = { - icon : '', - label: '', - iconsContainer: '
', - iconExpanded: [''].join(''), - iconAlwaysVisible: [''].join(''), - iconClose: [''].join('') -}; - - -// AccordionItem extends Widget - -Y.extend( AccordionItem, Y.Widget, { +Y.AccordionItem = Y.Base.create( AccItemName, Y.Widget, [Y.WidgetStdMod], { /** * Creates the header content * @@ -2327,11 +1853,11 @@ Y.extend( AccordionItem, Y.Widget, { iconAlwaysVisible = this.get( ICON_ALWAYSVISIBLE ); iconClose = this.get( ICON_CLOSE ); iconsContainer = this.get( ICONS_CONTAINER ); - + strings = this.get( STRINGS ); closable = this.get( "closable" ); - templates = AccordionItem.TEMPLATES; - + templates = Y.AccordionItem.TEMPLATES; + if( !icon ){ icon = Node.create( templates.icon ); this.set( ICON, icon ); @@ -2360,7 +1886,7 @@ Y.extend( AccordionItem, Y.Widget, { iconAlwaysVisible.setAttribute( HREF, HREF_VALUE ); } - + if( !iconExpanded ){ iconExpanded = Node.create( templates.iconExpanded ); iconExpanded.setAttribute( TITLE, strings.title_iconexpanded_off ); @@ -2368,8 +1894,8 @@ Y.extend( AccordionItem, Y.Widget, { } else if( !iconExpanded.hasAttribute( HREF ) ){ iconExpanded.setAttribute( HREF, HREF_VALUE ); } - - + + if( !iconClose ){ iconClose = Node.create( templates.iconClose ); iconClose.setAttribute( TITLE, strings.title_iconclose ); @@ -2377,7 +1903,7 @@ Y.extend( AccordionItem, Y.Widget, { } else if( !iconClose.hasAttribute( HREF ) ){ iconClose.setAttribute( HREF, HREF_VALUE ); } - + if( closable ){ iconClose.removeClass( C_ICONCLOSE_HIDDEN ); } else { @@ -2404,7 +1930,7 @@ Y.extend( AccordionItem, Y.Widget, { iconClose = this.get( ICON_CLOSE ); iconsContainer = this.get( ICONS_CONTAINER ); - header = this.get( HEADER_CONTENT ); + header = this.getStdModNode( WidgetStdMod.HEADER ); if( !header ){ header = new Node( document.createDocumentFragment() ); @@ -2450,14 +1976,14 @@ Y.extend( AccordionItem, Y.Widget, { /** * Handles the change of "labelChanged" property. Updates item's UI with the label provided - * + * * @method _labelChanged * @protected * @param params {EventFacade} The event facade for the attribute change */ _labelChanged: function( params ){ var label; - + if( this.get( RENDERED ) ){ label = this.get( NODE_LABEL ); label.set( INNER_HTML, params.newVal ); @@ -2498,8 +2024,8 @@ Y.extend( AccordionItem, Y.Widget, { this.after( "labelChange", Y.bind( this._labelChanged, this ) ); this.after( "closableChange", Y.bind( this._closableChanged, this ) ); }, - - + + /** * Destructor lifecycle implementation for the AccordionItem class. * @@ -2510,17 +2036,17 @@ Y.extend( AccordionItem, Y.Widget, { // EMPTY }, - + /** * Creates AccordionItem's header. - * + * * @method renderUI * @protected */ renderUI: function(){ this._createHeader(); }, - + /** * Configures/Sets up listeners to bind Widget State to UI/DOM * @@ -2528,10 +2054,8 @@ Y.extend( AccordionItem, Y.Widget, { * @protected */ bindUI: function(){ - var contentBox; - - contentBox = this.get( CONTENT_BOX ); - + var contentBox = this.get( "contentBox" ); + contentBox.delegate( "click", Y.bind( this._onLinkClick, this ), HEADER_SELECTOR + ' a' ); }, @@ -2548,11 +2072,11 @@ Y.extend( AccordionItem, Y.Widget, { _onLinkClick: function( e ){ e.preventDefault(); }, - + /** * Marks the item as always visible by adding class to always visible icon. * The icon will be updated only if needed. - * + * * @method markAsAlwaysVisible * @param alwaysVisible {Boolean} If true, the item should be marked as always visible. * @return {Boolean} Return true if the icon has been updated, false if there was no need to update @@ -2576,22 +2100,22 @@ Y.extend( AccordionItem, Y.Widget, { return true; } } - + return false; }, - + /** * Marks the item as expanded by adding class to expand icon. * The icon will be updated only if needed. - * + * * @method markAsExpanded * @param expanded {Boolean} Boolean indicating that item should be marked as expanded. * @return {Boolean} Return true if the icon has been updated, false if there was no need to update */ markAsExpanded: function( expanded ){ var strings, iconExpanded; - + iconExpanded = this.get( ICON_EXPANDED ); strings = this.get( STRINGS ); @@ -2608,22 +2132,22 @@ Y.extend( AccordionItem, Y.Widget, { return true; } } - + return false; }, - + /** * Marks the item as expanding by adding class to expand icon. * The method will update icon only if needed. - * + * * @method markAsExpanding * @param expanding {Boolean} Boolean indicating that the item should be marked as expanding. * @return {Boolean} Return true if the icon has been updated, false if there was no need to update */ markAsExpanding: function( expanding ){ var iconExpanded = this.get( ICON_EXPANDED ); - + if( expanding ){ if( !iconExpanded.hasClass( C_ICONEXPANDED_EXPANDING ) ){ iconExpanded.addClass( C_ICONEXPANDED_EXPANDING ); @@ -2635,15 +2159,15 @@ Y.extend( AccordionItem, Y.Widget, { return true; } } - + return false; }, - + /** * Marks the item as collapsing by adding class to expand icon. * The method will update icon only if needed. - * + * * @method markAsCollapsing * @param collapsing {Boolean} Boolean indicating that the item should be marked as collapsing. * @return {Boolean} Return true if the icon has been updated, false if there was no need to update @@ -2662,7 +2186,7 @@ Y.extend( AccordionItem, Y.Widget, { return true; } } - + return false; }, @@ -2678,28 +2202,6 @@ Y.extend( AccordionItem, Y.Widget, { }, - /** - * Parses and returns the yuiConfig attribute from contentBox. It must be stringified JSON object. - * This function will be replaced with more clever solution when YUI 3.1 becomes available - * - * @method _getConfigDOMAttribute - * @param contentBox {Node} Widget's contentBox - * @return {Object} The parsed yuiConfig value - * @private - */ - _getConfigDOMAttribute: function( contentBox ) { - if( !this._parsedCfg ){ - this._parsedCfg = contentBox.getAttribute( YUICONFIG ); - - if( this._parsedCfg ){ - this._parsedCfg = JSON.parse( this._parsedCfg ); - } - } - - return this._parsedCfg; - }, - - /** * Parses and returns the value of contentHeight property, if set method "fixed". * The value must be in this format: fixed-X, where X is integer @@ -2725,8 +2227,8 @@ Y.extend( AccordionItem, Y.Widget, { return height; }, - - + + /** * Validator applied to the icon attribute. Setting new value is not allowed if Accordion has been rendered. * @@ -2738,8 +2240,8 @@ Y.extend( AccordionItem, Y.Widget, { _validateIcon: function( value ) { return !this.get(RENDERED) || value; }, - - + + /** * Validator applied to the nodeLabel attribute. Setting new value is not allowed if Accordion has been rendered. * @@ -2751,8 +2253,8 @@ Y.extend( AccordionItem, Y.Widget, { _validateNodeLabel: function( value ) { return !this.get(RENDERED) || value; }, - - + + /** * Validator applied to the iconsContainer attribute. Setting new value is not allowed if Accordion has been rendered. * @@ -2764,8 +2266,8 @@ Y.extend( AccordionItem, Y.Widget, { _validateIconsContainer: function( value ) { return !this.get(RENDERED) || value; }, - - + + /** * Validator applied to the iconExpanded attribute. Setting new value is not allowed if Accordion has been rendered. * @@ -2777,8 +2279,8 @@ Y.extend( AccordionItem, Y.Widget, { _validateIconExpanded: function( value ) { return !this.get(RENDERED) || value; }, - - + + /** * Validator applied to the iconAlwaysVisible attribute. Setting new value is not allowed if Accordion has been rendered. * @@ -2790,8 +2292,8 @@ Y.extend( AccordionItem, Y.Widget, { _validateIconAlwaysVisible: function( value ) { return !this.get(RENDERED) || value; }, - - + + /** * Validator applied to the iconClose attribute. Setting new value is not allowed if Accordion has been rendered. * @@ -2803,8 +2305,8 @@ Y.extend( AccordionItem, Y.Widget, { _validateIconClose: function( value ) { return !this.get(RENDERED) || value; }, - - + + /** * Setter applied to the input when updating the icon attribute. Input can * be a Node, raw HTMLElement, or a selector string to locate it. @@ -2817,8 +2319,8 @@ Y.extend( AccordionItem, Y.Widget, { _setIcon: function( value ){ return Y.get( value ) || null; }, - - + + /** * Setter applied to the input when updating the nodeLabel attribute. Input can * be a Node, raw HTMLElement, or a selector string to locate it. @@ -2831,8 +2333,8 @@ Y.extend( AccordionItem, Y.Widget, { _setNodeLabel: function( value ){ return Y.get( value ) || null; }, - - + + /** * Setter applied to the input when updating the iconsContainer attribute. Input can * be a Node, raw HTMLElement, or a selector string to locate it. @@ -2845,8 +2347,8 @@ Y.extend( AccordionItem, Y.Widget, { _setIconsContainer: function( value ){ return Y.get( value ) || null; }, - - + + /** * Setter applied to the input when updating the iconExpanded attribute. Input can * be a Node, raw HTMLElement, or a selector string to locate it. @@ -2859,8 +2361,8 @@ Y.extend( AccordionItem, Y.Widget, { _setIconExpanded: function( value ){ return Y.get( value ) || null; }, - - + + /** * Setter applied to the input when updating the iconAlwaysVisible attribute. Input can * be a Node, raw HTMLElement, or a selector string to locate it. @@ -2873,8 +2375,8 @@ Y.extend( AccordionItem, Y.Widget, { _setIconAlwaysVisible: function( value ){ return Y.get( value ) || null; }, - - + + /** * Setter applied to the input when updating the iconClose attribute. Input can * be a Node, raw HTMLElement, or a selector string to locate it. @@ -2886,18 +2388,475 @@ Y.extend( AccordionItem, Y.Widget, { */ _setIconClose: function( value ){ return Y.get( value ) || null; + }, + + + /** + * Overwrites Widget's _applyParser method in order to parse yuiConfig attribute before entering in HTML_PARSER attributes + * + * @method _applyParser + * @protected + * @param config {Object} User configuration object (will be populated with values from Node) + */ + _applyParser : function(config) { + var srcNode; + + srcNode = this.get( "srcNode" ); + + if( srcNode ){ + this._parsedYUIConfig = srcNode.getAttribute( YUICONFIG ); + + if( this._parsedYUIConfig ){ + this._parsedYUIConfig = JSON.parse( this._parsedYUIConfig ); + } + } + + Y.AccordionItem.superclass._applyParser.apply( this, arguments ); + + delete this._parsedYUIConfig; } -}); +}, { + /** + * Static property provides a string to identify the class. + * + * @property NAME + * @type String + * @static + */ + NAME : AccItemName, -// Add WidgetStdMod's functionality to AccordionItem -Base.build( AccordionItem.NAME, AccordionItem, [ WidgetStdMod ], { - dynamic: false -}); + /** + * Static property used to define the default attribute + * configuration for the Accordion. + * + * @property Accordion.ATTRS + * @type Object + * @static + */ + ATTRS : { + + /** + * @description The Node, representing item's icon + * + * @attribute icon + * @default null + * @type Node + */ + icon: { + value: null, + validator: function( value ){ + return this._validateIcon( value ); + }, + setter : function( value ) { + return this._setIcon( value ); + } + }, + + /** + * @description The label of item + * + * @attribute label + * @default " " + * @type String + */ + label: { + value: " ", + validator: Lang.isString + }, -Y.AccordionItem = AccordionItem; + /** + * @description The node, which contains item's label + * + * @attribute nodeLabel + * @default null + * @type Node + */ + nodeLabel: { + value: null, + validator: function( value ){ + return this._validateNodeLabel( value ); + }, + setter : function( value ) { + return this._setNodeLabel( value ); + } + }, + + + /** + * @description The container of iconAlwaysVisible, iconExpanded and iconClose + * + * @attribute iconsContainer + * @default null + * @type Node + */ + iconsContainer: { + value: null, + validator: function( value ){ + return this._validateIconsContainer( value ); + }, + setter : function( value ) { + return this._setIconsContainer( value ); + } + }, + + /** + * @description The Node, representing icon expanded + * + * @attribute iconExpanded + * @default null + * @type Node + */ + iconExpanded: { + value: null, + validator: function( value ){ + return this._validateIconExpanded( value ); + }, + setter : function( value ) { + return this._setIconExpanded( value ); + } + }, + + + /** + * @description The Node, representing icon always visible + * + * @attribute iconAlwaysVisible + * @default null + * @type Node + */ + iconAlwaysVisible: { + value: null, + validator: function( value ){ + return this._validateIconAlwaysVisible( value ); + }, + setter : function( value ) { + return this._setIconAlwaysVisible( value ); + } + }, + + + /** + * @description The Node, representing icon close, or null if the item is not closable + * + * @attribute iconClose + * @default null + * @type Node + */ + iconClose: { + value: null, + validator: function( value ){ + return this._validateIconClose( value ); + }, + setter : function( value ) { + return this._setIconClose( value ); + } + }, + + /** + * @description Get/Set expanded status of the item + * + * @attribute expanded + * @default false + * @type Boolean + */ + expanded: { + value: false, + validator: Lang.isBoolean + }, + + /** + * @description Describe the method, which will be used when expanding/collapsing + * the item. The value should be an object with at least one property ("method"): + *
+ *
method
+ *
The method can be one of these: "auto", "fixed" and "stretch"
+ *
height
+ *
Must be set only if method's value is "fixed"
+ *
+ * + * @attribute contentHeight + * @default auto + * @type Object + */ + contentHeight: { + value: { + method: AUTO + }, + validator: function( value ){ + if( Lang.isObject( value ) ){ + if( value.method === AUTO ){ + return true; + } else if( value.method === STRETCH ){ + return true; + } else if( value.method === FIXED && Lang.isNumber( value.height ) && + value.height >= 0 ){ + return true; + } + } + + return false; + } + }, + + /** + * @description Get/Set always visible status of the item + * + * @attribute alwaysVisible + * @default false + * @type Boolean + */ + alwaysVisible: { + value: false, + validator: Lang.isBoolean + }, + + + /** + * @description Get/Set the animaton specific settings. By default there are no any settings. + * If set, they will overwrite Accordion's animation settings + * + * @attribute animation + * @default {} + * @type Object + */ + animation: { + value: {}, + validator: Lang.isObject + }, + + /** + * @description Provides client side string localization support. + * + * @attribute strings + * @default Object English messages + * @type Object + */ + strings: { + value: { + title_always_visible_off: "Click to set always visible on", + title_always_visible_on: "Click to set always visible off", + title_iconexpanded_off: "Click to expand", + title_iconexpanded_on: "Click to collapse", + title_iconclose: "Click to close" + } + }, + + /** + * @description Boolean indicating that the item can be closed by user. + * If true, there will be placed close icon, otherwise not + * + * @attribute closable + * @default false + * @type Boolean + */ + closable: { + value: false, + validator: Lang.isBoolean + } + }, + + + /** + * Static Object hash used to capture existing markup for progressive + * enhancement. Keys correspond to config attribute names and values + * are selectors used to inspect the srcNode for an existing node + * structure. + * + * @property HTML_PARSER + * @type Object + * @protected + * @static + */ + HTML_PARSER : { + + icon: HEADER_SELECTOR_SUB + C_ICON, + + label: function( srcNode ){ + var node, labelSelector, yuiConfig, label; + + yuiConfig = this._parsedYUIConfig; + + if( yuiConfig && Lang.isValue( yuiConfig.label ) ){ + return yuiConfig.label; + } + + label = srcNode.getAttribute( "data-label" ); + + if( label ){ + return label; + } + + labelSelector = HEADER_SELECTOR_SUB + C_LABEL; + node = srcNode.query( labelSelector ); + + return (node) ? node.get( INNER_HTML ) : null; + }, + + nodeLabel: HEADER_SELECTOR_SUB + C_LABEL, + + iconsContainer: HEADER_SELECTOR_SUB + C_ICONSCONTAINER, + + iconAlwaysVisible: HEADER_SELECTOR_SUB + C_ICONALWAYSVISIBLE, + + iconExpanded: HEADER_SELECTOR_SUB + C_ICONEXPANDED, + + iconClose: HEADER_SELECTOR_SUB + C_ICONCLOSE, + + expanded: function( srcNode ){ + var yuiConfig, expanded; + + yuiConfig = this._parsedYUIConfig; + + if( yuiConfig && Lang.isBoolean( yuiConfig.expanded ) ){ + return yuiConfig.expanded; + } + + expanded = srcNode.getAttribute( "data-expanded" ); + + if( expanded ) { + return REGEX_TRUE.test( expanded ); + } + + return srcNode.hasClass( C_EXPANDED ); + }, + + alwaysVisible: function( srcNode ){ + var yuiConfig, alwaysVisible; + + yuiConfig = this._parsedYUIConfig; + + if( yuiConfig && Lang.isBoolean( yuiConfig.alwaysVisible ) ){ + alwaysVisible = yuiConfig.alwaysVisible; + } else { + alwaysVisible = srcNode.getAttribute( "data-alwaysvisible" ); + + if( alwaysVisible ) { + alwaysVisible = REGEX_TRUE.test( alwaysVisible ); + } else { + alwaysVisible = srcNode.hasClass( C_ALWAYSVISIBLE ); + } + } + + if( alwaysVisible ){ + this.set( "expanded", true, { + internalCall: true + } ); + } + + return alwaysVisible; + }, + + closable: function( srcNode ){ + var yuiConfig, closable; + + yuiConfig = this._parsedYUIConfig; + + if( yuiConfig && Lang.isBoolean( yuiConfig.closable ) ){ + return yuiConfig.closable; + } + + closable = srcNode.getAttribute( "data-closable" ); + + if( closable ) { + return REGEX_TRUE.test( closable ); + } + + return srcNode.hasClass( C_CLOSABLE ); + }, + + contentHeight: function( srcNode ){ + var contentHeightClass, classValue, height = 0, index, yuiConfig, + contentHeight; + + yuiConfig = this._parsedYUIConfig; + + if( yuiConfig && yuiConfig.contentHeight ){ + return yuiConfig.contentHeight; + } + + contentHeight = srcNode.getAttribute( "data-contentheight" ); + + if( REGEX_AUTO.test( contentHeight ) ){ + return { + method: AUTO + }; + } else if( REGEX_STRETCH.test( contentHeight ) ){ + return { + method: STRETCH + }; + } else if( REGEX_FIXED.test( contentHeight ) ){ + height = this._extractFixedMethodValue( contentHeight ); + + return { + method: FIXED, + height: height + }; + } + + + classValue = srcNode.get( CLASS_NAME ); + + contentHeightClass = C_CONTENTHEIGHT + '-'; + + index = classValue.indexOf( contentHeightClass, 0); + + if( index >= 0 ){ + index += contentHeightClass.length; + + classValue = classValue.substring( index ); + + if( REGEX_AUTO.test( classValue ) ){ + return { + method: AUTO + }; + } else if( REGEX_STRETCH.test( classValue ) ){ + return { + method: STRETCH + }; + } else if( REGEX_FIXED.test( classValue ) ){ + height = this._extractFixedMethodValue( classValue ); + + return { + method: FIXED, + height: height + }; + } + } + + return null; + } + }, + + + /** + * The template HTML strings for each of header components. + * e.g. + *
+      *    {
+      *       icon : '<a class="yui3-accordion-item-icon"></a>',
+      *       label: '<a href="#" class="yui3-accordion-item-label"></a>',
+      *       iconsContainer: '<div class="yui3-accordion-item-icons"></div>',
+      *       iconAlwaysVisible: '<a href="#" class="yui3-accordion-item-iconalwaysvisible"></a>',
+      *       iconExpanded: '<a href="#" class="yui3-accordion-item-iconexpanded"></a>',
+      *       iconClose: '<a href="#" class="yui3-accordion-item-iconclose yui3-accordion-item-iconclose-hidden"></a>'
+      *    }
+      * 
+ * @property WidgetStdMod.TEMPLATES + * @type Object + */ + TEMPLATES : { + icon : '', + label: '', + iconsContainer: '
', + iconExpanded: [''].join(''), + iconAlwaysVisible: [''].join(''), + iconClose: [''].join('') + } + +}); }()); -}, 'gallery-2010.03.02-18' ,{requires:['event', 'anim-easing', 'widget', 'widget-stdmod', 'json-parse'], optional:['dd-constrain', 'dd-proxy', 'dd-drop']}); +}, 'gallery-2010.04.02-17-26' ,{optional:['dd-constrain', 'dd-proxy', 'dd-drop'], requires:['event', 'anim-easing', 'widget', 'widget-stdmod', 'json-parse']}); diff --git a/build/gallery-formmgr/gallery-formmgr-debug.js b/build/gallery-formmgr/gallery-formmgr-debug.js index dfbda2a84d..9ab7ef04de 100644 --- a/build/gallery-formmgr/gallery-formmgr-debug.js +++ b/build/gallery-formmgr/gallery-formmgr-debug.js @@ -1061,18 +1061,18 @@ FormManager.prototype = { this.displayMessage(e[i], info.error, 'error'); status = false; - } - if (!info.keepGoing) - { continue; } - if (this.validation.regex[e_id] && - !this.validation.regex[e_id].test(e[i].value)) + if (info.keepGoing) { - this.displayMessage(e[i], msg_list ? msg_list.regex : null, 'error'); - status = false; - continue; + if (this.validation.regex[e_id] && + !this.validation.regex[e_id].test(e[i].value)) + { + this.displayMessage(e[i], msg_list ? msg_list.regex : null, 'error'); + status = false; + continue; + } } var f = this.validation.fn[e_id]; @@ -1371,4 +1371,4 @@ FormManager.prototype = Y.FormManager = FormManager; -}, 'gallery-2010.03.23-17-54' ,{requires:['node-base','substitute']}); +}, 'gallery-2010.04.02-17-26' ,{requires:['node-base','substitute']}); diff --git a/build/gallery-formmgr/gallery-formmgr-min.js b/build/gallery-formmgr/gallery-formmgr-min.js index 91500ce737..bbe2f7361f 100644 --- a/build/gallery-formmgr/gallery-formmgr-min.js +++ b/build/gallery-formmgr/gallery-formmgr-min.js @@ -1,2 +1,2 @@ YUI.add("gallery-formmgr",function(B){function M(P,O){if(arguments.length===0){return;}if(!O){O={};}this.form_name=P;this.status_node=B.one(O.status_node);this.enabled=true;this.default_value_map=O.default_value_map;this.validation={fn:{},regex:{}};this.validation_msgs={};this.has_messages=false;this.has_errors=false;this.button_list=[];this.user_button_list=[];this.has_file_inputs=false;}var C="(?:^|\\s)(?:";var H=")(?:\\s|$)";var F="yiv-required";var L=/(?:^|\s+)yiv-length:\[([0-9]+)?,([1-9][0-9]*)?\](?:\s+|$)/;var K=/(?:^|\s+)yiv-integer(?::\[([-+]?[0-9]+)?,([-+]?[0-9]+)?\])?(?:\s+|$)/;var I=/(?:^|\s+)yiv-decimal(?::\[([-+]?(?:[0-9]+\.?|[0-9]+\.[0-9]+|\.[0-9]+))?,([-+]?(?:[0-9]+\.?|[0-9]+\.[0-9]+|\.[0-9]+))?\])?(?:\s+|$)/;M.integer_value_re=/^[-+]?[0-9]+$/;M.decimal_value_re=/^[-+]?(?:[0-9]+\.?|[0-9]*\.[0-9]+)$/;M.row_marker_class="formmgr-row";M.status_marker_class="formmgr-message-text";M.status_none_class="formmgr-status-hidden";M.status_success_class="formmgr-status-success";M.status_failure_class="formmgr-status-failure";M.row_status_prefix="formmgr-has";var E=M.status_success_class+"|"+M.status_failure_class;var A=M.row_status_prefix+"([^\\s]+)";var N=new RegExp(C+A+H);M.Strings={validation_error:"Correct errors in the highlighted fields before continuing.",required_string:"This field requires a value.",required_menu:"This field is required. Choose a value from the pull-down list.",length_too_short:"Enter text that is at least {min} characters or longer.",length_too_long:"Enter text that is up to {max} characters long.",length_out_of_range:"Enter text that is {min} to {max} characters long.",integer:"Enter a whole number (no decimal point).",integer_too_small:"Enter a number that is {min} or higher (no decimal point).",integer_too_large:"Enter a number that is {max} or lower (no decimal point).",integer_out_of_range:"Enter a number between or including {min} and {max} (no decimal point).",decimal:"Enter a number.",decimal_too_small:"Enter a number that is {min} or higher.",decimal_too_large:"Enter a number that is {max} or lower.",decimal_out_of_range:"Enter a number between or including {min} and {max}."};M.status_order=["error","warn","success","info"];M.getStatusPrecedence=function(O){for(var P=0;P1?O[1]:false);};function D(O){if(B.Lang.isString(O)){return O.replace(/^#/,"");}else{if(O instanceof B.Node){return O.get("id");}else{return O.id;}}}M.cleanValues=function(S){var R=false;for(var P=0;P0);}M.validateFromCSSData=function(S,P){var U=B.DOM.hasClass(S,F);if(U&&S.value===""){var T=null;if(P&&P.required){T=P.required;}else{if(S.tagName.toLowerCase()=="select"){T=M.Strings.required_menu;}else{T=M.Strings.required_string;}}return{keepGoing:false,error:T};}else{if(!U&&S.value===""){return{keepGoing:false};}}if(S.className){var O=S.className.match(L);if(O&&O.length){if(G(O[1])&&G(O[2])&&parseInt(O[1],10)>parseInt(O[2],10)){}var T=null;var Q=(G(O[1])&&O[1]!=="0");if(Q&&G(O[2])){T=M.Strings.length_out_of_range;}else{if(Q){T=M.Strings.length_too_short;}else{if(G(O[2])){T=M.Strings.length_too_long;}}}if(S.value&&G(O[1])&&S.value.lengthparseInt(O[2],10)){if(P&&P.max_length){T=P.max_length;}T=B.substitute(T,{min:parseInt(O[1],10),max:parseInt(O[2],10)});return{keepGoing:false,error:T};}}var O=S.className.match(K);if(O&&O.length){if(G(O[1])&&G(O[2])&&parseInt(O[1],10)>parseInt(O[2],10)){}var R=parseInt(S.value,10);if(S.value&&(!M.integer_value_re.test(S.value)||(G(O[1])&&RparseInt(O[2],10)))){var T=null;if(P&&P.integer){T=P.integer;}else{if(G(O[1])&&G(O[2])){T=M.Strings.integer_out_of_range;}else{if(G(O[1])){T=M.Strings.integer_too_small;}else{if(G(O[2])){T=M.Strings.integer_too_large;}else{T=M.Strings.integer;}}}}T=B.substitute(T,{min:parseInt(O[1],10),max:parseInt(O[2],10)});return{keepGoing:false,error:T};}}var O=S.className.match(I);if(O&&O.length){if(G(O[1])&&G(O[2])&&parseFloat(O[1])>parseFloat(O[2])){}var R=parseFloat(S.value);if(S.value&&(!M.decimal_value_re.test(S.value)||(G(O[1])&&RparseFloat(O[2])))){var T=null;if(P&&P.decimal){T=P.decimal;}else{if(G(O[1])&&G(O[2])){T=M.Strings.decimal_out_of_range;}else{if(G(O[1])){T=M.Strings.decimal_too_small;}else{if(G(O[2])){T=M.Strings.decimal_too_large;}else{T=M.Strings.decimal;}}}}T=B.substitute(T,{min:parseFloat(O[1],10),max:parseFloat(O[2],10)});return{keepGoing:false,error:T};}}}return{keepGoing:true};};function J(){var S=(this.button_list.length===0);for(var R=0;R=0&&V.options[V.selectedIndex].value!==O.toString()){V.selectedIndex=-1;}}else{if(Q=="textarea"){V.value=O;}}}}}}}}M.prototype={getForm:function(){if(!this.form){this.form=document.forms[this.form_name];}return this.form;},hasFileInputs:function(){return this.has_file_inputs;},setDefaultValues:function(O){this.default_value_map=O;},setDefaultValue:function(P,O){this.default_value_map[P]=O;},saveCurrentValuesAsDefault:function(){this.default_value_map={};this.button_list=[];J.call(this);},setFunction:function(P,O){this.validation.fn[D(P)]=O;},setRegex:function(Q,P,O){Q=D(Q);if(B.Lang.isString(P)){this.validation.regex[Q]=new RegExp(P,O);}else{this.validation.regex[Q]=P;}if(!this.validation_msgs[Q]||!this.validation_msgs[Q].regex){}},setErrorMessages:function(P,O){this.validation_msgs[D(P)]=O;},addErrorMessage:function(Q,O,P){Q=D(Q);if(!this.validation_msgs[Q]){this.validation_msgs[Q]={};}this.validation_msgs[Q][O]=P;},clearForm:function(){this.clearMessages();this.form.reset();this.postPopulateForm();},populateForm:function(){if(!this.default_value_map){this.default_value_map={};}this.clearMessages();J.call(this);this.postPopulateForm();},postPopulateForm:function(){},isChanged:function(){for(var Q=0;Q0){S.scrollIntoView();try{T.focus();}catch(Q){}}this.has_messages=true;if(R=="error"){this.has_errors=true;}}},notifyErrors:function(){this.displayFormMessage(M.Strings.validation_error,true,false);},displayFormMessage:function(Q,P,O){if(B.Lang.isUndefined(O)){O=true;}if(this.status_node){if(!this.status_node.innerHTML){this.status_node.replaceClass(M.status_none_class,(P?M.status_failure_class:M.status_success_class));this.status_node.set("innerHTML",Q);}if(O){this.status_node.scrollIntoView();}}else{}}};B.FormManager=M;},"gallery-2010.03.23-17-54",{requires:["node-base","substitute"]}); \ No newline at end of file +}}}}}else{if(Q=="input"&&(T=="password"||T=="text")){V.value=O;}else{if(Q=="input"&&(T=="checkbox"||T=="radio")){V.checked=(V.value==O);}else{if(Q=="select"&&T=="select-one"){V.value=O;if(V.selectedIndex>=0&&V.options[V.selectedIndex].value!==O.toString()){V.selectedIndex=-1;}}else{if(Q=="textarea"){V.value=O;}}}}}}}}M.prototype={getForm:function(){if(!this.form){this.form=document.forms[this.form_name];}return this.form;},hasFileInputs:function(){return this.has_file_inputs;},setDefaultValues:function(O){this.default_value_map=O;},setDefaultValue:function(P,O){this.default_value_map[P]=O;},saveCurrentValuesAsDefault:function(){this.default_value_map={};this.button_list=[];J.call(this);},setFunction:function(P,O){this.validation.fn[D(P)]=O;},setRegex:function(Q,P,O){Q=D(Q);if(B.Lang.isString(P)){this.validation.regex[Q]=new RegExp(P,O);}else{this.validation.regex[Q]=P;}if(!this.validation_msgs[Q]||!this.validation_msgs[Q].regex){}},setErrorMessages:function(P,O){this.validation_msgs[D(P)]=O;},addErrorMessage:function(Q,O,P){Q=D(Q);if(!this.validation_msgs[Q]){this.validation_msgs[Q]={};}this.validation_msgs[Q][O]=P;},clearForm:function(){this.clearMessages();this.form.reset();this.postPopulateForm();},populateForm:function(){if(!this.default_value_map){this.default_value_map={};}this.clearMessages();J.call(this);this.postPopulateForm();},postPopulateForm:function(){},isChanged:function(){for(var Q=0;Q0){S.scrollIntoView();try{T.focus();}catch(Q){}}this.has_messages=true;if(R=="error"){this.has_errors=true;}}},notifyErrors:function(){this.displayFormMessage(M.Strings.validation_error,true,false);},displayFormMessage:function(Q,P,O){if(B.Lang.isUndefined(O)){O=true;}if(this.status_node){if(!this.status_node.innerHTML){this.status_node.replaceClass(M.status_none_class,(P?M.status_failure_class:M.status_success_class));this.status_node.set("innerHTML",Q);}if(O){this.status_node.scrollIntoView();}}else{}}};B.FormManager=M;},"gallery-2010.04.02-17-26",{requires:["node-base","substitute"]}); \ No newline at end of file diff --git a/build/gallery-formmgr/gallery-formmgr.js b/build/gallery-formmgr/gallery-formmgr.js index ec5c207603..1d62963fad 100644 --- a/build/gallery-formmgr/gallery-formmgr.js +++ b/build/gallery-formmgr/gallery-formmgr.js @@ -1057,18 +1057,18 @@ FormManager.prototype = { this.displayMessage(e[i], info.error, 'error'); status = false; - } - if (!info.keepGoing) - { continue; } - if (this.validation.regex[e_id] && - !this.validation.regex[e_id].test(e[i].value)) + if (info.keepGoing) { - this.displayMessage(e[i], msg_list ? msg_list.regex : null, 'error'); - status = false; - continue; + if (this.validation.regex[e_id] && + !this.validation.regex[e_id].test(e[i].value)) + { + this.displayMessage(e[i], msg_list ? msg_list.regex : null, 'error'); + status = false; + continue; + } } var f = this.validation.fn[e_id]; @@ -1366,4 +1366,4 @@ FormManager.prototype = Y.FormManager = FormManager; -}, 'gallery-2010.03.23-17-54' ,{requires:['node-base','substitute']}); +}, 'gallery-2010.04.02-17-26' ,{requires:['node-base','substitute']}); diff --git a/build/gallery-node-accordion/assets/skins/sam/gallery-node-accordion.css b/build/gallery-node-accordion/assets/skins/sam/gallery-node-accordion.css index d16bf3f72b..f1d8a13150 100644 --- a/build/gallery-node-accordion/assets/skins/sam/gallery-node-accordion.css +++ b/build/gallery-node-accordion/assets/skins/sam/gallery-node-accordion.css @@ -1 +1 @@ -.yui-accordion{position:relative;zoom:1;}.yui-accordion .yui-accordion-item{display:block;}.yui-accordion .yui-accordion-item .yui-accordion-item-bd{height:0;_height:1px;*height:1px;overflow:hidden;zoom:1;}.yui-accordion .yui-accordion-item-active .yui-accordion-item-bd{height:auto;}.yui-accordion-hidden{border:0;height:0;width:0;padding:0;position:absolute;left:-999999px;overflow:hidden;visibility:hidden;}.yui-skin-sam .yui-accordion{font-size:93%;line-height:1.5;*line-height:1.45;border-top:solid 1px #808080;border-left:solid 1px #808080;border-right:solid 1px #808080;background:#fff;padding:0;text-align:left;}.yui-skin-sam .yui-accordion .yui-accordion-item{display:block;border-bottom:solid 1px #808080;}.yui-skin-sam .yui-accordion .yui-accordion-item .yui-accordion-item-hd{line-height:2;*line-height:1.9;background:url(http://yui.yahooapis.com/3.0.0/build/assets/skins/sam/sprite.png) repeat-x 0 0;padding:0;padding:5px;}.yui-skin-sam .yui-accordion .yui-accordion-item .yui-accordion-item-bd{font-size:100%;margin:0;padding:0;display:block;}.yui-skin-sam .yui-accordion .yui-accordion-item-hd a.yui-accordion-item-trigger{width:auto;display:block;color:#000;text-decoration:none;cursor:default;padding:0 5px 0 10px;background:url(http://yui.yahooapis.com/3.0.0/build/assets/skins/sam/sprite.png) no-repeat 110% -345px;}.yui-skin-sam .yui-accordion .yui-accordion-item-active .yui-accordion-item-hd a.yui-accordion-item-trigger{background:url(http://yui.yahooapis.com/3.0.0/build/assets/skins/sam/sprite.png) no-repeat 110% -395px;} +.yui3-accordion{position:relative;zoom:1;}.yui3-accordion .yui3-accordion-item{display:block;}.yui3-accordion .yui3-accordion-item .yui3-accordion-item-bd{height:0;_height:1px;*height:1px;overflow:hidden;zoom:1;}.yui3-accordion .yui3-accordion-item-active .yui3-accordion-item-bd{height:auto;}.yui3-accordion-hidden{border:0;height:0;width:0;padding:0;position:absolute;left:-999999px;overflow:hidden;visibility:hidden;}.yui3-skin-sam .yui3-accordion{font-size:93%;line-height:1.5;*line-height:1.45;border-top:solid 1px #808080;border-left:solid 1px #808080;border-right:solid 1px #808080;background:#fff;padding:0;text-align:left;}.yui3-skin-sam .yui3-accordion .yui3-accordion-item{display:block;border-bottom:solid 1px #808080;}.yui3-skin-sam .yui3-accordion .yui3-accordion-item .yui3-accordion-item-hd{line-height:2;*line-height:1.9;background:url(http://yui.yahooapis.com/3.0.0/build/assets/skins/sam/sprite.png) repeat-x 0 0;padding:0;padding:5px;}.yui3-skin-sam .yui3-accordion .yui3-accordion-item .yui3-accordion-item-bd{font-size:100%;margin:0;padding:0;display:block;}.yui3-skin-sam .yui3-accordion .yui3-accordion-item-hd a.yui3-accordion-item-trigger{width:auto;display:block;color:#000;text-decoration:none;cursor:default;padding:0 5px 0 10px;background:url(http://yui.yahooapis.com/3.0.0/build/assets/skins/sam/sprite.png) no-repeat 110% -345px;}.yui3-skin-sam .yui3-accordion .yui3-accordion-item-active .yui3-accordion-item-hd a.yui3-accordion-item-trigger{background:url(http://yui.yahooapis.com/3.0.0/build/assets/skins/sam/sprite.png) no-repeat 110% -395px;} diff --git a/build/gallery-node-accordion/gallery-node-accordion-debug.js b/build/gallery-node-accordion/gallery-node-accordion-debug.js index 1c6fd2debe..f3cf0ad923 100644 --- a/build/gallery-node-accordion/gallery-node-accordion-debug.js +++ b/build/gallery-node-accordion/gallery-node-accordion-debug.js @@ -144,7 +144,7 @@ var UA = Y.UA, * The NodeAccordion class is a plugin for a Node instance. The class is used via * the plug method of Node and * should not be instantiated directly. - * @namespace plugin + * @namespace Y.Plugin * @class NodeAccordion */ NodeAccordion = function () { @@ -161,6 +161,7 @@ NodeAccordion.ATTRS = { * Nodes representing the list of active items. * * @attribute activeItems + * @readOnly * @type Y.NodeList */ activeItems: { @@ -173,6 +174,7 @@ NodeAccordion.ATTRS = { * Nodes representing the list of items. * * @attribute items + * @readOnly * @type Y.NodeList */ items: { @@ -263,7 +265,6 @@ NodeAccordion.ATTRS = { * * * @attribute speed - * @readOnly * @default 0.4 * @type numeric */ @@ -596,4 +597,4 @@ Y.namespace('Plugin'); Y.Plugin.NodeAccordion = NodeAccordion; -}, 'gallery-2010.02.17-20' ,{optional:['anim'], requires:['node-base', 'node-style', 'plugin', 'node-event-delegate', 'classnamemanager']}); +}, 'gallery-2010.04.02-17-26' ,{requires:['node-base', 'node-style', 'plugin', 'node-event-delegate', 'classnamemanager'], optional:['anim']}); diff --git a/build/gallery-node-accordion/gallery-node-accordion-min.js b/build/gallery-node-accordion/gallery-node-accordion-min.js index 2f597fb8d6..a078a82709 100644 --- a/build/gallery-node-accordion/gallery-node-accordion-min.js +++ b/build/gallery-node-accordion/gallery-node-accordion-min.js @@ -1 +1 @@ -YUI.add("gallery-node-accordion",function(B){var S=B.UA,f=B.ClassNameManager.getClassName,X={},I={fast:0.1,slow:0.6,normal:0.4},J="accordion",E="item",a="scrollHeight",e="scrollWidth",F="width",V="height",i="px",G=".",O="host",j="orientation",D="fade",W="multiple",L="persistent",k="speed",c="anim",T="items",g=f(J),Z=f(J,"hidden"),H=f(J,E),M=f(J,E,"active"),A=f(J,E,"sliding"),d=f(J,E,"hd"),b=f(J,E,"bd"),K=f(J,E,"ft"),P=f(J,E,"trigger"),h=G+H,C=G+b,Q=">.",U=Q+H,R=U+G+P+", "+U+Q+d+G+P+", "+U+Q+d+Q+P+", "+U+Q+K+G+P+", "+U+Q+K+Q+P,N=function(){N.superclass.constructor.apply(this,arguments);};N.NAME="NodeAccordion";N.NS=J;N.ATTRS={activeItems:{readOnly:true,getter:function(Y){return this._root.all(Q+M);}},items:{readOnly:true,getter:function(Y){return this._root.all(U);}},orientation:{value:V,writeOnce:true},fade:{value:false},anim:{value:false,validator:function(Y){return !B.Lang.isUndefined(B.Anim);}},multiple:{value:true},persistent:{value:false},speed:{value:0.4,validator:function(Y){return(B.Lang.isNumber(Y)||(B.Lang.isString(Y)&&I.hasOwnProperty(Y)));},setter:function(Y){return(I.hasOwnProperty(Y)?I[Y]:Y);}}};B.extend(N,B.Plugin.Base,{_root:null,initializer:function(l){var m=this.get(O),Y=[];if(m){this._root=m;this.get(T).each(function(n){if(n.hasClass(M)){this.expandItem(n);}else{this.collapseItem(n);}},this);Y.push(m.delegate("click",function(n){this.toggleItem(n.currentTarget);n.target.blur();n.halt();},R,this));Y=this._eventHandlers;m.removeClass(Z);}},destructor:function(){var Y=this._eventHandlers;if(Y){B.Array.each(Y,function(l){l.detach();});this._eventHandlers=null;}},_getItem:function(l){if(B.Lang.isNumber(l)){l=this.get(T).item(l);}var Y=function(m){return m.hasClass(H);};if(l&&!l.hasClass(H)){return l.ancestor(Y);}return l;},_animate:function(n,Y,l){var m=X[n];if((m)&&(m.get("running"))){m.stop();}if(B.Lang.isFunction(this.get(c))){Y.easing=this.get(c);}m=new B.Anim(Y);m.on("end",l,this);m.run();X[n]=m;return m;},_openItem:function(u){var p,Y,s,n,m,r=this.get(T),l=this.get(j),q={duration:this.get(k),to:{scroll:[]}},t;if(u&&r.size()&&!u.hasClass(M)&&(p=u.one(C))&&(Y=B.stamp(p))){if(!this.get(W)){t=this._root.one(Q+M);}q.to[l]=(l==F?p.get(e):p.get(a));q.node=p;u.addClass(A);s=function(){u.removeClass(A);u.addClass(M);};if(!this.get(c)){n=p.get(l);if(B.Lang.isObject(t)){n=t.get(l);t.addClass(A);}for(m=1;m<=n;m++){if(B.Lang.isObject(t)){t.setStyle(l,(n-m)+i);}p.setStyle(l,m+i);}if(B.Lang.isObject(t)){t.removeClass(A);t.removeClass(M);}s();}else{q.to.scroll=[0,0];if(this.get(D)){q.to.opacity=1;}if(B.Lang.isObject(t)){this._closeItem(t);}this._animate(Y,q,s);}}},_closeItem:function(t){var p,Y,s,n,m,r=this.get(T),l=this.get(j),q={duration:this.get(k),to:{scroll:[]}};if(t&&r.size()&&(p=t.one(C))&&(Y=B.stamp(p))){q.to[l]=(((l==V)&&S.ie&&(S.ie<7))?1:0);q.node=p;t.addClass(A);s=function(){t.removeClass(A);t.removeClass(M);};if(!this.get(c)){n=p.get(l);for(m=n;m>=q.to[l].to;m--){p.setStyle(l,m+i);}s();}else{q.to.scroll=(l==F?[p.get(e),0]:[0,p.get(a)]);if(this.get(D)){q.to.opacity=0;}this._animate(Y,q,s);}}},expandAllItems:function(){if(this.get(W)){this.get(T).each(function(Y){this.expandItem(Y);},this);}return this;},collapseAllItems:function(){if(this.get(W)||!this.get(L)){this.get(T).each(function(Y){this.collapseItem(Y);},this);}return this;},expandItem:function(l){var Y=this._getItem(l);if(Y){this._openItem(Y);}return this;},collapseItem:function(l){var Y=this._getItem(l);if(Y&&Y.hasClass(M)&&(this.get(W)||!this.get(L))){this._closeItem(Y);}return this;},toggleItem:function(l){var Y=this._getItem(l);if(Y){((Y.hasClass(M)&&(this.get(W)||!this.get(L)))?this._closeItem(Y):this._openItem(Y));}return this;}});B.namespace("Plugin");B.Plugin.NodeAccordion=N;},"gallery-2010.02.17-20",{optional:["anim"],requires:["node-base","node-style","plugin","node-event-delegate","classnamemanager"]}); \ No newline at end of file +YUI.add("gallery-node-accordion",function(B){var S=B.UA,f=B.ClassNameManager.getClassName,X={},I={fast:0.1,slow:0.6,normal:0.4},J="accordion",E="item",a="scrollHeight",e="scrollWidth",F="width",V="height",i="px",G=".",O="host",j="orientation",D="fade",W="multiple",L="persistent",k="speed",c="anim",T="items",g=f(J),Z=f(J,"hidden"),H=f(J,E),M=f(J,E,"active"),A=f(J,E,"sliding"),d=f(J,E,"hd"),b=f(J,E,"bd"),K=f(J,E,"ft"),P=f(J,E,"trigger"),h=G+H,C=G+b,Q=">.",U=Q+H,R=U+G+P+", "+U+Q+d+G+P+", "+U+Q+d+Q+P+", "+U+Q+K+G+P+", "+U+Q+K+Q+P,N=function(){N.superclass.constructor.apply(this,arguments);};N.NAME="NodeAccordion";N.NS=J;N.ATTRS={activeItems:{readOnly:true,getter:function(Y){return this._root.all(Q+M);}},items:{readOnly:true,getter:function(Y){return this._root.all(U);}},orientation:{value:V,writeOnce:true},fade:{value:false},anim:{value:false,validator:function(Y){return !B.Lang.isUndefined(B.Anim);}},multiple:{value:true},persistent:{value:false},speed:{value:0.4,validator:function(Y){return(B.Lang.isNumber(Y)||(B.Lang.isString(Y)&&I.hasOwnProperty(Y)));},setter:function(Y){return(I.hasOwnProperty(Y)?I[Y]:Y);}}};B.extend(N,B.Plugin.Base,{_root:null,initializer:function(l){var m=this.get(O),Y=[];if(m){this._root=m;this.get(T).each(function(n){if(n.hasClass(M)){this.expandItem(n);}else{this.collapseItem(n);}},this);Y.push(m.delegate("click",function(n){this.toggleItem(n.currentTarget);n.target.blur();n.halt();},R,this));Y=this._eventHandlers;m.removeClass(Z);}},destructor:function(){var Y=this._eventHandlers;if(Y){B.Array.each(Y,function(l){l.detach();});this._eventHandlers=null;}},_getItem:function(l){if(B.Lang.isNumber(l)){l=this.get(T).item(l);}var Y=function(m){return m.hasClass(H);};if(l&&!l.hasClass(H)){return l.ancestor(Y);}return l;},_animate:function(n,Y,l){var m=X[n];if((m)&&(m.get("running"))){m.stop();}if(B.Lang.isFunction(this.get(c))){Y.easing=this.get(c);}m=new B.Anim(Y);m.on("end",l,this);m.run();X[n]=m;return m;},_openItem:function(u){var p,Y,s,n,m,r=this.get(T),l=this.get(j),q={duration:this.get(k),to:{scroll:[]}},t;if(u&&r.size()&&!u.hasClass(M)&&(p=u.one(C))&&(Y=B.stamp(p))){if(!this.get(W)){t=this._root.one(Q+M);}q.to[l]=(l==F?p.get(e):p.get(a));q.node=p;u.addClass(A);s=function(){u.removeClass(A);u.addClass(M);};if(!this.get(c)){n=p.get(l);if(B.Lang.isObject(t)){n=t.get(l);t.addClass(A);}for(m=1;m<=n;m++){if(B.Lang.isObject(t)){t.setStyle(l,(n-m)+i);}p.setStyle(l,m+i);}if(B.Lang.isObject(t)){t.removeClass(A);t.removeClass(M);}s();}else{q.to.scroll=[0,0];if(this.get(D)){q.to.opacity=1;}if(B.Lang.isObject(t)){this._closeItem(t);}this._animate(Y,q,s);}}},_closeItem:function(t){var p,Y,s,n,m,r=this.get(T),l=this.get(j),q={duration:this.get(k),to:{scroll:[]}};if(t&&r.size()&&(p=t.one(C))&&(Y=B.stamp(p))){q.to[l]=(((l==V)&&S.ie&&(S.ie<7))?1:0);q.node=p;t.addClass(A);s=function(){t.removeClass(A);t.removeClass(M);};if(!this.get(c)){n=p.get(l);for(m=n;m>=q.to[l].to;m--){p.setStyle(l,m+i);}s();}else{q.to.scroll=(l==F?[p.get(e),0]:[0,p.get(a)]);if(this.get(D)){q.to.opacity=0;}this._animate(Y,q,s);}}},expandAllItems:function(){if(this.get(W)){this.get(T).each(function(Y){this.expandItem(Y);},this);}return this;},collapseAllItems:function(){if(this.get(W)||!this.get(L)){this.get(T).each(function(Y){this.collapseItem(Y);},this);}return this;},expandItem:function(l){var Y=this._getItem(l);if(Y){this._openItem(Y);}return this;},collapseItem:function(l){var Y=this._getItem(l);if(Y&&Y.hasClass(M)&&(this.get(W)||!this.get(L))){this._closeItem(Y);}return this;},toggleItem:function(l){var Y=this._getItem(l);if(Y){((Y.hasClass(M)&&(this.get(W)||!this.get(L)))?this._closeItem(Y):this._openItem(Y));}return this;}});B.namespace("Plugin");B.Plugin.NodeAccordion=N;},"gallery-2010.04.02-17-26",{requires:["node-base","node-style","plugin","node-event-delegate","classnamemanager"],optional:["anim"]}); \ No newline at end of file diff --git a/build/gallery-node-accordion/gallery-node-accordion.js b/build/gallery-node-accordion/gallery-node-accordion.js index 65527a5601..0a91d91868 100644 --- a/build/gallery-node-accordion/gallery-node-accordion.js +++ b/build/gallery-node-accordion/gallery-node-accordion.js @@ -144,7 +144,7 @@ var UA = Y.UA, * The NodeAccordion class is a plugin for a Node instance. The class is used via * the plug method of Node and * should not be instantiated directly. - * @namespace plugin + * @namespace Y.Plugin * @class NodeAccordion */ NodeAccordion = function () { @@ -161,6 +161,7 @@ NodeAccordion.ATTRS = { * Nodes representing the list of active items. * * @attribute activeItems + * @readOnly * @type Y.NodeList */ activeItems: { @@ -173,6 +174,7 @@ NodeAccordion.ATTRS = { * Nodes representing the list of items. * * @attribute items + * @readOnly * @type Y.NodeList */ items: { @@ -263,7 +265,6 @@ NodeAccordion.ATTRS = { * * * @attribute speed - * @readOnly * @default 0.4 * @type numeric */ @@ -588,4 +589,4 @@ Y.namespace('Plugin'); Y.Plugin.NodeAccordion = NodeAccordion; -}, 'gallery-2010.02.17-20' ,{optional:['anim'], requires:['node-base', 'node-style', 'plugin', 'node-event-delegate', 'classnamemanager']}); +}, 'gallery-2010.04.02-17-26' ,{requires:['node-base', 'node-style', 'plugin', 'node-event-delegate', 'classnamemanager'], optional:['anim']}); diff --git a/build/gallery-paginator/assets/skins/sam/gallery-paginator.css b/build/gallery-paginator/assets/skins/sam/gallery-paginator.css index 595c10f854..889d564462 100644 --- a/build/gallery-paginator/assets/skins/sam/gallery-paginator.css +++ b/build/gallery-paginator/assets/skins/sam/gallery-paginator.css @@ -1 +1 @@ -.yui-skin-sam .yui-paginator{display:block;margin:6px 0;white-space:nowrap;}.yui-skin-sam .yui-paginator-first,.yui-skin-sam .yui-paginator-previous,.yui-skin-sam .yui-paginator-next,.yui-skin-sam .yui-paginator-last,.yui-skin-sam .yui-paginator-current,.yui-skin-sam .yui-paginator-page-input,.yui-skin-sam .yui-paginator-ir-dropdown,.yui-skin-sam .yui-paginator-pages,.yui-skin-sam .yui-paginator-page{display:inline-block;font-family:arial,helvetica,clean,sans-serif;padding:3px 6px;zoom:1;}.yui-skin-sam .yui-paginator-pages{padding:0;}.yui-skin-sam .yui-paginator-current{padding:3px 0;}.yui-skin-sam a.yui-paginator-first:link,.yui-skin-sam a.yui-paginator-first:visited,.yui-skin-sam a.yui-paginator-first:active,.yui-skin-sam a.yui-paginator-first:hover,.yui-skin-sam a.yui-paginator-previous:link,.yui-skin-sam a.yui-paginator-previous:visited,.yui-skin-sam a.yui-paginator-previous:active,.yui-skin-sam a.yui-paginator-previous:hover,.yui-skin-sam a.yui-paginator-next:link,.yui-skin-sam a.yui-paginator-next:visited,.yui-skin-sam a.yui-paginator-next:active,.yui-skin-sam a.yui-paginator-next:hover,.yui-skin-sam a.yui-paginator-last:link,.yui-skin-sam a.yui-paginator-last:visited,.yui-skin-sam a.yui-paginator-last:active,.yui-skin-sam a.yui-paginator-last:hover,.yui-skin-sam a.yui-paginator-page:link,.yui-skin-sam a.yui-paginator-page:visited,.yui-skin-sam a.yui-paginator-page:active,.yui-skin-sam a.yui-paginator-page:hover{color:#06c;text-decoration:underline;outline:0;}.yui-skin-sam span.yui-paginator-first,.yui-skin-sam span.yui-paginator-previous,.yui-skin-sam span.yui-paginator-next,.yui-skin-sam span.yui-paginator-last{color:#a6a6a6;}.yui-skin-sam .yui-paginator-page{background-color:#fff;border:1px solid #CBCBCB;padding:2px 6px;text-decoration:none;}.yui-skin-sam .yui-paginator-current-page{background-color:transparent;border:none;font-weight:bold;padding:3px 6px;}.yui-skin-sam .yui-paginator-page{margin-left:1px;margin-right:1px;}.yui-skin-sam .yui-paginator-first,.yui-skin-sam .yui-paginator-previous{padding-left:0;}.yui-skin-sam .yui-paginator-next,.yui-skin-sam .yui-paginator-last{padding-right:0;}.yui-skin-sam .yui-paginator-current,.yui-skin-sam .yui-paginator-rpp-options{margin-left:1em;margin-right:1em;}.yui-skin-sam .yui-paginator-page-input .yui-page-input{width:2.4em;} +.yui3-skin-sam .yui3-paginator{display:block;margin:6px 0;white-space:nowrap;}.yui3-skin-sam .yui3-paginator-first,.yui3-skin-sam .yui3-paginator-previous,.yui3-skin-sam .yui3-paginator-next,.yui3-skin-sam .yui3-paginator-last,.yui3-skin-sam .yui3-paginator-current,.yui3-skin-sam .yui3-paginator-page-input,.yui3-skin-sam .yui3-paginator-ir-dropdown,.yui3-skin-sam .yui3-paginator-pages,.yui3-skin-sam .yui3-paginator-page{display:inline-block;font-family:arial,helvetica,clean,sans-serif;padding:3px 6px;zoom:1;}.yui3-skin-sam .yui3-paginator-pages{padding:0;}.yui3-skin-sam .yui3-paginator-current{padding:3px 0;}.yui3-skin-sam a.yui3-paginator-first:link,.yui3-skin-sam a.yui3-paginator-first:visited,.yui3-skin-sam a.yui3-paginator-first:active,.yui3-skin-sam a.yui3-paginator-first:hover,.yui3-skin-sam a.yui3-paginator-previous:link,.yui3-skin-sam a.yui3-paginator-previous:visited,.yui3-skin-sam a.yui3-paginator-previous:active,.yui3-skin-sam a.yui3-paginator-previous:hover,.yui3-skin-sam a.yui3-paginator-next:link,.yui3-skin-sam a.yui3-paginator-next:visited,.yui3-skin-sam a.yui3-paginator-next:active,.yui3-skin-sam a.yui3-paginator-next:hover,.yui3-skin-sam a.yui3-paginator-last:link,.yui3-skin-sam a.yui3-paginator-last:visited,.yui3-skin-sam a.yui3-paginator-last:active,.yui3-skin-sam a.yui3-paginator-last:hover,.yui3-skin-sam a.yui3-paginator-page:link,.yui3-skin-sam a.yui3-paginator-page:visited,.yui3-skin-sam a.yui3-paginator-page:active,.yui3-skin-sam a.yui3-paginator-page:hover{color:#06c;text-decoration:underline;outline:0;}.yui3-skin-sam span.yui3-paginator-first,.yui3-skin-sam span.yui3-paginator-previous,.yui3-skin-sam span.yui3-paginator-next,.yui3-skin-sam span.yui3-paginator-last{color:#a6a6a6;}.yui3-skin-sam .yui3-paginator-page{background-color:#fff;border:1px solid #CBCBCB;padding:2px 6px;text-decoration:none;}.yui3-skin-sam .yui3-paginator-current-page{background-color:transparent;border:none;font-weight:bold;padding:3px 6px;}.yui3-skin-sam .yui3-paginator-page{margin-left:1px;margin-right:1px;}.yui3-skin-sam .yui3-paginator-first,.yui3-skin-sam .yui3-paginator-previous{padding-left:0;}.yui3-skin-sam .yui3-paginator-next,.yui3-skin-sam .yui3-paginator-last{padding-right:0;}.yui3-skin-sam .yui3-paginator-current,.yui3-skin-sam .yui3-paginator-rpp-options{margin-left:1em;margin-right:1em;}.yui3-skin-sam .yui3-paginator-page-input .yui3-page-input{width:2.4em;} diff --git a/build/gallery-paginator/gallery-paginator-debug.js b/build/gallery-paginator/gallery-paginator-debug.js index 569abb0916..5c8f53a09a 100644 --- a/build/gallery-paginator/gallery-paginator-debug.js +++ b/build/gallery-paginator/gallery-paginator-debug.js @@ -2436,4 +2436,4 @@ Paginator.ui.RowsPerPageDropdown.prototype = { }; -}, 'gallery-2010.02.25-22' ,{requires:['widget','event-key','substitute']}); +}, 'gallery-2010.04.02-17-26' ,{requires:['widget','event-key','substitute']}); diff --git a/build/gallery-paginator/gallery-paginator-min.js b/build/gallery-paginator/gallery-paginator-min.js index 9f59a6a9dc..6ae0e37c70 100644 --- a/build/gallery-paginator/gallery-paginator-min.js +++ b/build/gallery-paginator/gallery-paginator-min.js @@ -1,4 +1,4 @@ YUI.add("gallery-paginator",function(A){A.Node.DOM_EVENTS.key={on:A.Env.evt.plugins.key.on};"use strict";function B(C){B.superclass.constructor.call(this,C);}A.mix(B,{NAME:"paginator",id:0,ID_BASE:"yui-pg-",VALUE_UNLIMITED:-1,TEMPLATE_DEFAULT:"{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}",TEMPLATE_ROWS_PER_PAGE:"{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}",ui:{},isNumeric:function(C){return isFinite(+C);},toNumber:function(C){return isFinite(+C)?+C:null;}},true);B.ATTRS={rowsPerPage:{value:0,validator:B.isNumeric,setter:B.toNumber},totalRecords:{value:0,validator:B.isNumeric,setter:B.toNumber},recordOffset:{value:0,validator:function(D){var C=this.get("totalRecords");if(B.isNumeric(D)){D=+D;return C===B.VALUE_UNLIMITED||C>D||(C===0&&D===0);}return false;},setter:B.toNumber},initialPage:{value:1,validator:B.isNumeric,setter:B.toNumber},template:{value:B.TEMPLATE_DEFAULT,validator:A.Lang.isString},alwaysVisible:{value:true,validator:A.Lang.isBoolean},updateOnChange:{value:false,validator:A.Lang.isBoolean},id:{value:B.id++,readOnly:true}};A.extend(B,A.Widget,{_batch:false,_pageChanged:false,_state:null,initializer:function(F){var H=B.VALUE_UNLIMITED,C,D,E,G;this._selfSubscribe();C=this.get("initialPage");D=this.get("totalRecords");E=this.get("rowsPerPage");if(C>1&&E!==H){G=(C-1)*E;if(D===H||G'));C.all("span."+E).each(function(H){this.renderUIComponent(H,F);},this);if(!D){C.setStyle("display","");}},renderUIComponent:function(C,I){var H=C.get("parentNode"),G=this.getClassName("ui"),F=new RegExp(G+"-(\\w+)").exec(C.get("className")),E=F&&B.ui[F[1]],D;if(A.Lang.isFunction(E)){D=new E(this);if(A.Lang.isFunction(D.render)){H.replaceChild(D.render(I),C);}}},updateVisibility:function(H){var D=this.get("alwaysVisible"),J,I,F,G,E,C;if(!H||H.type==="alwaysVisibleChange"||!D){J=this.get("totalRecords");I=true;F=this.get("rowsPerPage");G=this.get("rowsPerPageOptions");if(A.Lang.isArray(G)){for(E=0,C=G.length;E=D);},getCurrentPage:function(){var C=this.get("rowsPerPage");if(!C||!this.get("totalRecords")){return 0;}return Math.floor(this.get("recordOffset")/C)+1;},hasNextPage:function(){var C=this.getCurrentPage(),D=this.getTotalPages();return C&&(D===B.VALUE_UNLIMITED||C1);},getPreviousPage:function(){return(this.hasPreviousPage()?this.getCurrentPage()-1:1);},getPageRecords:function(F){if(!A.Lang.isNumber(F)){F=this.getCurrentPage();}var E=this.get("rowsPerPage"),D=this.get("totalRecords"),G,C;if(!F||!E){return null;}G=(F-1)*E;if(D!==B.VALUE_UNLIMITED){if(G>=D){return null;}C=Math.min(G+E,D)-1;}else{C=G+E-1;}return[G,C];},setPage:function(D,C){if(this.hasPage(D)&&D!==this.getCurrentPage()){if(this.get("updateOnChange")||C){this.set("recordOffset",(D-1)*this.get("rowsPerPage"));}else{this.fire("changeRequest",this.getState({"page":D}));}}},getRowsPerPage:function(){return this.get("rowsPerPage");},setRowsPerPage:function(D,C){if(B.isNumeric(D)&&+D>0&&+D!==this.get("rowsPerPage")){if(this.get("updateOnChange")||C){this.set("rowsPerPage",D);}else{this.fire("changeRequest",this.getState({"rowsPerPage":+D}));}}},getTotalRecords:function(){return this.get("totalRecords");},setTotalRecords:function(D,C){if(B.isNumeric(D)&&+D>=0&&+D!==this.get("totalRecords")){if(this.get("updateOnChange")||C){this.set("totalRecords",D);}else{this.fire("changeRequest",this.getState({"totalRecords":+D}));}}},getStartIndex:function(){return this.get("recordOffset");},setStartIndex:function(D,C){if(B.isNumeric(D)&&+D>=0&&+D!==this.get("recordOffset")){if(this.get("updateOnChange")||C){this.set("recordOffset",D);}else{this.fire("changeRequest",this.getState({"recordOffset":+D}));}}},getState:function(I){var K=B.VALUE_UNLIMITED,G=Math,H=G.max,J=G.ceil,E,C,F;function D(N,L,M){if(N<=0||L===0){return 0;}if(L===K||L>N){return N-(N%M);}return L-(L%M||M);}E={paginator:this,totalRecords:this.get("totalRecords"),rowsPerPage:this.get("rowsPerPage"),records:this.getPageRecords()};E.recordOffset=D(this.get("recordOffset"),E.totalRecords,E.rowsPerPage);E.page=J(E.recordOffset/E.rowsPerPage)+1;if(!I){return E;}C={paginator:this,before:E,rowsPerPage:I.rowsPerPage||E.rowsPerPage,totalRecords:(B.isNumeric(I.totalRecords)?H(I.totalRecords,K):+E.totalRecords)};if(C.totalRecords===0){C.recordOffset=C.page=0;}else{F=B.isNumeric(I.page)?(I.page-1)*C.rowsPerPage:B.isNumeric(I.recordOffset)?+I.recordOffset:E.recordOffset;C.recordOffset=D(F,C.totalRecords,C.rowsPerPage);C.page=J(C.recordOffset/C.rowsPerPage)+1;}C.records=[C.recordOffset,C.recordOffset+C.rowsPerPage-1];if(C.totalRecords!==K&&C.recordOffsetC.totalRecords-1){C.records[1]=C.totalRecords-1; }return C;},setState:function(D){if(A.Lang.isObject(D)){this._state=this.getState({});D={page:D.page,rowsPerPage:D.rowsPerPage,totalRecords:D.totalRecords,recordOffset:D.recordOffset};if(D.page&&D.recordOffset===undefined){D.recordOffset=(D.page-1)*(D.rowsPerPage||this.get("rowsPerPage"));}this._batch=true;this._pageChanged=false;for(var C in D){if(D.hasOwnProperty(C)&&this._configs.hasOwnProperty(C)){this.set(C,D[C]);}}this._batch=false;if(this._pageChanged){this._pageChanged=false;this._firePageChange(this.getState(this._state));}}},_syncRecordOffset:function(F){var C=F.newValue,E,D;if(F.prevValue!==C){if(C!==B.VALUE_UNLIMITED){E=this.get("rowsPerPage");if(E&&this.get("recordOffset")>=C){D=this.getState({totalRecords:F.prevValue,recordOffset:this.get("recordOffset")});this.set("recordOffset",D.before.recordOffset);this._firePageChange(D);}}}},_handleStateChange:function(D){if(D.prevValue!==D.newValue){var E=this._state||{},C;E[D.type.replace(/Change$/,"")]=D.prevValue;C=this.getState(E);if(C.page!==C.before.page){if(this._batch){this._pageChanged=true;}else{this._firePageChange(C);}}}},_firePageChange:function(C){if(A.Lang.isObject(C)){var D=C.before;delete C.before;this.fire("pageChange",{type:"pageChange",prevValue:C.page,newValue:D.page,prevState:C,newState:D});}}});A.Paginator=B;B.ui.CurrentPageInput=function(C){this.paginator=C;C.on("destroy",this.destroy,this);C.after("recordOffsetChange",this.update,this);C.after("rowsPerPageChange",this.update,this);C.after("totalRecordsChange",this.update,this);C.after("pageInputClassChange",this.update,this);};B.ATTRS.pageInputClass={value:A.ClassNameManager.getClassName(B.NAME,"page-input"),validator:A.Lang.isString};B.ATTRS.pageInputTemplate={value:"{currentPage} of {totalPages}",validator:A.Lang.isString};B.ui.CurrentPageInput.prototype={destroy:function(){this.span.remove(true);this.span=null;this.input=null;this.page_count=null;},render:function(C){this.span=A.Node.create(''+A.substitute(this.paginator.get("pageInputTemplate"),{currentPage:'',totalPages:''})+"");this.span.set("className",this.paginator.get("pageInputClass"));this.input=this.span.one("input");this.input.on("change",this._onChange,this);this.input.on("key",this._onReturnKey,"down:13",this);this.page_count=this.span.one("span.yui-page-count");this.update();return this.span;},update:function(C){if(C&&C.prevVal===C.newVal){return;}this.span.set("className",this.paginator.get("pageInputClass"));this.input.set("value",this.paginator.getCurrentPage());this.page_count.set("innerHTML",this.paginator.getTotalPages());},_onChange:function(C){this.paginator.setPage(parseInt(this.input.get("value"),10));},_onReturnKey:function(C){C.halt(true);this.paginator.setPage(parseInt(this.input.get("value"),10));}};B.ui.CurrentPageReport=function(C){this.paginator=C;C.on("destroy",this.destroy,this);C.after("recordOffsetChange",this.update,this);C.after("rowsPerPageChange",this.update,this);C.after("totalRecordsChange",this.update,this);C.after("pageReportClassChange",this.update,this);C.after("pageReportTemplateChange",this.update,this);};B.ATTRS.pageReportClass={value:A.ClassNameManager.getClassName(B.NAME,"current"),validator:A.Lang.isString};B.ATTRS.pageReportTemplate={value:"({currentPage} of {totalPages})",validator:A.Lang.isString};B.ATTRS.pageReportValueGenerator={value:function(E){var D=E.getCurrentPage(),C=E.getPageRecords();return{"currentPage":C?D:0,"totalPages":E.getTotalPages(),"startIndex":C?C[0]:0,"endIndex":C?C[1]:0,"startRecord":C?C[0]+1:0,"endRecord":C?C[1]+1:0,"totalRecords":E.get("totalRecords")};},validator:A.Lang.isFunction};B.ui.CurrentPageReport.sprintf=function(D,C){return D.replace(/\{([\w\s\-]+)\}/g,function(E,F){return(F in C)?C[F]:"";});};B.ui.CurrentPageReport.prototype={span:null,destroy:function(){this.span.remove(true);this.span=null;},render:function(C){this.span=A.Node.create('');this.span.set("className",this.paginator.get("pageReportClass"));this.update();return this.span;},update:function(C){if(C&&C.prevVal===C.newVal){return;}this.span.set("className",this.paginator.get("pageReportClass"));this.span.set("innerHTML",B.ui.CurrentPageReport.sprintf(this.paginator.get("pageReportTemplate"),this.paginator.get("pageReportValueGenerator")(this.paginator)));}};B.ui.FirstPageLink=function(C){this.paginator=C;C.on("destroy",this.destroy,this);C.after("recordOffsetChange",this.update,this);C.after("rowsPerPageChange",this.update,this);C.after("totalRecordsChange",this.update,this);C.after("firstPageLinkLabelChange",this.rebuild,this);C.after("firstPageLinkClassChange",this.rebuild,this);};B.ATTRS.firstPageLinkLabel={value:"<< first",validator:A.Lang.isString};B.ATTRS.firstPageLinkClass={value:A.ClassNameManager.getClassName(B.NAME,"first"),validator:A.Lang.isString};B.ui.FirstPageLink.prototype={current:null,link:null,span:null,destroy:function(){this.link.remove(true);this.span.remove(true);this.current=this.link=this.span=null;},render:function(D){var E=this.paginator,F=E.get("firstPageLinkClass"),C=E.get("firstPageLinkLabel");this.link=A.Node.create(''+C+"");this.link.set("className",F);this.link.on("click",this.onClick,this);this.span=A.Node.create(''+C+"");this.span.set("className",F);this.current=E.getCurrentPage()>1?this.link:this.span;return this.current;},update:function(D){if(D&&D.prevVal===D.newVal){return;}var C=this.current?this.current.get("parentNode"):null;if(this.paginator.getCurrentPage()>1){if(C&&this.current===this.span){C.replaceChild(this.link,this.current);this.current=this.link;}}else{if(C&&this.current===this.link){C.replaceChild(this.span,this.current);this.current=this.span;}}},rebuild:function(E){if(E&&E.prevVal===E.newVal){return;}var D=this.paginator,F=D.get("firstPageLinkClass"),C=D.get("firstPageLinkLabel");this.link.set("className",F); this.link.set("innerHTML",C);this.span.set("className",F);this.span.set("innerHTML",C);},onClick:function(C){C.halt();this.paginator.setPage(1);}};B.ui.ItemRangeDropdown=function(C){this.paginator=C;C.on("destroy",this.destroy,this);C.after("recordOffsetChange",this.update,this);C.after("rowsPerPageChange",this.update,this);C.after("totalRecordsChange",this.update,this);C.after("itemRangeDropdownClassChange",this.update,this);};B.ATTRS.itemRangeDropdownClass={value:A.ClassNameManager.getClassName(B.NAME,"ir-dropdown"),validator:A.Lang.isString};B.ATTRS.itemRangeDropdownTemplate={value:"{currentRange} of {totalItems}",validator:A.Lang.isString};B.ui.ItemRangeDropdown.prototype={destroy:function(){this.span.remove(true);this.span=null;this.menu=null;this.page_count=null;},render:function(C){this.span=A.Node.create(''+A.substitute(this.paginator.get("itemRangeDropdownTemplate"),{currentRange:'',totalItems:''})+"");this.span.set("className",this.paginator.get("itemRangeDropdownClass"));this.menu=this.span.one("select");this.menu.on("change",this._onChange,this);this.page_count=this.span.one("span.yui-item-count");this.update();return this.span;},update:function(H){if(H&&H.prevVal===H.newVal){return;}var G=this.paginator.getCurrentPage();var F=this.paginator.getTotalPages();var D=A.Node.getDOMNode(this.menu).options;D.length=0;for(var E=1;E<=F;E++){var C=this.paginator.getPageRecords(E);D[E-1]=new Option((C[0]+1)+" - "+(C[1]+1),E);if(E==G){this.menu.set("selectedIndex",E-1);}}this.span.set("className",this.paginator.get("itemRangeDropdownClass"));this.page_count.set("innerHTML",this.paginator.getTotalRecords());},_onChange:function(C){this.paginator.setPage(parseInt(this.menu.get("value"),10));}};B.ui.LastPageLink=function(C){this.paginator=C;C.on("destroy",this.destroy,this);C.after("recordOffsetChange",this.update,this);C.after("rowsPerPageChange",this.update,this);C.after("totalRecordsChange",this.update,this);C.after("lastPageLinkClassChange",this.rebuild,this);C.after("lastPageLinkLabelChange",this.rebuild,this);};B.ATTRS.lastPageLinkClass={value:A.ClassNameManager.getClassName(B.NAME,"last"),validator:A.Lang.isString};B.ATTRS.lastPageLinkLabel={value:"last >>",validator:A.Lang.isString};B.ui.LastPageLink.prototype={current:null,link:null,span:null,na:null,destroy:function(){this.link.remove(true);this.span.remove(true);this.na.remove(true);this.current=this.link=this.span=this.na=null;},render:function(D){var F=this.paginator,G=F.get("lastPageLinkClass"),C=F.get("lastPageLinkLabel"),E=F.getTotalPages();this.link=A.Node.create(''+C+"");this.link.set("className",G);this.link.on("click",this.onClick,this);this.span=A.Node.create(''+C+"");this.span.set("className",G);this.na=A.Node.create('');switch(E){case B.VALUE_UNLIMITED:this.current=this.na;break;case F.getCurrentPage():this.current=this.span;break;default:this.current=this.link;}return this.current;},update:function(D){if(D&&D.prevVal===D.newVal){return;}var C=this.current?this.current.get("parentNode"):null,E=this.link;if(C){switch(this.paginator.getTotalPages()){case B.VALUE_UNLIMITED:E=this.na;break;case this.paginator.getCurrentPage():E=this.span;break;}if(this.current!==E){C.replaceChild(E,this.current);this.current=E;}}},rebuild:function(E){if(E&&E.prevVal===E.newVal){return;}var D=this.paginator,F=D.get("lastPageLinkClass"),C=D.get("lastPageLinkLabel");this.link.set("className",F);this.link.set("innerHTML",C);this.span.set("className",F);this.span.set("innerHTML",C);},onClick:function(C){C.halt();this.paginator.setPage(this.paginator.getTotalPages());}};B.ui.NextPageLink=function(C){this.paginator=C;C.on("destroy",this.destroy,this);C.after("recordOffsetChange",this.update,this);C.after("rowsPerPageChange",this.update,this);C.after("totalRecordsChange",this.update,this);C.after("nextPageLinkClassChange",this.rebuild,this);C.after("nextPageLinkLabelChange",this.rebuild,this);};B.ATTRS.nextPageLinkClass={value:A.ClassNameManager.getClassName(B.NAME,"next"),validator:A.Lang.isString};B.ATTRS.nextPageLinkLabel={value:"next >",validator:A.Lang.isString};B.ui.NextPageLink.prototype={current:null,link:null,span:null,destroy:function(){this.link.remove(true);this.span.remove(true);this.current=this.link=this.span=null;},render:function(D){var F=this.paginator,G=F.get("nextPageLinkClass"),C=F.get("nextPageLinkLabel"),E=F.getTotalPages();this.link=A.Node.create(''+C+"");this.link.set("className",G);this.link.on("click",this.onClick,this);this.span=A.Node.create(''+C+"");this.span.set("className",G);this.current=F.getCurrentPage()===E?this.span:this.link;return this.current;},update:function(E){if(E&&E.prevVal===E.newVal){return;}var D=this.paginator.getTotalPages(),C=this.current?this.current.get("parentNode"):null;if(this.paginator.getCurrentPage()!==D){if(C&&this.current===this.span){C.replaceChild(this.link,this.current);this.current=this.link;}}else{if(this.current===this.link){if(C){C.replaceChild(this.span,this.current);this.current=this.span;}}}},rebuild:function(E){if(E&&E.prevVal===E.newVal){return;}var D=this.paginator,F=D.get("nextPageLinkClass"),C=D.get("nextPageLinkLabel");this.link.set("className",F);this.link.set("innerHTML",C);this.span.set("className",F);this.span.set("innerHTML",C);},onClick:function(C){C.halt();this.paginator.setPage(this.paginator.getNextPage());}};B.ui.PageLinks=function(C){this.paginator=C;C.on("destroy",this.destroy,this);C.after("recordOffsetChange",this.update,this);C.after("rowsPerPageChange",this.update,this);C.after("totalRecordsChange",this.update,this);C.after("pageLinksContainerClassChange",this.rebuild,this);C.after("pageLinkClassChange",this.rebuild,this);C.after("currentPageClassChange",this.rebuild,this); -C.after("pageLinksChange",this.rebuild,this);};B.ATTRS.pageLinksContainerClass={value:A.ClassNameManager.getClassName(B.NAME,"pages"),validator:A.Lang.isString};B.ATTRS.pageLinkClass={value:A.ClassNameManager.getClassName(B.NAME,"page"),validator:A.Lang.isString};B.ATTRS.currentPageClass={value:A.ClassNameManager.getClassName(B.NAME,"current-page"),validator:A.Lang.isString};B.ATTRS.pageLinks={value:10,validator:B.isNumeric};B.ATTRS.pageLabelBuilder={value:function(C,D){return C;},validator:A.Lang.isFunction};B.ui.PageLinks.calculateRange=function(E,F,D){var I=B.VALUE_UNLIMITED,H,C,G;if(!E||D===0||F===0||(F===I&&D===I)){return[0,-1];}if(F!==I){D=D===I?F:Math.min(D,F);}H=Math.max(1,Math.ceil(E-(D/2)));if(F===I){C=H+D-1;}else{C=Math.min(F,H+D-1);}G=D-(C-H+1);H=Math.max(1,H-G);return[H,C];};B.ui.PageLinks.prototype={current:0,container:null,destroy:function(){this.container.remove(true);this.container=null;},render:function(C){this.container=A.Node.create('');this.container.on("click",this.onClick,this);this.update({newVal:null,rebuild:true});return this.container;},update:function(J){if(J&&J.prevVal===J.newVal){return;}var E=this.paginator,I=E.getCurrentPage();if(this.current!==I||!I||J.rebuild){var L=E.get("pageLabelBuilder"),H=B.ui.PageLinks.calculateRange(I,E.getTotalPages(),E.get("pageLinks")),D=H[0],F=H[1],K="",C,G;C=''+L(G,E)+"";}else{K+=C+G+'">'+L(G,E)+"";}}this.container.set("className",E.get("pageLinksContainerClass"));this.container.set("innerHTML",K);}},rebuild:function(C){C.rebuild=true;this.update(C);},onClick:function(D){var C=D.target;if(C&&C.hasClass(this.paginator.get("pageLinkClass"))){D.halt();this.paginator.setPage(parseInt(C.getAttribute("page"),10));}}};B.ui.PreviousPageLink=function(C){this.paginator=C;C.on("destroy",this.destroy,this);C.after("recordOffsetChange",this.update,this);C.after("rowsPerPageChange",this.update,this);C.after("totalRecordsChange",this.update,this);C.after("previousPageLinkLabelChange",this.update,this);C.after("previousPageLinkClassChange",this.update,this);};B.ATTRS.previousPageLinkClass={value:A.ClassNameManager.getClassName(B.NAME,"previous"),validator:A.Lang.isString};B.ATTRS.previousPageLinkLabel={value:"< prev",validator:A.Lang.isString};B.ui.PreviousPageLink.prototype={current:null,link:null,span:null,destroy:function(){this.link.remove(true);this.span.remove(true);this.current=this.link=this.span=null;},render:function(D){var E=this.paginator,F=E.get("previousPageLinkClass"),C=E.get("previousPageLinkLabel");this.link=A.Node.create(''+C+"");this.link.set("className",F);this.link.on("click",this.onClick,this);this.span=A.Node.create(''+C+"");this.span.set("className",F);this.current=E.getCurrentPage()>1?this.link:this.span;return this.current;},update:function(D){if(D&&D.prevVal===D.newVal){return;}var C=this.current?this.current.get("parentNode"):null;if(this.paginator.getCurrentPage()>1){if(C&&this.current===this.span){C.replaceChild(this.link,this.current);this.current=this.link;}}else{if(C&&this.current===this.link){C.replaceChild(this.span,this.current);this.current=this.span;}}},onClick:function(C){C.halt();this.paginator.setPage(this.paginator.getPreviousPage());}};B.ui.RowsPerPageDropdown=function(C){this.paginator=C;C.on("destroy",this.destroy,this);C.after("rowsPerPageChange",this.update,this);C.after("totalRecordsChange",this._handleTotalRecordsChange,this);C.after("rowsPerPageDropdownClassChange",this.rebuild,this);C.after("rowsPerPageDropdownTitleChange",this.rebuild,this);C.after("rowsPerPageOptionsChange",this.rebuild,this);};B.ATTRS.rowsPerPageDropdownClass={value:A.ClassNameManager.getClassName(B.NAME,"rpp-options"),validator:A.Lang.isString};B.ATTRS.rowsPerPageDropdownTitle={value:"Rows per page",validator:A.Lang.isString};B.ATTRS.rowsPerPageOptions={value:[],validator:A.Lang.isArray};B.ui.RowsPerPageDropdown.prototype={select:null,all:null,destroy:function(){this.select.remove(true);this.all=this.select=null;},render:function(C){this.select=A.Node.create('');this.select.on("change",this.onChange,this);this.rebuild();return this.select;},rebuild:function(K){var D=this.paginator,F=this.select,L=D.get("rowsPerPageOptions"),C=A.Node.getDOMNode(F).options,E,J,G,H,I;this.all=null;F.set("className",this.paginator.get("rowsPerPageDropdownClass"));F.set("title",this.paginator.get("rowsPerPageDropdownTitle"));for(H=0,I=L.length;H"));G=A.Lang.isValue(J.value)?J.value:J;E.set("innerHTML",A.Lang.isValue(J.text)?J.text:J);if(A.Lang.isString(G)&&G.toLowerCase()==="all"){this.all=E;E.set("value",D.get("totalRecords"));}else{E.set("value",G);}}while(C.length>L.length){F.get("lastChild").remove();}this.update();},update:function(G){if(G&&G.prevVal===G.newVal){return;}var F=this.paginator.get("rowsPerPage")+"",D=A.Node.getDOMNode(this.select).options,E,C;for(E=0,C=D.length;E');this.container.on("click",this.onClick,this);this.update({newVal:null,rebuild:true});return this.container;},update:function(J){if(J&&J.prevVal===J.newVal){return;}var E=this.paginator,I=E.getCurrentPage();if(this.current!==I||!I||J.rebuild){var L=E.get("pageLabelBuilder"),H=B.ui.PageLinks.calculateRange(I,E.getTotalPages(),E.get("pageLinks")),D=H[0],F=H[1],K="",C,G;C=''+L(G,E)+"";}else{K+=C+G+'">'+L(G,E)+"";}}this.container.set("className",E.get("pageLinksContainerClass"));this.container.set("innerHTML",K);}},rebuild:function(C){C.rebuild=true;this.update(C);},onClick:function(D){var C=D.target;if(C&&C.hasClass(this.paginator.get("pageLinkClass"))){D.halt();this.paginator.setPage(parseInt(C.getAttribute("page"),10));}}};B.ui.PreviousPageLink=function(C){this.paginator=C;C.on("destroy",this.destroy,this);C.after("recordOffsetChange",this.update,this);C.after("rowsPerPageChange",this.update,this);C.after("totalRecordsChange",this.update,this);C.after("previousPageLinkLabelChange",this.update,this);C.after("previousPageLinkClassChange",this.update,this);};B.ATTRS.previousPageLinkClass={value:A.ClassNameManager.getClassName(B.NAME,"previous"),validator:A.Lang.isString};B.ATTRS.previousPageLinkLabel={value:"< prev",validator:A.Lang.isString};B.ui.PreviousPageLink.prototype={current:null,link:null,span:null,destroy:function(){this.link.remove(true);this.span.remove(true);this.current=this.link=this.span=null;},render:function(D){var E=this.paginator,F=E.get("previousPageLinkClass"),C=E.get("previousPageLinkLabel");this.link=A.Node.create(''+C+"");this.link.set("className",F);this.link.on("click",this.onClick,this);this.span=A.Node.create(''+C+"");this.span.set("className",F);this.current=E.getCurrentPage()>1?this.link:this.span;return this.current;},update:function(D){if(D&&D.prevVal===D.newVal){return;}var C=this.current?this.current.get("parentNode"):null;if(this.paginator.getCurrentPage()>1){if(C&&this.current===this.span){C.replaceChild(this.link,this.current);this.current=this.link;}}else{if(C&&this.current===this.link){C.replaceChild(this.span,this.current);this.current=this.span;}}},onClick:function(C){C.halt();this.paginator.setPage(this.paginator.getPreviousPage());}};B.ui.RowsPerPageDropdown=function(C){this.paginator=C;C.on("destroy",this.destroy,this);C.after("rowsPerPageChange",this.update,this);C.after("totalRecordsChange",this._handleTotalRecordsChange,this);C.after("rowsPerPageDropdownClassChange",this.rebuild,this);C.after("rowsPerPageDropdownTitleChange",this.rebuild,this);C.after("rowsPerPageOptionsChange",this.rebuild,this);};B.ATTRS.rowsPerPageDropdownClass={value:A.ClassNameManager.getClassName(B.NAME,"rpp-options"),validator:A.Lang.isString};B.ATTRS.rowsPerPageDropdownTitle={value:"Rows per page",validator:A.Lang.isString};B.ATTRS.rowsPerPageOptions={value:[],validator:A.Lang.isArray};B.ui.RowsPerPageDropdown.prototype={select:null,all:null,destroy:function(){this.select.remove(true);this.all=this.select=null;},render:function(C){this.select=A.Node.create('');this.select.on("change",this.onChange,this);this.rebuild();return this.select;},rebuild:function(K){var D=this.paginator,F=this.select,L=D.get("rowsPerPageOptions"),C=A.Node.getDOMNode(F).options,E,J,G,H,I;this.all=null;F.set("className",this.paginator.get("rowsPerPageDropdownClass"));F.set("title",this.paginator.get("rowsPerPageDropdownTitle"));for(H=0,I=L.length;H"));G=A.Lang.isValue(J.value)?J.value:J;E.set("innerHTML",A.Lang.isValue(J.text)?J.text:J);if(A.Lang.isString(G)&&G.toLowerCase()==="all"){this.all=E;E.set("value",D.get("totalRecords"));}else{E.set("value",G);}}while(C.length>L.length){F.get("lastChild").remove();}this.update();},update:function(G){if(G&&G.prevVal===G.newVal){return;}var F=this.paginator.get("rowsPerPage")+"",D=A.Node.getDOMNode(this.select).options,E,C;for(E=0,C=D.length;E 0 ){ calcdW = this._snapTick( dw , this.get( "xTicks" ) ); @@ -652,6 +670,8 @@ YUI.add('gallery-resize', function(Y) { if ( ch.hasClass( "yui3-resize-handle-r" ) ) { calcdW = dw; + t = orig.t; + l = orig.l; } @@ -659,19 +679,22 @@ YUI.add('gallery-resize', function(Y) { calcdW = -dw; calcdL = dw; + t = orig.t; } else if( ch.hasClass( "yui3-resize-handle-t" ) ) { calcdH = -dh; calcdT = dh; + l = orig.l; } else if ( ch.hasClass( "yui3-resize-handle-b" ) ) { calcdH = dh; - + l = orig.l; + t = orig.t; } else if( ch.hasClass( "yui3-resize-handle-tl" ) ) { @@ -687,6 +710,7 @@ YUI.add('gallery-resize', function(Y) { calcdW = dw; calcdH = -dh; calcdT = dh; + l = orig.l; } @@ -694,26 +718,39 @@ YUI.add('gallery-resize', function(Y) { calcdW = -dw; calcdH = dh; - calcdL = dw; + calcdL = dw; + t = orig.t; } else if( ch.hasClass( "yui3-resize-handle-br" ) ) { calcdW = dw; - calcdH = dh; + calcdH = dh; + t = orig.t; calcdT = 0; + l = orig.l; calcdL = 0; } - + + + + finalCoords = this._constrainResize( { w: w + calcdW, h: h + calcdH, t: t + calcdT, l: l + calcdL } ); + + + this._setPosition( finalCoords , this._resizeNode ); this._updateStatus( ev, { w: w + calcdW, h: h + calcdH, dw: dw, dh: dh } ); // update any child elements we're wrapping - this._resizeChildren( { ratioW: calcdW/w, ratioH: calcdH/h, dl: calcdL, dt: calcdT } ); + this._resizeChildren( Y.mix( { ratioW: calcdW/w, + ratioH: calcdH/h, + dl: calcdL, + dt: calcdT }, + finalCoords) ); @@ -728,10 +765,20 @@ YUI.add('gallery-resize', function(Y) { * Resize children by same amount */ _resizeChildren: function( oChange ){ - + if( this._wrappedEls === false ){ return; } + + // single element wrapper: set to same size as wrapper + if( this._wrappedEls.length == 1 ){ + this._setPosition( {w: oChange.w, + h: oChange.h, + t: oChange.t, + l: oChange.l }, + this._wrappedEls[ 0 ] ); + return; + } // private function does the hard work: var doResize = function( el ){ @@ -797,11 +844,12 @@ YUI.add('gallery-resize', function(Y) { if( node === undefined ){ node = this.get( "host" ); } - - return { w: parseInt( node.getStyle( "width" ), 10 ), + + + return { w : parseInt( node.getStyle( "width" ), 10 ), h : parseInt( node.getStyle( "height" ) , 10 ), - t : parseInt( node.getStyle( "top" ) , 10 ), - l : parseInt( node.getStyle( "left" ) , 10 ) }; + t : parseInt( node.getY() , 10 ), + l : parseInt( node.getX() , 10 ) }; }, @@ -815,7 +863,7 @@ YUI.add('gallery-resize', function(Y) { if( node === undefined ) { node = this.get( "host" ); } - + node.setStyle( "width" , parseInt( oPos.w, 10 ) + "px" ); node.setStyle( "height" , parseInt( oPos.h, 10 ) + "px" ); node.setStyle( "top" , parseInt( oPos.t, 10 ) + "px" ); @@ -1101,4 +1149,5 @@ YUI.add('gallery-resize', function(Y) { -}, 'gallery-2010.03.23-17-54' ,{requires:['attribute','node','plugin','dd-plugin','dd-proxy','anim','event-mouseenter']}); + +}, 'gallery-2010.04.02-17-26' ,{requires:['attribute','node','plugin','dd-plugin','dd-proxy','anim','event-mouseenter']}); diff --git a/build/gallery-resize/gallery-resize-min.js b/build/gallery-resize/gallery-resize-min.js index 01d26f167a..7c61e77cb3 100644 --- a/build/gallery-resize/gallery-resize-min.js +++ b/build/gallery-resize/gallery-resize-min.js @@ -1,2 +1,2 @@ -YUI.add("gallery-resize",function(B){var A=function(C){A.superclass.constructor.apply(this,arguments);};A.NAME="resizePlugin";A.NS="resize";A.ATTRS={animate:{value:false,validator:function(C){return B.Lang.isNumber(C);}},animateDuration:{value:0.25},animateEasing:{value:(B.Easing===undefined?null:B.Easing.easeNone)},autoRatio:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},draggable:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},ghost:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},handles:{value:["r","br","b"],setter:function(C){if(B.Lang.isString(C)&&C.toLowerCase()=="all"){return["t","b","r","l","bl","br","tl","tr"];}}},height:{lazyAdd:false,setter:function(C){this.get("host").setStyle("height",C+"px");return C;},validator:function(C){return B.Lang.isNumber(C);}},hiddenHandles:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},hover:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},knobHandles:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},maxHeight:{validator:function(C){return B.Lang.isNumber(C);}},maxWidth:{validator:function(C){return B.Lang.isNumber(C);}},maxX:{validator:function(C){return B.Lang.isNumber(C);}},maxY:{validator:function(C){return B.Lang.isNumber(C);}},minHeight:{validator:function(C){return B.Lang.isNumber(C);}},minWidth:{validator:function(C){return B.Lang.isNumber(C);}},minX:{validator:function(C){return B.Lang.isNumber(C);}},minY:{validator:function(C){return B.Lang.isNumber(C);}},proxy:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},ratio:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},setSize:{},status:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},useShim:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},width:{lazyAdd:false,setter:function(C){this.get("host").setStyle("width",C+"px");return C;},validator:function(C){return B.Lang.isNumber(C);}},wrappedEls:{value:false,lazyAdd:false,validator:function(C){return B.Lang.isString(C);},setter:function(C){if(C){this._wrappedEls=B.Array(B.all("#"+this.get("host").get("id")+" "+C));}}},hugWrappedEl:{value:false,lazyAdd:false,setter:function(F){if(this._wrappedEls!==undefined&&this._wrappedEls.length==1&&F===true){var G=this._wrappedEls[0],D=this.get("host"),C=parseInt(G.getComputedStyle("height")||G.getAttribute("height"),10),E=parseInt(G.getComputedStyle("width")||G.getAttribute("width"),10);if(G.getStyle("position")=="absolute"){D.setXY(G.getXY());}if(B.UA.ie){C+=8;E+=5;}D.setStyle("width",E+"px");D.setStyle("height",C+"px");}}},xTicks:{validator:function(C){return B.Lang.isNumber(C);}},yTicks:{validator:function(C){return B.Lang.isNumber(C);}}};B.extend(A,B.Plugin.Base,{_currentHandle:false,_locked:false,_ratioValue:null,_resizeNode:null,_originalPosition:{},_statusNode:false,_wrappedEls:[],initializer:function(C){switch(this.get("host").get("nodeName").toLowerCase()){case"textarea":case"img":case"input":case"iframe":case"select":return false;}this._renderHandles();this._renderStatus();this._addDD();},_renderHandles:function(){var F=this.get("host"),D=F.getAttribute("id"),E=this.get("hover"),C,H,G;G=function(I){return B.Node.create("
").addClass("yui3-resize-handle").addClass("yui3-resize-handle-"+I).append(B.Node.create("
").addClass("yui3-resize-handle-inner-"+I));};B.each(this.get("handles"),function(J,I){F.append(G(J,I));});C=function(){B.each(this.getAttribute("class").split(" "),function(I,J){this.addClass(I+"-active");},this);if(E){F.removeClass("yui3-resize-hover");}};H=function(){B.each(this.getAttribute("class").split(" "),function(I,J){if(I.slice(-7)=="-active"){this.removeClass(I);}},this);if(E){F.addClass("yui3-resize-hover");}};B.on("mouseenter",C,"#"+D+" .yui3-resize-handle");B.on("mouseleave",H,"#"+D+" .yui3-resize-handle");F.addClass("yui3-resize");if(this.get("hiddenHandles")){F.addClass("yui3-resize-hidden");}if(E){F.addClass("yui3-resize-hover");}if(this.get("knobHandles")){F.addClass("yui3-resize-knob");}},_renderStatus:function(){if(this.get("status")){this._statusNode=B.Node.create('');B.Node.one("body").prepend(this._statusNode);}},_addDD:function(){var C=this.get("host");C.plug(B.Plugin.Drag,{useShim:this.get("useShim")});if(this.get("proxy")){C.dd.plug(B.Plugin.DDProxy,{moveOnEnd:true});this._resizeNode=B.DD.DDM._proxy;}else{this._resizeNode=C;}C.dd.addHandle(".yui3-resize-handle");C.dd.on("drag:start",this._startResize,this);C.dd.on("drag:drag",this._resize,this);C.dd.on("drag:end",this._endResize,this);if(this.get("draggable")){C.dd.addHandle(C);}},_startResize:function(E){var D=this.get("host"),C=D.dd.get("activeHandle");if(C===undefined||!C.hasClass("yui3-resize-handle")){if(this.get("draggable")){D.dd.set("move",true);}return;}this._currentHandle=C;if(this.get("ratio")||(this.get("autoRatio")&&E.currentTarget._ev_md.shiftKey)){this._ratioValue=parseInt(D.getComputedStyle("height"),10)/parseInt(D.getComputedStyle("width"),10);}if(this.get("ghost")){D.addClass("yui3-resize-ghost");}this._originalPosition=this._getPosition(this._resizeNode);this._startChildResize();this._showStatus();},_startChildResize:function(){},_resize:function(L){if(this._locked===true||this._currentHandle===false){return;}var M=this._getPosition(this._resizeNode),N=this._originalPosition,O=M.w,I=M.h,Q=M.t,G=M.l,E=L.info.delta[0],J=L.info.delta[1],K=0,H=0,P=0,F=0,D=this._currentHandle,C;if(this.get("xTicks")&&this.get("xTicks")>0){K=this._snapTick(E,this.get("xTicks"));}if(this.get("yTicks")&&this.get("yTicks")>0){H=this._snapTick(J,this.get("yTicks"));}if(D.hasClass("yui3-resize-handle-r")){K=E;Q=N.t;G=N.l;}else{if(D.hasClass("yui3-resize-handle-l")){K=-E;F=E;Q=N.t;}else{if(D.hasClass("yui3-resize-handle-t")){H=-J;P=J;G=N.l;}else{if(D.hasClass("yui3-resize-handle-b")){H=J;G=N.l;Q=N.t;}else{if(D.hasClass("yui3-resize-handle-tl")){K=-E;F=E;H=-J;P=J;}else{if(D.hasClass("yui3-resize-handle-tr")){K=E; -H=-J;P=J;G=N.l;}else{if(D.hasClass("yui3-resize-handle-bl")){K=-E;H=J;F=E;Q=N.t;}else{if(D.hasClass("yui3-resize-handle-br")){K=E;H=J;Q=N.t;P=0;G=N.l;F=0;}}}}}}}}C=this._constrainResize({w:O+K,h:I+H,t:Q+P,l:G+F});this._setPosition(C,this._resizeNode);this._updateStatus(L,{w:O+K,h:I+H,dw:E,dh:J});this._resizeChildren(B.mix({ratioW:K/O,ratioH:H/I,dl:F,dt:P},C));L.halt(true);},_resizeChildren:function(C){if(this._wrappedEls===false){return;}if(this._wrappedEls.length==1){this._setPosition({w:C.w,h:C.h,t:C.t,l:C.l},this._wrappedEls[0]);return;}var D=function(F){var E=this._getPosition(F);this._setPosition({w:E.w*(1+C.ratioW),h:E.h*(1+C.ratioH),t:E.t+C.dt,l:E.l+C.dl},F);};B.each(this._wrappedEls,D,this);},_endResize:function(C){if(this.get("draggable")&&this._currentHandle!==false){this.get("host").dd.set("move",false);}if(this.get("proxy")&&this._currentHandle!==false){if(this.get("animate")){this._animPosition(this._getPosition(this._resizeNode));}else{this._setPosition(this._getPosition(this._resizeNode));}}this._currentHandle=false;this._ratioValue=null;if(this.get("ghost")){this.get("host").removeClass("yui3-resize-ghost");}this._hideStatus();},_getPosition:function(C){if(C===undefined){C=this.get("host");}return{w:parseInt(C.getStyle("width"),10),h:parseInt(C.getStyle("height"),10),t:parseInt(C.getY(),10),l:parseInt(C.getX(),10)};},_setPosition:function(C,D){if(D===undefined){D=this.get("host");}D.setStyle("width",parseInt(C.w,10)+"px");D.setStyle("height",parseInt(C.h,10)+"px");D.setStyle("top",parseInt(C.t,10)+"px");D.setStyle("left",parseInt(C.l,10)+"px");},_animPosition:function(D,E){if(B.Anim===undefined){return this._setPosition(D,E);}this._setPosition(this._originalPosition,this.get("host"));if(E===undefined){E=this.get("host");}var C=new B.Anim({node:E,from:this._originalPosition,to:{width:D.w,height:D.h,left:D.l,top:D.t},easing:this.get("animEasing"),duration:this.get("animDuration")});C.run();},_showStatus:function(){if(!this.get("status")){return;}this._statusNode.setStyle("display","inline");},_updateStatus:function(C,E){if(!this.get("status")){return;}var D=this._statusNode;D.setContent(""+E.w+" x "+E.h+""+(E.w-this._originalPosition.w)+" x "+(E.h-this._originalPosition.h)+"");D.setXY([C.target.mouseXY[0]+12,C.target.mouseXY[1]+12]);},_hideStatus:function(){if(!this.get("status")){return;}this._statusNode.setContent("");this._statusNode.setStyle("display","none");},_constrainResize:function(E){var G=E.w,D=E.h,C=E.t,F=E.l;if(this.get("minX")&&Fthis.get("maxX")){F=this.get("maxX");}if(this.get("maxY")&&C>this.get("maxY")){C=this.get("maxY");}if(this.get("minHeight")&&Dthis.get("maxHeight")){D=this.get("maxHeight");}if(this.get("maxWidth")&&G>this.get("maxWidth")){G=this.get("maxWidth");}if((this.get("ratio")===true||this.get("autoRatio"))&&(this._ratioValue>0)){D=G*this._ratioValue;}return{w:G,h:D,t:C,l:F};},_snapTick:function(E,D){if(!E||!D){return E;}var F=E,C=Math.abs(E%D);if(Math.abs(C)>(D/2)){F=E+(D-C);}else{F=E-C;}return F;},destructor:function(){this.get("host").dd.destroy();this.get("host").unplug("dd");this.detachAll();B.all("#"+this.get("host").get("id")+" .yui3-resize-handle").each(function(C){C.remove();});if(this._statusNode!==false){this._statusNode.remove();}this.get("host").removeClass("yui3-resize").removeClass("yui3-resize-hover").removeClass("yui3-resize-knob").removeClass("yui3-resize-hidden");},getActiveHandleEl:function(){return this._currentHandle;},getProxyEl:function(){if(this.get("proxy")){return B.DD.DDM._proxy;}return false;},getStatusEl:function(){return this._statusNode;},getWrapEl:function(){return false;},isActive:function(){return this._currentHandle===false?false:true;},isLocked:function(){return this._locked;},lock:function(){this._locked=true;if(this.get("host").dd){this.get("host").dd.lock();}},unlock:function(){this._locked=false;if(this.get("host").dd){this.get("host").dd.unlock();}},reset:function(){},toString:function(){return"Resize plugin "+this.get("host").getAttribute("id");}});B.Plugin.Resize=A;},"gallery-2010.03.29-18-07",{requires:["attribute","node","plugin","dd-plugin","dd-proxy","anim","event-mouseenter"]}); \ No newline at end of file +YUI.add("gallery-resize",function(B){var A=function(C){A.superclass.constructor.apply(this,arguments);};A.NAME="resizePlugin";A.NS="resize";A.ATTRS={animate:{value:false,validator:function(C){return B.Lang.isNumber(C);}},animateDuration:{value:0.25},animateEasing:{value:(B.Easing===undefined?null:B.Easing.easeNone)},autoRatio:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},draggable:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},ghost:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},handles:{value:["r","br","b"],setter:function(C){if(B.Lang.isString(C)&&C.toLowerCase()=="all"){return["t","b","r","l","bl","br","tl","tr"];}}},height:{lazyAdd:false,setter:function(C){this.get("host").setStyle("height",C+"px");return C;},validator:function(C){return B.Lang.isNumber(C);}},hiddenHandles:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},hover:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},knobHandles:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},maxHeight:{validator:function(C){return B.Lang.isNumber(C);}},maxWidth:{validator:function(C){return B.Lang.isNumber(C);}},maxX:{validator:function(C){return B.Lang.isNumber(C);}},maxY:{validator:function(C){return B.Lang.isNumber(C);}},minHeight:{validator:function(C){return B.Lang.isNumber(C);}},minWidth:{validator:function(C){return B.Lang.isNumber(C);}},minX:{validator:function(C){return B.Lang.isNumber(C);}},minY:{validator:function(C){return B.Lang.isNumber(C);}},proxy:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},ratio:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},setSize:{},status:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},useShim:{value:false,validator:function(C){return B.Lang.isBoolean(C);}},width:{lazyAdd:false,setter:function(C){this.get("host").setStyle("width",C+"px");return C;},validator:function(C){return B.Lang.isNumber(C);}},wrappedEls:{value:false,lazyAdd:false,validator:function(C){return B.Lang.isString(C);},setter:function(C){if(C){this._wrappedEls=B.Array(B.all("#"+this.get("host").get("id")+" "+C));}}},hugWrappedEl:{value:false,lazyAdd:false,setter:function(F){if(this._wrappedEls!==undefined&&this._wrappedEls.length==1&&F===true){var G=this._wrappedEls[0],D=this.get("host"),C=parseInt(G.getComputedStyle("height")||G.getAttribute("height"),10),E=parseInt(G.getComputedStyle("width")||G.getAttribute("width"),10);if(G.getStyle("position")=="absolute"){D.setXY(G.getXY());}if(B.UA.ie){C+=8;E+=5;}D.setStyle("width",E+"px");D.setStyle("height",C+"px");}}},xTicks:{validator:function(C){return B.Lang.isNumber(C);}},yTicks:{validator:function(C){return B.Lang.isNumber(C);}}};B.extend(A,B.Plugin.Base,{_currentHandle:false,_locked:false,_ratioValue:null,_resizeNode:null,_originalPosition:{},_statusNode:false,_wrappedEls:[],initializer:function(C){switch(this.get("host").get("nodeName").toLowerCase()){case"textarea":case"img":case"input":case"iframe":case"select":return false;}this._renderHandles();this._renderStatus();this._addDD();},_renderHandles:function(){var F=this.get("host"),D=F.getAttribute("id"),E=this.get("hover"),C,H,G;G=function(I){return B.Node.create("
").addClass("yui3-resize-handle").addClass("yui3-resize-handle-"+I).append(B.Node.create("
").addClass("yui3-resize-handle-inner-"+I));};B.each(this.get("handles"),function(J,I){F.append(G(J,I));});C=function(){B.each(this.getAttribute("class").split(" "),function(I,J){this.addClass(I+"-active");},this);if(E){F.removeClass("yui3-resize-hover");}};H=function(){B.each(this.getAttribute("class").split(" "),function(I,J){if(I.slice(-7)=="-active"){this.removeClass(I);}},this);if(E){F.addClass("yui3-resize-hover");}};B.on("mouseenter",C,"#"+D+" .yui3-resize-handle");B.on("mouseleave",H,"#"+D+" .yui3-resize-handle");F.addClass("yui3-resize");if(this.get("hiddenHandles")){F.addClass("yui3-resize-hidden");}if(E){F.addClass("yui3-resize-hover");}if(this.get("knobHandles")){F.addClass("yui3-resize-knob");}},_renderStatus:function(){if(this.get("status")){this._statusNode=B.Node.create('');B.Node.one("body").prepend(this._statusNode);}},_addDD:function(){var C=this.get("host");C.plug(B.Plugin.Drag,{useShim:this.get("useShim")});if(this.get("proxy")){C.dd.plug(B.Plugin.DDProxy,{moveOnEnd:true});this._resizeNode=B.DD.DDM._proxy;}else{this._resizeNode=C;}C.dd.addHandle(".yui3-resize-handle");C.dd.on("drag:start",this._startResize,this);C.dd.on("drag:drag",this._resize,this);C.dd.on("drag:end",this._endResize,this);if(this.get("draggable")){C.dd.addHandle(C);}},_startResize:function(E){var D=this.get("host"),C=D.dd.get("activeHandle");if(C===undefined||!C.hasClass("yui3-resize-handle")){if(this.get("draggable")){D.dd.set("move",true);}return;}this._currentHandle=C;if(this.get("ratio")||(this.get("autoRatio")&&E.currentTarget._ev_md.shiftKey)){this._ratioValue=parseInt(D.getComputedStyle("height"),10)/parseInt(D.getComputedStyle("width"),10);}if(this.get("ghost")){D.addClass("yui3-resize-ghost");}this._originalPosition=this._getPosition(this._resizeNode);this._startChildResize();this._showStatus();},_startChildResize:function(){},_resize:function(L){if(this._locked===true||this._currentHandle===false){return;}var M=this._getPosition(this._resizeNode),N=this._originalPosition,O=M.w,I=M.h,Q=M.t,G=M.l,E=L.info.delta[0],J=L.info.delta[1],K=0,H=0,P=0,F=0,D=this._currentHandle,C;if(this._resizeNode.getStyle("position")!=="absolute"){N.t=0;Q=0;N.l=0;G=0;}if(this.get("xTicks")&&this.get("xTicks")>0){K=this._snapTick(E,this.get("xTicks"));}if(this.get("yTicks")&&this.get("yTicks")>0){H=this._snapTick(J,this.get("yTicks"));}if(D.hasClass("yui3-resize-handle-r")){K=E;Q=N.t;G=N.l;}else{if(D.hasClass("yui3-resize-handle-l")){K=-E;F=E;Q=N.t;}else{if(D.hasClass("yui3-resize-handle-t")){H=-J;P=J;G=N.l;}else{if(D.hasClass("yui3-resize-handle-b")){H=J;G=N.l;Q=N.t;}else{if(D.hasClass("yui3-resize-handle-tl")){K=-E; +F=E;H=-J;P=J;}else{if(D.hasClass("yui3-resize-handle-tr")){K=E;H=-J;P=J;G=N.l;}else{if(D.hasClass("yui3-resize-handle-bl")){K=-E;H=J;F=E;Q=N.t;}else{if(D.hasClass("yui3-resize-handle-br")){K=E;H=J;Q=N.t;P=0;G=N.l;F=0;}}}}}}}}C=this._constrainResize({w:O+K,h:I+H,t:Q+P,l:G+F});this._setPosition(C,this._resizeNode);this._updateStatus(L,{w:O+K,h:I+H,dw:E,dh:J});this._resizeChildren(B.mix({ratioW:K/O,ratioH:H/I,dl:F,dt:P},C));L.halt(true);},_resizeChildren:function(C){if(this._wrappedEls===false){return;}if(this._wrappedEls.length==1){this._setPosition({w:C.w,h:C.h,t:C.t,l:C.l},this._wrappedEls[0]);return;}var D=function(F){var E=this._getPosition(F);this._setPosition({w:E.w*(1+C.ratioW),h:E.h*(1+C.ratioH),t:E.t+C.dt,l:E.l+C.dl},F);};B.each(this._wrappedEls,D,this);},_endResize:function(C){if(this.get("draggable")&&this._currentHandle!==false){this.get("host").dd.set("move",false);}if(this.get("proxy")&&this._currentHandle!==false){if(this.get("animate")){this._animPosition(this._getPosition(this._resizeNode));}else{this._setPosition(this._getPosition(this._resizeNode));}}this._currentHandle=false;this._ratioValue=null;if(this.get("ghost")){this.get("host").removeClass("yui3-resize-ghost");}this._hideStatus();},_getPosition:function(C){if(C===undefined){C=this.get("host");}return{w:parseInt(C.getStyle("width"),10),h:parseInt(C.getStyle("height"),10),t:parseInt(C.getY(),10),l:parseInt(C.getX(),10)};},_setPosition:function(C,D){if(D===undefined){D=this.get("host");}D.setStyle("width",parseInt(C.w,10)+"px");D.setStyle("height",parseInt(C.h,10)+"px");D.setStyle("top",parseInt(C.t,10)+"px");D.setStyle("left",parseInt(C.l,10)+"px");},_animPosition:function(D,E){if(B.Anim===undefined){return this._setPosition(D,E);}this._setPosition(this._originalPosition,this.get("host"));if(E===undefined){E=this.get("host");}var C=new B.Anim({node:E,from:this._originalPosition,to:{width:D.w,height:D.h,left:D.l,top:D.t},easing:this.get("animEasing"),duration:this.get("animDuration")});C.run();},_showStatus:function(){if(!this.get("status")){return;}this._statusNode.setStyle("display","inline");},_updateStatus:function(C,E){if(!this.get("status")){return;}var D=this._statusNode;D.setContent(""+E.w+" x "+E.h+""+(E.w-this._originalPosition.w)+" x "+(E.h-this._originalPosition.h)+"");D.setXY([C.target.mouseXY[0]+12,C.target.mouseXY[1]+12]);},_hideStatus:function(){if(!this.get("status")){return;}this._statusNode.setContent("");this._statusNode.setStyle("display","none");},_constrainResize:function(E){var G=E.w,D=E.h,C=E.t,F=E.l;if(this.get("minX")&&Fthis.get("maxX")){F=this.get("maxX");}if(this.get("maxY")&&C>this.get("maxY")){C=this.get("maxY");}if(this.get("minHeight")&&Dthis.get("maxHeight")){D=this.get("maxHeight");}if(this.get("maxWidth")&&G>this.get("maxWidth")){G=this.get("maxWidth");}if((this.get("ratio")===true||this.get("autoRatio"))&&(this._ratioValue>0)){D=G*this._ratioValue;}return{w:G,h:D,t:C,l:F};},_snapTick:function(E,D){if(!E||!D){return E;}var F=E,C=Math.abs(E%D);if(Math.abs(C)>(D/2)){F=E+(D-C);}else{F=E-C;}return F;},destructor:function(){this.get("host").dd.destroy();this.get("host").unplug("dd");this.detachAll();B.all("#"+this.get("host").get("id")+" .yui3-resize-handle").each(function(C){C.remove();});if(this._statusNode!==false){this._statusNode.remove();}this.get("host").removeClass("yui3-resize").removeClass("yui3-resize-hover").removeClass("yui3-resize-knob").removeClass("yui3-resize-hidden");},getActiveHandleEl:function(){return this._currentHandle;},getProxyEl:function(){if(this.get("proxy")){return B.DD.DDM._proxy;}return false;},getStatusEl:function(){return this._statusNode;},getWrapEl:function(){return false;},isActive:function(){return this._currentHandle===false?false:true;},isLocked:function(){return this._locked;},lock:function(){this._locked=true;if(this.get("host").dd){this.get("host").dd.lock();}},unlock:function(){this._locked=false;if(this.get("host").dd){this.get("host").dd.unlock();}},reset:function(){},toString:function(){return"Resize plugin "+this.get("host").getAttribute("id");}});B.Plugin.Resize=A;},"gallery-2010.04.02-17-26",{requires:["attribute","node","plugin","dd-plugin","dd-proxy","anim","event-mouseenter"]}); \ No newline at end of file diff --git a/build/gallery-resize/gallery-resize.js b/build/gallery-resize/gallery-resize.js index 75e532f76d..00621eed04 100644 --- a/build/gallery-resize/gallery-resize.js +++ b/build/gallery-resize/gallery-resize.js @@ -1,5 +1,6 @@ YUI.add('gallery-resize', function(Y) { + /** * * Plugin to make elements resizeable. @@ -75,7 +76,7 @@ YUI.add('gallery-resize', function(Y) { animateDuration : { value: 0.25 }, - animateEasing : { value: Y.Easing.easeNone }, + animateEasing : { value: ( Y.Easing === undefined ? null : Y.Easing.easeNone ) }, autoRatio : { value: false , @@ -257,7 +258,9 @@ YUI.add('gallery-resize', function(Y) { }, setter: function( val ) { if( val ){ + this._wrappedEls = Y.Array( Y.all( "#" + this.get("host").get("id") + " " + val ) ); + } } }, @@ -272,13 +275,22 @@ YUI.add('gallery-resize', function(Y) { value: false, lazyAdd: false, setter: function( val ){ - if( this._wrappedEls.length == 1 && val === true ){ - var c = Y.one(this._wrappedEls[0]), h = this.get("host"); + if( this._wrappedEls !== undefined && this._wrappedEls.length == 1 && val === true ){ + var c = this._wrappedEls[0], h = this.get("host"), + hHeight = parseInt( c.getComputedStyle( "height" ) || c.getAttribute( "height" ), 10 ) , + hWidth = parseInt( c.getComputedStyle( "width" ) || c.getAttribute( "width" ) , 10 ); + if( c.getStyle( "position" ) == "absolute" ){ h.setXY( c.getXY() ); } - h.setStyle( "width" , c.getComputedStyle( "width" ) || c.getAttribute( "width" ) + "px" ); - h.setStyle( "height" , c.getComputedStyle( "height" ) || c.getAttribute( "height" ) + "px" ); + + if( Y.UA.ie ){ + hHeight += 8; + hWidth += 5; + } + + h.setStyle( "width" , hWidth + "px" ); + h.setStyle( "height" , hHeight + "px" ); } } }, @@ -579,8 +591,7 @@ YUI.add('gallery-resize', function(Y) { // Are we resizing at set ratio - by config or shift key? - if( this.get( "ratio" ) || - ( this.get("autoRatio") && ev.currentTarget._ev_md.shiftKey ) ) { + if( this.get( "ratio" ) || ( this.get("autoRatio") && ev.currentTarget._ev_md.shiftKey ) ) { this._ratioValue = parseInt( el.getComputedStyle( "height" ) , 10 ) / parseInt( el.getComputedStyle( "width" ) , 10 ); } @@ -588,8 +599,8 @@ YUI.add('gallery-resize', function(Y) { el.addClass( "yui3-resize-ghost" ); } - this._originalPosition = this._getPosition( el ); - + this._originalPosition = this._getPosition( this._resizeNode ); + this._startChildResize(); // show the status panel: @@ -623,6 +634,7 @@ YUI.add('gallery-resize', function(Y) { // get the current location var coords = this._getPosition( this._resizeNode ), + orig = this._originalPosition, w = coords.w, h = coords.h, t = coords.t, @@ -639,6 +651,12 @@ YUI.add('gallery-resize', function(Y) { finalCoords ; + if( this._resizeNode.getStyle("position") !== "absolute" ){ + orig.t = 0; t=0; + orig.l = 0; l=0; + } + + if( this.get( "xTicks" ) && this.get( "xTicks" ) > 0 ){ calcdW = this._snapTick( dw , this.get( "xTicks" ) ); @@ -652,6 +670,8 @@ YUI.add('gallery-resize', function(Y) { if ( ch.hasClass( "yui3-resize-handle-r" ) ) { calcdW = dw; + t = orig.t; + l = orig.l; } @@ -659,19 +679,22 @@ YUI.add('gallery-resize', function(Y) { calcdW = -dw; calcdL = dw; + t = orig.t; } else if( ch.hasClass( "yui3-resize-handle-t" ) ) { calcdH = -dh; calcdT = dh; + l = orig.l; } else if ( ch.hasClass( "yui3-resize-handle-b" ) ) { calcdH = dh; - + l = orig.l; + t = orig.t; } else if( ch.hasClass( "yui3-resize-handle-tl" ) ) { @@ -687,6 +710,7 @@ YUI.add('gallery-resize', function(Y) { calcdW = dw; calcdH = -dh; calcdT = dh; + l = orig.l; } @@ -694,26 +718,39 @@ YUI.add('gallery-resize', function(Y) { calcdW = -dw; calcdH = dh; - calcdL = dw; + calcdL = dw; + t = orig.t; } else if( ch.hasClass( "yui3-resize-handle-br" ) ) { calcdW = dw; - calcdH = dh; + calcdH = dh; + t = orig.t; calcdT = 0; + l = orig.l; calcdL = 0; } - + + + + finalCoords = this._constrainResize( { w: w + calcdW, h: h + calcdH, t: t + calcdT, l: l + calcdL } ); + + + this._setPosition( finalCoords , this._resizeNode ); this._updateStatus( ev, { w: w + calcdW, h: h + calcdH, dw: dw, dh: dh } ); // update any child elements we're wrapping - this._resizeChildren( { ratioW: calcdW/w, ratioH: calcdH/h, dl: calcdL, dt: calcdT } ); + this._resizeChildren( Y.mix( { ratioW: calcdW/w, + ratioH: calcdH/h, + dl: calcdL, + dt: calcdT }, + finalCoords) ); @@ -728,10 +765,20 @@ YUI.add('gallery-resize', function(Y) { * Resize children by same amount */ _resizeChildren: function( oChange ){ - + if( this._wrappedEls === false ){ return; } + + // single element wrapper: set to same size as wrapper + if( this._wrappedEls.length == 1 ){ + this._setPosition( {w: oChange.w, + h: oChange.h, + t: oChange.t, + l: oChange.l }, + this._wrappedEls[ 0 ] ); + return; + } // private function does the hard work: var doResize = function( el ){ @@ -797,11 +844,12 @@ YUI.add('gallery-resize', function(Y) { if( node === undefined ){ node = this.get( "host" ); } - - return { w: parseInt( node.getStyle( "width" ), 10 ), + + + return { w : parseInt( node.getStyle( "width" ), 10 ), h : parseInt( node.getStyle( "height" ) , 10 ), - t : parseInt( node.getStyle( "top" ) , 10 ), - l : parseInt( node.getStyle( "left" ) , 10 ) }; + t : parseInt( node.getY() , 10 ), + l : parseInt( node.getX() , 10 ) }; }, @@ -815,7 +863,7 @@ YUI.add('gallery-resize', function(Y) { if( node === undefined ) { node = this.get( "host" ); } - + node.setStyle( "width" , parseInt( oPos.w, 10 ) + "px" ); node.setStyle( "height" , parseInt( oPos.h, 10 ) + "px" ); node.setStyle( "top" , parseInt( oPos.t, 10 ) + "px" ); @@ -1101,4 +1149,5 @@ YUI.add('gallery-resize', function(Y) { -}, 'gallery-2010.03.23-17-54' ,{requires:['attribute','node','plugin','dd-plugin','dd-proxy','anim','event-mouseenter']}); + +}, 'gallery-2010.04.02-17-26' ,{requires:['attribute','node','plugin','dd-plugin','dd-proxy','anim','event-mouseenter']}); diff --git a/build/gallery-stalker/gallery-stalker-debug.js b/build/gallery-stalker/gallery-stalker-debug.js new file mode 100644 index 0000000000..b5799b0092 --- /dev/null +++ b/build/gallery-stalker/gallery-stalker-debug.js @@ -0,0 +1,163 @@ +YUI.add('gallery-stalker', function(Y) { + +/** +*

Stalker plugin will allow you to keep elements at a fixed position "floating" but at +* the same time, keeping those elements embeded to the layout of the page. The general idea +* is that an element can control it's own position within the layout in order to keep its +* area within the viewport boundaries. +* +*

To use the Stalker Plugin, simply pass a reference to the plugin to a +* Node instance's plug method.

+* +*

+* +* <script type="text/javascript">
+*
+* // Call the "use" method, passing in "gallery-stalker". This will
+* // load the script for the Stalker Plugin and all of
+* // the required dependencies.
+*
+* YUI().use("gallery-stalker", function(Y) {
+*
+* Y.one('#mytarget').plug(Y.Plugin.Stalker);
+*
+* });
+*
+* </script>
+*
+*

+* @module gallery-stalker +*/ + + +// Util shortcuts +var UA = Y.UA, +getClassName = Y.ClassNameManager.getClassName, + +// Frequently used strings +STALKER = "stalker", +HOST = "host", +PX = 'px', + +// CSS class names +CLASS_STALKER = getClassName(STALKER), + +// Utility functions +/** + * The NodeStalker class is a plugin for a Node instance.The class is used via + * the plug method of Node and + * should not be instantiated directly. + * @namespace Y.Plugin + * @class NodeStalker + */ +NodeStalker = function() { + + NodeStalker.superclass.constructor.apply(this, arguments); + +}; + +NodeStalker.NAME = "NodeStalker"; +NodeStalker.NS = STALKER; + +NodeStalker.ATTRS = {}; + +Y.extend(NodeStalker, Y.Plugin.Base, { + + // Protected properties + /** + * @property _root + * @description Node instance representing the target node to follow. + * @default null + * @protected + * @type Node + */ + _root: null, + _eventHandlers: [], + + // Public methods + initializer: function(config) { + var fn = Y.bind(this.refresh, this); + if ((this._root = this.get(HOST))) { + + this._root.addClass(CLASS_STALKER); + + // Wire up all event handlers + this._eventHandlers.push(Y.on('scroll', fn)); + this._eventHandlers.push(Y.on('windowresize', fn)); + + } + }, + + destructor: function() { + if (this._root) { + this._root.removeClass(CLASS_STALKER); + } + Y.Array.each(this._eventHandlers, + function(handle) { + handle.detach(); + }); + }, + + /** + * @method refresh + * @description Refreshing the position of the element in every scroll/resize event + * @public + */ + refresh: function() { + Y.log ('Refreshing the target', 'info', STALKER); + + var top = Y.DOM.docScrollY(), + left = Y.DOM.docScrollX(), + n = this._root, + r = n.get('parentNode').getXY(), + c = ["marginTop", "marginLeft", "borderLeftWidth", "borderTopWidth"]; + + // viewport computations + r[1] = Math.max(0, r[1] - top); + r[0] = r[0] - left; + // node size computation + Y.Array.each(c, + function(v) { + r[v] = parseInt(n.getStyle(v), 10) || 0; + }); + n.setStyles({ + top: r[1] - r.borderTopWidth - r.marginTop, + left: r[0] - r.borderLeftWidth - r.marginLeft, + position: 'fixed' + }); + }, + + // Protected methods + /** + * @method _IE6Fix + * @description Adding a CSS expression to workaround the lack of "position:fixed" in IE6 + * @protected + * @return {boolean} whether or not is this fix needed + */ + _IE6Fix: function() { + var targetID, + parentID, + css; + if (UA.ie == 6) { + Y.log('Appliying IE6 fix for static position.', 'info', STALKER); + targetID = this._root.get('id'); + parentID = this._root.get('parentNode').get('id'); + css = "#" + targetID + " {top:expression((ignore = document.documentElement.scrollTop>document.getElementById('" + parentID + "').offsetTop) ? document.documentElement.scrollTop : document.getElementById('" + parentID + "').offsetTop + 'px' );}"; + // adding CSS to the page + Y.on('domready', + function(e) { + Y.log('Inserting IE6 fix in the page: ' + css, 'info', STALKER); + // TODO + }); + return true; + } + } + +}); + +Y.namespace('Plugin'); + +Y.Plugin.NodeStalker = NodeStalker; + + +}, 'gallery-2010.04.02-17-26' ,{requires:['plugin','node-base','event-resize','event-base','dom-screen', 'classnamemanager']}); diff --git a/build/gallery-stalker/gallery-stalker-min.js b/build/gallery-stalker/gallery-stalker-min.js new file mode 100644 index 0000000000..3a83f21afa --- /dev/null +++ b/build/gallery-stalker/gallery-stalker-min.js @@ -0,0 +1 @@ +YUI.add("gallery-stalker",function(H){var F=H.UA,C=H.ClassNameManager.getClassName,D="stalker",A="host",E="px",B=C(D),G=function(){G.superclass.constructor.apply(this,arguments);};G.NAME="NodeStalker";G.NS=D;G.ATTRS={};H.extend(G,H.Plugin.Base,{_root:null,_eventHandlers:[],initializer:function(I){var J=H.bind(this.refresh,this);if((this._root=this.get(A))){this._root.addClass(B);this._eventHandlers.push(H.on("scroll",J));this._eventHandlers.push(H.on("windowresize",J));}},destructor:function(){if(this._root){this._root.removeClass(B);}H.Array.each(this._eventHandlers,function(I){I.detach();});},refresh:function(){var K=H.DOM.docScrollY(),J=H.DOM.docScrollX(),M=this._root,I=M.get("parentNode").getXY(),L=["marginTop","marginLeft","borderLeftWidth","borderTopWidth"];I[1]=Math.max(0,I[1]-K);I[0]=I[0]-J;H.Array.each(L,function(N){I[N]=parseInt(M.getStyle(N),10)||0;});M.setStyles({top:I[1]-I.borderTopWidth-I.marginTop,left:I[0]-I.borderLeftWidth-I.marginLeft,position:"fixed"});},_IE6Fix:function(){var I,K,J;if(F.ie==6){I=this._root.get("id");K=this._root.get("parentNode").get("id");J="#"+I+" {top:expression((ignore = document.documentElement.scrollTop>document.getElementById('"+K+"').offsetTop) ? document.documentElement.scrollTop : document.getElementById('"+K+"').offsetTop + 'px' );}";H.on("domready",function(L){});return true;}}});H.namespace("Plugin");H.Plugin.NodeStalker=G;},"gallery-2010.04.02-17-26",{requires:["plugin","node-base","event-resize","event-base","dom-screen","classnamemanager"]}); \ No newline at end of file diff --git a/build/gallery-stalker/gallery-stalker.js b/build/gallery-stalker/gallery-stalker.js new file mode 100644 index 0000000000..73ad79133e --- /dev/null +++ b/build/gallery-stalker/gallery-stalker.js @@ -0,0 +1,160 @@ +YUI.add('gallery-stalker', function(Y) { + +/** +*

Stalker plugin will allow you to keep elements at a fixed position "floating" but at +* the same time, keeping those elements embeded to the layout of the page. The general idea +* is that an element can control it's own position within the layout in order to keep its +* area within the viewport boundaries. +* +*

To use the Stalker Plugin, simply pass a reference to the plugin to a +* Node instance's plug method.

+* +*

+* +* <script type="text/javascript">
+*
+* // Call the "use" method, passing in "gallery-stalker". This will
+* // load the script for the Stalker Plugin and all of
+* // the required dependencies.
+*
+* YUI().use("gallery-stalker", function(Y) {
+*
+* Y.one('#mytarget').plug(Y.Plugin.Stalker);
+*
+* });
+*
+* </script>
+*
+*

+* @module gallery-stalker +*/ + + +// Util shortcuts +var UA = Y.UA, +getClassName = Y.ClassNameManager.getClassName, + +// Frequently used strings +STALKER = "stalker", +HOST = "host", +PX = 'px', + +// CSS class names +CLASS_STALKER = getClassName(STALKER), + +// Utility functions +/** + * The NodeStalker class is a plugin for a Node instance.The class is used via + * the plug method of Node and + * should not be instantiated directly. + * @namespace Y.Plugin + * @class NodeStalker + */ +NodeStalker = function() { + + NodeStalker.superclass.constructor.apply(this, arguments); + +}; + +NodeStalker.NAME = "NodeStalker"; +NodeStalker.NS = STALKER; + +NodeStalker.ATTRS = {}; + +Y.extend(NodeStalker, Y.Plugin.Base, { + + // Protected properties + /** + * @property _root + * @description Node instance representing the target node to follow. + * @default null + * @protected + * @type Node + */ + _root: null, + _eventHandlers: [], + + // Public methods + initializer: function(config) { + var fn = Y.bind(this.refresh, this); + if ((this._root = this.get(HOST))) { + + this._root.addClass(CLASS_STALKER); + + // Wire up all event handlers + this._eventHandlers.push(Y.on('scroll', fn)); + this._eventHandlers.push(Y.on('windowresize', fn)); + + } + }, + + destructor: function() { + if (this._root) { + this._root.removeClass(CLASS_STALKER); + } + Y.Array.each(this._eventHandlers, + function(handle) { + handle.detach(); + }); + }, + + /** + * @method refresh + * @description Refreshing the position of the element in every scroll/resize event + * @public + */ + refresh: function() { + + var top = Y.DOM.docScrollY(), + left = Y.DOM.docScrollX(), + n = this._root, + r = n.get('parentNode').getXY(), + c = ["marginTop", "marginLeft", "borderLeftWidth", "borderTopWidth"]; + + // viewport computations + r[1] = Math.max(0, r[1] - top); + r[0] = r[0] - left; + // node size computation + Y.Array.each(c, + function(v) { + r[v] = parseInt(n.getStyle(v), 10) || 0; + }); + n.setStyles({ + top: r[1] - r.borderTopWidth - r.marginTop, + left: r[0] - r.borderLeftWidth - r.marginLeft, + position: 'fixed' + }); + }, + + // Protected methods + /** + * @method _IE6Fix + * @description Adding a CSS expression to workaround the lack of "position:fixed" in IE6 + * @protected + * @return {boolean} whether or not is this fix needed + */ + _IE6Fix: function() { + var targetID, + parentID, + css; + if (UA.ie == 6) { + targetID = this._root.get('id'); + parentID = this._root.get('parentNode').get('id'); + css = "#" + targetID + " {top:expression((ignore = document.documentElement.scrollTop>document.getElementById('" + parentID + "').offsetTop) ? document.documentElement.scrollTop : document.getElementById('" + parentID + "').offsetTop + 'px' );}"; + // adding CSS to the page + Y.on('domready', + function(e) { + // TODO + }); + return true; + } + } + +}); + +Y.namespace('Plugin'); + +Y.Plugin.NodeStalker = NodeStalker; + + +}, 'gallery-2010.04.02-17-26' ,{requires:['plugin','node-base','event-resize','event-base','dom-screen', 'classnamemanager']});