Add JS files
This commit is contained in:
9
jssource/src_files/include/javascript/yui3/build/widget/widget-min.js
vendored
Executable file
9
jssource/src_files/include/javascript/yui3/build/widget/widget-min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
8
jssource/src_files/include/javascript/yui3/build/widget/widget-position-ext-min.js
vendored
Executable file
8
jssource/src_files/include/javascript/yui3/build/widget/widget-position-ext-min.js
vendored
Executable file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("widget-position-ext",function(A){var H=A.Lang,C="align",E="bindUI",B="syncUI",D="offsetWidth",I="offsetHeight",K="viewportRegion",G="region",J="alignChange";function F(L){if(!this._posNode){A.error("WidgetPosition needs to be added to the Widget, before WidgetPositionExt is added");}A.after(this._syncUIPosExtras,this,B);A.after(this._bindUIPosExtras,this,E);}F.ATTRS={align:{value:null},centered:{setter:function(L){return this._setAlignCenter(L);},lazyAdd:false,value:false}};F.TL="tl";F.TR="tr";F.BL="bl";F.BR="br";F.TC="tc";F.RC="rc";F.BC="bc";F.LC="lc";F.CC="cc";F.prototype={_syncUIPosExtras:function(){var L=this.get(C);if(L){this._uiSetAlign(L.node,L.points);}},_bindUIPosExtras:function(){this.after(J,this._afterAlignChange);},_setAlignCenter:function(L){if(L){this.set(C,{node:L===true?null:L,points:[F.CC,F.CC]});}return L;},_afterAlignChange:function(L){if(L.newVal){this._uiSetAlign(L.newVal.node,L.newVal.points);}},_uiSetAlign:function(O,N){if(!H.isArray(N)||N.length!=2){A.error("align: Invalid Points Arguments");return;}var M,L,P,Q;if(!O){M=this._posNode.get(K);}else{O=A.Node.get(O);if(O){M=O.get(G);}}if(M){M.width=M.width||M.right-M.left;M.height=M.height||M.bottom-M.top;L=N[0];P=N[1];switch(P){case F.TL:Q=[M.left,M.top];break;case F.TR:Q=[M.right,M.top];break;case F.BL:Q=[M.left,M.bottom];break;case F.BR:Q=[M.right,M.bottom];break;case F.TC:Q=[M.left+Math.floor(M.width/2),M.top];break;case F.BC:Q=[M.left+Math.floor(M.width/2),M.bottom];break;case F.LC:Q=[M.left,M.top+Math.floor(M.height/2)];break;case F.RC:Q=[M.right,M.top+Math.floor(M.height/2),L];break;case F.CC:Q=[M.left+Math.floor(M.width/2),M.top+Math.floor(M.height/2),L];break;default:break;}if(Q){this._doAlign(L,Q[0],Q[1]);}}},_doAlign:function(M,L,P){var O=this._posNode,N;switch(M){case F.TL:N=[L,P];break;case F.TR:N=[L-O.get(D),P];break;case F.BL:N=[L,P-O.get(I)];break;case F.BR:N=[L-O.get(D),P-O.get(I)];break;case F.TC:N=[L-(O.get(D)/2),P];break;case F.BC:N=[L-(O.get(D)/2),P-O.get(I)];break;case F.LC:N=[L,P-(O.get(I)/2)];break;case F.RC:N=[(L-O.get(D)),P-(O.get(I)/2)];break;case F.CC:N=[L-(O.get(D)/2),P-(O.get(I)/2)];break;default:break;}if(N){this.move(N);}},align:function(M,L){this.set(C,{node:M,points:L});},centered:function(L){this.align(L,[F.CC,F.CC]);}};A.WidgetPositionExt=F;},"3.0.0",{requires:["widget","widget-position"]});
|
||||
407
jssource/src_files/include/javascript/yui3/build/widget/widget-position-ext.js
vendored
Executable file
407
jssource/src_files/include/javascript/yui3/build/widget/widget-position-ext.js
vendored
Executable file
@@ -0,0 +1,407 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('widget-position-ext', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides extended/advanced XY positioning support for Widgets, through an extension.
|
||||
*
|
||||
* It builds on top of the widget-position module, to provide alignmentment and centering support.
|
||||
* Future releases aim to add constrained and fixed positioning support.
|
||||
*
|
||||
* @module widget-position-ext
|
||||
*/
|
||||
var L = Y.Lang,
|
||||
ALIGN = "align",
|
||||
|
||||
BINDUI = "bindUI",
|
||||
SYNCUI = "syncUI",
|
||||
|
||||
OFFSET_WIDTH = "offsetWidth",
|
||||
OFFSET_HEIGHT = "offsetHeight",
|
||||
VIEWPORT_REGION = "viewportRegion",
|
||||
REGION = "region",
|
||||
|
||||
AlignChange = "alignChange";
|
||||
|
||||
/**
|
||||
* Widget extension, which can be used to add extended XY positioning support to the base Widget class,
|
||||
* through the <a href="Base.html#method_build">Base.build</a> method. This extension requires that
|
||||
* the WidgetPosition extension be added to the Widget (before WidgetPositionExt, if part of the same
|
||||
* extension list passed to Base.build).
|
||||
*
|
||||
* @class WidgetPositionExt
|
||||
* @param {Object} User configuration object
|
||||
*/
|
||||
function PositionExt(config) {
|
||||
if (!this._posNode) {
|
||||
Y.error("WidgetPosition needs to be added to the Widget, before WidgetPositionExt is added");
|
||||
}
|
||||
Y.after(this._syncUIPosExtras, this, SYNCUI);
|
||||
Y.after(this._bindUIPosExtras, this, BINDUI);
|
||||
}
|
||||
|
||||
/**
|
||||
* Static property used to define the default attribute
|
||||
* configuration introduced by WidgetPositionExt.
|
||||
*
|
||||
* @property WidgetPositionExt.ATTRS
|
||||
* @type Object
|
||||
* @static
|
||||
*/
|
||||
PositionExt.ATTRS = {
|
||||
|
||||
/**
|
||||
* @attribute align
|
||||
* @type Object
|
||||
* @default null
|
||||
* @desciption The align attribute is used to align a reference point on the widget, with the refernce point on another node, or the viewport.
|
||||
* The object which align expects has the following properties:
|
||||
* <dl>
|
||||
* <dt>node</dt>
|
||||
* <dd>
|
||||
* The node to which the Widget is to be aligned. If set to null, or not provided, the Widget is aligned to the viewport
|
||||
* </dd>
|
||||
* <dt>points</dt>
|
||||
* <dd>
|
||||
* <p>
|
||||
* A two element array, defining the two points on the Widget and node/viewport which are to be aligned. The first element is the point on the Widget, and the second element is the point on the node/viewport.
|
||||
* Supported alignment points are defined as static properties on <code>WidgetPositionExt</code>.
|
||||
* </p>
|
||||
* <p>
|
||||
* e.g. <code>[WidgetPositionExt.TR, WidgetPositionExt.TL]</code> aligns the Top-Right corner of the Widget with the
|
||||
* Top-Left corner of the node/viewport, and <code>[WidgetPositionExt.CC, WidgetPositionExt.TC]</code> aligns the Center of the
|
||||
* Widget with the Top-Center edge of the node/viewport.
|
||||
* </p>
|
||||
* </dd>
|
||||
* </dl>
|
||||
*/
|
||||
align: {
|
||||
value:null
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute centered
|
||||
* @type {boolean | node}
|
||||
* @default false
|
||||
* @description A convenience attribute, which can be used as a shortcut for the align attribute.
|
||||
* If set to true, the Widget is centered in the viewport. If set to a node reference or valid selector string,
|
||||
* the Widget will be centered within the node. If set the false, no center positioning is applied.
|
||||
*/
|
||||
centered: {
|
||||
setter: function(val) {
|
||||
return this._setAlignCenter(val);
|
||||
},
|
||||
lazyAdd:false,
|
||||
value:false
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Constant used to specify the top-left corner for alignment
|
||||
*
|
||||
* @property WidgetPositionExt.TL
|
||||
* @type String
|
||||
* @static
|
||||
* @value "tl"
|
||||
*/
|
||||
PositionExt.TL = "tl";
|
||||
/**
|
||||
* Constant used to specify the top-right corner for alignment
|
||||
*
|
||||
* @property WidgetPositionExt.TR
|
||||
* @type String
|
||||
* @static
|
||||
* @value "tr"
|
||||
*/
|
||||
PositionExt.TR = "tr";
|
||||
/**
|
||||
* Constant used to specify the bottom-left corner for alignment
|
||||
*
|
||||
* @property WidgetPositionExt.BL
|
||||
* @type String
|
||||
* @static
|
||||
* @value "bl"
|
||||
*/
|
||||
PositionExt.BL = "bl";
|
||||
/**
|
||||
* Constant used to specify the bottom-right corner for alignment
|
||||
*
|
||||
* @property WidgetPositionExt.BR
|
||||
* @type String
|
||||
* @static
|
||||
* @value "br"
|
||||
*/
|
||||
PositionExt.BR = "br";
|
||||
/**
|
||||
* Constant used to specify the top edge-center point for alignment
|
||||
*
|
||||
* @property WidgetPositionExt.TC
|
||||
* @type String
|
||||
* @static
|
||||
* @value "tc"
|
||||
*/
|
||||
PositionExt.TC = "tc";
|
||||
/**
|
||||
* Constant used to specify the right edge, center point for alignment
|
||||
*
|
||||
* @property WidgetPositionExt.RC
|
||||
* @type String
|
||||
* @static
|
||||
* @value "rc"
|
||||
*/
|
||||
PositionExt.RC = "rc";
|
||||
/**
|
||||
* Constant used to specify the bottom edge, center point for alignment
|
||||
*
|
||||
* @property WidgetPositionExt.BC
|
||||
* @type String
|
||||
* @static
|
||||
* @value "bc"
|
||||
*/
|
||||
PositionExt.BC = "bc";
|
||||
/**
|
||||
* Constant used to specify the left edge, center point for alignment
|
||||
*
|
||||
* @property WidgetPositionExt.LC
|
||||
* @type String
|
||||
* @static
|
||||
* @value "lc"
|
||||
*/
|
||||
PositionExt.LC = "lc";
|
||||
/**
|
||||
* Constant used to specify the center of widget/node/viewport for alignment
|
||||
*
|
||||
* @property WidgetPositionExt.CC
|
||||
* @type String
|
||||
* @static
|
||||
* @value "cc"
|
||||
*/
|
||||
PositionExt.CC = "cc";
|
||||
|
||||
PositionExt.prototype = {
|
||||
|
||||
/**
|
||||
* Synchronizes the UI to match the Widgets extended positioning state.
|
||||
* This method in invoked after syncUI is invoked for the Widget class
|
||||
* using YUI's aop infrastructure.
|
||||
*
|
||||
* @method _syncUIPosExtras
|
||||
* @protected
|
||||
*/
|
||||
_syncUIPosExtras : function() {
|
||||
var align = this.get(ALIGN);
|
||||
if (align) {
|
||||
this._uiSetAlign(align.node, align.points);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Binds event listeners responsible for updating the UI state in response to
|
||||
* Widget extended positioning related state changes.
|
||||
* <p>
|
||||
* This method is invoked after bindUI is invoked for the Widget class
|
||||
* using YUI's aop infrastructure.
|
||||
* </p>
|
||||
* @method _bindUIStack
|
||||
* @protected
|
||||
*/
|
||||
_bindUIPosExtras : function() {
|
||||
this.after(AlignChange, this._afterAlignChange);
|
||||
},
|
||||
|
||||
/**
|
||||
* Default setter for center attribute changes. Sets up the appropriate value, and passes
|
||||
* it through the to the align attribute.
|
||||
*
|
||||
* @method _setAlignCenter
|
||||
* @protected
|
||||
* @param {boolean | node} The attribute value being set.
|
||||
* @return {Number} The attribute value being set.
|
||||
*/
|
||||
_setAlignCenter : function(val) {
|
||||
if (val) {
|
||||
this.set(ALIGN, {
|
||||
node: val === true ? null : val,
|
||||
points: [PositionExt.CC, PositionExt.CC]
|
||||
});
|
||||
}
|
||||
return val;
|
||||
},
|
||||
|
||||
/**
|
||||
* Default attribute change listener for the align attribute, responsible
|
||||
* for updating the UI, in response to attribute changes.
|
||||
*
|
||||
* @method _afterAlignChange
|
||||
* @protected
|
||||
* @param {EventFacade} e The event facade for the attribute change
|
||||
*/
|
||||
_afterAlignChange : function(e) {
|
||||
if (e.newVal) {
|
||||
this._uiSetAlign(e.newVal.node, e.newVal.points);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the UI to reflect the align value passed in (see the align attribute documentation, for the object stucture expected)
|
||||
* @method _uiSetAlign
|
||||
* @protected
|
||||
* @param {Node | null} The node to align to, or null to indicate the viewport
|
||||
*/
|
||||
_uiSetAlign: function (node, points) {
|
||||
|
||||
if (!L.isArray(points) || points.length != 2) {
|
||||
Y.error("align: Invalid Points Arguments");
|
||||
return;
|
||||
}
|
||||
|
||||
var nodeRegion, widgetPoint, nodePoint, xy;
|
||||
|
||||
if (!node) {
|
||||
nodeRegion = this._posNode.get(VIEWPORT_REGION);
|
||||
} else {
|
||||
node = Y.Node.get(node);
|
||||
if (node) {
|
||||
nodeRegion = node.get(REGION);
|
||||
}
|
||||
}
|
||||
|
||||
if (nodeRegion) {
|
||||
|
||||
// TODO: ViewportRegion doesn't have width/height - Workaround until normalized in Node/Dom
|
||||
nodeRegion.width = nodeRegion.width || nodeRegion.right - nodeRegion.left;
|
||||
nodeRegion.height = nodeRegion.height || nodeRegion.bottom - nodeRegion.top;
|
||||
|
||||
widgetPoint = points[0];
|
||||
nodePoint = points[1];
|
||||
|
||||
// TODO: Optimize KWeight - Would lookup table help?
|
||||
switch (nodePoint) {
|
||||
case PositionExt.TL:
|
||||
xy = [nodeRegion.left, nodeRegion.top];
|
||||
break;
|
||||
case PositionExt.TR:
|
||||
xy = [nodeRegion.right, nodeRegion.top];
|
||||
break;
|
||||
case PositionExt.BL:
|
||||
xy = [nodeRegion.left, nodeRegion.bottom];
|
||||
break;
|
||||
case PositionExt.BR:
|
||||
xy = [nodeRegion.right, nodeRegion.bottom];
|
||||
break;
|
||||
case PositionExt.TC:
|
||||
xy = [nodeRegion.left + Math.floor(nodeRegion.width/2), nodeRegion.top];
|
||||
break;
|
||||
case PositionExt.BC:
|
||||
xy = [nodeRegion.left + Math.floor(nodeRegion.width/2), nodeRegion.bottom];
|
||||
break;
|
||||
case PositionExt.LC:
|
||||
xy = [nodeRegion.left, nodeRegion.top + Math.floor(nodeRegion.height/2)];
|
||||
break;
|
||||
case PositionExt.RC:
|
||||
xy = [nodeRegion.right, nodeRegion.top + Math.floor(nodeRegion.height/2), widgetPoint];
|
||||
break;
|
||||
case PositionExt.CC:
|
||||
xy = [nodeRegion.left + Math.floor(nodeRegion.width/2), nodeRegion.top + Math.floor(nodeRegion.height/2), widgetPoint];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (xy) {
|
||||
this._doAlign(widgetPoint, xy[0], xy[1]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper method, used to align the given point on the widget, with the XY page co-ordinates provided.
|
||||
*
|
||||
* @method _doAlign
|
||||
* @private
|
||||
* @param {String} widgetPoint Supported point constant (e.g. WidgetPositionExt.TL)
|
||||
* @param {Number} x X page co-ordinate to align to
|
||||
* @param {Number} y Y page co-ordinate to align to
|
||||
*/
|
||||
_doAlign : function(widgetPoint, x, y) {
|
||||
var widgetNode = this._posNode,
|
||||
xy;
|
||||
|
||||
switch (widgetPoint) {
|
||||
case PositionExt.TL:
|
||||
xy = [x, y];
|
||||
break;
|
||||
case PositionExt.TR:
|
||||
xy = [x - widgetNode.get(OFFSET_WIDTH), y];
|
||||
break;
|
||||
case PositionExt.BL:
|
||||
xy = [x, y - widgetNode.get(OFFSET_HEIGHT)];
|
||||
break;
|
||||
case PositionExt.BR:
|
||||
xy = [x - widgetNode.get(OFFSET_WIDTH), y - widgetNode.get(OFFSET_HEIGHT)];
|
||||
break;
|
||||
case PositionExt.TC:
|
||||
xy = [x - (widgetNode.get(OFFSET_WIDTH)/2), y];
|
||||
break;
|
||||
case PositionExt.BC:
|
||||
xy = [x - (widgetNode.get(OFFSET_WIDTH)/2), y - widgetNode.get(OFFSET_HEIGHT)];
|
||||
break;
|
||||
case PositionExt.LC:
|
||||
xy = [x, y - (widgetNode.get(OFFSET_HEIGHT)/2)];
|
||||
break;
|
||||
case PositionExt.RC:
|
||||
xy = [(x - widgetNode.get(OFFSET_WIDTH)), y - (widgetNode.get(OFFSET_HEIGHT)/2)];
|
||||
break;
|
||||
case PositionExt.CC:
|
||||
xy = [x - (widgetNode.get(OFFSET_WIDTH)/2), y - (widgetNode.get(OFFSET_HEIGHT)/2)];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (xy) {
|
||||
this.move(xy);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Aligns the Widget to the provided node (or viewport) using the provided
|
||||
* points. The method can be invoked directly, however it will result in
|
||||
* the align attribute being out of sync with current position of the of Widget.
|
||||
*
|
||||
* @method align
|
||||
* @param {Node | String | null} node A reference (or selector string) for the Node which with the Widget is to be aligned.
|
||||
* If null is passed in, the Widget will be aligned with the viewport.
|
||||
* @param {Array[2]} points A two element array, specifying the points on the Widget and node/viewport which need to be aligned.
|
||||
* The first entry is the point on the Widget, and the second entry is the point on the node/viewport which need to align.
|
||||
* Valid point references are defined as static constants on the WidgetPositionExt class.
|
||||
*
|
||||
* e.g. [WidgetPositionExt.TL, WidgetPositionExt.TR] will align the top-left corner of the Widget with the top-right corner of the node/viewport.
|
||||
*/
|
||||
align: function (node, points) {
|
||||
this.set(ALIGN, {node: node, points:points});
|
||||
},
|
||||
|
||||
/**
|
||||
* Centers the container in the viewport, or if a node is passed in,
|
||||
* the node.
|
||||
*
|
||||
* @method centered
|
||||
* @param {Node | String} node Optional. A node reference or selector string defining the node
|
||||
* inside which the Widget is to be centered. If not passed in, the Widget will be centered in the
|
||||
* viewport.
|
||||
*/
|
||||
centered: function (node) {
|
||||
this.align(node, [PositionExt.CC, PositionExt.CC]);
|
||||
}
|
||||
};
|
||||
|
||||
Y.WidgetPositionExt = PositionExt;
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['widget', 'widget-position']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/widget/widget-position-min.js
vendored
Executable file
8
jssource/src_files/include/javascript/yui3/build/widget/widget-position-min.js
vendored
Executable file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("widget-position",function(A){var H=A.Lang,J=A.Widget,K="xy",F="positioned",I="boundingBox",L="renderUI",G="bindUI",D="syncUI",C=J.UI_SRC,E="xyChange";function B(M){this._posNode=this.get(I);A.after(this._renderUIPosition,this,L);A.after(this._syncUIPosition,this,D);A.after(this._bindUIPosition,this,G);}B.ATTRS={x:{setter:function(M){this._setX(M);},lazyAdd:false,getter:function(){return this._getX();}},y:{setter:function(M){this._setY(M);},lazyAdd:false,getter:function(){return this._getY();}},xy:{value:[0,0],validator:function(M){return this._validateXY(M);}}};B.POSITIONED_CLASS_NAME=J.getClassName(F);B.prototype={_renderUIPosition:function(){this._posNode.addClass(B.POSITIONED_CLASS_NAME);},_syncUIPosition:function(){this._uiSetXY(this.get(K));},_bindUIPosition:function(){this.after(E,this._afterXYChange);},move:function(){var M=arguments,N=(H.isArray(M[0]))?M[0]:[M[0],M[1]];this.set(K,N);},syncXY:function(){this.set(K,this._posNode.getXY(),{src:C});},_validateXY:function(M){return(H.isArray(M)&&H.isNumber(M[0])&&H.isNumber(M[1]));},_setX:function(M){this.set(K,[M,this.get(K)[1]]);},_setY:function(M){this.set(K,[this.get(K)[0],M]);},_getX:function(){return this.get(K)[0];},_getY:function(){return this.get(K)[1];},_afterXYChange:function(M){if(M.src!=C){this._uiSetXY(M.newVal);}},_uiSetXY:function(M){this._posNode.setXY(M);}};A.WidgetPosition=B;},"3.0.0",{requires:["widget"]});
|
||||
272
jssource/src_files/include/javascript/yui3/build/widget/widget-position.js
vendored
Executable file
272
jssource/src_files/include/javascript/yui3/build/widget/widget-position.js
vendored
Executable file
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('widget-position', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides basic XY positioning support for Widgets, though an extension
|
||||
*
|
||||
* @module widget-position
|
||||
*/
|
||||
var Lang = Y.Lang,
|
||||
Widget = Y.Widget,
|
||||
|
||||
XY_COORD = "xy",
|
||||
|
||||
POSITIONED = "positioned",
|
||||
BOUNDING_BOX = "boundingBox",
|
||||
|
||||
RENDERUI = "renderUI",
|
||||
BINDUI = "bindUI",
|
||||
SYNCUI = "syncUI",
|
||||
|
||||
UI = Widget.UI_SRC,
|
||||
|
||||
XYChange = "xyChange";
|
||||
|
||||
/**
|
||||
* Widget extension, which can be used to add positioning support to the base Widget class,
|
||||
* through the <a href="Base.html#method_build">Base.build</a> method.
|
||||
*
|
||||
* @class WidgetPosition
|
||||
* @param {Object} config User configuration object
|
||||
*/
|
||||
function Position(config) {
|
||||
this._posNode = this.get(BOUNDING_BOX);
|
||||
|
||||
// WIDGET METHOD OVERLAP
|
||||
Y.after(this._renderUIPosition, this, RENDERUI);
|
||||
Y.after(this._syncUIPosition, this, SYNCUI);
|
||||
Y.after(this._bindUIPosition, this, BINDUI);
|
||||
}
|
||||
|
||||
/**
|
||||
* Static property used to define the default attribute
|
||||
* configuration introduced by WidgetPosition.
|
||||
*
|
||||
* @property WidgetPosition.ATTRS
|
||||
* @static
|
||||
* @type Object
|
||||
*/
|
||||
Position.ATTRS = {
|
||||
|
||||
/**
|
||||
* @attribute x
|
||||
* @type number
|
||||
* @default 0
|
||||
*
|
||||
* @description Page X co-ordinate for the widget. This attribute acts as a facade for the
|
||||
* xy attribute. Changes in position can be monitored by listening for xyChange events.
|
||||
*/
|
||||
x: {
|
||||
setter: function(val) {
|
||||
this._setX(val);
|
||||
},
|
||||
lazyAdd:false,
|
||||
getter: function() {
|
||||
return this._getX();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute y
|
||||
* @type number
|
||||
* @default 0
|
||||
*
|
||||
* @description Page Y co-ordinate for the widget. This attribute acts as a facade for the
|
||||
* xy attribute. Changes in position can be monitored by listening for xyChange events.
|
||||
*/
|
||||
y: {
|
||||
setter: function(val) {
|
||||
this._setY(val);
|
||||
},
|
||||
lazyAdd: false,
|
||||
getter: function() {
|
||||
return this._getY();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute xy
|
||||
* @type Array
|
||||
* @default [0,0]
|
||||
*
|
||||
* @description Page XY co-ordinate pair for the widget.
|
||||
*/
|
||||
xy: {
|
||||
value:[0,0],
|
||||
|
||||
validator: function(val) {
|
||||
return this._validateXY(val);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Default class used to mark the boundingBox of a positioned widget.
|
||||
*
|
||||
* @property WidgetPosition.POSITIONED_CLASS_NAME
|
||||
* @type String
|
||||
* @default "yui-widget-positioned"
|
||||
* @static
|
||||
*/
|
||||
Position.POSITIONED_CLASS_NAME = Widget.getClassName(POSITIONED);
|
||||
|
||||
Position.prototype = {
|
||||
|
||||
/**
|
||||
* Creates/Initializes the DOM to support xy page positioning.
|
||||
* <p>
|
||||
* This method in invoked after renderUI is invoked for the Widget class
|
||||
* using YUI's aop infrastructure.
|
||||
* </p>
|
||||
* @method _renderUIPosition
|
||||
* @protected
|
||||
*/
|
||||
_renderUIPosition : function() {
|
||||
this._posNode.addClass(Position.POSITIONED_CLASS_NAME);
|
||||
},
|
||||
|
||||
/**
|
||||
* Synchronizes the UI to match the Widgets xy page position state.
|
||||
* <p>
|
||||
* This method in invoked after syncUI is invoked for the Widget class
|
||||
* using YUI's aop infrastructure.
|
||||
* </p>
|
||||
* @method _syncUIPosition
|
||||
* @protected
|
||||
*/
|
||||
_syncUIPosition : function() {
|
||||
this._uiSetXY(this.get(XY_COORD));
|
||||
},
|
||||
|
||||
/**
|
||||
* Binds event listeners responsible for updating the UI state in response to
|
||||
* Widget position related state changes.
|
||||
* <p>
|
||||
* This method in invoked after bindUI is invoked for the Widget class
|
||||
* using YUI's aop infrastructure.
|
||||
* </p>
|
||||
* @method _bindUIPosition
|
||||
* @protected
|
||||
*/
|
||||
_bindUIPosition :function() {
|
||||
this.after(XYChange, this._afterXYChange);
|
||||
},
|
||||
|
||||
/**
|
||||
* Moves the Widget to the specified page xy co-ordinate position.
|
||||
*
|
||||
* @method move
|
||||
*
|
||||
* @param {Number} x The new x position
|
||||
* @param {Number} y The new y position
|
||||
* <p>Or</p>
|
||||
* @param {Array} x, y values passed as an array ([x, y]), to support
|
||||
* simple pass through of Node.getXY results
|
||||
*/
|
||||
move: function () {
|
||||
var args = arguments,
|
||||
coord = (Lang.isArray(args[0])) ? args[0] : [args[0], args[1]];
|
||||
this.set(XY_COORD, coord);
|
||||
},
|
||||
|
||||
/**
|
||||
* Synchronizes the Panel's "xy", "x", and "y" properties with the
|
||||
* Widget's position in the DOM.
|
||||
*
|
||||
* @method syncXY
|
||||
*/
|
||||
syncXY : function () {
|
||||
this.set(XY_COORD, this._posNode.getXY(), {src: UI});
|
||||
},
|
||||
|
||||
/**
|
||||
* Default validator for the XY attribute
|
||||
*
|
||||
* @method _validateXY
|
||||
* @param {Array} val The XY page co-ordinate value which is being set.
|
||||
* @return {boolean} true if valid, false if not.
|
||||
*/
|
||||
_validateXY : function(val) {
|
||||
return (Lang.isArray(val) && Lang.isNumber(val[0]) && Lang.isNumber(val[1]));
|
||||
},
|
||||
|
||||
/**
|
||||
* Default setter for the X attribute. The setter passes the X value through
|
||||
* to the XY attribute, which is the sole store for the XY state.
|
||||
*
|
||||
* @method _setX
|
||||
* @param {Number} val The X page co-ordinate value
|
||||
*/
|
||||
_setX : function(val) {
|
||||
this.set(XY_COORD, [val, this.get(XY_COORD)[1]]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Default setter for the Y attribute. The setter passes the Y value through
|
||||
* to the XY attribute, which is the sole store for the XY state.
|
||||
*
|
||||
* @method _setY
|
||||
* @param {Number} val The Y page co-ordinate value
|
||||
*/
|
||||
_setY : function(val) {
|
||||
this.set(XY_COORD, [this.get(XY_COORD)[0], val]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Default getter for the X attribute. The value is retrieved from
|
||||
* the XY attribute, which is the sole store for the XY state.
|
||||
*
|
||||
* @method _getX
|
||||
* @return {Number} The X page co-ordinate value
|
||||
*/
|
||||
_getX : function() {
|
||||
return this.get(XY_COORD)[0];
|
||||
},
|
||||
|
||||
/**
|
||||
* Default getter for the Y attribute. The value is retrieved from
|
||||
* the XY attribute, which is the sole store for the XY state.
|
||||
*
|
||||
* @method _getY
|
||||
* @return {Number} The Y page co-ordinate value
|
||||
*/
|
||||
_getY : function() {
|
||||
return this.get(XY_COORD)[1];
|
||||
},
|
||||
|
||||
/**
|
||||
* Default attribute change listener for the xy attribute, responsible
|
||||
* for updating the UI, in response to attribute changes.
|
||||
*
|
||||
* @method _afterXYChange
|
||||
* @protected
|
||||
* @param {EventFacade} e The event facade for the attribute change
|
||||
*/
|
||||
_afterXYChange : function(e) {
|
||||
if (e.src != UI) {
|
||||
this._uiSetXY(e.newVal);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the UI to reflect the XY page co-ordinates passed in.
|
||||
*
|
||||
* @method _uiSetXY
|
||||
* @protected
|
||||
* @param {String} val The XY page co-ordinates value to be reflected in the UI
|
||||
*/
|
||||
_uiSetXY : function(val) {
|
||||
this._posNode.setXY(val);
|
||||
}
|
||||
};
|
||||
|
||||
Y.WidgetPosition = Position;
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['widget']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/widget/widget-stack-min.js
vendored
Executable file
8
jssource/src_files/include/javascript/yui3/build/widget/widget-stack-min.js
vendored
Executable file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("widget-stack",function(E){var N=E.Lang,T=E.UA,d=E.Node,F=E.Widget,c="zIndex",P="shim",a="visible",e="boundingBox",W="renderUI",G="bindUI",S="syncUI",Q="offsetWidth",D="offsetHeight",M="parentNode",A="firstChild",X="ownerDocument",H="width",V="height",K="px",O="shimdeferred",f="shimresize",Z="visibleChange",C="widthChange",J="heightChange",b="shimChange",B="zIndexChange",I="contentUpdate",R="stacked";function U(L){this._stackNode=this.get(e);this._stackHandles={};E.after(this._renderUIStack,this,W);E.after(this._syncUIStack,this,S);E.after(this._bindUIStack,this,G);}U.ATTRS={shim:{value:(T.ie==6)},zIndex:{value:0,setter:function(L){return this._setZIndex(L);}}};U.HTML_PARSER={zIndex:function(L){return L.getStyle(c);}};U.SHIM_CLASS_NAME=F.getClassName(P);U.STACKED_CLASS_NAME=F.getClassName(R);U.SHIM_TEMPLATE='<iframe class="'+U.SHIM_CLASS_NAME+'" frameborder="0" title="Widget Stacking Shim" src="javascript:false" tabindex="-1" role="presentation"></iframe>';U.prototype={_syncUIStack:function(){this._uiSetShim(this.get(P));this._uiSetZIndex(this.get(c));},_bindUIStack:function(){this.after(b,this._afterShimChange);this.after(B,this._afterZIndexChange);},_renderUIStack:function(){this._stackNode.addClass(U.STACKED_CLASS_NAME);},_setZIndex:function(L){if(N.isString(L)){L=parseInt(L,10);}if(!N.isNumber(L)){L=0;}return L;},_afterShimChange:function(L){this._uiSetShim(L.newVal);},_afterZIndexChange:function(L){this._uiSetZIndex(L.newVal);},_uiSetZIndex:function(L){this._stackNode.setStyle(c,L);},_uiSetShim:function(L){if(L){if(this.get(a)){this._renderShim();}else{this._renderShimDeferred();}}else{this._destroyShim();}},_renderShimDeferred:function(){this._stackHandles[O]=this._stackHandles[O]||[];var Y=this._stackHandles[O],L=function(g){if(g.newVal){this._renderShim();}};Y.push(this.on(Z,L));},_addShimResizeHandlers:function(){this._stackHandles[f]=this._stackHandles[f]||[];var Y=this.sizeShim,L=this._stackHandles[f];this.sizeShim();L.push(this.after(Z,Y));L.push(this.after(C,Y));L.push(this.after(J,Y));L.push(this.after(I,Y));},_detachStackHandles:function(L){var Y=this._stackHandles[L],g;if(Y&&Y.length>0){while((g=Y.pop())){g.detach();}}},_renderShim:function(){var L=this._shimNode,Y=this._stackNode;if(!L){L=this._shimNode=this._getShimTemplate();Y.insertBefore(L,Y.get(A));if(T.ie==6){this._addShimResizeHandlers();}this._detachStackHandles(O);}},_destroyShim:function(){if(this._shimNode){this._shimNode.get(M).removeChild(this._shimNode);this._shimNode=null;this._detachStackHandles(O);this._detachStackHandles(f);}},sizeShim:function(){var Y=this._shimNode,L=this._stackNode;if(Y&&T.ie===6&&this.get(a)){Y.setStyle(H,L.get(Q)+K);Y.setStyle(V,L.get(D)+K);}},_getShimTemplate:function(){return d.create(U.SHIM_TEMPLATE,this._stackNode.get(X));}};E.WidgetStack=U;},"3.0.0",{requires:["widget"]});
|
||||
403
jssource/src_files/include/javascript/yui3/build/widget/widget-stack.js
vendored
Executable file
403
jssource/src_files/include/javascript/yui3/build/widget/widget-stack.js
vendored
Executable file
@@ -0,0 +1,403 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('widget-stack', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides stackable (z-index) support for Widgets through an extension.
|
||||
*
|
||||
* @module widget-stack
|
||||
*/
|
||||
var L = Y.Lang,
|
||||
UA = Y.UA,
|
||||
Node = Y.Node,
|
||||
Widget = Y.Widget,
|
||||
|
||||
ZINDEX = "zIndex",
|
||||
SHIM = "shim",
|
||||
VISIBLE = "visible",
|
||||
|
||||
BOUNDING_BOX = "boundingBox",
|
||||
|
||||
RENDER_UI = "renderUI",
|
||||
BIND_UI = "bindUI",
|
||||
SYNC_UI = "syncUI",
|
||||
|
||||
OFFSET_WIDTH = "offsetWidth",
|
||||
OFFSET_HEIGHT = "offsetHeight",
|
||||
PARENT_NODE = "parentNode",
|
||||
FIRST_CHILD = "firstChild",
|
||||
OWNER_DOCUMENT = "ownerDocument",
|
||||
|
||||
WIDTH = "width",
|
||||
HEIGHT = "height",
|
||||
PX = "px",
|
||||
|
||||
// HANDLE KEYS
|
||||
SHIM_DEFERRED = "shimdeferred",
|
||||
SHIM_RESIZE = "shimresize",
|
||||
|
||||
// Events
|
||||
VisibleChange = "visibleChange",
|
||||
WidthChange = "widthChange",
|
||||
HeightChange = "heightChange",
|
||||
ShimChange = "shimChange",
|
||||
ZIndexChange = "zIndexChange",
|
||||
ContentUpdate = "contentUpdate",
|
||||
|
||||
// CSS
|
||||
STACKED = "stacked";
|
||||
|
||||
/**
|
||||
* Widget extension, which can be used to add stackable (z-index) support to the
|
||||
* base Widget class along with a shimming solution, through the
|
||||
* <a href="Base.html#method_build">Base.build</a> method.
|
||||
*
|
||||
* @class WidgetStack
|
||||
* @param {Object} User configuration object
|
||||
*/
|
||||
function Stack(config) {
|
||||
this._stackNode = this.get(BOUNDING_BOX);
|
||||
this._stackHandles = {};
|
||||
|
||||
// WIDGET METHOD OVERLAP
|
||||
Y.after(this._renderUIStack, this, RENDER_UI);
|
||||
Y.after(this._syncUIStack, this, SYNC_UI);
|
||||
Y.after(this._bindUIStack, this, BIND_UI);
|
||||
}
|
||||
|
||||
// Static Properties
|
||||
/**
|
||||
* Static property used to define the default attribute
|
||||
* configuration introduced by WidgetStack.
|
||||
*
|
||||
* @property WidgetStack.ATTRS
|
||||
* @type Object
|
||||
* @static
|
||||
*/
|
||||
Stack.ATTRS = {
|
||||
/**
|
||||
* @attribute shim
|
||||
* @type boolean
|
||||
* @default false, for all browsers other than IE6, for which a shim is enabled by default.
|
||||
*
|
||||
* @description Boolean flag to indicate whether or not a shim should be added to the Widgets
|
||||
* boundingBox, to protect it from select box bleedthrough.
|
||||
*/
|
||||
shim: {
|
||||
value: (UA.ie == 6)
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute zIndex
|
||||
* @type number
|
||||
* @default 0
|
||||
* @description The z-index to apply to the Widgets boundingBox. Non-numerical values for
|
||||
* zIndex will be converted to 0
|
||||
*/
|
||||
zIndex: {
|
||||
value:0,
|
||||
setter: function(val) {
|
||||
return this._setZIndex(val);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The HTML parsing rules for the WidgetStack class.
|
||||
*
|
||||
* @property WidgetStack.HTML_PARSER
|
||||
* @static
|
||||
* @type Object
|
||||
*/
|
||||
Stack.HTML_PARSER = {
|
||||
zIndex: function(contentBox) {
|
||||
return contentBox.getStyle(ZINDEX);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Default class used to mark the shim element
|
||||
*
|
||||
* @property WidgetStack.SHIM_CLASS_NAME
|
||||
* @type String
|
||||
* @static
|
||||
* @default "yui-widget-shim"
|
||||
*/
|
||||
Stack.SHIM_CLASS_NAME = Widget.getClassName(SHIM);
|
||||
|
||||
/**
|
||||
* Default class used to mark the boundingBox of a stacked widget.
|
||||
*
|
||||
* @property WidgetStack.STACKED_CLASS_NAME
|
||||
* @type String
|
||||
* @static
|
||||
* @default "yui-widget-stacked"
|
||||
*/
|
||||
Stack.STACKED_CLASS_NAME = Widget.getClassName(STACKED);
|
||||
|
||||
/**
|
||||
* Default markup template used to generate the shim element.
|
||||
*
|
||||
* @property WidgetStack.SHIM_TEMPLATE
|
||||
* @type String
|
||||
* @static
|
||||
*/
|
||||
Stack.SHIM_TEMPLATE = '<iframe class="' + Stack.SHIM_CLASS_NAME + '" frameborder="0" title="Widget Stacking Shim" src="javascript:false" tabindex="-1" role="presentation"></iframe>';
|
||||
|
||||
Stack.prototype = {
|
||||
|
||||
/**
|
||||
* Synchronizes the UI to match the Widgets stack state. This method in
|
||||
* invoked after syncUI is invoked for the Widget class using YUI's aop infrastructure.
|
||||
*
|
||||
* @method _syncUIStack
|
||||
* @protected
|
||||
*/
|
||||
_syncUIStack: function() {
|
||||
this._uiSetShim(this.get(SHIM));
|
||||
this._uiSetZIndex(this.get(ZINDEX));
|
||||
},
|
||||
|
||||
/**
|
||||
* Binds event listeners responsible for updating the UI state in response to
|
||||
* Widget stack related state changes.
|
||||
* <p>
|
||||
* This method is invoked after bindUI is invoked for the Widget class
|
||||
* using YUI's aop infrastructure.
|
||||
* </p>
|
||||
* @method _bindUIStack
|
||||
* @protected
|
||||
*/
|
||||
_bindUIStack: function() {
|
||||
this.after(ShimChange, this._afterShimChange);
|
||||
this.after(ZIndexChange, this._afterZIndexChange);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates/Initializes the DOM to support stackability.
|
||||
* <p>
|
||||
* This method in invoked after renderUI is invoked for the Widget class
|
||||
* using YUI's aop infrastructure.
|
||||
* </p>
|
||||
* @method _renderUIStack
|
||||
* @protected
|
||||
*/
|
||||
_renderUIStack: function() {
|
||||
this._stackNode.addClass(Stack.STACKED_CLASS_NAME);
|
||||
},
|
||||
|
||||
/**
|
||||
* Default setter for zIndex attribute changes. Normalizes zIndex values to
|
||||
* numbers, converting non-numerical values to 0.
|
||||
*
|
||||
* @method _setZIndex
|
||||
* @protected
|
||||
* @param {String | Number} zIndex
|
||||
* @return {Number} Normalized zIndex
|
||||
*/
|
||||
_setZIndex: function(zIndex) {
|
||||
if (L.isString(zIndex)) {
|
||||
zIndex = parseInt(zIndex, 10);
|
||||
}
|
||||
if (!L.isNumber(zIndex)) {
|
||||
zIndex = 0;
|
||||
}
|
||||
return zIndex;
|
||||
},
|
||||
|
||||
/**
|
||||
* Default attribute change listener for the shim attribute, responsible
|
||||
* for updating the UI, in response to attribute changes.
|
||||
*
|
||||
* @method _afterShimChange
|
||||
* @protected
|
||||
* @param {EventFacade} e The event facade for the attribute change
|
||||
*/
|
||||
_afterShimChange : function(e) {
|
||||
this._uiSetShim(e.newVal);
|
||||
},
|
||||
|
||||
/**
|
||||
* Default attribute change listener for the zIndex attribute, responsible
|
||||
* for updating the UI, in response to attribute changes.
|
||||
*
|
||||
* @method _afterZIndexChange
|
||||
* @protected
|
||||
* @param {EventFacade} e The event facade for the attribute change
|
||||
*/
|
||||
_afterZIndexChange : function(e) {
|
||||
this._uiSetZIndex(e.newVal);
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the UI to reflect the zIndex value passed in.
|
||||
*
|
||||
* @method _uiSetZIndex
|
||||
* @protected
|
||||
* @param {number} zIndex The zindex to be reflected in the UI
|
||||
*/
|
||||
_uiSetZIndex: function (zIndex) {
|
||||
this._stackNode.setStyle(ZINDEX, zIndex);
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the UI to enable/disable the shim. If the widget is not currently visible,
|
||||
* creation of the shim is deferred until it is made visible, for performance reasons.
|
||||
*
|
||||
* @method _uiSetShim
|
||||
* @protected
|
||||
* @param {boolean} enable If true, creates/renders the shim, if false, removes it.
|
||||
*/
|
||||
_uiSetShim: function (enable) {
|
||||
if (enable) {
|
||||
// Lazy creation
|
||||
if (this.get(VISIBLE)) {
|
||||
this._renderShim();
|
||||
} else {
|
||||
this._renderShimDeferred();
|
||||
}
|
||||
} else {
|
||||
this._destroyShim();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets up change handlers for the visible attribute, to defer shim creation/rendering
|
||||
* until the Widget is made visible.
|
||||
*
|
||||
* @method _renderShimDeferred
|
||||
* @private
|
||||
*/
|
||||
_renderShimDeferred : function() {
|
||||
|
||||
this._stackHandles[SHIM_DEFERRED] = this._stackHandles[SHIM_DEFERRED] || [];
|
||||
|
||||
var handles = this._stackHandles[SHIM_DEFERRED],
|
||||
createBeforeVisible = function(e) {
|
||||
if (e.newVal) {
|
||||
this._renderShim();
|
||||
}
|
||||
};
|
||||
|
||||
handles.push(this.on(VisibleChange, createBeforeVisible));
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets up event listeners to resize the shim when the size of the Widget changes.
|
||||
* <p>
|
||||
* NOTE: This method is only used for IE6 currently, since IE6 doesn't support a way to
|
||||
* resize the shim purely through CSS, when the Widget does not have an explicit width/height
|
||||
* set.
|
||||
* </p>
|
||||
* @method _addShimResizeHandlers
|
||||
* @private
|
||||
*/
|
||||
_addShimResizeHandlers : function() {
|
||||
|
||||
this._stackHandles[SHIM_RESIZE] = this._stackHandles[SHIM_RESIZE] || [];
|
||||
|
||||
var sizeShim = this.sizeShim,
|
||||
handles = this._stackHandles[SHIM_RESIZE];
|
||||
|
||||
this.sizeShim();
|
||||
|
||||
handles.push(this.after(VisibleChange, sizeShim));
|
||||
handles.push(this.after(WidthChange, sizeShim));
|
||||
handles.push(this.after(HeightChange, sizeShim));
|
||||
handles.push(this.after(ContentUpdate, sizeShim));
|
||||
},
|
||||
|
||||
/**
|
||||
* Detaches any handles stored for the provided key
|
||||
*
|
||||
* @method _detachStackHandles
|
||||
* @param String handleKey The key defining the group of handles which should be detached
|
||||
* @private
|
||||
*/
|
||||
_detachStackHandles : function(handleKey) {
|
||||
var handles = this._stackHandles[handleKey],
|
||||
handle;
|
||||
|
||||
if (handles && handles.length > 0) {
|
||||
while((handle = handles.pop())) {
|
||||
handle.detach();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates the shim element and adds it to the DOM
|
||||
*
|
||||
* @method _renderShim
|
||||
* @private
|
||||
*/
|
||||
_renderShim : function() {
|
||||
var shimEl = this._shimNode,
|
||||
stackEl = this._stackNode;
|
||||
|
||||
if (!shimEl) {
|
||||
shimEl = this._shimNode = this._getShimTemplate();
|
||||
stackEl.insertBefore(shimEl, stackEl.get(FIRST_CHILD));
|
||||
|
||||
if (UA.ie == 6) {
|
||||
this._addShimResizeHandlers();
|
||||
}
|
||||
this._detachStackHandles(SHIM_DEFERRED);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the shim from the DOM, and detaches any related event
|
||||
* listeners.
|
||||
*
|
||||
* @method _destroyShim
|
||||
* @private
|
||||
*/
|
||||
_destroyShim : function() {
|
||||
if (this._shimNode) {
|
||||
this._shimNode.get(PARENT_NODE).removeChild(this._shimNode);
|
||||
this._shimNode = null;
|
||||
|
||||
this._detachStackHandles(SHIM_DEFERRED);
|
||||
this._detachStackHandles(SHIM_RESIZE);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* For IE6, synchronizes the size and position of iframe shim to that of
|
||||
* Widget bounding box which it is protecting. For all other browsers,
|
||||
* this method does not do anything.
|
||||
*
|
||||
* @method sizeShim
|
||||
*/
|
||||
sizeShim: function () {
|
||||
var shim = this._shimNode,
|
||||
node = this._stackNode;
|
||||
|
||||
if (shim && UA.ie === 6 && this.get(VISIBLE)) {
|
||||
shim.setStyle(WIDTH, node.get(OFFSET_WIDTH) + PX);
|
||||
shim.setStyle(HEIGHT, node.get(OFFSET_HEIGHT) + PX);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a cloned shim node, using the SHIM_TEMPLATE html template, for use on a new instance.
|
||||
*
|
||||
* @method _getShimTemplate
|
||||
* @private
|
||||
* @return {Node} node A new shim Node instance.
|
||||
*/
|
||||
_getShimTemplate : function() {
|
||||
return Node.create(Stack.SHIM_TEMPLATE, this._stackNode.get(OWNER_DOCUMENT));
|
||||
}
|
||||
};
|
||||
|
||||
Y.WidgetStack = Stack;
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['widget']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/widget/widget-stdmod-min.js
vendored
Executable file
8
jssource/src_files/include/javascript/yui3/build/widget/widget-stdmod-min.js
vendored
Executable file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("widget-stdmod",function(A){var D=A.Lang,P=A.Node,c=A.NodeList,W=A.UA,C=A.Widget,B="",j="hd",h="bd",H="ft",e="header",m="body",k="footer",q="fillHeight",K="stdmod",t="px",T="Node",i="Content",o="innerHTML",d="firstChild",G="childNodes",l="createDocumentFragment",M="ownerDocument",U="contentBox",p="boundingBox",Z="height",g="offsetHeight",X="auto",J="headerContentChange",b="bodyContentChange",N="footerContentChange",R="fillHeightChange",S="HeightChange",r="contentUpdate",V="renderUI",f="bindUI",E="syncUI",Q=A.Widget.UI_SRC;function s(L){this._stdModNode=this.get(U);A.after(this._renderUIStdMod,this,V);A.after(this._bindUIStdMod,this,f);A.after(this._syncUIStdMod,this,E);}s.HEADER=e;s.BODY=m;s.FOOTER=k;s.AFTER="after";s.BEFORE="before";s.REPLACE="replace";var I=s.HEADER,a=s.BODY,O=s.FOOTER,n=s.AFTER,F=s.BEFORE;s.ATTRS={headerContent:{value:null},footerContent:{value:null},bodyContent:{value:null},fillHeight:{value:s.BODY,validator:function(L){return this._validateFillHeight(L);}}};s.HTML_PARSER={headerContent:function(L){return this._parseStdModHTML(I);},bodyContent:function(L){return this._parseStdModHTML(a);},footerContent:function(L){return this._parseStdModHTML(O);}};s.SECTION_CLASS_NAMES={header:C.getClassName(j),body:C.getClassName(h),footer:C.getClassName(H)};s.TEMPLATES={header:'<div class="'+s.SECTION_CLASS_NAMES[I]+'"></div>',body:'<div class="'+s.SECTION_CLASS_NAMES[a]+'"></div>',footer:'<div class="'+s.SECTION_CLASS_NAMES[O]+'"></div>'};s.prototype={_syncUIStdMod:function(){this._uiSetStdMod(I,this.get(I+i));this._uiSetStdMod(a,this.get(a+i));this._uiSetStdMod(O,this.get(O+i));this._uiSetFillHeight(this.get(q));},_renderUIStdMod:function(){this._stdModNode.addClass(C.getClassName(K));},_bindUIStdMod:function(){this.after(J,this._afterHeaderChange);this.after(b,this._afterBodyChange);this.after(N,this._afterFooterChange);this.after(R,this._afterFillHeightChange);this.after(S,this._fillHeight);this.after(r,this._fillHeight);},_afterHeaderChange:function(L){if(L.src!==Q){this._uiSetStdMod(I,L.newVal,L.stdModPosition);}},_afterBodyChange:function(L){if(L.src!==Q){this._uiSetStdMod(a,L.newVal,L.stdModPosition);}},_afterFooterChange:function(L){if(L.src!==Q){this._uiSetStdMod(O,L.newVal,L.stdModPosition);}},_afterFillHeightChange:function(L){this._uiSetFillHeight(L.newVal);},_validateFillHeight:function(L){return !L||L==s.BODY||L==s.HEADER||L==s.FOOTER;},_uiSetFillHeight:function(u){var Y=this.getStdModNode(u);var L=this._currFillNode;if(L&&Y!==L){L.setStyle(Z,B);}if(Y){this._currFillNode=Y;}this._fillHeight();},_fillHeight:function(){if(this.get(q)){var L=this.get(Z);if(L!=B&&L!=X){this.fillHeight(this._currFillNode);}}},_uiSetStdMod:function(v,u,L){if(u){var Y=this.getStdModNode(v)||this._renderStdMod(v);if(u instanceof P||u instanceof c){this._addNodeRef(Y,u,L);}else{this._addNodeHTML(Y,u,L);}this.set(v+i,this._getStdModContent(v),{src:Q});this.fire(r);}},_renderStdMod:function(u){var L=this.get(U),Y=this._findStdModSection(u);if(!Y){Y=this._getStdModTemplate(u);}this._insertStdModSection(L,u,Y);this[u+T]=Y;return this[u+T];},_insertStdModSection:function(L,v,u){var Y=L.get(d);if(v===O||!Y){L.appendChild(u);}else{if(v===I){L.insertBefore(u,Y);}else{var w=this[O+T];if(w){L.insertBefore(u,w);}else{L.appendChild(u);}}}},_getStdModTemplate:function(L){return P.create(s.TEMPLATES[L],this._stdModNode.get(M));},_addNodeHTML:function(u,Y,L){if(L==n){u.set(o,u.get(o)+Y);}else{if(L==F){u.set(o,Y+u.get(o));}else{u.set(o,Y);}}},_addNodeRef:function(x,v,Y){var L=true,u,w;if(Y==F){var y=x.get(d);if(y){if(v instanceof c){for(u=v.size()-1;u>=0;--u){x.insertBefore(v.item(u),y);}}else{x.insertBefore(v,y);}L=false;}}else{if(Y!=n){x.set(o,B);}}if(L){if(v instanceof c){for(u=0,w=v.size();u<w;++u){x.appendChild(v.item(u));}}else{x.appendChild(v);}}},_getPreciseHeight:function(u){var L=(u)?u.get(g):0,v="getBoundingClientRect";if(u&&u.hasMethod(v)){var Y=u.invoke(v);if(Y){L=Y.bottom-Y.top;}}return L;},_findStdModSection:function(L){return this.get(U).query("> ."+s.SECTION_CLASS_NAMES[L]);},_parseStdModHTML:function(x){var w=this._findStdModSection(x),u,Y;if(w){u=w.get(M).invoke(l);Y=w.get(G);for(var L=Y.size()-1;L>=0;L--){var v=u.get(d);if(v){u.insertBefore(Y.item(L),v);}else{u.appendChild(Y.item(L));}}return u;}return null;},_getStdModContent:function(L){return(this[L+T])?this[L+T].get(G):null;},setStdModContent:function(u,Y,L){this.set(u+i,Y,{stdModPosition:L});},getStdModNode:function(L){return this[L+T]||null;},fillHeight:function(u){if(u){var y=this.get(p),AA=[this.headerNode,this.bodyNode,this.footerNode],Y,AB=0,AC=0,x=0,w=false;for(var z=0,v=AA.length;z<v;z++){Y=AA[z];if(Y){if(Y!==u){AC+=this._getPreciseHeight(Y);}else{w=true;}}}if(w){if(W.ie||W.opera){u.setStyle(Z,0+t);}AB=parseInt(y.getComputedStyle(Z),10);if(D.isNumber(AB)){x=AB-AC;if(x>=0){u.setStyle(Z,x+t);}var L=this.get(U).get(g);if(L!=AB){x=x-(L-AB);u.setStyle(Z,x+t);}}}}}};A.WidgetStdMod=s;},"3.0.0",{requires:["widget"]});
|
||||
755
jssource/src_files/include/javascript/yui3/build/widget/widget-stdmod.js
vendored
Executable file
755
jssource/src_files/include/javascript/yui3/build/widget/widget-stdmod.js
vendored
Executable file
@@ -0,0 +1,755 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('widget-stdmod', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides standard module support for Widgets through an extension.
|
||||
*
|
||||
* @module widget-stdmod
|
||||
*/
|
||||
var L = Y.Lang,
|
||||
Node = Y.Node,
|
||||
NodeList = Y.NodeList,
|
||||
UA = Y.UA,
|
||||
Widget = Y.Widget,
|
||||
|
||||
EMPTY = "",
|
||||
HD = "hd",
|
||||
BD = "bd",
|
||||
FT = "ft",
|
||||
HEADER = "header",
|
||||
BODY = "body",
|
||||
FOOTER = "footer",
|
||||
FILL_HEIGHT = "fillHeight",
|
||||
STDMOD = "stdmod",
|
||||
|
||||
PX = "px",
|
||||
NODE_SUFFIX = "Node",
|
||||
CONTENT_SUFFIX = "Content",
|
||||
INNER_HTML = "innerHTML",
|
||||
FIRST_CHILD = "firstChild",
|
||||
CHILD_NODES = "childNodes",
|
||||
CREATE_DOCUMENT_FRAGMENT = "createDocumentFragment",
|
||||
OWNER_DOCUMENT = "ownerDocument",
|
||||
|
||||
CONTENT_BOX = "contentBox",
|
||||
BOUNDING_BOX = "boundingBox",
|
||||
|
||||
HEIGHT = "height",
|
||||
OFFSET_HEIGHT = "offsetHeight",
|
||||
AUTO = "auto",
|
||||
|
||||
HeaderChange = "headerContentChange",
|
||||
BodyChange = "bodyContentChange",
|
||||
FooterChange = "footerContentChange",
|
||||
FillHeightChange = "fillHeightChange",
|
||||
HeightChange = "HeightChange",
|
||||
ContentUpdate = "contentUpdate",
|
||||
|
||||
RENDERUI = "renderUI",
|
||||
BINDUI = "bindUI",
|
||||
SYNCUI = "syncUI",
|
||||
|
||||
UI = Y.Widget.UI_SRC;
|
||||
|
||||
/**
|
||||
* Widget extension, which can be used to add Standard Module support to the
|
||||
* base Widget class, through the <a href="Base.html#method_build">Base.build</a>
|
||||
* method.
|
||||
* <p>
|
||||
* The extension adds header, body and footer sections to the Widget's content box and
|
||||
* provides the corresponding methods and attributes to modify the contents of these sections.
|
||||
* </p>
|
||||
* @class WidgetStdMod
|
||||
* @param {Object} The user configuration object
|
||||
*/
|
||||
function StdMod(config) {
|
||||
|
||||
this._stdModNode = this.get(CONTENT_BOX);
|
||||
|
||||
Y.after(this._renderUIStdMod, this, RENDERUI);
|
||||
Y.after(this._bindUIStdMod, this, BINDUI);
|
||||
Y.after(this._syncUIStdMod, this, SYNCUI);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constant used to refer the the standard module header, in methods which expect a section specifier
|
||||
*
|
||||
* @property WidgetStdMod.HEADER
|
||||
* @static
|
||||
* @type String
|
||||
*/
|
||||
StdMod.HEADER = HEADER;
|
||||
/**
|
||||
* Constant used to refer the the standard module body, in methods which expect a section specifier
|
||||
*
|
||||
* @property WidgetStdMod.BODY
|
||||
* @static
|
||||
* @type String
|
||||
*/
|
||||
StdMod.BODY = BODY;
|
||||
/**
|
||||
* Constant used to refer the the standard module footer, in methods which expect a section specifier
|
||||
*
|
||||
* @property WidgetStdMod.FOOTER
|
||||
* @static
|
||||
* @type String
|
||||
*/
|
||||
StdMod.FOOTER = FOOTER;
|
||||
|
||||
/**
|
||||
* Constant used to specify insertion position, when adding content to sections of the standard module in
|
||||
* methods which expect a "where" argument.
|
||||
* <p>
|
||||
* Inserts new content <em>before</em> the sections existing content.
|
||||
* </p>
|
||||
* @property WidgetStdMod.AFTER
|
||||
* @static
|
||||
* @type String
|
||||
*/
|
||||
StdMod.AFTER = "after";
|
||||
|
||||
/**
|
||||
* Constant used to specify insertion position, when adding content to sections of the standard module in
|
||||
* methods which expect a "where" argument.
|
||||
* <p>
|
||||
* Inserts new content <em>before</em> the sections existing content.
|
||||
* </p>
|
||||
* @property WidgetStdMod.BEFORE
|
||||
* @static
|
||||
* @type String
|
||||
*/
|
||||
StdMod.BEFORE = "before";
|
||||
/**
|
||||
* Constant used to specify insertion position, when adding content to sections of the standard module in
|
||||
* methods which expect a "where" argument.
|
||||
* <p>
|
||||
* <em>Replaces</em> the sections existing content, with new content.
|
||||
* </p>
|
||||
* @property WidgetStdMod.REPLACE
|
||||
* @static
|
||||
* @type String
|
||||
*/
|
||||
StdMod.REPLACE = "replace";
|
||||
|
||||
var STD_HEADER = StdMod.HEADER,
|
||||
STD_BODY = StdMod.BODY,
|
||||
STD_FOOTER = StdMod.FOOTER,
|
||||
AFTER = StdMod.AFTER,
|
||||
BEFORE = StdMod.BEFORE;
|
||||
|
||||
/**
|
||||
* Static property used to define the default attribute
|
||||
* configuration introduced by WidgetStdMod.
|
||||
*
|
||||
* @property WidgetStdMod.ATTRS
|
||||
* @type Object
|
||||
* @static
|
||||
*/
|
||||
StdMod.ATTRS = {
|
||||
|
||||
/**
|
||||
* @attribute headerContent
|
||||
* @type {String | Node}
|
||||
* @default undefined
|
||||
* @description The content to be added to the header section. This will replace any existing content
|
||||
* in the header. If you want to append, or insert new content, use the <a href="#method_setStdModContent">setStdModContent</a> method.
|
||||
*/
|
||||
headerContent: {
|
||||
value:null
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute footerContent
|
||||
* @type {String | Node}
|
||||
* @default undefined
|
||||
* @description The content to be added to the footer section. This will replace any existing content
|
||||
* in the footer. If you want to append, or insert new content, use the <a href="#method_setStdModContent">setStdModContent</a> method.
|
||||
*/
|
||||
footerContent: {
|
||||
value:null
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute bodyContent
|
||||
* @type {String | Node}
|
||||
* @default undefined
|
||||
* @description The content to be added to the body section. This will replace any existing content
|
||||
* in the body. If you want to append, or insert new content, use the <a href="#method_setStdModContent">setStdModContent</a> method.
|
||||
*/
|
||||
bodyContent: {
|
||||
value:null
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute fillHeight
|
||||
* @type {String}
|
||||
* @default WidgetStdMod.BODY
|
||||
* @description The section (WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER) which should be resized to fill the height of the standard module, when a
|
||||
* height is set on the Widget. If a height is not set on the widget, then all sections are sized based on
|
||||
* their content.
|
||||
*/
|
||||
fillHeight: {
|
||||
value: StdMod.BODY,
|
||||
validator: function(val) {
|
||||
return this._validateFillHeight(val);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The HTML parsing rules for the WidgetStdMod class.
|
||||
*
|
||||
* @property WidgetStdMod.HTML_PARSER
|
||||
* @static
|
||||
* @type Object
|
||||
*/
|
||||
StdMod.HTML_PARSER = {
|
||||
headerContent: function(contentBox) {
|
||||
return this._parseStdModHTML(STD_HEADER);
|
||||
},
|
||||
|
||||
bodyContent: function(contentBox) {
|
||||
return this._parseStdModHTML(STD_BODY);
|
||||
},
|
||||
|
||||
footerContent : function(contentBox) {
|
||||
return this._parseStdModHTML(STD_FOOTER);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Static hash of default class names used for the header,
|
||||
* body and footer sections of the standard module, keyed by
|
||||
* the section identifier (WidgetStdMod.STD_HEADER, WidgetStdMod.STD_BODY, WidgetStdMod.STD_FOOTER)
|
||||
*
|
||||
* @property WidgetStdMod.SECTION_CLASS_NAMES
|
||||
* @static
|
||||
* @type Object
|
||||
*/
|
||||
StdMod.SECTION_CLASS_NAMES = {
|
||||
header: Widget.getClassName(HD),
|
||||
body: Widget.getClassName(BD),
|
||||
footer: Widget.getClassName(FT)
|
||||
};
|
||||
|
||||
/**
|
||||
* The template HTML strings for each of the standard module sections. Section entries are keyed by the section constants,
|
||||
* WidgetStdMod.HEADER, WidgetStdMod.BODY, WidgetStdMod.FOOTER, and contain the HTML to be added for each section.
|
||||
* e.g.
|
||||
* <pre>
|
||||
* {
|
||||
* header : '<div class="yui-widget-hd"></div>',
|
||||
* body : '<div class="yui-widget-bd"></div>',
|
||||
* footer : '<div class="yui-widget-ft"></div>'
|
||||
* }
|
||||
* </pre>
|
||||
* @property WidgetStdMod.TEMPLATES
|
||||
* @type Object
|
||||
* @static
|
||||
*/
|
||||
StdMod.TEMPLATES = {
|
||||
header : '<div class="' + StdMod.SECTION_CLASS_NAMES[STD_HEADER] + '"></div>',
|
||||
body : '<div class="' + StdMod.SECTION_CLASS_NAMES[STD_BODY] + '"></div>',
|
||||
footer : '<div class="' + StdMod.SECTION_CLASS_NAMES[STD_FOOTER] + '"></div>'
|
||||
};
|
||||
|
||||
StdMod.prototype = {
|
||||
|
||||
/**
|
||||
* Synchronizes the UI to match the Widgets standard module state.
|
||||
* <p>
|
||||
* This method is invoked after syncUI is invoked for the Widget class
|
||||
* using YUI's aop infrastructure.
|
||||
* </p>
|
||||
* @method _syncUIStdMod
|
||||
* @protected
|
||||
*/
|
||||
_syncUIStdMod : function() {
|
||||
this._uiSetStdMod(STD_HEADER, this.get(STD_HEADER + CONTENT_SUFFIX));
|
||||
this._uiSetStdMod(STD_BODY, this.get(STD_BODY + CONTENT_SUFFIX));
|
||||
this._uiSetStdMod(STD_FOOTER, this.get(STD_FOOTER + CONTENT_SUFFIX));
|
||||
this._uiSetFillHeight(this.get(FILL_HEIGHT));
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates/Initializes the DOM for standard module support.
|
||||
* <p>
|
||||
* This method is invoked after renderUI is invoked for the Widget class
|
||||
* using YUI's aop infrastructure.
|
||||
* </p>
|
||||
* @method _renderUIStdMod
|
||||
* @protected
|
||||
*/
|
||||
_renderUIStdMod : function() {
|
||||
this._stdModNode.addClass(Widget.getClassName(STDMOD));
|
||||
},
|
||||
|
||||
/**
|
||||
* Binds event listeners responsible for updating the UI state in response to
|
||||
* Widget standard module related state changes.
|
||||
* <p>
|
||||
* This method is invoked after bindUI is invoked for the Widget class
|
||||
* using YUI's aop infrastructure.
|
||||
* </p>
|
||||
* @method _bindUIStdMod
|
||||
* @protected
|
||||
*/
|
||||
_bindUIStdMod : function() {
|
||||
this.after(HeaderChange, this._afterHeaderChange);
|
||||
this.after(BodyChange, this._afterBodyChange);
|
||||
this.after(FooterChange, this._afterFooterChange);
|
||||
|
||||
this.after(FillHeightChange, this._afterFillHeightChange);
|
||||
this.after(HeightChange, this._fillHeight);
|
||||
this.after(ContentUpdate, this._fillHeight);
|
||||
},
|
||||
|
||||
/**
|
||||
* Default attribute change listener for the headerContent attribute, responsible
|
||||
* for updating the UI, in response to attribute changes.
|
||||
*
|
||||
* @method _afterHeaderChange
|
||||
* @protected
|
||||
* @param {EventFacade} e The event facade for the attribute change
|
||||
*/
|
||||
_afterHeaderChange : function(e) {
|
||||
if (e.src !== UI) {
|
||||
this._uiSetStdMod(STD_HEADER, e.newVal, e.stdModPosition);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Default attribute change listener for the bodyContent attribute, responsible
|
||||
* for updating the UI, in response to attribute changes.
|
||||
*
|
||||
* @method _afterBodyChange
|
||||
* @protected
|
||||
* @param {EventFacade} e The event facade for the attribute change
|
||||
*/
|
||||
_afterBodyChange : function(e) {
|
||||
if (e.src !== UI) {
|
||||
this._uiSetStdMod(STD_BODY, e.newVal, e.stdModPosition);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Default attribute change listener for the footerContent attribute, responsible
|
||||
* for updating the UI, in response to attribute changes.
|
||||
*
|
||||
* @method _afterFooterChange
|
||||
* @protected
|
||||
* @param {EventFacade} e The event facade for the attribute change
|
||||
*/
|
||||
_afterFooterChange : function(e) {
|
||||
if (e.src !== UI) {
|
||||
this._uiSetStdMod(STD_FOOTER, e.newVal, e.stdModPosition);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Default attribute change listener for the fillHeight attribute, responsible
|
||||
* for updating the UI, in response to attribute changes.
|
||||
*
|
||||
* @method _afterFillHeightChange
|
||||
* @protected
|
||||
* @param {EventFacade} e The event facade for the attribute change
|
||||
*/
|
||||
_afterFillHeightChange: function (e) {
|
||||
this._uiSetFillHeight(e.newVal);
|
||||
},
|
||||
|
||||
/**
|
||||
* Default validator for the fillHeight attribute. Verifies that the
|
||||
* value set is a valid section specifier - one of WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER,
|
||||
* or a falsey value if fillHeight is to be disabled.
|
||||
*
|
||||
* @method _validateFillHeight
|
||||
* @protected
|
||||
* @param {String} val The section which should be setup to fill height, or false/null to disable fillHeight
|
||||
* @return true if valid, false if not
|
||||
*/
|
||||
_validateFillHeight : function(val) {
|
||||
return !val || val == StdMod.BODY || val == StdMod.HEADER || val == StdMod.FOOTER;
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the rendered UI, to resize the provided section so that the standard module fills out
|
||||
* the specified widget height. Note: This method does not check whether or not a height is set
|
||||
* on the Widget.
|
||||
*
|
||||
* @method _uiSetFillHeight
|
||||
* @protected
|
||||
* @param {String} fillSection A valid section specifier - one of WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER
|
||||
*/
|
||||
_uiSetFillHeight : function(fillSection) {
|
||||
var fillNode = this.getStdModNode(fillSection);
|
||||
var currNode = this._currFillNode;
|
||||
|
||||
if (currNode && fillNode !== currNode){
|
||||
currNode.setStyle(HEIGHT, EMPTY);
|
||||
}
|
||||
|
||||
if (fillNode) {
|
||||
this._currFillNode = fillNode;
|
||||
}
|
||||
|
||||
this._fillHeight();
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the rendered UI, to resize the current section specified by the fillHeight attribute, so
|
||||
* that the standard module fills out the Widget height. If a height has not been set on Widget,
|
||||
* the section is not resized (height is set to "auto").
|
||||
*
|
||||
* @method _fillHeight
|
||||
* @private
|
||||
*/
|
||||
_fillHeight : function() {
|
||||
if (this.get(FILL_HEIGHT)) {
|
||||
var height = this.get(HEIGHT);
|
||||
if (height != EMPTY && height != AUTO) {
|
||||
this.fillHeight(this._currFillNode);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the rendered UI, adding the provided content (either an HTML string, or node reference),
|
||||
* to the specified section. The content is either added before, after or replaces existing content
|
||||
* in the section, based on the value of the <code>where</code> argument.
|
||||
*
|
||||
* @method _uiSetStdMod
|
||||
* @protected
|
||||
*
|
||||
* @param {String} section The section to be updated. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
|
||||
* @param {String | Node} content The new content (either as an HTML string, or Node reference) to add to the section
|
||||
* @param {String} where Optional. Either WidgetStdMod.AFTER, WidgetStdMod.BEFORE or WidgetStdMod.REPLACE.
|
||||
* If not provided, the content will replace existing content in the section.
|
||||
*/
|
||||
_uiSetStdMod : function(section, content, where) {
|
||||
if (content) {
|
||||
var node = this.getStdModNode(section) || this._renderStdMod(section);
|
||||
if (content instanceof Node || content instanceof NodeList) {
|
||||
this._addNodeRef(node, content, where);
|
||||
} else {
|
||||
this._addNodeHTML(node, content, where);
|
||||
}
|
||||
this.set(section + CONTENT_SUFFIX, this._getStdModContent(section), {src:UI});
|
||||
this.fire(ContentUpdate);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates the DOM node for the given section, and inserts it into the correct location in the contentBox.
|
||||
*
|
||||
* @method _renderStdMod
|
||||
* @protected
|
||||
* @param {String} section The section to create/render. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
|
||||
* @return {Node} A reference to the added section node
|
||||
*/
|
||||
_renderStdMod : function(section) {
|
||||
|
||||
var contentBox = this.get(CONTENT_BOX),
|
||||
sectionNode = this._findStdModSection(section);
|
||||
|
||||
if (!sectionNode) {
|
||||
sectionNode = this._getStdModTemplate(section);
|
||||
}
|
||||
|
||||
this._insertStdModSection(contentBox, section, sectionNode);
|
||||
|
||||
this[section + NODE_SUFFIX] = sectionNode;
|
||||
return this[section + NODE_SUFFIX];
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper method to insert the Node for the given section into the correct location in the contentBox.
|
||||
*
|
||||
* @method _insertStdModSection
|
||||
* @private
|
||||
* @param {Node} contentBox A reference to the Widgets content box.
|
||||
* @param {String} section The section to create/render. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
|
||||
* @param {Node} sectionNode The Node for the section.
|
||||
*/
|
||||
_insertStdModSection : function(contentBox, section, sectionNode) {
|
||||
var fc = contentBox.get(FIRST_CHILD);
|
||||
|
||||
if (section === STD_FOOTER || !fc) {
|
||||
contentBox.appendChild(sectionNode);
|
||||
} else {
|
||||
if (section === STD_HEADER) {
|
||||
contentBox.insertBefore(sectionNode, fc);
|
||||
} else {
|
||||
// BODY
|
||||
var footer = this[STD_FOOTER + NODE_SUFFIX];
|
||||
if (footer) {
|
||||
contentBox.insertBefore(sectionNode, footer);
|
||||
} else {
|
||||
contentBox.appendChild(sectionNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets a new Node reference for the given standard module section, by cloning
|
||||
* the stored template node.
|
||||
*
|
||||
* @method _getStdModTemplate
|
||||
* @protected
|
||||
* @param {String} section The section to create a new node for. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
|
||||
* @return {Node} The new Node instance for the section
|
||||
*/
|
||||
_getStdModTemplate : function(section) {
|
||||
return Node.create(StdMod.TEMPLATES[section], this._stdModNode.get(OWNER_DOCUMENT));
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper method to add the given HTML string to the node reference provided.
|
||||
* The HTML is added either before, after or replaces the existing node content
|
||||
* based on the value of the <code>where</code> argument.
|
||||
*
|
||||
* @method _addNodeHTML
|
||||
* @private
|
||||
*
|
||||
* @param {Node} node The section Node to be updated.
|
||||
* @param {String} html The new content HTML string to be added to the section Node.
|
||||
* @param {String} where Optional. Either WidgetStdMod.AFTER, WidgetStdMod.BEFORE or WidgetStdMod.REPLACE.
|
||||
* If not provided, the content will replace Nodes existing content.
|
||||
*/
|
||||
_addNodeHTML : function(node, html, where) {
|
||||
if (where == AFTER) {
|
||||
node.set(INNER_HTML, node.get(INNER_HTML) + html);
|
||||
} else if (where == BEFORE) {
|
||||
node.set(INNER_HTML, html + node.get(INNER_HTML));
|
||||
} else {
|
||||
node.set(INNER_HTML, html);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper method to add nodes, to another node.
|
||||
* The child node(s) are added either before, after or replaces the existing node content
|
||||
* based on the value of the <code>where</code> argument.
|
||||
*
|
||||
* @method _addNodeRef
|
||||
* @private
|
||||
*
|
||||
* @param {Node} node The section Node to be updated.
|
||||
* @param {Node|NodeList} children The new content Node, or NodeList to be added to section Node provided.
|
||||
* @param {String} where Optional. Either WidgetStdMod.AFTER, WidgetStdMod.BEFORE or WidgetStdMod.REPLACE.
|
||||
* If not provided, the content will replace existing content in the Node.
|
||||
*/
|
||||
_addNodeRef : function(node, children, where) {
|
||||
var append = true,
|
||||
i, s;
|
||||
|
||||
if (where == BEFORE) {
|
||||
var n = node.get(FIRST_CHILD);
|
||||
if (n) {
|
||||
if (children instanceof NodeList) {
|
||||
for (i = children.size() - 1; i >=0; --i) {
|
||||
node.insertBefore(children.item(i), n);
|
||||
}
|
||||
} else {
|
||||
node.insertBefore(children, n);
|
||||
}
|
||||
append = false;
|
||||
}
|
||||
} else if (where != AFTER) { // replace
|
||||
node.set(INNER_HTML, EMPTY);
|
||||
}
|
||||
|
||||
if (append) {
|
||||
if (children instanceof NodeList) {
|
||||
for (i = 0, s = children.size(); i < s; ++i) {
|
||||
node.appendChild(children.item(i));
|
||||
}
|
||||
} else {
|
||||
node.appendChild(children);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper method to obtain the precise height of the node provided, including padding and border.
|
||||
* The height could be a sub-pixel value for certain browsers, such as Firefox 3.
|
||||
*
|
||||
* @method _getPreciseHeight
|
||||
* @private
|
||||
* @param {Node} node The node for which the precise height is required.
|
||||
* @return {Number} The height of the Node including borders and padding, possibly a float.
|
||||
*/
|
||||
_getPreciseHeight : function(node) {
|
||||
var height = (node) ? node.get(OFFSET_HEIGHT) : 0,
|
||||
getBCR = "getBoundingClientRect";
|
||||
|
||||
if (node && node.hasMethod(getBCR)) {
|
||||
var preciseRegion = node.invoke(getBCR);
|
||||
if (preciseRegion) {
|
||||
height = preciseRegion.bottom - preciseRegion.top;
|
||||
}
|
||||
}
|
||||
|
||||
return height;
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper method to query the rendered contents of the contentBox to find the
|
||||
* node for the given section if it exists.
|
||||
*
|
||||
* @method _findStdModSection
|
||||
* @private
|
||||
* @param {String} section The section for which the render Node is to be found. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
|
||||
* @return {Node} The rendered node for the given section, or null if not found.
|
||||
*/
|
||||
_findStdModSection: function(section) {
|
||||
return this.get(CONTENT_BOX).query("> ." + StdMod.SECTION_CLASS_NAMES[section]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Utility method, used by WidgetStdMods HTML_PARSER implementation
|
||||
* to extract data for each section from markup.
|
||||
*
|
||||
* @method _parseStdModHTML
|
||||
* @private
|
||||
* @param {String} section
|
||||
* @return {String} Inner HTML string with the contents of the section
|
||||
*/
|
||||
_parseStdModHTML : function(section) {
|
||||
var node = this._findStdModSection(section),
|
||||
docFrag, children;
|
||||
|
||||
if (node) {
|
||||
docFrag = node.get(OWNER_DOCUMENT).invoke(CREATE_DOCUMENT_FRAGMENT);
|
||||
children = node.get(CHILD_NODES);
|
||||
|
||||
for (var i = children.size() - 1; i >= 0; i--) {
|
||||
var fc = docFrag.get(FIRST_CHILD);
|
||||
if (fc) {
|
||||
docFrag.insertBefore(children.item(i), fc);
|
||||
} else {
|
||||
docFrag.appendChild(children.item(i));
|
||||
}
|
||||
}
|
||||
|
||||
return docFrag;
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieves the child nodes (content) of a standard module section
|
||||
*
|
||||
* @method _getStdModContent
|
||||
* @private
|
||||
* @param {String} section The standard module section whose child nodes are to be retrieved. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
|
||||
* @return {Node} The child node collection of the standard module section.
|
||||
*/
|
||||
_getStdModContent : function(section) {
|
||||
return (this[section + NODE_SUFFIX]) ? this[section + NODE_SUFFIX].get(CHILD_NODES) : null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the body section of the standard module with the content provided (either an HTML string, or node reference).
|
||||
* <p>
|
||||
* This method can be used instead of the corresponding section content attribute if you'd like to retain the current content of the section,
|
||||
* and insert content before or after it, by specifying the <code>where</code> argument.
|
||||
* </p>
|
||||
* @method setStdModContent
|
||||
* @param {String} section The standard module section whose content is to be updated. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
|
||||
* @param {String | Node} content The content to be added, either an HTML string or a Node reference.
|
||||
* @param {String} where Optional. Either WidgetStdMod.AFTER, WidgetStdMod.BEFORE or WidgetStdMod.REPLACE.
|
||||
* If not provided, the content will replace existing content in the section.
|
||||
*/
|
||||
setStdModContent : function(section, content, where) {
|
||||
this.set(section + CONTENT_SUFFIX, content, {stdModPosition:where});
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the node reference for the given section. Note: The DOM is not queried for the node reference. The reference
|
||||
* stored by the widget instance is returned if set.
|
||||
*
|
||||
* @method getStdModNode
|
||||
* @param {String} section The section whose node reference is required. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
|
||||
* @return {Node} The node reference for the section, or null if not set.
|
||||
*/
|
||||
getStdModNode : function(section) {
|
||||
return this[section + NODE_SUFFIX] || null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the height on the provided header, body or footer element to
|
||||
* fill out the height of the Widget. It determines the height of the
|
||||
* widgets bounding box, based on it's configured height value, and
|
||||
* sets the height of the provided section to fill out any
|
||||
* space remaining after the other standard module section heights
|
||||
* have been accounted for.
|
||||
*
|
||||
* <p><strong>NOTE:</strong> This method is not designed to work if an explicit
|
||||
* height has not been set on the Widget, since for an "auto" height Widget,
|
||||
* the heights of the header/body/footer will drive the height of the Widget.</p>
|
||||
*
|
||||
* @method fillHeight
|
||||
* @param {Node} node The node which should be resized to fill out the height
|
||||
* of the Widget bounding box. Should be a standard module section node which belongs
|
||||
* to the widget.
|
||||
*/
|
||||
fillHeight : function(node) {
|
||||
if (node) {
|
||||
var boundingBox = this.get(BOUNDING_BOX),
|
||||
stdModNodes = [this.headerNode, this.bodyNode, this.footerNode],
|
||||
stdModNode,
|
||||
total = 0,
|
||||
filled = 0,
|
||||
remaining = 0,
|
||||
validNode = false;
|
||||
|
||||
for (var i = 0, l = stdModNodes.length; i < l; i++) {
|
||||
stdModNode = stdModNodes[i];
|
||||
if (stdModNode) {
|
||||
if (stdModNode !== node) {
|
||||
filled += this._getPreciseHeight(stdModNode);
|
||||
} else {
|
||||
validNode = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (validNode) {
|
||||
if (UA.ie || UA.opera) {
|
||||
// Need to set height to 0, to allow height to be reduced
|
||||
node.setStyle(HEIGHT, 0 + PX);
|
||||
}
|
||||
|
||||
total = parseInt(boundingBox.getComputedStyle(HEIGHT), 10);
|
||||
if (L.isNumber(total)) {
|
||||
remaining = total - filled;
|
||||
|
||||
if (remaining >= 0) {
|
||||
node.setStyle(HEIGHT, remaining + PX);
|
||||
}
|
||||
|
||||
// Re-adjust height if required, to account for el padding and border
|
||||
var offsetHeight = this.get(CONTENT_BOX).get(OFFSET_HEIGHT);
|
||||
if (offsetHeight != total) {
|
||||
remaining = remaining - (offsetHeight - total);
|
||||
node.setStyle(HEIGHT, remaining + PX);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Y.WidgetStdMod = StdMod;
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['widget']});
|
||||
1329
jssource/src_files/include/javascript/yui3/build/widget/widget.js
vendored
Executable file
1329
jssource/src_files/include/javascript/yui3/build/widget/widget.js
vendored
Executable file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user