From 8436e8b94b97ff37c0cf9702f763fd6c74c73b54 Mon Sep 17 00:00:00 2001
From: nicolasconnault The Button Control enables the creation of rich, graphical
+* buttons that function like traditional HTML form buttons. Unlike
+* tradition HTML form buttons, buttons created with the Button Control can have
+* a label that is different from its value. With the inclusion of the optional
+* Menu Control, the Button Control can also be
+* used to create menu buttons and split buttons, controls that are not
+* available natively in HTML. The Button Control can also be thought of as a
+* way to create more visually engaging implementations of the browser's
+* default radio-button and check-box controls. The Button Control supports the following types: 0){F=H-1;do{this._buttons[F].set("disabled",G);}while(F--);}},_onKeyDown:function(K){var G=B.getTarget(K),I=B.getCharCode(K),H=G.parentNode.parentNode.id,J=E[H],F=-1;if(I==37||I==38){F=(J.index===0)?(this._buttons.length-1):(J.index-1);}else{if(I==39||I==40){F=(J.index===(this._buttons.length-1))?0:(J.index+1);}}if(F>-1){this.check(F);this.getButton(F).focus();
+}},_onAppendTo:function(H){var I=this._buttons,G=I.length,F;for(F=0;F The Button Control enables the creation of rich, graphical
+* buttons that function like traditional HTML form buttons. Unlike
+* tradition HTML form buttons, buttons created with the Button Control can have
+* a label that is different from its value. With the inclusion of the optional
+* Menu Control, the Button Control can also be
+* used to create menu buttons and split buttons, controls that are not
+* available natively in HTML. The Button Control can also be thought of as a
+* way to create more visually engaging implementations of the browser's
+* default radio-button and check-box controls. The Button Control supports the following types:
+ * Fix approach and original findings are available here:
+ * http://brianary.blogspot.com/2006/03/safari-date-bug.html
+ *
+ * NOTE:Validation on argument values is not performed. It is the caller's responsibility to ensure
+ * arguments are valid as per the ECMAScript-262 Date object specification for the new Date(year, month[, date]) constructor.
+ * To construct the placeholder for the calendar widget, the code is as
* follows:
*
+* NOTE: As of 2.4.0, the constructor's ID argument is optional.
+* The Calendar can be constructed by simply providing a container ID string,
+* or a reference to a container DIV HTMLElement (the element needs to exist
+* in the document).
+*
+* E.g.:
+*
+ *
+ *
+ *
+ * @property asyncMode
+ * @type String
+ * @default "allowAll"
+ */
+YAHOO.widget.DS_ScriptNode.prototype.asyncMode = "allowAll";
+
+/**
+ * Callback string parameter name sent to scriptURI. For instance, requests will be
+ * sent to <scriptURI>?<scriptCallbackParam>=callbackFunction
+ *
+ * @property scriptCallbackParam
+ * @type String
+ * @default "callback"
+ */
+YAHOO.widget.DS_ScriptNode.prototype.scriptCallbackParam = "callback";
+
+/**
+ * Global array of callback functions, one for each request sent.
+ *
+ * @property callbacks
+ * @type Function[]
+ * @static
+ */
+YAHOO.widget.DS_ScriptNode.callbacks = [];
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Unique ID to track requests.
+ *
+ * @property _nId
+ * @type Number
+ * @private
+ * @static
+ */
+YAHOO.widget.DS_ScriptNode._nId = 0;
+
+/**
+ * Counter for pending requests. When this is 0, it is safe to purge callbacks
+ * array.
+ *
+ * @property _nPending
+ * @type Number
+ * @private
+ * @static
+ */
+YAHOO.widget.DS_ScriptNode._nPending = 0;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Queries the live data source. Results are passed back to a callback function.
+ *
+ * @method doQuery
+ * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
+ * @param sQuery {String} Query string.
+ * @param oParent {Object} The object instance that has requested data.
+ */
+YAHOO.widget.DS_ScriptNode.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
+ var oSelf = this;
+
+ // If there are no global pending requests, it is safe to purge global callback stack and global counter
+ if(YAHOO.widget.DS_ScriptNode._nPending === 0) {
+ YAHOO.widget.DS_ScriptNode.callbacks = [];
+ YAHOO.widget.DS_ScriptNode._nId = 0;
+ }
+
+ // ID for this request
+ var id = YAHOO.widget.DS_ScriptNode._nId;
+ YAHOO.widget.DS_ScriptNode._nId++;
+
+ // Dynamically add handler function with a closure to the callback stack
+ YAHOO.widget.DS_ScriptNode.callbacks[id] = function(oResponse) {
+ if((oSelf.asyncMode !== "ignoreStaleResponses")||
+ (id === YAHOO.widget.DS_ScriptNode.callbacks.length-1)) { // Must ignore stale responses
+ oSelf.handleResponse(oResponse, oCallbackFn, sQuery, oParent);
+ }
+ else {
+ YAHOO.log("DataSource ignored stale response for " + sQuery, "info", oSelf.toString());
+ }
+
+ delete YAHOO.widget.DS_ScriptNode.callbacks[id];
+ };
+
+ // We are now creating a request
+ YAHOO.widget.DS_ScriptNode._nPending++;
+
+ var sUri = this.scriptURI+"&"+ this.scriptQueryParam+"="+sQuery+"&"+
+ this.scriptCallbackParam+"=YAHOO.widget.DS_ScriptNode.callbacks["+id+"]";
+ YAHOO.log("DataSource is querying URL " + sUri, "info", this.toString());
+ this.getUtility.script(sUri,
+ {autopurge:true,
+ onsuccess:YAHOO.widget.DS_ScriptNode._bumpPendingDown,
+ onfail:YAHOO.widget.DS_ScriptNode._bumpPendingDown});
+};
+
+/**
+ * Parses JSON response data into an array of result objects and passes it to
+ * the callback function.
+ *
+ * @method handleResponse
+ * @param oResponse {Object} The raw response data to parse.
+ * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
+ * @param sQuery {String} Query string.
+ * @param oParent {Object} The object instance that has requested data.
+ */
+YAHOO.widget.DS_ScriptNode.prototype.handleResponse = function(oResponse, oCallbackFn, sQuery, oParent) {
+ var aSchema = this.schema;
+ var aResults = [];
+ var bError = false;
+
+ var jsonList, jsonObjParsed;
+
+ // Parse the JSON response as a string
+ try {
+ // Grab the object member that contains an array of all reponses...
+ // ...eval is necessary here since aSchema[0] is of unknown depth
+ jsonList = eval("(oResponse." + aSchema[0]+")");
+ }
+ catch(e) {
+ bError = true;
+ }
+
+ if(!jsonList) {
+ bError = true;
+ jsonList = [];
+ }
+
+ else if(!YAHOO.lang.isArray(jsonList)) {
+ jsonList = [jsonList];
+ }
+
+ // Loop through the array of all responses...
+ for(var i = jsonList.length-1; i >= 0 ; i--) {
+ var aResultItem = [];
+ var jsonResult = jsonList[i];
+ // ...and loop through each data field value of each response
+ for(var j = aSchema.length-1; j >= 1 ; j--) {
+ // ...and capture data into an array mapped according to the schema...
+ var dataFieldValue = jsonResult[aSchema[j]];
+ if(!dataFieldValue) {
+ dataFieldValue = "";
+ }
+ //YAHOO.log("data: " + i + " value:" +j+" = "+dataFieldValue,"debug",this.toString());
+ aResultItem.unshift(dataFieldValue);
+ }
+ // If schema isn't well defined, pass along the entire result object
+ if(aResultItem.length == 1) {
+ aResultItem.push(jsonResult);
+ }
+ // Capture the array of data field values in an array of results
+ aResults.unshift(aResultItem);
+ }
+
+ if(bError) {
+ aResults = null;
+ }
+
+ if(aResults === null) {
+ this.dataErrorEvent.fire(this, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATAPARSE);
+ YAHOO.log(YAHOO.widget.DataSource.ERROR_DATAPARSE, "error", this.toString());
+ aResults = [];
+ }
+ else {
+ var resultObj = {};
+ resultObj.query = decodeURIComponent(sQuery);
+ resultObj.results = aResults;
+ this._addCacheElem(resultObj);
+
+ this.getResultsEvent.fire(this, oParent, sQuery, aResults);
+ YAHOO.log("Results returned for query \"" + sQuery + "\": " +
+ YAHOO.lang.dump(aResults), "info", this.toString());
+ }
+
+ oCallbackFn(sQuery, aResults, oParent);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Any success/failure response should decrement counter.
+ *
+ * @method _bumpPendingDown
+ * @private
+ */
+YAHOO.widget.DS_ScriptNode._bumpPendingDown = function() {
+ YAHOO.widget.DS_ScriptNode._nPending--;
+};
+
+
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
@@ -3130,6 +3492,7 @@ YAHOO.widget.DS_JSFunction.prototype.doQuery = function(oCallbackFn, sQuery, oPa
return;
};
+
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
@@ -3250,4 +3613,4 @@ YAHOO.widget.DS_JSArray.prototype.doQuery = function(oCallbackFn, sQuery, oParen
oCallbackFn(sQuery, aResults, oParent);
};
-YAHOO.register("autocomplete", YAHOO.widget.AutoComplete, {version: "2.3.0", build: "442"});
+YAHOO.register("autocomplete", YAHOO.widget.AutoComplete, {version: "2.5.0", build: "895"});
diff --git a/lib/yui/autocomplete/autocomplete-min.js b/lib/yui/autocomplete/autocomplete-min.js
index d877c981f5..77eacceb94 100755
--- a/lib/yui/autocomplete/autocomplete-min.js
+++ b/lib/yui/autocomplete/autocomplete-min.js
@@ -1,191 +1,12 @@
/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Copyright (c) 2008, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
+version: 2.5.0
*/
-
-YAHOO.widget.AutoComplete=function(elInput,elContainer,oDataSource,oConfigs){if(elInput&&elContainer&&oDataSource){if(oDataSource instanceof YAHOO.widget.DataSource){this.dataSource=oDataSource;}
-else{return;}
-if(YAHOO.util.Dom.inDocument(elInput)){if(YAHOO.lang.isString(elInput)){this._sName="instance"+YAHOO.widget.AutoComplete._nIndex+" "+elInput;this._oTextbox=document.getElementById(elInput);}
-else{this._sName=(elInput.id)?"instance"+YAHOO.widget.AutoComplete._nIndex+" "+elInput.id:"instance"+YAHOO.widget.AutoComplete._nIndex;this._oTextbox=elInput;}
-YAHOO.util.Dom.addClass(this._oTextbox,"yui-ac-input");}
-else{return;}
-if(YAHOO.util.Dom.inDocument(elContainer)){if(YAHOO.lang.isString(elContainer)){this._oContainer=document.getElementById(elContainer);}
-else{this._oContainer=elContainer;}
-if(this._oContainer.style.display=="none"){}
-var elParent=this._oContainer.parentNode;var elTag=elParent.tagName.toLowerCase();while(elParent&&(elParent!="document")){if(elTag=="div"){YAHOO.util.Dom.addClass(elParent,"yui-ac");break;}
-else{elParent=elParent.parentNode;elTag=elParent.tagName.toLowerCase();}}
-if(elTag!="div"){}}
-else{return;}
-if(oConfigs&&(oConfigs.constructor==Object)){for(var sConfig in oConfigs){if(sConfig){this[sConfig]=oConfigs[sConfig];}}}
-this._initContainer();this._initProps();this._initList();this._initContainerHelpers();var oSelf=this;var oTextbox=this._oTextbox;var oContent=this._oContainer._oContent;YAHOO.util.Event.addListener(oTextbox,"keyup",oSelf._onTextboxKeyUp,oSelf);YAHOO.util.Event.addListener(oTextbox,"keydown",oSelf._onTextboxKeyDown,oSelf);YAHOO.util.Event.addListener(oTextbox,"focus",oSelf._onTextboxFocus,oSelf);YAHOO.util.Event.addListener(oTextbox,"blur",oSelf._onTextboxBlur,oSelf);YAHOO.util.Event.addListener(oContent,"mouseover",oSelf._onContainerMouseover,oSelf);YAHOO.util.Event.addListener(oContent,"mouseout",oSelf._onContainerMouseout,oSelf);YAHOO.util.Event.addListener(oContent,"scroll",oSelf._onContainerScroll,oSelf);YAHOO.util.Event.addListener(oContent,"resize",oSelf._onContainerResize,oSelf);if(oTextbox.form){YAHOO.util.Event.addListener(oTextbox.form,"submit",oSelf._onFormSubmit,oSelf);}
-YAHOO.util.Event.addListener(oTextbox,"keypress",oSelf._onTextboxKeyPress,oSelf);this.textboxFocusEvent=new YAHOO.util.CustomEvent("textboxFocus",this);this.textboxKeyEvent=new YAHOO.util.CustomEvent("textboxKey",this);this.dataRequestEvent=new YAHOO.util.CustomEvent("dataRequest",this);this.dataReturnEvent=new YAHOO.util.CustomEvent("dataReturn",this);this.dataErrorEvent=new YAHOO.util.CustomEvent("dataError",this);this.containerExpandEvent=new YAHOO.util.CustomEvent("containerExpand",this);this.typeAheadEvent=new YAHOO.util.CustomEvent("typeAhead",this);this.itemMouseOverEvent=new YAHOO.util.CustomEvent("itemMouseOver",this);this.itemMouseOutEvent=new YAHOO.util.CustomEvent("itemMouseOut",this);this.itemArrowToEvent=new YAHOO.util.CustomEvent("itemArrowTo",this);this.itemArrowFromEvent=new YAHOO.util.CustomEvent("itemArrowFrom",this);this.itemSelectEvent=new YAHOO.util.CustomEvent("itemSelect",this);this.unmatchedItemSelectEvent=new YAHOO.util.CustomEvent("unmatchedItemSelect",this);this.selectionEnforceEvent=new YAHOO.util.CustomEvent("selectionEnforce",this);this.containerCollapseEvent=new YAHOO.util.CustomEvent("containerCollapse",this);this.textboxBlurEvent=new YAHOO.util.CustomEvent("textboxBlur",this);oTextbox.setAttribute("autocomplete","off");YAHOO.widget.AutoComplete._nIndex++;}
-else{}};YAHOO.widget.AutoComplete.prototype.dataSource=null;YAHOO.widget.AutoComplete.prototype.minQueryLength=1;YAHOO.widget.AutoComplete.prototype.maxResultsDisplayed=10;YAHOO.widget.AutoComplete.prototype.queryDelay=0.2;YAHOO.widget.AutoComplete.prototype.highlightClassName="yui-ac-highlight";YAHOO.widget.AutoComplete.prototype.prehighlightClassName=null;YAHOO.widget.AutoComplete.prototype.delimChar=null;YAHOO.widget.AutoComplete.prototype.autoHighlight=true;YAHOO.widget.AutoComplete.prototype.typeAhead=false;YAHOO.widget.AutoComplete.prototype.animHoriz=false;YAHOO.widget.AutoComplete.prototype.animVert=true;YAHOO.widget.AutoComplete.prototype.animSpeed=0.3;YAHOO.widget.AutoComplete.prototype.forceSelection=false;YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete=true;YAHOO.widget.AutoComplete.prototype.alwaysShowContainer=false;YAHOO.widget.AutoComplete.prototype.useIFrame=false;YAHOO.widget.AutoComplete.prototype.useShadow=false;YAHOO.widget.AutoComplete.prototype.toString=function(){return"AutoComplete "+this._sName;};YAHOO.widget.AutoComplete.prototype.isContainerOpen=function(){return this._bContainerOpen;};YAHOO.widget.AutoComplete.prototype.getListItems=function(){return this._aListItems;};YAHOO.widget.AutoComplete.prototype.getListItemData=function(oListItem){if(oListItem._oResultData){return oListItem._oResultData;}
-else{return false;}};YAHOO.widget.AutoComplete.prototype.setHeader=function(sHeader){if(sHeader){if(this._oContainer._oContent._oHeader){this._oContainer._oContent._oHeader.innerHTML=sHeader;this._oContainer._oContent._oHeader.style.display="block";}}
-else{this._oContainer._oContent._oHeader.innerHTML="";this._oContainer._oContent._oHeader.style.display="none";}};YAHOO.widget.AutoComplete.prototype.setFooter=function(sFooter){if(sFooter){if(this._oContainer._oContent._oFooter){this._oContainer._oContent._oFooter.innerHTML=sFooter;this._oContainer._oContent._oFooter.style.display="block";}}
-else{this._oContainer._oContent._oFooter.innerHTML="";this._oContainer._oContent._oFooter.style.display="none";}};YAHOO.widget.AutoComplete.prototype.setBody=function(sBody){if(sBody){if(this._oContainer._oContent._oBody){this._oContainer._oContent._oBody.innerHTML=sBody;this._oContainer._oContent._oBody.style.display="block";this._oContainer._oContent.style.display="block";}}
-else{this._oContainer._oContent._oBody.innerHTML="";this._oContainer._oContent.style.display="none";}
-this._maxResultsDisplayed=0;};YAHOO.widget.AutoComplete.prototype.formatResult=function(oResultItem,sQuery){var sResult=oResultItem[0];if(sResult){return sResult;}
-else{return"";}};YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer=function(oTextbox,oContainer,sQuery,aResults){return true;};YAHOO.widget.AutoComplete.prototype.sendQuery=function(sQuery){this._sendQuery(sQuery);};YAHOO.widget.AutoComplete.prototype.doBeforeSendQuery=function(sQuery){return sQuery;};YAHOO.widget.AutoComplete.prototype.destroy=function(){var instanceName=this.toString();var elInput=this._oTextbox;var elContainer=this._oContainer;this.textboxFocusEvent.unsubscribe();this.textboxKeyEvent.unsubscribe();this.dataRequestEvent.unsubscribe();this.dataReturnEvent.unsubscribe();this.dataErrorEvent.unsubscribe();this.containerExpandEvent.unsubscribe();this.typeAheadEvent.unsubscribe();this.itemMouseOverEvent.unsubscribe();this.itemMouseOutEvent.unsubscribe();this.itemArrowToEvent.unsubscribe();this.itemArrowFromEvent.unsubscribe();this.itemSelectEvent.unsubscribe();this.unmatchedItemSelectEvent.unsubscribe();this.selectionEnforceEvent.unsubscribe();this.containerCollapseEvent.unsubscribe();this.textboxBlurEvent.unsubscribe();YAHOO.util.Event.purgeElement(elInput,true);YAHOO.util.Event.purgeElement(elContainer,true);elContainer.innerHTML="";for(var key in this){if(this.hasOwnProperty(key)){this[key]=null;}}};YAHOO.widget.AutoComplete.prototype.textboxFocusEvent=null;YAHOO.widget.AutoComplete.prototype.textboxKeyEvent=null;YAHOO.widget.AutoComplete.prototype.dataRequestEvent=null;YAHOO.widget.AutoComplete.prototype.dataReturnEvent=null;YAHOO.widget.AutoComplete.prototype.dataErrorEvent=null;YAHOO.widget.AutoComplete.prototype.containerExpandEvent=null;YAHOO.widget.AutoComplete.prototype.typeAheadEvent=null;YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent=null;YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent=null;YAHOO.widget.AutoComplete.prototype.itemArrowToEvent=null;YAHOO.widget.AutoComplete.prototype.itemArrowFromEvent=null;YAHOO.widget.AutoComplete.prototype.itemSelectEvent=null;YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent=null;YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent=null;YAHOO.widget.AutoComplete.prototype.containerCollapseEvent=null;YAHOO.widget.AutoComplete.prototype.textboxBlurEvent=null;YAHOO.widget.AutoComplete._nIndex=0;YAHOO.widget.AutoComplete.prototype._sName=null;YAHOO.widget.AutoComplete.prototype._oTextbox=null;YAHOO.widget.AutoComplete.prototype._bFocused=true;YAHOO.widget.AutoComplete.prototype._oAnim=null;YAHOO.widget.AutoComplete.prototype._oContainer=null;YAHOO.widget.AutoComplete.prototype._bContainerOpen=false;YAHOO.widget.AutoComplete.prototype._bOverContainer=false;YAHOO.widget.AutoComplete.prototype._aListItems=null;YAHOO.widget.AutoComplete.prototype._nDisplayedItems=0;YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed=0;YAHOO.widget.AutoComplete.prototype._sCurQuery=null;YAHOO.widget.AutoComplete.prototype._sSavedQuery=null;YAHOO.widget.AutoComplete.prototype._oCurItem=null;YAHOO.widget.AutoComplete.prototype._bItemSelected=false;YAHOO.widget.AutoComplete.prototype._nKeyCode=null;YAHOO.widget.AutoComplete.prototype._nDelayID=-1;YAHOO.widget.AutoComplete.prototype._iFrameSrc="javascript:false;";YAHOO.widget.AutoComplete.prototype._queryInterval=null;YAHOO.widget.AutoComplete.prototype._sLastTextboxValue=null;YAHOO.widget.AutoComplete.prototype._initProps=function(){var minQueryLength=this.minQueryLength;if(!YAHOO.lang.isNumber(minQueryLength)){this.minQueryLength=1;}
-var maxResultsDisplayed=this.maxResultsDisplayed;if(!YAHOO.lang.isNumber(maxResultsDisplayed)||(maxResultsDisplayed<1)){this.maxResultsDisplayed=10;}
-var queryDelay=this.queryDelay;if(!YAHOO.lang.isNumber(queryDelay)||(queryDelay<0)){this.queryDelay=0.2;}
-var delimChar=this.delimChar;if(YAHOO.lang.isString(delimChar)){this.delimChar=[delimChar];}
-else if(!YAHOO.lang.isArray(delimChar)){this.delimChar=null;}
-var animSpeed=this.animSpeed;if((this.animHoriz||this.animVert)&&YAHOO.util.Anim){if(!YAHOO.lang.isNumber(animSpeed)||(animSpeed<0)){this.animSpeed=0.3;}
-if(!this._oAnim){this._oAnim=new YAHOO.util.Anim(this._oContainer._oContent,{},this.animSpeed);}
-else{this._oAnim.duration=this.animSpeed;}}
-if(this.forceSelection&&delimChar){}};YAHOO.widget.AutoComplete.prototype._initContainerHelpers=function(){if(this.useShadow&&!this._oContainer._oShadow){var oShadow=document.createElement("div");oShadow.className="yui-ac-shadow";this._oContainer._oShadow=this._oContainer.appendChild(oShadow);}
-if(this.useIFrame&&!this._oContainer._oIFrame){var oIFrame=document.createElement("iframe");oIFrame.src=this._iFrameSrc;oIFrame.frameBorder=0;oIFrame.scrolling="no";oIFrame.style.position="absolute";oIFrame.style.width="100%";oIFrame.style.height="100%";oIFrame.tabIndex=-1;this._oContainer._oIFrame=this._oContainer.appendChild(oIFrame);}};YAHOO.widget.AutoComplete.prototype._initContainer=function(){YAHOO.util.Dom.addClass(this._oContainer,"yui-ac-container");if(!this._oContainer._oContent){var oContent=document.createElement("div");oContent.className="yui-ac-content";oContent.style.display="none";this._oContainer._oContent=this._oContainer.appendChild(oContent);var oHeader=document.createElement("div");oHeader.className="yui-ac-hd";oHeader.style.display="none";this._oContainer._oContent._oHeader=this._oContainer._oContent.appendChild(oHeader);var oBody=document.createElement("div");oBody.className="yui-ac-bd";this._oContainer._oContent._oBody=this._oContainer._oContent.appendChild(oBody);var oFooter=document.createElement("div");oFooter.className="yui-ac-ft";oFooter.style.display="none";this._oContainer._oContent._oFooter=this._oContainer._oContent.appendChild(oFooter);}
-else{}};YAHOO.widget.AutoComplete.prototype._initList=function(){this._aListItems=[];while(this._oContainer._oContent._oBody.hasChildNodes()){var oldListItems=this.getListItems();if(oldListItems){for(var oldi=oldListItems.length-1;oldi>=0;oldi--){oldListItems[oldi]=null;}}
-this._oContainer._oContent._oBody.innerHTML="";}
-var oList=document.createElement("ul");oList=this._oContainer._oContent._oBody.appendChild(oList);for(var i=0;i
+ *
+ *
+ *
+ * @property asyncMode
+ * @type String
+ * @default "allowAll"
+ */
+YAHOO.widget.DS_ScriptNode.prototype.asyncMode = "allowAll";
+
+/**
+ * Callback string parameter name sent to scriptURI. For instance, requests will be
+ * sent to <scriptURI>?<scriptCallbackParam>=callbackFunction
+ *
+ * @property scriptCallbackParam
+ * @type String
+ * @default "callback"
+ */
+YAHOO.widget.DS_ScriptNode.prototype.scriptCallbackParam = "callback";
+
+/**
+ * Global array of callback functions, one for each request sent.
+ *
+ * @property callbacks
+ * @type Function[]
+ * @static
+ */
+YAHOO.widget.DS_ScriptNode.callbacks = [];
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Unique ID to track requests.
+ *
+ * @property _nId
+ * @type Number
+ * @private
+ * @static
+ */
+YAHOO.widget.DS_ScriptNode._nId = 0;
+
+/**
+ * Counter for pending requests. When this is 0, it is safe to purge callbacks
+ * array.
+ *
+ * @property _nPending
+ * @type Number
+ * @private
+ * @static
+ */
+YAHOO.widget.DS_ScriptNode._nPending = 0;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Queries the live data source. Results are passed back to a callback function.
+ *
+ * @method doQuery
+ * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
+ * @param sQuery {String} Query string.
+ * @param oParent {Object} The object instance that has requested data.
+ */
+YAHOO.widget.DS_ScriptNode.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
+ var oSelf = this;
+
+ // If there are no global pending requests, it is safe to purge global callback stack and global counter
+ if(YAHOO.widget.DS_ScriptNode._nPending === 0) {
+ YAHOO.widget.DS_ScriptNode.callbacks = [];
+ YAHOO.widget.DS_ScriptNode._nId = 0;
+ }
+
+ // ID for this request
+ var id = YAHOO.widget.DS_ScriptNode._nId;
+ YAHOO.widget.DS_ScriptNode._nId++;
+
+ // Dynamically add handler function with a closure to the callback stack
+ YAHOO.widget.DS_ScriptNode.callbacks[id] = function(oResponse) {
+ if((oSelf.asyncMode !== "ignoreStaleResponses")||
+ (id === YAHOO.widget.DS_ScriptNode.callbacks.length-1)) { // Must ignore stale responses
+ oSelf.handleResponse(oResponse, oCallbackFn, sQuery, oParent);
+ }
+ else {
+ }
+
+ delete YAHOO.widget.DS_ScriptNode.callbacks[id];
+ };
+
+ // We are now creating a request
+ YAHOO.widget.DS_ScriptNode._nPending++;
+
+ var sUri = this.scriptURI+"&"+ this.scriptQueryParam+"="+sQuery+"&"+
+ this.scriptCallbackParam+"=YAHOO.widget.DS_ScriptNode.callbacks["+id+"]";
+ this.getUtility.script(sUri,
+ {autopurge:true,
+ onsuccess:YAHOO.widget.DS_ScriptNode._bumpPendingDown,
+ onfail:YAHOO.widget.DS_ScriptNode._bumpPendingDown});
+};
+
+/**
+ * Parses JSON response data into an array of result objects and passes it to
+ * the callback function.
+ *
+ * @method handleResponse
+ * @param oResponse {Object} The raw response data to parse.
+ * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
+ * @param sQuery {String} Query string.
+ * @param oParent {Object} The object instance that has requested data.
+ */
+YAHOO.widget.DS_ScriptNode.prototype.handleResponse = function(oResponse, oCallbackFn, sQuery, oParent) {
+ var aSchema = this.schema;
+ var aResults = [];
+ var bError = false;
+
+ var jsonList, jsonObjParsed;
+
+ // Parse the JSON response as a string
+ try {
+ // Grab the object member that contains an array of all reponses...
+ // ...eval is necessary here since aSchema[0] is of unknown depth
+ jsonList = eval("(oResponse." + aSchema[0]+")");
+ }
+ catch(e) {
+ bError = true;
+ }
+
+ if(!jsonList) {
+ bError = true;
+ jsonList = [];
+ }
+
+ else if(!YAHOO.lang.isArray(jsonList)) {
+ jsonList = [jsonList];
+ }
+
+ // Loop through the array of all responses...
+ for(var i = jsonList.length-1; i >= 0 ; i--) {
+ var aResultItem = [];
+ var jsonResult = jsonList[i];
+ // ...and loop through each data field value of each response
+ for(var j = aSchema.length-1; j >= 1 ; j--) {
+ // ...and capture data into an array mapped according to the schema...
+ var dataFieldValue = jsonResult[aSchema[j]];
+ if(!dataFieldValue) {
+ dataFieldValue = "";
+ }
+ aResultItem.unshift(dataFieldValue);
+ }
+ // If schema isn't well defined, pass along the entire result object
+ if(aResultItem.length == 1) {
+ aResultItem.push(jsonResult);
+ }
+ // Capture the array of data field values in an array of results
+ aResults.unshift(aResultItem);
+ }
+
+ if(bError) {
+ aResults = null;
+ }
+
+ if(aResults === null) {
+ this.dataErrorEvent.fire(this, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATAPARSE);
+ aResults = [];
+ }
+ else {
+ var resultObj = {};
+ resultObj.query = decodeURIComponent(sQuery);
+ resultObj.results = aResults;
+ this._addCacheElem(resultObj);
+
+ this.getResultsEvent.fire(this, oParent, sQuery, aResults);
+ }
+
+ oCallbackFn(sQuery, aResults, oParent);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Any success/failure response should decrement counter.
+ *
+ * @method _bumpPendingDown
+ * @private
+ */
+YAHOO.widget.DS_ScriptNode._bumpPendingDown = function() {
+ YAHOO.widget.DS_ScriptNode._nPending--;
+};
+
+
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
@@ -3071,6 +3425,7 @@ YAHOO.widget.DS_JSFunction.prototype.doQuery = function(oCallbackFn, sQuery, oPa
return;
};
+
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
@@ -3187,4 +3542,4 @@ YAHOO.widget.DS_JSArray.prototype.doQuery = function(oCallbackFn, sQuery, oParen
oCallbackFn(sQuery, aResults, oParent);
};
-YAHOO.register("autocomplete", YAHOO.widget.AutoComplete, {version: "2.3.0", build: "442"});
+YAHOO.register("autocomplete", YAHOO.widget.AutoComplete, {version: "2.5.0", build: "895"});
diff --git a/lib/yui/base/README b/lib/yui/base/README
index 287f22ea11..a5f3562d1f 100755
--- a/lib/yui/base/README
+++ b/lib/yui/base/README
@@ -1,5 +1,17 @@
YUI Library - Base - Release Notes
+Version 2.5.0
+
+ * No changes.
+
+Version 2.4.0
+
+ * Fixed typo in comments.
+ * Added margin-bottom:1em; for PRE element to match P
+ * Added color:#000 for legend element, accomodation for IE
+ * Added set width (equivilant to 160px but set in EMs) for input's
+ width type = text or password, and for textareas.
+
Version 2.3.0
* Initial release.
\ No newline at end of file
diff --git a/lib/yui/base/base-min.css b/lib/yui/base/base-min.css
index a4dcc816f6..fcb5b2c853 100755
--- a/lib/yui/base/base-min.css
+++ b/lib/yui/base/base-min.css
@@ -1,7 +1,7 @@
/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Copyright (c) 2008, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
+version: 2.5.0
*/
-h1{font-size:138.5%;}h2{font-size:123.1%;}h3{font-size:108%;}h1,h2,h3{margin:1em 0;}h1,h2,h3,h4,h5,h6,strong{font-weight:bold;}abbr,acronym{border-bottom:1px dotted #000;cursor:help;}em{font-style:italic;}blockquote,ul,ol,dl{margin:1em;}ol,ul,dl{margin-left:2em;}ol li{list-style: decimal outside;}ul li{list-style: disc outside;}dl dd{margin-left:1em;}th,td {border:1px solid #000;padding:.5em;}th {font-weight:bold;text-align:center;}caption {margin-bottom:.5em;text-align:center;}p,fieldset,table {margin-bottom:1em;}
\ No newline at end of file
+h1{font-size:138.5%;}h2{font-size:123.1%;}h3{font-size:108%;}h1,h2,h3{margin:1em 0;}h1,h2,h3,h4,h5,h6,strong{font-weight:bold;}abbr,acronym{border-bottom:1px dotted #000;cursor:help;} em{font-style:italic;}blockquote,ul,ol,dl{margin:1em;}ol,ul,dl{margin-left:2em;}ol li{list-style:decimal outside;}ul li{list-style:disc outside;}dl dd{margin-left:1em;}th,td{border:1px solid #000;padding:.5em;}th{font-weight:bold;text-align:center;}caption{margin-bottom:.5em;text-align:center;}p,fieldset,table,pre{margin-bottom:1em;}input[type=text],input[type=password],textarea{width:12.25em;*width:11.9em;}
diff --git a/lib/yui/base/base.css b/lib/yui/base/base.css
index 85dcca7dd2..bb504f8873 100755
--- a/lib/yui/base/base.css
+++ b/lib/yui/base/base.css
@@ -1,8 +1,8 @@
/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Copyright (c) 2008, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
+version: 2.5.0
*/
/* base.css, part of YUI's CSS Foundation */
h1 {
@@ -65,12 +65,15 @@ th {
text-align:center;
}
caption {
- /*coordinated marking to match cell's padding*/
+ /*coordinated margin to match cell's padding*/
margin-bottom:.5em;
/*centered so it doesn't blend in to other content*/
text-align:center;
}
-p,fieldset,table {
+p,fieldset,table,pre {
/*so things don't run into each other*/
margin-bottom:1em;
-}
\ No newline at end of file
+}
+/* setting a consistent width, 160px;
+ control of type=file still not possible */
+input[type=text],input[type=password],textarea{width:12.25em;*width:11.9em;}
diff --git a/lib/yui/button/README b/lib/yui/button/README
index a0bcb58831..b0dca1d4a4 100755
--- a/lib/yui/button/README
+++ b/lib/yui/button/README
@@ -1,4 +1,75 @@
-*** Version 2.3.0 ***
+*** Version 2.5.0 ***
+
++ Fixed issue where returning false inside the scope of a listener for attribute "before"
+ events (i.e "beforeCheckedChange") would not cancel the attribute's default setter.
+
+
+
+*** Version 2.4.1 ***
+
++ No changes.
+
+
+
+*** Version 2.4.0 ***
+
+Added the following features:
+-----------------------------
+
++ Added a static method "YAHOO.widget.Button.getButton" that returns a Button
+ instance with the specified HTML element id.
+
+
+Fixed the following bugs:
+-------------------------
+
++ Removed the ".yui-skin-sam" CSS class name from style rules in the core
+ stylesheet so that it is now truly skin agnostic.
+
++ Updated the default text for tooltips for Buttons of type "radio" so that
+ they offer the correct instructional text.
+
++ Menus with grouped YAHOO.widget.MenuItem instances will now highlight
+ correctly when used with Button.
+
++ Buttons of type "link" now have the same default height as other Button
+ types in Internet Explorer.
+
++ Buttons of various types now line up correctly on the same line.
+
++ Menu is now truly an optional dependancy of Button.
+
++ Menus now render with the correct width when the "yui-skin-sam" CSS class
+ name is applied to an element other than the .
+
+
+
+*** Version 2.3.1 ***
+
+Fixed the following bugs:
+-------------------------
++ Purged the old 2.2.2 Button stylesheet and related image assets that was
+ mistakenly included in the 2.3.0 build.
+
++ Fixed an issue in Gecko where changing a Button instance's "label" attribute
+ after the Button had been created would not result in the Button redrawing at
+ a width to fit its content.
+
++ Fixed an issue where the singleton keypress event handler
+ (YAHOO.widget.Button.onFormKeyPress) registered for forms containing
+ Button instances of type "submit" was not removed from the form once all of
+ its child Button instances are destroyed.
+
++ Submitting a form by clicking on a MenuItem of a SplitButton's or MenuButton's
+ Menu will no longer result in a JavaScript error.
+
++ Modified how element tag names are compared to support XHTML applications.
+
++ Added code to remove the CSS class names representing the "hover," "focus,"
+ and "active" states when a Button instance is disabled.
+
+
+*** Version 2.3 ***
Added the following features:
-----------------------------
diff --git a/lib/yui/button/assets/button-core.css b/lib/yui/button/assets/button-core.css
index 5aa3015efe..e3ff7ea186 100755
--- a/lib/yui/button/assets/button-core.css
+++ b/lib/yui/button/assets/button-core.css
@@ -1,6 +1,44 @@
/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Copyright (c) 2008, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
+version: 2.5.0
*/
+.yui-button {
+
+ display: -moz-inline-box; /* Gecko */
+ display: inline-block; /* IE, Opera and Safari */
+ vertical-align: text-bottom;
+
+}
+
+.yui-button .first-child {
+
+ display: block;
+ *display: inline-block; /* IE */
+
+}
+
+.yui-button button,
+.yui-button a {
+
+ display: block;
+ *display: inline-block; /* IE */
+ border: none;
+ margin: 0;
+
+}
+
+.yui-button button {
+
+ background-color: transparent;
+ *overflow: visible; /* Remove superfluous padding for IE */
+ cursor: pointer;
+
+}
+
+.yui-button a {
+
+ text-decoration: none;
+
+}
\ No newline at end of file
diff --git a/lib/yui/button/assets/skins/sam/button-skin.css b/lib/yui/button/assets/skins/sam/button-skin.css
index e8f8011a81..ad97242ac3 100755
--- a/lib/yui/button/assets/skins/sam/button-skin.css
+++ b/lib/yui/button/assets/skins/sam/button-skin.css
@@ -1,13 +1,11 @@
/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Copyright (c) 2008, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
+version: 2.5.0
*/
.yui-skin-sam .yui-button {
- display: -moz-inline-box; /* Gecko */
- display: inline-block; /* IE, Opera and Safari */
border-width: 1px 0;
border-style: solid;
border-color: #808080;
@@ -18,13 +16,11 @@ version: 2.3.0
.yui-skin-sam .yui-button .first-child {
- display: block;
- *display: inline-block; /* IE */
border-width: 0 1px;
border-style: solid;
border-color: #808080;
margin: 0 -1px;
- *position: relative;
+ *position: relative; /* Necessary to get negative margins working in IE */
*left: -1px;
}
@@ -32,10 +28,7 @@ version: 2.3.0
.yui-skin-sam .yui-button button,
.yui-skin-sam .yui-button a {
- display: block;
- *display: inline-block; /* IE */
padding: 0 10px;
- border: none;
font-size: 93%; /* 12px */
line-height: 2; /* ~24px */
*line-height: 1.7; /* For IE */
@@ -45,22 +38,16 @@ version: 2.3.0
}
-.yui-skin-sam .yui-button button {
-
- *overflow: visible; /* Remove superfluous padding for IE */
- background-color: transparent;
- cursor: pointer;
- cursor: hand;
-
-}
-
.yui-skin-sam .yui-button a {
- text-decoration: none;
+ /*
+ Necessary to get Button's of type "link" to be the correct
+ height in IE.
+ */
+ *line-height: 2;
}
-
.yui-skin-sam .yui-split-button button,
.yui-skin-sam .yui-menu-button button {
diff --git a/lib/yui/button/assets/skins/sam/button.css b/lib/yui/button/assets/skins/sam/button.css
index 0de5e6e01e..cef04bbe92 100755
--- a/lib/yui/button/assets/skins/sam/button.css
+++ b/lib/yui/button/assets/skins/sam/button.css
@@ -1,7 +1,7 @@
/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Copyright (c) 2008, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
+version: 2.5.0
*/
-.yui-skin-sam .yui-button{display:-moz-inline-box;display:inline-block;border-width:1px 0;border-style:solid;border-color:#808080;background:url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0;margin:auto .25em;}.yui-skin-sam .yui-button .first-child{display:block;*display:inline-block;border-width:0 1px;border-style:solid;border-color:#808080;margin:0 -1px;*position:relative;*left:-1px;}.yui-skin-sam .yui-button button,.yui-skin-sam .yui-button a{display:block;*display:inline-block;padding:0 10px;border:none;font-size:93%;line-height:2;*line-height:1.7;min-height:2em;*min-height:auto;color:#000;}.yui-skin-sam .yui-button button{*overflow:visible;background-color:transparent;cursor:pointer;cursor:hand;}.yui-skin-sam .yui-button a{text-decoration:none;}.yui-skin-sam .yui-split-button button,.yui-skin-sam .yui-menu-button button{padding-right:20px;background-position:right center;background-repeat:no-repeat;}.yui-skin-sam .yui-menu-button button{background-image:url(menu-button-arrow.png);}.yui-skin-sam .yui-split-button button{background-image:url(split-button-arrow.png);}.yui-skin-sam .yui-button-focus{border-color:#7D98B8;background-position:0 -1300px;}.yui-skin-sam .yui-button-focus .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-button-focus button,.yui-skin-sam .yui-button-focus a{color:#000;}.yui-skin-sam .yui-split-button-focus button{background-image:url(split-button-arrow-focus.png);}.yui-skin-sam .yui-button-hover{border-color:#7D98B8;background-position:0 -1300px;}.yui-skin-sam .yui-button-hover .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-button-hover button,.yui-skin-sam .yui-button-hover a{color:#000;}.yui-skin-sam .yui-split-button-hover button{background-image:url(split-button-arrow-hover.png);}.yui-skin-sam .yui-button-active{border-color:#7D98B8;background-position:0 -1700px;}.yui-skin-sam .yui-button-active .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-button-active button,.yui-skin-sam .yui-button-active a{color:#000;}.yui-skin-sam .yui-split-button-activeoption{border-color:#808080;background-position:0 0;}.yui-skin-sam .yui-split-button-activeoption .first-child{border-color:#808080;}.yui-skin-sam .yui-split-button-activeoption button{background-image:url(split-button-arrow-active.png);}.yui-skin-sam .yui-radio-button-checked,.yui-skin-sam .yui-checkbox-button-checked{border-color:#304369;background-position:0 -1400px;}.yui-skin-sam .yui-radio-button-checked .first-child,.yui-skin-sam .yui-checkbox-button-checked .first-child{border-color:#304369;}.yui-skin-sam .yui-radio-button-checked button,.yui-skin-sam .yui-checkbox-button-checked button{color:#fff;}.yui-skin-sam .yui-button-disabled{border-color:#ccc;background-position:0 -1500px;}.yui-skin-sam .yui-button-disabled .first-child{border-color:#ccc;}.yui-skin-sam .yui-button-disabled button,.yui-skin-sam .yui-button-disabled a{color:#A6A6A6;cursor:default;}.yui-skin-sam .yui-menu-button-disabled button{background-image:url(menu-button-arrow-disabled.png);}.yui-skin-sam .yui-split-button-disabled button{background-image:url(split-button-arrow-disabled.png);}
+.yui-button{display:-moz-inline-box;display:inline-block;vertical-align:text-bottom;}.yui-button .first-child{display:block;*display:inline-block;}.yui-button button,.yui-button a{display:block;*display:inline-block;border:none;margin:0;}.yui-button button{background-color:transparent;*overflow:visible;cursor:pointer;}.yui-button a{text-decoration:none;}.yui-skin-sam .yui-button{border-width:1px 0;border-style:solid;border-color:#808080;background:url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0;margin:auto .25em;}.yui-skin-sam .yui-button .first-child{border-width:0 1px;border-style:solid;border-color:#808080;margin:0 -1px;*position:relative;*left:-1px;}.yui-skin-sam .yui-button button,.yui-skin-sam .yui-button a{padding:0 10px;font-size:93%;line-height:2;*line-height:1.7;min-height:2em;*min-height:auto;color:#000;}.yui-skin-sam .yui-button a{*line-height:2;}.yui-skin-sam .yui-split-button button,.yui-skin-sam .yui-menu-button button{padding-right:20px;background-position:right center;background-repeat:no-repeat;}.yui-skin-sam .yui-menu-button button{background-image:url(menu-button-arrow.png);}.yui-skin-sam .yui-split-button button{background-image:url(split-button-arrow.png);}.yui-skin-sam .yui-button-focus{border-color:#7D98B8;background-position:0 -1300px;}.yui-skin-sam .yui-button-focus .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-button-focus button,.yui-skin-sam .yui-button-focus a{color:#000;}.yui-skin-sam .yui-split-button-focus button{background-image:url(split-button-arrow-focus.png);}.yui-skin-sam .yui-button-hover{border-color:#7D98B8;background-position:0 -1300px;}.yui-skin-sam .yui-button-hover .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-button-hover button,.yui-skin-sam .yui-button-hover a{color:#000;}.yui-skin-sam .yui-split-button-hover button{background-image:url(split-button-arrow-hover.png);}.yui-skin-sam .yui-button-active{border-color:#7D98B8;background-position:0 -1700px;}.yui-skin-sam .yui-button-active .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-button-active button,.yui-skin-sam .yui-button-active a{color:#000;}.yui-skin-sam .yui-split-button-activeoption{border-color:#808080;background-position:0 0;}.yui-skin-sam .yui-split-button-activeoption .first-child{border-color:#808080;}.yui-skin-sam .yui-split-button-activeoption button{background-image:url(split-button-arrow-active.png);}.yui-skin-sam .yui-radio-button-checked,.yui-skin-sam .yui-checkbox-button-checked{border-color:#304369;background-position:0 -1400px;}.yui-skin-sam .yui-radio-button-checked .first-child,.yui-skin-sam .yui-checkbox-button-checked .first-child{border-color:#304369;}.yui-skin-sam .yui-radio-button-checked button,.yui-skin-sam .yui-checkbox-button-checked button{color:#fff;}.yui-skin-sam .yui-button-disabled{border-color:#ccc;background-position:0 -1500px;}.yui-skin-sam .yui-button-disabled .first-child{border-color:#ccc;}.yui-skin-sam .yui-button-disabled button,.yui-skin-sam .yui-button-disabled a{color:#A6A6A6;cursor:default;}.yui-skin-sam .yui-menu-button-disabled button{background-image:url(menu-button-arrow-disabled.png);}.yui-skin-sam .yui-split-button-disabled button{background-image:url(split-button-arrow-disabled.png);}
diff --git a/lib/yui/button/button-debug.js b/lib/yui/button/button-debug.js
new file mode 100644
index 0000000000..2474c910f6
--- /dev/null
+++ b/lib/yui/button/button-debug.js
@@ -0,0 +1,4738 @@
+/*
+Copyright (c) 2008, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.5.0
+*/
+/**
+* @module button
+* @description
+*
+* @title Button
+* @namespace YAHOO.widget
+* @requires yahoo, dom, element, event
+* @optional container, menu
+*/
+
+
+(function () {
+
+
+ /**
+ * The Button class creates a rich, graphical button.
+ * @param {String} p_oElement String specifying the id attribute of the
+ * <input>
, <button>
,
+ * <a>
, or <span>
element to
+ * be used to create the button.
+ * @param {HTMLInputElement|
+ * HTMLButtonElement|HTMLElement} p_oElement Object reference for the
+ * <input>
, <button>
,
+ * <a>
, or <span>
element to be
+ * used to create the button.
+ * @param {Object} p_oElement Object literal specifying a set of
+ * configuration attributes used to create the button.
+ * @param {Object} p_oAttributes Optional. Object literal specifying a set
+ * of configuration attributes used to create the button.
+ * @namespace YAHOO.widget
+ * @class Button
+ * @constructor
+ * @extends YAHOO.util.Element
+ */
+
+
+
+ // Shorthard for utilities
+
+ var Dom = YAHOO.util.Dom,
+ Event = YAHOO.util.Event,
+ Lang = YAHOO.lang,
+ Overlay = YAHOO.widget.Overlay,
+ Menu = YAHOO.widget.Menu,
+
+
+ // Private member variables
+
+ m_oButtons = {}, // Collection of all Button instances
+ m_oOverlayManager = null, // YAHOO.widget.OverlayManager instance
+ m_oSubmitTrigger = null, // The button that submitted the form
+ m_oFocusedButton = null; // The button that has focus
+
+
+
+ // Private methods
+
+
+
+ /**
+ * @method createInputElement
+ * @description Creates an <input>
element of the
+ * specified type.
+ * @private
+ * @param {String} p_sType String specifying the type of
+ * <input>
element to create.
+ * @param {String} p_sName String specifying the name of
+ * <input>
element to create.
+ * @param {String} p_sValue String specifying the value of
+ * <input>
element to create.
+ * @param {String} p_bChecked Boolean specifying if the
+ * <input>
element is to be checked.
+ * @return {HTMLInputElement}
+ */
+ function createInputElement(p_sType, p_sName, p_sValue, p_bChecked) {
+
+ var oInput,
+ sInput;
+
+ if (Lang.isString(p_sType) && Lang.isString(p_sName)) {
+
+ if (YAHOO.env.ua.ie) {
+
+ /*
+ For IE it is necessary to create the element with the
+ "type," "name," "value," and "checked" properties set all
+ at once.
+ */
+
+ sInput = "";
+
+ oInput = document.createElement(sInput);
+
+ }
+ else {
+
+ oInput = document.createElement("input");
+ oInput.name = p_sName;
+ oInput.type = p_sType;
+
+ if (p_bChecked) {
+
+ oInput.checked = true;
+
+ }
+
+ }
+
+ oInput.value = p_sValue;
+
+ return oInput;
+
+ }
+
+ }
+
+
+ /**
+ * @method setAttributesFromSrcElement
+ * @description Gets the values for all the attributes of the source element
+ * (either <input>
or <a>
) that
+ * map to Button configuration attributes and sets them into a collection
+ * that is passed to the Button constructor.
+ * @private
+ * @param {HTMLInputElement|HTMLAnchorElement} p_oElement Object reference to the HTML
+ * element (either <input>
or <span>
+ *
) used to create the button.
+ * @param {Object} p_oAttributes Object reference for the collection of
+ * configuration attributes used to create the button.
+ */
+ function setAttributesFromSrcElement(p_oElement, p_oAttributes) {
+
+ var sSrcElementNodeName = p_oElement.nodeName.toUpperCase(),
+ me = this,
+ oAttribute,
+ oRootNode,
+ sText;
+
+
+ /**
+ * @method setAttributeFromDOMAttribute
+ * @description Gets the value of the specified DOM attribute and sets it
+ * into the collection of configuration attributes used to configure
+ * the button.
+ * @private
+ * @param {String} p_sAttribute String representing the name of the
+ * attribute to retrieve from the DOM element.
+ */
+ function setAttributeFromDOMAttribute(p_sAttribute) {
+
+ if (!(p_sAttribute in p_oAttributes)) {
+
+ /*
+ Need to use "getAttributeNode" instead of "getAttribute"
+ because using "getAttribute," IE will return the innerText
+ of a <button>
for the value attribute
+ rather than the value of the "value" attribute.
+ */
+
+ oAttribute = p_oElement.getAttributeNode(p_sAttribute);
+
+
+ if (oAttribute && ("value" in oAttribute)) {
+
+ me.logger.log("Setting attribute \"" + p_sAttribute +
+ "\" using source element's attribute value of \"" +
+ oAttribute.value + "\"");
+
+ p_oAttributes[p_sAttribute] = oAttribute.value;
+
+ }
+
+ }
+
+ }
+
+
+ /**
+ * @method setFormElementProperties
+ * @description Gets the value of the attributes from the form element
+ * and sets them into the collection of configuration attributes used to
+ * configure the button.
+ * @private
+ */
+ function setFormElementProperties() {
+
+ setAttributeFromDOMAttribute("type");
+
+ if (p_oAttributes.type == "button") {
+
+ p_oAttributes.type = "push";
+
+ }
+
+ if (!("disabled" in p_oAttributes)) {
+
+ p_oAttributes.disabled = p_oElement.disabled;
+
+ }
+
+ setAttributeFromDOMAttribute("name");
+ setAttributeFromDOMAttribute("value");
+ setAttributeFromDOMAttribute("title");
+
+ }
+
+
+ switch (sSrcElementNodeName) {
+
+ case "A":
+
+ p_oAttributes.type = "link";
+
+ setAttributeFromDOMAttribute("href");
+ setAttributeFromDOMAttribute("target");
+
+ break;
+
+ case "INPUT":
+
+ setFormElementProperties();
+
+ if (!("checked" in p_oAttributes)) {
+
+ p_oAttributes.checked = p_oElement.checked;
+
+ }
+
+ break;
+
+ case "BUTTON":
+
+ setFormElementProperties();
+
+ oRootNode = p_oElement.parentNode.parentNode;
+
+ if (Dom.hasClass(oRootNode, this.CSS_CLASS_NAME + "-checked")) {
+
+ p_oAttributes.checked = true;
+
+ }
+
+ if (Dom.hasClass(oRootNode, this.CSS_CLASS_NAME + "-disabled")) {
+
+ p_oAttributes.disabled = true;
+
+ }
+
+ p_oElement.removeAttribute("value");
+
+ p_oElement.setAttribute("type", "button");
+
+ break;
+
+ }
+
+ p_oElement.removeAttribute("id");
+ p_oElement.removeAttribute("name");
+
+ if (!("tabindex" in p_oAttributes)) {
+
+ p_oAttributes.tabindex = p_oElement.tabIndex;
+
+ }
+
+ if (!("label" in p_oAttributes)) {
+
+ // Set the "label" property
+
+ sText = sSrcElementNodeName == "INPUT" ?
+ p_oElement.value : p_oElement.innerHTML;
+
+
+ if (sText && sText.length > 0) {
+
+ p_oAttributes.label = sText;
+
+ }
+
+ }
+
+ }
+
+
+ /**
+ * @method initConfig
+ * @description Initializes the set of configuration attributes that are
+ * used to instantiate the button.
+ * @private
+ * @param {Object} Object representing the button's set of
+ * configuration attributes.
+ */
+ function initConfig(p_oConfig) {
+
+ var oAttributes = p_oConfig.attributes,
+ oSrcElement = oAttributes.srcelement,
+ sSrcElementNodeName = oSrcElement.nodeName.toUpperCase(),
+ me = this;
+
+
+ if (sSrcElementNodeName == this.NODE_NAME) {
+
+ p_oConfig.element = oSrcElement;
+ p_oConfig.id = oSrcElement.id;
+
+ Dom.getElementsBy(function (p_oElement) {
+
+ switch (p_oElement.nodeName.toUpperCase()) {
+
+ case "BUTTON":
+ case "A":
+ case "INPUT":
+
+ setAttributesFromSrcElement.call(me, p_oElement,
+ oAttributes);
+
+ break;
+
+ }
+
+ }, "*", oSrcElement);
+
+ }
+ else {
+
+ switch (sSrcElementNodeName) {
+
+ case "BUTTON":
+ case "A":
+ case "INPUT":
+
+ setAttributesFromSrcElement.call(this, oSrcElement,
+ oAttributes);
+
+ break;
+
+ }
+
+ }
+
+ }
+
+
+
+ // Constructor
+
+ YAHOO.widget.Button = function (p_oElement, p_oAttributes) {
+
+ if (!Overlay && YAHOO.widget.Overlay) {
+
+ Overlay = YAHOO.widget.Overlay;
+
+ }
+
+
+ if (!Menu && YAHOO.widget.Menu) {
+
+ Menu = YAHOO.widget.Menu;
+
+ }
+
+
+ var fnSuperClass = YAHOO.widget.Button.superclass.constructor,
+ oConfig,
+ oElement;
+
+ if (arguments.length == 1 && !Lang.isString(p_oElement) &&
+ !p_oElement.nodeName) {
+
+ if (!p_oElement.id) {
+
+ p_oElement.id = Dom.generateId();
+
+ YAHOO.log("No value specified for the button's \"id\" " +
+ "attribute. Setting button id to \"" + p_oElement.id +
+ "\".", "warn");
+
+ }
+
+ this.logger = new YAHOO.widget.LogWriter("Button " + p_oElement.id);
+
+ this.logger.log("No source HTML element. Building the button " +
+ "using the set of configuration attributes.");
+
+ fnSuperClass.call(this,
+ (this.createButtonElement(p_oElement.type)),
+ p_oElement);
+
+ }
+ else {
+
+ oConfig = { element: null, attributes: (p_oAttributes || {}) };
+
+
+ if (Lang.isString(p_oElement)) {
+
+ oElement = Dom.get(p_oElement);
+
+ if (oElement) {
+
+ if (!oConfig.attributes.id) {
+
+ oConfig.attributes.id = p_oElement;
+
+ }
+
+ this.logger = new YAHOO.widget.LogWriter(
+ "Button " + oConfig.attributes.id);
+
+ this.logger.log("Building the button using an existing " +
+ "HTML element as a source element.");
+
+
+ oConfig.attributes.srcelement = oElement;
+
+ initConfig.call(this, oConfig);
+
+
+ if (!oConfig.element) {
+
+ this.logger.log("Source element could not be used " +
+ "as is. Creating a new HTML element for " +
+ "the button.");
+
+ oConfig.element =
+ this.createButtonElement(oConfig.attributes.type);
+
+ }
+
+ fnSuperClass.call(this, oConfig.element,
+ oConfig.attributes);
+
+ }
+
+ }
+ else if (p_oElement.nodeName) {
+
+ if (!oConfig.attributes.id) {
+
+ if (p_oElement.id) {
+
+ oConfig.attributes.id = p_oElement.id;
+
+ }
+ else {
+
+ oConfig.attributes.id = Dom.generateId();
+
+ YAHOO.log("No value specified for the button's " +
+ "\"id\" attribute. Setting button id to \"" +
+ oConfig.attributes.id + "\".", "warn");
+
+ }
+
+ }
+
+
+ this.logger = new YAHOO.widget.LogWriter(
+ "Button " + oConfig.attributes.id);
+
+ this.logger.log("Building the button using an existing HTML " +
+ "element as a source element.");
+
+
+ oConfig.attributes.srcelement = p_oElement;
+
+ initConfig.call(this, oConfig);
+
+
+ if (!oConfig.element) {
+
+ this.logger.log("Source element could not be used as is." +
+ " Creating a new HTML element for the button.");
+
+ oConfig.element =
+ this.createButtonElement(oConfig.attributes.type);
+
+ }
+
+ fnSuperClass.call(this, oConfig.element, oConfig.attributes);
+
+ }
+
+ }
+
+ };
+
+
+
+ YAHOO.extend(YAHOO.widget.Button, YAHOO.util.Element, {
+
+
+ // Protected properties
+
+
+ /**
+ * @property _button
+ * @description Object reference to the button's internal
+ * <a>
or <button>
element.
+ * @default null
+ * @protected
+ * @type HTMLAnchorElement|HTMLButtonElement
+ */
+ _button: null,
+
+
+ /**
+ * @property _menu
+ * @description Object reference to the button's menu.
+ * @default null
+ * @protected
+ * @type {YAHOO.widget.Overlay|
+ * YAHOO.widget.Menu}
+ */
+ _menu: null,
+
+
+ /**
+ * @property _hiddenFields
+ * @description Object reference to the <input>
+ * element, or array of HTML form elements used to represent the button
+ * when its parent form is submitted.
+ * @default null
+ * @protected
+ * @type HTMLInputElement|Array
+ */
+ _hiddenFields: null,
+
+
+ /**
+ * @property _onclickAttributeValue
+ * @description Object reference to the button's current value for the
+ * "onclick" configuration attribute.
+ * @default null
+ * @protected
+ * @type Object
+ */
+ _onclickAttributeValue: null,
+
+
+ /**
+ * @property _activationKeyPressed
+ * @description Boolean indicating if the key(s) that toggle the button's
+ * "active" state have been pressed.
+ * @default false
+ * @protected
+ * @type Boolean
+ */
+ _activationKeyPressed: false,
+
+
+ /**
+ * @property _activationButtonPressed
+ * @description Boolean indicating if the mouse button that toggles
+ * the button's "active" state has been pressed.
+ * @default false
+ * @protected
+ * @type Boolean
+ */
+ _activationButtonPressed: false,
+
+
+ /**
+ * @property _hasKeyEventHandlers
+ * @description Boolean indicating if the button's "blur", "keydown" and
+ * "keyup" event handlers are assigned
+ * @default false
+ * @protected
+ * @type Boolean
+ */
+ _hasKeyEventHandlers: false,
+
+
+ /**
+ * @property _hasMouseEventHandlers
+ * @description Boolean indicating if the button's "mouseout,"
+ * "mousedown," and "mouseup" event handlers are assigned
+ * @default false
+ * @protected
+ * @type Boolean
+ */
+ _hasMouseEventHandlers: false,
+
+
+
+ // Constants
+
+
+ /**
+ * @property NODE_NAME
+ * @description The name of the node to be used for the button's
+ * root element.
+ * @default "SPAN"
+ * @final
+ * @type String
+ */
+ NODE_NAME: "SPAN",
+
+
+ /**
+ * @property CHECK_ACTIVATION_KEYS
+ * @description Array of numbers representing keys that (when pressed)
+ * toggle the button's "checked" attribute.
+ * @default [32]
+ * @final
+ * @type Array
+ */
+ CHECK_ACTIVATION_KEYS: [32],
+
+
+ /**
+ * @property ACTIVATION_KEYS
+ * @description Array of numbers representing keys that (when presed)
+ * toggle the button's "active" state.
+ * @default [13, 32]
+ * @final
+ * @type Array
+ */
+ ACTIVATION_KEYS: [13, 32],
+
+
+ /**
+ * @property OPTION_AREA_WIDTH
+ * @description Width (in pixels) of the area of a split button that
+ * when pressed will display a menu.
+ * @default 20
+ * @final
+ * @type Number
+ */
+ OPTION_AREA_WIDTH: 20,
+
+
+ /**
+ * @property CSS_CLASS_NAME
+ * @description String representing the CSS class(es) to be applied to
+ * the button's root element.
+ * @default "yui-button"
+ * @final
+ * @type String
+ */
+ CSS_CLASS_NAME: "yui-button",
+
+
+ /**
+ * @property RADIO_DEFAULT_TITLE
+ * @description String representing the default title applied to buttons
+ * of type "radio."
+ * @default "Unchecked. Click to check."
+ * @final
+ * @type String
+ */
+ RADIO_DEFAULT_TITLE: "Unchecked. Click to check.",
+
+
+ /**
+ * @property RADIO_CHECKED_TITLE
+ * @description String representing the title applied to buttons of
+ * type "radio" when checked.
+ * @default "Checked. Click another button to uncheck"
+ * @final
+ * @type String
+ */
+ RADIO_CHECKED_TITLE: "Checked. Click another button to uncheck",
+
+
+ /**
+ * @property CHECKBOX_DEFAULT_TITLE
+ * @description String representing the default title applied to
+ * buttons of type "checkbox."
+ * @default "Unchecked. Click to check."
+ * @final
+ * @type String
+ */
+ CHECKBOX_DEFAULT_TITLE: "Unchecked. Click to check.",
+
+
+ /**
+ * @property CHECKBOX_CHECKED_TITLE
+ * @description String representing the title applied to buttons of type
+ * "checkbox" when checked.
+ * @default "Checked. Click to uncheck."
+ * @final
+ * @type String
+ */
+ CHECKBOX_CHECKED_TITLE: "Checked. Click to uncheck.",
+
+
+ /**
+ * @property MENUBUTTON_DEFAULT_TITLE
+ * @description String representing the default title applied to
+ * buttons of type "menu."
+ * @default "Menu collapsed. Click to expand."
+ * @final
+ * @type String
+ */
+ MENUBUTTON_DEFAULT_TITLE: "Menu collapsed. Click to expand.",
+
+
+ /**
+ * @property MENUBUTTON_MENU_VISIBLE_TITLE
+ * @description String representing the title applied to buttons of type
+ * "menu" when the button's menu is visible.
+ * @default "Menu expanded. Click or press Esc to collapse."
+ * @final
+ * @type String
+ */
+ MENUBUTTON_MENU_VISIBLE_TITLE:
+ "Menu expanded. Click or press Esc to collapse.",
+
+
+ /**
+ * @property SPLITBUTTON_DEFAULT_TITLE
+ * @description String representing the default title applied to
+ * buttons of type "split."
+ * @default "Menu collapsed. Click inside option region or press
+ * Ctrl + Shift + M to show the menu."
+ * @final
+ * @type String
+ */
+ SPLITBUTTON_DEFAULT_TITLE: ("Menu collapsed. Click inside option " +
+ "region or press Ctrl + Shift + M to show the menu."),
+
+
+ /**
+ * @property SPLITBUTTON_OPTION_VISIBLE_TITLE
+ * @description String representing the title applied to buttons of type
+ * "split" when the button's menu is visible.
+ * @default "Menu expanded. Press Esc or Ctrl + Shift + M to hide
+ * the menu."
+ * @final
+ * @type String
+ */
+ SPLITBUTTON_OPTION_VISIBLE_TITLE:
+ "Menu expanded. Press Esc or Ctrl + Shift + M to hide the menu.",
+
+
+ /**
+ * @property SUBMIT_TITLE
+ * @description String representing the title applied to buttons of
+ * type "submit."
+ * @default "Click to submit form."
+ * @final
+ * @type String
+ */
+ SUBMIT_TITLE: "Click to submit form.",
+
+
+
+ // Protected attribute setter methods
+
+
+ /**
+ * @method _setType
+ * @description Sets the value of the button's "type" attribute.
+ * @protected
+ * @param {String} p_sType String indicating the value for the button's
+ * "type" attribute.
+ */
+ _setType: function (p_sType) {
+
+ if (p_sType == "split") {
+
+ this.on("option", this._onOption);
+
+ }
+
+ },
+
+
+ /**
+ * @method _setLabel
+ * @description Sets the value of the button's "label" attribute.
+ * @protected
+ * @param {String} p_sLabel String indicating the value for the button's
+ * "label" attribute.
+ */
+ _setLabel: function (p_sLabel) {
+
+ this._button.innerHTML = p_sLabel;
+
+ /*
+ Remove and add the default class name from the root element
+ for Gecko to ensure that the button shrinkwraps to the label.
+ Without this the button will not be rendered at the correct
+ width when the label changes. The most likely cause for this
+ bug is button's use of the Gecko-specific CSS display type of
+ "-moz-inline-box" to simulate "inline-block" supported by IE,
+ Safari and Opera.
+ */
+
+ var sClass,
+ me;
+
+ if (YAHOO.env.ua.gecko && Dom.inDocument(this.get("element"))) {
+
+ me = this;
+ sClass = this.CSS_CLASS_NAME;
+
+ this.removeClass(sClass);
+
+ window.setTimeout(function () {
+
+ me.addClass(sClass);
+
+ }, 0);
+
+ }
+
+ },
+
+
+ /**
+ * @method _setTabIndex
+ * @description Sets the value of the button's "tabindex" attribute.
+ * @protected
+ * @param {Number} p_nTabIndex Number indicating the value for the
+ * button's "tabindex" attribute.
+ */
+ _setTabIndex: function (p_nTabIndex) {
+
+ this._button.tabIndex = p_nTabIndex;
+
+ },
+
+
+ /**
+ * @method _setTitle
+ * @description Sets the value of the button's "title" attribute.
+ * @protected
+ * @param {String} p_nTabIndex Number indicating the value for
+ * the button's "title" attribute.
+ */
+ _setTitle: function (p_sTitle) {
+
+ var sTitle = p_sTitle;
+
+ if (this.get("type") != "link") {
+
+ if (!sTitle) {
+
+ switch (this.get("type")) {
+
+ case "radio":
+
+ sTitle = this.RADIO_DEFAULT_TITLE;
+
+ break;
+
+ case "checkbox":
+
+ sTitle = this.CHECKBOX_DEFAULT_TITLE;
+
+ break;
+
+ case "menu":
+
+ sTitle = this.MENUBUTTON_DEFAULT_TITLE;
+
+ break;
+
+ case "split":
+
+ sTitle = this.SPLITBUTTON_DEFAULT_TITLE;
+
+ break;
+
+ case "submit":
+
+ sTitle = this.SUBMIT_TITLE;
+
+ break;
+
+ }
+
+ }
+
+ this._button.title = sTitle;
+
+ }
+
+ },
+
+
+ /**
+ * @method _setDisabled
+ * @description Sets the value of the button's "disabled" attribute.
+ * @protected
+ * @param {Boolean} p_bDisabled Boolean indicating the value for
+ * the button's "disabled" attribute.
+ */
+ _setDisabled: function (p_bDisabled) {
+
+ if (this.get("type") != "link") {
+
+ if (p_bDisabled) {
+
+ if (this._menu) {
+
+ this._menu.hide();
+
+ }
+
+ if (this.hasFocus()) {
+
+ this.blur();
+
+ }
+
+ this._button.setAttribute("disabled", "disabled");
+
+ this.addStateCSSClasses("disabled");
+
+ this.removeStateCSSClasses("hover");
+ this.removeStateCSSClasses("active");
+ this.removeStateCSSClasses("focus");
+
+ }
+ else {
+
+ this._button.removeAttribute("disabled");
+
+ this.removeStateCSSClasses("disabled");
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _setHref
+ * @description Sets the value of the button's "href" attribute.
+ * @protected
+ * @param {String} p_sHref String indicating the value for the button's
+ * "href" attribute.
+ */
+ _setHref: function (p_sHref) {
+
+ if (this.get("type") == "link") {
+
+ this._button.href = p_sHref;
+
+ }
+
+ },
+
+
+ /**
+ * @method _setTarget
+ * @description Sets the value of the button's "target" attribute.
+ * @protected
+ * @param {String} p_sTarget String indicating the value for the button's
+ * "target" attribute.
+ */
+ _setTarget: function (p_sTarget) {
+
+ if (this.get("type") == "link") {
+
+ this._button.setAttribute("target", p_sTarget);
+
+ }
+
+ },
+
+
+ /**
+ * @method _setChecked
+ * @description Sets the value of the button's "target" attribute.
+ * @protected
+ * @param {Boolean} p_bChecked Boolean indicating the value for
+ * the button's "checked" attribute.
+ */
+ _setChecked: function (p_bChecked) {
+
+ var sType = this.get("type"),
+ sTitle;
+
+ if (sType == "checkbox" || sType == "radio") {
+
+ if (p_bChecked) {
+
+ this.addStateCSSClasses("checked");
+
+ sTitle = (sType == "radio") ?
+ this.RADIO_CHECKED_TITLE :
+ this.CHECKBOX_CHECKED_TITLE;
+
+ }
+ else {
+
+ this.removeStateCSSClasses("checked");
+
+ sTitle = (sType == "radio") ?
+ this.RADIO_DEFAULT_TITLE :
+ this.CHECKBOX_DEFAULT_TITLE;
+
+ }
+
+ this.set("title", sTitle);
+
+ }
+
+ },
+
+
+ /**
+ * @method _setMenu
+ * @description Sets the value of the button's "menu" attribute.
+ * @protected
+ * @param {Object} p_oMenu Object indicating the value for the button's
+ * "menu" attribute.
+ */
+ _setMenu: function (p_oMenu) {
+
+ var bLazyLoad = this.get("lazyloadmenu"),
+ oButtonElement = this.get("element"),
+ sMenuCSSClassName,
+
+ /*
+ Boolean indicating if the value of p_oMenu is an instance
+ of YAHOO.widget.Menu or YAHOO.widget.Overlay.
+ */
+
+ bInstance = false,
+
+
+ oMenu,
+ oMenuElement,
+ oSrcElement,
+ aItems,
+ nItems,
+ oItem,
+ i;
+
+
+ if (!Overlay) {
+
+ this.logger.log("YAHOO.widget.Overlay dependency not met.",
+ "error");
+
+ return false;
+
+ }
+
+
+ if (Menu) {
+
+ sMenuCSSClassName = Menu.prototype.CSS_CLASS_NAME;
+
+ }
+
+
+ function onAppendTo() {
+
+ oMenu.render(oButtonElement.parentNode);
+
+ this.removeListener("appendTo", onAppendTo);
+
+ }
+
+
+ function initMenu() {
+
+ if (oMenu) {
+
+ Dom.addClass(oMenu.element, this.get("menuclassname"));
+ Dom.addClass(oMenu.element,
+ "yui-" + this.get("type") + "-button-menu");
+
+ oMenu.showEvent.subscribe(this._onMenuShow, null, this);
+ oMenu.hideEvent.subscribe(this._onMenuHide, null, this);
+ oMenu.renderEvent.subscribe(this._onMenuRender, null, this);
+
+
+ if (Menu && oMenu instanceof Menu) {
+
+ oMenu.keyDownEvent.subscribe(this._onMenuKeyDown,
+ this, true);
+
+ oMenu.subscribe("click", this._onMenuClick,
+ this, true);
+
+ oMenu.itemAddedEvent.subscribe(this._onMenuItemAdded,
+ this, true);
+
+ oSrcElement = oMenu.srcElement;
+
+ if (oSrcElement &&
+ oSrcElement.nodeName.toUpperCase() == "SELECT") {
+
+ oSrcElement.style.display = "none";
+ oSrcElement.parentNode.removeChild(oSrcElement);
+
+ }
+
+ }
+ else if (Overlay && oMenu instanceof Overlay) {
+
+ if (!m_oOverlayManager) {
+
+ m_oOverlayManager =
+ new YAHOO.widget.OverlayManager();
+
+ }
+
+ m_oOverlayManager.register(oMenu);
+
+ }
+
+
+ this._menu = oMenu;
+
+
+ if (!bInstance) {
+
+ if (bLazyLoad && Menu && !(oMenu instanceof Menu)) {
+
+ /*
+ Mimic Menu's "lazyload" functionality by adding
+ a "beforeshow" event listener that renders the
+ Overlay instance before it is made visible by
+ the button.
+ */
+
+ oMenu.beforeShowEvent.subscribe(
+ this._onOverlayBeforeShow, null, this);
+
+ }
+ else if (!bLazyLoad) {
+
+ if (Dom.inDocument(oButtonElement)) {
+
+ oMenu.render(oButtonElement.parentNode);
+
+ }
+ else {
+
+ this.on("appendTo", onAppendTo);
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+
+ if (p_oMenu && Menu && (p_oMenu instanceof Menu)) {
+
+ oMenu = p_oMenu;
+ aItems = oMenu.getItems();
+ nItems = aItems.length;
+ bInstance = true;
+
+
+ if (nItems > 0) {
+
+ i = nItems - 1;
+
+ do {
+
+ oItem = aItems[i];
+
+ if (oItem) {
+
+ oItem.cfg.subscribeToConfigEvent("selected",
+ this._onMenuItemSelected,
+ oItem,
+ this);
+
+ }
+
+ }
+ while (i--);
+
+ }
+
+ initMenu.call(this);
+
+ }
+ else if (Overlay && p_oMenu && (p_oMenu instanceof Overlay)) {
+
+ oMenu = p_oMenu;
+ bInstance = true;
+
+ oMenu.cfg.setProperty("visible", false);
+ oMenu.cfg.setProperty("context", [oButtonElement, "tl", "bl"]);
+
+ initMenu.call(this);
+
+ }
+ else if (Menu && Lang.isArray(p_oMenu)) {
+
+ this.on("appendTo", function () {
+
+ oMenu = new Menu(Dom.generateId(), { lazyload: bLazyLoad,
+ itemdata: p_oMenu });
+
+ initMenu.call(this);
+
+ });
+
+ }
+ else if (Lang.isString(p_oMenu)) {
+
+ oMenuElement = Dom.get(p_oMenu);
+
+ if (oMenuElement) {
+
+ if (Menu && Dom.hasClass(oMenuElement, sMenuCSSClassName) ||
+ oMenuElement.nodeName.toUpperCase() == "SELECT") {
+
+ oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad });
+
+ initMenu.call(this);
+
+ }
+ else if (Overlay) {
+
+ oMenu = new Overlay(p_oMenu, { visible: false,
+ context: [oButtonElement, "tl", "bl"] });
+
+ initMenu.call(this);
+
+ }
+
+ }
+
+ }
+ else if (p_oMenu && p_oMenu.nodeName) {
+
+ if (Menu && Dom.hasClass(p_oMenu, sMenuCSSClassName) ||
+ p_oMenu.nodeName.toUpperCase() == "SELECT") {
+
+ oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad });
+
+ initMenu.call(this);
+
+ }
+ else if (Overlay) {
+
+ if (!p_oMenu.id) {
+
+ Dom.generateId(p_oMenu);
+
+ }
+
+ oMenu = new Overlay(p_oMenu, { visible: false,
+ context: [oButtonElement, "tl", "bl"] });
+
+ initMenu.call(this);
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _setOnClick
+ * @description Sets the value of the button's "onclick" attribute.
+ * @protected
+ * @param {Object} p_oObject Object indicating the value for the button's
+ * "onclick" attribute.
+ */
+ _setOnClick: function (p_oObject) {
+
+ /*
+ Remove any existing listeners if a "click" event handler
+ has already been specified.
+ */
+
+ if (this._onclickAttributeValue &&
+ (this._onclickAttributeValue != p_oObject)) {
+
+ this.removeListener("click", this._onclickAttributeValue.fn);
+
+ this._onclickAttributeValue = null;
+
+ }
+
+
+ if (!this._onclickAttributeValue &&
+ Lang.isObject(p_oObject) &&
+ Lang.isFunction(p_oObject.fn)) {
+
+ this.on("click", p_oObject.fn, p_oObject.obj, p_oObject.scope);
+
+ this._onclickAttributeValue = p_oObject;
+
+ }
+
+ },
+
+
+ /**
+ * @method _setSelectedMenuItem
+ * @description Sets the value of the button's
+ * "selectedMenuItem" attribute.
+ * @protected
+ * @param {Number} p_nIndex Number representing the index of the item
+ * in the button's menu that is currently selected.
+ */
+ _setSelectedMenuItem: function (p_nIndex) {
+
+ var oMenu = this._menu,
+ oMenuItem;
+
+
+ if (Menu && oMenu && oMenu instanceof Menu) {
+
+ oMenuItem = oMenu.getItem(p_nIndex);
+
+
+ if (oMenuItem && !oMenuItem.cfg.getProperty("selected")) {
+
+ oMenuItem.cfg.setProperty("selected", true);
+
+ }
+
+ }
+
+ },
+
+
+ // Protected methods
+
+
+
+ /**
+ * @method _isActivationKey
+ * @description Determines if the specified keycode is one that toggles
+ * the button's "active" state.
+ * @protected
+ * @param {Number} p_nKeyCode Number representing the keycode to
+ * be evaluated.
+ * @return {Boolean}
+ */
+ _isActivationKey: function (p_nKeyCode) {
+
+ var sType = this.get("type"),
+ aKeyCodes = (sType == "checkbox" || sType == "radio") ?
+ this.CHECK_ACTIVATION_KEYS : this.ACTIVATION_KEYS,
+
+ nKeyCodes = aKeyCodes.length,
+ i;
+
+ if (nKeyCodes > 0) {
+
+ i = nKeyCodes - 1;
+
+ do {
+
+ if (p_nKeyCode == aKeyCodes[i]) {
+
+ return true;
+
+ }
+
+ }
+ while (i--);
+
+ }
+
+ },
+
+
+ /**
+ * @method _isSplitButtonOptionKey
+ * @description Determines if the specified keycode is one that toggles
+ * the display of the split button's menu.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ * @return {Boolean}
+ */
+ _isSplitButtonOptionKey: function (p_oEvent) {
+
+ return (p_oEvent.ctrlKey && p_oEvent.shiftKey &&
+ Event.getCharCode(p_oEvent) == 77);
+
+ },
+
+
+ /**
+ * @method _addListenersToForm
+ * @description Adds event handlers to the button's form.
+ * @protected
+ */
+ _addListenersToForm: function () {
+
+ var oForm = this.getForm(),
+ onFormKeyPress = YAHOO.widget.Button.onFormKeyPress,
+ bHasKeyPressListener,
+ oSrcElement,
+ aListeners,
+ nListeners,
+ i;
+
+
+ if (oForm) {
+
+ Event.on(oForm, "reset", this._onFormReset, null, this);
+ Event.on(oForm, "submit", this.createHiddenFields, null, this);
+
+ oSrcElement = this.get("srcelement");
+
+
+ if (this.get("type") == "submit" ||
+ (oSrcElement && oSrcElement.type == "submit"))
+ {
+
+ aListeners = Event.getListeners(oForm, "keypress");
+ bHasKeyPressListener = false;
+
+ if (aListeners) {
+
+ nListeners = aListeners.length;
+
+ if (nListeners > 0) {
+
+ i = nListeners - 1;
+
+ do {
+
+ if (aListeners[i].fn == onFormKeyPress) {
+
+ bHasKeyPressListener = true;
+ break;
+
+ }
+
+ }
+ while (i--);
+
+ }
+
+ }
+
+
+ if (!bHasKeyPressListener) {
+
+ Event.on(oForm, "keypress", onFormKeyPress);
+
+ }
+
+ }
+
+ }
+
+ },
+
+
+
+ /**
+ * @method _showMenu
+ * @description Shows the button's menu.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event) that triggered
+ * the display of the menu.
+ */
+ _showMenu: function (p_oEvent) {
+
+ if (YAHOO.widget.MenuManager) {
+
+ YAHOO.widget.MenuManager.hideVisible();
+
+ }
+
+
+ if (m_oOverlayManager) {
+
+ m_oOverlayManager.hideAll();
+
+ }
+
+
+ var nViewportOffset = Overlay.VIEWPORT_OFFSET,
+
+ oMenu = this._menu,
+ oButton = this,
+ oButtonEL = oButton.get("element"),
+ bMenuFlipped = false,
+ nButtonY = Dom.getY(oButtonEL),
+ nScrollTop = Dom.getDocumentScrollTop(),
+ nMenuMinScrollHeight,
+ nMenuHeight,
+ oMenuShadow;
+
+
+ if (nScrollTop) {
+
+ nButtonY = nButtonY - nScrollTop;
+
+ }
+
+
+ var nTopRegion = nButtonY,
+ nBottomRegion = (Dom.getViewportHeight() -
+ (nButtonY + oButtonEL.offsetHeight));
+
+
+ /*
+ Uses the Button's position to calculate the availble height
+ above and below it to display its corresponding Menu.
+ */
+
+ function getMenuDisplayRegionHeight() {
+
+ if (bMenuFlipped) {
+
+ return (nTopRegion - nViewportOffset);
+
+ }
+ else {
+
+ return (nBottomRegion - nViewportOffset);
+
+ }
+
+ }
+
+
+
+ /*
+ Sets the Menu's "maxheight" configuration property and trys to
+ place the Menu in the best possible position (either above or
+ below its corresponding Button).
+ */
+
+ function sizeAndPositionMenu() {
+
+ var nDisplayRegionHeight = getMenuDisplayRegionHeight();
+
+
+ if (nMenuHeight > nDisplayRegionHeight) {
+
+ nMenuMinScrollHeight = oMenu.cfg.getProperty("minscrollheight");
+
+
+ if (nDisplayRegionHeight > nMenuMinScrollHeight) {
+
+ oMenu.cfg.setProperty("maxheight",
+ nDisplayRegionHeight);
+
+
+ if (bMenuFlipped) {
+
+ oMenu.align("bl", "tl");
+
+ }
+
+ }
+
+
+ if (nDisplayRegionHeight < nMenuMinScrollHeight) {
+
+ if (bMenuFlipped) {
+
+ /*
+ All possible positions and values for the
+ "maxheight" configuration property have been
+ tried, but none were successful, so fall back
+ to the original size and position.
+ */
+
+ oMenu.cfg.setProperty("context",
+ [oButtonEL, "tl", "bl"], true);
+
+ oMenu.align("tl", "bl");
+
+ }
+ else {
+
+ oMenu.cfg.setProperty("context",
+ [oButtonEL, "bl", "tl"], true);
+
+ oMenu.align("bl", "tl");
+
+ bMenuFlipped = true;
+
+ return sizeAndPositionMenu();
+
+ }
+
+ }
+
+ }
+
+ }
+
+
+ if (Menu && oMenu && (oMenu instanceof Menu)) {
+
+ oMenu.cfg.applyConfig({ context: [oButtonEL, "tl", "bl"],
+ clicktohide: false,
+ visible: true });
+
+ oMenu.cfg.fireQueue();
+
+ oMenu.cfg.setProperty("maxheight", 0);
+
+ oMenu.align("tl", "bl");
+
+
+ /*
+ Stop the propagation of the event so that the MenuManager
+ doesn't blur the menu after it gets focus.
+ */
+
+ if (p_oEvent.type == "mousedown") {
+
+ Event.stopPropagation(p_oEvent);
+
+ }
+
+
+ nMenuHeight = oMenu.element.offsetHeight;
+
+ oMenuShadow = oMenu.element.lastChild;
+
+ sizeAndPositionMenu();
+
+ if (this.get("focusmenu")) {
+
+ this._menu.focus();
+
+ }
+
+ }
+ else if (Overlay && oMenu && (oMenu instanceof Overlay)) {
+
+ oMenu.show();
+ oMenu.align("tl", "bl");
+
+ var nDisplayRegionHeight = getMenuDisplayRegionHeight();
+
+ nMenuHeight = oMenu.element.offsetHeight;
+
+
+ if (nDisplayRegionHeight < nMenuHeight) {
+
+ oMenu.align("bl", "tl");
+
+ bMenuFlipped = true;
+
+ nDisplayRegionHeight = getMenuDisplayRegionHeight();
+
+ if (nDisplayRegionHeight < nMenuHeight) {
+
+ oMenu.align("tl", "bl");
+
+ }
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _hideMenu
+ * @description Hides the button's menu.
+ * @protected
+ */
+ _hideMenu: function () {
+
+ var oMenu = this._menu;
+
+ if (oMenu) {
+
+ oMenu.hide();
+
+ }
+
+ },
+
+
+
+
+ // Protected event handlers
+
+
+ /**
+ * @method _onMouseOver
+ * @description "mouseover" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onMouseOver: function (p_oEvent) {
+
+ if (!this._hasMouseEventHandlers) {
+
+ this.on("mouseout", this._onMouseOut);
+ this.on("mousedown", this._onMouseDown);
+ this.on("mouseup", this._onMouseUp);
+
+ this._hasMouseEventHandlers = true;
+
+ }
+
+ this.addStateCSSClasses("hover");
+
+ if (this._activationButtonPressed) {
+
+ this.addStateCSSClasses("active");
+
+ }
+
+
+ if (this._bOptionPressed) {
+
+ this.addStateCSSClasses("activeoption");
+
+ }
+
+
+ if (this._activationButtonPressed || this._bOptionPressed) {
+
+ Event.removeListener(document, "mouseup", this._onDocumentMouseUp);
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMouseOut
+ * @description "mouseout" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onMouseOut: function (p_oEvent) {
+
+ this.removeStateCSSClasses("hover");
+
+ if (this.get("type") != "menu") {
+
+ this.removeStateCSSClasses("active");
+
+ }
+
+ if (this._activationButtonPressed || this._bOptionPressed) {
+
+ Event.on(document, "mouseup", this._onDocumentMouseUp,
+ null, this);
+
+ }
+
+ },
+
+
+ /**
+ * @method _onDocumentMouseUp
+ * @description "mouseup" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onDocumentMouseUp: function (p_oEvent) {
+
+ this._activationButtonPressed = false;
+ this._bOptionPressed = false;
+
+ var sType = this.get("type"),
+ oTarget,
+ oMenuElement;
+
+ if (sType == "menu" || sType == "split") {
+
+ oTarget = Event.getTarget(p_oEvent);
+ oMenuElement = this._menu.element;
+
+ if (oTarget != oMenuElement &&
+ !Dom.isAncestor(oMenuElement, oTarget)) {
+
+ this.removeStateCSSClasses((sType == "menu" ?
+ "active" : "activeoption"));
+
+ this._hideMenu();
+
+ }
+
+ }
+
+ Event.removeListener(document, "mouseup", this._onDocumentMouseUp);
+
+ },
+
+
+ /**
+ * @method _onMouseDown
+ * @description "mousedown" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onMouseDown: function (p_oEvent) {
+
+ var sType,
+ oElement,
+ nX,
+ me;
+
+
+ function onMouseUp() {
+
+ this._hideMenu();
+ this.removeListener("mouseup", onMouseUp);
+
+ }
+
+
+ if ((p_oEvent.which || p_oEvent.button) == 1) {
+
+
+ if (!this.hasFocus()) {
+
+ this.focus();
+
+ }
+
+
+ sType = this.get("type");
+
+
+ if (sType == "split") {
+
+ oElement = this.get("element");
+ nX = Event.getPageX(p_oEvent) - Dom.getX(oElement);
+
+ if ((oElement.offsetWidth - this.OPTION_AREA_WIDTH) < nX) {
+
+ this.fireEvent("option", p_oEvent);
+
+ }
+ else {
+
+ this.addStateCSSClasses("active");
+
+ this._activationButtonPressed = true;
+
+ }
+
+ }
+ else if (sType == "menu") {
+
+ if (this.isActive()) {
+
+ this._hideMenu();
+
+ this._activationButtonPressed = false;
+
+ }
+ else {
+
+ this._showMenu(p_oEvent);
+
+ this._activationButtonPressed = true;
+
+ }
+
+ }
+ else {
+
+ this.addStateCSSClasses("active");
+
+ this._activationButtonPressed = true;
+
+ }
+
+
+
+ if (sType == "split" || sType == "menu") {
+
+ me = this;
+
+ this._hideMenuTimerId = window.setTimeout(function () {
+
+ me.on("mouseup", onMouseUp);
+
+ }, 250);
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMouseUp
+ * @description "mouseup" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onMouseUp: function (p_oEvent) {
+
+ var sType = this.get("type");
+
+
+ if (this._hideMenuTimerId) {
+
+ window.clearTimeout(this._hideMenuTimerId);
+
+ }
+
+
+ if (sType == "checkbox" || sType == "radio") {
+
+ this.set("checked", !(this.get("checked")));
+
+ }
+
+
+ this._activationButtonPressed = false;
+
+
+ if (this.get("type") != "menu") {
+
+ this.removeStateCSSClasses("active");
+
+ }
+
+ },
+
+
+ /**
+ * @method _onFocus
+ * @description "focus" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onFocus: function (p_oEvent) {
+
+ var oElement;
+
+ this.addStateCSSClasses("focus");
+
+ if (this._activationKeyPressed) {
+
+ this.addStateCSSClasses("active");
+
+ }
+
+ m_oFocusedButton = this;
+
+
+ if (!this._hasKeyEventHandlers) {
+
+ oElement = this._button;
+
+ Event.on(oElement, "blur", this._onBlur, null, this);
+ Event.on(oElement, "keydown", this._onKeyDown, null, this);
+ Event.on(oElement, "keyup", this._onKeyUp, null, this);
+
+ this._hasKeyEventHandlers = true;
+
+ }
+
+
+ this.fireEvent("focus", p_oEvent);
+
+ },
+
+
+ /**
+ * @method _onBlur
+ * @description "blur" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onBlur: function (p_oEvent) {
+
+ this.removeStateCSSClasses("focus");
+
+ if (this.get("type") != "menu") {
+
+ this.removeStateCSSClasses("active");
+
+ }
+
+ if (this._activationKeyPressed) {
+
+ Event.on(document, "keyup", this._onDocumentKeyUp, null, this);
+
+ }
+
+
+ m_oFocusedButton = null;
+
+ this.fireEvent("blur", p_oEvent);
+
+ },
+
+
+ /**
+ * @method _onDocumentKeyUp
+ * @description "keyup" event handler for the document.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onDocumentKeyUp: function (p_oEvent) {
+
+ if (this._isActivationKey(Event.getCharCode(p_oEvent))) {
+
+ this._activationKeyPressed = false;
+
+ Event.removeListener(document, "keyup", this._onDocumentKeyUp);
+
+ }
+
+ },
+
+
+ /**
+ * @method _onKeyDown
+ * @description "keydown" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onKeyDown: function (p_oEvent) {
+
+ var oMenu = this._menu;
+
+
+ if (this.get("type") == "split" &&
+ this._isSplitButtonOptionKey(p_oEvent)) {
+
+ this.fireEvent("option", p_oEvent);
+
+ }
+ else if (this._isActivationKey(Event.getCharCode(p_oEvent))) {
+
+ if (this.get("type") == "menu") {
+
+ this._showMenu(p_oEvent);
+
+ }
+ else {
+
+ this._activationKeyPressed = true;
+
+ this.addStateCSSClasses("active");
+
+ }
+
+ }
+
+
+ if (oMenu && oMenu.cfg.getProperty("visible") &&
+ Event.getCharCode(p_oEvent) == 27) {
+
+ oMenu.hide();
+ this.focus();
+
+ }
+
+ },
+
+
+ /**
+ * @method _onKeyUp
+ * @description "keyup" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onKeyUp: function (p_oEvent) {
+
+ var sType;
+
+ if (this._isActivationKey(Event.getCharCode(p_oEvent))) {
+
+ sType = this.get("type");
+
+ if (sType == "checkbox" || sType == "radio") {
+
+ this.set("checked", !(this.get("checked")));
+
+ }
+
+ this._activationKeyPressed = false;
+
+ if (this.get("type") != "menu") {
+
+ this.removeStateCSSClasses("active");
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _onClick
+ * @description "click" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onClick: function (p_oEvent) {
+
+ var sType = this.get("type"),
+ sTitle,
+ oForm,
+ oSrcElement,
+ oElement,
+ nX;
+
+
+ switch (sType) {
+
+ case "radio":
+ case "checkbox":
+
+ if (this.get("checked")) {
+
+ sTitle = (sType == "radio") ?
+ this.RADIO_CHECKED_TITLE :
+ this.CHECKBOX_CHECKED_TITLE;
+
+ }
+ else {
+
+ sTitle = (sType == "radio") ?
+ this.RADIO_DEFAULT_TITLE :
+ this.CHECKBOX_DEFAULT_TITLE;
+
+ }
+
+ this.set("title", sTitle);
+
+ break;
+
+ case "submit":
+
+ this.submitForm();
+
+ break;
+
+ case "reset":
+
+ oForm = this.getForm();
+
+ if (oForm) {
+
+ oForm.reset();
+
+ }
+
+ break;
+
+ case "menu":
+
+ sTitle = this._menu.cfg.getProperty("visible") ?
+ this.MENUBUTTON_MENU_VISIBLE_TITLE :
+ this.MENUBUTTON_DEFAULT_TITLE;
+
+ this.set("title", sTitle);
+
+ break;
+
+ case "split":
+
+ oElement = this.get("element");
+ nX = Event.getPageX(p_oEvent) - Dom.getX(oElement);
+
+ if ((oElement.offsetWidth - this.OPTION_AREA_WIDTH) < nX) {
+
+ return false;
+
+ }
+ else {
+
+ this._hideMenu();
+
+ oSrcElement = this.get("srcelement");
+
+ if (oSrcElement && oSrcElement.type == "submit") {
+
+ this.submitForm();
+
+ }
+
+ }
+
+ sTitle = this._menu.cfg.getProperty("visible") ?
+ this.SPLITBUTTON_OPTION_VISIBLE_TITLE :
+ this.SPLITBUTTON_DEFAULT_TITLE;
+
+ this.set("title", sTitle);
+
+ break;
+
+ }
+
+ },
+
+
+ /**
+ * @method _onAppendTo
+ * @description "appendTo" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onAppendTo: function (p_oEvent) {
+
+ /*
+ It is necessary to call "_addListenersToForm" using
+ "setTimeout" to make sure that the button's "form" property
+ returns a node reference. Sometimes, if you try to get the
+ reference immediately after appending the field, it is null.
+ */
+
+ var me = this;
+
+ window.setTimeout(function () {
+
+ me._addListenersToForm();
+
+ }, 0);
+
+ },
+
+
+ /**
+ * @method _onFormReset
+ * @description "reset" event handler for the button's form.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event
+ * object passed back by the event utility (YAHOO.util.Event).
+ */
+ _onFormReset: function (p_oEvent) {
+
+ var sType = this.get("type"),
+ oMenu = this._menu;
+
+ if (sType == "checkbox" || sType == "radio") {
+
+ this.resetValue("checked");
+
+ }
+
+
+ if (Menu && oMenu && (oMenu instanceof Menu)) {
+
+ this.resetValue("selectedMenuItem");
+
+ }
+
+ },
+
+
+ /**
+ * @method _onDocumentMouseDown
+ * @description "mousedown" event handler for the document.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onDocumentMouseDown: function (p_oEvent) {
+
+ var oTarget = Event.getTarget(p_oEvent),
+ oButtonElement = this.get("element"),
+ oMenuElement = this._menu.element;
+
+
+ if (oTarget != oButtonElement &&
+ !Dom.isAncestor(oButtonElement, oTarget) &&
+ oTarget != oMenuElement &&
+ !Dom.isAncestor(oMenuElement, oTarget)) {
+
+ this._hideMenu();
+
+ Event.removeListener(document, "mousedown",
+ this._onDocumentMouseDown);
+
+ }
+
+ },
+
+
+ /**
+ * @method _onOption
+ * @description "option" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onOption: function (p_oEvent) {
+
+ if (this.hasClass("yui-split-button-activeoption")) {
+
+ this._hideMenu();
+
+ this._bOptionPressed = false;
+
+ }
+ else {
+
+ this._showMenu(p_oEvent);
+
+ this._bOptionPressed = true;
+
+ }
+
+ },
+
+
+ /**
+ * @method _onOverlayBeforeShow
+ * @description "beforeshow" event handler for the
+ * YAHOO.widget.Overlay instance
+ * serving as the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ */
+ _onOverlayBeforeShow: function (p_sType) {
+
+ var oMenu = this._menu;
+
+ oMenu.render(this.get("element").parentNode);
+
+ oMenu.beforeShowEvent.unsubscribe(this._onOverlayBeforeShow);
+
+ },
+
+
+ /**
+ * @method _onMenuShow
+ * @description "show" event handler for the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ */
+ _onMenuShow: function (p_sType) {
+
+ Event.on(document, "mousedown", this._onDocumentMouseDown,
+ null, this);
+
+ var sTitle,
+ sState;
+
+ if (this.get("type") == "split") {
+
+ sTitle = this.SPLITBUTTON_OPTION_VISIBLE_TITLE;
+ sState = "activeoption";
+
+ }
+ else {
+
+ sTitle = this.MENUBUTTON_MENU_VISIBLE_TITLE;
+ sState = "active";
+
+ }
+
+ this.addStateCSSClasses(sState);
+ this.set("title", sTitle);
+
+ },
+
+
+ /**
+ * @method _onMenuHide
+ * @description "hide" event handler for the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ */
+ _onMenuHide: function (p_sType) {
+
+ var oMenu = this._menu,
+ sTitle,
+ sState;
+
+
+ if (this.get("type") == "split") {
+
+ sTitle = this.SPLITBUTTON_DEFAULT_TITLE;
+ sState = "activeoption";
+
+ }
+ else {
+
+ sTitle = this.MENUBUTTON_DEFAULT_TITLE;
+ sState = "active";
+ }
+
+
+ this.removeStateCSSClasses(sState);
+ this.set("title", sTitle);
+
+
+ if (this.get("type") == "split") {
+
+ this._bOptionPressed = false;
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMenuKeyDown
+ * @description "keydown" event handler for the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ * @param {Array} p_aArgs Array of arguments sent when the event
+ * was fired.
+ */
+ _onMenuKeyDown: function (p_sType, p_aArgs) {
+
+ var oEvent = p_aArgs[0];
+
+ if (Event.getCharCode(oEvent) == 27) {
+
+ this.focus();
+
+ if (this.get("type") == "split") {
+
+ this._bOptionPressed = false;
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMenuRender
+ * @description "render" event handler for the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the
+ * event thatwas fired.
+ */
+ _onMenuRender: function (p_sType) {
+
+ var oButtonElement = this.get("element"),
+ oButtonParent = oButtonElement.parentNode,
+ oMenuElement = this._menu.element;
+
+
+ if (oButtonParent != oMenuElement.parentNode) {
+
+ oButtonParent.appendChild(oMenuElement);
+
+ }
+
+ this.set("selectedMenuItem", this.get("selectedMenuItem"));
+
+ },
+
+
+ /**
+ * @method _onMenuItemSelected
+ * @description "selectedchange" event handler for each item in the
+ * button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ * @param {Array} p_aArgs Array of arguments sent when the event
+ * was fired.
+ * @param {MenuItem} p_oItem Object representing the menu item that
+ * subscribed to the event.
+ */
+ _onMenuItemSelected: function (p_sType, p_aArgs, p_oItem) {
+
+ var bSelected = p_aArgs[0];
+
+ if (bSelected) {
+
+ this.set("selectedMenuItem", p_oItem);
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMenuItemAdded
+ * @description "itemadded" event handler for the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ * @param {Array} p_aArgs Array of arguments sent when the event
+ * was fired.
+ * @param {
+ * YAHOO.widget.MenuItem} p_oItem Object representing the menu
+ * item that subscribed to the event.
+ */
+ _onMenuItemAdded: function (p_sType, p_aArgs, p_oItem) {
+
+ var oItem = p_aArgs[0];
+
+ oItem.cfg.subscribeToConfigEvent("selected",
+ this._onMenuItemSelected, oItem, this);
+
+ },
+
+
+ /**
+ * @method _onMenuClick
+ * @description "click" event handler for the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ * @param {Array} p_aArgs Array of arguments sent when the event
+ * was fired.
+ */
+ _onMenuClick: function (p_sType, p_aArgs) {
+
+ var oItem = p_aArgs[1],
+ oSrcElement;
+
+ if (oItem) {
+
+ oSrcElement = this.get("srcelement");
+
+ if (oSrcElement && oSrcElement.type == "submit") {
+
+ this.submitForm();
+
+ }
+
+ this._hideMenu();
+
+ }
+
+ },
+
+
+
+ // Public methods
+
+
+ /**
+ * @method createButtonElement
+ * @description Creates the button's HTML elements.
+ * @param {String} p_sType String indicating the type of element
+ * to create.
+ * @return {HTMLElement}
+ */
+ createButtonElement: function (p_sType) {
+
+ var sNodeName = this.NODE_NAME,
+ oElement = document.createElement(sNodeName);
+
+ oElement.innerHTML = "<" + sNodeName + " class=\"first-child\">" +
+ (p_sType == "link" ? "" :
+ "") + "" + sNodeName + ">";
+
+ return oElement;
+
+ },
+
+
+ /**
+ * @method addStateCSSClasses
+ * @description Appends state-specific CSS classes to the button's root
+ * DOM element.
+ */
+ addStateCSSClasses: function (p_sState) {
+
+ var sType = this.get("type");
+
+ if (Lang.isString(p_sState)) {
+
+ if (p_sState != "activeoption") {
+
+ this.addClass(this.CSS_CLASS_NAME + ("-" + p_sState));
+
+ }
+
+ this.addClass("yui-" + sType + ("-button-" + p_sState));
+
+ }
+
+ },
+
+
+ /**
+ * @method removeStateCSSClasses
+ * @description Removes state-specific CSS classes to the button's root
+ * DOM element.
+ */
+ removeStateCSSClasses: function (p_sState) {
+
+ var sType = this.get("type");
+
+ if (Lang.isString(p_sState)) {
+
+ this.removeClass(this.CSS_CLASS_NAME + ("-" + p_sState));
+ this.removeClass("yui-" + sType + ("-button-" + p_sState));
+
+ }
+
+ },
+
+
+ /**
+ * @method createHiddenFields
+ * @description Creates the button's hidden form field and appends it
+ * to its parent form.
+ * @return {HTMLInputElement|Array}
+ */
+ createHiddenFields: function () {
+
+ this.removeHiddenFields();
+
+ var oForm = this.getForm(),
+ oButtonField,
+ sType,
+ bCheckable,
+ oMenu,
+ oMenuItem,
+ sName,
+ oValue,
+ oMenuField;
+
+
+ if (oForm && !this.get("disabled")) {
+
+ sType = this.get("type");
+ bCheckable = (sType == "checkbox" || sType == "radio");
+
+
+ if (bCheckable || (m_oSubmitTrigger == this)) {
+
+ this.logger.log("Creating hidden field.");
+
+ oButtonField = createInputElement(
+ (bCheckable ? sType : "hidden"),
+ this.get("name"),
+ this.get("value"),
+ this.get("checked"));
+
+
+ if (oButtonField) {
+
+ if (bCheckable) {
+
+ oButtonField.style.display = "none";
+
+ }
+
+ oForm.appendChild(oButtonField);
+
+ }
+
+ }
+
+
+ oMenu = this._menu;
+
+
+ if (Menu && oMenu && (oMenu instanceof Menu)) {
+
+ this.logger.log("Creating hidden field for menu.");
+
+ oMenuField = oMenu.srcElement;
+ oMenuItem = this.get("selectedMenuItem");
+
+ if (oMenuItem) {
+
+ if (oMenuField &&
+ oMenuField.nodeName.toUpperCase() == "SELECT") {
+
+ oForm.appendChild(oMenuField);
+ oMenuField.selectedIndex = oMenuItem.index;
+
+ }
+ else {
+
+ oValue = (oMenuItem.value === null ||
+ oMenuItem.value === "") ?
+ oMenuItem.cfg.getProperty("text") :
+ oMenuItem.value;
+
+ sName = this.get("name");
+
+ if (oValue && sName) {
+
+ oMenuField = createInputElement("hidden",
+ (sName + "_options"),
+ oValue);
+
+ oForm.appendChild(oMenuField);
+
+ }
+
+ }
+
+ }
+
+ }
+
+
+ if (oButtonField && oMenuField) {
+
+ this._hiddenFields = [oButtonField, oMenuField];
+
+ }
+ else if (!oButtonField && oMenuField) {
+
+ this._hiddenFields = oMenuField;
+
+ }
+ else if (oButtonField && !oMenuField) {
+
+ this._hiddenFields = oButtonField;
+
+ }
+
+
+ return this._hiddenFields;
+
+ }
+
+ },
+
+
+ /**
+ * @method removeHiddenFields
+ * @description Removes the button's hidden form field(s) from its
+ * parent form.
+ */
+ removeHiddenFields: function () {
+
+ var oField = this._hiddenFields,
+ nFields,
+ i;
+
+ function removeChild(p_oElement) {
+
+ if (Dom.inDocument(p_oElement)) {
+
+ p_oElement.parentNode.removeChild(p_oElement);
+
+ }
+
+ }
+
+
+ if (oField) {
+
+ if (Lang.isArray(oField)) {
+
+ nFields = oField.length;
+
+ if (nFields > 0) {
+
+ i = nFields - 1;
+
+ do {
+
+ removeChild(oField[i]);
+
+ }
+ while (i--);
+
+ }
+
+ }
+ else {
+
+ removeChild(oField);
+
+ }
+
+ this._hiddenFields = null;
+
+ }
+
+ },
+
+
+ /**
+ * @method submitForm
+ * @description Submits the form to which the button belongs. Returns
+ * true if the form was submitted successfully, false if the submission
+ * was cancelled.
+ * @protected
+ * @return {Boolean}
+ */
+ submitForm: function () {
+
+ var oForm = this.getForm(),
+
+ oSrcElement = this.get("srcelement"),
+
+ /*
+ Boolean indicating if the event fired successfully
+ (was not cancelled by any handlers)
+ */
+
+ bSubmitForm = false,
+
+ oEvent;
+
+
+ if (oForm) {
+
+ if (this.get("type") == "submit" ||
+ (oSrcElement && oSrcElement.type == "submit"))
+ {
+
+ m_oSubmitTrigger = this;
+
+ }
+
+
+ if (YAHOO.env.ua.ie) {
+
+ bSubmitForm = oForm.fireEvent("onsubmit");
+
+ }
+ else { // Gecko, Opera, and Safari
+
+ oEvent = document.createEvent("HTMLEvents");
+ oEvent.initEvent("submit", true, true);
+
+ bSubmitForm = oForm.dispatchEvent(oEvent);
+
+ }
+
+
+ /*
+ In IE and Safari, dispatching a "submit" event to a form
+ WILL cause the form's "submit" event to fire, but WILL NOT
+ submit the form. Therefore, we need to call the "submit"
+ method as well.
+ */
+
+ if ((YAHOO.env.ua.ie || YAHOO.env.ua.webkit) && bSubmitForm) {
+
+ oForm.submit();
+
+ }
+
+ }
+
+ return bSubmitForm;
+
+ },
+
+
+ /**
+ * @method init
+ * @description The Button class's initialization method.
+ * @param {String} p_oElement String specifying the id attribute of the
+ * <input>
, <button>
,
+ * <a>
, or <span>
element to
+ * be used to create the button.
+ * @param {HTMLInputElement|HTMLButtonElement|
+ * HTMLElement} p_oElement Object reference for the
+ * <input>
, <button>
,
+ * <a>
, or <span>
element to be
+ * used to create the button.
+ * @param {Object} p_oElement Object literal specifying a set of
+ * configuration attributes used to create the button.
+ * @param {Object} p_oAttributes Optional. Object literal specifying a
+ * set of configuration attributes used to create the button.
+ */
+ init: function (p_oElement, p_oAttributes) {
+
+ var sNodeName = p_oAttributes.type == "link" ? "a" : "button",
+ oSrcElement = p_oAttributes.srcelement,
+ oButton = p_oElement.getElementsByTagName(sNodeName)[0],
+ oInput;
+
+
+ if (!oButton) {
+
+ oInput = p_oElement.getElementsByTagName("input")[0];
+
+
+ if (oInput) {
+
+ oButton = document.createElement("button");
+ oButton.setAttribute("type", "button");
+
+ oInput.parentNode.replaceChild(oButton, oInput);
+
+ }
+
+ }
+
+ this._button = oButton;
+
+
+ YAHOO.widget.Button.superclass.init.call(this, p_oElement,
+ p_oAttributes);
+
+
+ m_oButtons[this.get("id")] = this;
+
+
+ this.addClass(this.CSS_CLASS_NAME);
+
+ this.addClass("yui-" + this.get("type") + "-button");
+
+ Event.on(this._button, "focus", this._onFocus, null, this);
+ this.on("mouseover", this._onMouseOver);
+ this.on("click", this._onClick);
+ this.on("appendTo", this._onAppendTo);
+
+
+ var oContainer = this.get("container"),
+ oElement = this.get("element"),
+ bElInDoc = Dom.inDocument(oElement),
+ oParentNode;
+
+
+ if (oContainer) {
+
+ if (oSrcElement && oSrcElement != oElement) {
+
+ oParentNode = oSrcElement.parentNode;
+
+ if (oParentNode) {
+
+ oParentNode.removeChild(oSrcElement);
+
+ }
+
+ }
+
+ if (Lang.isString(oContainer)) {
+
+ Event.onContentReady(oContainer, function () {
+
+ this.appendTo(oContainer);
+
+ }, null, this);
+
+ }
+ else {
+
+ this.appendTo(oContainer);
+
+ }
+
+ }
+ else if (!bElInDoc && oSrcElement && oSrcElement != oElement) {
+
+ oParentNode = oSrcElement.parentNode;
+
+ if (oParentNode) {
+
+ this.fireEvent("beforeAppendTo", {
+ type: "beforeAppendTo",
+ target: oParentNode
+ });
+
+ oParentNode.replaceChild(oElement, oSrcElement);
+
+ this.fireEvent("appendTo", {
+ type: "appendTo",
+ target: oParentNode
+ });
+
+ }
+
+ }
+ else if (this.get("type") != "link" && bElInDoc && oSrcElement &&
+ oSrcElement == oElement) {
+
+ this._addListenersToForm();
+
+ }
+
+ this.logger.log("Initialization completed.");
+
+ },
+
+
+ /**
+ * @method initAttributes
+ * @description Initializes all of the configuration attributes used to
+ * create the button.
+ * @param {Object} p_oAttributes Object literal specifying a set of
+ * configuration attributes used to create the button.
+ */
+ initAttributes: function (p_oAttributes) {
+
+ var oAttributes = p_oAttributes || {};
+
+ YAHOO.widget.Button.superclass.initAttributes.call(this,
+ oAttributes);
+
+
+ /**
+ * @attribute type
+ * @description String specifying the button's type. Possible
+ * values are: "push," "link," "submit," "reset," "checkbox,"
+ * "radio," "menu," and "split."
+ * @default "push"
+ * @type String
+ */
+ this.setAttributeConfig("type", {
+
+ value: (oAttributes.type || "push"),
+ validator: Lang.isString,
+ writeOnce: true,
+ method: this._setType
+
+ });
+
+
+ /**
+ * @attribute label
+ * @description String specifying the button's text label
+ * or innerHTML.
+ * @default null
+ * @type String
+ */
+ this.setAttributeConfig("label", {
+
+ value: oAttributes.label,
+ validator: Lang.isString,
+ method: this._setLabel
+
+ });
+
+
+ /**
+ * @attribute value
+ * @description Object specifying the value for the button.
+ * @default null
+ * @type Object
+ */
+ this.setAttributeConfig("value", {
+
+ value: oAttributes.value
+
+ });
+
+
+ /**
+ * @attribute name
+ * @description String specifying the name for the button.
+ * @default null
+ * @type String
+ */
+ this.setAttributeConfig("name", {
+
+ value: oAttributes.name,
+ validator: Lang.isString
+
+ });
+
+
+ /**
+ * @attribute tabindex
+ * @description Number specifying the tabindex for the button.
+ * @default null
+ * @type Number
+ */
+ this.setAttributeConfig("tabindex", {
+
+ value: oAttributes.tabindex,
+ validator: Lang.isNumber,
+ method: this._setTabIndex
+
+ });
+
+
+ /**
+ * @attribute title
+ * @description String specifying the title for the button.
+ * @default null
+ * @type String
+ */
+ this.configureAttribute("title", {
+
+ value: oAttributes.title,
+ validator: Lang.isString,
+ method: this._setTitle
+
+ });
+
+
+ /**
+ * @attribute disabled
+ * @description Boolean indicating if the button should be disabled.
+ * (Disabled buttons are dimmed and will not respond to user input
+ * or fire events. Does not apply to button's of type "link.")
+ * @default false
+ * @type Boolean
+ */
+ this.setAttributeConfig("disabled", {
+
+ value: (oAttributes.disabled || false),
+ validator: Lang.isBoolean,
+ method: this._setDisabled
+
+ });
+
+
+ /**
+ * @attribute href
+ * @description String specifying the href for the button. Applies
+ * only to buttons of type "link."
+ * @type String
+ */
+ this.setAttributeConfig("href", {
+
+ value: oAttributes.href,
+ validator: Lang.isString,
+ method: this._setHref
+
+ });
+
+
+ /**
+ * @attribute target
+ * @description String specifying the target for the button.
+ * Applies only to buttons of type "link."
+ * @type String
+ */
+ this.setAttributeConfig("target", {
+
+ value: oAttributes.target,
+ validator: Lang.isString,
+ method: this._setTarget
+
+ });
+
+
+ /**
+ * @attribute checked
+ * @description Boolean indicating if the button is checked.
+ * Applies only to buttons of type "radio" and "checkbox."
+ * @default false
+ * @type Boolean
+ */
+ this.setAttributeConfig("checked", {
+
+ value: (oAttributes.checked || false),
+ validator: Lang.isBoolean,
+ method: this._setChecked
+
+ });
+
+
+ /**
+ * @attribute container
+ * @description HTML element reference or string specifying the id
+ * attribute of the HTML element that the button's markup should be
+ * rendered into.
+ * @type HTMLElement|String
+ * @default null
+ */
+ this.setAttributeConfig("container", {
+
+ value: oAttributes.container,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @attribute srcelement
+ * @description Object reference to the HTML element (either
+ * <input>
or <span>
)
+ * used to create the button.
+ * @type HTMLElement|String
+ * @default null
+ */
+ this.setAttributeConfig("srcelement", {
+
+ value: oAttributes.srcelement,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @attribute menu
+ * @description Object specifying the menu for the button.
+ * The value can be one of the following:
+ *
+ *
+ * @type YAHOO.widget.Menu|YAHOO.widget.Overlay|HTMLElement|String|Array
+ * @default null
+ */
+ this.setAttributeConfig("menu", {
+
+ value: null,
+ method: this._setMenu,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @attribute lazyloadmenu
+ * @description Boolean indicating the value to set for the
+ * "lazyload"
+ * configuration property of the button's menu. Setting
+ * "lazyloadmenu" to <div>
+ *
element used to create the menu. By default the menu
+ * will be created as an instance of
+ * YAHOO.widget.Overlay.
+ * If the
+ * default CSS class name for YAHOO.widget.Menu is applied to
+ * the <div>
element, it will be created as an
+ * instance of YAHOO.widget.Menu
+ * .<select>
element used to create the menu.
+ * <div>
element
+ * used to create the menu.<select>
element
+ * used to create the menu.true
will defer rendering of
+ * the button's menu until the first time it is made visible.
+ * If "lazyloadmenu" is set to false
, the button's
+ * menu will be rendered immediately if the button is in the
+ * document, or in response to the button's "appendTo" event if
+ * the button is not yet in the document. In either case, the
+ * menu is rendered into the button's parent HTML element.
+ * This attribute does not apply if a
+ * YAHOO.widget.Menu or
+ * YAHOO.widget.Overlay
+ * instance is passed as the value of the button's "menu"
+ * configuration attribute.
+ * YAHOO.widget.Menu or
+ * YAHOO.widget.Overlay instances should be rendered before
+ * being set as the value for the "menu" configuration
+ * attribute.
+ * @default true
+ * @type Boolean
+ */
+ this.setAttributeConfig("lazyloadmenu", {
+
+ value: (oAttributes.lazyloadmenu === false ? false : true),
+ validator: Lang.isBoolean,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @attribute menuclassname
+ * @description String representing the CSS class name to be
+ * applied to the root element of the button's menu.
+ * @type String
+ * @default "yui-button-menu"
+ */
+ this.setAttributeConfig("menuclassname", {
+
+ value: (oAttributes.menuclassname || "yui-button-menu"),
+ validator: Lang.isString,
+ method: this._setMenuClassName,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @attribute selectedMenuItem
+ * @description Object representing the item in the button's menu
+ * that is currently selected.
+ * @type Number
+ * @default null
+ */
+ this.setAttributeConfig("selectedMenuItem", {
+
+ value: null,
+ method: this._setSelectedMenuItem
+
+ });
+
+
+ /**
+ * @attribute onclick
+ * @description Object literal representing the code to be executed
+ * when the button is clicked. Format:
{
+ * @type Object
+ * @default null
+ */
+ this.setAttributeConfig("onclick", {
+
+ value: oAttributes.onclick,
+ method: this._setOnClick
+
+ });
+
+
+ /**
+ * @attribute focusmenu
+ * @description Boolean indicating whether or not the button's menu
+ * should be focused when it is made visible.
+ * @type Boolean
+ * @default true
+ */
+ this.setAttributeConfig("focusmenu", {
+
+ value: (oAttributes.focusmenu === false ? false : true),
+ validator: Lang.isBoolean
+
+ });
+
+ },
+
+
+ /**
+ * @method focus
+ * @description Causes the button to receive the focus and fires the
+ * button's "focus" event.
+ */
+ focus: function () {
+
+ if (!this.get("disabled")) {
+
+ this._button.focus();
+
+ }
+
+ },
+
+
+ /**
+ * @method blur
+ * @description Causes the button to lose focus and fires the button's
+ * "blur" event.
+ */
+ blur: function () {
+
+ if (!this.get("disabled")) {
+
+ this._button.blur();
+
+ }
+
+ },
+
+
+ /**
+ * @method hasFocus
+ * @description Returns a boolean indicating whether or not the button
+ * has focus.
+ * @return {Boolean}
+ */
+ hasFocus: function () {
+
+ return (m_oFocusedButton == this);
+
+ },
+
+
+ /**
+ * @method isActive
+ * @description Returns a boolean indicating whether or not the button
+ * is active.
+ * @return {Boolean}
+ */
+ isActive: function () {
+
+ return this.hasClass(this.CSS_CLASS_NAME + "-active");
+
+ },
+
+
+ /**
+ * @method getMenu
+ * @description Returns a reference to the button's menu.
+ * @return {
+ * YAHOO.widget.Overlay|YAHOO.widget.Menu}
+ */
+ getMenu: function () {
+
+ return this._menu;
+
+ },
+
+
+ /**
+ * @method getForm
+ * @description Returns a reference to the button's parent form.
+ * @return {HTMLFormElement}
+ */
+ getForm: function () {
+
+ return this._button.form;
+
+ },
+
+
+ /**
+ * @method getHiddenFields
+ * @description Returns an
+ * fn: Function, // The handler to call
+ * when the event fires.
obj: Object,
+ * // An object to pass back to the handler.
+ * scope: Object // The object to use
+ * for the scope of the handler.
} <input>
element or
+ * array of form elements used to represent the button when its parent
+ * form is submitted.
+ * @return {HTMLInputElement|Array}
+ */
+ getHiddenFields: function () {
+
+ return this._hiddenFields;
+
+ },
+
+
+ /**
+ * @method destroy
+ * @description Removes the button's element from its parent element and
+ * removes all event handlers.
+ */
+ destroy: function () {
+
+ this.logger.log("Destroying ...");
+
+ var oElement = this.get("element"),
+ oParentNode = oElement.parentNode,
+ oMenu = this._menu,
+ aButtons;
+
+ if (oMenu) {
+
+ this.logger.log("Destroying menu.");
+
+ if (m_oOverlayManager && m_oOverlayManager.find(oMenu)) {
+
+ m_oOverlayManager.remove(oMenu);
+
+ }
+
+ oMenu.destroy();
+
+ }
+
+ this.logger.log("Removing DOM event listeners.");
+
+ Event.purgeElement(oElement);
+ Event.purgeElement(this._button);
+ Event.removeListener(document, "mouseup", this._onDocumentMouseUp);
+ Event.removeListener(document, "keyup", this._onDocumentKeyUp);
+ Event.removeListener(document, "mousedown",
+ this._onDocumentMouseDown);
+
+
+ var oForm = this.getForm();
+
+ if (oForm) {
+
+ Event.removeListener(oForm, "reset", this._onFormReset);
+ Event.removeListener(oForm, "submit", this.createHiddenFields);
+
+ }
+
+ this.logger.log("Removing CustomEvent listeners.");
+
+ this.unsubscribeAll();
+
+ if (oParentNode) {
+
+ oParentNode.removeChild(oElement);
+
+ }
+
+ this.logger.log("Removing from document.");
+
+ delete m_oButtons[this.get("id")];
+
+ aButtons = Dom.getElementsByClassName(this.CSS_CLASS_NAME,
+ this.NODE_NAME, oForm);
+
+ if (Lang.isArray(aButtons) && aButtons.length === 0) {
+
+ Event.removeListener(oForm, "keypress",
+ YAHOO.widget.Button.onFormKeyPress);
+
+ }
+
+ this.logger.log("Destroyed.");
+
+ },
+
+
+ fireEvent: function (p_sType , p_aArgs) {
+
+ var sType = arguments[0];
+
+ // Disabled buttons should not respond to DOM events
+
+ if (this.DOM_EVENTS[sType] && this.get("disabled")) {
+
+ return;
+
+ }
+
+ return YAHOO.widget.Button.superclass.fireEvent.apply(this, arguments);
+
+ },
+
+
+ /**
+ * @method toString
+ * @description Returns a string representing the button.
+ * @return {String}
+ */
+ toString: function () {
+
+ return ("Button " + this.get("id"));
+
+ }
+
+ });
+
+
+ /**
+ * @method YAHOO.widget.Button.onFormKeyPress
+ * @description "keypress" event handler for the button's form.
+ * @param {Event} p_oEvent Object representing the DOM event object passed
+ * back by the event utility (YAHOO.util.Event).
+ */
+ YAHOO.widget.Button.onFormKeyPress = function (p_oEvent) {
+
+ var oTarget = Event.getTarget(p_oEvent),
+ nCharCode = Event.getCharCode(p_oEvent),
+ sNodeName = oTarget.nodeName && oTarget.nodeName.toUpperCase(),
+ sType = oTarget.type,
+
+ /*
+ Boolean indicating if the form contains any enabled or
+ disabled YUI submit buttons
+ */
+
+ bFormContainsYUIButtons = false,
+
+ oButton,
+
+ oYUISubmitButton, // The form's first, enabled YUI submit button
+
+ /*
+ The form's first, enabled HTML submit button that precedes any
+ YUI submit button
+ */
+
+ oPrecedingSubmitButton,
+
+
+ /*
+ The form's first, enabled HTML submit button that follows a
+ YUI button
+ */
+
+ oFollowingSubmitButton;
+
+
+ function isSubmitButton(p_oElement) {
+
+ var sId,
+ oSrcElement;
+
+ switch (p_oElement.nodeName.toUpperCase()) {
+
+ case "INPUT":
+ case "BUTTON":
+
+ if (p_oElement.type == "submit" && !p_oElement.disabled) {
+
+ if (!bFormContainsYUIButtons &&
+ !oPrecedingSubmitButton) {
+
+ oPrecedingSubmitButton = p_oElement;
+
+ }
+
+ if (oYUISubmitButton && !oFollowingSubmitButton) {
+
+ oFollowingSubmitButton = p_oElement;
+
+ }
+
+ }
+
+ break;
+
+
+ default:
+
+ sId = p_oElement.id;
+
+ if (sId) {
+
+ oButton = m_oButtons[sId];
+
+ if (oButton) {
+
+ bFormContainsYUIButtons = true;
+
+ if (!oButton.get("disabled")) {
+
+ oSrcElement = oButton.get("srcelement");
+
+ if (!oYUISubmitButton &&
+ (oButton.get("type") == "submit" ||
+ (oSrcElement && oSrcElement.type == "submit")))
+ {
+
+ oYUISubmitButton = oButton;
+
+ }
+
+ }
+
+ }
+
+ }
+
+ break;
+
+ }
+
+ }
+
+
+ if (nCharCode == 13 && ((sNodeName == "INPUT" && (sType == "text" ||
+ sType == "password" || sType == "checkbox" || sType == "radio" ||
+ sType == "file")) || sNodeName == "SELECT"))
+ {
+
+ Dom.getElementsBy(isSubmitButton, "*", this);
+
+
+ if (oPrecedingSubmitButton) {
+
+ /*
+ Need to set focus to the first enabled submit button
+ to make sure that IE includes its name and value
+ in the form's data set.
+ */
+
+ oPrecedingSubmitButton.focus();
+
+ }
+ else if (!oPrecedingSubmitButton && oYUISubmitButton) {
+
+ if (oFollowingSubmitButton) {
+
+ /*
+ Need to call "preventDefault" to ensure that
+ the name and value of the regular submit button
+ following the YUI button doesn't get added to the
+ form's data set when it is submitted.
+ */
+
+ Event.preventDefault(p_oEvent);
+
+ }
+
+ oYUISubmitButton.submitForm();
+
+ }
+
+ }
+
+ };
+
+
+ /**
+ * @method YAHOO.widget.Button.addHiddenFieldsToForm
+ * @description Searches the specified form and adds hidden fields for
+ * instances of YAHOO.widget.Button that are of type "radio," "checkbox,"
+ * "menu," and "split."
+ * @param {HTMLFormElement} p_oForm Object reference
+ * for the form to search.
+ */
+ YAHOO.widget.Button.addHiddenFieldsToForm = function (p_oForm) {
+
+ var aButtons = Dom.getElementsByClassName(
+ YAHOO.widget.Button.prototype.CSS_CLASS_NAME,
+ "*",
+ p_oForm),
+
+ nButtons = aButtons.length,
+ oButton,
+ sId,
+ i;
+
+ if (nButtons > 0) {
+
+ YAHOO.log("Form contains " + nButtons + " YUI buttons.");
+
+ for (i = 0; i < nButtons; i++) {
+
+ sId = aButtons[i].id;
+
+ if (sId) {
+
+ oButton = m_oButtons[sId];
+
+ if (oButton) {
+
+ oButton.createHiddenFields();
+
+ }
+
+ }
+
+ }
+
+ }
+
+ };
+
+
+ /**
+ * @method YAHOO.widget.Button.getButton
+ * @description Returns a button with the specified id.
+ * @param {String} p_sId String specifying the id of the root node of the
+ * HTML element representing the button to be retrieved.
+ * @return {YAHOO.widget.Button}
+ */
+ YAHOO.widget.Button.getButton = function (p_sId) {
+
+ var oButton = m_oButtons[p_sId];
+
+ if (oButton) {
+
+ return oButton;
+
+ }
+
+ };
+
+
+ // Events
+
+
+ /**
+ * @event focus
+ * @description Fires when the menu item receives focus. Passes back a
+ * single object representing the original DOM event object passed back by
+ * the event utility (YAHOO.util.Event) when the event was fired. See
+ * Element.addListener
+ * for more information on listening for this event.
+ * @type YAHOO.util.CustomEvent
+ */
+
+
+ /**
+ * @event blur
+ * @description Fires when the menu item loses the input focus. Passes back
+ * a single object representing the original DOM event object passed back by
+ * the event utility (YAHOO.util.Event) when the event was fired. See
+ * Element.addListener for
+ * more information on listening for this event.
+ * @type YAHOO.util.CustomEvent
+ */
+
+
+ /**
+ * @event option
+ * @description Fires when the user invokes the button's option. Passes
+ * back a single object representing the original DOM event (either
+ * "mousedown" or "keydown") that caused the "option" event to fire. See
+ * Element.addListener
+ * for more information on listening for this event.
+ * @type YAHOO.util.CustomEvent
+ */
+
+})();
+(function () {
+
+ // Shorthard for utilities
+
+ var Dom = YAHOO.util.Dom,
+ Event = YAHOO.util.Event,
+ Lang = YAHOO.lang,
+ Button = YAHOO.widget.Button,
+
+ // Private collection of radio buttons
+
+ m_oButtons = {};
+
+
+
+ /**
+ * The ButtonGroup class creates a set of buttons that are mutually
+ * exclusive; checking one button in the set will uncheck all others in the
+ * button group.
+ * @param {String} p_oElement String specifying the id attribute of the
+ * <div>
element of the button group.
+ * @param {HTMLDivElement} p_oElement Object
+ * specifying the <div>
element of the button group.
+ * @param {Object} p_oElement Object literal specifying a set of
+ * configuration attributes used to create the button group.
+ * @param {Object} p_oAttributes Optional. Object literal specifying a set
+ * of configuration attributes used to create the button group.
+ * @namespace YAHOO.widget
+ * @class ButtonGroup
+ * @constructor
+ * @extends YAHOO.util.Element
+ */
+ YAHOO.widget.ButtonGroup = function (p_oElement, p_oAttributes) {
+
+ var fnSuperClass = YAHOO.widget.ButtonGroup.superclass.constructor,
+ sNodeName,
+ oElement,
+ sId;
+
+ if (arguments.length == 1 && !Lang.isString(p_oElement) &&
+ !p_oElement.nodeName) {
+
+ if (!p_oElement.id) {
+
+ sId = Dom.generateId();
+
+ p_oElement.id = sId;
+
+ YAHOO.log("No value specified for the button group's \"id\"" +
+ " attribute. Setting button group id to \"" + sId + "\".",
+ "warn");
+
+ }
+
+ this.logger = new YAHOO.widget.LogWriter("ButtonGroup " + sId);
+
+ this.logger.log("No source HTML element. Building the button " +
+ "group using the set of configuration attributes.");
+
+ fnSuperClass.call(this, (this._createGroupElement()), p_oElement);
+
+ }
+ else if (Lang.isString(p_oElement)) {
+
+ oElement = Dom.get(p_oElement);
+
+ if (oElement) {
+
+ if (oElement.nodeName.toUpperCase() == this.NODE_NAME) {
+
+ this.logger =
+ new YAHOO.widget.LogWriter("ButtonGroup " + p_oElement);
+
+ fnSuperClass.call(this, oElement, p_oAttributes);
+
+ }
+
+ }
+
+ }
+ else {
+
+ sNodeName = p_oElement.nodeName.toUpperCase();
+
+ if (sNodeName && sNodeName == this.NODE_NAME) {
+
+ if (!p_oElement.id) {
+
+ p_oElement.id = Dom.generateId();
+
+ YAHOO.log("No value specified for the button group's" +
+ " \"id\" attribute. Setting button group id " +
+ "to \"" + p_oElement.id + "\".", "warn");
+
+ }
+
+ this.logger =
+ new YAHOO.widget.LogWriter("ButtonGroup " + p_oElement.id);
+
+ fnSuperClass.call(this, p_oElement, p_oAttributes);
+
+ }
+
+ }
+
+ };
+
+
+ YAHOO.extend(YAHOO.widget.ButtonGroup, YAHOO.util.Element, {
+
+
+ // Protected properties
+
+
+ /**
+ * @property _buttons
+ * @description Array of buttons in the button group.
+ * @default null
+ * @protected
+ * @type Array
+ */
+ _buttons: null,
+
+
+
+ // Constants
+
+
+ /**
+ * @property NODE_NAME
+ * @description The name of the tag to be used for the button
+ * group's element.
+ * @default "DIV"
+ * @final
+ * @type String
+ */
+ NODE_NAME: "DIV",
+
+
+ /**
+ * @property CSS_CLASS_NAME
+ * @description String representing the CSS class(es) to be applied
+ * to the button group's element.
+ * @default "yui-buttongroup"
+ * @final
+ * @type String
+ */
+ CSS_CLASS_NAME: "yui-buttongroup",
+
+
+
+ // Protected methods
+
+
+ /**
+ * @method _createGroupElement
+ * @description Creates the button group's element.
+ * @protected
+ * @return {HTMLDivElement}
+ */
+ _createGroupElement: function () {
+
+ var oElement = document.createElement(this.NODE_NAME);
+
+ return oElement;
+
+ },
+
+
+
+ // Protected attribute setter methods
+
+
+ /**
+ * @method _setDisabled
+ * @description Sets the value of the button groups's
+ * "disabled" attribute.
+ * @protected
+ * @param {Boolean} p_bDisabled Boolean indicating the value for
+ * the button group's "disabled" attribute.
+ */
+ _setDisabled: function (p_bDisabled) {
+
+ var nButtons = this.getCount(),
+ i;
+
+ if (nButtons > 0) {
+
+ i = nButtons - 1;
+
+ do {
+
+ this._buttons[i].set("disabled", p_bDisabled);
+
+ }
+ while (i--);
+
+ }
+
+ },
+
+
+
+ // Protected event handlers
+
+
+ /**
+ * @method _onKeyDown
+ * @description "keydown" event handler for the button group.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onKeyDown: function (p_oEvent) {
+
+ var oTarget = Event.getTarget(p_oEvent),
+ nCharCode = Event.getCharCode(p_oEvent),
+ sId = oTarget.parentNode.parentNode.id,
+ oButton = m_oButtons[sId],
+ nIndex = -1;
+
+
+ if (nCharCode == 37 || nCharCode == 38) {
+
+ nIndex = (oButton.index === 0) ?
+ (this._buttons.length - 1) : (oButton.index - 1);
+
+ }
+ else if (nCharCode == 39 || nCharCode == 40) {
+
+ nIndex = (oButton.index === (this._buttons.length - 1)) ?
+ 0 : (oButton.index + 1);
+
+ }
+
+
+ if (nIndex > -1) {
+
+ this.check(nIndex);
+ this.getButton(nIndex).focus();
+
+ }
+
+ },
+
+
+ /**
+ * @method _onAppendTo
+ * @description "appendTo" event handler for the button group.
+ * @protected
+ * @param {Event} p_oEvent Object representing the event that was fired.
+ */
+ _onAppendTo: function (p_oEvent) {
+
+ var aButtons = this._buttons,
+ nButtons = aButtons.length,
+ i;
+
+ for (i = 0; i < nButtons; i++) {
+
+ aButtons[i].appendTo(this.get("element"));
+
+ }
+
+ },
+
+
+ /**
+ * @method _onButtonCheckedChange
+ * @description "checkedChange" event handler for each button in the
+ * button group.
+ * @protected
+ * @param {Event} p_oEvent Object representing the event that was fired.
+ * @param {YAHOO.widget.Button}
+ * p_oButton Object representing the button that fired the event.
+ */
+ _onButtonCheckedChange: function (p_oEvent, p_oButton) {
+
+ var bChecked = p_oEvent.newValue,
+ oCheckedButton = this.get("checkedButton");
+
+ if (bChecked && oCheckedButton != p_oButton) {
+
+ if (oCheckedButton) {
+
+ oCheckedButton.set("checked", false, true);
+
+ }
+
+ this.set("checkedButton", p_oButton);
+ this.set("value", p_oButton.get("value"));
+
+ }
+ else if (oCheckedButton && !oCheckedButton.set("checked")) {
+
+ oCheckedButton.set("checked", true, true);
+
+ }
+
+ },
+
+
+
+ // Public methods
+
+
+ /**
+ * @method init
+ * @description The ButtonGroup class's initialization method.
+ * @param {String} p_oElement String specifying the id attribute of the
+ * <div>
element of the button group.
+ * @param {HTMLDivElement} p_oElement Object
+ * specifying the <div>
element of the button group.
+ * @param {Object} p_oElement Object literal specifying a set of
+ * configuration attributes used to create the button group.
+ * @param {Object} p_oAttributes Optional. Object literal specifying a
+ * set of configuration attributes used to create the button group.
+ */
+ init: function (p_oElement, p_oAttributes) {
+
+ this._buttons = [];
+
+ YAHOO.widget.ButtonGroup.superclass.init.call(this, p_oElement,
+ p_oAttributes);
+
+ this.addClass(this.CSS_CLASS_NAME);
+
+ this.logger.log("Searching for child nodes with the class name " +
+ "\"yui-radio-button\" to add to the button group.");
+
+ var aButtons = this.getElementsByClassName("yui-radio-button");
+
+
+ if (aButtons.length > 0) {
+
+ this.logger.log("Found " + aButtons.length +
+ " child nodes with the class name \"yui-radio-button.\"" +
+ " Attempting to add to button group.");
+
+ this.addButtons(aButtons);
+
+ }
+
+
+ this.logger.log("Searching for child nodes with the type of " +
+ " \"radio\" to add to the button group.");
+
+ function isRadioButton(p_oElement) {
+
+ return (p_oElement.type == "radio");
+
+ }
+
+ aButtons =
+ Dom.getElementsBy(isRadioButton, "input", this.get("element"));
+
+
+ if (aButtons.length > 0) {
+
+ this.logger.log("Found " + aButtons.length + " child nodes" +
+ " with the type of \"radio.\" Attempting to add to" +
+ " button group.");
+
+ this.addButtons(aButtons);
+
+ }
+
+ this.on("keydown", this._onKeyDown);
+ this.on("appendTo", this._onAppendTo);
+
+
+ var oContainer = this.get("container");
+
+ if (oContainer) {
+
+ if (Lang.isString(oContainer)) {
+
+ Event.onContentReady(oContainer, function () {
+
+ this.appendTo(oContainer);
+
+ }, null, this);
+
+ }
+ else {
+
+ this.appendTo(oContainer);
+
+ }
+
+ }
+
+
+ this.logger.log("Initialization completed.");
+
+ },
+
+
+ /**
+ * @method initAttributes
+ * @description Initializes all of the configuration attributes used to
+ * create the button group.
+ * @param {Object} p_oAttributes Object literal specifying a set of
+ * configuration attributes used to create the button group.
+ */
+ initAttributes: function (p_oAttributes) {
+
+ var oAttributes = p_oAttributes || {};
+
+ YAHOO.widget.ButtonGroup.superclass.initAttributes.call(
+ this, oAttributes);
+
+
+ /**
+ * @attribute name
+ * @description String specifying the name for the button group.
+ * This name will be applied to each button in the button group.
+ * @default null
+ * @type String
+ */
+ this.setAttributeConfig("name", {
+
+ value: oAttributes.name,
+ validator: Lang.isString
+
+ });
+
+
+ /**
+ * @attribute disabled
+ * @description Boolean indicating if the button group should be
+ * disabled. Disabling the button group will disable each button
+ * in the button group. Disabled buttons are dimmed and will not
+ * respond to user input or fire events.
+ * @default false
+ * @type Boolean
+ */
+ this.setAttributeConfig("disabled", {
+
+ value: (oAttributes.disabled || false),
+ validator: Lang.isBoolean,
+ method: this._setDisabled
+
+ });
+
+
+ /**
+ * @attribute value
+ * @description Object specifying the value for the button group.
+ * @default null
+ * @type Object
+ */
+ this.setAttributeConfig("value", {
+
+ value: oAttributes.value
+
+ });
+
+
+ /**
+ * @attribute container
+ * @description HTML element reference or string specifying the id
+ * attribute of the HTML element that the button group's markup
+ * should be rendered into.
+ * @type HTMLElement|String
+ * @default null
+ */
+ this.setAttributeConfig("container", {
+
+ value: oAttributes.container,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @attribute checkedButton
+ * @description Reference for the button in the button group that
+ * is checked.
+ * @type {YAHOO.widget.Button}
+ * @default null
+ */
+ this.setAttributeConfig("checkedButton", {
+
+ value: null
+
+ });
+
+ },
+
+
+ /**
+ * @method addButton
+ * @description Adds the button to the button group.
+ * @param {YAHOO.widget.Button}
+ * p_oButton Object reference for the
+ * YAHOO.widget.Button instance to be added to the button group.
+ * @param {String} p_oButton String specifying the id attribute of the
+ * <input>
or <span>
element
+ * to be used to create the button to be added to the button group.
+ * @param {HTMLInputElement|HTMLElement} p_oButton Object reference for the
+ * <input>
or <span>
element
+ * to be used to create the button to be added to the button group.
+ * @param {Object} p_oButton Object literal specifying a set of
+ * YAHOO.widget.Button
+ * configuration attributes used to configure the button to be added to
+ * the button group.
+ * @return {YAHOO.widget.Button}
+ */
+ addButton: function (p_oButton) {
+
+ var oButton,
+ oButtonElement,
+ oGroupElement,
+ nIndex,
+ sButtonName,
+ sGroupName;
+
+
+ if (p_oButton instanceof Button &&
+ p_oButton.get("type") == "radio") {
+
+ oButton = p_oButton;
+
+ }
+ else if (!Lang.isString(p_oButton) && !p_oButton.nodeName) {
+
+ p_oButton.type = "radio";
+
+ oButton = new Button(p_oButton);
+
+ }
+ else {
+
+ oButton = new Button(p_oButton, { type: "radio" });
+
+ }
+
+
+ if (oButton) {
+
+ nIndex = this._buttons.length;
+ sButtonName = oButton.get("name");
+ sGroupName = this.get("name");
+
+ oButton.index = nIndex;
+
+ this._buttons[nIndex] = oButton;
+ m_oButtons[oButton.get("id")] = oButton;
+
+
+ if (sButtonName != sGroupName) {
+
+ oButton.set("name", sGroupName);
+
+ }
+
+
+ if (this.get("disabled")) {
+
+ oButton.set("disabled", true);
+
+ }
+
+
+ if (oButton.get("checked")) {
+
+ this.set("checkedButton", oButton);
+
+ }
+
+
+ oButtonElement = oButton.get("element");
+ oGroupElement = this.get("element");
+
+ if (oButtonElement.parentNode != oGroupElement) {
+
+ oGroupElement.appendChild(oButtonElement);
+
+ }
+
+
+ oButton.on("checkedChange",
+ this._onButtonCheckedChange, oButton, this);
+
+ this.logger.log("Button " + oButton.get("id") + " added.");
+
+ return oButton;
+
+ }
+
+ },
+
+
+ /**
+ * @method addButtons
+ * @description Adds the array of buttons to the button group.
+ * @param {Array} p_aButtons Array of
+ * YAHOO.widget.Button instances to be added
+ * to the button group.
+ * @param {Array} p_aButtons Array of strings specifying the id
+ * attribute of the <input>
or <span>
+ *
elements to be used to create the buttons to be added to the
+ * button group.
+ * @param {Array} p_aButtons Array of object references for the
+ * <input>
or <span>
elements
+ * to be used to create the buttons to be added to the button group.
+ * @param {Array} p_aButtons Array of object literals, each containing
+ * a set of YAHOO.widget.Button
+ * configuration attributes used to configure each button to be added
+ * to the button group.
+ * @return {Array}
+ */
+ addButtons: function (p_aButtons) {
+
+ var nButtons,
+ oButton,
+ aButtons,
+ i;
+
+ if (Lang.isArray(p_aButtons)) {
+
+ nButtons = p_aButtons.length;
+ aButtons = [];
+
+ if (nButtons > 0) {
+
+ for (i = 0; i < nButtons; i++) {
+
+ oButton = this.addButton(p_aButtons[i]);
+
+ if (oButton) {
+
+ aButtons[aButtons.length] = oButton;
+
+ }
+
+ }
+
+ if (aButtons.length > 0) {
+
+ this.logger.log(aButtons.length + " buttons added.");
+
+ return aButtons;
+
+ }
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method removeButton
+ * @description Removes the button at the specified index from the
+ * button group.
+ * @param {Number} p_nIndex Number specifying the index of the button
+ * to be removed from the button group.
+ */
+ removeButton: function (p_nIndex) {
+
+ var oButton = this.getButton(p_nIndex),
+ nButtons,
+ i;
+
+ if (oButton) {
+
+ this.logger.log("Removing button " + oButton.get("id") + ".");
+
+ this._buttons.splice(p_nIndex, 1);
+ delete m_oButtons[oButton.get("id")];
+
+ oButton.removeListener("checkedChange",
+ this._onButtonCheckedChange);
+
+ oButton.destroy();
+
+
+ nButtons = this._buttons.length;
+
+ if (nButtons > 0) {
+
+ i = this._buttons.length - 1;
+
+ do {
+
+ this._buttons[i].index = i;
+
+ }
+ while (i--);
+
+ }
+
+ this.logger.log("Button " + oButton.get("id") + " removed.");
+
+ }
+
+ },
+
+
+ /**
+ * @method getButton
+ * @description Returns the button at the specified index.
+ * @param {Number} p_nIndex The index of the button to retrieve from the
+ * button group.
+ * @return {YAHOO.widget.Button}
+ */
+ getButton: function (p_nIndex) {
+
+ if (Lang.isNumber(p_nIndex)) {
+
+ return this._buttons[p_nIndex];
+
+ }
+
+ },
+
+
+ /**
+ * @method getButtons
+ * @description Returns an array of the buttons in the button group.
+ * @return {Array}
+ */
+ getButtons: function () {
+
+ return this._buttons;
+
+ },
+
+
+ /**
+ * @method getCount
+ * @description Returns the number of buttons in the button group.
+ * @return {Number}
+ */
+ getCount: function () {
+
+ return this._buttons.length;
+
+ },
+
+
+ /**
+ * @method focus
+ * @description Sets focus to the button at the specified index.
+ * @param {Number} p_nIndex Number indicating the index of the button
+ * to focus.
+ */
+ focus: function (p_nIndex) {
+
+ var oButton,
+ nButtons,
+ i;
+
+ if (Lang.isNumber(p_nIndex)) {
+
+ oButton = this._buttons[p_nIndex];
+
+ if (oButton) {
+
+ oButton.focus();
+
+ }
+
+ }
+ else {
+
+ nButtons = this.getCount();
+
+ for (i = 0; i < nButtons; i++) {
+
+ oButton = this._buttons[i];
+
+ if (!oButton.get("disabled")) {
+
+ oButton.focus();
+ break;
+
+ }
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method check
+ * @description Checks the button at the specified index.
+ * @param {Number} p_nIndex Number indicating the index of the button
+ * to check.
+ */
+ check: function (p_nIndex) {
+
+ var oButton = this.getButton(p_nIndex);
+
+ if (oButton) {
+
+ oButton.set("checked", true);
+
+ }
+
+ },
+
+
+ /**
+ * @method destroy
+ * @description Removes the button group's element from its parent
+ * element and removes all event handlers.
+ */
+ destroy: function () {
+
+ this.logger.log("Destroying...");
+
+ var nButtons = this._buttons.length,
+ oElement = this.get("element"),
+ oParentNode = oElement.parentNode,
+ i;
+
+ if (nButtons > 0) {
+
+ i = this._buttons.length - 1;
+
+ do {
+
+ this._buttons[i].destroy();
+
+ }
+ while (i--);
+
+ }
+
+ this.logger.log("Removing DOM event handlers.");
+
+ Event.purgeElement(oElement);
+
+ this.logger.log("Removing from document.");
+
+ oParentNode.removeChild(oElement);
+
+ },
+
+
+ /**
+ * @method toString
+ * @description Returns a string representing the button group.
+ * @return {String}
+ */
+ toString: function () {
+
+ return ("ButtonGroup " + this.get("id"));
+
+ }
+
+ });
+
+})();
+YAHOO.register("button", YAHOO.widget.Button, {version: "2.5.0", build: "895"});
diff --git a/lib/yui/button/button-min.js b/lib/yui/button/button-min.js
new file mode 100644
index 0000000000..e1d1b6df8f
--- /dev/null
+++ b/lib/yui/button/button-min.js
@@ -0,0 +1,11 @@
+/*
+Copyright (c) 2008, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.5.0
+*/
+(function(){var G=YAHOO.util.Dom,L=YAHOO.util.Event,I=YAHOO.lang,B=YAHOO.widget.Overlay,J=YAHOO.widget.Menu,D={},K=null,E=null,C=null;function F(N,M,Q,O){var R,P;if(I.isString(N)&&I.isString(M)){if(YAHOO.env.ua.ie){P="";R=document.createElement(P);}else{R=document.createElement("input");R.name=M;R.type=N;if(O){R.checked=true;}}R.value=Q;return R;}}function H(N,T){var M=N.nodeName.toUpperCase(),R=this,S,O,P;function U(V){if(!(V in T)){S=N.getAttributeNode(V);if(S&&("value" in S)){T[V]=S.value;}}}function Q(){U("type");if(T.type=="button"){T.type="push";}if(!("disabled" in T)){T.disabled=N.disabled;}U("name");U("value");U("title");}switch(M){case"A":T.type="link";U("href");U("target");break;case"INPUT":Q();if(!("checked" in T)){T.checked=N.checked;}break;case"BUTTON":Q();O=N.parentNode.parentNode;if(G.hasClass(O,this.CSS_CLASS_NAME+"-checked")){T.checked=true;}if(G.hasClass(O,this.CSS_CLASS_NAME+"-disabled")){T.disabled=true;}N.removeAttribute("value");N.setAttribute("type","button");break;}N.removeAttribute("id");N.removeAttribute("name");if(!("tabindex" in T)){T.tabindex=N.tabIndex;}if(!("label" in T)){P=M=="INPUT"?N.value:N.innerHTML;if(P&&P.length>0){T.label=P;}}}function A(O){var N=O.attributes,M=N.srcelement,Q=M.nodeName.toUpperCase(),P=this;if(Q==this.NODE_NAME){O.element=M;O.id=M.id;G.getElementsBy(function(R){switch(R.nodeName.toUpperCase()){case"BUTTON":case"A":case"INPUT":H.call(P,R,N);break;}},"*",M);}else{switch(Q){case"BUTTON":case"A":case"INPUT":H.call(this,M,N);break;}}}YAHOO.widget.Button=function(Q,N){if(!B&&YAHOO.widget.Overlay){B=YAHOO.widget.Overlay;}if(!J&&YAHOO.widget.Menu){J=YAHOO.widget.Menu;}var P=YAHOO.widget.Button.superclass.constructor,O,M;if(arguments.length==1&&!I.isString(Q)&&!Q.nodeName){if(!Q.id){Q.id=G.generateId();}P.call(this,(this.createButtonElement(Q.type)),Q);}else{O={element:null,attributes:(N||{})};if(I.isString(Q)){M=G.get(Q);if(M){if(!O.attributes.id){O.attributes.id=Q;}O.attributes.srcelement=M;A.call(this,O);if(!O.element){O.element=this.createButtonElement(O.attributes.type);}P.call(this,O.element,O.attributes);}}else{if(Q.nodeName){if(!O.attributes.id){if(Q.id){O.attributes.id=Q.id;}else{O.attributes.id=G.generateId();}}O.attributes.srcelement=Q;A.call(this,O);if(!O.element){O.element=this.createButtonElement(O.attributes.type);}P.call(this,O.element,O.attributes);}}}};YAHOO.extend(YAHOO.widget.Button,YAHOO.util.Element,{_button:null,_menu:null,_hiddenFields:null,_onclickAttributeValue:null,_activationKeyPressed:false,_activationButtonPressed:false,_hasKeyEventHandlers:false,_hasMouseEventHandlers:false,NODE_NAME:"SPAN",CHECK_ACTIVATION_KEYS:[32],ACTIVATION_KEYS:[13,32],OPTION_AREA_WIDTH:20,CSS_CLASS_NAME:"yui-button",RADIO_DEFAULT_TITLE:"Unchecked. Click to check.",RADIO_CHECKED_TITLE:"Checked. Click another button to uncheck",CHECKBOX_DEFAULT_TITLE:"Unchecked. Click to check.",CHECKBOX_CHECKED_TITLE:"Checked. Click to uncheck.",MENUBUTTON_DEFAULT_TITLE:"Menu collapsed. Click to expand.",MENUBUTTON_MENU_VISIBLE_TITLE:"Menu expanded. Click or press Esc to collapse.",SPLITBUTTON_DEFAULT_TITLE:("Menu collapsed. Click inside option region or press Ctrl + Shift + M to show the menu."),SPLITBUTTON_OPTION_VISIBLE_TITLE:"Menu expanded. Press Esc or Ctrl + Shift + M to hide the menu.",SUBMIT_TITLE:"Click to submit form.",_setType:function(M){if(M=="split"){this.on("option",this._onOption);}},_setLabel:function(M){this._button.innerHTML=M;var O,N;if(YAHOO.env.ua.gecko&&G.inDocument(this.get("element"))){N=this;O=this.CSS_CLASS_NAME;this.removeClass(O);window.setTimeout(function(){N.addClass(O);},0);}},_setTabIndex:function(M){this._button.tabIndex=M;},_setTitle:function(N){var M=N;if(this.get("type")!="link"){if(!M){switch(this.get("type")){case"radio":M=this.RADIO_DEFAULT_TITLE;break;case"checkbox":M=this.CHECKBOX_DEFAULT_TITLE;break;case"menu":M=this.MENUBUTTON_DEFAULT_TITLE;break;case"split":M=this.SPLITBUTTON_DEFAULT_TITLE;break;case"submit":M=this.SUBMIT_TITLE;break;}}this._button.title=M;}},_setDisabled:function(M){if(this.get("type")!="link"){if(M){if(this._menu){this._menu.hide();}if(this.hasFocus()){this.blur();}this._button.setAttribute("disabled","disabled");this.addStateCSSClasses("disabled");this.removeStateCSSClasses("hover");this.removeStateCSSClasses("active");this.removeStateCSSClasses("focus");}else{this._button.removeAttribute("disabled");this.removeStateCSSClasses("disabled");}}},_setHref:function(M){if(this.get("type")=="link"){this._button.href=M;}},_setTarget:function(M){if(this.get("type")=="link"){this._button.setAttribute("target",M);}},_setChecked:function(N){var O=this.get("type"),M;if(O=="checkbox"||O=="radio"){if(N){this.addStateCSSClasses("checked");M=(O=="radio")?this.RADIO_CHECKED_TITLE:this.CHECKBOX_CHECKED_TITLE;}else{this.removeStateCSSClasses("checked");M=(O=="radio")?this.RADIO_DEFAULT_TITLE:this.CHECKBOX_DEFAULT_TITLE;}this.set("title",M);}},_setMenu:function(W){var Q=this.get("lazyloadmenu"),T=this.get("element"),M,Y=false,Z,P,S,O,N,V,R;if(!B){return false;}if(J){M=J.prototype.CSS_CLASS_NAME;}function X(){Z.render(T.parentNode);this.removeListener("appendTo",X);}function U(){if(Z){G.addClass(Z.element,this.get("menuclassname"));G.addClass(Z.element,"yui-"+this.get("type")+"-button-menu");Z.showEvent.subscribe(this._onMenuShow,null,this);Z.hideEvent.subscribe(this._onMenuHide,null,this);Z.renderEvent.subscribe(this._onMenuRender,null,this);if(J&&Z instanceof J){Z.keyDownEvent.subscribe(this._onMenuKeyDown,this,true);Z.subscribe("click",this._onMenuClick,this,true);Z.itemAddedEvent.subscribe(this._onMenuItemAdded,this,true);S=Z.srcElement;if(S&&S.nodeName.toUpperCase()=="SELECT"){S.style.display="none";S.parentNode.removeChild(S);}}else{if(B&&Z instanceof B){if(!K){K=new YAHOO.widget.OverlayManager();}K.register(Z);}}this._menu=Z;if(!Y){if(Q&&J&&!(Z instanceof J)){Z.beforeShowEvent.subscribe(this._onOverlayBeforeShow,null,this);}else{if(!Q){if(G.inDocument(T)){Z.render(T.parentNode);
+}else{this.on("appendTo",X);}}}}}}if(W&&J&&(W instanceof J)){Z=W;O=Z.getItems();N=O.length;Y=true;if(N>0){R=N-1;do{V=O[R];if(V){V.cfg.subscribeToConfigEvent("selected",this._onMenuItemSelected,V,this);}}while(R--);}U.call(this);}else{if(B&&W&&(W instanceof B)){Z=W;Y=true;Z.cfg.setProperty("visible",false);Z.cfg.setProperty("context",[T,"tl","bl"]);U.call(this);}else{if(J&&I.isArray(W)){this.on("appendTo",function(){Z=new J(G.generateId(),{lazyload:Q,itemdata:W});U.call(this);});}else{if(I.isString(W)){P=G.get(W);if(P){if(J&&G.hasClass(P,M)||P.nodeName.toUpperCase()=="SELECT"){Z=new J(W,{lazyload:Q});U.call(this);}else{if(B){Z=new B(W,{visible:false,context:[T,"tl","bl"]});U.call(this);}}}}else{if(W&&W.nodeName){if(J&&G.hasClass(W,M)||W.nodeName.toUpperCase()=="SELECT"){Z=new J(W,{lazyload:Q});U.call(this);}else{if(B){if(!W.id){G.generateId(W);}Z=new B(W,{visible:false,context:[T,"tl","bl"]});U.call(this);}}}}}}}},_setOnClick:function(M){if(this._onclickAttributeValue&&(this._onclickAttributeValue!=M)){this.removeListener("click",this._onclickAttributeValue.fn);this._onclickAttributeValue=null;}if(!this._onclickAttributeValue&&I.isObject(M)&&I.isFunction(M.fn)){this.on("click",M.fn,M.obj,M.scope);this._onclickAttributeValue=M;}},_setSelectedMenuItem:function(N){var M=this._menu,O;if(J&&M&&M instanceof J){O=M.getItem(N);if(O&&!O.cfg.getProperty("selected")){O.cfg.setProperty("selected",true);}}},_isActivationKey:function(M){var Q=this.get("type"),N=(Q=="checkbox"||Q=="radio")?this.CHECK_ACTIVATION_KEYS:this.ACTIVATION_KEYS,P=N.length,O;if(P>0){O=P-1;do{if(M==N[O]){return true;}}while(O--);}},_isSplitButtonOptionKey:function(M){return(M.ctrlKey&&M.shiftKey&&L.getCharCode(M)==77);},_addListenersToForm:function(){var S=this.getForm(),R=YAHOO.widget.Button.onFormKeyPress,Q,M,P,O,N;if(S){L.on(S,"reset",this._onFormReset,null,this);L.on(S,"submit",this.createHiddenFields,null,this);M=this.get("srcelement");if(this.get("type")=="submit"||(M&&M.type=="submit")){P=L.getListeners(S,"keypress");Q=false;if(P){O=P.length;if(O>0){N=O-1;do{if(P[N].fn==R){Q=true;break;}}while(N--);}}if(!Q){L.on(S,"keypress",R);}}}},_showMenu:function(R){if(YAHOO.widget.MenuManager){YAHOO.widget.MenuManager.hideVisible();}if(K){K.hideAll();}var P=B.VIEWPORT_OFFSET,Y=this._menu,W=this,Z=W.get("element"),T=false,V=G.getY(Z),U=G.getDocumentScrollTop(),M,Q,b;if(U){V=V-U;}var O=V,N=(G.getViewportHeight()-(V+Z.offsetHeight));function S(){if(T){return(O-P);}else{return(N-P);}}function a(){var c=S();if(Q>c){M=Y.cfg.getProperty("minscrollheight");if(c>M){Y.cfg.setProperty("maxheight",c);if(T){Y.align("bl","tl");}}if(c
+*
+* @title Button
+* @namespace YAHOO.widget
+* @requires yahoo, dom, element, event
+* @optional container, menu
+*/
+
+
+(function () {
+
+
+ /**
+ * The Button class creates a rich, graphical button.
+ * @param {String} p_oElement String specifying the id attribute of the
+ * <input>
, <button>
,
+ * <a>
, or <span>
element to
+ * be used to create the button.
+ * @param {HTMLInputElement|
+ * HTMLButtonElement|HTMLElement} p_oElement Object reference for the
+ * <input>
, <button>
,
+ * <a>
, or <span>
element to be
+ * used to create the button.
+ * @param {Object} p_oElement Object literal specifying a set of
+ * configuration attributes used to create the button.
+ * @param {Object} p_oAttributes Optional. Object literal specifying a set
+ * of configuration attributes used to create the button.
+ * @namespace YAHOO.widget
+ * @class Button
+ * @constructor
+ * @extends YAHOO.util.Element
+ */
+
+
+
+ // Shorthard for utilities
+
+ var Dom = YAHOO.util.Dom,
+ Event = YAHOO.util.Event,
+ Lang = YAHOO.lang,
+ Overlay = YAHOO.widget.Overlay,
+ Menu = YAHOO.widget.Menu,
+
+
+ // Private member variables
+
+ m_oButtons = {}, // Collection of all Button instances
+ m_oOverlayManager = null, // YAHOO.widget.OverlayManager instance
+ m_oSubmitTrigger = null, // The button that submitted the form
+ m_oFocusedButton = null; // The button that has focus
+
+
+
+ // Private methods
+
+
+
+ /**
+ * @method createInputElement
+ * @description Creates an <input>
element of the
+ * specified type.
+ * @private
+ * @param {String} p_sType String specifying the type of
+ * <input>
element to create.
+ * @param {String} p_sName String specifying the name of
+ * <input>
element to create.
+ * @param {String} p_sValue String specifying the value of
+ * <input>
element to create.
+ * @param {String} p_bChecked Boolean specifying if the
+ * <input>
element is to be checked.
+ * @return {HTMLInputElement}
+ */
+ function createInputElement(p_sType, p_sName, p_sValue, p_bChecked) {
+
+ var oInput,
+ sInput;
+
+ if (Lang.isString(p_sType) && Lang.isString(p_sName)) {
+
+ if (YAHOO.env.ua.ie) {
+
+ /*
+ For IE it is necessary to create the element with the
+ "type," "name," "value," and "checked" properties set all
+ at once.
+ */
+
+ sInput = "";
+
+ oInput = document.createElement(sInput);
+
+ }
+ else {
+
+ oInput = document.createElement("input");
+ oInput.name = p_sName;
+ oInput.type = p_sType;
+
+ if (p_bChecked) {
+
+ oInput.checked = true;
+
+ }
+
+ }
+
+ oInput.value = p_sValue;
+
+ return oInput;
+
+ }
+
+ }
+
+
+ /**
+ * @method setAttributesFromSrcElement
+ * @description Gets the values for all the attributes of the source element
+ * (either <input>
or <a>
) that
+ * map to Button configuration attributes and sets them into a collection
+ * that is passed to the Button constructor.
+ * @private
+ * @param {HTMLInputElement|HTMLAnchorElement} p_oElement Object reference to the HTML
+ * element (either <input>
or <span>
+ *
) used to create the button.
+ * @param {Object} p_oAttributes Object reference for the collection of
+ * configuration attributes used to create the button.
+ */
+ function setAttributesFromSrcElement(p_oElement, p_oAttributes) {
+
+ var sSrcElementNodeName = p_oElement.nodeName.toUpperCase(),
+ me = this,
+ oAttribute,
+ oRootNode,
+ sText;
+
+
+ /**
+ * @method setAttributeFromDOMAttribute
+ * @description Gets the value of the specified DOM attribute and sets it
+ * into the collection of configuration attributes used to configure
+ * the button.
+ * @private
+ * @param {String} p_sAttribute String representing the name of the
+ * attribute to retrieve from the DOM element.
+ */
+ function setAttributeFromDOMAttribute(p_sAttribute) {
+
+ if (!(p_sAttribute in p_oAttributes)) {
+
+ /*
+ Need to use "getAttributeNode" instead of "getAttribute"
+ because using "getAttribute," IE will return the innerText
+ of a <button>
for the value attribute
+ rather than the value of the "value" attribute.
+ */
+
+ oAttribute = p_oElement.getAttributeNode(p_sAttribute);
+
+
+ if (oAttribute && ("value" in oAttribute)) {
+
+
+ p_oAttributes[p_sAttribute] = oAttribute.value;
+
+ }
+
+ }
+
+ }
+
+
+ /**
+ * @method setFormElementProperties
+ * @description Gets the value of the attributes from the form element
+ * and sets them into the collection of configuration attributes used to
+ * configure the button.
+ * @private
+ */
+ function setFormElementProperties() {
+
+ setAttributeFromDOMAttribute("type");
+
+ if (p_oAttributes.type == "button") {
+
+ p_oAttributes.type = "push";
+
+ }
+
+ if (!("disabled" in p_oAttributes)) {
+
+ p_oAttributes.disabled = p_oElement.disabled;
+
+ }
+
+ setAttributeFromDOMAttribute("name");
+ setAttributeFromDOMAttribute("value");
+ setAttributeFromDOMAttribute("title");
+
+ }
+
+
+ switch (sSrcElementNodeName) {
+
+ case "A":
+
+ p_oAttributes.type = "link";
+
+ setAttributeFromDOMAttribute("href");
+ setAttributeFromDOMAttribute("target");
+
+ break;
+
+ case "INPUT":
+
+ setFormElementProperties();
+
+ if (!("checked" in p_oAttributes)) {
+
+ p_oAttributes.checked = p_oElement.checked;
+
+ }
+
+ break;
+
+ case "BUTTON":
+
+ setFormElementProperties();
+
+ oRootNode = p_oElement.parentNode.parentNode;
+
+ if (Dom.hasClass(oRootNode, this.CSS_CLASS_NAME + "-checked")) {
+
+ p_oAttributes.checked = true;
+
+ }
+
+ if (Dom.hasClass(oRootNode, this.CSS_CLASS_NAME + "-disabled")) {
+
+ p_oAttributes.disabled = true;
+
+ }
+
+ p_oElement.removeAttribute("value");
+
+ p_oElement.setAttribute("type", "button");
+
+ break;
+
+ }
+
+ p_oElement.removeAttribute("id");
+ p_oElement.removeAttribute("name");
+
+ if (!("tabindex" in p_oAttributes)) {
+
+ p_oAttributes.tabindex = p_oElement.tabIndex;
+
+ }
+
+ if (!("label" in p_oAttributes)) {
+
+ // Set the "label" property
+
+ sText = sSrcElementNodeName == "INPUT" ?
+ p_oElement.value : p_oElement.innerHTML;
+
+
+ if (sText && sText.length > 0) {
+
+ p_oAttributes.label = sText;
+
+ }
+
+ }
+
+ }
+
+
+ /**
+ * @method initConfig
+ * @description Initializes the set of configuration attributes that are
+ * used to instantiate the button.
+ * @private
+ * @param {Object} Object representing the button's set of
+ * configuration attributes.
+ */
+ function initConfig(p_oConfig) {
+
+ var oAttributes = p_oConfig.attributes,
+ oSrcElement = oAttributes.srcelement,
+ sSrcElementNodeName = oSrcElement.nodeName.toUpperCase(),
+ me = this;
+
+
+ if (sSrcElementNodeName == this.NODE_NAME) {
+
+ p_oConfig.element = oSrcElement;
+ p_oConfig.id = oSrcElement.id;
+
+ Dom.getElementsBy(function (p_oElement) {
+
+ switch (p_oElement.nodeName.toUpperCase()) {
+
+ case "BUTTON":
+ case "A":
+ case "INPUT":
+
+ setAttributesFromSrcElement.call(me, p_oElement,
+ oAttributes);
+
+ break;
+
+ }
+
+ }, "*", oSrcElement);
+
+ }
+ else {
+
+ switch (sSrcElementNodeName) {
+
+ case "BUTTON":
+ case "A":
+ case "INPUT":
+
+ setAttributesFromSrcElement.call(this, oSrcElement,
+ oAttributes);
+
+ break;
+
+ }
+
+ }
+
+ }
+
+
+
+ // Constructor
+
+ YAHOO.widget.Button = function (p_oElement, p_oAttributes) {
+
+ if (!Overlay && YAHOO.widget.Overlay) {
+
+ Overlay = YAHOO.widget.Overlay;
+
+ }
+
+
+ if (!Menu && YAHOO.widget.Menu) {
+
+ Menu = YAHOO.widget.Menu;
+
+ }
+
+
+ var fnSuperClass = YAHOO.widget.Button.superclass.constructor,
+ oConfig,
+ oElement;
+
+ if (arguments.length == 1 && !Lang.isString(p_oElement) &&
+ !p_oElement.nodeName) {
+
+ if (!p_oElement.id) {
+
+ p_oElement.id = Dom.generateId();
+
+
+ }
+
+
+
+ fnSuperClass.call(this,
+ (this.createButtonElement(p_oElement.type)),
+ p_oElement);
+
+ }
+ else {
+
+ oConfig = { element: null, attributes: (p_oAttributes || {}) };
+
+
+ if (Lang.isString(p_oElement)) {
+
+ oElement = Dom.get(p_oElement);
+
+ if (oElement) {
+
+ if (!oConfig.attributes.id) {
+
+ oConfig.attributes.id = p_oElement;
+
+ }
+
+
+
+
+ oConfig.attributes.srcelement = oElement;
+
+ initConfig.call(this, oConfig);
+
+
+ if (!oConfig.element) {
+
+
+ oConfig.element =
+ this.createButtonElement(oConfig.attributes.type);
+
+ }
+
+ fnSuperClass.call(this, oConfig.element,
+ oConfig.attributes);
+
+ }
+
+ }
+ else if (p_oElement.nodeName) {
+
+ if (!oConfig.attributes.id) {
+
+ if (p_oElement.id) {
+
+ oConfig.attributes.id = p_oElement.id;
+
+ }
+ else {
+
+ oConfig.attributes.id = Dom.generateId();
+
+
+ }
+
+ }
+
+
+
+
+
+ oConfig.attributes.srcelement = p_oElement;
+
+ initConfig.call(this, oConfig);
+
+
+ if (!oConfig.element) {
+
+
+ oConfig.element =
+ this.createButtonElement(oConfig.attributes.type);
+
+ }
+
+ fnSuperClass.call(this, oConfig.element, oConfig.attributes);
+
+ }
+
+ }
+
+ };
+
+
+
+ YAHOO.extend(YAHOO.widget.Button, YAHOO.util.Element, {
+
+
+ // Protected properties
+
+
+ /**
+ * @property _button
+ * @description Object reference to the button's internal
+ * <a>
or <button>
element.
+ * @default null
+ * @protected
+ * @type HTMLAnchorElement|HTMLButtonElement
+ */
+ _button: null,
+
+
+ /**
+ * @property _menu
+ * @description Object reference to the button's menu.
+ * @default null
+ * @protected
+ * @type {YAHOO.widget.Overlay|
+ * YAHOO.widget.Menu}
+ */
+ _menu: null,
+
+
+ /**
+ * @property _hiddenFields
+ * @description Object reference to the <input>
+ * element, or array of HTML form elements used to represent the button
+ * when its parent form is submitted.
+ * @default null
+ * @protected
+ * @type HTMLInputElement|Array
+ */
+ _hiddenFields: null,
+
+
+ /**
+ * @property _onclickAttributeValue
+ * @description Object reference to the button's current value for the
+ * "onclick" configuration attribute.
+ * @default null
+ * @protected
+ * @type Object
+ */
+ _onclickAttributeValue: null,
+
+
+ /**
+ * @property _activationKeyPressed
+ * @description Boolean indicating if the key(s) that toggle the button's
+ * "active" state have been pressed.
+ * @default false
+ * @protected
+ * @type Boolean
+ */
+ _activationKeyPressed: false,
+
+
+ /**
+ * @property _activationButtonPressed
+ * @description Boolean indicating if the mouse button that toggles
+ * the button's "active" state has been pressed.
+ * @default false
+ * @protected
+ * @type Boolean
+ */
+ _activationButtonPressed: false,
+
+
+ /**
+ * @property _hasKeyEventHandlers
+ * @description Boolean indicating if the button's "blur", "keydown" and
+ * "keyup" event handlers are assigned
+ * @default false
+ * @protected
+ * @type Boolean
+ */
+ _hasKeyEventHandlers: false,
+
+
+ /**
+ * @property _hasMouseEventHandlers
+ * @description Boolean indicating if the button's "mouseout,"
+ * "mousedown," and "mouseup" event handlers are assigned
+ * @default false
+ * @protected
+ * @type Boolean
+ */
+ _hasMouseEventHandlers: false,
+
+
+
+ // Constants
+
+
+ /**
+ * @property NODE_NAME
+ * @description The name of the node to be used for the button's
+ * root element.
+ * @default "SPAN"
+ * @final
+ * @type String
+ */
+ NODE_NAME: "SPAN",
+
+
+ /**
+ * @property CHECK_ACTIVATION_KEYS
+ * @description Array of numbers representing keys that (when pressed)
+ * toggle the button's "checked" attribute.
+ * @default [32]
+ * @final
+ * @type Array
+ */
+ CHECK_ACTIVATION_KEYS: [32],
+
+
+ /**
+ * @property ACTIVATION_KEYS
+ * @description Array of numbers representing keys that (when presed)
+ * toggle the button's "active" state.
+ * @default [13, 32]
+ * @final
+ * @type Array
+ */
+ ACTIVATION_KEYS: [13, 32],
+
+
+ /**
+ * @property OPTION_AREA_WIDTH
+ * @description Width (in pixels) of the area of a split button that
+ * when pressed will display a menu.
+ * @default 20
+ * @final
+ * @type Number
+ */
+ OPTION_AREA_WIDTH: 20,
+
+
+ /**
+ * @property CSS_CLASS_NAME
+ * @description String representing the CSS class(es) to be applied to
+ * the button's root element.
+ * @default "yui-button"
+ * @final
+ * @type String
+ */
+ CSS_CLASS_NAME: "yui-button",
+
+
+ /**
+ * @property RADIO_DEFAULT_TITLE
+ * @description String representing the default title applied to buttons
+ * of type "radio."
+ * @default "Unchecked. Click to check."
+ * @final
+ * @type String
+ */
+ RADIO_DEFAULT_TITLE: "Unchecked. Click to check.",
+
+
+ /**
+ * @property RADIO_CHECKED_TITLE
+ * @description String representing the title applied to buttons of
+ * type "radio" when checked.
+ * @default "Checked. Click another button to uncheck"
+ * @final
+ * @type String
+ */
+ RADIO_CHECKED_TITLE: "Checked. Click another button to uncheck",
+
+
+ /**
+ * @property CHECKBOX_DEFAULT_TITLE
+ * @description String representing the default title applied to
+ * buttons of type "checkbox."
+ * @default "Unchecked. Click to check."
+ * @final
+ * @type String
+ */
+ CHECKBOX_DEFAULT_TITLE: "Unchecked. Click to check.",
+
+
+ /**
+ * @property CHECKBOX_CHECKED_TITLE
+ * @description String representing the title applied to buttons of type
+ * "checkbox" when checked.
+ * @default "Checked. Click to uncheck."
+ * @final
+ * @type String
+ */
+ CHECKBOX_CHECKED_TITLE: "Checked. Click to uncheck.",
+
+
+ /**
+ * @property MENUBUTTON_DEFAULT_TITLE
+ * @description String representing the default title applied to
+ * buttons of type "menu."
+ * @default "Menu collapsed. Click to expand."
+ * @final
+ * @type String
+ */
+ MENUBUTTON_DEFAULT_TITLE: "Menu collapsed. Click to expand.",
+
+
+ /**
+ * @property MENUBUTTON_MENU_VISIBLE_TITLE
+ * @description String representing the title applied to buttons of type
+ * "menu" when the button's menu is visible.
+ * @default "Menu expanded. Click or press Esc to collapse."
+ * @final
+ * @type String
+ */
+ MENUBUTTON_MENU_VISIBLE_TITLE:
+ "Menu expanded. Click or press Esc to collapse.",
+
+
+ /**
+ * @property SPLITBUTTON_DEFAULT_TITLE
+ * @description String representing the default title applied to
+ * buttons of type "split."
+ * @default "Menu collapsed. Click inside option region or press
+ * Ctrl + Shift + M to show the menu."
+ * @final
+ * @type String
+ */
+ SPLITBUTTON_DEFAULT_TITLE: ("Menu collapsed. Click inside option " +
+ "region or press Ctrl + Shift + M to show the menu."),
+
+
+ /**
+ * @property SPLITBUTTON_OPTION_VISIBLE_TITLE
+ * @description String representing the title applied to buttons of type
+ * "split" when the button's menu is visible.
+ * @default "Menu expanded. Press Esc or Ctrl + Shift + M to hide
+ * the menu."
+ * @final
+ * @type String
+ */
+ SPLITBUTTON_OPTION_VISIBLE_TITLE:
+ "Menu expanded. Press Esc or Ctrl + Shift + M to hide the menu.",
+
+
+ /**
+ * @property SUBMIT_TITLE
+ * @description String representing the title applied to buttons of
+ * type "submit."
+ * @default "Click to submit form."
+ * @final
+ * @type String
+ */
+ SUBMIT_TITLE: "Click to submit form.",
+
+
+
+ // Protected attribute setter methods
+
+
+ /**
+ * @method _setType
+ * @description Sets the value of the button's "type" attribute.
+ * @protected
+ * @param {String} p_sType String indicating the value for the button's
+ * "type" attribute.
+ */
+ _setType: function (p_sType) {
+
+ if (p_sType == "split") {
+
+ this.on("option", this._onOption);
+
+ }
+
+ },
+
+
+ /**
+ * @method _setLabel
+ * @description Sets the value of the button's "label" attribute.
+ * @protected
+ * @param {String} p_sLabel String indicating the value for the button's
+ * "label" attribute.
+ */
+ _setLabel: function (p_sLabel) {
+
+ this._button.innerHTML = p_sLabel;
+
+ /*
+ Remove and add the default class name from the root element
+ for Gecko to ensure that the button shrinkwraps to the label.
+ Without this the button will not be rendered at the correct
+ width when the label changes. The most likely cause for this
+ bug is button's use of the Gecko-specific CSS display type of
+ "-moz-inline-box" to simulate "inline-block" supported by IE,
+ Safari and Opera.
+ */
+
+ var sClass,
+ me;
+
+ if (YAHOO.env.ua.gecko && Dom.inDocument(this.get("element"))) {
+
+ me = this;
+ sClass = this.CSS_CLASS_NAME;
+
+ this.removeClass(sClass);
+
+ window.setTimeout(function () {
+
+ me.addClass(sClass);
+
+ }, 0);
+
+ }
+
+ },
+
+
+ /**
+ * @method _setTabIndex
+ * @description Sets the value of the button's "tabindex" attribute.
+ * @protected
+ * @param {Number} p_nTabIndex Number indicating the value for the
+ * button's "tabindex" attribute.
+ */
+ _setTabIndex: function (p_nTabIndex) {
+
+ this._button.tabIndex = p_nTabIndex;
+
+ },
+
+
+ /**
+ * @method _setTitle
+ * @description Sets the value of the button's "title" attribute.
+ * @protected
+ * @param {String} p_nTabIndex Number indicating the value for
+ * the button's "title" attribute.
+ */
+ _setTitle: function (p_sTitle) {
+
+ var sTitle = p_sTitle;
+
+ if (this.get("type") != "link") {
+
+ if (!sTitle) {
+
+ switch (this.get("type")) {
+
+ case "radio":
+
+ sTitle = this.RADIO_DEFAULT_TITLE;
+
+ break;
+
+ case "checkbox":
+
+ sTitle = this.CHECKBOX_DEFAULT_TITLE;
+
+ break;
+
+ case "menu":
+
+ sTitle = this.MENUBUTTON_DEFAULT_TITLE;
+
+ break;
+
+ case "split":
+
+ sTitle = this.SPLITBUTTON_DEFAULT_TITLE;
+
+ break;
+
+ case "submit":
+
+ sTitle = this.SUBMIT_TITLE;
+
+ break;
+
+ }
+
+ }
+
+ this._button.title = sTitle;
+
+ }
+
+ },
+
+
+ /**
+ * @method _setDisabled
+ * @description Sets the value of the button's "disabled" attribute.
+ * @protected
+ * @param {Boolean} p_bDisabled Boolean indicating the value for
+ * the button's "disabled" attribute.
+ */
+ _setDisabled: function (p_bDisabled) {
+
+ if (this.get("type") != "link") {
+
+ if (p_bDisabled) {
+
+ if (this._menu) {
+
+ this._menu.hide();
+
+ }
+
+ if (this.hasFocus()) {
+
+ this.blur();
+
+ }
+
+ this._button.setAttribute("disabled", "disabled");
+
+ this.addStateCSSClasses("disabled");
+
+ this.removeStateCSSClasses("hover");
+ this.removeStateCSSClasses("active");
+ this.removeStateCSSClasses("focus");
+
+ }
+ else {
+
+ this._button.removeAttribute("disabled");
+
+ this.removeStateCSSClasses("disabled");
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _setHref
+ * @description Sets the value of the button's "href" attribute.
+ * @protected
+ * @param {String} p_sHref String indicating the value for the button's
+ * "href" attribute.
+ */
+ _setHref: function (p_sHref) {
+
+ if (this.get("type") == "link") {
+
+ this._button.href = p_sHref;
+
+ }
+
+ },
+
+
+ /**
+ * @method _setTarget
+ * @description Sets the value of the button's "target" attribute.
+ * @protected
+ * @param {String} p_sTarget String indicating the value for the button's
+ * "target" attribute.
+ */
+ _setTarget: function (p_sTarget) {
+
+ if (this.get("type") == "link") {
+
+ this._button.setAttribute("target", p_sTarget);
+
+ }
+
+ },
+
+
+ /**
+ * @method _setChecked
+ * @description Sets the value of the button's "target" attribute.
+ * @protected
+ * @param {Boolean} p_bChecked Boolean indicating the value for
+ * the button's "checked" attribute.
+ */
+ _setChecked: function (p_bChecked) {
+
+ var sType = this.get("type"),
+ sTitle;
+
+ if (sType == "checkbox" || sType == "radio") {
+
+ if (p_bChecked) {
+
+ this.addStateCSSClasses("checked");
+
+ sTitle = (sType == "radio") ?
+ this.RADIO_CHECKED_TITLE :
+ this.CHECKBOX_CHECKED_TITLE;
+
+ }
+ else {
+
+ this.removeStateCSSClasses("checked");
+
+ sTitle = (sType == "radio") ?
+ this.RADIO_DEFAULT_TITLE :
+ this.CHECKBOX_DEFAULT_TITLE;
+
+ }
+
+ this.set("title", sTitle);
+
+ }
+
+ },
+
+
+ /**
+ * @method _setMenu
+ * @description Sets the value of the button's "menu" attribute.
+ * @protected
+ * @param {Object} p_oMenu Object indicating the value for the button's
+ * "menu" attribute.
+ */
+ _setMenu: function (p_oMenu) {
+
+ var bLazyLoad = this.get("lazyloadmenu"),
+ oButtonElement = this.get("element"),
+ sMenuCSSClassName,
+
+ /*
+ Boolean indicating if the value of p_oMenu is an instance
+ of YAHOO.widget.Menu or YAHOO.widget.Overlay.
+ */
+
+ bInstance = false,
+
+
+ oMenu,
+ oMenuElement,
+ oSrcElement,
+ aItems,
+ nItems,
+ oItem,
+ i;
+
+
+ if (!Overlay) {
+
+
+ return false;
+
+ }
+
+
+ if (Menu) {
+
+ sMenuCSSClassName = Menu.prototype.CSS_CLASS_NAME;
+
+ }
+
+
+ function onAppendTo() {
+
+ oMenu.render(oButtonElement.parentNode);
+
+ this.removeListener("appendTo", onAppendTo);
+
+ }
+
+
+ function initMenu() {
+
+ if (oMenu) {
+
+ Dom.addClass(oMenu.element, this.get("menuclassname"));
+ Dom.addClass(oMenu.element,
+ "yui-" + this.get("type") + "-button-menu");
+
+ oMenu.showEvent.subscribe(this._onMenuShow, null, this);
+ oMenu.hideEvent.subscribe(this._onMenuHide, null, this);
+ oMenu.renderEvent.subscribe(this._onMenuRender, null, this);
+
+
+ if (Menu && oMenu instanceof Menu) {
+
+ oMenu.keyDownEvent.subscribe(this._onMenuKeyDown,
+ this, true);
+
+ oMenu.subscribe("click", this._onMenuClick,
+ this, true);
+
+ oMenu.itemAddedEvent.subscribe(this._onMenuItemAdded,
+ this, true);
+
+ oSrcElement = oMenu.srcElement;
+
+ if (oSrcElement &&
+ oSrcElement.nodeName.toUpperCase() == "SELECT") {
+
+ oSrcElement.style.display = "none";
+ oSrcElement.parentNode.removeChild(oSrcElement);
+
+ }
+
+ }
+ else if (Overlay && oMenu instanceof Overlay) {
+
+ if (!m_oOverlayManager) {
+
+ m_oOverlayManager =
+ new YAHOO.widget.OverlayManager();
+
+ }
+
+ m_oOverlayManager.register(oMenu);
+
+ }
+
+
+ this._menu = oMenu;
+
+
+ if (!bInstance) {
+
+ if (bLazyLoad && Menu && !(oMenu instanceof Menu)) {
+
+ /*
+ Mimic Menu's "lazyload" functionality by adding
+ a "beforeshow" event listener that renders the
+ Overlay instance before it is made visible by
+ the button.
+ */
+
+ oMenu.beforeShowEvent.subscribe(
+ this._onOverlayBeforeShow, null, this);
+
+ }
+ else if (!bLazyLoad) {
+
+ if (Dom.inDocument(oButtonElement)) {
+
+ oMenu.render(oButtonElement.parentNode);
+
+ }
+ else {
+
+ this.on("appendTo", onAppendTo);
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+
+ if (p_oMenu && Menu && (p_oMenu instanceof Menu)) {
+
+ oMenu = p_oMenu;
+ aItems = oMenu.getItems();
+ nItems = aItems.length;
+ bInstance = true;
+
+
+ if (nItems > 0) {
+
+ i = nItems - 1;
+
+ do {
+
+ oItem = aItems[i];
+
+ if (oItem) {
+
+ oItem.cfg.subscribeToConfigEvent("selected",
+ this._onMenuItemSelected,
+ oItem,
+ this);
+
+ }
+
+ }
+ while (i--);
+
+ }
+
+ initMenu.call(this);
+
+ }
+ else if (Overlay && p_oMenu && (p_oMenu instanceof Overlay)) {
+
+ oMenu = p_oMenu;
+ bInstance = true;
+
+ oMenu.cfg.setProperty("visible", false);
+ oMenu.cfg.setProperty("context", [oButtonElement, "tl", "bl"]);
+
+ initMenu.call(this);
+
+ }
+ else if (Menu && Lang.isArray(p_oMenu)) {
+
+ this.on("appendTo", function () {
+
+ oMenu = new Menu(Dom.generateId(), { lazyload: bLazyLoad,
+ itemdata: p_oMenu });
+
+ initMenu.call(this);
+
+ });
+
+ }
+ else if (Lang.isString(p_oMenu)) {
+
+ oMenuElement = Dom.get(p_oMenu);
+
+ if (oMenuElement) {
+
+ if (Menu && Dom.hasClass(oMenuElement, sMenuCSSClassName) ||
+ oMenuElement.nodeName.toUpperCase() == "SELECT") {
+
+ oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad });
+
+ initMenu.call(this);
+
+ }
+ else if (Overlay) {
+
+ oMenu = new Overlay(p_oMenu, { visible: false,
+ context: [oButtonElement, "tl", "bl"] });
+
+ initMenu.call(this);
+
+ }
+
+ }
+
+ }
+ else if (p_oMenu && p_oMenu.nodeName) {
+
+ if (Menu && Dom.hasClass(p_oMenu, sMenuCSSClassName) ||
+ p_oMenu.nodeName.toUpperCase() == "SELECT") {
+
+ oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad });
+
+ initMenu.call(this);
+
+ }
+ else if (Overlay) {
+
+ if (!p_oMenu.id) {
+
+ Dom.generateId(p_oMenu);
+
+ }
+
+ oMenu = new Overlay(p_oMenu, { visible: false,
+ context: [oButtonElement, "tl", "bl"] });
+
+ initMenu.call(this);
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _setOnClick
+ * @description Sets the value of the button's "onclick" attribute.
+ * @protected
+ * @param {Object} p_oObject Object indicating the value for the button's
+ * "onclick" attribute.
+ */
+ _setOnClick: function (p_oObject) {
+
+ /*
+ Remove any existing listeners if a "click" event handler
+ has already been specified.
+ */
+
+ if (this._onclickAttributeValue &&
+ (this._onclickAttributeValue != p_oObject)) {
+
+ this.removeListener("click", this._onclickAttributeValue.fn);
+
+ this._onclickAttributeValue = null;
+
+ }
+
+
+ if (!this._onclickAttributeValue &&
+ Lang.isObject(p_oObject) &&
+ Lang.isFunction(p_oObject.fn)) {
+
+ this.on("click", p_oObject.fn, p_oObject.obj, p_oObject.scope);
+
+ this._onclickAttributeValue = p_oObject;
+
+ }
+
+ },
+
+
+ /**
+ * @method _setSelectedMenuItem
+ * @description Sets the value of the button's
+ * "selectedMenuItem" attribute.
+ * @protected
+ * @param {Number} p_nIndex Number representing the index of the item
+ * in the button's menu that is currently selected.
+ */
+ _setSelectedMenuItem: function (p_nIndex) {
+
+ var oMenu = this._menu,
+ oMenuItem;
+
+
+ if (Menu && oMenu && oMenu instanceof Menu) {
+
+ oMenuItem = oMenu.getItem(p_nIndex);
+
+
+ if (oMenuItem && !oMenuItem.cfg.getProperty("selected")) {
+
+ oMenuItem.cfg.setProperty("selected", true);
+
+ }
+
+ }
+
+ },
+
+
+ // Protected methods
+
+
+
+ /**
+ * @method _isActivationKey
+ * @description Determines if the specified keycode is one that toggles
+ * the button's "active" state.
+ * @protected
+ * @param {Number} p_nKeyCode Number representing the keycode to
+ * be evaluated.
+ * @return {Boolean}
+ */
+ _isActivationKey: function (p_nKeyCode) {
+
+ var sType = this.get("type"),
+ aKeyCodes = (sType == "checkbox" || sType == "radio") ?
+ this.CHECK_ACTIVATION_KEYS : this.ACTIVATION_KEYS,
+
+ nKeyCodes = aKeyCodes.length,
+ i;
+
+ if (nKeyCodes > 0) {
+
+ i = nKeyCodes - 1;
+
+ do {
+
+ if (p_nKeyCode == aKeyCodes[i]) {
+
+ return true;
+
+ }
+
+ }
+ while (i--);
+
+ }
+
+ },
+
+
+ /**
+ * @method _isSplitButtonOptionKey
+ * @description Determines if the specified keycode is one that toggles
+ * the display of the split button's menu.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ * @return {Boolean}
+ */
+ _isSplitButtonOptionKey: function (p_oEvent) {
+
+ return (p_oEvent.ctrlKey && p_oEvent.shiftKey &&
+ Event.getCharCode(p_oEvent) == 77);
+
+ },
+
+
+ /**
+ * @method _addListenersToForm
+ * @description Adds event handlers to the button's form.
+ * @protected
+ */
+ _addListenersToForm: function () {
+
+ var oForm = this.getForm(),
+ onFormKeyPress = YAHOO.widget.Button.onFormKeyPress,
+ bHasKeyPressListener,
+ oSrcElement,
+ aListeners,
+ nListeners,
+ i;
+
+
+ if (oForm) {
+
+ Event.on(oForm, "reset", this._onFormReset, null, this);
+ Event.on(oForm, "submit", this.createHiddenFields, null, this);
+
+ oSrcElement = this.get("srcelement");
+
+
+ if (this.get("type") == "submit" ||
+ (oSrcElement && oSrcElement.type == "submit"))
+ {
+
+ aListeners = Event.getListeners(oForm, "keypress");
+ bHasKeyPressListener = false;
+
+ if (aListeners) {
+
+ nListeners = aListeners.length;
+
+ if (nListeners > 0) {
+
+ i = nListeners - 1;
+
+ do {
+
+ if (aListeners[i].fn == onFormKeyPress) {
+
+ bHasKeyPressListener = true;
+ break;
+
+ }
+
+ }
+ while (i--);
+
+ }
+
+ }
+
+
+ if (!bHasKeyPressListener) {
+
+ Event.on(oForm, "keypress", onFormKeyPress);
+
+ }
+
+ }
+
+ }
+
+ },
+
+
+
+ /**
+ * @method _showMenu
+ * @description Shows the button's menu.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event) that triggered
+ * the display of the menu.
+ */
+ _showMenu: function (p_oEvent) {
+
+ if (YAHOO.widget.MenuManager) {
+
+ YAHOO.widget.MenuManager.hideVisible();
+
+ }
+
+
+ if (m_oOverlayManager) {
+
+ m_oOverlayManager.hideAll();
+
+ }
+
+
+ var nViewportOffset = Overlay.VIEWPORT_OFFSET,
+
+ oMenu = this._menu,
+ oButton = this,
+ oButtonEL = oButton.get("element"),
+ bMenuFlipped = false,
+ nButtonY = Dom.getY(oButtonEL),
+ nScrollTop = Dom.getDocumentScrollTop(),
+ nMenuMinScrollHeight,
+ nMenuHeight,
+ oMenuShadow;
+
+
+ if (nScrollTop) {
+
+ nButtonY = nButtonY - nScrollTop;
+
+ }
+
+
+ var nTopRegion = nButtonY,
+ nBottomRegion = (Dom.getViewportHeight() -
+ (nButtonY + oButtonEL.offsetHeight));
+
+
+ /*
+ Uses the Button's position to calculate the availble height
+ above and below it to display its corresponding Menu.
+ */
+
+ function getMenuDisplayRegionHeight() {
+
+ if (bMenuFlipped) {
+
+ return (nTopRegion - nViewportOffset);
+
+ }
+ else {
+
+ return (nBottomRegion - nViewportOffset);
+
+ }
+
+ }
+
+
+
+ /*
+ Sets the Menu's "maxheight" configuration property and trys to
+ place the Menu in the best possible position (either above or
+ below its corresponding Button).
+ */
+
+ function sizeAndPositionMenu() {
+
+ var nDisplayRegionHeight = getMenuDisplayRegionHeight();
+
+
+ if (nMenuHeight > nDisplayRegionHeight) {
+
+ nMenuMinScrollHeight = oMenu.cfg.getProperty("minscrollheight");
+
+
+ if (nDisplayRegionHeight > nMenuMinScrollHeight) {
+
+ oMenu.cfg.setProperty("maxheight",
+ nDisplayRegionHeight);
+
+
+ if (bMenuFlipped) {
+
+ oMenu.align("bl", "tl");
+
+ }
+
+ }
+
+
+ if (nDisplayRegionHeight < nMenuMinScrollHeight) {
+
+ if (bMenuFlipped) {
+
+ /*
+ All possible positions and values for the
+ "maxheight" configuration property have been
+ tried, but none were successful, so fall back
+ to the original size and position.
+ */
+
+ oMenu.cfg.setProperty("context",
+ [oButtonEL, "tl", "bl"], true);
+
+ oMenu.align("tl", "bl");
+
+ }
+ else {
+
+ oMenu.cfg.setProperty("context",
+ [oButtonEL, "bl", "tl"], true);
+
+ oMenu.align("bl", "tl");
+
+ bMenuFlipped = true;
+
+ return sizeAndPositionMenu();
+
+ }
+
+ }
+
+ }
+
+ }
+
+
+ if (Menu && oMenu && (oMenu instanceof Menu)) {
+
+ oMenu.cfg.applyConfig({ context: [oButtonEL, "tl", "bl"],
+ clicktohide: false,
+ visible: true });
+
+ oMenu.cfg.fireQueue();
+
+ oMenu.cfg.setProperty("maxheight", 0);
+
+ oMenu.align("tl", "bl");
+
+
+ /*
+ Stop the propagation of the event so that the MenuManager
+ doesn't blur the menu after it gets focus.
+ */
+
+ if (p_oEvent.type == "mousedown") {
+
+ Event.stopPropagation(p_oEvent);
+
+ }
+
+
+ nMenuHeight = oMenu.element.offsetHeight;
+
+ oMenuShadow = oMenu.element.lastChild;
+
+ sizeAndPositionMenu();
+
+ if (this.get("focusmenu")) {
+
+ this._menu.focus();
+
+ }
+
+ }
+ else if (Overlay && oMenu && (oMenu instanceof Overlay)) {
+
+ oMenu.show();
+ oMenu.align("tl", "bl");
+
+ var nDisplayRegionHeight = getMenuDisplayRegionHeight();
+
+ nMenuHeight = oMenu.element.offsetHeight;
+
+
+ if (nDisplayRegionHeight < nMenuHeight) {
+
+ oMenu.align("bl", "tl");
+
+ bMenuFlipped = true;
+
+ nDisplayRegionHeight = getMenuDisplayRegionHeight();
+
+ if (nDisplayRegionHeight < nMenuHeight) {
+
+ oMenu.align("tl", "bl");
+
+ }
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _hideMenu
+ * @description Hides the button's menu.
+ * @protected
+ */
+ _hideMenu: function () {
+
+ var oMenu = this._menu;
+
+ if (oMenu) {
+
+ oMenu.hide();
+
+ }
+
+ },
+
+
+
+
+ // Protected event handlers
+
+
+ /**
+ * @method _onMouseOver
+ * @description "mouseover" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onMouseOver: function (p_oEvent) {
+
+ if (!this._hasMouseEventHandlers) {
+
+ this.on("mouseout", this._onMouseOut);
+ this.on("mousedown", this._onMouseDown);
+ this.on("mouseup", this._onMouseUp);
+
+ this._hasMouseEventHandlers = true;
+
+ }
+
+ this.addStateCSSClasses("hover");
+
+ if (this._activationButtonPressed) {
+
+ this.addStateCSSClasses("active");
+
+ }
+
+
+ if (this._bOptionPressed) {
+
+ this.addStateCSSClasses("activeoption");
+
+ }
+
+
+ if (this._activationButtonPressed || this._bOptionPressed) {
+
+ Event.removeListener(document, "mouseup", this._onDocumentMouseUp);
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMouseOut
+ * @description "mouseout" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onMouseOut: function (p_oEvent) {
+
+ this.removeStateCSSClasses("hover");
+
+ if (this.get("type") != "menu") {
+
+ this.removeStateCSSClasses("active");
+
+ }
+
+ if (this._activationButtonPressed || this._bOptionPressed) {
+
+ Event.on(document, "mouseup", this._onDocumentMouseUp,
+ null, this);
+
+ }
+
+ },
+
+
+ /**
+ * @method _onDocumentMouseUp
+ * @description "mouseup" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onDocumentMouseUp: function (p_oEvent) {
+
+ this._activationButtonPressed = false;
+ this._bOptionPressed = false;
+
+ var sType = this.get("type"),
+ oTarget,
+ oMenuElement;
+
+ if (sType == "menu" || sType == "split") {
+
+ oTarget = Event.getTarget(p_oEvent);
+ oMenuElement = this._menu.element;
+
+ if (oTarget != oMenuElement &&
+ !Dom.isAncestor(oMenuElement, oTarget)) {
+
+ this.removeStateCSSClasses((sType == "menu" ?
+ "active" : "activeoption"));
+
+ this._hideMenu();
+
+ }
+
+ }
+
+ Event.removeListener(document, "mouseup", this._onDocumentMouseUp);
+
+ },
+
+
+ /**
+ * @method _onMouseDown
+ * @description "mousedown" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onMouseDown: function (p_oEvent) {
+
+ var sType,
+ oElement,
+ nX,
+ me;
+
+
+ function onMouseUp() {
+
+ this._hideMenu();
+ this.removeListener("mouseup", onMouseUp);
+
+ }
+
+
+ if ((p_oEvent.which || p_oEvent.button) == 1) {
+
+
+ if (!this.hasFocus()) {
+
+ this.focus();
+
+ }
+
+
+ sType = this.get("type");
+
+
+ if (sType == "split") {
+
+ oElement = this.get("element");
+ nX = Event.getPageX(p_oEvent) - Dom.getX(oElement);
+
+ if ((oElement.offsetWidth - this.OPTION_AREA_WIDTH) < nX) {
+
+ this.fireEvent("option", p_oEvent);
+
+ }
+ else {
+
+ this.addStateCSSClasses("active");
+
+ this._activationButtonPressed = true;
+
+ }
+
+ }
+ else if (sType == "menu") {
+
+ if (this.isActive()) {
+
+ this._hideMenu();
+
+ this._activationButtonPressed = false;
+
+ }
+ else {
+
+ this._showMenu(p_oEvent);
+
+ this._activationButtonPressed = true;
+
+ }
+
+ }
+ else {
+
+ this.addStateCSSClasses("active");
+
+ this._activationButtonPressed = true;
+
+ }
+
+
+
+ if (sType == "split" || sType == "menu") {
+
+ me = this;
+
+ this._hideMenuTimerId = window.setTimeout(function () {
+
+ me.on("mouseup", onMouseUp);
+
+ }, 250);
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMouseUp
+ * @description "mouseup" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onMouseUp: function (p_oEvent) {
+
+ var sType = this.get("type");
+
+
+ if (this._hideMenuTimerId) {
+
+ window.clearTimeout(this._hideMenuTimerId);
+
+ }
+
+
+ if (sType == "checkbox" || sType == "radio") {
+
+ this.set("checked", !(this.get("checked")));
+
+ }
+
+
+ this._activationButtonPressed = false;
+
+
+ if (this.get("type") != "menu") {
+
+ this.removeStateCSSClasses("active");
+
+ }
+
+ },
+
+
+ /**
+ * @method _onFocus
+ * @description "focus" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onFocus: function (p_oEvent) {
+
+ var oElement;
+
+ this.addStateCSSClasses("focus");
+
+ if (this._activationKeyPressed) {
+
+ this.addStateCSSClasses("active");
+
+ }
+
+ m_oFocusedButton = this;
+
+
+ if (!this._hasKeyEventHandlers) {
+
+ oElement = this._button;
+
+ Event.on(oElement, "blur", this._onBlur, null, this);
+ Event.on(oElement, "keydown", this._onKeyDown, null, this);
+ Event.on(oElement, "keyup", this._onKeyUp, null, this);
+
+ this._hasKeyEventHandlers = true;
+
+ }
+
+
+ this.fireEvent("focus", p_oEvent);
+
+ },
+
+
+ /**
+ * @method _onBlur
+ * @description "blur" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onBlur: function (p_oEvent) {
+
+ this.removeStateCSSClasses("focus");
+
+ if (this.get("type") != "menu") {
+
+ this.removeStateCSSClasses("active");
+
+ }
+
+ if (this._activationKeyPressed) {
+
+ Event.on(document, "keyup", this._onDocumentKeyUp, null, this);
+
+ }
+
+
+ m_oFocusedButton = null;
+
+ this.fireEvent("blur", p_oEvent);
+
+ },
+
+
+ /**
+ * @method _onDocumentKeyUp
+ * @description "keyup" event handler for the document.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onDocumentKeyUp: function (p_oEvent) {
+
+ if (this._isActivationKey(Event.getCharCode(p_oEvent))) {
+
+ this._activationKeyPressed = false;
+
+ Event.removeListener(document, "keyup", this._onDocumentKeyUp);
+
+ }
+
+ },
+
+
+ /**
+ * @method _onKeyDown
+ * @description "keydown" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onKeyDown: function (p_oEvent) {
+
+ var oMenu = this._menu;
+
+
+ if (this.get("type") == "split" &&
+ this._isSplitButtonOptionKey(p_oEvent)) {
+
+ this.fireEvent("option", p_oEvent);
+
+ }
+ else if (this._isActivationKey(Event.getCharCode(p_oEvent))) {
+
+ if (this.get("type") == "menu") {
+
+ this._showMenu(p_oEvent);
+
+ }
+ else {
+
+ this._activationKeyPressed = true;
+
+ this.addStateCSSClasses("active");
+
+ }
+
+ }
+
+
+ if (oMenu && oMenu.cfg.getProperty("visible") &&
+ Event.getCharCode(p_oEvent) == 27) {
+
+ oMenu.hide();
+ this.focus();
+
+ }
+
+ },
+
+
+ /**
+ * @method _onKeyUp
+ * @description "keyup" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onKeyUp: function (p_oEvent) {
+
+ var sType;
+
+ if (this._isActivationKey(Event.getCharCode(p_oEvent))) {
+
+ sType = this.get("type");
+
+ if (sType == "checkbox" || sType == "radio") {
+
+ this.set("checked", !(this.get("checked")));
+
+ }
+
+ this._activationKeyPressed = false;
+
+ if (this.get("type") != "menu") {
+
+ this.removeStateCSSClasses("active");
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _onClick
+ * @description "click" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onClick: function (p_oEvent) {
+
+ var sType = this.get("type"),
+ sTitle,
+ oForm,
+ oSrcElement,
+ oElement,
+ nX;
+
+
+ switch (sType) {
+
+ case "radio":
+ case "checkbox":
+
+ if (this.get("checked")) {
+
+ sTitle = (sType == "radio") ?
+ this.RADIO_CHECKED_TITLE :
+ this.CHECKBOX_CHECKED_TITLE;
+
+ }
+ else {
+
+ sTitle = (sType == "radio") ?
+ this.RADIO_DEFAULT_TITLE :
+ this.CHECKBOX_DEFAULT_TITLE;
+
+ }
+
+ this.set("title", sTitle);
+
+ break;
+
+ case "submit":
+
+ this.submitForm();
+
+ break;
+
+ case "reset":
+
+ oForm = this.getForm();
+
+ if (oForm) {
+
+ oForm.reset();
+
+ }
+
+ break;
+
+ case "menu":
+
+ sTitle = this._menu.cfg.getProperty("visible") ?
+ this.MENUBUTTON_MENU_VISIBLE_TITLE :
+ this.MENUBUTTON_DEFAULT_TITLE;
+
+ this.set("title", sTitle);
+
+ break;
+
+ case "split":
+
+ oElement = this.get("element");
+ nX = Event.getPageX(p_oEvent) - Dom.getX(oElement);
+
+ if ((oElement.offsetWidth - this.OPTION_AREA_WIDTH) < nX) {
+
+ return false;
+
+ }
+ else {
+
+ this._hideMenu();
+
+ oSrcElement = this.get("srcelement");
+
+ if (oSrcElement && oSrcElement.type == "submit") {
+
+ this.submitForm();
+
+ }
+
+ }
+
+ sTitle = this._menu.cfg.getProperty("visible") ?
+ this.SPLITBUTTON_OPTION_VISIBLE_TITLE :
+ this.SPLITBUTTON_DEFAULT_TITLE;
+
+ this.set("title", sTitle);
+
+ break;
+
+ }
+
+ },
+
+
+ /**
+ * @method _onAppendTo
+ * @description "appendTo" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onAppendTo: function (p_oEvent) {
+
+ /*
+ It is necessary to call "_addListenersToForm" using
+ "setTimeout" to make sure that the button's "form" property
+ returns a node reference. Sometimes, if you try to get the
+ reference immediately after appending the field, it is null.
+ */
+
+ var me = this;
+
+ window.setTimeout(function () {
+
+ me._addListenersToForm();
+
+ }, 0);
+
+ },
+
+
+ /**
+ * @method _onFormReset
+ * @description "reset" event handler for the button's form.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event
+ * object passed back by the event utility (YAHOO.util.Event).
+ */
+ _onFormReset: function (p_oEvent) {
+
+ var sType = this.get("type"),
+ oMenu = this._menu;
+
+ if (sType == "checkbox" || sType == "radio") {
+
+ this.resetValue("checked");
+
+ }
+
+
+ if (Menu && oMenu && (oMenu instanceof Menu)) {
+
+ this.resetValue("selectedMenuItem");
+
+ }
+
+ },
+
+
+ /**
+ * @method _onDocumentMouseDown
+ * @description "mousedown" event handler for the document.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onDocumentMouseDown: function (p_oEvent) {
+
+ var oTarget = Event.getTarget(p_oEvent),
+ oButtonElement = this.get("element"),
+ oMenuElement = this._menu.element;
+
+
+ if (oTarget != oButtonElement &&
+ !Dom.isAncestor(oButtonElement, oTarget) &&
+ oTarget != oMenuElement &&
+ !Dom.isAncestor(oMenuElement, oTarget)) {
+
+ this._hideMenu();
+
+ Event.removeListener(document, "mousedown",
+ this._onDocumentMouseDown);
+
+ }
+
+ },
+
+
+ /**
+ * @method _onOption
+ * @description "option" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onOption: function (p_oEvent) {
+
+ if (this.hasClass("yui-split-button-activeoption")) {
+
+ this._hideMenu();
+
+ this._bOptionPressed = false;
+
+ }
+ else {
+
+ this._showMenu(p_oEvent);
+
+ this._bOptionPressed = true;
+
+ }
+
+ },
+
+
+ /**
+ * @method _onOverlayBeforeShow
+ * @description "beforeshow" event handler for the
+ * YAHOO.widget.Overlay instance
+ * serving as the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ */
+ _onOverlayBeforeShow: function (p_sType) {
+
+ var oMenu = this._menu;
+
+ oMenu.render(this.get("element").parentNode);
+
+ oMenu.beforeShowEvent.unsubscribe(this._onOverlayBeforeShow);
+
+ },
+
+
+ /**
+ * @method _onMenuShow
+ * @description "show" event handler for the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ */
+ _onMenuShow: function (p_sType) {
+
+ Event.on(document, "mousedown", this._onDocumentMouseDown,
+ null, this);
+
+ var sTitle,
+ sState;
+
+ if (this.get("type") == "split") {
+
+ sTitle = this.SPLITBUTTON_OPTION_VISIBLE_TITLE;
+ sState = "activeoption";
+
+ }
+ else {
+
+ sTitle = this.MENUBUTTON_MENU_VISIBLE_TITLE;
+ sState = "active";
+
+ }
+
+ this.addStateCSSClasses(sState);
+ this.set("title", sTitle);
+
+ },
+
+
+ /**
+ * @method _onMenuHide
+ * @description "hide" event handler for the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ */
+ _onMenuHide: function (p_sType) {
+
+ var oMenu = this._menu,
+ sTitle,
+ sState;
+
+
+ if (this.get("type") == "split") {
+
+ sTitle = this.SPLITBUTTON_DEFAULT_TITLE;
+ sState = "activeoption";
+
+ }
+ else {
+
+ sTitle = this.MENUBUTTON_DEFAULT_TITLE;
+ sState = "active";
+ }
+
+
+ this.removeStateCSSClasses(sState);
+ this.set("title", sTitle);
+
+
+ if (this.get("type") == "split") {
+
+ this._bOptionPressed = false;
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMenuKeyDown
+ * @description "keydown" event handler for the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ * @param {Array} p_aArgs Array of arguments sent when the event
+ * was fired.
+ */
+ _onMenuKeyDown: function (p_sType, p_aArgs) {
+
+ var oEvent = p_aArgs[0];
+
+ if (Event.getCharCode(oEvent) == 27) {
+
+ this.focus();
+
+ if (this.get("type") == "split") {
+
+ this._bOptionPressed = false;
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMenuRender
+ * @description "render" event handler for the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the
+ * event thatwas fired.
+ */
+ _onMenuRender: function (p_sType) {
+
+ var oButtonElement = this.get("element"),
+ oButtonParent = oButtonElement.parentNode,
+ oMenuElement = this._menu.element;
+
+
+ if (oButtonParent != oMenuElement.parentNode) {
+
+ oButtonParent.appendChild(oMenuElement);
+
+ }
+
+ this.set("selectedMenuItem", this.get("selectedMenuItem"));
+
+ },
+
+
+ /**
+ * @method _onMenuItemSelected
+ * @description "selectedchange" event handler for each item in the
+ * button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ * @param {Array} p_aArgs Array of arguments sent when the event
+ * was fired.
+ * @param {MenuItem} p_oItem Object representing the menu item that
+ * subscribed to the event.
+ */
+ _onMenuItemSelected: function (p_sType, p_aArgs, p_oItem) {
+
+ var bSelected = p_aArgs[0];
+
+ if (bSelected) {
+
+ this.set("selectedMenuItem", p_oItem);
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMenuItemAdded
+ * @description "itemadded" event handler for the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ * @param {Array} p_aArgs Array of arguments sent when the event
+ * was fired.
+ * @param {
+ * YAHOO.widget.MenuItem} p_oItem Object representing the menu
+ * item that subscribed to the event.
+ */
+ _onMenuItemAdded: function (p_sType, p_aArgs, p_oItem) {
+
+ var oItem = p_aArgs[0];
+
+ oItem.cfg.subscribeToConfigEvent("selected",
+ this._onMenuItemSelected, oItem, this);
+
+ },
+
+
+ /**
+ * @method _onMenuClick
+ * @description "click" event handler for the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ * @param {Array} p_aArgs Array of arguments sent when the event
+ * was fired.
+ */
+ _onMenuClick: function (p_sType, p_aArgs) {
+
+ var oItem = p_aArgs[1],
+ oSrcElement;
+
+ if (oItem) {
+
+ oSrcElement = this.get("srcelement");
+
+ if (oSrcElement && oSrcElement.type == "submit") {
+
+ this.submitForm();
+
+ }
+
+ this._hideMenu();
+
+ }
+
+ },
+
+
+
+ // Public methods
+
+
+ /**
+ * @method createButtonElement
+ * @description Creates the button's HTML elements.
+ * @param {String} p_sType String indicating the type of element
+ * to create.
+ * @return {HTMLElement}
+ */
+ createButtonElement: function (p_sType) {
+
+ var sNodeName = this.NODE_NAME,
+ oElement = document.createElement(sNodeName);
+
+ oElement.innerHTML = "<" + sNodeName + " class=\"first-child\">" +
+ (p_sType == "link" ? "" :
+ "") + "" + sNodeName + ">";
+
+ return oElement;
+
+ },
+
+
+ /**
+ * @method addStateCSSClasses
+ * @description Appends state-specific CSS classes to the button's root
+ * DOM element.
+ */
+ addStateCSSClasses: function (p_sState) {
+
+ var sType = this.get("type");
+
+ if (Lang.isString(p_sState)) {
+
+ if (p_sState != "activeoption") {
+
+ this.addClass(this.CSS_CLASS_NAME + ("-" + p_sState));
+
+ }
+
+ this.addClass("yui-" + sType + ("-button-" + p_sState));
+
+ }
+
+ },
+
+
+ /**
+ * @method removeStateCSSClasses
+ * @description Removes state-specific CSS classes to the button's root
+ * DOM element.
+ */
+ removeStateCSSClasses: function (p_sState) {
+
+ var sType = this.get("type");
+
+ if (Lang.isString(p_sState)) {
+
+ this.removeClass(this.CSS_CLASS_NAME + ("-" + p_sState));
+ this.removeClass("yui-" + sType + ("-button-" + p_sState));
+
+ }
+
+ },
+
+
+ /**
+ * @method createHiddenFields
+ * @description Creates the button's hidden form field and appends it
+ * to its parent form.
+ * @return {HTMLInputElement|Array}
+ */
+ createHiddenFields: function () {
+
+ this.removeHiddenFields();
+
+ var oForm = this.getForm(),
+ oButtonField,
+ sType,
+ bCheckable,
+ oMenu,
+ oMenuItem,
+ sName,
+ oValue,
+ oMenuField;
+
+
+ if (oForm && !this.get("disabled")) {
+
+ sType = this.get("type");
+ bCheckable = (sType == "checkbox" || sType == "radio");
+
+
+ if (bCheckable || (m_oSubmitTrigger == this)) {
+
+
+ oButtonField = createInputElement(
+ (bCheckable ? sType : "hidden"),
+ this.get("name"),
+ this.get("value"),
+ this.get("checked"));
+
+
+ if (oButtonField) {
+
+ if (bCheckable) {
+
+ oButtonField.style.display = "none";
+
+ }
+
+ oForm.appendChild(oButtonField);
+
+ }
+
+ }
+
+
+ oMenu = this._menu;
+
+
+ if (Menu && oMenu && (oMenu instanceof Menu)) {
+
+
+ oMenuField = oMenu.srcElement;
+ oMenuItem = this.get("selectedMenuItem");
+
+ if (oMenuItem) {
+
+ if (oMenuField &&
+ oMenuField.nodeName.toUpperCase() == "SELECT") {
+
+ oForm.appendChild(oMenuField);
+ oMenuField.selectedIndex = oMenuItem.index;
+
+ }
+ else {
+
+ oValue = (oMenuItem.value === null ||
+ oMenuItem.value === "") ?
+ oMenuItem.cfg.getProperty("text") :
+ oMenuItem.value;
+
+ sName = this.get("name");
+
+ if (oValue && sName) {
+
+ oMenuField = createInputElement("hidden",
+ (sName + "_options"),
+ oValue);
+
+ oForm.appendChild(oMenuField);
+
+ }
+
+ }
+
+ }
+
+ }
+
+
+ if (oButtonField && oMenuField) {
+
+ this._hiddenFields = [oButtonField, oMenuField];
+
+ }
+ else if (!oButtonField && oMenuField) {
+
+ this._hiddenFields = oMenuField;
+
+ }
+ else if (oButtonField && !oMenuField) {
+
+ this._hiddenFields = oButtonField;
+
+ }
+
+
+ return this._hiddenFields;
+
+ }
+
+ },
+
+
+ /**
+ * @method removeHiddenFields
+ * @description Removes the button's hidden form field(s) from its
+ * parent form.
+ */
+ removeHiddenFields: function () {
+
+ var oField = this._hiddenFields,
+ nFields,
+ i;
+
+ function removeChild(p_oElement) {
+
+ if (Dom.inDocument(p_oElement)) {
+
+ p_oElement.parentNode.removeChild(p_oElement);
+
+ }
+
+ }
+
+
+ if (oField) {
+
+ if (Lang.isArray(oField)) {
+
+ nFields = oField.length;
+
+ if (nFields > 0) {
+
+ i = nFields - 1;
+
+ do {
+
+ removeChild(oField[i]);
+
+ }
+ while (i--);
+
+ }
+
+ }
+ else {
+
+ removeChild(oField);
+
+ }
+
+ this._hiddenFields = null;
+
+ }
+
+ },
+
+
+ /**
+ * @method submitForm
+ * @description Submits the form to which the button belongs. Returns
+ * true if the form was submitted successfully, false if the submission
+ * was cancelled.
+ * @protected
+ * @return {Boolean}
+ */
+ submitForm: function () {
+
+ var oForm = this.getForm(),
+
+ oSrcElement = this.get("srcelement"),
+
+ /*
+ Boolean indicating if the event fired successfully
+ (was not cancelled by any handlers)
+ */
+
+ bSubmitForm = false,
+
+ oEvent;
+
+
+ if (oForm) {
+
+ if (this.get("type") == "submit" ||
+ (oSrcElement && oSrcElement.type == "submit"))
+ {
+
+ m_oSubmitTrigger = this;
+
+ }
+
+
+ if (YAHOO.env.ua.ie) {
+
+ bSubmitForm = oForm.fireEvent("onsubmit");
+
+ }
+ else { // Gecko, Opera, and Safari
+
+ oEvent = document.createEvent("HTMLEvents");
+ oEvent.initEvent("submit", true, true);
+
+ bSubmitForm = oForm.dispatchEvent(oEvent);
+
+ }
+
+
+ /*
+ In IE and Safari, dispatching a "submit" event to a form
+ WILL cause the form's "submit" event to fire, but WILL NOT
+ submit the form. Therefore, we need to call the "submit"
+ method as well.
+ */
+
+ if ((YAHOO.env.ua.ie || YAHOO.env.ua.webkit) && bSubmitForm) {
+
+ oForm.submit();
+
+ }
+
+ }
+
+ return bSubmitForm;
+
+ },
+
+
+ /**
+ * @method init
+ * @description The Button class's initialization method.
+ * @param {String} p_oElement String specifying the id attribute of the
+ * <input>
, <button>
,
+ * <a>
, or <span>
element to
+ * be used to create the button.
+ * @param {HTMLInputElement|HTMLButtonElement|
+ * HTMLElement} p_oElement Object reference for the
+ * <input>
, <button>
,
+ * <a>
, or <span>
element to be
+ * used to create the button.
+ * @param {Object} p_oElement Object literal specifying a set of
+ * configuration attributes used to create the button.
+ * @param {Object} p_oAttributes Optional. Object literal specifying a
+ * set of configuration attributes used to create the button.
+ */
+ init: function (p_oElement, p_oAttributes) {
+
+ var sNodeName = p_oAttributes.type == "link" ? "a" : "button",
+ oSrcElement = p_oAttributes.srcelement,
+ oButton = p_oElement.getElementsByTagName(sNodeName)[0],
+ oInput;
+
+
+ if (!oButton) {
+
+ oInput = p_oElement.getElementsByTagName("input")[0];
+
+
+ if (oInput) {
+
+ oButton = document.createElement("button");
+ oButton.setAttribute("type", "button");
+
+ oInput.parentNode.replaceChild(oButton, oInput);
+
+ }
+
+ }
+
+ this._button = oButton;
+
+
+ YAHOO.widget.Button.superclass.init.call(this, p_oElement,
+ p_oAttributes);
+
+
+ m_oButtons[this.get("id")] = this;
+
+
+ this.addClass(this.CSS_CLASS_NAME);
+
+ this.addClass("yui-" + this.get("type") + "-button");
+
+ Event.on(this._button, "focus", this._onFocus, null, this);
+ this.on("mouseover", this._onMouseOver);
+ this.on("click", this._onClick);
+ this.on("appendTo", this._onAppendTo);
+
+
+ var oContainer = this.get("container"),
+ oElement = this.get("element"),
+ bElInDoc = Dom.inDocument(oElement),
+ oParentNode;
+
+
+ if (oContainer) {
+
+ if (oSrcElement && oSrcElement != oElement) {
+
+ oParentNode = oSrcElement.parentNode;
+
+ if (oParentNode) {
+
+ oParentNode.removeChild(oSrcElement);
+
+ }
+
+ }
+
+ if (Lang.isString(oContainer)) {
+
+ Event.onContentReady(oContainer, function () {
+
+ this.appendTo(oContainer);
+
+ }, null, this);
+
+ }
+ else {
+
+ this.appendTo(oContainer);
+
+ }
+
+ }
+ else if (!bElInDoc && oSrcElement && oSrcElement != oElement) {
+
+ oParentNode = oSrcElement.parentNode;
+
+ if (oParentNode) {
+
+ this.fireEvent("beforeAppendTo", {
+ type: "beforeAppendTo",
+ target: oParentNode
+ });
+
+ oParentNode.replaceChild(oElement, oSrcElement);
+
+ this.fireEvent("appendTo", {
+ type: "appendTo",
+ target: oParentNode
+ });
+
+ }
+
+ }
+ else if (this.get("type") != "link" && bElInDoc && oSrcElement &&
+ oSrcElement == oElement) {
+
+ this._addListenersToForm();
+
+ }
+
+
+ },
+
+
+ /**
+ * @method initAttributes
+ * @description Initializes all of the configuration attributes used to
+ * create the button.
+ * @param {Object} p_oAttributes Object literal specifying a set of
+ * configuration attributes used to create the button.
+ */
+ initAttributes: function (p_oAttributes) {
+
+ var oAttributes = p_oAttributes || {};
+
+ YAHOO.widget.Button.superclass.initAttributes.call(this,
+ oAttributes);
+
+
+ /**
+ * @attribute type
+ * @description String specifying the button's type. Possible
+ * values are: "push," "link," "submit," "reset," "checkbox,"
+ * "radio," "menu," and "split."
+ * @default "push"
+ * @type String
+ */
+ this.setAttributeConfig("type", {
+
+ value: (oAttributes.type || "push"),
+ validator: Lang.isString,
+ writeOnce: true,
+ method: this._setType
+
+ });
+
+
+ /**
+ * @attribute label
+ * @description String specifying the button's text label
+ * or innerHTML.
+ * @default null
+ * @type String
+ */
+ this.setAttributeConfig("label", {
+
+ value: oAttributes.label,
+ validator: Lang.isString,
+ method: this._setLabel
+
+ });
+
+
+ /**
+ * @attribute value
+ * @description Object specifying the value for the button.
+ * @default null
+ * @type Object
+ */
+ this.setAttributeConfig("value", {
+
+ value: oAttributes.value
+
+ });
+
+
+ /**
+ * @attribute name
+ * @description String specifying the name for the button.
+ * @default null
+ * @type String
+ */
+ this.setAttributeConfig("name", {
+
+ value: oAttributes.name,
+ validator: Lang.isString
+
+ });
+
+
+ /**
+ * @attribute tabindex
+ * @description Number specifying the tabindex for the button.
+ * @default null
+ * @type Number
+ */
+ this.setAttributeConfig("tabindex", {
+
+ value: oAttributes.tabindex,
+ validator: Lang.isNumber,
+ method: this._setTabIndex
+
+ });
+
+
+ /**
+ * @attribute title
+ * @description String specifying the title for the button.
+ * @default null
+ * @type String
+ */
+ this.configureAttribute("title", {
+
+ value: oAttributes.title,
+ validator: Lang.isString,
+ method: this._setTitle
+
+ });
+
+
+ /**
+ * @attribute disabled
+ * @description Boolean indicating if the button should be disabled.
+ * (Disabled buttons are dimmed and will not respond to user input
+ * or fire events. Does not apply to button's of type "link.")
+ * @default false
+ * @type Boolean
+ */
+ this.setAttributeConfig("disabled", {
+
+ value: (oAttributes.disabled || false),
+ validator: Lang.isBoolean,
+ method: this._setDisabled
+
+ });
+
+
+ /**
+ * @attribute href
+ * @description String specifying the href for the button. Applies
+ * only to buttons of type "link."
+ * @type String
+ */
+ this.setAttributeConfig("href", {
+
+ value: oAttributes.href,
+ validator: Lang.isString,
+ method: this._setHref
+
+ });
+
+
+ /**
+ * @attribute target
+ * @description String specifying the target for the button.
+ * Applies only to buttons of type "link."
+ * @type String
+ */
+ this.setAttributeConfig("target", {
+
+ value: oAttributes.target,
+ validator: Lang.isString,
+ method: this._setTarget
+
+ });
+
+
+ /**
+ * @attribute checked
+ * @description Boolean indicating if the button is checked.
+ * Applies only to buttons of type "radio" and "checkbox."
+ * @default false
+ * @type Boolean
+ */
+ this.setAttributeConfig("checked", {
+
+ value: (oAttributes.checked || false),
+ validator: Lang.isBoolean,
+ method: this._setChecked
+
+ });
+
+
+ /**
+ * @attribute container
+ * @description HTML element reference or string specifying the id
+ * attribute of the HTML element that the button's markup should be
+ * rendered into.
+ * @type HTMLElement|String
+ * @default null
+ */
+ this.setAttributeConfig("container", {
+
+ value: oAttributes.container,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @attribute srcelement
+ * @description Object reference to the HTML element (either
+ * <input>
or <span>
)
+ * used to create the button.
+ * @type HTMLElement|String
+ * @default null
+ */
+ this.setAttributeConfig("srcelement", {
+
+ value: oAttributes.srcelement,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @attribute menu
+ * @description Object specifying the menu for the button.
+ * The value can be one of the following:
+ *
+ *
+ * @type YAHOO.widget.Menu|YAHOO.widget.Overlay|HTMLElement|String|Array
+ * @default null
+ */
+ this.setAttributeConfig("menu", {
+
+ value: null,
+ method: this._setMenu,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @attribute lazyloadmenu
+ * @description Boolean indicating the value to set for the
+ * "lazyload"
+ * configuration property of the button's menu. Setting
+ * "lazyloadmenu" to <div>
+ *
element used to create the menu. By default the menu
+ * will be created as an instance of
+ * YAHOO.widget.Overlay.
+ * If the
+ * default CSS class name for YAHOO.widget.Menu is applied to
+ * the <div>
element, it will be created as an
+ * instance of YAHOO.widget.Menu
+ * .<select>
element used to create the menu.
+ * <div>
element
+ * used to create the menu.<select>
element
+ * used to create the menu.true
will defer rendering of
+ * the button's menu until the first time it is made visible.
+ * If "lazyloadmenu" is set to false
, the button's
+ * menu will be rendered immediately if the button is in the
+ * document, or in response to the button's "appendTo" event if
+ * the button is not yet in the document. In either case, the
+ * menu is rendered into the button's parent HTML element.
+ * This attribute does not apply if a
+ * YAHOO.widget.Menu or
+ * YAHOO.widget.Overlay
+ * instance is passed as the value of the button's "menu"
+ * configuration attribute.
+ * YAHOO.widget.Menu or
+ * YAHOO.widget.Overlay instances should be rendered before
+ * being set as the value for the "menu" configuration
+ * attribute.
+ * @default true
+ * @type Boolean
+ */
+ this.setAttributeConfig("lazyloadmenu", {
+
+ value: (oAttributes.lazyloadmenu === false ? false : true),
+ validator: Lang.isBoolean,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @attribute menuclassname
+ * @description String representing the CSS class name to be
+ * applied to the root element of the button's menu.
+ * @type String
+ * @default "yui-button-menu"
+ */
+ this.setAttributeConfig("menuclassname", {
+
+ value: (oAttributes.menuclassname || "yui-button-menu"),
+ validator: Lang.isString,
+ method: this._setMenuClassName,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @attribute selectedMenuItem
+ * @description Object representing the item in the button's menu
+ * that is currently selected.
+ * @type Number
+ * @default null
+ */
+ this.setAttributeConfig("selectedMenuItem", {
+
+ value: null,
+ method: this._setSelectedMenuItem
+
+ });
+
+
+ /**
+ * @attribute onclick
+ * @description Object literal representing the code to be executed
+ * when the button is clicked. Format:
{
+ * @type Object
+ * @default null
+ */
+ this.setAttributeConfig("onclick", {
+
+ value: oAttributes.onclick,
+ method: this._setOnClick
+
+ });
+
+
+ /**
+ * @attribute focusmenu
+ * @description Boolean indicating whether or not the button's menu
+ * should be focused when it is made visible.
+ * @type Boolean
+ * @default true
+ */
+ this.setAttributeConfig("focusmenu", {
+
+ value: (oAttributes.focusmenu === false ? false : true),
+ validator: Lang.isBoolean
+
+ });
+
+ },
+
+
+ /**
+ * @method focus
+ * @description Causes the button to receive the focus and fires the
+ * button's "focus" event.
+ */
+ focus: function () {
+
+ if (!this.get("disabled")) {
+
+ this._button.focus();
+
+ }
+
+ },
+
+
+ /**
+ * @method blur
+ * @description Causes the button to lose focus and fires the button's
+ * "blur" event.
+ */
+ blur: function () {
+
+ if (!this.get("disabled")) {
+
+ this._button.blur();
+
+ }
+
+ },
+
+
+ /**
+ * @method hasFocus
+ * @description Returns a boolean indicating whether or not the button
+ * has focus.
+ * @return {Boolean}
+ */
+ hasFocus: function () {
+
+ return (m_oFocusedButton == this);
+
+ },
+
+
+ /**
+ * @method isActive
+ * @description Returns a boolean indicating whether or not the button
+ * is active.
+ * @return {Boolean}
+ */
+ isActive: function () {
+
+ return this.hasClass(this.CSS_CLASS_NAME + "-active");
+
+ },
+
+
+ /**
+ * @method getMenu
+ * @description Returns a reference to the button's menu.
+ * @return {
+ * YAHOO.widget.Overlay|YAHOO.widget.Menu}
+ */
+ getMenu: function () {
+
+ return this._menu;
+
+ },
+
+
+ /**
+ * @method getForm
+ * @description Returns a reference to the button's parent form.
+ * @return {HTMLFormElement}
+ */
+ getForm: function () {
+
+ return this._button.form;
+
+ },
+
+
+ /**
+ * @method getHiddenFields
+ * @description Returns an
+ * fn: Function, // The handler to call
+ * when the event fires.
obj: Object,
+ * // An object to pass back to the handler.
+ * scope: Object // The object to use
+ * for the scope of the handler.
} <input>
element or
+ * array of form elements used to represent the button when its parent
+ * form is submitted.
+ * @return {HTMLInputElement|Array}
+ */
+ getHiddenFields: function () {
+
+ return this._hiddenFields;
+
+ },
+
+
+ /**
+ * @method destroy
+ * @description Removes the button's element from its parent element and
+ * removes all event handlers.
+ */
+ destroy: function () {
+
+
+ var oElement = this.get("element"),
+ oParentNode = oElement.parentNode,
+ oMenu = this._menu,
+ aButtons;
+
+ if (oMenu) {
+
+
+ if (m_oOverlayManager && m_oOverlayManager.find(oMenu)) {
+
+ m_oOverlayManager.remove(oMenu);
+
+ }
+
+ oMenu.destroy();
+
+ }
+
+
+ Event.purgeElement(oElement);
+ Event.purgeElement(this._button);
+ Event.removeListener(document, "mouseup", this._onDocumentMouseUp);
+ Event.removeListener(document, "keyup", this._onDocumentKeyUp);
+ Event.removeListener(document, "mousedown",
+ this._onDocumentMouseDown);
+
+
+ var oForm = this.getForm();
+
+ if (oForm) {
+
+ Event.removeListener(oForm, "reset", this._onFormReset);
+ Event.removeListener(oForm, "submit", this.createHiddenFields);
+
+ }
+
+
+ this.unsubscribeAll();
+
+ if (oParentNode) {
+
+ oParentNode.removeChild(oElement);
+
+ }
+
+
+ delete m_oButtons[this.get("id")];
+
+ aButtons = Dom.getElementsByClassName(this.CSS_CLASS_NAME,
+ this.NODE_NAME, oForm);
+
+ if (Lang.isArray(aButtons) && aButtons.length === 0) {
+
+ Event.removeListener(oForm, "keypress",
+ YAHOO.widget.Button.onFormKeyPress);
+
+ }
+
+
+ },
+
+
+ fireEvent: function (p_sType , p_aArgs) {
+
+ var sType = arguments[0];
+
+ // Disabled buttons should not respond to DOM events
+
+ if (this.DOM_EVENTS[sType] && this.get("disabled")) {
+
+ return;
+
+ }
+
+ return YAHOO.widget.Button.superclass.fireEvent.apply(this, arguments);
+
+ },
+
+
+ /**
+ * @method toString
+ * @description Returns a string representing the button.
+ * @return {String}
+ */
+ toString: function () {
+
+ return ("Button " + this.get("id"));
+
+ }
+
+ });
+
+
+ /**
+ * @method YAHOO.widget.Button.onFormKeyPress
+ * @description "keypress" event handler for the button's form.
+ * @param {Event} p_oEvent Object representing the DOM event object passed
+ * back by the event utility (YAHOO.util.Event).
+ */
+ YAHOO.widget.Button.onFormKeyPress = function (p_oEvent) {
+
+ var oTarget = Event.getTarget(p_oEvent),
+ nCharCode = Event.getCharCode(p_oEvent),
+ sNodeName = oTarget.nodeName && oTarget.nodeName.toUpperCase(),
+ sType = oTarget.type,
+
+ /*
+ Boolean indicating if the form contains any enabled or
+ disabled YUI submit buttons
+ */
+
+ bFormContainsYUIButtons = false,
+
+ oButton,
+
+ oYUISubmitButton, // The form's first, enabled YUI submit button
+
+ /*
+ The form's first, enabled HTML submit button that precedes any
+ YUI submit button
+ */
+
+ oPrecedingSubmitButton,
+
+
+ /*
+ The form's first, enabled HTML submit button that follows a
+ YUI button
+ */
+
+ oFollowingSubmitButton;
+
+
+ function isSubmitButton(p_oElement) {
+
+ var sId,
+ oSrcElement;
+
+ switch (p_oElement.nodeName.toUpperCase()) {
+
+ case "INPUT":
+ case "BUTTON":
+
+ if (p_oElement.type == "submit" && !p_oElement.disabled) {
+
+ if (!bFormContainsYUIButtons &&
+ !oPrecedingSubmitButton) {
+
+ oPrecedingSubmitButton = p_oElement;
+
+ }
+
+ if (oYUISubmitButton && !oFollowingSubmitButton) {
+
+ oFollowingSubmitButton = p_oElement;
+
+ }
+
+ }
+
+ break;
+
+
+ default:
+
+ sId = p_oElement.id;
+
+ if (sId) {
+
+ oButton = m_oButtons[sId];
+
+ if (oButton) {
+
+ bFormContainsYUIButtons = true;
+
+ if (!oButton.get("disabled")) {
+
+ oSrcElement = oButton.get("srcelement");
+
+ if (!oYUISubmitButton &&
+ (oButton.get("type") == "submit" ||
+ (oSrcElement && oSrcElement.type == "submit")))
+ {
+
+ oYUISubmitButton = oButton;
+
+ }
+
+ }
+
+ }
+
+ }
+
+ break;
+
+ }
+
+ }
+
+
+ if (nCharCode == 13 && ((sNodeName == "INPUT" && (sType == "text" ||
+ sType == "password" || sType == "checkbox" || sType == "radio" ||
+ sType == "file")) || sNodeName == "SELECT"))
+ {
+
+ Dom.getElementsBy(isSubmitButton, "*", this);
+
+
+ if (oPrecedingSubmitButton) {
+
+ /*
+ Need to set focus to the first enabled submit button
+ to make sure that IE includes its name and value
+ in the form's data set.
+ */
+
+ oPrecedingSubmitButton.focus();
+
+ }
+ else if (!oPrecedingSubmitButton && oYUISubmitButton) {
+
+ if (oFollowingSubmitButton) {
+
+ /*
+ Need to call "preventDefault" to ensure that
+ the name and value of the regular submit button
+ following the YUI button doesn't get added to the
+ form's data set when it is submitted.
+ */
+
+ Event.preventDefault(p_oEvent);
+
+ }
+
+ oYUISubmitButton.submitForm();
+
+ }
+
+ }
+
+ };
+
+
+ /**
+ * @method YAHOO.widget.Button.addHiddenFieldsToForm
+ * @description Searches the specified form and adds hidden fields for
+ * instances of YAHOO.widget.Button that are of type "radio," "checkbox,"
+ * "menu," and "split."
+ * @param {HTMLFormElement} p_oForm Object reference
+ * for the form to search.
+ */
+ YAHOO.widget.Button.addHiddenFieldsToForm = function (p_oForm) {
+
+ var aButtons = Dom.getElementsByClassName(
+ YAHOO.widget.Button.prototype.CSS_CLASS_NAME,
+ "*",
+ p_oForm),
+
+ nButtons = aButtons.length,
+ oButton,
+ sId,
+ i;
+
+ if (nButtons > 0) {
+
+
+ for (i = 0; i < nButtons; i++) {
+
+ sId = aButtons[i].id;
+
+ if (sId) {
+
+ oButton = m_oButtons[sId];
+
+ if (oButton) {
+
+ oButton.createHiddenFields();
+
+ }
+
+ }
+
+ }
+
+ }
+
+ };
+
+
+ /**
+ * @method YAHOO.widget.Button.getButton
+ * @description Returns a button with the specified id.
+ * @param {String} p_sId String specifying the id of the root node of the
+ * HTML element representing the button to be retrieved.
+ * @return {YAHOO.widget.Button}
+ */
+ YAHOO.widget.Button.getButton = function (p_sId) {
+
+ var oButton = m_oButtons[p_sId];
+
+ if (oButton) {
+
+ return oButton;
+
+ }
+
+ };
+
+
+ // Events
+
+
+ /**
+ * @event focus
+ * @description Fires when the menu item receives focus. Passes back a
+ * single object representing the original DOM event object passed back by
+ * the event utility (YAHOO.util.Event) when the event was fired. See
+ * Element.addListener
+ * for more information on listening for this event.
+ * @type YAHOO.util.CustomEvent
+ */
+
+
+ /**
+ * @event blur
+ * @description Fires when the menu item loses the input focus. Passes back
+ * a single object representing the original DOM event object passed back by
+ * the event utility (YAHOO.util.Event) when the event was fired. See
+ * Element.addListener for
+ * more information on listening for this event.
+ * @type YAHOO.util.CustomEvent
+ */
+
+
+ /**
+ * @event option
+ * @description Fires when the user invokes the button's option. Passes
+ * back a single object representing the original DOM event (either
+ * "mousedown" or "keydown") that caused the "option" event to fire. See
+ * Element.addListener
+ * for more information on listening for this event.
+ * @type YAHOO.util.CustomEvent
+ */
+
+})();
+(function () {
+
+ // Shorthard for utilities
+
+ var Dom = YAHOO.util.Dom,
+ Event = YAHOO.util.Event,
+ Lang = YAHOO.lang,
+ Button = YAHOO.widget.Button,
+
+ // Private collection of radio buttons
+
+ m_oButtons = {};
+
+
+
+ /**
+ * The ButtonGroup class creates a set of buttons that are mutually
+ * exclusive; checking one button in the set will uncheck all others in the
+ * button group.
+ * @param {String} p_oElement String specifying the id attribute of the
+ * <div>
element of the button group.
+ * @param {HTMLDivElement} p_oElement Object
+ * specifying the <div>
element of the button group.
+ * @param {Object} p_oElement Object literal specifying a set of
+ * configuration attributes used to create the button group.
+ * @param {Object} p_oAttributes Optional. Object literal specifying a set
+ * of configuration attributes used to create the button group.
+ * @namespace YAHOO.widget
+ * @class ButtonGroup
+ * @constructor
+ * @extends YAHOO.util.Element
+ */
+ YAHOO.widget.ButtonGroup = function (p_oElement, p_oAttributes) {
+
+ var fnSuperClass = YAHOO.widget.ButtonGroup.superclass.constructor,
+ sNodeName,
+ oElement,
+ sId;
+
+ if (arguments.length == 1 && !Lang.isString(p_oElement) &&
+ !p_oElement.nodeName) {
+
+ if (!p_oElement.id) {
+
+ sId = Dom.generateId();
+
+ p_oElement.id = sId;
+
+
+ }
+
+
+
+ fnSuperClass.call(this, (this._createGroupElement()), p_oElement);
+
+ }
+ else if (Lang.isString(p_oElement)) {
+
+ oElement = Dom.get(p_oElement);
+
+ if (oElement) {
+
+ if (oElement.nodeName.toUpperCase() == this.NODE_NAME) {
+
+
+ fnSuperClass.call(this, oElement, p_oAttributes);
+
+ }
+
+ }
+
+ }
+ else {
+
+ sNodeName = p_oElement.nodeName.toUpperCase();
+
+ if (sNodeName && sNodeName == this.NODE_NAME) {
+
+ if (!p_oElement.id) {
+
+ p_oElement.id = Dom.generateId();
+
+
+ }
+
+
+ fnSuperClass.call(this, p_oElement, p_oAttributes);
+
+ }
+
+ }
+
+ };
+
+
+ YAHOO.extend(YAHOO.widget.ButtonGroup, YAHOO.util.Element, {
+
+
+ // Protected properties
+
+
+ /**
+ * @property _buttons
+ * @description Array of buttons in the button group.
+ * @default null
+ * @protected
+ * @type Array
+ */
+ _buttons: null,
+
+
+
+ // Constants
+
+
+ /**
+ * @property NODE_NAME
+ * @description The name of the tag to be used for the button
+ * group's element.
+ * @default "DIV"
+ * @final
+ * @type String
+ */
+ NODE_NAME: "DIV",
+
+
+ /**
+ * @property CSS_CLASS_NAME
+ * @description String representing the CSS class(es) to be applied
+ * to the button group's element.
+ * @default "yui-buttongroup"
+ * @final
+ * @type String
+ */
+ CSS_CLASS_NAME: "yui-buttongroup",
+
+
+
+ // Protected methods
+
+
+ /**
+ * @method _createGroupElement
+ * @description Creates the button group's element.
+ * @protected
+ * @return {HTMLDivElement}
+ */
+ _createGroupElement: function () {
+
+ var oElement = document.createElement(this.NODE_NAME);
+
+ return oElement;
+
+ },
+
+
+
+ // Protected attribute setter methods
+
+
+ /**
+ * @method _setDisabled
+ * @description Sets the value of the button groups's
+ * "disabled" attribute.
+ * @protected
+ * @param {Boolean} p_bDisabled Boolean indicating the value for
+ * the button group's "disabled" attribute.
+ */
+ _setDisabled: function (p_bDisabled) {
+
+ var nButtons = this.getCount(),
+ i;
+
+ if (nButtons > 0) {
+
+ i = nButtons - 1;
+
+ do {
+
+ this._buttons[i].set("disabled", p_bDisabled);
+
+ }
+ while (i--);
+
+ }
+
+ },
+
+
+
+ // Protected event handlers
+
+
+ /**
+ * @method _onKeyDown
+ * @description "keydown" event handler for the button group.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onKeyDown: function (p_oEvent) {
+
+ var oTarget = Event.getTarget(p_oEvent),
+ nCharCode = Event.getCharCode(p_oEvent),
+ sId = oTarget.parentNode.parentNode.id,
+ oButton = m_oButtons[sId],
+ nIndex = -1;
+
+
+ if (nCharCode == 37 || nCharCode == 38) {
+
+ nIndex = (oButton.index === 0) ?
+ (this._buttons.length - 1) : (oButton.index - 1);
+
+ }
+ else if (nCharCode == 39 || nCharCode == 40) {
+
+ nIndex = (oButton.index === (this._buttons.length - 1)) ?
+ 0 : (oButton.index + 1);
+
+ }
+
+
+ if (nIndex > -1) {
+
+ this.check(nIndex);
+ this.getButton(nIndex).focus();
+
+ }
+
+ },
+
+
+ /**
+ * @method _onAppendTo
+ * @description "appendTo" event handler for the button group.
+ * @protected
+ * @param {Event} p_oEvent Object representing the event that was fired.
+ */
+ _onAppendTo: function (p_oEvent) {
+
+ var aButtons = this._buttons,
+ nButtons = aButtons.length,
+ i;
+
+ for (i = 0; i < nButtons; i++) {
+
+ aButtons[i].appendTo(this.get("element"));
+
+ }
+
+ },
+
+
+ /**
+ * @method _onButtonCheckedChange
+ * @description "checkedChange" event handler for each button in the
+ * button group.
+ * @protected
+ * @param {Event} p_oEvent Object representing the event that was fired.
+ * @param {YAHOO.widget.Button}
+ * p_oButton Object representing the button that fired the event.
+ */
+ _onButtonCheckedChange: function (p_oEvent, p_oButton) {
+
+ var bChecked = p_oEvent.newValue,
+ oCheckedButton = this.get("checkedButton");
+
+ if (bChecked && oCheckedButton != p_oButton) {
+
+ if (oCheckedButton) {
+
+ oCheckedButton.set("checked", false, true);
+
+ }
+
+ this.set("checkedButton", p_oButton);
+ this.set("value", p_oButton.get("value"));
+
+ }
+ else if (oCheckedButton && !oCheckedButton.set("checked")) {
+
+ oCheckedButton.set("checked", true, true);
+
+ }
+
+ },
+
+
+
+ // Public methods
+
+
+ /**
+ * @method init
+ * @description The ButtonGroup class's initialization method.
+ * @param {String} p_oElement String specifying the id attribute of the
+ * <div>
element of the button group.
+ * @param {HTMLDivElement} p_oElement Object
+ * specifying the <div>
element of the button group.
+ * @param {Object} p_oElement Object literal specifying a set of
+ * configuration attributes used to create the button group.
+ * @param {Object} p_oAttributes Optional. Object literal specifying a
+ * set of configuration attributes used to create the button group.
+ */
+ init: function (p_oElement, p_oAttributes) {
+
+ this._buttons = [];
+
+ YAHOO.widget.ButtonGroup.superclass.init.call(this, p_oElement,
+ p_oAttributes);
+
+ this.addClass(this.CSS_CLASS_NAME);
+
+
+ var aButtons = this.getElementsByClassName("yui-radio-button");
+
+
+ if (aButtons.length > 0) {
+
+
+ this.addButtons(aButtons);
+
+ }
+
+
+
+ function isRadioButton(p_oElement) {
+
+ return (p_oElement.type == "radio");
+
+ }
+
+ aButtons =
+ Dom.getElementsBy(isRadioButton, "input", this.get("element"));
+
+
+ if (aButtons.length > 0) {
+
+
+ this.addButtons(aButtons);
+
+ }
+
+ this.on("keydown", this._onKeyDown);
+ this.on("appendTo", this._onAppendTo);
+
+
+ var oContainer = this.get("container");
+
+ if (oContainer) {
+
+ if (Lang.isString(oContainer)) {
+
+ Event.onContentReady(oContainer, function () {
+
+ this.appendTo(oContainer);
+
+ }, null, this);
+
+ }
+ else {
+
+ this.appendTo(oContainer);
+
+ }
+
+ }
+
+
+
+ },
+
+
+ /**
+ * @method initAttributes
+ * @description Initializes all of the configuration attributes used to
+ * create the button group.
+ * @param {Object} p_oAttributes Object literal specifying a set of
+ * configuration attributes used to create the button group.
+ */
+ initAttributes: function (p_oAttributes) {
+
+ var oAttributes = p_oAttributes || {};
+
+ YAHOO.widget.ButtonGroup.superclass.initAttributes.call(
+ this, oAttributes);
+
+
+ /**
+ * @attribute name
+ * @description String specifying the name for the button group.
+ * This name will be applied to each button in the button group.
+ * @default null
+ * @type String
+ */
+ this.setAttributeConfig("name", {
+
+ value: oAttributes.name,
+ validator: Lang.isString
+
+ });
+
+
+ /**
+ * @attribute disabled
+ * @description Boolean indicating if the button group should be
+ * disabled. Disabling the button group will disable each button
+ * in the button group. Disabled buttons are dimmed and will not
+ * respond to user input or fire events.
+ * @default false
+ * @type Boolean
+ */
+ this.setAttributeConfig("disabled", {
+
+ value: (oAttributes.disabled || false),
+ validator: Lang.isBoolean,
+ method: this._setDisabled
+
+ });
+
+
+ /**
+ * @attribute value
+ * @description Object specifying the value for the button group.
+ * @default null
+ * @type Object
+ */
+ this.setAttributeConfig("value", {
+
+ value: oAttributes.value
+
+ });
+
+
+ /**
+ * @attribute container
+ * @description HTML element reference or string specifying the id
+ * attribute of the HTML element that the button group's markup
+ * should be rendered into.
+ * @type HTMLElement|String
+ * @default null
+ */
+ this.setAttributeConfig("container", {
+
+ value: oAttributes.container,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @attribute checkedButton
+ * @description Reference for the button in the button group that
+ * is checked.
+ * @type {YAHOO.widget.Button}
+ * @default null
+ */
+ this.setAttributeConfig("checkedButton", {
+
+ value: null
+
+ });
+
+ },
+
+
+ /**
+ * @method addButton
+ * @description Adds the button to the button group.
+ * @param {YAHOO.widget.Button}
+ * p_oButton Object reference for the
+ * YAHOO.widget.Button instance to be added to the button group.
+ * @param {String} p_oButton String specifying the id attribute of the
+ * <input>
or <span>
element
+ * to be used to create the button to be added to the button group.
+ * @param {HTMLInputElement|HTMLElement} p_oButton Object reference for the
+ * <input>
or <span>
element
+ * to be used to create the button to be added to the button group.
+ * @param {Object} p_oButton Object literal specifying a set of
+ * YAHOO.widget.Button
+ * configuration attributes used to configure the button to be added to
+ * the button group.
+ * @return {YAHOO.widget.Button}
+ */
+ addButton: function (p_oButton) {
+
+ var oButton,
+ oButtonElement,
+ oGroupElement,
+ nIndex,
+ sButtonName,
+ sGroupName;
+
+
+ if (p_oButton instanceof Button &&
+ p_oButton.get("type") == "radio") {
+
+ oButton = p_oButton;
+
+ }
+ else if (!Lang.isString(p_oButton) && !p_oButton.nodeName) {
+
+ p_oButton.type = "radio";
+
+ oButton = new Button(p_oButton);
+
+ }
+ else {
+
+ oButton = new Button(p_oButton, { type: "radio" });
+
+ }
+
+
+ if (oButton) {
+
+ nIndex = this._buttons.length;
+ sButtonName = oButton.get("name");
+ sGroupName = this.get("name");
+
+ oButton.index = nIndex;
+
+ this._buttons[nIndex] = oButton;
+ m_oButtons[oButton.get("id")] = oButton;
+
+
+ if (sButtonName != sGroupName) {
+
+ oButton.set("name", sGroupName);
+
+ }
+
+
+ if (this.get("disabled")) {
+
+ oButton.set("disabled", true);
+
+ }
+
+
+ if (oButton.get("checked")) {
+
+ this.set("checkedButton", oButton);
+
+ }
+
+
+ oButtonElement = oButton.get("element");
+ oGroupElement = this.get("element");
+
+ if (oButtonElement.parentNode != oGroupElement) {
+
+ oGroupElement.appendChild(oButtonElement);
+
+ }
+
+
+ oButton.on("checkedChange",
+ this._onButtonCheckedChange, oButton, this);
+
+
+ return oButton;
+
+ }
+
+ },
+
+
+ /**
+ * @method addButtons
+ * @description Adds the array of buttons to the button group.
+ * @param {Array} p_aButtons Array of
+ * YAHOO.widget.Button instances to be added
+ * to the button group.
+ * @param {Array} p_aButtons Array of strings specifying the id
+ * attribute of the <input>
or <span>
+ *
elements to be used to create the buttons to be added to the
+ * button group.
+ * @param {Array} p_aButtons Array of object references for the
+ * <input>
or <span>
elements
+ * to be used to create the buttons to be added to the button group.
+ * @param {Array} p_aButtons Array of object literals, each containing
+ * a set of YAHOO.widget.Button
+ * configuration attributes used to configure each button to be added
+ * to the button group.
+ * @return {Array}
+ */
+ addButtons: function (p_aButtons) {
+
+ var nButtons,
+ oButton,
+ aButtons,
+ i;
+
+ if (Lang.isArray(p_aButtons)) {
+
+ nButtons = p_aButtons.length;
+ aButtons = [];
+
+ if (nButtons > 0) {
+
+ for (i = 0; i < nButtons; i++) {
+
+ oButton = this.addButton(p_aButtons[i]);
+
+ if (oButton) {
+
+ aButtons[aButtons.length] = oButton;
+
+ }
+
+ }
+
+ if (aButtons.length > 0) {
+
+
+ return aButtons;
+
+ }
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method removeButton
+ * @description Removes the button at the specified index from the
+ * button group.
+ * @param {Number} p_nIndex Number specifying the index of the button
+ * to be removed from the button group.
+ */
+ removeButton: function (p_nIndex) {
+
+ var oButton = this.getButton(p_nIndex),
+ nButtons,
+ i;
+
+ if (oButton) {
+
+
+ this._buttons.splice(p_nIndex, 1);
+ delete m_oButtons[oButton.get("id")];
+
+ oButton.removeListener("checkedChange",
+ this._onButtonCheckedChange);
+
+ oButton.destroy();
+
+
+ nButtons = this._buttons.length;
+
+ if (nButtons > 0) {
+
+ i = this._buttons.length - 1;
+
+ do {
+
+ this._buttons[i].index = i;
+
+ }
+ while (i--);
+
+ }
+
+
+ }
+
+ },
+
+
+ /**
+ * @method getButton
+ * @description Returns the button at the specified index.
+ * @param {Number} p_nIndex The index of the button to retrieve from the
+ * button group.
+ * @return {YAHOO.widget.Button}
+ */
+ getButton: function (p_nIndex) {
+
+ if (Lang.isNumber(p_nIndex)) {
+
+ return this._buttons[p_nIndex];
+
+ }
+
+ },
+
+
+ /**
+ * @method getButtons
+ * @description Returns an array of the buttons in the button group.
+ * @return {Array}
+ */
+ getButtons: function () {
+
+ return this._buttons;
+
+ },
+
+
+ /**
+ * @method getCount
+ * @description Returns the number of buttons in the button group.
+ * @return {Number}
+ */
+ getCount: function () {
+
+ return this._buttons.length;
+
+ },
+
+
+ /**
+ * @method focus
+ * @description Sets focus to the button at the specified index.
+ * @param {Number} p_nIndex Number indicating the index of the button
+ * to focus.
+ */
+ focus: function (p_nIndex) {
+
+ var oButton,
+ nButtons,
+ i;
+
+ if (Lang.isNumber(p_nIndex)) {
+
+ oButton = this._buttons[p_nIndex];
+
+ if (oButton) {
+
+ oButton.focus();
+
+ }
+
+ }
+ else {
+
+ nButtons = this.getCount();
+
+ for (i = 0; i < nButtons; i++) {
+
+ oButton = this._buttons[i];
+
+ if (!oButton.get("disabled")) {
+
+ oButton.focus();
+ break;
+
+ }
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method check
+ * @description Checks the button at the specified index.
+ * @param {Number} p_nIndex Number indicating the index of the button
+ * to check.
+ */
+ check: function (p_nIndex) {
+
+ var oButton = this.getButton(p_nIndex);
+
+ if (oButton) {
+
+ oButton.set("checked", true);
+
+ }
+
+ },
+
+
+ /**
+ * @method destroy
+ * @description Removes the button group's element from its parent
+ * element and removes all event handlers.
+ */
+ destroy: function () {
+
+
+ var nButtons = this._buttons.length,
+ oElement = this.get("element"),
+ oParentNode = oElement.parentNode,
+ i;
+
+ if (nButtons > 0) {
+
+ i = this._buttons.length - 1;
+
+ do {
+
+ this._buttons[i].destroy();
+
+ }
+ while (i--);
+
+ }
+
+
+ Event.purgeElement(oElement);
+
+
+ oParentNode.removeChild(oElement);
+
+ },
+
+
+ /**
+ * @method toString
+ * @description Returns a string representing the button group.
+ * @return {String}
+ */
+ toString: function () {
+
+ return ("ButtonGroup " + this.get("id"));
+
+ }
+
+ });
+
+})();
+YAHOO.register("button", YAHOO.widget.Button, {version: "2.5.0", build: "895"});
diff --git a/lib/yui/calendar/README b/lib/yui/calendar/README
index 3c04748c14..9de846581b 100755
--- a/lib/yui/calendar/README
+++ b/lib/yui/calendar/README
@@ -1,110 +1,357 @@
Calendar Release Notes
-*** version 2.3.0 ***
-
- - Added checks to select, selectCell, deselect and deselectCell methods to ensure the Calendar/Calendar group was not set to an invalid state by programmatically selecting unselectable dates or cells.
- - Added new locale configuration properties for the Month/Year label used in the Calendar header (MY_LABEL_MONTH_POSITION, MY_LABEL_YEAR_POSITION, MY_LABEL_YEAR_SUFFIX, MY_LABEL_MONTH_SUFFIX). Japan is an example locale, where customization of the Month/Year label is required.
- - Changed "first", "last" class names to "first-of-type", "last-of-type", to avoid collision with YUI Grids' use of the "first" class name.
- - Added public isDateOOB method, to check if a given date is outside of the minimum/maximum configuration dates of the Calendar.
- - Deprecated YAHOO.widget.Calendar.browser, refactored to use YAHOO.env.ua instead.
- - Removed overflow:hidden from default Calendar/CalendarGroup container for non-IE6 browsers to fix clipping issue with IE7 when CalendarGroup was inside a box with a specific width. overflow:hidden is still required for IE6 with an iframe shim.
- - Added Opera container width calculation fix to CalendarGroup.show method, to fix incorrect wrapping when using a CalendarGroup which is initially rendered hidden (display:none). Previously this fix was only applied on render.
-
-*** version 2.2.2 ***
-
- - Fixed problem with selected dates being shared across instances, when more than one Calendar/CalendarGroup was on the page
-
-*** version 2.2.1 ***
-
- - Fixed problem with selectCell adding duplicate selected date entries for dates which were already selected
- - Fixed problem with CalendarGroup iframe shim not covering the CalendarGroup title area
- - Removed javascript:void(null) from close button and cell links which was interrupting form submission and firing onbeforeunload in IE
- - Fixed problem with CalendarGroup getSelectedDates returning invalid results, when used in conjunction with the "selected" Config property (either passed in the constructor config argument or set seperately after construction)
- - Refactored Calendar and CalendarGroup to improve performance, especially when working with a large number of instances in IE6
-
-*** version 2.2.0 ***
-
- - Image customization can now be done through CSS. Images for Close, Left and Right Arrows are now pulled in using CSS defined in calendar.css and by default use relative paths to the images in the same directory as calendar.css.
- - Deprecated Calendar.IMG_ROOT and NAV_ARROW_LEFT, NAV_ARROW_RIGHT configuration properties. Customizations based on older releases which set these properties will still function as expected.
- - Deprecated CalendarGroup.CSS_2UPCLOSE. Calendar's Style.CSS_CLOSE property now represents the new default CSS class (calclose) for the close button. CSS_2UPCLOSE is still applied along with CSS_CLOSE to the new markup for the close button to support existing customizations of the CSS_2UPCLOSE CSS class (close-icon)
- - Fixed problem with Safari setting Calendar pages to incorrect dates if the pages spanned a year boundary in CalendarGroups with 3 or more pages, due to a bug in Safari's implementation of Date setMonth
- - Fixed problem with CalendarGroup setMonth rendering Calendar pages with incorrect dates in all browsers if current pages spanned year boundary
- - Fixed incorrect CalendarGroup logging statement in calendar-debug.js
- - Fixed domEventMap support for Safari versions prior to 2.0.2, caused by hasOwnProperty not being supported
- - Removed unused private property : _pageDate from Calendar class
-
-*** version 0.12.2 ***
-
- - Corrected documentation for clearTime function to reflect the change from midnight to noon
-
-*** version 0.12.1 ***
-
- - Calendar and CalendarGroup now automatically parse the argument passed to setMonth and setYear into an integer, eliminating potential concatenation bugs.
-
-*** version 0.12 ***
-
- - New documentation format implemented
- - Calendar2up and Calendar_Core are now deprecated. Now, Calendar alone represents the single Calendar instance, and CalendarGroup represents an n-up instance, defaulting to 2up
- - Added semantic style classes to Calendar elements to allow for custom styling solely using CSS.
- - Remapped all configuration properties to use the Config object (familiar to those who use the Container collection of controls). Property names are the same as their previous counterparts, but wrapped into Calendar.cfg, allowing for runtime reconfiguration of most properties
- - Added "title" property for setting the Calendar title
- - Added "close" property for enabling and disabling the close icon
- - Added "iframe" property for enabling an iframe shim in Internet Explorer 6 and below to fix the select bleed-through bug
- - pageDate moved to property: "pagedate"
- - selectedDates moved to property: "selected"
- - minDate moved to property : "mindate", which accepts a JavaScript Date object like its predecessor, but also supports string dates
- - maxDate moved to property : "maxdate", which accepts a JavaScript Date object like its predecessor, but also supports string dates
- - Moved style declarations to initStyles function
- - Optimized event handling in doSelectCell/doCellMouseOver/doCellMouseOut by only attaching the listener to the outer Calendar container, and only reacting to events on cells with the "selectable" CSS class.
- - Added domEventMap field for applying DOM event listeners to cells containing specific class and tag combinations.
- - Moved all cell DOM event attachment to applyListeners function
- - Added getDateByCellId / getDateFieldsByCellId helper functions
- - Corrected DateMath.getWeekNumber to comply with ISO week number handling
- - Separated renderCellDefault style portions into styleCellDefault function for easy extension
- - Deprecated onBeforeSelect. Created beforeSelectEvent which automatically subscribes to its deprecated predecessor.
- - Deprecated onSelect. Created selectEvent, which automatically subscribes to its deprecated predecessor.
- - Deprecated onBeforeDeselect. Created beforeSelectEvent which automatically subscribes to its deprecated predecessor.
- - Deprecated onDeselect. Created beforeDeselectEvent, which automatically subscribes to its deprecated predecessor.
- - Deprecated onChangePage. Created changePageEvent, which automatically subscribes to its deprecated predecessor.
- - Deprecated onRender. Created renderEvent, which automatically subscribes to its deprecated predecessor.
- - Deprecated onReset. Created resetEvent, which automatically subscribes to its deprecated predecessor.
- - Deprecated onClear. Created clearEvent, which automatically subscribes to its deprecated predecessor.
- - Corrected setMonth documentation to refer to 0-11 indexed months.
- - Added show and hide methods to Calendar for setting the Calendar's display property.
- - Optimized internal render classes to use innerHTML and string buffers
- - Removed wireCustomEvents function
- - Removed wireDefaultEvents function
- - Removed doNextMonth / doPreviousMonth
- - Removed all buildShell (header, body, footer) functions, since the Calendar shell is now built dynamically on each render
- - Wired all CalendarGroup events and configuration properties to be properly delegated to Calendar
- - Augmented CalendarGroup with all built-in renderers, label functions, hide, show, and initStyles, creating API transparency between Calendar and CalendarGroup.
- - Made all tagName, createElement, and entity references XHTML compliant
- - Fixed Daylight Saving Time bug for Brazilian time zone
-
-*** version 0.11.3 ***
-
- - Calendar_Core: Added arguments for selected/deselected dates to onSelect/onDeselect
- - CalendarGroup: Fixed bug where selected dates passed to constructor were not represented in selectedDates
- - Calendar2up: Now displays correctly in Opera 9
-
-*** version 0.11.0 ***
-
- - DateMath: DateMath.add now properly adds weeks
- - DateMath: between() function added
- - DateMath: getWeekNumber() fixed to take starting day of week into account
- - All references to Calendar's built in CSS class handlers are removed, replaced with calls to Dom utility (addClass, removeClass)
- - Several CSS class constants now have clearer names
- - All CSS classes are now properly namespaced to avoid CSS conflicts
- - Fixed table:hover bug in CSS
- - Calendar no longer requires the container ID and variable name to match in order for month navigation to function properly
- - Calendar month navigation arrows are now represented as background images
-
-*** version 0.10.0 ***
-
- - Major performance improvements from attaching DOM events to associated table cells only once, when the Calendar shell is built
- - DOM events for mouseover/mouseout are now fired for all browsers (not just Internet Explorer)
- - Reset functionality bug fixed for 2-up Calendar view
-
-*** version 0.9.0 ***
-
-* Initial release
+*** version 2.5.0 ***
+
++ Prevent default event handling in CalendarNavigator enter key
+ listener, to prevent automatic form submission when using Calendar
+ inside a form.
+
++ Added workaround to DateMath.add and subtract for Safari 2 (webkit)
+ bug in Date.setDate(n) which doesn't handle value of n less than -128
+ or greater than 127 correctly.
+
+ See: http://brianary.blogspot.com/2006/03/safari-date-bug.html
+
++ Added border, padding and margin rules to Calendar Sam Skin to
+ protect Sam Skin's look and feel when Calendar is used with
+ YUI base.css
+
+*** version 2.4.0 ***
+
++ Added CalendarNavigator (year selector) feature to allow the user to
+ jump to a year/month directly without having to scroll through months
+ sequentially.
+
+ The feature is enabled/configured using the "navigator" configuration
+ property.
+
++ Added Custom Events:
+
+ showNav/beforeShowNav
+ hideNav/beforeHideNav,
+ renderNav/beforeRenderNav
+
+ To Calendar/CalendarGroup, in support of the CalendarNavigator
+ functionality.
+
++ Added Custom Events:
+
+ show/beforeShow
+ hide/beforeHide
+
+ To Calendar and CalendarGroup. Returning false from a
+ beforeShow/beforeHide listener can be used to prevent the Calendar
+ from being shown/hidden respectively.
+
++ Added Public Methods:
+
+ getCellIndex(date) [ Calendar ]
+ getCalendarPage(date) [ CalendarGroup ]
+ toDate(dateArray) [ Calendar/CalendarGroup ]
+ removeRenderers() [ Calendar/CalendarGroup ]
+
++ The Calendar/CalendarGroup constructor is now more flexible:
+
+ * It no longer requires an "id" argument.
+
+ In it's simplest form, a Calendar/CalendarGroup can be
+ constructed by simply providing a container id or reference.
+
+ var cal = new YAHOO.widget.Calendar("container");
+ -or-
+ var containerDiv = YAHOO.util.Dom.get("container");
+ var cal = new YAHOO.widget.Calendar(containerDiv);
+
+ An id for the Calendar does not need to be provided, and will be
+ generated from the container id by appending an "_t" suffix to the
+ container id if only the container is provided.
+
+ * The container argument can be either a string, representing the
+ id of the container, or an HTMLElement referring to the container
+ element itself, as suggested in the example above.
+
+ * If an HTMLElement is provided for the container argument and the
+ element does not have an id, one will be generated for it using
+ YAHOO.util.Dom.generateId().
+
+ * The older form of Calendar/CalendarGroup signature, expecting
+ both an id and containerId is still supported and works as it did
+ prior to 2.4.0.
+
++ Fixed performance issue, where the same custom renderer was being
+ applied multiple times to the same cell.
+
++ Added getDate(year, month, date) factory method to the DateMath utility,
+ which can be used to create JavaScript Date instances for years less
+ than 100.
+
+ The default Date(year, month, date) constructor implementations across
+ browsers, assume that if year < 100, the caller is referring to the
+ nineteen hundreds, and the year is set to 19xx instead of xx (as with
+ the deprecated setYear method). However Date.setFullYear(xx) can
+ be used to set dates below 100. The above factory method provides a
+ construction mechanism consistent with setFullYear.
+
++ Changed Calendar/CalendarGroup/DateMath code to use the DateMath.getDate
+ method, so that 2 digit years are not assumed to be in the 1900's.
+
+ NOTE: Calendar's API already expects 4 digit date strings when referring
+ to years after 999.
+
+*** version 2.3.1 ***
+
++ Changed Calendar/CalendarGroup to render an empty title bar element
+ when "close" is set to true, but "title" has not been set, to allow Sam
+ Skin to render a title bar correctly.
+
+*** version 2.3.0 ***
+
++ Added checks to select, selectCell, deselect and deselectCell methods
+ to ensure the Calendar/Calendar group was not set to an invalid state
+ by programmatically selecting unselectable dates or cells.
+
++ Added new locale configuration properties for the Month/Year label
+ used in the Calendar header (MY_LABEL_MONTH_POSITION,
+ MY_LABEL_YEAR_POSITION, MY_LABEL_YEAR_SUFFIX, MY_LABEL_MONTH_SUFFIX).
+ Japan is an example locale, where customization of the Month/Year
+ label is required.
+
++ Changed "first", "last" class names to "first-of-type", "last-of-type",
+ to avoid collision with YUI Grids' use of the "first" class name.
+
++ Added public isDateOOB method, to check if a given date is outside of
+ the minimum/maximum configuration dates of the Calendar.
+
++ Deprecated YAHOO.widget.Calendar.browser, refactored to use
+ YAHOO.env.ua instead.
+
++ Removed overflow:hidden from default Calendar/CalendarGroup container
+ for non-IE6 browsers to fix clipping issue with IE7 when CalendarGroup
+ was inside a box with a specific width. overflow:hidden is still
+ required for IE6 with an iframe shim.
+
++ Added Opera container width calculation fix to CalendarGroup.show
+ method, to fix incorrect wrapping when using a CalendarGroup which is
+ initially rendered hidden (display:none). Previously this fix was
+ only applied on render.
+
+*** version 2.2.2 ***
+
++ Fixed problem with selected dates being shared across instances, when
+ more than one Calendar/CalendarGroup was on the page
+
+*** version 2.2.1 ***
+
++ Fixed problem with selectCell adding duplicate selected date entries
+ for dates which were already selected
+
++ Fixed problem with CalendarGroup iframe shim not covering the
+ CalendarGroup title area
+
++ Removed javascript:void(null) from close button and cell links which
+ was interrupting form submission and firing onbeforeunload in IE
+
++ Fixed problem with CalendarGroup getSelectedDates returning invalid
+ results, when used in conjunction with the "selected" Config property
+ (either passed in the constructor config argument or set seperately
+ after construction)
+
++ Refactored Calendar and CalendarGroup to improve performance,
+ especially when working with a large number of instances in
+ IE6
+
+*** version 2.2.0 ***
+
++ Image customization can now be done through CSS. Images for Close,
+ Left and Right Arrows are now pulled in using CSS defined in
+ calendar.css and by default use relative paths to the images in
+ the same directory as calendar.css.
+
++ Deprecated Calendar.IMG_ROOT and NAV_ARROW_LEFT, NAV_ARROW_RIGHT
+ configuration properties. Customizations based on older releases
+ which set these properties will still function as expected.
+
++ Deprecated CalendarGroup.CSS_2UPCLOSE. Calendar's Style.CSS_CLOSE
+ property now represents the new default CSS class (calclose) for
+ the close button. CSS_2UPCLOSE is still applied along with
+ CSS_CLOSE to the new markup for the close button to support existing
+ customizations of the CSS_2UPCLOSE CSS class (close-icon)
+
++ Fixed problem with Safari setting Calendar pages to incorrect dates
+ if the pages spanned a year boundary in CalendarGroups with 3 or more
+ pages, due to a bug in Safari's implementation of Date setMonth
+
++ Fixed problem with CalendarGroup setMonth rendering Calendar pages
+ with incorrect dates in all browsers if current pages spanned year
+ boundary
+
++ Fixed incorrect CalendarGroup logging statement in calendar-debug.js
+
++ Fixed domEventMap support for Safari versions prior to 2.0.2,
+ caused by hasOwnProperty not being supported
+
++ Removed unused private property : _pageDate from Calendar class
+
+*** version 0.12.2 ***
+
++ Corrected documentation for clearTime function to reflect the
+ change from midnight to noon
+
+*** version 0.12.1 ***
+
++ Calendar and CalendarGroup now automatically parse the argument
+ passed to setMonth and setYear into an integer, eliminating
+ potential concatenation bugs.
+
+*** version 0.12 ***
+
++ New documentation format implemented
+
++ Calendar2up and Calendar_Core are now deprecated. Now, Calendar alone
+ represents the single Calendar instance, and CalendarGroup represents
+ an n-up instance, defaulting to 2up
+
++ Added semantic style classes to Calendar elements to allow for
+ custom styling solely using CSS.
+
++ Remapped all configuration properties to use the Config object
+ (familiar to those who use the Container collection of controls).
+ Property names are the same as their previous counterparts, but
+ wrapped into Calendar.cfg, allowing for runtime reconfiguration of
+ most properties
+
++ Added "title" property for setting the Calendar title
+
++ Added "close" property for enabling and disabling the close icon
+
++ Added "iframe" property for enabling an iframe shim in Internet
+ Explorer 6 and below to fix the select bleed-through bug
+
++ pageDate moved to property: "pagedate"
+
++ selectedDates moved to property: "selected"
+
++ minDate moved to property : "mindate", which accepts a JavaScript
+ Date object like its predecessor, but also supports string dates
+
++ maxDate moved to property : "maxdate", which accepts a JavaScript
+ Date object like its predecessor, but also supports string dates
+
++ Moved style declarations to initStyles function
+
++ Optimized event handling in doSelectCell/doCellMouseOver/
+ doCellMouseOut by only attaching the listener to the outer
+ Calendar container, and only reacting to events on cells with
+ the "selectable" CSS class.
+
++ Added domEventMap field for applying DOM event listeners to cells
+ containing specific class and tag combinations.
+
++ Moved all cell DOM event attachment to applyListeners function
+
++ Added getDateByCellId / getDateFieldsByCellId helper functions
+
++ Corrected DateMath.getWeekNumber to comply with ISO week number
+ handling
+
++ Separated renderCellDefault style portions into styleCellDefault
+ function for easy extension
+
++ Deprecated onBeforeSelect. Created beforeSelectEvent which
+ automatically subscribes to its deprecated predecessor.
+
++ Deprecated onSelect. Created selectEvent, which automatically
+ subscribes to its deprecated predecessor.
+
++ Deprecated onBeforeDeselect. Created beforeSelectEvent which
+ automatically subscribes to its deprecated predecessor.
+
++ Deprecated onDeselect. Created beforeDeselectEvent, which
+ automatically subscribes to its deprecated predecessor.
+
++ Deprecated onChangePage. Created changePageEvent, which automatically
+ subscribes to its deprecated predecessor.
+
++ Deprecated onRender. Created renderEvent, which automatically
+ subscribes to its deprecated predecessor.
+
++ Deprecated onReset. Created resetEvent, which automatically
+ subscribes to its deprecated predecessor.
+
++ Deprecated onClear. Created clearEvent, which automatically
+ subscribes to its deprecated predecessor.
+
++ Corrected setMonth documentation to refer to 0-11 indexed months.
+
++ Added show and hide methods to Calendar for setting the Calendar's
+ display property.
+
++ Optimized internal render classes to use innerHTML and string buffers
+
++ Removed wireCustomEvents function
+
++ Removed wireDefaultEvents function
+
++ Removed doNextMonth / doPreviousMonth
+
++ Removed all buildShell (header, body, footer) functions, since
+ the Calendar shell is now built dynamically on each render
+
++ Wired all CalendarGroup events and configuration properties to
+ be properly delegated to Calendar
+
++ Augmented CalendarGroup with all built-in renderers, label functions,
+ hide, show, and initStyles, creating API transparency between Calendar
+ and CalendarGroup.
+
++ Made all tagName, createElement, and entity references XHTML compliant
+
++ Fixed Daylight Saving Time bug for Brazilian time zone
+
+*** version 0.11.3 ***
+
++ Calendar_Core: Added arguments for selected/deselected dates to
+ onSelect/onDeselect
+
++ CalendarGroup: Fixed bug where selected dates passed to constructor
+ were not represented in selectedDates
+
++ Calendar2up: Now displays correctly in Opera 9
+
+*** version 0.11.0 ***
+
++ DateMath: DateMath.add now properly adds weeks
+
++ DateMath: between() function added
+
++ DateMath: getWeekNumber() fixed to take starting day of week into
+ account
+
++ All references to Calendar's built in CSS class handlers are
+ removed, replaced with calls to Dom utility (addClass, removeClass)
+
++ Several CSS class constants now have clearer names
+
++ All CSS classes are now properly namespaced to avoid CSS conflicts
+
++ Fixed table:hover bug in CSS
+
++ Calendar no longer requires the container ID and variable name to
+ match in order for month navigation to function properly
+
++ Calendar month navigation arrows are now represented as
+ background images
+
+*** version 0.10.0 ***
+
++ Major performance improvements from attaching DOM events to
+ associated table cells only once, when the Calendar shell is built
+
++ DOM events for mouseover/mouseout are now fired for all browsers
+ (not just Internet Explorer)
+
++ Reset functionality bug fixed for 2-up Calendar view
+
+*** version 0.9.0 ***
+
+* Initial release
\ No newline at end of file
diff --git a/lib/yui/calendar/assets/calendar-core.css b/lib/yui/calendar/assets/calendar-core.css
index d25fd0427f..294405181c 100755
--- a/lib/yui/calendar/assets/calendar-core.css
+++ b/lib/yui/calendar/assets/calendar-core.css
@@ -1,8 +1,8 @@
/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Copyright (c) 2008, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
+version: 2.5.0
*/
/**
* CORE
@@ -83,6 +83,44 @@ version: 2.3.0
text-align:center;
}
+/* CalendarNavigator */
+.yui-calcontainer .yui-cal-nav-mask {
+ position:absolute;
+ z-index:2;
+ margin:0;
+ padding:0;
+ width:100%;
+ height:100%;
+ _width:0; /* IE6, IE7 quirks - width/height set programmatically to match container */
+ _height:0;
+ left:0;
+ top:0;
+ display:none;
+}
+
+/* NAVIGATOR BOUNDING BOX */
+.yui-calcontainer .yui-cal-nav {
+ position:absolute;
+ z-index:3;
+ top:0;
+ display:none;
+}
+
+/* NAVIGATOR BUTTONS (based on button-core.css) */
+.yui-calcontainer .yui-cal-nav .yui-cal-nav-btn {
+ display: -moz-inline-box; /* Gecko */
+ display: inline-block; /* IE, Opera and Safari */
+}
+
+.yui-calcontainer .yui-cal-nav .yui-cal-nav-btn button {
+ display: block;
+ *display: inline-block; /* IE */
+ *overflow: visible; /* Remove superfluous padding for IE */
+ border: none;
+ background-color: transparent;
+ cursor: pointer;
+}
+
/* Specific changes for calendar running under fonts/reset */
.yui-calendar .calbody a:hover {background:inherit;}
p#clear {clear:left; padding-top:10px;}
\ No newline at end of file
diff --git a/lib/yui/calendar/assets/calendar.css b/lib/yui/calendar/assets/calendar.css
index 377b93191d..26975d21dd 100755
--- a/lib/yui/calendar/assets/calendar.css
+++ b/lib/yui/calendar/assets/calendar.css
@@ -1,8 +1,8 @@
/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Copyright (c) 2008, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
+version: 2.5.0
*/
.yui-calcontainer {
position:relative;
@@ -91,7 +91,7 @@ version: 2.3.0
top:2px;
bottom:0;
width:9px;
- height:12px;
+ height:12px;
left:2px;
z-index:1;
background: url("callt.gif") no-repeat;
@@ -200,6 +200,115 @@ version: 2.3.0
border-right-width:2px;
}
+/* CalendarNavigator */
+.yui-calendar a.calnav {
+ _position:relative;
+ padding-left:2px;
+ padding-right:2px;
+ text-decoration:none;
+ color:#000;
+}
+
+.yui-calendar a.calnav:hover {
+ border:1px solid #003366;
+ background-color:#6699cc;
+ background: url(calgrad.png) repeat-x;
+ color:#fff;
+ cursor:pointer;
+}
+
+.yui-calcontainer .yui-cal-nav-mask {
+ position:absolute;
+ z-index:2;
+ display:none;
+
+ margin:0;
+ padding:0;
+
+ left:0;
+ top:0;
+ width:100%;
+ height:100%;
+ _width:0; /* IE6, IE7 Quirks - width/height set programmatically to match container */
+ _height:0;
+
+ background-color:#000;
+ opacity:0.25;
+ *filter:alpha(opacity=25);
+}
+
+.yui-calcontainer .yui-cal-nav {
+ position:absolute;
+ z-index:3;
+ display:none;
+
+ padding:0;
+ top:1.5em;
+ left:50%;
+ width:12em;
+ margin-left:-6em;
+
+ border:1px solid #7B9EBD;
+ background-color:#F7F9FB;
+ font-size:93%;
+}
+
+.yui-calcontainer.withtitle .yui-cal-nav {
+ top:3.5em;
+}
+
+.yui-calcontainer .yui-cal-nav-y,
+.yui-calcontainer .yui-cal-nav-m,
+.yui-calcontainer .yui-cal-nav-b {
+ padding:2px 5px 2px 5px;
+}
+
+.yui-calcontainer .yui-cal-nav-b {
+ text-align:center;
+}
+
+.yui-calcontainer .yui-cal-nav-e {
+ margin-top:2px;
+ padding:2px;
+ background-color:#EDF5FF;
+ border-top:1px solid black;
+ display:none;
+}
+
+.yui-calcontainer .yui-cal-nav label {
+ display:block;
+ font-weight:bold;
+}
+
+.yui-calcontainer .yui-cal-nav-mc {
+ width:100%;
+ _width:auto; /* IE6 doesn't like width 100% */
+}
+
+.yui-calcontainer .yui-cal-nav-y input.yui-invalid {
+ background-color:#FFEE69;
+ border: 1px solid #000;
+}
+
+.yui-calcontainer .yui-cal-nav-yc {
+ width:3em;
+}
+
+.yui-calcontainer .yui-cal-nav-b button {
+ font-size:93%;
+ text-decoration:none;
+ cursor: pointer;
+ background-color: #79b2ea;
+ border: 1px solid #003366;
+ border-top-color:#FFF;
+ border-left-color:#FFF;
+ margin:1px;
+}
+
+.yui-calcontainer .yui-cal-nav-b .yui-default button {
+ /* not implemented */
+}
+
/* Specific changes for calendar running under fonts/reset */
.yui-calendar .calbody a:hover {background:inherit;}
p#clear {clear:left; padding-top:10px;}
diff --git a/lib/yui/calendar/assets/calgrad.png b/lib/yui/calendar/assets/calgrad.png
new file mode 100644
index 0000000000000000000000000000000000000000..9be3d958c746ded4969acf34d7f86d76c3687314
GIT binary patch
literal 497
zcmV
+* If not provided, the ID will be generated from the container DIV ID by adding an "_t" suffix. +* For example if an ID is not provided, and the container's ID is "calContainer", the Calendar's ID will be set to "calContainer_t". +*
+* * @namespace YAHOO.widget * @class Calendar * @constructor -* @param {String} id The id of the table element that will represent the calendar widget -* @param {String} containerId The id of the container div element that will wrap the calendar table -* @param {Object} config The configuration object containing the Calendar's arguments +* @param {String} id optional The id of the table element that will represent the Calendar widget. As of 2.4.0, this argument is optional. +* @param {String | HTMLElement} container The id of the container div element that will wrap the Calendar table, or a reference to a DIV element which exists in the document. +* @param {Object} config optional The configuration object containing the initial configuration values for the Calendar. */ YAHOO.widget.Calendar = function(id, containerId, config) { - this.init(id, containerId, config); + this.init.apply(this, arguments); }; /** @@ -1153,7 +1226,8 @@ YAHOO.widget.Calendar._DEFAULT_CONFIG = { MY_LABEL_MONTH_POSITION:{key:"my_label_month_position", value:1}, MY_LABEL_YEAR_POSITION:{key:"my_label_year_position", value:2}, MY_LABEL_MONTH_SUFFIX:{key:"my_label_month_suffix", value:" "}, - MY_LABEL_YEAR_SUFFIX:{key:"my_label_year_suffix", value:""} + MY_LABEL_YEAR_SUFFIX:{key:"my_label_year_suffix", value:""}, + NAV: {key:"navigator", value: null} }; /** @@ -1173,7 +1247,17 @@ YAHOO.widget.Calendar._EVENT_TYPES = { BEFORE_RENDER : "beforeRender", RENDER : "render", RESET : "reset", - CLEAR : "clear" + CLEAR : "clear", + BEFORE_HIDE : "beforeHide", + HIDE : "hide", + BEFORE_SHOW : "beforeShow", + SHOW : "show", + BEFORE_HIDE_NAV : "beforeHideNav", + HIDE_NAV : "hideNav", + BEFORE_SHOW_NAV : "beforeShowNav", + SHOW_NAV : "showNav", + BEFORE_RENDER_NAV : "beforeRenderNav", + RENDER_NAV : "renderNav" }; /** @@ -1206,6 +1290,7 @@ YAHOO.widget.Calendar._STYLES = { CSS_CONTAINER : "yui-calcontainer", CSS_NAV_LEFT : "calnavleft", CSS_NAV_RIGHT : "calnavright", + CSS_NAV : "calnav", CSS_CLOSE : "calclose", CSS_CELL_TOP : "calcelltop", CSS_CELL_LEFT : "calcellleft", @@ -1249,7 +1334,7 @@ YAHOO.widget.Calendar.prototype = { * @type HTMLTableCellElement[] */ cells : null, - + /** * The collection of calendar cell dates that is parallel to the cells collection. The array contains dates field arrays in the format of [YYYY, M, D]. * @property cellDates @@ -1258,12 +1343,19 @@ YAHOO.widget.Calendar.prototype = { cellDates : null, /** - * The id that uniquely identifies this calendar. This id should match the id of the placeholder element on the page. + * The id that uniquely identifies this Calendar. * @property id * @type String */ id : null, + /** + * The unique id associated with the Calendar's container + * @property containerId + * @type String + */ + containerId: null, + /** * The DOM element reference that points to this calendar's container element. The calendar will be inserted into this element when the shell is rendered. * @property oDomContainer @@ -1293,6 +1385,14 @@ YAHOO.widget.Calendar.prototype = { */ _renderStack : null, + /** + * A reference to the CalendarNavigator instance created for this Calendar. + * Will be null if the "navigator" configuration property has not been set + * @property oNavigator + * @type CalendarNavigator + */ + oNavigator : null, + /** * The private list of initially selected dates. * @property _selectedDates @@ -1306,3674 +1406,5416 @@ YAHOO.widget.Calendar.prototype = { * @property domEventMap * @type Object */ - domEventMap : null -}; - - - -/** -* Initializes the Calendar widget. -* @method init -* @param {String} id The id of the table element that will represent the calendar widget -* @param {String} containerId The id of the container div element that will wrap the calendar table -* @param {Object} config The configuration object containing the Calendar's arguments -*/ -YAHOO.widget.Calendar.prototype.init = function(id, containerId, config) { - this.logger = new YAHOO.widget.LogWriter("Calendar " + id); - this.initEvents(); - this.today = new Date(); - YAHOO.widget.DateMath.clearTime(this.today); - - this.id = id; - this.oDomContainer = document.getElementById(containerId); - if (! this.oDomContainer) { this.logger.log("No valid container present.", "error"); } - - /** - * The Config object used to hold the configuration variables for the Calendar - * @property cfg - * @type YAHOO.util.Config - */ - this.cfg = new YAHOO.util.Config(this); - - /** - * The local object which contains the Calendar's options - * @property Options - * @type Object - */ - this.Options = {}; - - /** - * The local object which contains the Calendar's locale settings - * @property Locale - * @type Object - */ - this.Locale = {}; - - this.initStyles(); - - YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_CONTAINER); - YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_SINGLE); - - this.cellDates = []; - this.cells = []; - this.renderStack = []; - this._renderStack = []; - - this.setupConfig(); - - if (config) { - this.cfg.applyConfig(config, true); - } - - this.cfg.fireQueue(); -}; - -/** -* Default Config listener for the iframe property. If the iframe config property is set to true, -* renders the built-in IFRAME shim if the container is relatively or absolutely positioned. -* -* @method configIframe -*/ -YAHOO.widget.Calendar.prototype.configIframe = function(type, args, obj) { - var useIframe = args[0]; - - if (!this.parent) { - if (YAHOO.util.Dom.inDocument(this.oDomContainer)) { - if (useIframe) { - var pos = YAHOO.util.Dom.getStyle(this.oDomContainer, "position"); - - if (pos == "absolute" || pos == "relative") { - - if (!YAHOO.util.Dom.inDocument(this.iframe)) { - this.iframe = document.createElement("iframe"); - this.iframe.src = "javascript:false;"; - - YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0"); - - if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) { - YAHOO.util.Dom.addClass(this.iframe, "fixedsize"); - } - - this.oDomContainer.insertBefore(this.iframe, this.oDomContainer.firstChild); - } - } - } else { - if (this.iframe) { - if (this.iframe.parentNode) { - this.iframe.parentNode.removeChild(this.iframe); + domEventMap : null, + + /** + * Protected helper used to parse Calendar constructor/init arguments. + * + * As of 2.4.0, Calendar supports a simpler constructor + * signature. This method reconciles arguments + * received in the pre 2.4.0 and 2.4.0 formats. + * + * @protected + * @method _parseArgs + * @param {Array} Function "arguments" array + * @return {Object} Object with id, container, config properties containing + * the reconciled argument values. + **/ + _parseArgs : function(args) { + /* + 2.4.0 Constructors signatures + + new Calendar(String) + new Calendar(HTMLElement) + new Calendar(String, ConfigObject) + new Calendar(HTMLElement, ConfigObject) + + Pre 2.4.0 Constructor signatures + + new Calendar(String, String) + new Calendar(String, HTMLElement) + new Calendar(String, String, ConfigObject) + new Calendar(String, HTMLElement, ConfigObject) + */ + var nArgs = {id:null, container:null, config:null}; + + if (args && args.length && args.length > 0) { + switch (args.length) { + case 1: + nArgs.id = null; + nArgs.container = args[0]; + nArgs.config = null; + break; + case 2: + if (YAHOO.lang.isObject(args[1]) && !args[1].tagName && !(args[1] instanceof String)) { + nArgs.id = null; + nArgs.container = args[0]; + nArgs.config = args[1]; + } else { + nArgs.id = args[0]; + nArgs.container = args[1]; + nArgs.config = null; } - this.iframe = null; - } + break; + default: // 3+ + nArgs.id = args[0]; + nArgs.container = args[1]; + nArgs.config = args[2]; + break; } + } else { + this.logger.log("Invalid constructor/init arguments", "error"); } - } -}; + return nArgs; + }, -/** -* Default handler for the "title" property -* @method configTitle -*/ -YAHOO.widget.Calendar.prototype.configTitle = function(type, args, obj) { - var title = args[0]; - var close = this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.CLOSE.key); - - var titleDiv; + /** + * Initializes the Calendar widget. + * @method init + * + * @param {String} id optional The id of the table element that will represent the Calendar widget. As of 2.4.0, this argument is optional. + * @param {String | HTMLElement} container The id of the container div element that will wrap the Calendar table, or a reference to a DIV element which exists in the document. + * @param {Object} config optional The configuration object containing the initial configuration values for the Calendar. + */ + init : function(id, container, config) { + // Normalize 2.4.0, pre 2.4.0 args + var nArgs = this._parseArgs(arguments); - if (title && title !== "") { - titleDiv = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE, "div", this.oDomContainer)[0] || document.createElement("div"); - titleDiv.className = YAHOO.widget.CalendarGroup.CSS_2UPTITLE; - titleDiv.innerHTML = title; - this.oDomContainer.insertBefore(titleDiv, this.oDomContainer.firstChild); - YAHOO.util.Dom.addClass(this.oDomContainer, "withtitle"); - } else { - titleDiv = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE, "div", this.oDomContainer)[0] || null; + id = nArgs.id; + container = nArgs.container; + config = nArgs.config; + + this.oDomContainer = YAHOO.util.Dom.get(container); + if (!this.oDomContainer) { this.logger.log("Container not found in document.", "error"); } - if (titleDiv) { - YAHOO.util.Event.purgeElement(titleDiv); - this.oDomContainer.removeChild(titleDiv); + if (!this.oDomContainer.id) { + this.oDomContainer.id = YAHOO.util.Dom.generateId(); } - if (! close) { - YAHOO.util.Dom.removeClass(this.oDomContainer, "withtitle"); + if (!id) { + id = this.oDomContainer.id + "_t"; } - } -}; -/** -* Default handler for the "close" property -* @method configClose -*/ -YAHOO.widget.Calendar.prototype.configClose = function(type, args, obj) { - var close = args[0]; - var title = this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.TITLE.key); - - var DEPR_CLOSE_PATH = "us/my/bn/x_d.gif"; + this.id = id; + this.containerId = this.oDomContainer.id; - var linkClose; + this.logger = new YAHOO.widget.LogWriter("Calendar " + this.id); + this.initEvents(); - if (close === true) { - linkClose = YAHOO.util.Dom.getElementsByClassName("link-close", "a", this.oDomContainer)[0] || document.createElement("a"); - linkClose.href = "#"; - linkClose.className = "link-close"; - YAHOO.util.Event.addListener(linkClose, "click", function(e, cal) {cal.hide(); YAHOO.util.Event.preventDefault(e); }, this); - - if (YAHOO.widget.Calendar.IMG_ROOT !== null) { - var imgClose = document.createElement("img"); - imgClose.src = YAHOO.widget.Calendar.IMG_ROOT + DEPR_CLOSE_PATH; - imgClose.className = YAHOO.widget.CalendarGroup.CSS_2UPCLOSE; - linkClose.appendChild(imgClose); - } else { - linkClose.innerHTML = ''; - } - - this.oDomContainer.appendChild(linkClose); - YAHOO.util.Dom.addClass(this.oDomContainer, "withtitle"); - } else { - linkClose = YAHOO.util.Dom.getElementsByClassName("link-close", "a", this.oDomContainer)[0] || null; - if (linkClose) { - YAHOO.util.Event.purgeElement(linkClose); - this.oDomContainer.removeChild(linkClose); - } - if (! title || title === "") { - YAHOO.util.Dom.removeClass(this.oDomContainer, "withtitle"); - } - } -}; + this.today = new Date(); + YAHOO.widget.DateMath.clearTime(this.today); -/** -* Initializes Calendar's built-in CustomEvents -* @method initEvents -*/ -YAHOO.widget.Calendar.prototype.initEvents = function() { + /** + * The Config object used to hold the configuration variables for the Calendar + * @property cfg + * @type YAHOO.util.Config + */ + this.cfg = new YAHOO.util.Config(this); - var defEvents = YAHOO.widget.Calendar._EVENT_TYPES; + /** + * The local object which contains the Calendar's options + * @property Options + * @type Object + */ + this.Options = {}; - /** - * Fired before a selection is made - * @event beforeSelectEvent - */ - this.beforeSelectEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_SELECT); + /** + * The local object which contains the Calendar's locale settings + * @property Locale + * @type Object + */ + this.Locale = {}; - /** - * Fired when a selection is made - * @event selectEvent - * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD]. - */ - this.selectEvent = new YAHOO.util.CustomEvent(defEvents.SELECT); + this.initStyles(); - /** - * Fired before a selection is made - * @event beforeDeselectEvent - */ - this.beforeDeselectEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_DESELECT); + YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_CONTAINER); + YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_SINGLE); - /** - * Fired when a selection is made - * @event deselectEvent - * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD]. - */ - this.deselectEvent = new YAHOO.util.CustomEvent(defEvents.DESELECT); + this.cellDates = []; + this.cells = []; + this.renderStack = []; + this._renderStack = []; - /** - * Fired when the Calendar page is changed - * @event changePageEvent - */ - this.changePageEvent = new YAHOO.util.CustomEvent(defEvents.CHANGE_PAGE); + this.setupConfig(); - /** - * Fired before the Calendar is rendered - * @event beforeRenderEvent - */ - this.beforeRenderEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_RENDER); + if (config) { + this.cfg.applyConfig(config, true); + } - /** - * Fired when the Calendar is rendered - * @event renderEvent - */ - this.renderEvent = new YAHOO.util.CustomEvent(defEvents.RENDER); + this.cfg.fireQueue(); + }, /** - * Fired when the Calendar is reset - * @event resetEvent + * Default Config listener for the iframe property. If the iframe config property is set to true, + * renders the built-in IFRAME shim if the container is relatively or absolutely positioned. + * + * @method configIframe */ - this.resetEvent = new YAHOO.util.CustomEvent(defEvents.RESET); + configIframe : function(type, args, obj) { + var useIframe = args[0]; + + if (!this.parent) { + if (YAHOO.util.Dom.inDocument(this.oDomContainer)) { + if (useIframe) { + var pos = YAHOO.util.Dom.getStyle(this.oDomContainer, "position"); + + if (pos == "absolute" || pos == "relative") { + + if (!YAHOO.util.Dom.inDocument(this.iframe)) { + this.iframe = document.createElement("iframe"); + this.iframe.src = "javascript:false;"; + + YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0"); + + if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) { + YAHOO.util.Dom.addClass(this.iframe, "fixedsize"); + } + + this.oDomContainer.insertBefore(this.iframe, this.oDomContainer.firstChild); + } + } + } else { + if (this.iframe) { + if (this.iframe.parentNode) { + this.iframe.parentNode.removeChild(this.iframe); + } + this.iframe = null; + } + } + } + } + }, /** - * Fired when the Calendar is cleared - * @event clearEvent + * Default handler for the "title" property + * @method configTitle */ - this.clearEvent = new YAHOO.util.CustomEvent(defEvents.CLEAR); - - this.beforeSelectEvent.subscribe(this.onBeforeSelect, this, true); - this.selectEvent.subscribe(this.onSelect, this, true); - this.beforeDeselectEvent.subscribe(this.onBeforeDeselect, this, true); - this.deselectEvent.subscribe(this.onDeselect, this, true); - this.changePageEvent.subscribe(this.onChangePage, this, true); - this.renderEvent.subscribe(this.onRender, this, true); - this.resetEvent.subscribe(this.onReset, this, true); - this.clearEvent.subscribe(this.onClear, this, true); -}; - -/** -* The default event function that is attached to a date link within a calendar cell -* when the calendar is rendered. -* @method doSelectCell -* @param {DOMEvent} e The event -* @param {Calendar} cal A reference to the calendar passed by the Event utility -*/ -YAHOO.widget.Calendar.prototype.doSelectCell = function(e, cal) { - var cell,index,d,date; - - var target = YAHOO.util.Event.getTarget(e); - var tagName = target.tagName.toLowerCase(); - var defSelector = false; - - while (tagName != "td" && ! YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) { + configTitle : function(type, args, obj) { + var title = args[0]; - if (!defSelector && tagName == "a" && YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTOR)) { - defSelector = true; - } - - target = target.parentNode; - tagName = target.tagName.toLowerCase(); - if (tagName == "html") { - return; + // "" disables title bar + if (title) { + this.createTitleBar(title); + } else { + var close = this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.CLOSE.key); + if (!close) { + this.removeTitleBar(); + } else { + this.createTitleBar(" "); + } } - } - - if (defSelector) { - // Stop link href navigation for default renderer - YAHOO.util.Event.preventDefault(e); - } - - cell = target; - - if (YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_SELECTABLE)) { - index = cell.id.split("cell")[1]; - d = cal.cellDates[index]; - date = new Date(d[0],d[1]-1,d[2]); + }, - var link; - - cal.logger.log("Selecting cell " + index + " via click", "info"); - if (cal.Options.MULTI_SELECT) { - link = cell.getElementsByTagName("a")[0]; - if (link) { - link.blur(); + /** + * Default handler for the "close" property + * @method configClose + */ + configClose : function(type, args, obj) { + var close = args[0], + title = this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.TITLE.key); + + if (close) { + if (!title) { + this.createTitleBar(" "); } - - var cellDate = cal.cellDates[index]; - var cellDateIndex = cal._indexOfSelectedFieldArray(cellDate); - - if (cellDateIndex > -1) { - cal.deselectCell(index); - } else { - cal.selectCell(index); - } - + this.createCloseButton(); } else { - link = cell.getElementsByTagName("a")[0]; - if (link) { - link.blur(); + this.removeCloseButton(); + if (!title) { + this.removeTitleBar(); } - cal.selectCell(index); } - } -}; - -/** -* The event that is executed when the user hovers over a cell -* @method doCellMouseOver -* @param {DOMEvent} e The event -* @param {Calendar} cal A reference to the calendar passed by the Event utility -*/ -YAHOO.widget.Calendar.prototype.doCellMouseOver = function(e, cal) { - var target; - if (e) { - target = YAHOO.util.Event.getTarget(e); - } else { - target = this; - } - - while (target.tagName.toLowerCase() != "td") { - target = target.parentNode; - if (target.tagName.toLowerCase() == "html") { - return; - } - } - - if (YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) { - YAHOO.util.Dom.addClass(target, cal.Style.CSS_CELL_HOVER); - } -}; - -/** -* The event that is executed when the user moves the mouse out of a cell -* @method doCellMouseOut -* @param {DOMEvent} e The event -* @param {Calendar} cal A reference to the calendar passed by the Event utility -*/ -YAHOO.widget.Calendar.prototype.doCellMouseOut = function(e, cal) { - var target; - if (e) { - target = YAHOO.util.Event.getTarget(e); - } else { - target = this; - } - - while (target.tagName.toLowerCase() != "td") { - target = target.parentNode; - if (target.tagName.toLowerCase() == "html") { - return; - } - } - - if (YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) { - YAHOO.util.Dom.removeClass(target, cal.Style.CSS_CELL_HOVER); - } -}; - -YAHOO.widget.Calendar.prototype.setupConfig = function() { - - var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; - - /** - * The month/year representing the current visible Calendar date (mm/yyyy) - * @config pagedate - * @type String - * @default today's date - */ - this.cfg.addProperty(defCfg.PAGEDATE.key, { value:new Date(), handler:this.configPageDate } ); - - /** - * The date or range of dates representing the current Calendar selection - * @config selected - * @type String - * @default [] - */ - this.cfg.addProperty(defCfg.SELECTED.key, { value:[], handler:this.configSelected } ); - - /** - * The title to display above the Calendar's month header - * @config title - * @type String - * @default "" - */ - this.cfg.addProperty(defCfg.TITLE.key, { value:defCfg.TITLE.value, handler:this.configTitle } ); - - /** - * Whether or not a close button should be displayed for this Calendar - * @config close - * @type Boolean - * @default false - */ - this.cfg.addProperty(defCfg.CLOSE.key, { value:defCfg.CLOSE.value, handler:this.configClose } ); - - /** - * Whether or not an iframe shim should be placed under the Calendar to prevent select boxes from bleeding through in Internet Explorer 6 and below. - * This property is enabled by default for IE6 and below. It is disabled by default for other browsers for performance reasons, but can be - * enabled if required. - * - * @config iframe - * @type Boolean - * @default true for IE6 and below, false for all other browsers - */ - this.cfg.addProperty(defCfg.IFRAME.key, { value:defCfg.IFRAME.value, handler:this.configIframe, validator:this.cfg.checkBoolean } ); - - /** - * The minimum selectable date in the current Calendar (mm/dd/yyyy) - * @config mindate - * @type String - * @default null - */ - this.cfg.addProperty(defCfg.MINDATE.key, { value:defCfg.MINDATE.value, handler:this.configMinDate } ); - - /** - * The maximum selectable date in the current Calendar (mm/dd/yyyy) - * @config maxdate - * @type String - * @default null - */ - this.cfg.addProperty(defCfg.MAXDATE.key, { value:defCfg.MAXDATE.value, handler:this.configMaxDate } ); - - - // Options properties - - /** - * True if the Calendar should allow multiple selections. False by default. - * @config MULTI_SELECT - * @type Boolean - * @default false - */ - this.cfg.addProperty(defCfg.MULTI_SELECT.key, { value:defCfg.MULTI_SELECT.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - - /** - * The weekday the week begins on. Default is 0 (Sunday). - * @config START_WEEKDAY - * @type number - * @default 0 - */ - this.cfg.addProperty(defCfg.START_WEEKDAY.key, { value:defCfg.START_WEEKDAY.value, handler:this.configOptions, validator:this.cfg.checkNumber } ); - - /** - * True if the Calendar should show weekday labels. True by default. - * @config SHOW_WEEKDAYS - * @type Boolean - * @default true - */ - this.cfg.addProperty(defCfg.SHOW_WEEKDAYS.key, { value:defCfg.SHOW_WEEKDAYS.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - - /** - * True if the Calendar should show week row headers. False by default. - * @config SHOW_WEEK_HEADER - * @type Boolean - * @default false - */ - this.cfg.addProperty(defCfg.SHOW_WEEK_HEADER.key, { value:defCfg.SHOW_WEEK_HEADER.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - - /** - * True if the Calendar should show week row footers. False by default. - * @config SHOW_WEEK_FOOTER - * @type Boolean - * @default false - */ - this.cfg.addProperty(defCfg.SHOW_WEEK_FOOTER.key,{ value:defCfg.SHOW_WEEK_FOOTER.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - - /** - * True if the Calendar should suppress weeks that are not a part of the current month. False by default. - * @config HIDE_BLANK_WEEKS - * @type Boolean - * @default false - */ - this.cfg.addProperty(defCfg.HIDE_BLANK_WEEKS.key, { value:defCfg.HIDE_BLANK_WEEKS.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - - /** - * The image that should be used for the left navigation arrow. - * @config NAV_ARROW_LEFT - * @type String - * @deprecated You can customize the image by overriding the default CSS class for the left arrow - "calnavleft" - * @default null - */ - this.cfg.addProperty(defCfg.NAV_ARROW_LEFT.key, { value:defCfg.NAV_ARROW_LEFT.value, handler:this.configOptions } ); - - /** - * The image that should be used for the right navigation arrow. - * @config NAV_ARROW_RIGHT - * @type String - * @deprecated You can customize the image by overriding the default CSS class for the right arrow - "calnavright" - * @default null - */ - this.cfg.addProperty(defCfg.NAV_ARROW_RIGHT.key, { value:defCfg.NAV_ARROW_RIGHT.value, handler:this.configOptions } ); - - // Locale properties - - /** - * The short month labels for the current locale. - * @config MONTHS_SHORT - * @type String[] - * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] - */ - this.cfg.addProperty(defCfg.MONTHS_SHORT.key, { value:defCfg.MONTHS_SHORT.value, handler:this.configLocale } ); - - /** - * The long month labels for the current locale. - * @config MONTHS_LONG - * @type String[] - * @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" - */ - this.cfg.addProperty(defCfg.MONTHS_LONG.key, { value:defCfg.MONTHS_LONG.value, handler:this.configLocale } ); - - /** - * The 1-character weekday labels for the current locale. - * @config WEEKDAYS_1CHAR - * @type String[] - * @default ["S", "M", "T", "W", "T", "F", "S"] - */ - this.cfg.addProperty(defCfg.WEEKDAYS_1CHAR.key, { value:defCfg.WEEKDAYS_1CHAR.value, handler:this.configLocale } ); - - /** - * The short weekday labels for the current locale. - * @config WEEKDAYS_SHORT - * @type String[] - * @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"] - */ - this.cfg.addProperty(defCfg.WEEKDAYS_SHORT.key, { value:defCfg.WEEKDAYS_SHORT.value, handler:this.configLocale } ); - - /** - * The medium weekday labels for the current locale. - * @config WEEKDAYS_MEDIUM - * @type String[] - * @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] - */ - this.cfg.addProperty(defCfg.WEEKDAYS_MEDIUM.key, { value:defCfg.WEEKDAYS_MEDIUM.value, handler:this.configLocale } ); - - /** - * The long weekday labels for the current locale. - * @config WEEKDAYS_LONG - * @type String[] - * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] - */ - this.cfg.addProperty(defCfg.WEEKDAYS_LONG.key, { value:defCfg.WEEKDAYS_LONG.value, handler:this.configLocale } ); - - /** - * Refreshes the locale values used to build the Calendar. - * @method refreshLocale - * @private - */ - var refreshLocale = function() { - this.cfg.refireEvent(defCfg.LOCALE_MONTHS.key); - this.cfg.refireEvent(defCfg.LOCALE_WEEKDAYS.key); - }; - - this.cfg.subscribeToConfigEvent(defCfg.START_WEEKDAY.key, refreshLocale, this, true); - this.cfg.subscribeToConfigEvent(defCfg.MONTHS_SHORT.key, refreshLocale, this, true); - this.cfg.subscribeToConfigEvent(defCfg.MONTHS_LONG.key, refreshLocale, this, true); - this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_1CHAR.key, refreshLocale, this, true); - this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_SHORT.key, refreshLocale, this, true); - this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_MEDIUM.key, refreshLocale, this, true); - this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_LONG.key, refreshLocale, this, true); - - /** - * The setting that determines which length of month labels should be used. Possible values are "short" and "long". - * @config LOCALE_MONTHS - * @type String - * @default "long" - */ - this.cfg.addProperty(defCfg.LOCALE_MONTHS.key, { value:defCfg.LOCALE_MONTHS.value, handler:this.configLocaleValues } ); - - /** - * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long". - * @config LOCALE_WEEKDAYS - * @type String - * @default "short" - */ - this.cfg.addProperty(defCfg.LOCALE_WEEKDAYS.key, { value:defCfg.LOCALE_WEEKDAYS.value, handler:this.configLocaleValues } ); - - /** - * The value used to delimit individual dates in a date string passed to various Calendar functions. - * @config DATE_DELIMITER - * @type String - * @default "," - */ - this.cfg.addProperty(defCfg.DATE_DELIMITER.key, { value:defCfg.DATE_DELIMITER.value, handler:this.configLocale } ); - - /** - * The value used to delimit date fields in a date string passed to various Calendar functions. - * @config DATE_FIELD_DELIMITER - * @type String - * @default "/" - */ - this.cfg.addProperty(defCfg.DATE_FIELD_DELIMITER.key, { value:defCfg.DATE_FIELD_DELIMITER.value, handler:this.configLocale } ); - - /** - * The value used to delimit date ranges in a date string passed to various Calendar functions. - * @config DATE_RANGE_DELIMITER - * @type String - * @default "-" - */ - this.cfg.addProperty(defCfg.DATE_RANGE_DELIMITER.key, { value:defCfg.DATE_RANGE_DELIMITER.value, handler:this.configLocale } ); - - /** - * The position of the month in a month/year date string - * @config MY_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty(defCfg.MY_MONTH_POSITION.key, { value:defCfg.MY_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the year in a month/year date string - * @config MY_YEAR_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty(defCfg.MY_YEAR_POSITION.key, { value:defCfg.MY_YEAR_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the month in a month/day date string - * @config MD_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty(defCfg.MD_MONTH_POSITION.key, { value:defCfg.MD_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the day in a month/year date string - * @config MD_DAY_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty(defCfg.MD_DAY_POSITION.key, { value:defCfg.MD_DAY_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the month in a month/day/year date string - * @config MDY_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty(defCfg.MDY_MONTH_POSITION.key, { value:defCfg.MDY_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the day in a month/day/year date string - * @config MDY_DAY_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty(defCfg.MDY_DAY_POSITION.key, { value:defCfg.MDY_DAY_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the year in a month/day/year date string - * @config MDY_YEAR_POSITION - * @type Number - * @default 3 - */ - this.cfg.addProperty(defCfg.MDY_YEAR_POSITION.key, { value:defCfg.MDY_YEAR_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the month in the month year label string used as the Calendar header - * @config MY_LABEL_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty(defCfg.MY_LABEL_MONTH_POSITION.key, { value:defCfg.MY_LABEL_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the year in the month year label string used as the Calendar header - * @config MY_LABEL_YEAR_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty(defCfg.MY_LABEL_YEAR_POSITION.key, { value:defCfg.MY_LABEL_YEAR_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); + }, /** - * The suffix used after the month when rendering the Calendar header - * @config MY_LABEL_MONTH_SUFFIX - * @type String - * @default " " + * Initializes Calendar's built-in CustomEvents + * @method initEvents */ - this.cfg.addProperty(defCfg.MY_LABEL_MONTH_SUFFIX.key, { value:defCfg.MY_LABEL_MONTH_SUFFIX.value, handler:this.configLocale } ); + initEvents : function() { - /** - * The suffix used after the year when rendering the Calendar header - * @config MY_LABEL_YEAR_SUFFIX - * @type String - * @default "" - */ - this.cfg.addProperty(defCfg.MY_LABEL_YEAR_SUFFIX.key, { value:defCfg.MY_LABEL_YEAR_SUFFIX.value, handler:this.configLocale } ); -}; - -/** -* The default handler for the "pagedate" property -* @method configPageDate -*/ -YAHOO.widget.Calendar.prototype.configPageDate = function(type, args, obj) { - this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key, this._parsePageDate(args[0]), true); -}; - -/** -* The default handler for the "mindate" property -* @method configMinDate -*/ -YAHOO.widget.Calendar.prototype.configMinDate = function(type, args, obj) { - var val = args[0]; - if (YAHOO.lang.isString(val)) { - val = this._parseDate(val); - this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MINDATE.key, new Date(val[0],(val[1]-1),val[2])); - } -}; - -/** -* The default handler for the "maxdate" property -* @method configMaxDate -*/ -YAHOO.widget.Calendar.prototype.configMaxDate = function(type, args, obj) { - var val = args[0]; - if (YAHOO.lang.isString(val)) { - val = this._parseDate(val); - this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MAXDATE.key, new Date(val[0],(val[1]-1),val[2])); - } -}; - -/** -* The default handler for the "selected" property -* @method configSelected -*/ -YAHOO.widget.Calendar.prototype.configSelected = function(type, args, obj) { - var selected = args[0]; - var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key; + var defEvents = YAHOO.widget.Calendar._EVENT_TYPES; - if (selected) { - if (YAHOO.lang.isString(selected)) { - this.cfg.setProperty(cfgSelected, this._parseDates(selected), true); - } - } - if (! this._selectedDates) { - this._selectedDates = this.cfg.getProperty(cfgSelected); - } -}; - -/** -* The default handler for all configuration options properties -* @method configOptions -*/ -YAHOO.widget.Calendar.prototype.configOptions = function(type, args, obj) { - this.Options[type.toUpperCase()] = args[0]; -}; - -/** -* The default handler for all configuration locale properties -* @method configLocale -*/ -YAHOO.widget.Calendar.prototype.configLocale = function(type, args, obj) { - var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; - this.Locale[type.toUpperCase()] = args[0]; - - this.cfg.refireEvent(defCfg.LOCALE_MONTHS.key); - this.cfg.refireEvent(defCfg.LOCALE_WEEKDAYS.key); -}; - -/** -* The default handler for all configuration locale field length properties -* @method configLocaleValues -*/ -YAHOO.widget.Calendar.prototype.configLocaleValues = function(type, args, obj) { - var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; - - type = type.toLowerCase(); - var val = args[0]; - - switch (type) { - case defCfg.LOCALE_MONTHS.key: - switch (val) { - case YAHOO.widget.Calendar.SHORT: - this.Locale.LOCALE_MONTHS = this.cfg.getProperty(defCfg.MONTHS_SHORT.key).concat(); - break; - case YAHOO.widget.Calendar.LONG: - this.Locale.LOCALE_MONTHS = this.cfg.getProperty(defCfg.MONTHS_LONG.key).concat(); - break; - } - break; - case defCfg.LOCALE_WEEKDAYS.key: - switch (val) { - case YAHOO.widget.Calendar.ONE_CHAR: - this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_1CHAR.key).concat(); - break; - case YAHOO.widget.Calendar.SHORT: - this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_SHORT.key).concat(); - break; - case YAHOO.widget.Calendar.MEDIUM: - this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_MEDIUM.key).concat(); - break; - case YAHOO.widget.Calendar.LONG: - this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_LONG.key).concat(); - break; - } - - var START_WEEKDAY = this.cfg.getProperty(defCfg.START_WEEKDAY.key); - - if (START_WEEKDAY > 0) { - for (var w=0;w+ * Setting this property to true will enable the CalendarNavigatior UI with the default CalendarNavigator configuration values. + *
+ *+ * This property can also be set to an object literal containing configuration properties for the CalendarNavigator UI. + * The configuration object expects the the following case-sensitive properties, with the "strings" property being a nested object. + * Any properties which are not provided will use the default values (defined in the CalendarNavigator class). + *
+ *E.g.
+ *+ * var navConfig = { + * strings: { + * month:"Calendar Month", + * year:"Calendar Year", + * submit: "Submit", + * cancel: "Cancel", + * invalidYear: "Please enter a valid year" + * }, + * monthFormat: YAHOO.widget.Calendar.SHORT, + * initialFocus: "month" + * } + *+ * @config navigator + * @type {Object|Boolean} + * @default null + */ + this.cfg.addProperty(defCfg.NAV.key, { value:defCfg.NAV.value, handler:this.configNavigator } ); + }, - var rArray = this.renderStack[s]; - var type = rArray[0]; - - var month; - var day; - var year; - - switch (type) { - case YAHOO.widget.Calendar.DATE: - month = rArray[1][1]; - day = rArray[1][2]; - year = rArray[1][0]; - - if (workingDate.getMonth()+1 == month && workingDate.getDate() == day && workingDate.getFullYear() == year) { - renderer = rArray[2]; - this.renderStack.splice(s,1); - } - break; - case YAHOO.widget.Calendar.MONTH_DAY: - month = rArray[1][0]; - day = rArray[1][1]; - - if (workingDate.getMonth()+1 == month && workingDate.getDate() == day) { - renderer = rArray[2]; - this.renderStack.splice(s,1); - } - break; - case YAHOO.widget.Calendar.RANGE: - var date1 = rArray[1][0]; - var date2 = rArray[1][1]; - - var d1month = date1[1]; - var d1day = date1[2]; - var d1year = date1[0]; - - var d1 = new Date(d1year, d1month-1, d1day); - - var d2month = date2[1]; - var d2day = date2[2]; - var d2year = date2[0]; - - var d2 = new Date(d2year, d2month-1, d2day); - - if (workingDate.getTime() >= d1.getTime() && workingDate.getTime() <= d2.getTime()) { - renderer = rArray[2]; - - if (workingDate.getTime()==d2.getTime()) { - this.renderStack.splice(s,1); - } - } - break; - case YAHOO.widget.Calendar.WEEKDAY: - - var weekday = rArray[1][0]; - if (workingDate.getDay()+1 == weekday) { - renderer = rArray[2]; - } - break; - case YAHOO.widget.Calendar.MONTH: - - month = rArray[1][0]; - if (workingDate.getMonth()+1 == month) { - renderer = rArray[2]; - } - break; - } - - if (renderer) { - cellRenderers[cellRenderers.length]=renderer; - } - } + /** + * The default handler for the "pagedate" property + * @method configPageDate + */ + configPageDate : function(type, args, obj) { + this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key, this._parsePageDate(args[0]), true); + }, - } + /** + * The default handler for the "mindate" property + * @method configMinDate + */ + configMinDate : function(type, args, obj) { + var val = args[0]; + if (YAHOO.lang.isString(val)) { + val = this._parseDate(val); + this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MINDATE.key, YAHOO.widget.DateMath.getDate(val[0],(val[1]-1),val[2])); + } + }, - if (this._indexOfSelectedFieldArray(workingArray) > -1) { - cellRenderers[cellRenderers.length]=cal.renderCellStyleSelected; + /** + * The default handler for the "maxdate" property + * @method configMaxDate + */ + configMaxDate : function(type, args, obj) { + var val = args[0]; + if (YAHOO.lang.isString(val)) { + val = this._parseDate(val); + this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MAXDATE.key, YAHOO.widget.DateMath.getDate(val[0],(val[1]-1),val[2])); + } + }, + + /** + * The default handler for the "selected" property + * @method configSelected + */ + configSelected : function(type, args, obj) { + var selected = args[0]; + var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key; + + if (selected) { + if (YAHOO.lang.isString(selected)) { + this.cfg.setProperty(cfgSelected, this._parseDates(selected), true); + } + } + if (! this._selectedDates) { + this._selectedDates = this.cfg.getProperty(cfgSelected); + } + }, + + /** + * The default handler for all configuration options properties + * @method configOptions + */ + configOptions : function(type, args, obj) { + this.Options[type.toUpperCase()] = args[0]; + }, + + /** + * The default handler for all configuration locale properties + * @method configLocale + */ + configLocale : function(type, args, obj) { + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + this.Locale[type.toUpperCase()] = args[0]; + + this.cfg.refireEvent(defCfg.LOCALE_MONTHS.key); + this.cfg.refireEvent(defCfg.LOCALE_WEEKDAYS.key); + }, + + /** + * The default handler for all configuration locale field length properties + * @method configLocaleValues + */ + configLocaleValues : function(type, args, obj) { + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + + type = type.toLowerCase(); + var val = args[0]; + + switch (type) { + case defCfg.LOCALE_MONTHS.key: + switch (val) { + case YAHOO.widget.Calendar.SHORT: + this.Locale.LOCALE_MONTHS = this.cfg.getProperty(defCfg.MONTHS_SHORT.key).concat(); + break; + case YAHOO.widget.Calendar.LONG: + this.Locale.LOCALE_MONTHS = this.cfg.getProperty(defCfg.MONTHS_LONG.key).concat(); + break; } - - if ((mindate && (workingDate.getTime() < mindate.getTime())) || - (maxdate && (workingDate.getTime() > maxdate.getTime())) - ) { - cellRenderers[cellRenderers.length]=cal.renderOutOfBoundsDate; - } else { - cellRenderers[cellRenderers.length]=cal.styleCellDefault; - cellRenderers[cellRenderers.length]=cal.renderCellDefault; + break; + case defCfg.LOCALE_WEEKDAYS.key: + switch (val) { + case YAHOO.widget.Calendar.ONE_CHAR: + this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_1CHAR.key).concat(); + break; + case YAHOO.widget.Calendar.SHORT: + this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_SHORT.key).concat(); + break; + case YAHOO.widget.Calendar.MEDIUM: + this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_MEDIUM.key).concat(); + break; + case YAHOO.widget.Calendar.LONG: + this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_LONG.key).concat(); + break; } - for (var x=0; x < cellRenderers.length; ++x) { - this.logger.log("renderer[" + x + "] for (" + workingDate.getFullYear() + "-" + (workingDate.getMonth()+1) + "-" + workingDate.getDate() + ")", "cellrender"); - if (cellRenderers[x].call(cal, workingDate, cell) == YAHOO.widget.Calendar.STOP_RENDER) { - break; + var START_WEEKDAY = this.cfg.getProperty(defCfg.START_WEEKDAY.key); + + if (START_WEEKDAY > 0) { + for (var w=0;w
+* NOTE: As of 2.4.0, the constructor's ID argument is optional. +* The CalendarGroup can be constructed by simply providing a container ID string, +* or a reference to a container DIV HTMLElement (the element needs to exist +* in the document). +* +* E.g.: +*
+* If not provided, the ID will be generated from the container DIV ID by adding an "_t" suffix. +* For example if an ID is not provided, and the container's ID is "calContainer", the CalendarGroup's ID will be set to "calContainer_t". +*
+* +* @namespace YAHOO.widget +* @class CalendarGroup +* @constructor +* @param {String} id optional The id of the table element that will represent the CalendarGroup widget. As of 2.4.0, this argument is optional. +* @param {String | HTMLElement} container The id of the container div element that will wrap the CalendarGroup table, or a reference to a DIV element which exists in the document. +* @param {Object} config optional The configuration object containing the initial configuration values for the CalendarGroup. +*/ +YAHOO.widget.CalendarGroup = function(id, containerId, config) { + if (arguments.length > 0) { + this.init.apply(this, arguments); } - - YAHOO.util.Event.addListener(this.oDomContainer, "click", this.doSelectCell, this); - YAHOO.util.Event.addListener(this.oDomContainer, "mouseover", this.doCellMouseOver, this); - YAHOO.util.Event.addListener(this.oDomContainer, "mouseout", this.doCellMouseOut, this); }; -/** -* Retrieves the Date object for the specified Calendar cell -* @method getDateByCellId -* @param {String} id The id of the cell -* @return {Date} The Date object for the specified Calendar cell -*/ -YAHOO.widget.Calendar.prototype.getDateByCellId = function(id) { - var date = this.getDateFieldsByCellId(id); - return new Date(date[0],date[1]-1,date[2]); -}; +YAHOO.widget.CalendarGroup.prototype = { -/** -* Retrieves the Date object for the specified Calendar cell -* @method getDateFieldsByCellId -* @param {String} id The id of the cell -* @return {Array} The array of Date fields for the specified Calendar cell -*/ -YAHOO.widget.Calendar.prototype.getDateFieldsByCellId = function(id) { - id = id.toLowerCase().split("_cell")[1]; - id = parseInt(id, 10); - return this.cellDates[id]; -}; + /** + * Initializes the calendar group. All subclasses must call this method in order for the + * group to be initialized properly. + * @method init + * @param {String} id optional The id of the table element that will represent the CalendarGroup widget. As of 2.4.0, this argument is optional. + * @param {String | HTMLElement} container The id of the container div element that will wrap the CalendarGroup table, or a reference to a DIV element which exists in the document. + * @param {Object} config optional The configuration object containing the initial configuration values for the CalendarGroup. + */ + init : function(id, container, config) { -// BEGIN BUILT-IN TABLE CELL RENDERERS + // Normalize 2.4.0, pre 2.4.0 args + var nArgs = this._parseArgs(arguments); -/** -* Renders a cell that falls before the minimum date or after the maximum date. -* widget class. -* @method renderOutOfBoundsDate -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering -* should not be terminated -*/ -YAHOO.widget.Calendar.prototype.renderOutOfBoundsDate = function(workingDate, cell) { - YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOB); - cell.innerHTML = workingDate.getDate(); - return YAHOO.widget.Calendar.STOP_RENDER; -}; + id = nArgs.id; + container = nArgs.container; + config = nArgs.config; -/** -* Renders the row header for a week. -* @method renderRowHeader -* @param {Number} weekNum The week number of the current row -* @param {Array} cell The current working HTML array -*/ -YAHOO.widget.Calendar.prototype.renderRowHeader = function(weekNum, html) { - html[html.length] = '+ * The method will call applyKeyListeners, to setup keyboard specific + * listeners + *
+ * @method applyListeners + */ + applyListeners : function() { + var E = YAHOO.util.Event; - for (var p=0;p+ * See applyKeyListeners + *
+ * @protected + * @method _setFirstLastElements + */ + _setFirstLastElements : function() { + this.firstCtrl = this.monthEl; + this.lastCtrl = this.cancelEl; + + // Special handling for MacOSX. + // - Safari 2.x can't focus on buttons + // - Gecko can't focus on select boxes or buttons + if (this.__isMac) { + if (YAHOO.env.ua.webkit && YAHOO.env.ua.webkit < 420){ + this.firstCtrl = this.monthEl; + this.lastCtrl = this.yearEl; + } + if (YAHOO.env.ua.gecko) { + this.firstCtrl = this.yearEl; + this.lastCtrl = this.yearEl; + } + } + }, -/** -* The set of default Config property keys and values for the CalendarGroup -* @property YAHOO.widget.CalendarGroup._DEFAULT_CONFIG -* @final -* @static -* @private -* @type Object -*/ -YAHOO.widget.CalendarGroup._DEFAULT_CONFIG = YAHOO.widget.Calendar._DEFAULT_CONFIG; -YAHOO.widget.CalendarGroup._DEFAULT_CONFIG.PAGES = {key:"pages", value:2}; + /** + * Default Keyboard event handler to capture Enter + * on the Navigator's year control (yearEl) + * + * @method _handleEnterKey + * @protected + * @param {Event} e The DOM event being handled + */ + _handleEnterKey : function(e) { + var KEYS = YAHOO.util.KeyListener.KEY; -/** -* Returns a string representation of the object. -* @method toString -* @return {String} A string representation of the CalendarGroup object. -*/ -YAHOO.widget.CalendarGroup.prototype.toString = function() { - return "CalendarGroup " + this.id; -}; + if (YAHOO.util.Event.getCharCode(e) == KEYS.ENTER) { + YAHOO.util.Event.preventDefault(e); + this.submit(); + } + }, -YAHOO.widget.CalGrp = YAHOO.widget.CalendarGroup; + /** + * Default Keyboard event handler to capture up/down/pgup/pgdown + * on the Navigator's year control (yearEl). + * + * @method _handleDirectionKeys + * @protected + * @param {Event} e The DOM event being handled + */ + _handleDirectionKeys : function(e) { + var E = YAHOO.util.Event; + var KEYS = YAHOO.util.KeyListener.KEY; + var NAV = YAHOO.widget.CalendarNavigator; + + var value = (this.yearEl.value) ? parseInt(this.yearEl.value, 10) : null; + if (isFinite(value)) { + var dir = false; + switch(E.getCharCode(e)) { + case KEYS.UP: + this.yearEl.value = value + NAV.YR_MINOR_INC; + dir = true; + break; + case KEYS.DOWN: + this.yearEl.value = Math.max(value - NAV.YR_MINOR_INC, 0); + dir = true; + break; + case KEYS.PAGE_UP: + this.yearEl.value = value + NAV.YR_MAJOR_INC; + dir = true; + break; + case KEYS.PAGE_DOWN: + this.yearEl.value = Math.max(value - NAV.YR_MAJOR_INC, 0); + dir = true; + break; + default: + break; + } + if (dir) { + E.preventDefault(e); + try { + this.yearEl.select(); + } catch(e) { + // Ignore + } + } + } + }, -/** -* @class YAHOO.widget.Calendar2up -* @extends YAHOO.widget.CalendarGroup -* @deprecated The old Calendar2up class is no longer necessary, since CalendarGroup renders in a 2up view by default. -*/ -YAHOO.widget.Calendar2up = function(id, containerId, config) { - this.init(id, containerId, config); -}; + /** + * Default Keyboard event handler to capture Tab + * on the last control (lastCtrl) in the Navigator. + * + * @method _handleTabKey + * @protected + * @param {Event} e The DOM event being handled + */ + _handleTabKey : function(e) { + var E = YAHOO.util.Event; + var KEYS = YAHOO.util.KeyListener.KEY; + + if (E.getCharCode(e) == KEYS.TAB && !e.shiftKey) { + try { + E.preventDefault(e); + this.firstCtrl.focus(); + } catch (e) { + // Ignore - mainly for focus edge cases + } + } + }, -YAHOO.extend(YAHOO.widget.Calendar2up, YAHOO.widget.CalendarGroup); + /** + * Default Keyboard event handler to capture Shift-Tab + * on the first control (firstCtrl) in the Navigator. + * + * @method _handleShiftTabKey + * @protected + * @param {Event} e The DOM event being handled + */ + _handleShiftTabKey : function(e) { + var E = YAHOO.util.Event; + var KEYS = YAHOO.util.KeyListener.KEY; + + if (e.shiftKey && E.getCharCode(e) == KEYS.TAB) { + try { + E.preventDefault(e); + this.lastCtrl.focus(); + } catch (e) { + // Ignore - mainly for focus edge cases + } + } + }, -/** -* @deprecated The old Calendar2up class is no longer necessary, since CalendarGroup renders in a 2up view by default. -*/ -YAHOO.widget.Cal2up = YAHOO.widget.Calendar2up; + /** + * Retrieve Navigator configuration values from + * the parent Calendar/CalendarGroup's config value. + *+ * If it has not been set in the user provided configuration, the method will + * return the default value of the configuration property, as set in _DEFAULT_CFG + *
+ * @private + * @method __getCfg + * @param {String} Case sensitive property name. + * @param {Boolean} true, if the property is a string property, false if not. + * @return The value of the configuration property + */ + __getCfg : function(prop, bIsStr) { + var DEF_CFG = YAHOO.widget.CalendarNavigator._DEFAULT_CFG; + var cfg = this.cal.cfg.getProperty("navigator"); + + if (bIsStr) { + return (cfg !== true && cfg.strings && cfg.strings[prop]) ? cfg.strings[prop] : DEF_CFG.strings[prop]; + } else { + return (cfg !== true && cfg[prop]) ? cfg[prop] : DEF_CFG[prop]; + } + }, + + /** + * Private flag, to identify MacOS + * @private + * @property __isMac + */ + __isMac : (navigator.userAgent.toLowerCase().indexOf("macintosh") != -1) + +}; -YAHOO.register("calendar", YAHOO.widget.Calendar, {version: "2.3.0", build: "442"}); +YAHOO.register("calendar", YAHOO.widget.Calendar, {version: "2.5.0", build: "895"}); diff --git a/lib/yui/calendar/calendar-min.js b/lib/yui/calendar/calendar-min.js index 98877bae0a..cb632508c5 100755 --- a/lib/yui/calendar/calendar-min.js +++ b/lib/yui/calendar/calendar-min.js @@ -1,130 +1,18 @@ /* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Copyright (c) 2008, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt -version: 2.3.0 +version: 2.5.0 */ - -(function(){YAHOO.util.Config=function(owner){if(owner){this.init(owner);} -if(!owner){}};var Lang=YAHOO.lang,CustomEvent=YAHOO.util.CustomEvent,Config=YAHOO.util.Config;Config.CONFIG_CHANGED_EVENT="configChanged";Config.BOOLEAN_TYPE="boolean";Config.prototype={owner:null,queueInProgress:false,config:null,initialConfig:null,eventQueue:null,configChangedEvent:null,init:function(owner){this.owner=owner;this.configChangedEvent=this.createEvent(Config.CONFIG_CHANGED_EVENT);this.configChangedEvent.signature=CustomEvent.LIST;this.queueInProgress=false;this.config={};this.initialConfig={};this.eventQueue=[];},checkBoolean:function(val){return(typeof val==Config.BOOLEAN_TYPE);},checkNumber:function(val){return(!isNaN(val));},fireEvent:function(key,value){var property=this.config[key];if(property&&property.event){property.event.fire(value);}},addProperty:function(key,propertyObject){key=key.toLowerCase();this.config[key]=propertyObject;propertyObject.event=this.createEvent(key,{scope:this.owner});propertyObject.event.signature=CustomEvent.LIST;propertyObject.key=key;if(propertyObject.handler){propertyObject.event.subscribe(propertyObject.handler,this.owner);} -this.setProperty(key,propertyObject.value,true);if(!propertyObject.suppressEvent){this.queueProperty(key,propertyObject.value);}},getConfig:function(){var cfg={},prop,property;for(prop in this.config){property=this.config[prop];if(property&&property.event){cfg[prop]=property.value;}} -return cfg;},getProperty:function(key){var property=this.config[key.toLowerCase()];if(property&&property.event){return property.value;}else{return undefined;}},resetProperty:function(key){key=key.toLowerCase();var property=this.config[key];if(property&&property.event){if(this.initialConfig[key]&&!Lang.isUndefined(this.initialConfig[key])){this.setProperty(key,this.initialConfig[key]);} -return true;}else{return false;}},setProperty:function(key,value,silent){var property;key=key.toLowerCase();if(this.queueInProgress&&!silent){this.queueProperty(key,value);return true;}else{property=this.config[key];if(property&&property.event){if(property.validator&&!property.validator(value)){return false;}else{property.value=value;if(!silent){this.fireEvent(key,value);this.configChangedEvent.fire([key,value]);} -return true;}}else{return false;}}},queueProperty:function(key,value){key=key.toLowerCase();var property=this.config[key],foundDuplicate=false,iLen,queueItem,queueItemKey,queueItemValue,sLen,supercedesCheck,qLen,queueItemCheck,queueItemCheckKey,queueItemCheckValue,i,s,q;if(property&&property.event){if(!Lang.isUndefined(value)&&property.validator&&!property.validator(value)){return false;}else{if(!Lang.isUndefined(value)){property.value=value;}else{value=property.value;} -foundDuplicate=false;iLen=this.eventQueue.length;for(i=0;i+ * Fix approach and original findings are available here: + * http://brianary.blogspot.com/2006/03/safari-date-bug.html + *
+ * @method _addDays + * @param {Date} d JavaScript date object + * @param {Number} nDays The number of days to add to the date object (can be negative) + * @private + */ + _addDays : function(d, nDays) { + if (YAHOO.env.ua.webkit && YAHOO.env.ua.webkit < 420) { + if (nDays < 0) { + // Ensure we don't go below -128 (getDate() is always 1 to 31, so we won't go above 127) + for(var min = -128; nDays < min; nDays -= min) { + d.setDate(d.getDate() + min); + } + } else { + // Ensure we don't go above 96 + 31 = 127 + for(var max = 96; nDays > max; nDays -= max) { + d.setDate(d.getDate() + max); + } + } + // nDays should be remainder between -128 and 96 + } + d.setDate(d.getDate() + nDays); + }, + /** * Subtracts the specified amount of time from the this instance. * @method subtract @@ -854,7 +874,7 @@ YAHOO.widget.DateMath = { * @return {Date} January 1 of the calendar year specified. */ getJan1 : function(calendarYear) { - return new Date(calendarYear,0,1); + return this.getDate(calendarYear,0,1); }, /** @@ -890,7 +910,7 @@ YAHOO.widget.DateMath = { date = this.clearTime(date); var nearestThurs = new Date(date.getTime() + (4 * this.ONE_DAY_MS) - ((date.getDay()) * this.ONE_DAY_MS)); - var jan1 = new Date(nearestThurs.getFullYear(),0,1); + var jan1 = this.getDate(nearestThurs.getFullYear(),0,1); var dayOfYear = ((nearestThurs.getTime() - jan1.getTime()) / this.ONE_DAY_MS) - 1; var weekNum = Math.ceil((dayOfYear)/ 7); @@ -934,7 +954,7 @@ YAHOO.widget.DateMath = { * @return {Date} The JavaScript Date representing the first day of the month */ findMonthStart : function(date) { - var start = new Date(date.getFullYear(), date.getMonth(), 1); + var start = this.getDate(date.getFullYear(), date.getMonth(), 1); return start; }, @@ -960,14 +980,46 @@ YAHOO.widget.DateMath = { clearTime : function(date) { date.setHours(12,0,0,0); return date; + }, + + /** + * Returns a new JavaScript Date object, representing the given year, month and date. Time fields (hr, min, sec, ms) on the new Date object + * are set to 0. The method allows Date instances to be created with the a year less than 100. "new Date(year, month, date)" implementations + * set the year to 19xx if a year (xx) which is less than 100 is provided. + *+ * NOTE:Validation on argument values is not performed. It is the caller's responsibility to ensure + * arguments are valid as per the ECMAScript-262 Date object specification for the new Date(year, month[, date]) constructor. + *
+ * @method getDate + * @param {Number} y Year. + * @param {Number} m Month index from 0 (Jan) to 11 (Dec). + * @param {Number} d (optional) Date from 1 to 31. If not provided, defaults to 1. + * @return {Date} The JavaScript date object with year, month, date set as provided. + */ + getDate : function(y, m, d) { + var dt = null; + if (YAHOO.lang.isUndefined(d)) { + d = 1; + } + if (y >= 100) { + dt = new Date(y, m, d); + } else { + dt = new Date(); + dt.setFullYear(y); + dt.setMonth(m); + dt.setDate(d); + dt.setHours(0,0,0,0); + } + return dt; } }; /** -* The Calendar component is a UI control that enables users to choose one or more dates from a graphical calendar presented in a one-month or multi-month interface. Calendars are generated entirely via script and can be navigated without any page refreshes. +* The Calendar component is a UI control that enables users to choose one or more dates from a graphical calendar presented in a one-month or +* multi-month interface. Calendars are generated entirely via script and can be navigated without any page refreshes. * @module calendar -* @title Calendar -* @namespace YAHOO.widget +* @title Calendar +* @namespace YAHOO.widget * @requires yahoo,dom,event */ @@ -979,18 +1031,39 @@ YAHOO.widget.DateMath = { *To construct the placeholder for the calendar widget, the code is as * follows: *
+* NOTE: As of 2.4.0, the constructor's ID argument is optional. +* The Calendar can be constructed by simply providing a container ID string, +* or a reference to a container DIV HTMLElement (the element needs to exist +* in the document). +* +* E.g.: +*
+* If not provided, the ID will be generated from the container DIV ID by adding an "_t" suffix. +* For example if an ID is not provided, and the container's ID is "calContainer", the Calendar's ID will be set to "calContainer_t". +*
+* * @namespace YAHOO.widget * @class Calendar * @constructor -* @param {String} id The id of the table element that will represent the calendar widget -* @param {String} containerId The id of the container div element that will wrap the calendar table -* @param {Object} config The configuration object containing the Calendar's arguments +* @param {String} id optional The id of the table element that will represent the Calendar widget. As of 2.4.0, this argument is optional. +* @param {String | HTMLElement} container The id of the container div element that will wrap the Calendar table, or a reference to a DIV element which exists in the document. +* @param {Object} config optional The configuration object containing the initial configuration values for the Calendar. */ YAHOO.widget.Calendar = function(id, containerId, config) { - this.init(id, containerId, config); + this.init.apply(this, arguments); }; /** @@ -1147,7 +1220,8 @@ YAHOO.widget.Calendar._DEFAULT_CONFIG = { MY_LABEL_MONTH_POSITION:{key:"my_label_month_position", value:1}, MY_LABEL_YEAR_POSITION:{key:"my_label_year_position", value:2}, MY_LABEL_MONTH_SUFFIX:{key:"my_label_month_suffix", value:" "}, - MY_LABEL_YEAR_SUFFIX:{key:"my_label_year_suffix", value:""} + MY_LABEL_YEAR_SUFFIX:{key:"my_label_year_suffix", value:""}, + NAV: {key:"navigator", value: null} }; /** @@ -1167,7 +1241,17 @@ YAHOO.widget.Calendar._EVENT_TYPES = { BEFORE_RENDER : "beforeRender", RENDER : "render", RESET : "reset", - CLEAR : "clear" + CLEAR : "clear", + BEFORE_HIDE : "beforeHide", + HIDE : "hide", + BEFORE_SHOW : "beforeShow", + SHOW : "show", + BEFORE_HIDE_NAV : "beforeHideNav", + HIDE_NAV : "hideNav", + BEFORE_SHOW_NAV : "beforeShowNav", + SHOW_NAV : "showNav", + BEFORE_RENDER_NAV : "beforeRenderNav", + RENDER_NAV : "renderNav" }; /** @@ -1200,6 +1284,7 @@ YAHOO.widget.Calendar._STYLES = { CSS_CONTAINER : "yui-calcontainer", CSS_NAV_LEFT : "calnavleft", CSS_NAV_RIGHT : "calnavright", + CSS_NAV : "calnav", CSS_CLOSE : "calclose", CSS_CELL_TOP : "calcelltop", CSS_CELL_LEFT : "calcellleft", @@ -1243,7 +1328,7 @@ YAHOO.widget.Calendar.prototype = { * @type HTMLTableCellElement[] */ cells : null, - + /** * The collection of calendar cell dates that is parallel to the cells collection. The array contains dates field arrays in the format of [YYYY, M, D]. * @property cellDates @@ -1252,12 +1337,19 @@ YAHOO.widget.Calendar.prototype = { cellDates : null, /** - * The id that uniquely identifies this calendar. This id should match the id of the placeholder element on the page. + * The id that uniquely identifies this Calendar. * @property id * @type String */ id : null, + /** + * The unique id associated with the Calendar's container + * @property containerId + * @type String + */ + containerId: null, + /** * The DOM element reference that points to this calendar's container element. The calendar will be inserted into this element when the shell is rendered. * @property oDomContainer @@ -1287,6 +1379,14 @@ YAHOO.widget.Calendar.prototype = { */ _renderStack : null, + /** + * A reference to the CalendarNavigator instance created for this Calendar. + * Will be null if the "navigator" configuration property has not been set + * @property oNavigator + * @type CalendarNavigator + */ + oNavigator : null, + /** * The private list of initially selected dates. * @property _selectedDates @@ -1300,3652 +1400,5392 @@ YAHOO.widget.Calendar.prototype = { * @property domEventMap * @type Object */ - domEventMap : null -}; - - - -/** -* Initializes the Calendar widget. -* @method init -* @param {String} id The id of the table element that will represent the calendar widget -* @param {String} containerId The id of the container div element that will wrap the calendar table -* @param {Object} config The configuration object containing the Calendar's arguments -*/ -YAHOO.widget.Calendar.prototype.init = function(id, containerId, config) { - this.initEvents(); - this.today = new Date(); - YAHOO.widget.DateMath.clearTime(this.today); - - this.id = id; - this.oDomContainer = document.getElementById(containerId); - - /** - * The Config object used to hold the configuration variables for the Calendar - * @property cfg - * @type YAHOO.util.Config - */ - this.cfg = new YAHOO.util.Config(this); - - /** - * The local object which contains the Calendar's options - * @property Options - * @type Object - */ - this.Options = {}; - - /** - * The local object which contains the Calendar's locale settings - * @property Locale - * @type Object - */ - this.Locale = {}; - - this.initStyles(); - - YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_CONTAINER); - YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_SINGLE); - - this.cellDates = []; - this.cells = []; - this.renderStack = []; - this._renderStack = []; - - this.setupConfig(); - - if (config) { - this.cfg.applyConfig(config, true); - } - - this.cfg.fireQueue(); -}; - -/** -* Default Config listener for the iframe property. If the iframe config property is set to true, -* renders the built-in IFRAME shim if the container is relatively or absolutely positioned. -* -* @method configIframe -*/ -YAHOO.widget.Calendar.prototype.configIframe = function(type, args, obj) { - var useIframe = args[0]; - - if (!this.parent) { - if (YAHOO.util.Dom.inDocument(this.oDomContainer)) { - if (useIframe) { - var pos = YAHOO.util.Dom.getStyle(this.oDomContainer, "position"); - - if (pos == "absolute" || pos == "relative") { - - if (!YAHOO.util.Dom.inDocument(this.iframe)) { - this.iframe = document.createElement("iframe"); - this.iframe.src = "javascript:false;"; - - YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0"); - - if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) { - YAHOO.util.Dom.addClass(this.iframe, "fixedsize"); - } - - this.oDomContainer.insertBefore(this.iframe, this.oDomContainer.firstChild); - } - } - } else { - if (this.iframe) { - if (this.iframe.parentNode) { - this.iframe.parentNode.removeChild(this.iframe); + domEventMap : null, + + /** + * Protected helper used to parse Calendar constructor/init arguments. + * + * As of 2.4.0, Calendar supports a simpler constructor + * signature. This method reconciles arguments + * received in the pre 2.4.0 and 2.4.0 formats. + * + * @protected + * @method _parseArgs + * @param {Array} Function "arguments" array + * @return {Object} Object with id, container, config properties containing + * the reconciled argument values. + **/ + _parseArgs : function(args) { + /* + 2.4.0 Constructors signatures + + new Calendar(String) + new Calendar(HTMLElement) + new Calendar(String, ConfigObject) + new Calendar(HTMLElement, ConfigObject) + + Pre 2.4.0 Constructor signatures + + new Calendar(String, String) + new Calendar(String, HTMLElement) + new Calendar(String, String, ConfigObject) + new Calendar(String, HTMLElement, ConfigObject) + */ + var nArgs = {id:null, container:null, config:null}; + + if (args && args.length && args.length > 0) { + switch (args.length) { + case 1: + nArgs.id = null; + nArgs.container = args[0]; + nArgs.config = null; + break; + case 2: + if (YAHOO.lang.isObject(args[1]) && !args[1].tagName && !(args[1] instanceof String)) { + nArgs.id = null; + nArgs.container = args[0]; + nArgs.config = args[1]; + } else { + nArgs.id = args[0]; + nArgs.container = args[1]; + nArgs.config = null; } - this.iframe = null; - } + break; + default: // 3+ + nArgs.id = args[0]; + nArgs.container = args[1]; + nArgs.config = args[2]; + break; } + } else { } - } -}; + return nArgs; + }, -/** -* Default handler for the "title" property -* @method configTitle -*/ -YAHOO.widget.Calendar.prototype.configTitle = function(type, args, obj) { - var title = args[0]; - var close = this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.CLOSE.key); - - var titleDiv; + /** + * Initializes the Calendar widget. + * @method init + * + * @param {String} id optional The id of the table element that will represent the Calendar widget. As of 2.4.0, this argument is optional. + * @param {String | HTMLElement} container The id of the container div element that will wrap the Calendar table, or a reference to a DIV element which exists in the document. + * @param {Object} config optional The configuration object containing the initial configuration values for the Calendar. + */ + init : function(id, container, config) { + // Normalize 2.4.0, pre 2.4.0 args + var nArgs = this._parseArgs(arguments); - if (title && title !== "") { - titleDiv = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE, "div", this.oDomContainer)[0] || document.createElement("div"); - titleDiv.className = YAHOO.widget.CalendarGroup.CSS_2UPTITLE; - titleDiv.innerHTML = title; - this.oDomContainer.insertBefore(titleDiv, this.oDomContainer.firstChild); - YAHOO.util.Dom.addClass(this.oDomContainer, "withtitle"); - } else { - titleDiv = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE, "div", this.oDomContainer)[0] || null; + id = nArgs.id; + container = nArgs.container; + config = nArgs.config; + + this.oDomContainer = YAHOO.util.Dom.get(container); - if (titleDiv) { - YAHOO.util.Event.purgeElement(titleDiv); - this.oDomContainer.removeChild(titleDiv); + if (!this.oDomContainer.id) { + this.oDomContainer.id = YAHOO.util.Dom.generateId(); } - if (! close) { - YAHOO.util.Dom.removeClass(this.oDomContainer, "withtitle"); + if (!id) { + id = this.oDomContainer.id + "_t"; } - } -}; -/** -* Default handler for the "close" property -* @method configClose -*/ -YAHOO.widget.Calendar.prototype.configClose = function(type, args, obj) { - var close = args[0]; - var title = this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.TITLE.key); - - var DEPR_CLOSE_PATH = "us/my/bn/x_d.gif"; + this.id = id; + this.containerId = this.oDomContainer.id; - var linkClose; + this.initEvents(); - if (close === true) { - linkClose = YAHOO.util.Dom.getElementsByClassName("link-close", "a", this.oDomContainer)[0] || document.createElement("a"); - linkClose.href = "#"; - linkClose.className = "link-close"; - YAHOO.util.Event.addListener(linkClose, "click", function(e, cal) {cal.hide(); YAHOO.util.Event.preventDefault(e); }, this); - - if (YAHOO.widget.Calendar.IMG_ROOT !== null) { - var imgClose = document.createElement("img"); - imgClose.src = YAHOO.widget.Calendar.IMG_ROOT + DEPR_CLOSE_PATH; - imgClose.className = YAHOO.widget.CalendarGroup.CSS_2UPCLOSE; - linkClose.appendChild(imgClose); - } else { - linkClose.innerHTML = ''; - } - - this.oDomContainer.appendChild(linkClose); - YAHOO.util.Dom.addClass(this.oDomContainer, "withtitle"); - } else { - linkClose = YAHOO.util.Dom.getElementsByClassName("link-close", "a", this.oDomContainer)[0] || null; - if (linkClose) { - YAHOO.util.Event.purgeElement(linkClose); - this.oDomContainer.removeChild(linkClose); - } - if (! title || title === "") { - YAHOO.util.Dom.removeClass(this.oDomContainer, "withtitle"); - } - } -}; + this.today = new Date(); + YAHOO.widget.DateMath.clearTime(this.today); -/** -* Initializes Calendar's built-in CustomEvents -* @method initEvents -*/ -YAHOO.widget.Calendar.prototype.initEvents = function() { + /** + * The Config object used to hold the configuration variables for the Calendar + * @property cfg + * @type YAHOO.util.Config + */ + this.cfg = new YAHOO.util.Config(this); - var defEvents = YAHOO.widget.Calendar._EVENT_TYPES; + /** + * The local object which contains the Calendar's options + * @property Options + * @type Object + */ + this.Options = {}; - /** - * Fired before a selection is made - * @event beforeSelectEvent - */ - this.beforeSelectEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_SELECT); + /** + * The local object which contains the Calendar's locale settings + * @property Locale + * @type Object + */ + this.Locale = {}; - /** - * Fired when a selection is made - * @event selectEvent - * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD]. - */ - this.selectEvent = new YAHOO.util.CustomEvent(defEvents.SELECT); + this.initStyles(); - /** - * Fired before a selection is made - * @event beforeDeselectEvent - */ - this.beforeDeselectEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_DESELECT); + YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_CONTAINER); + YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_SINGLE); - /** - * Fired when a selection is made - * @event deselectEvent - * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD]. - */ - this.deselectEvent = new YAHOO.util.CustomEvent(defEvents.DESELECT); + this.cellDates = []; + this.cells = []; + this.renderStack = []; + this._renderStack = []; - /** - * Fired when the Calendar page is changed - * @event changePageEvent - */ - this.changePageEvent = new YAHOO.util.CustomEvent(defEvents.CHANGE_PAGE); + this.setupConfig(); - /** - * Fired before the Calendar is rendered - * @event beforeRenderEvent - */ - this.beforeRenderEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_RENDER); + if (config) { + this.cfg.applyConfig(config, true); + } - /** - * Fired when the Calendar is rendered - * @event renderEvent - */ - this.renderEvent = new YAHOO.util.CustomEvent(defEvents.RENDER); + this.cfg.fireQueue(); + }, /** - * Fired when the Calendar is reset - * @event resetEvent + * Default Config listener for the iframe property. If the iframe config property is set to true, + * renders the built-in IFRAME shim if the container is relatively or absolutely positioned. + * + * @method configIframe */ - this.resetEvent = new YAHOO.util.CustomEvent(defEvents.RESET); + configIframe : function(type, args, obj) { + var useIframe = args[0]; + + if (!this.parent) { + if (YAHOO.util.Dom.inDocument(this.oDomContainer)) { + if (useIframe) { + var pos = YAHOO.util.Dom.getStyle(this.oDomContainer, "position"); + + if (pos == "absolute" || pos == "relative") { + + if (!YAHOO.util.Dom.inDocument(this.iframe)) { + this.iframe = document.createElement("iframe"); + this.iframe.src = "javascript:false;"; + + YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0"); + + if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) { + YAHOO.util.Dom.addClass(this.iframe, "fixedsize"); + } + + this.oDomContainer.insertBefore(this.iframe, this.oDomContainer.firstChild); + } + } + } else { + if (this.iframe) { + if (this.iframe.parentNode) { + this.iframe.parentNode.removeChild(this.iframe); + } + this.iframe = null; + } + } + } + } + }, /** - * Fired when the Calendar is cleared - * @event clearEvent + * Default handler for the "title" property + * @method configTitle */ - this.clearEvent = new YAHOO.util.CustomEvent(defEvents.CLEAR); - - this.beforeSelectEvent.subscribe(this.onBeforeSelect, this, true); - this.selectEvent.subscribe(this.onSelect, this, true); - this.beforeDeselectEvent.subscribe(this.onBeforeDeselect, this, true); - this.deselectEvent.subscribe(this.onDeselect, this, true); - this.changePageEvent.subscribe(this.onChangePage, this, true); - this.renderEvent.subscribe(this.onRender, this, true); - this.resetEvent.subscribe(this.onReset, this, true); - this.clearEvent.subscribe(this.onClear, this, true); -}; - -/** -* The default event function that is attached to a date link within a calendar cell -* when the calendar is rendered. -* @method doSelectCell -* @param {DOMEvent} e The event -* @param {Calendar} cal A reference to the calendar passed by the Event utility -*/ -YAHOO.widget.Calendar.prototype.doSelectCell = function(e, cal) { - var cell,index,d,date; - - var target = YAHOO.util.Event.getTarget(e); - var tagName = target.tagName.toLowerCase(); - var defSelector = false; - - while (tagName != "td" && ! YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) { + configTitle : function(type, args, obj) { + var title = args[0]; - if (!defSelector && tagName == "a" && YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTOR)) { - defSelector = true; - } - - target = target.parentNode; - tagName = target.tagName.toLowerCase(); - if (tagName == "html") { - return; + // "" disables title bar + if (title) { + this.createTitleBar(title); + } else { + var close = this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.CLOSE.key); + if (!close) { + this.removeTitleBar(); + } else { + this.createTitleBar(" "); + } } - } - - if (defSelector) { - // Stop link href navigation for default renderer - YAHOO.util.Event.preventDefault(e); - } - - cell = target; - - if (YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_SELECTABLE)) { - index = cell.id.split("cell")[1]; - d = cal.cellDates[index]; - date = new Date(d[0],d[1]-1,d[2]); + }, - var link; - - if (cal.Options.MULTI_SELECT) { - link = cell.getElementsByTagName("a")[0]; - if (link) { - link.blur(); + /** + * Default handler for the "close" property + * @method configClose + */ + configClose : function(type, args, obj) { + var close = args[0], + title = this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.TITLE.key); + + if (close) { + if (!title) { + this.createTitleBar(" "); } - - var cellDate = cal.cellDates[index]; - var cellDateIndex = cal._indexOfSelectedFieldArray(cellDate); - - if (cellDateIndex > -1) { - cal.deselectCell(index); - } else { - cal.selectCell(index); - } - + this.createCloseButton(); } else { - link = cell.getElementsByTagName("a")[0]; - if (link) { - link.blur(); + this.removeCloseButton(); + if (!title) { + this.removeTitleBar(); } - cal.selectCell(index); } - } -}; - -/** -* The event that is executed when the user hovers over a cell -* @method doCellMouseOver -* @param {DOMEvent} e The event -* @param {Calendar} cal A reference to the calendar passed by the Event utility -*/ -YAHOO.widget.Calendar.prototype.doCellMouseOver = function(e, cal) { - var target; - if (e) { - target = YAHOO.util.Event.getTarget(e); - } else { - target = this; - } - - while (target.tagName.toLowerCase() != "td") { - target = target.parentNode; - if (target.tagName.toLowerCase() == "html") { - return; - } - } - - if (YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) { - YAHOO.util.Dom.addClass(target, cal.Style.CSS_CELL_HOVER); - } -}; - -/** -* The event that is executed when the user moves the mouse out of a cell -* @method doCellMouseOut -* @param {DOMEvent} e The event -* @param {Calendar} cal A reference to the calendar passed by the Event utility -*/ -YAHOO.widget.Calendar.prototype.doCellMouseOut = function(e, cal) { - var target; - if (e) { - target = YAHOO.util.Event.getTarget(e); - } else { - target = this; - } - - while (target.tagName.toLowerCase() != "td") { - target = target.parentNode; - if (target.tagName.toLowerCase() == "html") { - return; - } - } - - if (YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) { - YAHOO.util.Dom.removeClass(target, cal.Style.CSS_CELL_HOVER); - } -}; - -YAHOO.widget.Calendar.prototype.setupConfig = function() { - - var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; - - /** - * The month/year representing the current visible Calendar date (mm/yyyy) - * @config pagedate - * @type String - * @default today's date - */ - this.cfg.addProperty(defCfg.PAGEDATE.key, { value:new Date(), handler:this.configPageDate } ); - - /** - * The date or range of dates representing the current Calendar selection - * @config selected - * @type String - * @default [] - */ - this.cfg.addProperty(defCfg.SELECTED.key, { value:[], handler:this.configSelected } ); - - /** - * The title to display above the Calendar's month header - * @config title - * @type String - * @default "" - */ - this.cfg.addProperty(defCfg.TITLE.key, { value:defCfg.TITLE.value, handler:this.configTitle } ); - - /** - * Whether or not a close button should be displayed for this Calendar - * @config close - * @type Boolean - * @default false - */ - this.cfg.addProperty(defCfg.CLOSE.key, { value:defCfg.CLOSE.value, handler:this.configClose } ); - - /** - * Whether or not an iframe shim should be placed under the Calendar to prevent select boxes from bleeding through in Internet Explorer 6 and below. - * This property is enabled by default for IE6 and below. It is disabled by default for other browsers for performance reasons, but can be - * enabled if required. - * - * @config iframe - * @type Boolean - * @default true for IE6 and below, false for all other browsers - */ - this.cfg.addProperty(defCfg.IFRAME.key, { value:defCfg.IFRAME.value, handler:this.configIframe, validator:this.cfg.checkBoolean } ); - - /** - * The minimum selectable date in the current Calendar (mm/dd/yyyy) - * @config mindate - * @type String - * @default null - */ - this.cfg.addProperty(defCfg.MINDATE.key, { value:defCfg.MINDATE.value, handler:this.configMinDate } ); - - /** - * The maximum selectable date in the current Calendar (mm/dd/yyyy) - * @config maxdate - * @type String - * @default null - */ - this.cfg.addProperty(defCfg.MAXDATE.key, { value:defCfg.MAXDATE.value, handler:this.configMaxDate } ); - - - // Options properties - - /** - * True if the Calendar should allow multiple selections. False by default. - * @config MULTI_SELECT - * @type Boolean - * @default false - */ - this.cfg.addProperty(defCfg.MULTI_SELECT.key, { value:defCfg.MULTI_SELECT.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - - /** - * The weekday the week begins on. Default is 0 (Sunday). - * @config START_WEEKDAY - * @type number - * @default 0 - */ - this.cfg.addProperty(defCfg.START_WEEKDAY.key, { value:defCfg.START_WEEKDAY.value, handler:this.configOptions, validator:this.cfg.checkNumber } ); - - /** - * True if the Calendar should show weekday labels. True by default. - * @config SHOW_WEEKDAYS - * @type Boolean - * @default true - */ - this.cfg.addProperty(defCfg.SHOW_WEEKDAYS.key, { value:defCfg.SHOW_WEEKDAYS.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - - /** - * True if the Calendar should show week row headers. False by default. - * @config SHOW_WEEK_HEADER - * @type Boolean - * @default false - */ - this.cfg.addProperty(defCfg.SHOW_WEEK_HEADER.key, { value:defCfg.SHOW_WEEK_HEADER.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - - /** - * True if the Calendar should show week row footers. False by default. - * @config SHOW_WEEK_FOOTER - * @type Boolean - * @default false - */ - this.cfg.addProperty(defCfg.SHOW_WEEK_FOOTER.key,{ value:defCfg.SHOW_WEEK_FOOTER.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - - /** - * True if the Calendar should suppress weeks that are not a part of the current month. False by default. - * @config HIDE_BLANK_WEEKS - * @type Boolean - * @default false - */ - this.cfg.addProperty(defCfg.HIDE_BLANK_WEEKS.key, { value:defCfg.HIDE_BLANK_WEEKS.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - - /** - * The image that should be used for the left navigation arrow. - * @config NAV_ARROW_LEFT - * @type String - * @deprecated You can customize the image by overriding the default CSS class for the left arrow - "calnavleft" - * @default null - */ - this.cfg.addProperty(defCfg.NAV_ARROW_LEFT.key, { value:defCfg.NAV_ARROW_LEFT.value, handler:this.configOptions } ); - - /** - * The image that should be used for the right navigation arrow. - * @config NAV_ARROW_RIGHT - * @type String - * @deprecated You can customize the image by overriding the default CSS class for the right arrow - "calnavright" - * @default null - */ - this.cfg.addProperty(defCfg.NAV_ARROW_RIGHT.key, { value:defCfg.NAV_ARROW_RIGHT.value, handler:this.configOptions } ); - - // Locale properties - - /** - * The short month labels for the current locale. - * @config MONTHS_SHORT - * @type String[] - * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] - */ - this.cfg.addProperty(defCfg.MONTHS_SHORT.key, { value:defCfg.MONTHS_SHORT.value, handler:this.configLocale } ); - - /** - * The long month labels for the current locale. - * @config MONTHS_LONG - * @type String[] - * @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" - */ - this.cfg.addProperty(defCfg.MONTHS_LONG.key, { value:defCfg.MONTHS_LONG.value, handler:this.configLocale } ); - - /** - * The 1-character weekday labels for the current locale. - * @config WEEKDAYS_1CHAR - * @type String[] - * @default ["S", "M", "T", "W", "T", "F", "S"] - */ - this.cfg.addProperty(defCfg.WEEKDAYS_1CHAR.key, { value:defCfg.WEEKDAYS_1CHAR.value, handler:this.configLocale } ); - - /** - * The short weekday labels for the current locale. - * @config WEEKDAYS_SHORT - * @type String[] - * @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"] - */ - this.cfg.addProperty(defCfg.WEEKDAYS_SHORT.key, { value:defCfg.WEEKDAYS_SHORT.value, handler:this.configLocale } ); - - /** - * The medium weekday labels for the current locale. - * @config WEEKDAYS_MEDIUM - * @type String[] - * @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] - */ - this.cfg.addProperty(defCfg.WEEKDAYS_MEDIUM.key, { value:defCfg.WEEKDAYS_MEDIUM.value, handler:this.configLocale } ); - - /** - * The long weekday labels for the current locale. - * @config WEEKDAYS_LONG - * @type String[] - * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] - */ - this.cfg.addProperty(defCfg.WEEKDAYS_LONG.key, { value:defCfg.WEEKDAYS_LONG.value, handler:this.configLocale } ); - - /** - * Refreshes the locale values used to build the Calendar. - * @method refreshLocale - * @private - */ - var refreshLocale = function() { - this.cfg.refireEvent(defCfg.LOCALE_MONTHS.key); - this.cfg.refireEvent(defCfg.LOCALE_WEEKDAYS.key); - }; - - this.cfg.subscribeToConfigEvent(defCfg.START_WEEKDAY.key, refreshLocale, this, true); - this.cfg.subscribeToConfigEvent(defCfg.MONTHS_SHORT.key, refreshLocale, this, true); - this.cfg.subscribeToConfigEvent(defCfg.MONTHS_LONG.key, refreshLocale, this, true); - this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_1CHAR.key, refreshLocale, this, true); - this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_SHORT.key, refreshLocale, this, true); - this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_MEDIUM.key, refreshLocale, this, true); - this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_LONG.key, refreshLocale, this, true); - - /** - * The setting that determines which length of month labels should be used. Possible values are "short" and "long". - * @config LOCALE_MONTHS - * @type String - * @default "long" - */ - this.cfg.addProperty(defCfg.LOCALE_MONTHS.key, { value:defCfg.LOCALE_MONTHS.value, handler:this.configLocaleValues } ); - - /** - * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long". - * @config LOCALE_WEEKDAYS - * @type String - * @default "short" - */ - this.cfg.addProperty(defCfg.LOCALE_WEEKDAYS.key, { value:defCfg.LOCALE_WEEKDAYS.value, handler:this.configLocaleValues } ); - - /** - * The value used to delimit individual dates in a date string passed to various Calendar functions. - * @config DATE_DELIMITER - * @type String - * @default "," - */ - this.cfg.addProperty(defCfg.DATE_DELIMITER.key, { value:defCfg.DATE_DELIMITER.value, handler:this.configLocale } ); - - /** - * The value used to delimit date fields in a date string passed to various Calendar functions. - * @config DATE_FIELD_DELIMITER - * @type String - * @default "/" - */ - this.cfg.addProperty(defCfg.DATE_FIELD_DELIMITER.key, { value:defCfg.DATE_FIELD_DELIMITER.value, handler:this.configLocale } ); - - /** - * The value used to delimit date ranges in a date string passed to various Calendar functions. - * @config DATE_RANGE_DELIMITER - * @type String - * @default "-" - */ - this.cfg.addProperty(defCfg.DATE_RANGE_DELIMITER.key, { value:defCfg.DATE_RANGE_DELIMITER.value, handler:this.configLocale } ); - - /** - * The position of the month in a month/year date string - * @config MY_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty(defCfg.MY_MONTH_POSITION.key, { value:defCfg.MY_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the year in a month/year date string - * @config MY_YEAR_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty(defCfg.MY_YEAR_POSITION.key, { value:defCfg.MY_YEAR_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the month in a month/day date string - * @config MD_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty(defCfg.MD_MONTH_POSITION.key, { value:defCfg.MD_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the day in a month/year date string - * @config MD_DAY_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty(defCfg.MD_DAY_POSITION.key, { value:defCfg.MD_DAY_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the month in a month/day/year date string - * @config MDY_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty(defCfg.MDY_MONTH_POSITION.key, { value:defCfg.MDY_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the day in a month/day/year date string - * @config MDY_DAY_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty(defCfg.MDY_DAY_POSITION.key, { value:defCfg.MDY_DAY_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the year in a month/day/year date string - * @config MDY_YEAR_POSITION - * @type Number - * @default 3 - */ - this.cfg.addProperty(defCfg.MDY_YEAR_POSITION.key, { value:defCfg.MDY_YEAR_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the month in the month year label string used as the Calendar header - * @config MY_LABEL_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty(defCfg.MY_LABEL_MONTH_POSITION.key, { value:defCfg.MY_LABEL_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the year in the month year label string used as the Calendar header - * @config MY_LABEL_YEAR_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty(defCfg.MY_LABEL_YEAR_POSITION.key, { value:defCfg.MY_LABEL_YEAR_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); + }, /** - * The suffix used after the month when rendering the Calendar header - * @config MY_LABEL_MONTH_SUFFIX - * @type String - * @default " " + * Initializes Calendar's built-in CustomEvents + * @method initEvents */ - this.cfg.addProperty(defCfg.MY_LABEL_MONTH_SUFFIX.key, { value:defCfg.MY_LABEL_MONTH_SUFFIX.value, handler:this.configLocale } ); + initEvents : function() { - /** - * The suffix used after the year when rendering the Calendar header - * @config MY_LABEL_YEAR_SUFFIX - * @type String - * @default "" - */ - this.cfg.addProperty(defCfg.MY_LABEL_YEAR_SUFFIX.key, { value:defCfg.MY_LABEL_YEAR_SUFFIX.value, handler:this.configLocale } ); -}; - -/** -* The default handler for the "pagedate" property -* @method configPageDate -*/ -YAHOO.widget.Calendar.prototype.configPageDate = function(type, args, obj) { - this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key, this._parsePageDate(args[0]), true); -}; - -/** -* The default handler for the "mindate" property -* @method configMinDate -*/ -YAHOO.widget.Calendar.prototype.configMinDate = function(type, args, obj) { - var val = args[0]; - if (YAHOO.lang.isString(val)) { - val = this._parseDate(val); - this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MINDATE.key, new Date(val[0],(val[1]-1),val[2])); - } -}; - -/** -* The default handler for the "maxdate" property -* @method configMaxDate -*/ -YAHOO.widget.Calendar.prototype.configMaxDate = function(type, args, obj) { - var val = args[0]; - if (YAHOO.lang.isString(val)) { - val = this._parseDate(val); - this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MAXDATE.key, new Date(val[0],(val[1]-1),val[2])); - } -}; - -/** -* The default handler for the "selected" property -* @method configSelected -*/ -YAHOO.widget.Calendar.prototype.configSelected = function(type, args, obj) { - var selected = args[0]; - var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key; + var defEvents = YAHOO.widget.Calendar._EVENT_TYPES; - if (selected) { - if (YAHOO.lang.isString(selected)) { - this.cfg.setProperty(cfgSelected, this._parseDates(selected), true); - } - } - if (! this._selectedDates) { - this._selectedDates = this.cfg.getProperty(cfgSelected); - } -}; - -/** -* The default handler for all configuration options properties -* @method configOptions -*/ -YAHOO.widget.Calendar.prototype.configOptions = function(type, args, obj) { - this.Options[type.toUpperCase()] = args[0]; -}; - -/** -* The default handler for all configuration locale properties -* @method configLocale -*/ -YAHOO.widget.Calendar.prototype.configLocale = function(type, args, obj) { - var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; - this.Locale[type.toUpperCase()] = args[0]; - - this.cfg.refireEvent(defCfg.LOCALE_MONTHS.key); - this.cfg.refireEvent(defCfg.LOCALE_WEEKDAYS.key); -}; - -/** -* The default handler for all configuration locale field length properties -* @method configLocaleValues -*/ -YAHOO.widget.Calendar.prototype.configLocaleValues = function(type, args, obj) { - var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; - - type = type.toLowerCase(); - var val = args[0]; - - switch (type) { - case defCfg.LOCALE_MONTHS.key: - switch (val) { - case YAHOO.widget.Calendar.SHORT: - this.Locale.LOCALE_MONTHS = this.cfg.getProperty(defCfg.MONTHS_SHORT.key).concat(); - break; - case YAHOO.widget.Calendar.LONG: - this.Locale.LOCALE_MONTHS = this.cfg.getProperty(defCfg.MONTHS_LONG.key).concat(); - break; - } - break; - case defCfg.LOCALE_WEEKDAYS.key: - switch (val) { - case YAHOO.widget.Calendar.ONE_CHAR: - this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_1CHAR.key).concat(); - break; - case YAHOO.widget.Calendar.SHORT: - this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_SHORT.key).concat(); - break; - case YAHOO.widget.Calendar.MEDIUM: - this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_MEDIUM.key).concat(); - break; - case YAHOO.widget.Calendar.LONG: - this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_LONG.key).concat(); - break; - } - - var START_WEEKDAY = this.cfg.getProperty(defCfg.START_WEEKDAY.key); - - if (START_WEEKDAY > 0) { - for (var w=0;w+ * Setting this property to true will enable the CalendarNavigatior UI with the default CalendarNavigator configuration values. + *
+ *+ * This property can also be set to an object literal containing configuration properties for the CalendarNavigator UI. + * The configuration object expects the the following case-sensitive properties, with the "strings" property being a nested object. + * Any properties which are not provided will use the default values (defined in the CalendarNavigator class). + *
+ *E.g.
+ *+ * var navConfig = { + * strings: { + * month:"Calendar Month", + * year:"Calendar Year", + * submit: "Submit", + * cancel: "Cancel", + * invalidYear: "Please enter a valid year" + * }, + * monthFormat: YAHOO.widget.Calendar.SHORT, + * initialFocus: "month" + * } + *+ * @config navigator + * @type {Object|Boolean} + * @default null + */ + this.cfg.addProperty(defCfg.NAV.key, { value:defCfg.NAV.value, handler:this.configNavigator } ); + }, - var rArray = this.renderStack[s]; - var type = rArray[0]; - - var month; - var day; - var year; - - switch (type) { - case YAHOO.widget.Calendar.DATE: - month = rArray[1][1]; - day = rArray[1][2]; - year = rArray[1][0]; - - if (workingDate.getMonth()+1 == month && workingDate.getDate() == day && workingDate.getFullYear() == year) { - renderer = rArray[2]; - this.renderStack.splice(s,1); - } - break; - case YAHOO.widget.Calendar.MONTH_DAY: - month = rArray[1][0]; - day = rArray[1][1]; - - if (workingDate.getMonth()+1 == month && workingDate.getDate() == day) { - renderer = rArray[2]; - this.renderStack.splice(s,1); - } - break; - case YAHOO.widget.Calendar.RANGE: - var date1 = rArray[1][0]; - var date2 = rArray[1][1]; - - var d1month = date1[1]; - var d1day = date1[2]; - var d1year = date1[0]; - - var d1 = new Date(d1year, d1month-1, d1day); - - var d2month = date2[1]; - var d2day = date2[2]; - var d2year = date2[0]; - - var d2 = new Date(d2year, d2month-1, d2day); - - if (workingDate.getTime() >= d1.getTime() && workingDate.getTime() <= d2.getTime()) { - renderer = rArray[2]; - - if (workingDate.getTime()==d2.getTime()) { - this.renderStack.splice(s,1); - } - } - break; - case YAHOO.widget.Calendar.WEEKDAY: - - var weekday = rArray[1][0]; - if (workingDate.getDay()+1 == weekday) { - renderer = rArray[2]; - } - break; - case YAHOO.widget.Calendar.MONTH: - - month = rArray[1][0]; - if (workingDate.getMonth()+1 == month) { - renderer = rArray[2]; - } - break; - } - - if (renderer) { - cellRenderers[cellRenderers.length]=renderer; - } - } + /** + * The default handler for the "pagedate" property + * @method configPageDate + */ + configPageDate : function(type, args, obj) { + this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key, this._parsePageDate(args[0]), true); + }, - } + /** + * The default handler for the "mindate" property + * @method configMinDate + */ + configMinDate : function(type, args, obj) { + var val = args[0]; + if (YAHOO.lang.isString(val)) { + val = this._parseDate(val); + this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MINDATE.key, YAHOO.widget.DateMath.getDate(val[0],(val[1]-1),val[2])); + } + }, - if (this._indexOfSelectedFieldArray(workingArray) > -1) { - cellRenderers[cellRenderers.length]=cal.renderCellStyleSelected; + /** + * The default handler for the "maxdate" property + * @method configMaxDate + */ + configMaxDate : function(type, args, obj) { + var val = args[0]; + if (YAHOO.lang.isString(val)) { + val = this._parseDate(val); + this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MAXDATE.key, YAHOO.widget.DateMath.getDate(val[0],(val[1]-1),val[2])); + } + }, + + /** + * The default handler for the "selected" property + * @method configSelected + */ + configSelected : function(type, args, obj) { + var selected = args[0]; + var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key; + + if (selected) { + if (YAHOO.lang.isString(selected)) { + this.cfg.setProperty(cfgSelected, this._parseDates(selected), true); + } + } + if (! this._selectedDates) { + this._selectedDates = this.cfg.getProperty(cfgSelected); + } + }, + + /** + * The default handler for all configuration options properties + * @method configOptions + */ + configOptions : function(type, args, obj) { + this.Options[type.toUpperCase()] = args[0]; + }, + + /** + * The default handler for all configuration locale properties + * @method configLocale + */ + configLocale : function(type, args, obj) { + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + this.Locale[type.toUpperCase()] = args[0]; + + this.cfg.refireEvent(defCfg.LOCALE_MONTHS.key); + this.cfg.refireEvent(defCfg.LOCALE_WEEKDAYS.key); + }, + + /** + * The default handler for all configuration locale field length properties + * @method configLocaleValues + */ + configLocaleValues : function(type, args, obj) { + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + + type = type.toLowerCase(); + var val = args[0]; + + switch (type) { + case defCfg.LOCALE_MONTHS.key: + switch (val) { + case YAHOO.widget.Calendar.SHORT: + this.Locale.LOCALE_MONTHS = this.cfg.getProperty(defCfg.MONTHS_SHORT.key).concat(); + break; + case YAHOO.widget.Calendar.LONG: + this.Locale.LOCALE_MONTHS = this.cfg.getProperty(defCfg.MONTHS_LONG.key).concat(); + break; } - - if ((mindate && (workingDate.getTime() < mindate.getTime())) || - (maxdate && (workingDate.getTime() > maxdate.getTime())) - ) { - cellRenderers[cellRenderers.length]=cal.renderOutOfBoundsDate; - } else { - cellRenderers[cellRenderers.length]=cal.styleCellDefault; - cellRenderers[cellRenderers.length]=cal.renderCellDefault; + break; + case defCfg.LOCALE_WEEKDAYS.key: + switch (val) { + case YAHOO.widget.Calendar.ONE_CHAR: + this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_1CHAR.key).concat(); + break; + case YAHOO.widget.Calendar.SHORT: + this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_SHORT.key).concat(); + break; + case YAHOO.widget.Calendar.MEDIUM: + this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_MEDIUM.key).concat(); + break; + case YAHOO.widget.Calendar.LONG: + this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_LONG.key).concat(); + break; } - for (var x=0; x < cellRenderers.length; ++x) { - if (cellRenderers[x].call(cal, workingDate, cell) == YAHOO.widget.Calendar.STOP_RENDER) { - break; + var START_WEEKDAY = this.cfg.getProperty(defCfg.START_WEEKDAY.key); + + if (START_WEEKDAY > 0) { + for (var w=0;w
+* NOTE: As of 2.4.0, the constructor's ID argument is optional. +* The CalendarGroup can be constructed by simply providing a container ID string, +* or a reference to a container DIV HTMLElement (the element needs to exist +* in the document). +* +* E.g.: +*
+* If not provided, the ID will be generated from the container DIV ID by adding an "_t" suffix. +* For example if an ID is not provided, and the container's ID is "calContainer", the CalendarGroup's ID will be set to "calContainer_t". +*
+* +* @namespace YAHOO.widget +* @class CalendarGroup +* @constructor +* @param {String} id optional The id of the table element that will represent the CalendarGroup widget. As of 2.4.0, this argument is optional. +* @param {String | HTMLElement} container The id of the container div element that will wrap the CalendarGroup table, or a reference to a DIV element which exists in the document. +* @param {Object} config optional The configuration object containing the initial configuration values for the CalendarGroup. +*/ +YAHOO.widget.CalendarGroup = function(id, containerId, config) { + if (arguments.length > 0) { + this.init.apply(this, arguments); } - - YAHOO.util.Event.addListener(this.oDomContainer, "click", this.doSelectCell, this); - YAHOO.util.Event.addListener(this.oDomContainer, "mouseover", this.doCellMouseOver, this); - YAHOO.util.Event.addListener(this.oDomContainer, "mouseout", this.doCellMouseOut, this); }; -/** -* Retrieves the Date object for the specified Calendar cell -* @method getDateByCellId -* @param {String} id The id of the cell -* @return {Date} The Date object for the specified Calendar cell -*/ -YAHOO.widget.Calendar.prototype.getDateByCellId = function(id) { - var date = this.getDateFieldsByCellId(id); - return new Date(date[0],date[1]-1,date[2]); -}; +YAHOO.widget.CalendarGroup.prototype = { -/** -* Retrieves the Date object for the specified Calendar cell -* @method getDateFieldsByCellId -* @param {String} id The id of the cell -* @return {Array} The array of Date fields for the specified Calendar cell -*/ -YAHOO.widget.Calendar.prototype.getDateFieldsByCellId = function(id) { - id = id.toLowerCase().split("_cell")[1]; - id = parseInt(id, 10); - return this.cellDates[id]; -}; + /** + * Initializes the calendar group. All subclasses must call this method in order for the + * group to be initialized properly. + * @method init + * @param {String} id optional The id of the table element that will represent the CalendarGroup widget. As of 2.4.0, this argument is optional. + * @param {String | HTMLElement} container The id of the container div element that will wrap the CalendarGroup table, or a reference to a DIV element which exists in the document. + * @param {Object} config optional The configuration object containing the initial configuration values for the CalendarGroup. + */ + init : function(id, container, config) { -// BEGIN BUILT-IN TABLE CELL RENDERERS + // Normalize 2.4.0, pre 2.4.0 args + var nArgs = this._parseArgs(arguments); -/** -* Renders a cell that falls before the minimum date or after the maximum date. -* widget class. -* @method renderOutOfBoundsDate -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering -* should not be terminated -*/ -YAHOO.widget.Calendar.prototype.renderOutOfBoundsDate = function(workingDate, cell) { - YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOB); - cell.innerHTML = workingDate.getDate(); - return YAHOO.widget.Calendar.STOP_RENDER; -}; + id = nArgs.id; + container = nArgs.container; + config = nArgs.config; -/** -* Renders the row header for a week. -* @method renderRowHeader -* @param {Number} weekNum The week number of the current row -* @param {Array} cell The current working HTML array -*/ -YAHOO.widget.Calendar.prototype.renderRowHeader = function(weekNum, html) { - html[html.length] = '+ * The method will call applyKeyListeners, to setup keyboard specific + * listeners + *
+ * @method applyListeners + */ + applyListeners : function() { + var E = YAHOO.util.Event; - for (var p=0;p+ * See applyKeyListeners + *
+ * @protected + * @method _setFirstLastElements + */ + _setFirstLastElements : function() { + this.firstCtrl = this.monthEl; + this.lastCtrl = this.cancelEl; + + // Special handling for MacOSX. + // - Safari 2.x can't focus on buttons + // - Gecko can't focus on select boxes or buttons + if (this.__isMac) { + if (YAHOO.env.ua.webkit && YAHOO.env.ua.webkit < 420){ + this.firstCtrl = this.monthEl; + this.lastCtrl = this.yearEl; + } + if (YAHOO.env.ua.gecko) { + this.firstCtrl = this.yearEl; + this.lastCtrl = this.yearEl; + } + } + }, -/** -* The set of default Config property keys and values for the CalendarGroup -* @property YAHOO.widget.CalendarGroup._DEFAULT_CONFIG -* @final -* @static -* @private -* @type Object -*/ -YAHOO.widget.CalendarGroup._DEFAULT_CONFIG = YAHOO.widget.Calendar._DEFAULT_CONFIG; -YAHOO.widget.CalendarGroup._DEFAULT_CONFIG.PAGES = {key:"pages", value:2}; + /** + * Default Keyboard event handler to capture Enter + * on the Navigator's year control (yearEl) + * + * @method _handleEnterKey + * @protected + * @param {Event} e The DOM event being handled + */ + _handleEnterKey : function(e) { + var KEYS = YAHOO.util.KeyListener.KEY; -/** -* Returns a string representation of the object. -* @method toString -* @return {String} A string representation of the CalendarGroup object. -*/ -YAHOO.widget.CalendarGroup.prototype.toString = function() { - return "CalendarGroup " + this.id; -}; + if (YAHOO.util.Event.getCharCode(e) == KEYS.ENTER) { + YAHOO.util.Event.preventDefault(e); + this.submit(); + } + }, -YAHOO.widget.CalGrp = YAHOO.widget.CalendarGroup; + /** + * Default Keyboard event handler to capture up/down/pgup/pgdown + * on the Navigator's year control (yearEl). + * + * @method _handleDirectionKeys + * @protected + * @param {Event} e The DOM event being handled + */ + _handleDirectionKeys : function(e) { + var E = YAHOO.util.Event; + var KEYS = YAHOO.util.KeyListener.KEY; + var NAV = YAHOO.widget.CalendarNavigator; + + var value = (this.yearEl.value) ? parseInt(this.yearEl.value, 10) : null; + if (isFinite(value)) { + var dir = false; + switch(E.getCharCode(e)) { + case KEYS.UP: + this.yearEl.value = value + NAV.YR_MINOR_INC; + dir = true; + break; + case KEYS.DOWN: + this.yearEl.value = Math.max(value - NAV.YR_MINOR_INC, 0); + dir = true; + break; + case KEYS.PAGE_UP: + this.yearEl.value = value + NAV.YR_MAJOR_INC; + dir = true; + break; + case KEYS.PAGE_DOWN: + this.yearEl.value = Math.max(value - NAV.YR_MAJOR_INC, 0); + dir = true; + break; + default: + break; + } + if (dir) { + E.preventDefault(e); + try { + this.yearEl.select(); + } catch(e) { + // Ignore + } + } + } + }, -/** -* @class YAHOO.widget.Calendar2up -* @extends YAHOO.widget.CalendarGroup -* @deprecated The old Calendar2up class is no longer necessary, since CalendarGroup renders in a 2up view by default. -*/ -YAHOO.widget.Calendar2up = function(id, containerId, config) { - this.init(id, containerId, config); -}; + /** + * Default Keyboard event handler to capture Tab + * on the last control (lastCtrl) in the Navigator. + * + * @method _handleTabKey + * @protected + * @param {Event} e The DOM event being handled + */ + _handleTabKey : function(e) { + var E = YAHOO.util.Event; + var KEYS = YAHOO.util.KeyListener.KEY; + + if (E.getCharCode(e) == KEYS.TAB && !e.shiftKey) { + try { + E.preventDefault(e); + this.firstCtrl.focus(); + } catch (e) { + // Ignore - mainly for focus edge cases + } + } + }, -YAHOO.extend(YAHOO.widget.Calendar2up, YAHOO.widget.CalendarGroup); + /** + * Default Keyboard event handler to capture Shift-Tab + * on the first control (firstCtrl) in the Navigator. + * + * @method _handleShiftTabKey + * @protected + * @param {Event} e The DOM event being handled + */ + _handleShiftTabKey : function(e) { + var E = YAHOO.util.Event; + var KEYS = YAHOO.util.KeyListener.KEY; + + if (e.shiftKey && E.getCharCode(e) == KEYS.TAB) { + try { + E.preventDefault(e); + this.lastCtrl.focus(); + } catch (e) { + // Ignore - mainly for focus edge cases + } + } + }, -/** -* @deprecated The old Calendar2up class is no longer necessary, since CalendarGroup renders in a 2up view by default. -*/ -YAHOO.widget.Cal2up = YAHOO.widget.Calendar2up; + /** + * Retrieve Navigator configuration values from + * the parent Calendar/CalendarGroup's config value. + *+ * If it has not been set in the user provided configuration, the method will + * return the default value of the configuration property, as set in _DEFAULT_CFG + *
+ * @private + * @method __getCfg + * @param {String} Case sensitive property name. + * @param {Boolean} true, if the property is a string property, false if not. + * @return The value of the configuration property + */ + __getCfg : function(prop, bIsStr) { + var DEF_CFG = YAHOO.widget.CalendarNavigator._DEFAULT_CFG; + var cfg = this.cal.cfg.getProperty("navigator"); + + if (bIsStr) { + return (cfg !== true && cfg.strings && cfg.strings[prop]) ? cfg.strings[prop] : DEF_CFG.strings[prop]; + } else { + return (cfg !== true && cfg[prop]) ? cfg[prop] : DEF_CFG[prop]; + } + }, + + /** + * Private flag, to identify MacOS + * @private + * @property __isMac + */ + __isMac : (navigator.userAgent.toLowerCase().indexOf("macintosh") != -1) + +}; -YAHOO.register("calendar", YAHOO.widget.Calendar, {version: "2.3.0", build: "442"}); +YAHOO.register("calendar", YAHOO.widget.Calendar, {version: "2.5.0", build: "895"}); diff --git a/lib/yui/charts/README b/lib/yui/charts/README new file mode 100644 index 0000000000..2c88c6ca4e --- /dev/null +++ b/lib/yui/charts/README @@ -0,0 +1,14 @@ +YUI Library - Charts - Release Notes + +2.5.0 + * Added lineSize style to series styles + * Added showLabels substyle to xAxis and yAxis styles + * Added more descriptive local content warning for ExternalInterface failure + * Improved minor unit calculation + * Fixed animation and marker positioning bugs + * Fixed bug that caused series definition update to fail + * Fixed bug that caused setting hex color values with # symbol to fail + * Added initialization flag to ensure DataSource doesn't receive multiple requests during initialization. + +2.4.0 + * Experimental release \ No newline at end of file diff --git a/lib/yui/charts/assets/charts.swf b/lib/yui/charts/assets/charts.swf new file mode 100644 index 0000000000000000000000000000000000000000..9e9597a91fde7c8ddeb9b8b9f5e502e3357d7f12 GIT binary patch literal 60209 zcmZUYQ*dQb+pS~U?AUfX?AW$#+sTf(W81cEr<0DYj&1Yw|NXc*Rioy`yjWH1)idgy zA{r{N;|HK1p6kUu(1xlbPlEmy_8C1{;$R`^04T+VIr^7_p71d8U+j=7qP}liZBm>Q zXXacE9wJ_c@8!zHu%v{=<3&?K7e?}wa#M(dd#in1hrs^l?
z4cq)b?m*g#_|xt3E-!VbT10oP*6qIG@1pE_C_8YuM4y-oT%Vcu?w(O{CSY+j4ApiM
zIPs7R67qBV;RZ8STtvVRK%ftZ!ci(QX9Uq;$cC!v+GM_3Z^ItBnb-b=zu}ziz?FBc5pTeqURsrz$O$aeuT3d6*gd=
z!j?g_eu=`~f@i}jh3$doz(*8zhJsoqT2T%L#cZG=ef>6-O;Z%f2AO>wJcodcex@RQ
zW39>tDbhE0s%#ge4&AG=@v0(Sa8P9v;CbN@mE8r;Z^2S^t|EQ=UX48j)%ebXu-HKI
z-_6z7!|?nraLYCD{Ci-BYvK95H5ywF&+o6-*bDId!6q1U@ciLsjctMFMQ>=#gXhIZ
zHMSR?KZ3D1K#~3d#@tv
*>ikP$s7i5e+*Hq9`D8#sYJHLSvctPLJ>1GQRV^GQN(}<9n}+
z?`x_OiNu^KhF1U{SWJLco0w{FXoB+<9;v=0kRX6BUni3waW%7N$j%2c$`OfIHRet;
zP}IV=*UJC!wahdu4a4vva~CYj@^l0DOQsmOZ53BEEAmqk9FcslmPyj3&QYKl6huhF
z#h@^*NsR)ZHi7Rd=K#UQLJ`<{Lo&%PRF&GjrIMi<3J^bl>sI7bSi=Y63UXePS{yYP
zT`va}M#XwS-H*xzM``gfM+Y*=%)3{(%jHx}AyLCxN78x?Ybh;-(G~RGu@CA6jLw2+
z!M)q4>)8XvlPmHVN&E}T%#jQ3J&=4MC1W_VTo#BDD;aZYT1LV`jOizpkWc=r6#d!h
z&@KkFGmMz!W1RtV52V}+fI-r|MrHvd-B$*>&&Vv4qaQ<4IqT#?q7y0#t$;-y)?vkg
zTD%JH@`dDZ7A;W7E^5h)9DPPa-sBirgAw~96jfnRL>Iy&Y0~T?dR9AAlccy59SK6{
z!63?_E<}$8Q91exh|ZM#D38L>v5y6BmFV{%dS~!fje@9We;mBkqGv($Z$VU#R-s%4
zAtNf|Uqd@92c4ZfQToG)(*Jj&)N!ITuvGd
;qNNFf6x+Jv4Eu@K@c736(oxsl83X*3N5`{^QD8#auhTk!o|O8kg(WwmTR7S
z)PPVCnK>E6U|KPA)F>8^GeC}IjH{8VZ