* The default queryDelay value has been changed to 0.2. In low-latency
implementations (e.g., when queryDelay is set to 0 against a local
diff --git a/lib/yui/autocomplete/assets/autocomplete-core.css b/lib/yui/autocomplete/assets/autocomplete-core.css
index 921fad9617..38a466d85d 100755
--- a/lib/yui/autocomplete/assets/autocomplete-core.css
+++ b/lib/yui/autocomplete/assets/autocomplete-core.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
*/
-/* This file intentionally left blank */
+/* This file intentionally left blank */
diff --git a/lib/yui/autocomplete/assets/skins/sam/autocomplete-skin.css b/lib/yui/autocomplete/assets/skins/sam/autocomplete-skin.css
index a2d2359072..343e4bb96c 100755
--- a/lib/yui/autocomplete/assets/skins/sam/autocomplete-skin.css
+++ b/lib/yui/autocomplete/assets/skins/sam/autocomplete-skin.css
@@ -1,50 +1,50 @@
/*
-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
*/
-/* styles for entire widget */
-.yui-skin-sam .yui-ac {
- position:relative;font-family:arial;font-size:100%;
-}
-
-/* styles for input field */
-.yui-skin-sam .yui-ac-input {
- position:absolute;width:100%;
-}
-
-/* styles for results container */
-.yui-skin-sam .yui-ac-container {
- position:absolute;top:1.6em;width:100%;
-}
-
-/* styles for header/body/footer wrapper within container */
-.yui-skin-sam .yui-ac-content {
- position:absolute;width:100%;border:1px solid #808080;background:#fff;overflow:hidden;z-index:9050;
-}
-
-/* styles for container shadow */
-.yui-skin-sam .yui-ac-shadow {
- position:absolute;margin:.3em;width:100%;background:#000;-moz-opacity: 0.10;opacity:.10;filter:alpha(opacity=10);z-index:9049;
-}
-
-/* styles for results list */
-.yui-skin-sam .yui-ac-content ul{
- margin:0;padding:0;width:100%;
-}
-
-/* styles for result item */
-.yui-skin-sam .yui-ac-content li {
- margin:0;padding:2px 5px;cursor:default;white-space:nowrap;
-}
-
-/* styles for prehighlighted result item */
-.yui-skin-sam .yui-ac-content li.yui-ac-prehighlight {
- background:#B3D4FF;
-}
-
-/* styles for highlighted result item */
-.yui-skin-sam .yui-ac-content li.yui-ac-highlight {
- background:#426FD9;color:#FFF;
-}
+/* styles for entire widget */
+.yui-skin-sam .yui-ac {
+ position:relative;font-family:arial;font-size:100%;
+}
+
+/* styles for input field */
+.yui-skin-sam .yui-ac-input {
+ position:absolute;width:100%;
+}
+
+/* styles for results container */
+.yui-skin-sam .yui-ac-container {
+ position:absolute;top:1.6em;width:100%;
+}
+
+/* styles for header/body/footer wrapper within container */
+.yui-skin-sam .yui-ac-content {
+ position:absolute;width:100%;border:1px solid #808080;background:#fff;overflow:hidden;z-index:9050;
+}
+
+/* styles for container shadow */
+.yui-skin-sam .yui-ac-shadow {
+ position:absolute;margin:.3em;width:100%;background:#000;-moz-opacity: 0.10;opacity:.10;filter:alpha(opacity=10);z-index:9049;
+}
+
+/* styles for results list */
+.yui-skin-sam .yui-ac-content ul{
+ margin:0;padding:0;width:100%;
+}
+
+/* styles for result item */
+.yui-skin-sam .yui-ac-content li {
+ margin:0;padding:2px 5px;cursor:default;white-space:nowrap;
+}
+
+/* styles for prehighlighted result item */
+.yui-skin-sam .yui-ac-content li.yui-ac-prehighlight {
+ background:#B3D4FF;
+}
+
+/* styles for highlighted result item */
+.yui-skin-sam .yui-ac-content li.yui-ac-highlight {
+ background:#426FD9;color:#FFF;
+}
diff --git a/lib/yui/autocomplete/assets/skins/sam/autocomplete.css b/lib/yui/autocomplete/assets/skins/sam/autocomplete.css
index 98b473e26a..ed09f85f97 100755
--- a/lib/yui/autocomplete/assets/skins/sam/autocomplete.css
+++ b/lib/yui/autocomplete/assets/skins/sam/autocomplete.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-ac{position:relative;font-family:arial;font-size:100%;}.yui-skin-sam .yui-ac-input{position:absolute;width:100%;}.yui-skin-sam .yui-ac-container{position:absolute;top:1.6em;width:100%;}.yui-skin-sam .yui-ac-content{position:absolute;width:100%;border:1px solid #808080;background:#fff;overflow:hidden;z-index:9050;}.yui-skin-sam .yui-ac-shadow{position:absolute;margin:.3em;width:100%;background:#000;-moz-opacity:0.10;opacity:.10;filter:alpha(opacity=10);z-index:9049;}.yui-skin-sam .yui-ac-content ul{margin:0;padding:0;width:100%;}.yui-skin-sam .yui-ac-content li{margin:0;padding:2px 5px;cursor:default;white-space:nowrap;}.yui-skin-sam .yui-ac-content li.yui-ac-prehighlight{background:#B3D4FF;}.yui-skin-sam .yui-ac-content li.yui-ac-highlight{background:#426FD9;color:#FFF;}
diff --git a/lib/yui/autocomplete/autocomplete-debug.js b/lib/yui/autocomplete/autocomplete-debug.js
index 522add11f0..47eec8d6c4 100755
--- a/lib/yui/autocomplete/autocomplete-debug.js
+++ b/lib/yui/autocomplete/autocomplete-debug.js
@@ -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
*/
/**
* The AutoComplete control provides the front-end logic for text-entry suggestion and
@@ -10,7 +10,7 @@ version: 2.3.0
*
* @module autocomplete
* @requires yahoo, dom, event, datasource
- * @optional animation, connection
+ * @optional animation, connection, get
* @namespace YAHOO.widget
* @title AutoComplete Widget
*/
@@ -54,15 +54,15 @@ YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) {
if(YAHOO.util.Dom.inDocument(elInput)) {
if(YAHOO.lang.isString(elInput)) {
this._sName = "instance" + YAHOO.widget.AutoComplete._nIndex + " " + elInput;
- this._oTextbox = document.getElementById(elInput);
+ this._elTextbox = document.getElementById(elInput);
}
else {
this._sName = (elInput.id) ?
"instance" + YAHOO.widget.AutoComplete._nIndex + " " + elInput.id:
"instance" + YAHOO.widget.AutoComplete._nIndex;
- this._oTextbox = elInput;
+ this._elTextbox = elInput;
}
- YAHOO.util.Dom.addClass(this._oTextbox, "yui-ac-input");
+ YAHOO.util.Dom.addClass(this._elTextbox, "yui-ac-input");
}
else {
YAHOO.log("Could not instantiate AutoComplete due to an invalid input element", "error", this.toString());
@@ -72,30 +72,23 @@ YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) {
// Validate container element
if(YAHOO.util.Dom.inDocument(elContainer)) {
if(YAHOO.lang.isString(elContainer)) {
- this._oContainer = document.getElementById(elContainer);
+ this._elContainer = document.getElementById(elContainer);
}
else {
- this._oContainer = elContainer;
+ this._elContainer = elContainer;
}
- if(this._oContainer.style.display == "none") {
+ if(this._elContainer.style.display == "none") {
YAHOO.log("The container may not display properly if display is set to \"none\" in CSS", "warn", this.toString());
}
// For skinning
- var elParent = this._oContainer.parentNode;
+ var elParent = this._elContainer.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") {
+ YAHOO.util.Dom.addClass(elParent, "yui-ac");
}
- if(elTag != "div") {
- YAHOO.log("Could not find an appropriate parent container for skinning", "warn", this.toString());
+ else {
+ YAHOO.log("Could not find the wrapper element for skinning", "warn", this.toString());
}
}
else {
@@ -120,23 +113,21 @@ YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) {
// Set up events
var oSelf = this;
- var oTextbox = this._oTextbox;
+ var elTextbox = this._elTextbox;
// Events are actually for the content module within the container
- var oContent = this._oContainer._oContent;
+ var elContent = this._elContent;
// Dom events
- 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);
+ YAHOO.util.Event.addListener(elTextbox,"keyup",oSelf._onTextboxKeyUp,oSelf);
+ YAHOO.util.Event.addListener(elTextbox,"keydown",oSelf._onTextboxKeyDown,oSelf);
+ YAHOO.util.Event.addListener(elTextbox,"focus",oSelf._onTextboxFocus,oSelf);
+ YAHOO.util.Event.addListener(elTextbox,"blur",oSelf._onTextboxBlur,oSelf);
+ YAHOO.util.Event.addListener(elContent,"mouseover",oSelf._onContainerMouseover,oSelf);
+ YAHOO.util.Event.addListener(elContent,"mouseout",oSelf._onContainerMouseout,oSelf);
+ YAHOO.util.Event.addListener(elContent,"scroll",oSelf._onContainerScroll,oSelf);
+ YAHOO.util.Event.addListener(elContent,"resize",oSelf._onContainerResize,oSelf);
+ YAHOO.util.Event.addListener(elTextbox,"keypress",oSelf._onTextboxKeyPress,oSelf);
+ YAHOO.util.Event.addListener(window,"unload",oSelf._onWindowUnload,oSelf);
// Custom events
this.textboxFocusEvent = new YAHOO.util.CustomEvent("textboxFocus", this);
@@ -157,7 +148,7 @@ YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) {
this.textboxBlurEvent = new YAHOO.util.CustomEvent("textboxBlur", this);
// Finish up
- oTextbox.setAttribute("autocomplete","off");
+ elTextbox.setAttribute("autocomplete","off");
YAHOO.widget.AutoComplete._nIndex++;
YAHOO.log("AutoComplete initialized","info",this.toString());
}
@@ -415,15 +406,16 @@ YAHOO.widget.AutoComplete.prototype.getListItemData = function(oListItem) {
* @param sHeader {String} HTML markup for results container header.
*/
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";
+ if(this._elHeader) {
+ var elHeader = this._elHeader;
+ if(sHeader) {
+ elHeader.innerHTML = sHeader;
+ elHeader.style.display = "block";
+ }
+ else {
+ elHeader.innerHTML = "";
+ elHeader.style.display = "none";
}
- }
- else {
- this._oContainer._oContent._oHeader.innerHTML = "";
- this._oContainer._oContent._oHeader.style.display = "none";
}
};
@@ -435,15 +427,16 @@ YAHOO.widget.AutoComplete.prototype.setHeader = function(sHeader) {
* @param sFooter {String} HTML markup for results container footer.
*/
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";
+ if(this._elFooter) {
+ var elFooter = this._elFooter;
+ if(sFooter) {
+ elFooter.innerHTML = sFooter;
+ elFooter.style.display = "block";
+ }
+ else {
+ elFooter.innerHTML = "";
+ elFooter.style.display = "none";
}
- }
- else {
- this._oContainer._oContent._oFooter.innerHTML = "";
- this._oContainer._oContent._oFooter.style.display = "none";
}
};
@@ -455,18 +448,19 @@ YAHOO.widget.AutoComplete.prototype.setFooter = function(sFooter) {
* @param sBody {String} HTML markup for results container body.
*/
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";
+ if(this._elBody) {
+ var elBody = this._elBody;
+ if(sBody) {
+ elBody.innerHTML = sBody;
+ elBody.style.display = "block";
+ elBody.style.display = "block";
}
+ else {
+ elBody.innerHTML = "";
+ elBody.style.display = "none";
+ }
+ this._maxResultsDisplayed = 0;
}
- else {
- this._oContainer._oContent._oBody.innerHTML = "";
- this._oContainer._oContent.style.display = "none";
- }
- this._maxResultsDisplayed = 0;
};
/**
@@ -495,13 +489,13 @@ YAHOO.widget.AutoComplete.prototype.formatResult = function(oResultItem, sQuery)
* and DOM elements.
*
* @method doBeforeExpandContainer
- * @param oTextbox {HTMLElement} The text input box.
- * @param oContainer {HTMLElement} The container element.
+ * @param elTextbox {HTMLElement} The text input box.
+ * @param elContainer {HTMLElement} The container element.
* @param sQuery {String} The query string.
* @param aResults {Object[]} An array of query results.
* @return {Boolean} Return true to continue expanding container, false to cancel the expand.
*/
-YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer = function(oTextbox, oContainer, sQuery, aResults) {
+YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer = function(elTextbox, elContainer, sQuery, aResults) {
return true;
};
@@ -536,26 +530,26 @@ YAHOO.widget.AutoComplete.prototype.doBeforeSendQuery = function(sQuery) {
*/
YAHOO.widget.AutoComplete.prototype.destroy = function() {
var instanceName = this.toString();
- var elInput = this._oTextbox;
- var elContainer = this._oContainer;
+ var elInput = this._elTextbox;
+ var elContainer = this._elContainer;
// Unhook custom events
- 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();
+ this.textboxFocusEvent.unsubscribeAll();
+ this.textboxKeyEvent.unsubscribeAll();
+ this.dataRequestEvent.unsubscribeAll();
+ this.dataReturnEvent.unsubscribeAll();
+ this.dataErrorEvent.unsubscribeAll();
+ this.containerExpandEvent.unsubscribeAll();
+ this.typeAheadEvent.unsubscribeAll();
+ this.itemMouseOverEvent.unsubscribeAll();
+ this.itemMouseOutEvent.unsubscribeAll();
+ this.itemArrowToEvent.unsubscribeAll();
+ this.itemArrowFromEvent.unsubscribeAll();
+ this.itemSelectEvent.unsubscribeAll();
+ this.unmatchedItemSelectEvent.unsubscribeAll();
+ this.selectionEnforceEvent.unsubscribeAll();
+ this.containerCollapseEvent.unsubscribeAll();
+ this.textboxBlurEvent.unsubscribeAll();
// Unhook DOM events
YAHOO.util.Event.purgeElement(elInput, true);
@@ -566,7 +560,7 @@ YAHOO.widget.AutoComplete.prototype.destroy = function() {
// Null out objects
for(var key in this) {
- if(this.hasOwnProperty(key)) {
+ if(YAHOO.lang.hasOwnProperty(this, key)) {
this[key] = null;
}
}
@@ -695,12 +689,9 @@ YAHOO.widget.AutoComplete.prototype.itemSelectEvent = null;
/**
* Fired when a user selection does not match any of the displayed result items.
- * Note that this event may not behave as expected when delimiter characters
- * have been defined.
*
* @event unmatchedItemSelectEvent
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param sQuery {String} The user-typed query string.
*/
YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent = null;
@@ -757,11 +748,74 @@ YAHOO.widget.AutoComplete.prototype._sName = null;
/**
* Text input field DOM element.
*
- * @property _oTextbox
+ * @property _elTextbox
* @type HTMLElement
* @private
*/
-YAHOO.widget.AutoComplete.prototype._oTextbox = null;
+YAHOO.widget.AutoComplete.prototype._elTextbox = null;
+
+/**
+ * Container DOM element.
+ *
+ * @property _elContainer
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._elContainer = null;
+
+/**
+ * Reference to content element within container element.
+ *
+ * @property _elContent
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._elContent = null;
+
+/**
+ * Reference to header element within content element.
+ *
+ * @property _elHeader
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._elHeader = null;
+
+/**
+ * Reference to body element within content element.
+ *
+ * @property _elBody
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._elBody = null;
+
+/**
+ * Reference to footer element within content element.
+ *
+ * @property _elFooter
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._elFooter = null;
+
+/**
+ * Reference to shadow element within container element.
+ *
+ * @property _elShadow
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._elShadow = null;
+
+/**
+ * Reference to iframe element within container element.
+ *
+ * @property _elIFrame
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._elIFrame = null;
/**
* Whether or not the input field is currently in focus. If query results come back
@@ -782,15 +836,6 @@ YAHOO.widget.AutoComplete.prototype._bFocused = true;
*/
YAHOO.widget.AutoComplete.prototype._oAnim = null;
-/**
- * Container DOM element.
- *
- * @property _oContainer
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._oContainer = null;
-
/**
* Whether or not the results container is currently open.
*
@@ -952,7 +997,7 @@ YAHOO.widget.AutoComplete.prototype._initProps = function() {
this.queryDelay = 0.2;
}
var delimChar = this.delimChar;
- if(YAHOO.lang.isString(delimChar)) {
+ if(YAHOO.lang.isString(delimChar) && (delimChar.length > 0)) {
this.delimChar = [delimChar];
}
else if(!YAHOO.lang.isArray(delimChar)) {
@@ -964,7 +1009,7 @@ YAHOO.widget.AutoComplete.prototype._initProps = function() {
this.animSpeed = 0.3;
}
if(!this._oAnim ) {
- this._oAnim = new YAHOO.util.Anim(this._oContainer._oContent, {}, this.animSpeed);
+ this._oAnim = new YAHOO.util.Anim(this._elContent, {}, this.animSpeed);
}
else {
this._oAnim.duration = this.animSpeed;
@@ -983,21 +1028,21 @@ YAHOO.widget.AutoComplete.prototype._initProps = function() {
* @private
*/
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);
+ if(this.useShadow && !this._elShadow) {
+ var elShadow = document.createElement("div");
+ elShadow.className = "yui-ac-shadow";
+ this._elShadow = this._elContainer.appendChild(elShadow);
+ }
+ if(this.useIFrame && !this._elIFrame) {
+ var elIFrame = document.createElement("iframe");
+ elIFrame.src = this._iFrameSrc;
+ elIFrame.frameBorder = 0;
+ elIFrame.scrolling = "no";
+ elIFrame.style.position = "absolute";
+ elIFrame.style.width = "100%";
+ elIFrame.style.height = "100%";
+ elIFrame.tabIndex = -1;
+ this._elIFrame = this._elContainer.appendChild(elIFrame);
}
};
@@ -1008,28 +1053,28 @@ YAHOO.widget.AutoComplete.prototype._initContainerHelpers = function() {
* @private
*/
YAHOO.widget.AutoComplete.prototype._initContainer = function() {
- YAHOO.util.Dom.addClass(this._oContainer, "yui-ac-container");
+ YAHOO.util.Dom.addClass(this._elContainer, "yui-ac-container");
- if(!this._oContainer._oContent) {
- // The oContent div helps size the iframe and shadow properly
- 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);
+ if(!this._elContent) {
+ // The elContent div helps size the iframe and shadow properly
+ var elContent = document.createElement("div");
+ elContent.className = "yui-ac-content";
+ elContent.style.display = "none";
+ this._elContent = this._elContainer.appendChild(elContent);
+
+ var elHeader = document.createElement("div");
+ elHeader.className = "yui-ac-hd";
+ elHeader.style.display = "none";
+ this._elHeader = this._elContent.appendChild(elHeader);
+
+ var elBody = document.createElement("div");
+ elBody.className = "yui-ac-bd";
+ this._elBody = this._elContent.appendChild(elBody);
+
+ var elFooter = document.createElement("div");
+ elFooter.className = "yui-ac-ft";
+ elFooter.style.display = "none";
+ this._elFooter = this._elContent.appendChild(elFooter);
}
else {
YAHOO.log("Could not initialize the container","warn",this.toString());
@@ -1046,18 +1091,18 @@ YAHOO.widget.AutoComplete.prototype._initContainer = function() {
*/
YAHOO.widget.AutoComplete.prototype._initList = function() {
this._aListItems = [];
- while(this._oContainer._oContent._oBody.hasChildNodes()) {
+ while(this._elBody.hasChildNodes()) {
var oldListItems = this.getListItems();
if(oldListItems) {
for(var oldi = oldListItems.length-1; oldi >= 0; oldi--) {
oldListItems[oldi] = null;
}
}
- this._oContainer._oContent._oBody.innerHTML = "";
+ this._elBody.innerHTML = "";
}
var oList = document.createElement("ul");
- oList = this._oContainer._oContent._oBody.appendChild(oList);
+ oList = this._elBody.appendChild(oList);
for(var i=0; i -1) {
- this._oTextbox.value = sValue.substring(0,nIndex);
+ this._elTextbox.value = sValue.substring(0,nIndex);
}
else {
- this._oTextbox.value = "";
+ this._elTextbox.value = "";
}
- this._sSavedQuery = this._oTextbox.value;
+ this._sSavedQuery = this._elTextbox.value;
// Fire custom event
this.selectionEnforceEvent.fire(this);
@@ -1372,20 +1417,20 @@ YAHOO.widget.AutoComplete.prototype._typeAhead = function(oItem, sQuery) {
return;
}
- var oTextbox = this._oTextbox;
- var sValue = this._oTextbox.value; // any saved queries plus what user has typed
+ var elTextbox = this._elTextbox;
+ var sValue = this._elTextbox.value; // any saved queries plus what user has typed
// Don't update with type-ahead if text selection is not supported
- if(!oTextbox.setSelectionRange && !oTextbox.createTextRange) {
+ if(!elTextbox.setSelectionRange && !elTextbox.createTextRange) {
return;
}
// Select the portion of text that the user has not typed
var nStart = sValue.length;
this._updateValue(oItem);
- var nEnd = oTextbox.value.length;
- this._selectText(oTextbox,nStart,nEnd);
- var sPrefill = oTextbox.value.substr(nStart,nEnd);
+ var nEnd = elTextbox.value.length;
+ this._selectText(elTextbox,nStart,nEnd);
+ var sPrefill = elTextbox.value.substr(nStart,nEnd);
this.typeAheadEvent.fire(this,sQuery,sPrefill);
YAHOO.log("Typeahead occured with prefill string \"" + sPrefill + "\"", "info", this.toString());
};
@@ -1394,23 +1439,23 @@ YAHOO.widget.AutoComplete.prototype._typeAhead = function(oItem, sQuery) {
* Selects text in the input field.
*
* @method _selectText
- * @param oTextbox {HTMLElement} Text input box element in which to select text.
+ * @param elTextbox {HTMLElement} Text input box element in which to select text.
* @param nStart {Number} Starting index of text string to select.
* @param nEnd {Number} Ending index of text selection.
* @private
*/
-YAHOO.widget.AutoComplete.prototype._selectText = function(oTextbox, nStart, nEnd) {
- if(oTextbox.setSelectionRange) { // For Mozilla
- oTextbox.setSelectionRange(nStart,nEnd);
+YAHOO.widget.AutoComplete.prototype._selectText = function(elTextbox, nStart, nEnd) {
+ if(elTextbox.setSelectionRange) { // For Mozilla
+ elTextbox.setSelectionRange(nStart,nEnd);
}
- else if(oTextbox.createTextRange) { // For IE
- var oTextRange = oTextbox.createTextRange();
+ else if(elTextbox.createTextRange) { // For IE
+ var oTextRange = elTextbox.createTextRange();
oTextRange.moveStart("character", nStart);
- oTextRange.moveEnd("character", nEnd-oTextbox.value.length);
+ oTextRange.moveEnd("character", nEnd-elTextbox.value.length);
oTextRange.select();
}
else {
- oTextbox.select();
+ elTextbox.select();
}
};
@@ -1423,29 +1468,29 @@ YAHOO.widget.AutoComplete.prototype._selectText = function(oTextbox, nStart, nEn
*/
YAHOO.widget.AutoComplete.prototype._toggleContainerHelpers = function(bShow) {
var bFireEvent = false;
- var width = this._oContainer._oContent.offsetWidth + "px";
- var height = this._oContainer._oContent.offsetHeight + "px";
+ var width = this._elContent.offsetWidth + "px";
+ var height = this._elContent.offsetHeight + "px";
- if(this.useIFrame && this._oContainer._oIFrame) {
+ if(this.useIFrame && this._elIFrame) {
bFireEvent = true;
if(bShow) {
- this._oContainer._oIFrame.style.width = width;
- this._oContainer._oIFrame.style.height = height;
+ this._elIFrame.style.width = width;
+ this._elIFrame.style.height = height;
}
else {
- this._oContainer._oIFrame.style.width = 0;
- this._oContainer._oIFrame.style.height = 0;
+ this._elIFrame.style.width = 0;
+ this._elIFrame.style.height = 0;
}
}
- if(this.useShadow && this._oContainer._oShadow) {
+ if(this.useShadow && this._elShadow) {
bFireEvent = true;
if(bShow) {
- this._oContainer._oShadow.style.width = width;
- this._oContainer._oShadow.style.height = height;
+ this._elShadow.style.width = width;
+ this._elShadow.style.height = height;
}
else {
- this._oContainer._oShadow.style.width = 0;
- this._oContainer._oShadow.style.height = 0;
+ this._elShadow.style.width = 0;
+ this._elShadow.style.height = 0;
}
}
};
@@ -1458,7 +1503,7 @@ YAHOO.widget.AutoComplete.prototype._toggleContainerHelpers = function(bShow) {
* @private
*/
YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
- var oContainer = this._oContainer;
+ var elContainer = this._elContainer;
// Implementer has container always open so don't mess with it
if(this.alwaysShowContainer && this._bContainerOpen) {
@@ -1467,7 +1512,7 @@ YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
// Clear contents of container
if(!bShow) {
- this._oContainer._oContent.scrollTop = 0;
+ this._elContent.scrollTop = 0;
var aItems = this._aListItems;
if(aItems && (aItems.length > 0)) {
@@ -1487,7 +1532,7 @@ YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
// Container is already closed
if(!bShow && !this._bContainerOpen) {
- oContainer._oContent.style.display = "none";
+ this._elContent.style.display = "none";
return;
}
@@ -1505,8 +1550,8 @@ YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
}
// Clone container to grab current size offscreen
- var oClone = oContainer._oContent.cloneNode(true);
- oContainer.appendChild(oClone);
+ var oClone = this._elContent.cloneNode(true);
+ elContainer.appendChild(oClone);
oClone.style.top = "-9000px";
oClone.style.display = "block";
@@ -1525,16 +1570,16 @@ YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
// If opening anew, set to a collapsed size...
if(bShow && !this._bContainerOpen) {
- oContainer._oContent.style.width = wColl+"px";
- oContainer._oContent.style.height = hColl+"px";
+ this._elContent.style.width = wColl+"px";
+ this._elContent.style.height = hColl+"px";
}
// Else, set it to its last known size.
else {
- oContainer._oContent.style.width = wExp+"px";
- oContainer._oContent.style.height = hExp+"px";
+ this._elContent.style.width = wExp+"px";
+ this._elContent.style.height = hExp+"px";
}
- oContainer.removeChild(oClone);
+ elContainer.removeChild(oClone);
oClone = null;
var oSelf = this;
@@ -1547,7 +1592,7 @@ YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
YAHOO.log("Container expanded", "info", oSelf.toString());
}
else {
- oContainer._oContent.style.display = "none";
+ oSelf._elContent.style.display = "none";
oSelf.containerCollapseEvent.fire(oSelf);
YAHOO.log("Container collapsed", "info", oSelf.toString());
}
@@ -1555,7 +1600,7 @@ YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
};
// Display container and animate it
- oContainer._oContent.style.display = "block";
+ this._elContent.style.display = "block";
oAnim.onComplete.subscribe(onAnimComplete);
oAnim.animate();
this._bContainerOpen = bShow;
@@ -1563,12 +1608,12 @@ YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
// Else don't animate, just show or hide
else {
if(bShow) {
- oContainer._oContent.style.display = "block";
+ this._elContent.style.display = "block";
this.containerExpandEvent.fire(this);
YAHOO.log("Container expanded", "info", this.toString());
}
else {
- oContainer._oContent.style.display = "none";
+ this._elContent.style.display = "none";
this.containerCollapseEvent.fire(this);
YAHOO.log("Container collapsed", "info", this.toString());
}
@@ -1634,34 +1679,34 @@ YAHOO.widget.AutoComplete.prototype._togglePrehighlight = function(oNewItem, sTy
* @private
*/
YAHOO.widget.AutoComplete.prototype._updateValue = function(oItem) {
- var oTextbox = this._oTextbox;
+ var elTextbox = this._elTextbox;
var sDelimChar = (this.delimChar) ? (this.delimChar[0] || this.delimChar) : null;
var sSavedQuery = this._sSavedQuery;
var sResultKey = oItem._sResultKey;
- oTextbox.focus();
+ elTextbox.focus();
// First clear text field
- oTextbox.value = "";
+ elTextbox.value = "";
// Grab data to put into text field
if(sDelimChar) {
if(sSavedQuery) {
- oTextbox.value = sSavedQuery;
+ elTextbox.value = sSavedQuery;
}
- oTextbox.value += sResultKey + sDelimChar;
+ elTextbox.value += sResultKey + sDelimChar;
if(sDelimChar != " ") {
- oTextbox.value += " ";
+ elTextbox.value += " ";
}
}
- else { oTextbox.value = sResultKey; }
+ else { elTextbox.value = sResultKey; }
// scroll to bottom of textarea if necessary
- if(oTextbox.type == "textarea") {
- oTextbox.scrollTop = oTextbox.scrollHeight;
+ if(elTextbox.type == "textarea") {
+ elTextbox.scrollTop = elTextbox.scrollHeight;
}
// move cursor to end
- var end = oTextbox.value.length;
- this._selectText(oTextbox,end,end);
+ var end = elTextbox.value.length;
+ this._selectText(elTextbox,end,end);
this._oCurItem = oItem;
};
@@ -1735,14 +1780,14 @@ YAHOO.widget.AutoComplete.prototype._moveSelection = function(nKeyCode) {
// Go back to query (remove type-ahead string)
if(this.delimChar && this._sSavedQuery) {
if(!this._textMatchesOption()) {
- this._oTextbox.value = this._sSavedQuery;
+ this._elTextbox.value = this._sSavedQuery;
}
else {
- this._oTextbox.value = this._sSavedQuery + this._sCurQuery;
+ this._elTextbox.value = this._sSavedQuery + this._sCurQuery;
}
}
else {
- this._oTextbox.value = this._sCurQuery;
+ this._elTextbox.value = this._sCurQuery;
}
this._oCurItem = null;
return;
@@ -1756,36 +1801,36 @@ YAHOO.widget.AutoComplete.prototype._moveSelection = function(nKeyCode) {
var oNewItem = this._aListItems[nNewItemIndex];
// Scroll the container if necessary
- var oContent = this._oContainer._oContent;
- var scrollOn = ((YAHOO.util.Dom.getStyle(oContent,"overflow") == "auto") ||
- (YAHOO.util.Dom.getStyle(oContent,"overflowY") == "auto"));
+ var elContent = this._elContent;
+ var scrollOn = ((YAHOO.util.Dom.getStyle(elContent,"overflow") == "auto") ||
+ (YAHOO.util.Dom.getStyle(elContent,"overflowY") == "auto"));
if(scrollOn && (nNewItemIndex > -1) &&
(nNewItemIndex < this._nDisplayedItems)) {
// User is keying down
if(nKeyCode == 40) {
// Bottom of selected item is below scroll area...
- if((oNewItem.offsetTop+oNewItem.offsetHeight) > (oContent.scrollTop + oContent.offsetHeight)) {
+ if((oNewItem.offsetTop+oNewItem.offsetHeight) > (elContent.scrollTop + elContent.offsetHeight)) {
// Set bottom of scroll area to bottom of selected item
- oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - oContent.offsetHeight;
+ elContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - elContent.offsetHeight;
}
// Bottom of selected item is above scroll area...
- else if((oNewItem.offsetTop+oNewItem.offsetHeight) < oContent.scrollTop) {
+ else if((oNewItem.offsetTop+oNewItem.offsetHeight) < elContent.scrollTop) {
// Set top of selected item to top of scroll area
- oContent.scrollTop = oNewItem.offsetTop;
+ elContent.scrollTop = oNewItem.offsetTop;
}
}
// User is keying up
else {
// Top of selected item is above scroll area
- if(oNewItem.offsetTop < oContent.scrollTop) {
+ if(oNewItem.offsetTop < elContent.scrollTop) {
// Set top of scroll area to top of selected item
- this._oContainer._oContent.scrollTop = oNewItem.offsetTop;
+ this._elContent.scrollTop = oNewItem.offsetTop;
}
// Top of selected item is below scroll area
- else if(oNewItem.offsetTop > (oContent.scrollTop + oContent.offsetHeight)) {
+ else if(oNewItem.offsetTop > (elContent.scrollTop + elContent.offsetHeight)) {
// Set bottom of selected item to bottom of scroll area
- this._oContainer._oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - oContent.offsetHeight;
+ this._elContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - elContent.offsetHeight;
}
}
}
@@ -1896,7 +1941,7 @@ YAHOO.widget.AutoComplete.prototype._onContainerMouseout = function(v,oSelf) {
* @private
*/
YAHOO.widget.AutoComplete.prototype._onContainerScroll = function(v,oSelf) {
- oSelf._oTextbox.focus();
+ oSelf._elTextbox.focus();
};
/**
@@ -1939,16 +1984,18 @@ YAHOO.widget.AutoComplete.prototype._onTextboxKeyDown = function(v,oSelf) {
}
break;
case 13: // enter
- if(oSelf._oCurItem) {
- if(oSelf._nKeyCode != nKeyCode) {
- if(oSelf._bContainerOpen) {
- YAHOO.util.Event.stopEvent(v);
+ if(!YAHOO.env.ua.webkit) {
+ if(oSelf._oCurItem) {
+ if(oSelf._nKeyCode != nKeyCode) {
+ if(oSelf._bContainerOpen) {
+ YAHOO.util.Event.stopEvent(v);
+ }
}
+ oSelf._selectItem(oSelf._oCurItem);
+ }
+ else {
+ oSelf._toggleContainer(false);
}
- oSelf._selectItem(oSelf._oCurItem);
- }
- else {
- oSelf._toggleContainer(false);
}
break;
case 27: // esc
@@ -1981,22 +2028,27 @@ YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress = function(v,oSelf) {
var nKeyCode = v.keyCode;
//Expose only to Mac browsers, where stopEvent is ineffective on keydown events (bug 790337)
- var isMac = (navigator.userAgent.toLowerCase().indexOf("mac") != -1);
- if(isMac) {
+ if(YAHOO.env.ua.webkit) {
switch (nKeyCode) {
case 9: // tab
- if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) {
- YAHOO.util.Event.stopEvent(v);
+ if(oSelf._oCurItem) {
+ if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) {
+ YAHOO.util.Event.stopEvent(v);
+ }
}
break;
case 13: // enter
- if(oSelf._nKeyCode != nKeyCode) {
- YAHOO.util.Event.stopEvent(v);
+ if(oSelf._oCurItem) {
+ if(oSelf._nKeyCode != nKeyCode) {
+ if(oSelf._bContainerOpen) {
+ YAHOO.util.Event.stopEvent(v);
+ }
+ }
+ oSelf._selectItem(oSelf._oCurItem);
+ }
+ else {
+ oSelf._toggleContainer(false);
}
- break;
- case 38: // up
- case 40: // down
- YAHOO.util.Event.stopEvent(v);
break;
default:
break;
@@ -2023,6 +2075,7 @@ YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp = function(v,oSelf) {
oSelf._initProps();
var nKeyCode = v.keyCode;
+
oSelf._nKeyCode = nKeyCode;
var sText = this.value; //string in textbox
@@ -2065,7 +2118,7 @@ YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp = function(v,oSelf) {
* @private
*/
YAHOO.widget.AutoComplete.prototype._onTextboxFocus = function (v,oSelf) {
- oSelf._oTextbox.setAttribute("autocomplete","off");
+ oSelf._elTextbox.setAttribute("autocomplete","off");
oSelf._bFocused = true;
if(!oSelf._bItemSelected) {
oSelf.textboxFocusEvent.fire(oSelf);
@@ -2084,20 +2137,27 @@ YAHOO.widget.AutoComplete.prototype._onTextboxFocus = function (v,oSelf) {
YAHOO.widget.AutoComplete.prototype._onTextboxBlur = function (v,oSelf) {
// Don't treat as a blur if it was a selection via mouse click
if(!oSelf._bOverContainer || (oSelf._nKeyCode == 9)) {
- // Current query needs to be validated
+ // Current query needs to be validated as a selection
if(!oSelf._bItemSelected) {
var oMatch = oSelf._textMatchesOption();
+ // Container is closed or current query doesn't match any result
if(!oSelf._bContainerOpen || (oSelf._bContainerOpen && (oMatch === null))) {
+ // Force selection is enabled so clear the current query
if(oSelf.forceSelection) {
oSelf._clearSelection();
}
+ // Treat current query as a valid selection
else {
- oSelf.unmatchedItemSelectEvent.fire(oSelf, oSelf._sCurQuery);
+ oSelf.unmatchedItemSelectEvent.fire(oSelf);
YAHOO.log("Unmatched item selected", "info", oSelf.toString());
}
}
+ // Container is open and current query matches a result
else {
- oSelf._selectItem(oMatch);
+ // Force a selection when textbox is blurred with a match
+ if(oSelf.forceSelection) {
+ oSelf._selectItem(oMatch);
+ }
}
}
@@ -2112,19 +2172,16 @@ YAHOO.widget.AutoComplete.prototype._onTextboxBlur = function (v,oSelf) {
};
/**
- * Handles form submission event.
+ * Handles window unload event.
*
- * @method _onFormSubmit
- * @param v {HTMLEvent} The submit event.
+ * @method _onWindowUnload
+ * @param v {HTMLEvent} The unload event.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
-YAHOO.widget.AutoComplete.prototype._onFormSubmit = function(v,oSelf) {
- if(oSelf.allowBrowserAutocomplete) {
- oSelf._oTextbox.setAttribute("autocomplete","on");
- }
- else {
- oSelf._oTextbox.setAttribute("autocomplete","off");
+YAHOO.widget.AutoComplete.prototype._onWindowUnload = function(v,oSelf) {
+ if(oSelf && oSelf._elTextbox && oSelf.allowBrowserAutocomplete) {
+ oSelf._elTextbox.setAttribute("autocomplete","on");
}
};
@@ -2478,6 +2535,7 @@ YAHOO.widget.DataSource.prototype._doQueryCache = function(oCallbackFn, sQuery,
var aCache = this._aCache;
var nCacheLength = (aCache) ? aCache.length : 0;
var bMatchContains = this.queryMatchContains;
+ var sOrigQuery;
// If cache is enabled...
if((this.maxCacheEntries > 0) && aCache && (nCacheLength > 0)) {
@@ -2485,7 +2543,7 @@ YAHOO.widget.DataSource.prototype._doQueryCache = function(oCallbackFn, sQuery,
YAHOO.log("Querying cache: \"" + sQuery + "\"", "info", this.toString());
// If case is unimportant, normalize query now instead of in loops
if(!this.queryMatchCase) {
- var sOrigQuery = sQuery;
+ sOrigQuery = sQuery;
sQuery = sQuery.toLowerCase();
}
@@ -2660,8 +2718,7 @@ YAHOO.widget.DS_XHR.ERROR_DATAXHR = "XHR response failed";
/////////////////////////////////////////////////////////////////////////////
/**
- * Alias to YUI Connection Manager. Allows implementers to specify their own
- * subclasses of the YUI Connection Manager utility.
+ * Alias to YUI Connection Manager, to allow implementers to customize the utility.
*
* @property connMgr
* @type Object
@@ -2853,9 +2910,27 @@ YAHOO.widget.DS_XHR.prototype.parseResponse = function(sQuery, oResponse, oParen
switch (this.responseType) {
case YAHOO.widget.DS_XHR.TYPE_JSON:
var jsonList, jsonObjParsed;
- // Check for JSON lib but divert KHTML clients
- var isNotMac = (navigator.userAgent.toLowerCase().indexOf('khtml')== -1);
- if(oResponse.parseJSON && isNotMac) {
+ // Check for YUI JSON
+ if(YAHOO.lang.JSON) {
+ // Use the JSON utility if available
+ jsonObjParsed = YAHOO.lang.JSON.parse(oResponse);
+ if(!jsonObjParsed) {
+ bError = true;
+ break;
+ }
+ else {
+ try {
+ // eval is necessary here since aSchema[0] is of unknown depth
+ jsonList = eval("jsonObjParsed." + aSchema[0]);
+ }
+ catch(e) {
+ bError = true;
+ break;
+ }
+ }
+ }
+ // Check for JSON lib
+ else if(oResponse.parseJSON) {
// Use the new JSON utility if available
jsonObjParsed = oResponse.parseJSON();
if(!jsonObjParsed) {
@@ -2872,8 +2947,8 @@ YAHOO.widget.DS_XHR.prototype.parseResponse = function(sQuery, oResponse, oParen
}
}
}
- else if(window.JSON && isNotMac) {
- // Use older JSON lib if available
+ // Use older JSON lib if available
+ else if(window.JSON) {
jsonObjParsed = JSON.parse(oResponse);
if(!jsonObjParsed) {
bError = true;
@@ -2935,7 +3010,7 @@ YAHOO.widget.DS_XHR.prototype.parseResponse = function(sQuery, oResponse, oParen
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 = [];
@@ -3042,6 +3117,293 @@ YAHOO.widget.DS_XHR.prototype.parseResponse = function(sQuery, oResponse, oParen
YAHOO.widget.DS_XHR.prototype._oConn = null;
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Implementation of YAHOO.widget.DataSource using the Get Utility to generate
+ * dynamic SCRIPT nodes for data retrieval.
+ *
+ * @class DS_ScriptNode
+ * @constructor
+ * @extends YAHOO.widget.DataSource
+ * @param sUri {String} URI to the script location that will return data.
+ * @param aSchema {String[]} Data schema definition of results.
+ * @param oConfigs {Object} (optional) Object literal of config params.
+ */
+YAHOO.widget.DS_ScriptNode = function(sUri, aSchema, oConfigs) {
+ // Set any config params passed in to override defaults
+ if(oConfigs && (oConfigs.constructor == Object)) {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!YAHOO.lang.isArray(aSchema) || !YAHOO.lang.isString(sUri)) {
+ YAHOO.log("Could not instantiate Script Node DataSource due to invalid arguments", "error", this.toString());
+ return;
+ }
+
+ this.schema = aSchema;
+ this.scriptURI = sUri;
+
+ this._init();
+ YAHOO.log("Script Node DataSource initialized","info",this.toString());
+};
+
+YAHOO.widget.DS_ScriptNode.prototype = new YAHOO.widget.DataSource();
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Alias to YUI Get Utility. Allows implementers to specify their own
+ * subclasses of the YUI Get Utility.
+ *
+ * @property getUtility
+ * @type Object
+ * @default YAHOO.util.Get
+ */
+YAHOO.widget.DS_ScriptNode.prototype.getUtility = YAHOO.util.Get;
+
+/**
+ * URI to the script that returns data.
+ *
+ * @property scriptURI
+ * @type String
+ */
+YAHOO.widget.DS_ScriptNode.prototype.scriptURI = null;
+
+/**
+ * Query string parameter name sent to scriptURI. For instance, requests will be
+ * sent to <scriptURI>?<scriptQueryParam>=queryString
+ *
+ * @property scriptQueryParam
+ * @type String
+ * @default "query"
+ */
+YAHOO.widget.DS_ScriptNode.prototype.scriptQueryParam = "query";
+
+/**
+ * Defines request/response management in the following manner:
+ *
+ *
+ *
ignoreStaleResponses
+ *
Send all requests, but handle only the response for the most recently sent request.
+ *
allowAll
+ *
Send all requests and handle all responses.
+ *
+ *
+ * @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=18&&nKeyCode<=20)||(nKeyCode==27)||(nKeyCode>=33&&nKeyCode<=35)||(nKeyCode>=36&&nKeyCode<=40)||(nKeyCode>=44&&nKeyCode<=45)){return true;}
-return false;};YAHOO.widget.AutoComplete.prototype._sendQuery=function(sQuery){if(this.minQueryLength==-1){this._toggleContainer(false);return;}
-var aDelimChar=(this.delimChar)?this.delimChar:null;if(aDelimChar){var nDelimIndex=-1;for(var i=aDelimChar.length-1;i>=0;i--){var nNewIndex=sQuery.lastIndexOf(aDelimChar[i]);if(nNewIndex>nDelimIndex){nDelimIndex=nNewIndex;}}
-if(aDelimChar[i]==" "){for(var j=aDelimChar.length-1;j>=0;j--){if(sQuery[nDelimIndex-1]==aDelimChar[j]){nDelimIndex--;break;}}}
-if(nDelimIndex>-1){var nQueryStart=nDelimIndex+1;while(sQuery.charAt(nQueryStart)==" "){nQueryStart+=1;}
-this._sSavedQuery=sQuery.substring(0,nQueryStart);sQuery=sQuery.substr(nQueryStart);}
-else if(sQuery.indexOf(this._sSavedQuery)<0){this._sSavedQuery=null;}}
-if((sQuery&&(sQuery.length0)){if(this._nDelayID!=-1){clearTimeout(this._nDelayID);}
-this._toggleContainer(false);return;}
-sQuery=encodeURIComponent(sQuery);this._nDelayID=-1;sQuery=this.doBeforeSendQuery(sQuery);this.dataRequestEvent.fire(this,sQuery);this.dataSource.getResults(this._populateList,sQuery,this);};YAHOO.widget.AutoComplete.prototype._populateList=function(sQuery,aResults,oSelf){if(aResults===null){oSelf.dataErrorEvent.fire(oSelf,sQuery);}
-if(!oSelf._bFocused||!aResults){return;}
-var isOpera=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);var contentStyle=oSelf._oContainer._oContent.style;contentStyle.width=(!isOpera)?null:"";contentStyle.height=(!isOpera)?null:"";var sCurQuery=decodeURIComponent(sQuery);oSelf._sCurQuery=sCurQuery;oSelf._bItemSelected=false;if(oSelf._maxResultsDisplayed!=oSelf.maxResultsDisplayed){oSelf._initList();}
-var nItems=Math.min(aResults.length,oSelf.maxResultsDisplayed);oSelf._nDisplayedItems=nItems;if(nItems>0){oSelf._initContainerHelpers();var aItems=oSelf._aListItems;for(var i=nItems-1;i>=0;i--){var oItemi=aItems[i];var oResultItemi=aResults[i];oItemi.innerHTML=oSelf.formatResult(oResultItemi,sCurQuery);oItemi.style.display="list-item";oItemi._sResultKey=oResultItemi[0];oItemi._oResultData=oResultItemi;}
-for(var j=aItems.length-1;j>=nItems;j--){var oItemj=aItems[j];oItemj.innerHTML=null;oItemj.style.display="none";oItemj._sResultKey=null;oItemj._oResultData=null;}
-var ok=oSelf.doBeforeExpandContainer(oSelf._oTextbox,oSelf._oContainer,sQuery,aResults);oSelf._toggleContainer(ok);if(oSelf.autoHighlight){var oFirstItem=aItems[0];oSelf._toggleHighlight(oFirstItem,"to");oSelf.itemArrowToEvent.fire(oSelf,oFirstItem);oSelf._typeAhead(oFirstItem,sQuery);}
-else{oSelf._oCurItem=null;}}
-else{oSelf._toggleContainer(false);}
-oSelf.dataReturnEvent.fire(oSelf,sQuery,aResults);};YAHOO.widget.AutoComplete.prototype._clearSelection=function(){var sValue=this._oTextbox.value;var sChar=(this.delimChar)?this.delimChar[0]:null;var nIndex=(sChar)?sValue.lastIndexOf(sChar,sValue.length-2):-1;if(nIndex>-1){this._oTextbox.value=sValue.substring(0,nIndex);}
-else{this._oTextbox.value="";}
-this._sSavedQuery=this._oTextbox.value;this.selectionEnforceEvent.fire(this);};YAHOO.widget.AutoComplete.prototype._textMatchesOption=function(){var foundMatch=null;for(var i=this._nDisplayedItems-1;i>=0;i--){var oItem=this._aListItems[i];var sMatch=oItem._sResultKey.toLowerCase();if(sMatch==this._sCurQuery.toLowerCase()){foundMatch=oItem;break;}}
-return(foundMatch);};YAHOO.widget.AutoComplete.prototype._typeAhead=function(oItem,sQuery){if(!this.typeAhead||(this._nKeyCode==8)){return;}
-var oTextbox=this._oTextbox;var sValue=this._oTextbox.value;if(!oTextbox.setSelectionRange&&!oTextbox.createTextRange){return;}
-var nStart=sValue.length;this._updateValue(oItem);var nEnd=oTextbox.value.length;this._selectText(oTextbox,nStart,nEnd);var sPrefill=oTextbox.value.substr(nStart,nEnd);this.typeAheadEvent.fire(this,sQuery,sPrefill);};YAHOO.widget.AutoComplete.prototype._selectText=function(oTextbox,nStart,nEnd){if(oTextbox.setSelectionRange){oTextbox.setSelectionRange(nStart,nEnd);}
-else if(oTextbox.createTextRange){var oTextRange=oTextbox.createTextRange();oTextRange.moveStart("character",nStart);oTextRange.moveEnd("character",nEnd-oTextbox.value.length);oTextRange.select();}
-else{oTextbox.select();}};YAHOO.widget.AutoComplete.prototype._toggleContainerHelpers=function(bShow){var bFireEvent=false;var width=this._oContainer._oContent.offsetWidth+"px";var height=this._oContainer._oContent.offsetHeight+"px";if(this.useIFrame&&this._oContainer._oIFrame){bFireEvent=true;if(bShow){this._oContainer._oIFrame.style.width=width;this._oContainer._oIFrame.style.height=height;}
-else{this._oContainer._oIFrame.style.width=0;this._oContainer._oIFrame.style.height=0;}}
-if(this.useShadow&&this._oContainer._oShadow){bFireEvent=true;if(bShow){this._oContainer._oShadow.style.width=width;this._oContainer._oShadow.style.height=height;}
-else{this._oContainer._oShadow.style.width=0;this._oContainer._oShadow.style.height=0;}}};YAHOO.widget.AutoComplete.prototype._toggleContainer=function(bShow){var oContainer=this._oContainer;if(this.alwaysShowContainer&&this._bContainerOpen){return;}
-if(!bShow){this._oContainer._oContent.scrollTop=0;var aItems=this._aListItems;if(aItems&&(aItems.length>0)){for(var i=aItems.length-1;i>=0;i--){aItems[i].style.display="none";}}
-if(this._oCurItem){this._toggleHighlight(this._oCurItem,"from");}
-this._oCurItem=null;this._nDisplayedItems=0;this._sCurQuery=null;}
-if(!bShow&&!this._bContainerOpen){oContainer._oContent.style.display="none";return;}
-var oAnim=this._oAnim;if(oAnim&&oAnim.getEl()&&(this.animHoriz||this.animVert)){if(!bShow){this._toggleContainerHelpers(bShow);}
-if(oAnim.isAnimated()){oAnim.stop();}
-var oClone=oContainer._oContent.cloneNode(true);oContainer.appendChild(oClone);oClone.style.top="-9000px";oClone.style.display="block";var wExp=oClone.offsetWidth;var hExp=oClone.offsetHeight;var wColl=(this.animHoriz)?0:wExp;var hColl=(this.animVert)?0:hExp;oAnim.attributes=(bShow)?{width:{to:wExp},height:{to:hExp}}:{width:{to:wColl},height:{to:hColl}};if(bShow&&!this._bContainerOpen){oContainer._oContent.style.width=wColl+"px";oContainer._oContent.style.height=hColl+"px";}
-else{oContainer._oContent.style.width=wExp+"px";oContainer._oContent.style.height=hExp+"px";}
-oContainer.removeChild(oClone);oClone=null;var oSelf=this;var onAnimComplete=function(){oAnim.onComplete.unsubscribeAll();if(bShow){oSelf.containerExpandEvent.fire(oSelf);}
-else{oContainer._oContent.style.display="none";oSelf.containerCollapseEvent.fire(oSelf);}
-oSelf._toggleContainerHelpers(bShow);};oContainer._oContent.style.display="block";oAnim.onComplete.subscribe(onAnimComplete);oAnim.animate();this._bContainerOpen=bShow;}
-else{if(bShow){oContainer._oContent.style.display="block";this.containerExpandEvent.fire(this);}
-else{oContainer._oContent.style.display="none";this.containerCollapseEvent.fire(this);}
-this._toggleContainerHelpers(bShow);this._bContainerOpen=bShow;}};YAHOO.widget.AutoComplete.prototype._toggleHighlight=function(oNewItem,sType){var sHighlight=this.highlightClassName;if(this._oCurItem){YAHOO.util.Dom.removeClass(this._oCurItem,sHighlight);}
-if((sType=="to")&&sHighlight){YAHOO.util.Dom.addClass(oNewItem,sHighlight);this._oCurItem=oNewItem;}};YAHOO.widget.AutoComplete.prototype._togglePrehighlight=function(oNewItem,sType){if(oNewItem==this._oCurItem){return;}
-var sPrehighlight=this.prehighlightClassName;if((sType=="mouseover")&&sPrehighlight){YAHOO.util.Dom.addClass(oNewItem,sPrehighlight);}
-else{YAHOO.util.Dom.removeClass(oNewItem,sPrehighlight);}};YAHOO.widget.AutoComplete.prototype._updateValue=function(oItem){var oTextbox=this._oTextbox;var sDelimChar=(this.delimChar)?(this.delimChar[0]||this.delimChar):null;var sSavedQuery=this._sSavedQuery;var sResultKey=oItem._sResultKey;oTextbox.focus();oTextbox.value="";if(sDelimChar){if(sSavedQuery){oTextbox.value=sSavedQuery;}
-oTextbox.value+=sResultKey+sDelimChar;if(sDelimChar!=" "){oTextbox.value+=" ";}}
-else{oTextbox.value=sResultKey;}
-if(oTextbox.type=="textarea"){oTextbox.scrollTop=oTextbox.scrollHeight;}
-var end=oTextbox.value.length;this._selectText(oTextbox,end,end);this._oCurItem=oItem;};YAHOO.widget.AutoComplete.prototype._selectItem=function(oItem){this._bItemSelected=true;this._updateValue(oItem);this._cancelIntervalDetection(this);this.itemSelectEvent.fire(this,oItem,oItem._oResultData);this._toggleContainer(false);};YAHOO.widget.AutoComplete.prototype._jumpSelection=function(){if(this._oCurItem){this._selectItem(this._oCurItem);}
-else{this._toggleContainer(false);}};YAHOO.widget.AutoComplete.prototype._moveSelection=function(nKeyCode){if(this._bContainerOpen){var oCurItem=this._oCurItem;var nCurItemIndex=-1;if(oCurItem){nCurItemIndex=oCurItem._nItemIndex;}
-var nNewItemIndex=(nKeyCode==40)?(nCurItemIndex+1):(nCurItemIndex-1);if(nNewItemIndex<-2||nNewItemIndex>=this._nDisplayedItems){return;}
-if(oCurItem){this._toggleHighlight(oCurItem,"from");this.itemArrowFromEvent.fire(this,oCurItem);}
-if(nNewItemIndex==-1){if(this.delimChar&&this._sSavedQuery){if(!this._textMatchesOption()){this._oTextbox.value=this._sSavedQuery;}
-else{this._oTextbox.value=this._sSavedQuery+this._sCurQuery;}}
-else{this._oTextbox.value=this._sCurQuery;}
-this._oCurItem=null;return;}
-if(nNewItemIndex==-2){this._toggleContainer(false);return;}
-var oNewItem=this._aListItems[nNewItemIndex];var oContent=this._oContainer._oContent;var scrollOn=((YAHOO.util.Dom.getStyle(oContent,"overflow")=="auto")||(YAHOO.util.Dom.getStyle(oContent,"overflowY")=="auto"));if(scrollOn&&(nNewItemIndex>-1)&&(nNewItemIndex(oContent.scrollTop+oContent.offsetHeight)){oContent.scrollTop=(oNewItem.offsetTop+oNewItem.offsetHeight)-oContent.offsetHeight;}
-else if((oNewItem.offsetTop+oNewItem.offsetHeight)(oContent.scrollTop+oContent.offsetHeight)){this._oContainer._oContent.scrollTop=(oNewItem.offsetTop+oNewItem.offsetHeight)-oContent.offsetHeight;}}}
-this._toggleHighlight(oNewItem,"to");this.itemArrowToEvent.fire(this,oNewItem);if(this.typeAhead){this._updateValue(oNewItem);}}};YAHOO.widget.AutoComplete.prototype._onItemMouseover=function(v,oSelf){if(oSelf.prehighlightClassName){oSelf._togglePrehighlight(this,"mouseover");}
-else{oSelf._toggleHighlight(this,"to");}
-oSelf.itemMouseOverEvent.fire(oSelf,this);};YAHOO.widget.AutoComplete.prototype._onItemMouseout=function(v,oSelf){if(oSelf.prehighlightClassName){oSelf._togglePrehighlight(this,"mouseout");}
-else{oSelf._toggleHighlight(this,"from");}
-oSelf.itemMouseOutEvent.fire(oSelf,this);};YAHOO.widget.AutoComplete.prototype._onItemMouseclick=function(v,oSelf){oSelf._toggleHighlight(this,"to");oSelf._selectItem(this);};YAHOO.widget.AutoComplete.prototype._onContainerMouseover=function(v,oSelf){oSelf._bOverContainer=true;};YAHOO.widget.AutoComplete.prototype._onContainerMouseout=function(v,oSelf){oSelf._bOverContainer=false;if(oSelf._oCurItem){oSelf._toggleHighlight(oSelf._oCurItem,"to");}};YAHOO.widget.AutoComplete.prototype._onContainerScroll=function(v,oSelf){oSelf._oTextbox.focus();};YAHOO.widget.AutoComplete.prototype._onContainerResize=function(v,oSelf){oSelf._toggleContainerHelpers(oSelf._bContainerOpen);};YAHOO.widget.AutoComplete.prototype._onTextboxKeyDown=function(v,oSelf){var nKeyCode=v.keyCode;switch(nKeyCode){case 9:if(oSelf._oCurItem){if(oSelf.delimChar&&(oSelf._nKeyCode!=nKeyCode)){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
-oSelf._selectItem(oSelf._oCurItem);}
-else{oSelf._toggleContainer(false);}
-break;case 13:if(oSelf._oCurItem){if(oSelf._nKeyCode!=nKeyCode){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
-oSelf._selectItem(oSelf._oCurItem);}
-else{oSelf._toggleContainer(false);}
-break;case 27:oSelf._toggleContainer(false);return;case 39:oSelf._jumpSelection();break;case 38:YAHOO.util.Event.stopEvent(v);oSelf._moveSelection(nKeyCode);break;case 40:YAHOO.util.Event.stopEvent(v);oSelf._moveSelection(nKeyCode);break;default:break;}};YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress=function(v,oSelf){var nKeyCode=v.keyCode;var isMac=(navigator.userAgent.toLowerCase().indexOf("mac")!=-1);if(isMac){switch(nKeyCode){case 9:if(oSelf.delimChar&&(oSelf._nKeyCode!=nKeyCode)){YAHOO.util.Event.stopEvent(v);}
-break;case 13:if(oSelf._nKeyCode!=nKeyCode){YAHOO.util.Event.stopEvent(v);}
-break;case 38:case 40:YAHOO.util.Event.stopEvent(v);break;default:break;}}
-else if(nKeyCode==229){oSelf._queryInterval=setInterval(function(){oSelf._onIMEDetected(oSelf);},500);}};YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp=function(v,oSelf){oSelf._initProps();var nKeyCode=v.keyCode;oSelf._nKeyCode=nKeyCode;var sText=this.value;if(oSelf._isIgnoreKey(nKeyCode)||(sText.toLowerCase()==oSelf._sCurQuery)){return;}
-else{oSelf._bItemSelected=false;YAHOO.util.Dom.removeClass(oSelf._oCurItem,oSelf.highlightClassName);oSelf._oCurItem=null;oSelf.textboxKeyEvent.fire(oSelf,nKeyCode);}
-if(oSelf.queryDelay>0){var nDelayID=setTimeout(function(){oSelf._sendQuery(sText);},(oSelf.queryDelay*1000));if(oSelf._nDelayID!=-1){clearTimeout(oSelf._nDelayID);}
-oSelf._nDelayID=nDelayID;}
-else{oSelf._sendQuery(sText);}};YAHOO.widget.AutoComplete.prototype._onTextboxFocus=function(v,oSelf){oSelf._oTextbox.setAttribute("autocomplete","off");oSelf._bFocused=true;if(!oSelf._bItemSelected){oSelf.textboxFocusEvent.fire(oSelf);}};YAHOO.widget.AutoComplete.prototype._onTextboxBlur=function(v,oSelf){if(!oSelf._bOverContainer||(oSelf._nKeyCode==9)){if(!oSelf._bItemSelected){var oMatch=oSelf._textMatchesOption();if(!oSelf._bContainerOpen||(oSelf._bContainerOpen&&(oMatch===null))){if(oSelf.forceSelection){oSelf._clearSelection();}
-else{oSelf.unmatchedItemSelectEvent.fire(oSelf,oSelf._sCurQuery);}}
-else{oSelf._selectItem(oMatch);}}
-if(oSelf._bContainerOpen){oSelf._toggleContainer(false);}
-oSelf._cancelIntervalDetection(oSelf);oSelf._bFocused=false;oSelf.textboxBlurEvent.fire(oSelf);}};YAHOO.widget.AutoComplete.prototype._onFormSubmit=function(v,oSelf){if(oSelf.allowBrowserAutocomplete){oSelf._oTextbox.setAttribute("autocomplete","on");}
-else{oSelf._oTextbox.setAttribute("autocomplete","off");}};YAHOO.widget.DataSource=function(){};YAHOO.widget.DataSource.ERROR_DATANULL="Response data was null";YAHOO.widget.DataSource.ERROR_DATAPARSE="Response data could not be parsed";YAHOO.widget.DataSource.prototype.maxCacheEntries=15;YAHOO.widget.DataSource.prototype.queryMatchContains=false;YAHOO.widget.DataSource.prototype.queryMatchSubset=false;YAHOO.widget.DataSource.prototype.queryMatchCase=false;YAHOO.widget.DataSource.prototype.toString=function(){return"DataSource "+this._sName;};YAHOO.widget.DataSource.prototype.getResults=function(oCallbackFn,sQuery,oParent){var aResults=this._doQueryCache(oCallbackFn,sQuery,oParent);if(aResults.length===0){this.queryEvent.fire(this,oParent,sQuery);this.doQuery(oCallbackFn,sQuery,oParent);}};YAHOO.widget.DataSource.prototype.doQuery=function(oCallbackFn,sQuery,oParent){};YAHOO.widget.DataSource.prototype.flushCache=function(){if(this._aCache){this._aCache=[];}
-if(this._aCacheHelper){this._aCacheHelper=[];}
-this.cacheFlushEvent.fire(this);};YAHOO.widget.DataSource.prototype.queryEvent=null;YAHOO.widget.DataSource.prototype.cacheQueryEvent=null;YAHOO.widget.DataSource.prototype.getResultsEvent=null;YAHOO.widget.DataSource.prototype.getCachedResultsEvent=null;YAHOO.widget.DataSource.prototype.dataErrorEvent=null;YAHOO.widget.DataSource.prototype.cacheFlushEvent=null;YAHOO.widget.DataSource._nIndex=0;YAHOO.widget.DataSource.prototype._sName=null;YAHOO.widget.DataSource.prototype._aCache=null;YAHOO.widget.DataSource.prototype._init=function(){var maxCacheEntries=this.maxCacheEntries;if(!YAHOO.lang.isNumber(maxCacheEntries)||(maxCacheEntries<0)){maxCacheEntries=0;}
-if(maxCacheEntries>0&&!this._aCache){this._aCache=[];}
-this._sName="instance"+YAHOO.widget.DataSource._nIndex;YAHOO.widget.DataSource._nIndex++;this.queryEvent=new YAHOO.util.CustomEvent("query",this);this.cacheQueryEvent=new YAHOO.util.CustomEvent("cacheQuery",this);this.getResultsEvent=new YAHOO.util.CustomEvent("getResults",this);this.getCachedResultsEvent=new YAHOO.util.CustomEvent("getCachedResults",this);this.dataErrorEvent=new YAHOO.util.CustomEvent("dataError",this);this.cacheFlushEvent=new YAHOO.util.CustomEvent("cacheFlush",this);};YAHOO.widget.DataSource.prototype._addCacheElem=function(oResult){var aCache=this._aCache;if(!aCache||!oResult||!oResult.query||!oResult.results){return;}
-if(aCache.length>=this.maxCacheEntries){aCache.shift();}
-aCache.push(oResult);};YAHOO.widget.DataSource.prototype._doQueryCache=function(oCallbackFn,sQuery,oParent){var aResults=[];var bMatchFound=false;var aCache=this._aCache;var nCacheLength=(aCache)?aCache.length:0;var bMatchContains=this.queryMatchContains;if((this.maxCacheEntries>0)&&aCache&&(nCacheLength>0)){this.cacheQueryEvent.fire(this,oParent,sQuery);if(!this.queryMatchCase){var sOrigQuery=sQuery;sQuery=sQuery.toLowerCase();}
-for(var i=nCacheLength-1;i>=0;i--){var resultObj=aCache[i];var aAllResultItems=resultObj.results;var matchKey=(!this.queryMatchCase)?encodeURIComponent(resultObj.query).toLowerCase():encodeURIComponent(resultObj.query);if(matchKey==sQuery){bMatchFound=true;aResults=aAllResultItems;if(i!=nCacheLength-1){aCache.splice(i,1);this._addCacheElem(resultObj);}
-break;}
-else if(this.queryMatchSubset){for(var j=sQuery.length-1;j>=0;j--){var subQuery=sQuery.substr(0,j);if(matchKey==subQuery){bMatchFound=true;for(var k=aAllResultItems.length-1;k>=0;k--){var aRecord=aAllResultItems[k];var sKeyIndex=(this.queryMatchCase)?encodeURIComponent(aRecord[0]).indexOf(sQuery):encodeURIComponent(aRecord[0]).toLowerCase().indexOf(sQuery);if((!bMatchContains&&(sKeyIndex===0))||(bMatchContains&&(sKeyIndex>-1))){aResults.unshift(aRecord);}}
-resultObj={};resultObj.query=sQuery;resultObj.results=aResults;this._addCacheElem(resultObj);break;}}
-if(bMatchFound){break;}}}
-if(bMatchFound){this.getCachedResultsEvent.fire(this,oParent,sOrigQuery,aResults);oCallbackFn(sOrigQuery,aResults,oParent);}}
-return aResults;};YAHOO.widget.DS_XHR=function(sScriptURI,aSchema,oConfigs){if(oConfigs&&(oConfigs.constructor==Object)){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
-if(!YAHOO.lang.isArray(aSchema)||!YAHOO.lang.isString(sScriptURI)){return;}
-this.schema=aSchema;this.scriptURI=sScriptURI;this._init();};YAHOO.widget.DS_XHR.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_XHR.TYPE_JSON=0;YAHOO.widget.DS_XHR.TYPE_XML=1;YAHOO.widget.DS_XHR.TYPE_FLAT=2;YAHOO.widget.DS_XHR.ERROR_DATAXHR="XHR response failed";YAHOO.widget.DS_XHR.prototype.connMgr=YAHOO.util.Connect;YAHOO.widget.DS_XHR.prototype.connTimeout=0;YAHOO.widget.DS_XHR.prototype.scriptURI=null;YAHOO.widget.DS_XHR.prototype.scriptQueryParam="query";YAHOO.widget.DS_XHR.prototype.scriptQueryAppend="";YAHOO.widget.DS_XHR.prototype.responseType=YAHOO.widget.DS_XHR.TYPE_JSON;YAHOO.widget.DS_XHR.prototype.responseStripAfter="\n0){sUri+="&"+this.scriptQueryAppend;}
-var oResponse=null;var oSelf=this;var responseSuccess=function(oResp){if(!oSelf._oConn||(oResp.tId!=oSelf._oConn.tId)){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,YAHOO.widget.DataSource.ERROR_DATANULL);return;}
-for(var foo in oResp){}
-if(!isXML){oResp=oResp.responseText;}
-else{oResp=oResp.responseXML;}
-if(oResp===null){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,YAHOO.widget.DataSource.ERROR_DATANULL);return;}
-var aResults=oSelf.parseResponse(sQuery,oResp,oParent);var resultObj={};resultObj.query=decodeURIComponent(sQuery);resultObj.results=aResults;if(aResults===null){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,YAHOO.widget.DataSource.ERROR_DATAPARSE);aResults=[];}
-else{oSelf.getResultsEvent.fire(oSelf,oParent,sQuery,aResults);oSelf._addCacheElem(resultObj);}
-oCallbackFn(sQuery,aResults,oParent);};var responseFailure=function(oResp){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,YAHOO.widget.DS_XHR.ERROR_DATAXHR);return;};var oCallback={success:responseSuccess,failure:responseFailure};if(YAHOO.lang.isNumber(this.connTimeout)&&(this.connTimeout>0)){oCallback.timeout=this.connTimeout;}
-if(this._oConn){this.connMgr.abort(this._oConn);}
-oSelf._oConn=this.connMgr.asyncRequest("GET",sUri,oCallback,null);};YAHOO.widget.DS_XHR.prototype.parseResponse=function(sQuery,oResponse,oParent){var aSchema=this.schema;var aResults=[];var bError=false;var nEnd=((this.responseStripAfter!=="")&&(oResponse.indexOf))?oResponse.indexOf(this.responseStripAfter):-1;if(nEnd!=-1){oResponse=oResponse.substring(0,nEnd);}
-switch(this.responseType){case YAHOO.widget.DS_XHR.TYPE_JSON:var jsonList,jsonObjParsed;var isNotMac=(navigator.userAgent.toLowerCase().indexOf('khtml')==-1);if(oResponse.parseJSON&&isNotMac){jsonObjParsed=oResponse.parseJSON();if(!jsonObjParsed){bError=true;}
-else{try{jsonList=eval("jsonObjParsed."+aSchema[0]);}
-catch(e){bError=true;break;}}}
-else if(window.JSON&&isNotMac){jsonObjParsed=JSON.parse(oResponse);if(!jsonObjParsed){bError=true;break;}
-else{try{jsonList=eval("jsonObjParsed."+aSchema[0]);}
-catch(e){bError=true;break;}}}
-else{try{while(oResponse.substring(0,1)==" "){oResponse=oResponse.substring(1,oResponse.length);}
-if(oResponse.indexOf("{")<0){bError=true;break;}
-if(oResponse.indexOf("{}")===0){break;}
-var jsonObjRaw=eval("("+oResponse+")");if(!jsonObjRaw){bError=true;break;}
-jsonList=eval("(jsonObjRaw."+aSchema[0]+")");}
-catch(e){bError=true;break;}}
-if(!jsonList){bError=true;break;}
-if(!YAHOO.lang.isArray(jsonList)){jsonList=[jsonList];}
-for(var i=jsonList.length-1;i>=0;i--){var aResultItem=[];var jsonResult=jsonList[i];for(var j=aSchema.length-1;j>=1;j--){var dataFieldValue=jsonResult[aSchema[j]];if(!dataFieldValue){dataFieldValue="";}
-aResultItem.unshift(dataFieldValue);}
-if(aResultItem.length==1){aResultItem.push(jsonResult);}
-aResults.unshift(aResultItem);}
-break;case YAHOO.widget.DS_XHR.TYPE_XML:var xmlList=oResponse.getElementsByTagName(aSchema[0]);if(!xmlList){bError=true;break;}
-for(var k=xmlList.length-1;k>=0;k--){var result=xmlList.item(k);var aFieldSet=[];for(var m=aSchema.length-1;m>=1;m--){var sValue=null;var xmlAttr=result.attributes.getNamedItem(aSchema[m]);if(xmlAttr){sValue=xmlAttr.value;}
-else{var xmlNode=result.getElementsByTagName(aSchema[m]);if(xmlNode&&xmlNode.item(0)&&xmlNode.item(0).firstChild){sValue=xmlNode.item(0).firstChild.nodeValue;}
-else{sValue="";}}
-aFieldSet.unshift(sValue);}
-aResults.unshift(aFieldSet);}
-break;case YAHOO.widget.DS_XHR.TYPE_FLAT:if(oResponse.length>0){var newLength=oResponse.length-aSchema[0].length;if(oResponse.substr(newLength)==aSchema[0]){oResponse=oResponse.substr(0,newLength);}
-var aRecords=oResponse.split(aSchema[0]);for(var n=aRecords.length-1;n>=0;n--){aResults[n]=aRecords[n].split(aSchema[1]);}}
-break;default:break;}
-sQuery=null;oResponse=null;oParent=null;if(bError){return null;}
-else{return aResults;}};YAHOO.widget.DS_XHR.prototype._oConn=null;YAHOO.widget.DS_JSFunction=function(oFunction,oConfigs){if(oConfigs&&(oConfigs.constructor==Object)){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
-if(!YAHOO.lang.isFunction(oFunction)){return;}
-else{this.dataFunction=oFunction;this._init();}};YAHOO.widget.DS_JSFunction.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_JSFunction.prototype.dataFunction=null;YAHOO.widget.DS_JSFunction.prototype.doQuery=function(oCallbackFn,sQuery,oParent){var oFunction=this.dataFunction;var aResults=[];aResults=oFunction(sQuery);if(aResults===null){this.dataErrorEvent.fire(this,oParent,sQuery,YAHOO.widget.DataSource.ERROR_DATANULL);return;}
-var resultObj={};resultObj.query=decodeURIComponent(sQuery);resultObj.results=aResults;this._addCacheElem(resultObj);this.getResultsEvent.fire(this,oParent,sQuery,aResults);oCallbackFn(sQuery,aResults,oParent);return;};YAHOO.widget.DS_JSArray=function(aData,oConfigs){if(oConfigs&&(oConfigs.constructor==Object)){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
-if(!YAHOO.lang.isArray(aData)){return;}
-else{this.data=aData;this._init();}};YAHOO.widget.DS_JSArray.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_JSArray.prototype.data=null;YAHOO.widget.DS_JSArray.prototype.doQuery=function(oCallbackFn,sQuery,oParent){var i;var aData=this.data;var aResults=[];var bMatchFound=false;var bMatchContains=this.queryMatchContains;if(sQuery){if(!this.queryMatchCase){sQuery=sQuery.toLowerCase();}
-for(i=aData.length-1;i>=0;i--){var aDataset=[];if(YAHOO.lang.isString(aData[i])){aDataset[0]=aData[i];}
-else if(YAHOO.lang.isArray(aData[i])){aDataset=aData[i];}
-if(YAHOO.lang.isString(aDataset[0])){var sKeyIndex=(this.queryMatchCase)?encodeURIComponent(aDataset[0]).indexOf(sQuery):encodeURIComponent(aDataset[0]).toLowerCase().indexOf(sQuery);if((!bMatchContains&&(sKeyIndex===0))||(bMatchContains&&(sKeyIndex>-1))){aResults.unshift(aDataset);}}}}
-else{for(i=aData.length-1;i>=0;i--){if(YAHOO.lang.isString(aData[i])){aResults.unshift([aData[i]]);}
-else if(YAHOO.lang.isArray(aData[i])){aResults.unshift(aData[i]);}}}
-this.getResultsEvent.fire(this,oParent,sQuery,aResults);oCallbackFn(sQuery,aResults,oParent);};YAHOO.register("autocomplete",YAHOO.widget.AutoComplete,{version:"2.3.0",build:"442"});
\ No newline at end of file
+YAHOO.widget.AutoComplete=function(G,B,J,C){if(G&&B&&J){if(J instanceof YAHOO.widget.DataSource){this.dataSource=J;}else{return ;}if(YAHOO.util.Dom.inDocument(G)){if(YAHOO.lang.isString(G)){this._sName="instance"+YAHOO.widget.AutoComplete._nIndex+" "+G;this._elTextbox=document.getElementById(G);}else{this._sName=(G.id)?"instance"+YAHOO.widget.AutoComplete._nIndex+" "+G.id:"instance"+YAHOO.widget.AutoComplete._nIndex;this._elTextbox=G;}YAHOO.util.Dom.addClass(this._elTextbox,"yui-ac-input");}else{return ;}if(YAHOO.util.Dom.inDocument(B)){if(YAHOO.lang.isString(B)){this._elContainer=document.getElementById(B);}else{this._elContainer=B;}if(this._elContainer.style.display=="none"){}var D=this._elContainer.parentNode;var A=D.tagName.toLowerCase();if(A=="div"){YAHOO.util.Dom.addClass(D,"yui-ac");}else{}}else{return ;}if(C&&(C.constructor==Object)){for(var I in C){if(I){this[I]=C[I];}}}this._initContainer();this._initProps();this._initList();this._initContainerHelpers();var H=this;var F=this._elTextbox;var E=this._elContent;YAHOO.util.Event.addListener(F,"keyup",H._onTextboxKeyUp,H);YAHOO.util.Event.addListener(F,"keydown",H._onTextboxKeyDown,H);YAHOO.util.Event.addListener(F,"focus",H._onTextboxFocus,H);YAHOO.util.Event.addListener(F,"blur",H._onTextboxBlur,H);YAHOO.util.Event.addListener(E,"mouseover",H._onContainerMouseover,H);YAHOO.util.Event.addListener(E,"mouseout",H._onContainerMouseout,H);YAHOO.util.Event.addListener(E,"scroll",H._onContainerScroll,H);YAHOO.util.Event.addListener(E,"resize",H._onContainerResize,H);YAHOO.util.Event.addListener(F,"keypress",H._onTextboxKeyPress,H);YAHOO.util.Event.addListener(window,"unload",H._onWindowUnload,H);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);F.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(A){if(A._oResultData){return A._oResultData;}else{return false;}};YAHOO.widget.AutoComplete.prototype.setHeader=function(B){if(this._elHeader){var A=this._elHeader;if(B){A.innerHTML=B;A.style.display="block";}else{A.innerHTML="";A.style.display="none";}}};YAHOO.widget.AutoComplete.prototype.setFooter=function(B){if(this._elFooter){var A=this._elFooter;if(B){A.innerHTML=B;A.style.display="block";}else{A.innerHTML="";A.style.display="none";}}};YAHOO.widget.AutoComplete.prototype.setBody=function(A){if(this._elBody){var B=this._elBody;if(A){B.innerHTML=A;B.style.display="block";B.style.display="block";}else{B.innerHTML="";B.style.display="none";}this._maxResultsDisplayed=0;}};YAHOO.widget.AutoComplete.prototype.formatResult=function(B,C){var A=B[0];if(A){return A;}else{return"";}};YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer=function(D,A,C,B){return true;};YAHOO.widget.AutoComplete.prototype.sendQuery=function(A){this._sendQuery(A);};YAHOO.widget.AutoComplete.prototype.doBeforeSendQuery=function(A){return A;};YAHOO.widget.AutoComplete.prototype.destroy=function(){var B=this.toString();var A=this._elTextbox;var D=this._elContainer;this.textboxFocusEvent.unsubscribeAll();this.textboxKeyEvent.unsubscribeAll();this.dataRequestEvent.unsubscribeAll();this.dataReturnEvent.unsubscribeAll();this.dataErrorEvent.unsubscribeAll();this.containerExpandEvent.unsubscribeAll();this.typeAheadEvent.unsubscribeAll();this.itemMouseOverEvent.unsubscribeAll();this.itemMouseOutEvent.unsubscribeAll();this.itemArrowToEvent.unsubscribeAll();this.itemArrowFromEvent.unsubscribeAll();this.itemSelectEvent.unsubscribeAll();this.unmatchedItemSelectEvent.unsubscribeAll();this.selectionEnforceEvent.unsubscribeAll();this.containerCollapseEvent.unsubscribeAll();this.textboxBlurEvent.unsubscribeAll();YAHOO.util.Event.purgeElement(A,true);
+YAHOO.util.Event.purgeElement(D,true);D.innerHTML="";for(var C in this){if(YAHOO.lang.hasOwnProperty(this,C)){this[C]=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._elTextbox=null;YAHOO.widget.AutoComplete.prototype._elContainer=null;YAHOO.widget.AutoComplete.prototype._elContent=null;YAHOO.widget.AutoComplete.prototype._elHeader=null;YAHOO.widget.AutoComplete.prototype._elBody=null;YAHOO.widget.AutoComplete.prototype._elFooter=null;YAHOO.widget.AutoComplete.prototype._elShadow=null;YAHOO.widget.AutoComplete.prototype._elIFrame=null;YAHOO.widget.AutoComplete.prototype._bFocused=true;YAHOO.widget.AutoComplete.prototype._oAnim=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 B=this.minQueryLength;if(!YAHOO.lang.isNumber(B)){this.minQueryLength=1;}var D=this.maxResultsDisplayed;if(!YAHOO.lang.isNumber(D)||(D<1)){this.maxResultsDisplayed=10;}var E=this.queryDelay;if(!YAHOO.lang.isNumber(E)||(E<0)){this.queryDelay=0.2;}var A=this.delimChar;if(YAHOO.lang.isString(A)&&(A.length>0)){this.delimChar=[A];}else{if(!YAHOO.lang.isArray(A)){this.delimChar=null;}}var C=this.animSpeed;if((this.animHoriz||this.animVert)&&YAHOO.util.Anim){if(!YAHOO.lang.isNumber(C)||(C<0)){this.animSpeed=0.3;}if(!this._oAnim){this._oAnim=new YAHOO.util.Anim(this._elContent,{},this.animSpeed);}else{this._oAnim.duration=this.animSpeed;}}if(this.forceSelection&&A){}};YAHOO.widget.AutoComplete.prototype._initContainerHelpers=function(){if(this.useShadow&&!this._elShadow){var A=document.createElement("div");A.className="yui-ac-shadow";this._elShadow=this._elContainer.appendChild(A);}if(this.useIFrame&&!this._elIFrame){var B=document.createElement("iframe");B.src=this._iFrameSrc;B.frameBorder=0;B.scrolling="no";B.style.position="absolute";B.style.width="100%";B.style.height="100%";B.tabIndex=-1;this._elIFrame=this._elContainer.appendChild(B);}};YAHOO.widget.AutoComplete.prototype._initContainer=function(){YAHOO.util.Dom.addClass(this._elContainer,"yui-ac-container");if(!this._elContent){var C=document.createElement("div");C.className="yui-ac-content";C.style.display="none";this._elContent=this._elContainer.appendChild(C);var B=document.createElement("div");B.className="yui-ac-hd";B.style.display="none";this._elHeader=this._elContent.appendChild(B);var D=document.createElement("div");D.className="yui-ac-bd";this._elBody=this._elContent.appendChild(D);var A=document.createElement("div");A.className="yui-ac-ft";A.style.display="none";this._elFooter=this._elContent.appendChild(A);}else{}};YAHOO.widget.AutoComplete.prototype._initList=function(){this._aListItems=[];while(this._elBody.hasChildNodes()){var B=this.getListItems();if(B){for(var A=B.length-1;A>=0;A--){B[A]=null;}}this._elBody.innerHTML="";}var E=document.createElement("ul");E=this._elBody.appendChild(E);for(var C=0;C=18&&A<=20)||(A==27)||(A>=33&&A<=35)||(A>=36&&A<=40)||(A>=44&&A<=45)){return true;}return false;};YAHOO.widget.AutoComplete.prototype._sendQuery=function(G){if(this.minQueryLength==-1){this._toggleContainer(false);return ;}var C=(this.delimChar)?this.delimChar:null;if(C){var E=-1;for(var B=C.length-1;B>=0;B--){var F=G.lastIndexOf(C[B]);if(F>E){E=F;
+}}if(C[B]==" "){for(var A=C.length-1;A>=0;A--){if(G[E-1]==C[A]){E--;break;}}}if(E>-1){var D=E+1;while(G.charAt(D)==" "){D+=1;}this._sSavedQuery=G.substring(0,D);G=G.substr(D);}else{if(G.indexOf(this._sSavedQuery)<0){this._sSavedQuery=null;}}}if((G&&(G.length0)){if(this._nDelayID!=-1){clearTimeout(this._nDelayID);}this._toggleContainer(false);return ;}G=encodeURIComponent(G);this._nDelayID=-1;G=this.doBeforeSendQuery(G);this.dataRequestEvent.fire(this,G);this.dataSource.getResults(this._populateList,G,this);};YAHOO.widget.AutoComplete.prototype._populateList=function(K,L,I){if(L===null){I.dataErrorEvent.fire(I,K);}if(!I._bFocused||!L){return ;}var A=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);var O=I._elContent.style;O.width=(!A)?null:"";O.height=(!A)?null:"";var H=decodeURIComponent(K);I._sCurQuery=H;I._bItemSelected=false;if(I._maxResultsDisplayed!=I.maxResultsDisplayed){I._initList();}var C=Math.min(L.length,I.maxResultsDisplayed);I._nDisplayedItems=C;if(C>0){I._initContainerHelpers();var D=I._aListItems;for(var G=C-1;G>=0;G--){var N=D[G];var B=L[G];N.innerHTML=I.formatResult(B,H);N.style.display="list-item";N._sResultKey=B[0];N._oResultData=B;}for(var F=D.length-1;F>=C;F--){var M=D[F];M.innerHTML=null;M.style.display="none";M._sResultKey=null;M._oResultData=null;}var J=I.doBeforeExpandContainer(I._elTextbox,I._elContainer,K,L);I._toggleContainer(J);if(I.autoHighlight){var E=D[0];I._toggleHighlight(E,"to");I.itemArrowToEvent.fire(I,E);I._typeAhead(E,K);}else{I._oCurItem=null;}}else{I._toggleContainer(false);}I.dataReturnEvent.fire(I,K,L);};YAHOO.widget.AutoComplete.prototype._clearSelection=function(){var C=this._elTextbox.value;var B=(this.delimChar)?this.delimChar[0]:null;var A=(B)?C.lastIndexOf(B,C.length-2):-1;if(A>-1){this._elTextbox.value=C.substring(0,A);}else{this._elTextbox.value="";}this._sSavedQuery=this._elTextbox.value;this.selectionEnforceEvent.fire(this);};YAHOO.widget.AutoComplete.prototype._textMatchesOption=function(){var D=null;for(var A=this._nDisplayedItems-1;A>=0;A--){var C=this._aListItems[A];var B=C._sResultKey.toLowerCase();if(B==this._sCurQuery.toLowerCase()){D=C;break;}}return(D);};YAHOO.widget.AutoComplete.prototype._typeAhead=function(D,G){if(!this.typeAhead||(this._nKeyCode==8)){return ;}var F=this._elTextbox;var E=this._elTextbox.value;if(!F.setSelectionRange&&!F.createTextRange){return ;}var B=E.length;this._updateValue(D);var C=F.value.length;this._selectText(F,B,C);var A=F.value.substr(B,C);this.typeAheadEvent.fire(this,G,A);};YAHOO.widget.AutoComplete.prototype._selectText=function(D,A,B){if(D.setSelectionRange){D.setSelectionRange(A,B);}else{if(D.createTextRange){var C=D.createTextRange();C.moveStart("character",A);C.moveEnd("character",B-D.value.length);C.select();}else{D.select();}}};YAHOO.widget.AutoComplete.prototype._toggleContainerHelpers=function(B){var D=false;var C=this._elContent.offsetWidth+"px";var A=this._elContent.offsetHeight+"px";if(this.useIFrame&&this._elIFrame){D=true;if(B){this._elIFrame.style.width=C;this._elIFrame.style.height=A;}else{this._elIFrame.style.width=0;this._elIFrame.style.height=0;}}if(this.useShadow&&this._elShadow){D=true;if(B){this._elShadow.style.width=C;this._elShadow.style.height=A;}else{this._elShadow.style.width=0;this._elShadow.style.height=0;}}};YAHOO.widget.AutoComplete.prototype._toggleContainer=function(K){var E=this._elContainer;if(this.alwaysShowContainer&&this._bContainerOpen){return ;}if(!K){this._elContent.scrollTop=0;var C=this._aListItems;if(C&&(C.length>0)){for(var H=C.length-1;H>=0;H--){C[H].style.display="none";}}if(this._oCurItem){this._toggleHighlight(this._oCurItem,"from");}this._oCurItem=null;this._nDisplayedItems=0;this._sCurQuery=null;}if(!K&&!this._bContainerOpen){this._elContent.style.display="none";return ;}var B=this._oAnim;if(B&&B.getEl()&&(this.animHoriz||this.animVert)){if(!K){this._toggleContainerHelpers(K);}if(B.isAnimated()){B.stop();}var I=this._elContent.cloneNode(true);E.appendChild(I);I.style.top="-9000px";I.style.display="block";var G=I.offsetWidth;var D=I.offsetHeight;var A=(this.animHoriz)?0:G;var F=(this.animVert)?0:D;B.attributes=(K)?{width:{to:G},height:{to:D}}:{width:{to:A},height:{to:F}};if(K&&!this._bContainerOpen){this._elContent.style.width=A+"px";this._elContent.style.height=F+"px";}else{this._elContent.style.width=G+"px";this._elContent.style.height=D+"px";}E.removeChild(I);I=null;var J=this;var L=function(){B.onComplete.unsubscribeAll();if(K){J.containerExpandEvent.fire(J);}else{J._elContent.style.display="none";J.containerCollapseEvent.fire(J);}J._toggleContainerHelpers(K);};this._elContent.style.display="block";B.onComplete.subscribe(L);B.animate();this._bContainerOpen=K;}else{if(K){this._elContent.style.display="block";this.containerExpandEvent.fire(this);}else{this._elContent.style.display="none";this.containerCollapseEvent.fire(this);}this._toggleContainerHelpers(K);this._bContainerOpen=K;}};YAHOO.widget.AutoComplete.prototype._toggleHighlight=function(A,C){var B=this.highlightClassName;if(this._oCurItem){YAHOO.util.Dom.removeClass(this._oCurItem,B);}if((C=="to")&&B){YAHOO.util.Dom.addClass(A,B);this._oCurItem=A;}};YAHOO.widget.AutoComplete.prototype._togglePrehighlight=function(A,C){if(A==this._oCurItem){return ;}var B=this.prehighlightClassName;if((C=="mouseover")&&B){YAHOO.util.Dom.addClass(A,B);}else{YAHOO.util.Dom.removeClass(A,B);}};YAHOO.widget.AutoComplete.prototype._updateValue=function(E){var F=this._elTextbox;var D=(this.delimChar)?(this.delimChar[0]||this.delimChar):null;var B=this._sSavedQuery;var C=E._sResultKey;F.focus();F.value="";if(D){if(B){F.value=B;}F.value+=C+D;if(D!=" "){F.value+=" ";}}else{F.value=C;}if(F.type=="textarea"){F.scrollTop=F.scrollHeight;}var A=F.value.length;this._selectText(F,A,A);this._oCurItem=E;};YAHOO.widget.AutoComplete.prototype._selectItem=function(A){this._bItemSelected=true;this._updateValue(A);this._cancelIntervalDetection(this);this.itemSelectEvent.fire(this,A,A._oResultData);
+this._toggleContainer(false);};YAHOO.widget.AutoComplete.prototype._jumpSelection=function(){if(this._oCurItem){this._selectItem(this._oCurItem);}else{this._toggleContainer(false);}};YAHOO.widget.AutoComplete.prototype._moveSelection=function(G){if(this._bContainerOpen){var E=this._oCurItem;var F=-1;if(E){F=E._nItemIndex;}var D=(G==40)?(F+1):(F-1);if(D<-2||D>=this._nDisplayedItems){return ;}if(E){this._toggleHighlight(E,"from");this.itemArrowFromEvent.fire(this,E);}if(D==-1){if(this.delimChar&&this._sSavedQuery){if(!this._textMatchesOption()){this._elTextbox.value=this._sSavedQuery;}else{this._elTextbox.value=this._sSavedQuery+this._sCurQuery;}}else{this._elTextbox.value=this._sCurQuery;}this._oCurItem=null;return ;}if(D==-2){this._toggleContainer(false);return ;}var C=this._aListItems[D];var A=this._elContent;var B=((YAHOO.util.Dom.getStyle(A,"overflow")=="auto")||(YAHOO.util.Dom.getStyle(A,"overflowY")=="auto"));if(B&&(D>-1)&&(D(A.scrollTop+A.offsetHeight)){A.scrollTop=(C.offsetTop+C.offsetHeight)-A.offsetHeight;}else{if((C.offsetTop+C.offsetHeight)(A.scrollTop+A.offsetHeight)){this._elContent.scrollTop=(C.offsetTop+C.offsetHeight)-A.offsetHeight;}}}}this._toggleHighlight(C,"to");this.itemArrowToEvent.fire(this,C);if(this.typeAhead){this._updateValue(C);}}};YAHOO.widget.AutoComplete.prototype._onItemMouseover=function(A,B){if(B.prehighlightClassName){B._togglePrehighlight(this,"mouseover");}else{B._toggleHighlight(this,"to");}B.itemMouseOverEvent.fire(B,this);};YAHOO.widget.AutoComplete.prototype._onItemMouseout=function(A,B){if(B.prehighlightClassName){B._togglePrehighlight(this,"mouseout");}else{B._toggleHighlight(this,"from");}B.itemMouseOutEvent.fire(B,this);};YAHOO.widget.AutoComplete.prototype._onItemMouseclick=function(A,B){B._toggleHighlight(this,"to");B._selectItem(this);};YAHOO.widget.AutoComplete.prototype._onContainerMouseover=function(A,B){B._bOverContainer=true;};YAHOO.widget.AutoComplete.prototype._onContainerMouseout=function(A,B){B._bOverContainer=false;if(B._oCurItem){B._toggleHighlight(B._oCurItem,"to");}};YAHOO.widget.AutoComplete.prototype._onContainerScroll=function(A,B){B._elTextbox.focus();};YAHOO.widget.AutoComplete.prototype._onContainerResize=function(A,B){B._toggleContainerHelpers(B._bContainerOpen);};YAHOO.widget.AutoComplete.prototype._onTextboxKeyDown=function(A,B){var C=A.keyCode;switch(C){case 9:if(B._oCurItem){if(B.delimChar&&(B._nKeyCode!=C)){if(B._bContainerOpen){YAHOO.util.Event.stopEvent(A);}}B._selectItem(B._oCurItem);}else{B._toggleContainer(false);}break;case 13:if(!YAHOO.env.ua.webkit){if(B._oCurItem){if(B._nKeyCode!=C){if(B._bContainerOpen){YAHOO.util.Event.stopEvent(A);}}B._selectItem(B._oCurItem);}else{B._toggleContainer(false);}}break;case 27:B._toggleContainer(false);return ;case 39:B._jumpSelection();break;case 38:YAHOO.util.Event.stopEvent(A);B._moveSelection(C);break;case 40:YAHOO.util.Event.stopEvent(A);B._moveSelection(C);break;default:break;}};YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress=function(A,B){var C=A.keyCode;if(YAHOO.env.ua.webkit){switch(C){case 9:if(B._oCurItem){if(B.delimChar&&(B._nKeyCode!=C)){YAHOO.util.Event.stopEvent(A);}}break;case 13:if(B._oCurItem){if(B._nKeyCode!=C){if(B._bContainerOpen){YAHOO.util.Event.stopEvent(A);}}B._selectItem(B._oCurItem);}else{B._toggleContainer(false);}break;default:break;}}else{if(C==229){B._queryInterval=setInterval(function(){B._onIMEDetected(B);},500);}}};YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp=function(B,D){D._initProps();var E=B.keyCode;D._nKeyCode=E;var C=this.value;if(D._isIgnoreKey(E)||(C.toLowerCase()==D._sCurQuery)){return ;}else{D._bItemSelected=false;YAHOO.util.Dom.removeClass(D._oCurItem,D.highlightClassName);D._oCurItem=null;D.textboxKeyEvent.fire(D,E);}if(D.queryDelay>0){var A=setTimeout(function(){D._sendQuery(C);},(D.queryDelay*1000));if(D._nDelayID!=-1){clearTimeout(D._nDelayID);}D._nDelayID=A;}else{D._sendQuery(C);}};YAHOO.widget.AutoComplete.prototype._onTextboxFocus=function(A,B){B._elTextbox.setAttribute("autocomplete","off");B._bFocused=true;if(!B._bItemSelected){B.textboxFocusEvent.fire(B);}};YAHOO.widget.AutoComplete.prototype._onTextboxBlur=function(A,B){if(!B._bOverContainer||(B._nKeyCode==9)){if(!B._bItemSelected){var C=B._textMatchesOption();if(!B._bContainerOpen||(B._bContainerOpen&&(C===null))){if(B.forceSelection){B._clearSelection();}else{B.unmatchedItemSelectEvent.fire(B);}}else{if(B.forceSelection){B._selectItem(C);}}}if(B._bContainerOpen){B._toggleContainer(false);}B._cancelIntervalDetection(B);B._bFocused=false;B.textboxBlurEvent.fire(B);}};YAHOO.widget.AutoComplete.prototype._onWindowUnload=function(A,B){if(B&&B._elTextbox&&B.allowBrowserAutocomplete){B._elTextbox.setAttribute("autocomplete","on");}};YAHOO.widget.DataSource=function(){};YAHOO.widget.DataSource.ERROR_DATANULL="Response data was null";YAHOO.widget.DataSource.ERROR_DATAPARSE="Response data could not be parsed";YAHOO.widget.DataSource.prototype.maxCacheEntries=15;YAHOO.widget.DataSource.prototype.queryMatchContains=false;YAHOO.widget.DataSource.prototype.queryMatchSubset=false;YAHOO.widget.DataSource.prototype.queryMatchCase=false;YAHOO.widget.DataSource.prototype.toString=function(){return"DataSource "+this._sName;};YAHOO.widget.DataSource.prototype.getResults=function(A,D,B){var C=this._doQueryCache(A,D,B);if(C.length===0){this.queryEvent.fire(this,B,D);this.doQuery(A,D,B);}};YAHOO.widget.DataSource.prototype.doQuery=function(A,C,B){};YAHOO.widget.DataSource.prototype.flushCache=function(){if(this._aCache){this._aCache=[];}if(this._aCacheHelper){this._aCacheHelper=[];}this.cacheFlushEvent.fire(this);};YAHOO.widget.DataSource.prototype.queryEvent=null;YAHOO.widget.DataSource.prototype.cacheQueryEvent=null;YAHOO.widget.DataSource.prototype.getResultsEvent=null;YAHOO.widget.DataSource.prototype.getCachedResultsEvent=null;
+YAHOO.widget.DataSource.prototype.dataErrorEvent=null;YAHOO.widget.DataSource.prototype.cacheFlushEvent=null;YAHOO.widget.DataSource._nIndex=0;YAHOO.widget.DataSource.prototype._sName=null;YAHOO.widget.DataSource.prototype._aCache=null;YAHOO.widget.DataSource.prototype._init=function(){var A=this.maxCacheEntries;if(!YAHOO.lang.isNumber(A)||(A<0)){A=0;}if(A>0&&!this._aCache){this._aCache=[];}this._sName="instance"+YAHOO.widget.DataSource._nIndex;YAHOO.widget.DataSource._nIndex++;this.queryEvent=new YAHOO.util.CustomEvent("query",this);this.cacheQueryEvent=new YAHOO.util.CustomEvent("cacheQuery",this);this.getResultsEvent=new YAHOO.util.CustomEvent("getResults",this);this.getCachedResultsEvent=new YAHOO.util.CustomEvent("getCachedResults",this);this.dataErrorEvent=new YAHOO.util.CustomEvent("dataError",this);this.cacheFlushEvent=new YAHOO.util.CustomEvent("cacheFlush",this);};YAHOO.widget.DataSource.prototype._addCacheElem=function(B){var A=this._aCache;if(!A||!B||!B.query||!B.results){return ;}if(A.length>=this.maxCacheEntries){A.shift();}A.push(B);};YAHOO.widget.DataSource.prototype._doQueryCache=function(A,I,N){var H=[];var G=false;var J=this._aCache;var F=(J)?J.length:0;var K=this.queryMatchContains;var D;if((this.maxCacheEntries>0)&&J&&(F>0)){this.cacheQueryEvent.fire(this,N,I);if(!this.queryMatchCase){D=I;I=I.toLowerCase();}for(var P=F-1;P>=0;P--){var E=J[P];var B=E.results;var C=(!this.queryMatchCase)?encodeURIComponent(E.query).toLowerCase():encodeURIComponent(E.query);if(C==I){G=true;H=B;if(P!=F-1){J.splice(P,1);this._addCacheElem(E);}break;}else{if(this.queryMatchSubset){for(var O=I.length-1;O>=0;O--){var R=I.substr(0,O);if(C==R){G=true;for(var M=B.length-1;M>=0;M--){var Q=B[M];var L=(this.queryMatchCase)?encodeURIComponent(Q[0]).indexOf(I):encodeURIComponent(Q[0]).toLowerCase().indexOf(I);if((!K&&(L===0))||(K&&(L>-1))){H.unshift(Q);}}E={};E.query=I;E.results=H;this._addCacheElem(E);break;}}if(G){break;}}}}if(G){this.getCachedResultsEvent.fire(this,N,D,H);A(D,H,N);}}return H;};YAHOO.widget.DS_XHR=function(C,A,D){if(D&&(D.constructor==Object)){for(var B in D){this[B]=D[B];}}if(!YAHOO.lang.isArray(A)||!YAHOO.lang.isString(C)){return ;}this.schema=A;this.scriptURI=C;this._init();};YAHOO.widget.DS_XHR.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_XHR.TYPE_JSON=0;YAHOO.widget.DS_XHR.TYPE_XML=1;YAHOO.widget.DS_XHR.TYPE_FLAT=2;YAHOO.widget.DS_XHR.ERROR_DATAXHR="XHR response failed";YAHOO.widget.DS_XHR.prototype.connMgr=YAHOO.util.Connect;YAHOO.widget.DS_XHR.prototype.connTimeout=0;YAHOO.widget.DS_XHR.prototype.scriptURI=null;YAHOO.widget.DS_XHR.prototype.scriptQueryParam="query";YAHOO.widget.DS_XHR.prototype.scriptQueryAppend="";YAHOO.widget.DS_XHR.prototype.responseType=YAHOO.widget.DS_XHR.TYPE_JSON;YAHOO.widget.DS_XHR.prototype.responseStripAfter="\n0){D+="&"+this.scriptQueryAppend;}var C=null;var F=this;var I=function(K){if(!F._oConn||(K.tId!=F._oConn.tId)){F.dataErrorEvent.fire(F,B,G,YAHOO.widget.DataSource.ERROR_DATANULL);return ;}for(var N in K){}if(!J){K=K.responseText;}else{K=K.responseXML;}if(K===null){F.dataErrorEvent.fire(F,B,G,YAHOO.widget.DataSource.ERROR_DATANULL);return ;}var M=F.parseResponse(G,K,B);var L={};L.query=decodeURIComponent(G);L.results=M;if(M===null){F.dataErrorEvent.fire(F,B,G,YAHOO.widget.DataSource.ERROR_DATAPARSE);M=[];}else{F.getResultsEvent.fire(F,B,G,M);F._addCacheElem(L);}E(G,M,B);};var A=function(K){F.dataErrorEvent.fire(F,B,G,YAHOO.widget.DS_XHR.ERROR_DATAXHR);return ;};var H={success:I,failure:A};if(YAHOO.lang.isNumber(this.connTimeout)&&(this.connTimeout>0)){H.timeout=this.connTimeout;}if(this._oConn){this.connMgr.abort(this._oConn);}F._oConn=this.connMgr.asyncRequest("GET",D,H,null);};YAHOO.widget.DS_XHR.prototype.parseResponse=function(sQuery,oResponse,oParent){var aSchema=this.schema;var aResults=[];var bError=false;var nEnd=((this.responseStripAfter!=="")&&(oResponse.indexOf))?oResponse.indexOf(this.responseStripAfter):-1;if(nEnd!=-1){oResponse=oResponse.substring(0,nEnd);}switch(this.responseType){case YAHOO.widget.DS_XHR.TYPE_JSON:var jsonList,jsonObjParsed;if(YAHOO.lang.JSON){jsonObjParsed=YAHOO.lang.JSON.parse(oResponse);if(!jsonObjParsed){bError=true;break;}else{try{jsonList=eval("jsonObjParsed."+aSchema[0]);}catch(e){bError=true;break;}}}else{if(oResponse.parseJSON){jsonObjParsed=oResponse.parseJSON();if(!jsonObjParsed){bError=true;}else{try{jsonList=eval("jsonObjParsed."+aSchema[0]);}catch(e){bError=true;break;}}}else{if(window.JSON){jsonObjParsed=JSON.parse(oResponse);if(!jsonObjParsed){bError=true;break;}else{try{jsonList=eval("jsonObjParsed."+aSchema[0]);}catch(e){bError=true;break;}}}else{try{while(oResponse.substring(0,1)==" "){oResponse=oResponse.substring(1,oResponse.length);}if(oResponse.indexOf("{")<0){bError=true;break;}if(oResponse.indexOf("{}")===0){break;}var jsonObjRaw=eval("("+oResponse+")");if(!jsonObjRaw){bError=true;break;}jsonList=eval("(jsonObjRaw."+aSchema[0]+")");}catch(e){bError=true;break;}}}}if(!jsonList){bError=true;break;}if(!YAHOO.lang.isArray(jsonList)){jsonList=[jsonList];}for(var i=jsonList.length-1;i>=0;i--){var aResultItem=[];var jsonResult=jsonList[i];for(var j=aSchema.length-1;j>=1;j--){var dataFieldValue=jsonResult[aSchema[j]];if(!dataFieldValue){dataFieldValue="";}aResultItem.unshift(dataFieldValue);}if(aResultItem.length==1){aResultItem.push(jsonResult);}aResults.unshift(aResultItem);}break;case YAHOO.widget.DS_XHR.TYPE_XML:var xmlList=oResponse.getElementsByTagName(aSchema[0]);if(!xmlList){bError=true;break;}for(var k=xmlList.length-1;k>=0;k--){var result=xmlList.item(k);var aFieldSet=[];for(var m=aSchema.length-1;m>=1;m--){var sValue=null;var xmlAttr=result.attributes.getNamedItem(aSchema[m]);if(xmlAttr){sValue=xmlAttr.value;}else{var xmlNode=result.getElementsByTagName(aSchema[m]);if(xmlNode&&xmlNode.item(0)&&xmlNode.item(0).firstChild){sValue=xmlNode.item(0).firstChild.nodeValue;
+}else{sValue="";}}aFieldSet.unshift(sValue);}aResults.unshift(aFieldSet);}break;case YAHOO.widget.DS_XHR.TYPE_FLAT:if(oResponse.length>0){var newLength=oResponse.length-aSchema[0].length;if(oResponse.substr(newLength)==aSchema[0]){oResponse=oResponse.substr(0,newLength);}var aRecords=oResponse.split(aSchema[0]);for(var n=aRecords.length-1;n>=0;n--){aResults[n]=aRecords[n].split(aSchema[1]);}}break;default:break;}sQuery=null;oResponse=null;oParent=null;if(bError){return null;}else{return aResults;}};YAHOO.widget.DS_XHR.prototype._oConn=null;YAHOO.widget.DS_ScriptNode=function(D,A,C){if(C&&(C.constructor==Object)){for(var B in C){this[B]=C[B];}}if(!YAHOO.lang.isArray(A)||!YAHOO.lang.isString(D)){return ;}this.schema=A;this.scriptURI=D;this._init();};YAHOO.widget.DS_ScriptNode.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_ScriptNode.prototype.getUtility=YAHOO.util.Get;YAHOO.widget.DS_ScriptNode.prototype.scriptURI=null;YAHOO.widget.DS_ScriptNode.prototype.scriptQueryParam="query";YAHOO.widget.DS_ScriptNode.prototype.asyncMode="allowAll";YAHOO.widget.DS_ScriptNode.prototype.scriptCallbackParam="callback";YAHOO.widget.DS_ScriptNode.callbacks=[];YAHOO.widget.DS_ScriptNode._nId=0;YAHOO.widget.DS_ScriptNode._nPending=0;YAHOO.widget.DS_ScriptNode.prototype.doQuery=function(A,F,C){var B=this;if(YAHOO.widget.DS_ScriptNode._nPending===0){YAHOO.widget.DS_ScriptNode.callbacks=[];YAHOO.widget.DS_ScriptNode._nId=0;}var E=YAHOO.widget.DS_ScriptNode._nId;YAHOO.widget.DS_ScriptNode._nId++;YAHOO.widget.DS_ScriptNode.callbacks[E]=function(G){if((B.asyncMode!=="ignoreStaleResponses")||(E===YAHOO.widget.DS_ScriptNode.callbacks.length-1)){B.handleResponse(G,A,F,C);}else{}delete YAHOO.widget.DS_ScriptNode.callbacks[E];};YAHOO.widget.DS_ScriptNode._nPending++;var D=this.scriptURI+"&"+this.scriptQueryParam+"="+F+"&"+this.scriptCallbackParam+"=YAHOO.widget.DS_ScriptNode.callbacks["+E+"]";this.getUtility.script(D,{autopurge:true,onsuccess:YAHOO.widget.DS_ScriptNode._bumpPendingDown,onfail:YAHOO.widget.DS_ScriptNode._bumpPendingDown});};YAHOO.widget.DS_ScriptNode.prototype.handleResponse=function(oResponse,oCallbackFn,sQuery,oParent){var aSchema=this.schema;var aResults=[];var bError=false;var jsonList,jsonObjParsed;try{jsonList=eval("(oResponse."+aSchema[0]+")");}catch(e){bError=true;}if(!jsonList){bError=true;jsonList=[];}else{if(!YAHOO.lang.isArray(jsonList)){jsonList=[jsonList];}}for(var i=jsonList.length-1;i>=0;i--){var aResultItem=[];var jsonResult=jsonList[i];for(var j=aSchema.length-1;j>=1;j--){var dataFieldValue=jsonResult[aSchema[j]];if(!dataFieldValue){dataFieldValue="";}aResultItem.unshift(dataFieldValue);}if(aResultItem.length==1){aResultItem.push(jsonResult);}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);};YAHOO.widget.DS_ScriptNode._bumpPendingDown=function(){YAHOO.widget.DS_ScriptNode._nPending--;};YAHOO.widget.DS_JSFunction=function(A,C){if(C&&(C.constructor==Object)){for(var B in C){this[B]=C[B];}}if(!YAHOO.lang.isFunction(A)){return ;}else{this.dataFunction=A;this._init();}};YAHOO.widget.DS_JSFunction.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_JSFunction.prototype.dataFunction=null;YAHOO.widget.DS_JSFunction.prototype.doQuery=function(C,F,D){var B=this.dataFunction;var E=[];E=B(F);if(E===null){this.dataErrorEvent.fire(this,D,F,YAHOO.widget.DataSource.ERROR_DATANULL);return ;}var A={};A.query=decodeURIComponent(F);A.results=E;this._addCacheElem(A);this.getResultsEvent.fire(this,D,F,E);C(F,E,D);return ;};YAHOO.widget.DS_JSArray=function(A,C){if(C&&(C.constructor==Object)){for(var B in C){this[B]=C[B];}}if(!YAHOO.lang.isArray(A)){return ;}else{this.data=A;this._init();}};YAHOO.widget.DS_JSArray.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_JSArray.prototype.data=null;YAHOO.widget.DS_JSArray.prototype.doQuery=function(E,I,A){var F;var C=this.data;var J=[];var D=false;var B=this.queryMatchContains;if(I){if(!this.queryMatchCase){I=I.toLowerCase();}for(F=C.length-1;F>=0;F--){var H=[];if(YAHOO.lang.isString(C[F])){H[0]=C[F];}else{if(YAHOO.lang.isArray(C[F])){H=C[F];}}if(YAHOO.lang.isString(H[0])){var G=(this.queryMatchCase)?encodeURIComponent(H[0]).indexOf(I):encodeURIComponent(H[0]).toLowerCase().indexOf(I);if((!B&&(G===0))||(B&&(G>-1))){J.unshift(H);}}}}else{for(F=C.length-1;F>=0;F--){if(YAHOO.lang.isString(C[F])){J.unshift([C[F]]);}else{if(YAHOO.lang.isArray(C[F])){J.unshift(C[F]);}}}}this.getResultsEvent.fire(this,A,I,J);E(I,J,A);};YAHOO.register("autocomplete",YAHOO.widget.AutoComplete,{version:"2.5.0",build:"895"});
\ No newline at end of file
diff --git a/lib/yui/autocomplete/autocomplete.js b/lib/yui/autocomplete/autocomplete.js
index 72a6772b59..d435e873c4 100755
--- a/lib/yui/autocomplete/autocomplete.js
+++ b/lib/yui/autocomplete/autocomplete.js
@@ -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
*/
/**
* The AutoComplete control provides the front-end logic for text-entry suggestion and
@@ -10,7 +10,7 @@ version: 2.3.0
*
* @module autocomplete
* @requires yahoo, dom, event, datasource
- * @optional animation, connection
+ * @optional animation, connection, get
* @namespace YAHOO.widget
* @title AutoComplete Widget
*/
@@ -53,15 +53,15 @@ YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) {
if(YAHOO.util.Dom.inDocument(elInput)) {
if(YAHOO.lang.isString(elInput)) {
this._sName = "instance" + YAHOO.widget.AutoComplete._nIndex + " " + elInput;
- this._oTextbox = document.getElementById(elInput);
+ this._elTextbox = document.getElementById(elInput);
}
else {
this._sName = (elInput.id) ?
"instance" + YAHOO.widget.AutoComplete._nIndex + " " + elInput.id:
"instance" + YAHOO.widget.AutoComplete._nIndex;
- this._oTextbox = elInput;
+ this._elTextbox = elInput;
}
- YAHOO.util.Dom.addClass(this._oTextbox, "yui-ac-input");
+ YAHOO.util.Dom.addClass(this._elTextbox, "yui-ac-input");
}
else {
return;
@@ -70,28 +70,21 @@ YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) {
// Validate container element
if(YAHOO.util.Dom.inDocument(elContainer)) {
if(YAHOO.lang.isString(elContainer)) {
- this._oContainer = document.getElementById(elContainer);
+ this._elContainer = document.getElementById(elContainer);
}
else {
- this._oContainer = elContainer;
+ this._elContainer = elContainer;
}
- if(this._oContainer.style.display == "none") {
+ if(this._elContainer.style.display == "none") {
}
// For skinning
- var elParent = this._oContainer.parentNode;
+ var elParent = this._elContainer.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") {
+ YAHOO.util.Dom.addClass(elParent, "yui-ac");
}
- if(elTag != "div") {
+ else {
}
}
else {
@@ -115,23 +108,21 @@ YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) {
// Set up events
var oSelf = this;
- var oTextbox = this._oTextbox;
+ var elTextbox = this._elTextbox;
// Events are actually for the content module within the container
- var oContent = this._oContainer._oContent;
+ var elContent = this._elContent;
// Dom events
- 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);
+ YAHOO.util.Event.addListener(elTextbox,"keyup",oSelf._onTextboxKeyUp,oSelf);
+ YAHOO.util.Event.addListener(elTextbox,"keydown",oSelf._onTextboxKeyDown,oSelf);
+ YAHOO.util.Event.addListener(elTextbox,"focus",oSelf._onTextboxFocus,oSelf);
+ YAHOO.util.Event.addListener(elTextbox,"blur",oSelf._onTextboxBlur,oSelf);
+ YAHOO.util.Event.addListener(elContent,"mouseover",oSelf._onContainerMouseover,oSelf);
+ YAHOO.util.Event.addListener(elContent,"mouseout",oSelf._onContainerMouseout,oSelf);
+ YAHOO.util.Event.addListener(elContent,"scroll",oSelf._onContainerScroll,oSelf);
+ YAHOO.util.Event.addListener(elContent,"resize",oSelf._onContainerResize,oSelf);
+ YAHOO.util.Event.addListener(elTextbox,"keypress",oSelf._onTextboxKeyPress,oSelf);
+ YAHOO.util.Event.addListener(window,"unload",oSelf._onWindowUnload,oSelf);
// Custom events
this.textboxFocusEvent = new YAHOO.util.CustomEvent("textboxFocus", this);
@@ -152,7 +143,7 @@ YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) {
this.textboxBlurEvent = new YAHOO.util.CustomEvent("textboxBlur", this);
// Finish up
- oTextbox.setAttribute("autocomplete","off");
+ elTextbox.setAttribute("autocomplete","off");
YAHOO.widget.AutoComplete._nIndex++;
}
// Required arguments were not found
@@ -408,15 +399,16 @@ YAHOO.widget.AutoComplete.prototype.getListItemData = function(oListItem) {
* @param sHeader {String} HTML markup for results container header.
*/
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";
+ if(this._elHeader) {
+ var elHeader = this._elHeader;
+ if(sHeader) {
+ elHeader.innerHTML = sHeader;
+ elHeader.style.display = "block";
+ }
+ else {
+ elHeader.innerHTML = "";
+ elHeader.style.display = "none";
}
- }
- else {
- this._oContainer._oContent._oHeader.innerHTML = "";
- this._oContainer._oContent._oHeader.style.display = "none";
}
};
@@ -428,15 +420,16 @@ YAHOO.widget.AutoComplete.prototype.setHeader = function(sHeader) {
* @param sFooter {String} HTML markup for results container footer.
*/
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";
+ if(this._elFooter) {
+ var elFooter = this._elFooter;
+ if(sFooter) {
+ elFooter.innerHTML = sFooter;
+ elFooter.style.display = "block";
+ }
+ else {
+ elFooter.innerHTML = "";
+ elFooter.style.display = "none";
}
- }
- else {
- this._oContainer._oContent._oFooter.innerHTML = "";
- this._oContainer._oContent._oFooter.style.display = "none";
}
};
@@ -448,18 +441,19 @@ YAHOO.widget.AutoComplete.prototype.setFooter = function(sFooter) {
* @param sBody {String} HTML markup for results container body.
*/
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";
+ if(this._elBody) {
+ var elBody = this._elBody;
+ if(sBody) {
+ elBody.innerHTML = sBody;
+ elBody.style.display = "block";
+ elBody.style.display = "block";
}
+ else {
+ elBody.innerHTML = "";
+ elBody.style.display = "none";
+ }
+ this._maxResultsDisplayed = 0;
}
- else {
- this._oContainer._oContent._oBody.innerHTML = "";
- this._oContainer._oContent.style.display = "none";
- }
- this._maxResultsDisplayed = 0;
};
/**
@@ -488,13 +482,13 @@ YAHOO.widget.AutoComplete.prototype.formatResult = function(oResultItem, sQuery)
* and DOM elements.
*
* @method doBeforeExpandContainer
- * @param oTextbox {HTMLElement} The text input box.
- * @param oContainer {HTMLElement} The container element.
+ * @param elTextbox {HTMLElement} The text input box.
+ * @param elContainer {HTMLElement} The container element.
* @param sQuery {String} The query string.
* @param aResults {Object[]} An array of query results.
* @return {Boolean} Return true to continue expanding container, false to cancel the expand.
*/
-YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer = function(oTextbox, oContainer, sQuery, aResults) {
+YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer = function(elTextbox, elContainer, sQuery, aResults) {
return true;
};
@@ -529,26 +523,26 @@ YAHOO.widget.AutoComplete.prototype.doBeforeSendQuery = function(sQuery) {
*/
YAHOO.widget.AutoComplete.prototype.destroy = function() {
var instanceName = this.toString();
- var elInput = this._oTextbox;
- var elContainer = this._oContainer;
+ var elInput = this._elTextbox;
+ var elContainer = this._elContainer;
// Unhook custom events
- 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();
+ this.textboxFocusEvent.unsubscribeAll();
+ this.textboxKeyEvent.unsubscribeAll();
+ this.dataRequestEvent.unsubscribeAll();
+ this.dataReturnEvent.unsubscribeAll();
+ this.dataErrorEvent.unsubscribeAll();
+ this.containerExpandEvent.unsubscribeAll();
+ this.typeAheadEvent.unsubscribeAll();
+ this.itemMouseOverEvent.unsubscribeAll();
+ this.itemMouseOutEvent.unsubscribeAll();
+ this.itemArrowToEvent.unsubscribeAll();
+ this.itemArrowFromEvent.unsubscribeAll();
+ this.itemSelectEvent.unsubscribeAll();
+ this.unmatchedItemSelectEvent.unsubscribeAll();
+ this.selectionEnforceEvent.unsubscribeAll();
+ this.containerCollapseEvent.unsubscribeAll();
+ this.textboxBlurEvent.unsubscribeAll();
// Unhook DOM events
YAHOO.util.Event.purgeElement(elInput, true);
@@ -559,7 +553,7 @@ YAHOO.widget.AutoComplete.prototype.destroy = function() {
// Null out objects
for(var key in this) {
- if(this.hasOwnProperty(key)) {
+ if(YAHOO.lang.hasOwnProperty(this, key)) {
this[key] = null;
}
}
@@ -687,12 +681,9 @@ YAHOO.widget.AutoComplete.prototype.itemSelectEvent = null;
/**
* Fired when a user selection does not match any of the displayed result items.
- * Note that this event may not behave as expected when delimiter characters
- * have been defined.
*
* @event unmatchedItemSelectEvent
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param sQuery {String} The user-typed query string.
*/
YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent = null;
@@ -749,11 +740,74 @@ YAHOO.widget.AutoComplete.prototype._sName = null;
/**
* Text input field DOM element.
*
- * @property _oTextbox
+ * @property _elTextbox
* @type HTMLElement
* @private
*/
-YAHOO.widget.AutoComplete.prototype._oTextbox = null;
+YAHOO.widget.AutoComplete.prototype._elTextbox = null;
+
+/**
+ * Container DOM element.
+ *
+ * @property _elContainer
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._elContainer = null;
+
+/**
+ * Reference to content element within container element.
+ *
+ * @property _elContent
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._elContent = null;
+
+/**
+ * Reference to header element within content element.
+ *
+ * @property _elHeader
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._elHeader = null;
+
+/**
+ * Reference to body element within content element.
+ *
+ * @property _elBody
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._elBody = null;
+
+/**
+ * Reference to footer element within content element.
+ *
+ * @property _elFooter
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._elFooter = null;
+
+/**
+ * Reference to shadow element within container element.
+ *
+ * @property _elShadow
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._elShadow = null;
+
+/**
+ * Reference to iframe element within container element.
+ *
+ * @property _elIFrame
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._elIFrame = null;
/**
* Whether or not the input field is currently in focus. If query results come back
@@ -774,15 +828,6 @@ YAHOO.widget.AutoComplete.prototype._bFocused = true;
*/
YAHOO.widget.AutoComplete.prototype._oAnim = null;
-/**
- * Container DOM element.
- *
- * @property _oContainer
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._oContainer = null;
-
/**
* Whether or not the results container is currently open.
*
@@ -944,7 +989,7 @@ YAHOO.widget.AutoComplete.prototype._initProps = function() {
this.queryDelay = 0.2;
}
var delimChar = this.delimChar;
- if(YAHOO.lang.isString(delimChar)) {
+ if(YAHOO.lang.isString(delimChar) && (delimChar.length > 0)) {
this.delimChar = [delimChar];
}
else if(!YAHOO.lang.isArray(delimChar)) {
@@ -956,7 +1001,7 @@ YAHOO.widget.AutoComplete.prototype._initProps = function() {
this.animSpeed = 0.3;
}
if(!this._oAnim ) {
- this._oAnim = new YAHOO.util.Anim(this._oContainer._oContent, {}, this.animSpeed);
+ this._oAnim = new YAHOO.util.Anim(this._elContent, {}, this.animSpeed);
}
else {
this._oAnim.duration = this.animSpeed;
@@ -974,21 +1019,21 @@ YAHOO.widget.AutoComplete.prototype._initProps = function() {
* @private
*/
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);
+ if(this.useShadow && !this._elShadow) {
+ var elShadow = document.createElement("div");
+ elShadow.className = "yui-ac-shadow";
+ this._elShadow = this._elContainer.appendChild(elShadow);
+ }
+ if(this.useIFrame && !this._elIFrame) {
+ var elIFrame = document.createElement("iframe");
+ elIFrame.src = this._iFrameSrc;
+ elIFrame.frameBorder = 0;
+ elIFrame.scrolling = "no";
+ elIFrame.style.position = "absolute";
+ elIFrame.style.width = "100%";
+ elIFrame.style.height = "100%";
+ elIFrame.tabIndex = -1;
+ this._elIFrame = this._elContainer.appendChild(elIFrame);
}
};
@@ -999,28 +1044,28 @@ YAHOO.widget.AutoComplete.prototype._initContainerHelpers = function() {
* @private
*/
YAHOO.widget.AutoComplete.prototype._initContainer = function() {
- YAHOO.util.Dom.addClass(this._oContainer, "yui-ac-container");
+ YAHOO.util.Dom.addClass(this._elContainer, "yui-ac-container");
- if(!this._oContainer._oContent) {
- // The oContent div helps size the iframe and shadow properly
- 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);
+ if(!this._elContent) {
+ // The elContent div helps size the iframe and shadow properly
+ var elContent = document.createElement("div");
+ elContent.className = "yui-ac-content";
+ elContent.style.display = "none";
+ this._elContent = this._elContainer.appendChild(elContent);
+
+ var elHeader = document.createElement("div");
+ elHeader.className = "yui-ac-hd";
+ elHeader.style.display = "none";
+ this._elHeader = this._elContent.appendChild(elHeader);
+
+ var elBody = document.createElement("div");
+ elBody.className = "yui-ac-bd";
+ this._elBody = this._elContent.appendChild(elBody);
+
+ var elFooter = document.createElement("div");
+ elFooter.className = "yui-ac-ft";
+ elFooter.style.display = "none";
+ this._elFooter = this._elContent.appendChild(elFooter);
}
else {
}
@@ -1036,18 +1081,18 @@ YAHOO.widget.AutoComplete.prototype._initContainer = function() {
*/
YAHOO.widget.AutoComplete.prototype._initList = function() {
this._aListItems = [];
- while(this._oContainer._oContent._oBody.hasChildNodes()) {
+ while(this._elBody.hasChildNodes()) {
var oldListItems = this.getListItems();
if(oldListItems) {
for(var oldi = oldListItems.length-1; oldi >= 0; oldi--) {
oldListItems[oldi] = null;
}
}
- this._oContainer._oContent._oBody.innerHTML = "";
+ this._elBody.innerHTML = "";
}
var oList = document.createElement("ul");
- oList = this._oContainer._oContent._oBody.appendChild(oList);
+ oList = this._elBody.appendChild(oList);
for(var i=0; i -1) {
- this._oTextbox.value = sValue.substring(0,nIndex);
+ this._elTextbox.value = sValue.substring(0,nIndex);
}
else {
- this._oTextbox.value = "";
+ this._elTextbox.value = "";
}
- this._sSavedQuery = this._oTextbox.value;
+ this._sSavedQuery = this._elTextbox.value;
// Fire custom event
this.selectionEnforceEvent.fire(this);
@@ -1355,20 +1400,20 @@ YAHOO.widget.AutoComplete.prototype._typeAhead = function(oItem, sQuery) {
return;
}
- var oTextbox = this._oTextbox;
- var sValue = this._oTextbox.value; // any saved queries plus what user has typed
+ var elTextbox = this._elTextbox;
+ var sValue = this._elTextbox.value; // any saved queries plus what user has typed
// Don't update with type-ahead if text selection is not supported
- if(!oTextbox.setSelectionRange && !oTextbox.createTextRange) {
+ if(!elTextbox.setSelectionRange && !elTextbox.createTextRange) {
return;
}
// Select the portion of text that the user has not typed
var nStart = sValue.length;
this._updateValue(oItem);
- var nEnd = oTextbox.value.length;
- this._selectText(oTextbox,nStart,nEnd);
- var sPrefill = oTextbox.value.substr(nStart,nEnd);
+ var nEnd = elTextbox.value.length;
+ this._selectText(elTextbox,nStart,nEnd);
+ var sPrefill = elTextbox.value.substr(nStart,nEnd);
this.typeAheadEvent.fire(this,sQuery,sPrefill);
};
@@ -1376,23 +1421,23 @@ YAHOO.widget.AutoComplete.prototype._typeAhead = function(oItem, sQuery) {
* Selects text in the input field.
*
* @method _selectText
- * @param oTextbox {HTMLElement} Text input box element in which to select text.
+ * @param elTextbox {HTMLElement} Text input box element in which to select text.
* @param nStart {Number} Starting index of text string to select.
* @param nEnd {Number} Ending index of text selection.
* @private
*/
-YAHOO.widget.AutoComplete.prototype._selectText = function(oTextbox, nStart, nEnd) {
- if(oTextbox.setSelectionRange) { // For Mozilla
- oTextbox.setSelectionRange(nStart,nEnd);
+YAHOO.widget.AutoComplete.prototype._selectText = function(elTextbox, nStart, nEnd) {
+ if(elTextbox.setSelectionRange) { // For Mozilla
+ elTextbox.setSelectionRange(nStart,nEnd);
}
- else if(oTextbox.createTextRange) { // For IE
- var oTextRange = oTextbox.createTextRange();
+ else if(elTextbox.createTextRange) { // For IE
+ var oTextRange = elTextbox.createTextRange();
oTextRange.moveStart("character", nStart);
- oTextRange.moveEnd("character", nEnd-oTextbox.value.length);
+ oTextRange.moveEnd("character", nEnd-elTextbox.value.length);
oTextRange.select();
}
else {
- oTextbox.select();
+ elTextbox.select();
}
};
@@ -1405,29 +1450,29 @@ YAHOO.widget.AutoComplete.prototype._selectText = function(oTextbox, nStart, nEn
*/
YAHOO.widget.AutoComplete.prototype._toggleContainerHelpers = function(bShow) {
var bFireEvent = false;
- var width = this._oContainer._oContent.offsetWidth + "px";
- var height = this._oContainer._oContent.offsetHeight + "px";
+ var width = this._elContent.offsetWidth + "px";
+ var height = this._elContent.offsetHeight + "px";
- if(this.useIFrame && this._oContainer._oIFrame) {
+ if(this.useIFrame && this._elIFrame) {
bFireEvent = true;
if(bShow) {
- this._oContainer._oIFrame.style.width = width;
- this._oContainer._oIFrame.style.height = height;
+ this._elIFrame.style.width = width;
+ this._elIFrame.style.height = height;
}
else {
- this._oContainer._oIFrame.style.width = 0;
- this._oContainer._oIFrame.style.height = 0;
+ this._elIFrame.style.width = 0;
+ this._elIFrame.style.height = 0;
}
}
- if(this.useShadow && this._oContainer._oShadow) {
+ if(this.useShadow && this._elShadow) {
bFireEvent = true;
if(bShow) {
- this._oContainer._oShadow.style.width = width;
- this._oContainer._oShadow.style.height = height;
+ this._elShadow.style.width = width;
+ this._elShadow.style.height = height;
}
else {
- this._oContainer._oShadow.style.width = 0;
- this._oContainer._oShadow.style.height = 0;
+ this._elShadow.style.width = 0;
+ this._elShadow.style.height = 0;
}
}
};
@@ -1440,7 +1485,7 @@ YAHOO.widget.AutoComplete.prototype._toggleContainerHelpers = function(bShow) {
* @private
*/
YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
- var oContainer = this._oContainer;
+ var elContainer = this._elContainer;
// Implementer has container always open so don't mess with it
if(this.alwaysShowContainer && this._bContainerOpen) {
@@ -1449,7 +1494,7 @@ YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
// Clear contents of container
if(!bShow) {
- this._oContainer._oContent.scrollTop = 0;
+ this._elContent.scrollTop = 0;
var aItems = this._aListItems;
if(aItems && (aItems.length > 0)) {
@@ -1469,7 +1514,7 @@ YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
// Container is already closed
if(!bShow && !this._bContainerOpen) {
- oContainer._oContent.style.display = "none";
+ this._elContent.style.display = "none";
return;
}
@@ -1487,8 +1532,8 @@ YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
}
// Clone container to grab current size offscreen
- var oClone = oContainer._oContent.cloneNode(true);
- oContainer.appendChild(oClone);
+ var oClone = this._elContent.cloneNode(true);
+ elContainer.appendChild(oClone);
oClone.style.top = "-9000px";
oClone.style.display = "block";
@@ -1507,16 +1552,16 @@ YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
// If opening anew, set to a collapsed size...
if(bShow && !this._bContainerOpen) {
- oContainer._oContent.style.width = wColl+"px";
- oContainer._oContent.style.height = hColl+"px";
+ this._elContent.style.width = wColl+"px";
+ this._elContent.style.height = hColl+"px";
}
// Else, set it to its last known size.
else {
- oContainer._oContent.style.width = wExp+"px";
- oContainer._oContent.style.height = hExp+"px";
+ this._elContent.style.width = wExp+"px";
+ this._elContent.style.height = hExp+"px";
}
- oContainer.removeChild(oClone);
+ elContainer.removeChild(oClone);
oClone = null;
var oSelf = this;
@@ -1528,14 +1573,14 @@ YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
oSelf.containerExpandEvent.fire(oSelf);
}
else {
- oContainer._oContent.style.display = "none";
+ oSelf._elContent.style.display = "none";
oSelf.containerCollapseEvent.fire(oSelf);
}
oSelf._toggleContainerHelpers(bShow);
};
// Display container and animate it
- oContainer._oContent.style.display = "block";
+ this._elContent.style.display = "block";
oAnim.onComplete.subscribe(onAnimComplete);
oAnim.animate();
this._bContainerOpen = bShow;
@@ -1543,11 +1588,11 @@ YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
// Else don't animate, just show or hide
else {
if(bShow) {
- oContainer._oContent.style.display = "block";
+ this._elContent.style.display = "block";
this.containerExpandEvent.fire(this);
}
else {
- oContainer._oContent.style.display = "none";
+ this._elContent.style.display = "none";
this.containerCollapseEvent.fire(this);
}
this._toggleContainerHelpers(bShow);
@@ -1612,34 +1657,34 @@ YAHOO.widget.AutoComplete.prototype._togglePrehighlight = function(oNewItem, sTy
* @private
*/
YAHOO.widget.AutoComplete.prototype._updateValue = function(oItem) {
- var oTextbox = this._oTextbox;
+ var elTextbox = this._elTextbox;
var sDelimChar = (this.delimChar) ? (this.delimChar[0] || this.delimChar) : null;
var sSavedQuery = this._sSavedQuery;
var sResultKey = oItem._sResultKey;
- oTextbox.focus();
+ elTextbox.focus();
// First clear text field
- oTextbox.value = "";
+ elTextbox.value = "";
// Grab data to put into text field
if(sDelimChar) {
if(sSavedQuery) {
- oTextbox.value = sSavedQuery;
+ elTextbox.value = sSavedQuery;
}
- oTextbox.value += sResultKey + sDelimChar;
+ elTextbox.value += sResultKey + sDelimChar;
if(sDelimChar != " ") {
- oTextbox.value += " ";
+ elTextbox.value += " ";
}
}
- else { oTextbox.value = sResultKey; }
+ else { elTextbox.value = sResultKey; }
// scroll to bottom of textarea if necessary
- if(oTextbox.type == "textarea") {
- oTextbox.scrollTop = oTextbox.scrollHeight;
+ if(elTextbox.type == "textarea") {
+ elTextbox.scrollTop = elTextbox.scrollHeight;
}
// move cursor to end
- var end = oTextbox.value.length;
- this._selectText(oTextbox,end,end);
+ var end = elTextbox.value.length;
+ this._selectText(elTextbox,end,end);
this._oCurItem = oItem;
};
@@ -1711,14 +1756,14 @@ YAHOO.widget.AutoComplete.prototype._moveSelection = function(nKeyCode) {
// Go back to query (remove type-ahead string)
if(this.delimChar && this._sSavedQuery) {
if(!this._textMatchesOption()) {
- this._oTextbox.value = this._sSavedQuery;
+ this._elTextbox.value = this._sSavedQuery;
}
else {
- this._oTextbox.value = this._sSavedQuery + this._sCurQuery;
+ this._elTextbox.value = this._sSavedQuery + this._sCurQuery;
}
}
else {
- this._oTextbox.value = this._sCurQuery;
+ this._elTextbox.value = this._sCurQuery;
}
this._oCurItem = null;
return;
@@ -1732,36 +1777,36 @@ YAHOO.widget.AutoComplete.prototype._moveSelection = function(nKeyCode) {
var oNewItem = this._aListItems[nNewItemIndex];
// Scroll the container if necessary
- var oContent = this._oContainer._oContent;
- var scrollOn = ((YAHOO.util.Dom.getStyle(oContent,"overflow") == "auto") ||
- (YAHOO.util.Dom.getStyle(oContent,"overflowY") == "auto"));
+ var elContent = this._elContent;
+ var scrollOn = ((YAHOO.util.Dom.getStyle(elContent,"overflow") == "auto") ||
+ (YAHOO.util.Dom.getStyle(elContent,"overflowY") == "auto"));
if(scrollOn && (nNewItemIndex > -1) &&
(nNewItemIndex < this._nDisplayedItems)) {
// User is keying down
if(nKeyCode == 40) {
// Bottom of selected item is below scroll area...
- if((oNewItem.offsetTop+oNewItem.offsetHeight) > (oContent.scrollTop + oContent.offsetHeight)) {
+ if((oNewItem.offsetTop+oNewItem.offsetHeight) > (elContent.scrollTop + elContent.offsetHeight)) {
// Set bottom of scroll area to bottom of selected item
- oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - oContent.offsetHeight;
+ elContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - elContent.offsetHeight;
}
// Bottom of selected item is above scroll area...
- else if((oNewItem.offsetTop+oNewItem.offsetHeight) < oContent.scrollTop) {
+ else if((oNewItem.offsetTop+oNewItem.offsetHeight) < elContent.scrollTop) {
// Set top of selected item to top of scroll area
- oContent.scrollTop = oNewItem.offsetTop;
+ elContent.scrollTop = oNewItem.offsetTop;
}
}
// User is keying up
else {
// Top of selected item is above scroll area
- if(oNewItem.offsetTop < oContent.scrollTop) {
+ if(oNewItem.offsetTop < elContent.scrollTop) {
// Set top of scroll area to top of selected item
- this._oContainer._oContent.scrollTop = oNewItem.offsetTop;
+ this._elContent.scrollTop = oNewItem.offsetTop;
}
// Top of selected item is below scroll area
- else if(oNewItem.offsetTop > (oContent.scrollTop + oContent.offsetHeight)) {
+ else if(oNewItem.offsetTop > (elContent.scrollTop + elContent.offsetHeight)) {
// Set bottom of selected item to bottom of scroll area
- this._oContainer._oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - oContent.offsetHeight;
+ this._elContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - elContent.offsetHeight;
}
}
}
@@ -1869,7 +1914,7 @@ YAHOO.widget.AutoComplete.prototype._onContainerMouseout = function(v,oSelf) {
* @private
*/
YAHOO.widget.AutoComplete.prototype._onContainerScroll = function(v,oSelf) {
- oSelf._oTextbox.focus();
+ oSelf._elTextbox.focus();
};
/**
@@ -1912,16 +1957,18 @@ YAHOO.widget.AutoComplete.prototype._onTextboxKeyDown = function(v,oSelf) {
}
break;
case 13: // enter
- if(oSelf._oCurItem) {
- if(oSelf._nKeyCode != nKeyCode) {
- if(oSelf._bContainerOpen) {
- YAHOO.util.Event.stopEvent(v);
+ if(!YAHOO.env.ua.webkit) {
+ if(oSelf._oCurItem) {
+ if(oSelf._nKeyCode != nKeyCode) {
+ if(oSelf._bContainerOpen) {
+ YAHOO.util.Event.stopEvent(v);
+ }
}
+ oSelf._selectItem(oSelf._oCurItem);
+ }
+ else {
+ oSelf._toggleContainer(false);
}
- oSelf._selectItem(oSelf._oCurItem);
- }
- else {
- oSelf._toggleContainer(false);
}
break;
case 27: // esc
@@ -1954,22 +2001,27 @@ YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress = function(v,oSelf) {
var nKeyCode = v.keyCode;
//Expose only to Mac browsers, where stopEvent is ineffective on keydown events (bug 790337)
- var isMac = (navigator.userAgent.toLowerCase().indexOf("mac") != -1);
- if(isMac) {
+ if(YAHOO.env.ua.webkit) {
switch (nKeyCode) {
case 9: // tab
- if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) {
- YAHOO.util.Event.stopEvent(v);
+ if(oSelf._oCurItem) {
+ if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) {
+ YAHOO.util.Event.stopEvent(v);
+ }
}
break;
case 13: // enter
- if(oSelf._nKeyCode != nKeyCode) {
- YAHOO.util.Event.stopEvent(v);
+ if(oSelf._oCurItem) {
+ if(oSelf._nKeyCode != nKeyCode) {
+ if(oSelf._bContainerOpen) {
+ YAHOO.util.Event.stopEvent(v);
+ }
+ }
+ oSelf._selectItem(oSelf._oCurItem);
+ }
+ else {
+ oSelf._toggleContainer(false);
}
- break;
- case 38: // up
- case 40: // down
- YAHOO.util.Event.stopEvent(v);
break;
default:
break;
@@ -1996,6 +2048,7 @@ YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp = function(v,oSelf) {
oSelf._initProps();
var nKeyCode = v.keyCode;
+
oSelf._nKeyCode = nKeyCode;
var sText = this.value; //string in textbox
@@ -2037,7 +2090,7 @@ YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp = function(v,oSelf) {
* @private
*/
YAHOO.widget.AutoComplete.prototype._onTextboxFocus = function (v,oSelf) {
- oSelf._oTextbox.setAttribute("autocomplete","off");
+ oSelf._elTextbox.setAttribute("autocomplete","off");
oSelf._bFocused = true;
if(!oSelf._bItemSelected) {
oSelf.textboxFocusEvent.fire(oSelf);
@@ -2055,19 +2108,26 @@ YAHOO.widget.AutoComplete.prototype._onTextboxFocus = function (v,oSelf) {
YAHOO.widget.AutoComplete.prototype._onTextboxBlur = function (v,oSelf) {
// Don't treat as a blur if it was a selection via mouse click
if(!oSelf._bOverContainer || (oSelf._nKeyCode == 9)) {
- // Current query needs to be validated
+ // Current query needs to be validated as a selection
if(!oSelf._bItemSelected) {
var oMatch = oSelf._textMatchesOption();
+ // Container is closed or current query doesn't match any result
if(!oSelf._bContainerOpen || (oSelf._bContainerOpen && (oMatch === null))) {
+ // Force selection is enabled so clear the current query
if(oSelf.forceSelection) {
oSelf._clearSelection();
}
+ // Treat current query as a valid selection
else {
- oSelf.unmatchedItemSelectEvent.fire(oSelf, oSelf._sCurQuery);
+ oSelf.unmatchedItemSelectEvent.fire(oSelf);
}
}
+ // Container is open and current query matches a result
else {
- oSelf._selectItem(oMatch);
+ // Force a selection when textbox is blurred with a match
+ if(oSelf.forceSelection) {
+ oSelf._selectItem(oMatch);
+ }
}
}
@@ -2081,19 +2141,16 @@ YAHOO.widget.AutoComplete.prototype._onTextboxBlur = function (v,oSelf) {
};
/**
- * Handles form submission event.
+ * Handles window unload event.
*
- * @method _onFormSubmit
- * @param v {HTMLEvent} The submit event.
+ * @method _onWindowUnload
+ * @param v {HTMLEvent} The unload event.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
-YAHOO.widget.AutoComplete.prototype._onFormSubmit = function(v,oSelf) {
- if(oSelf.allowBrowserAutocomplete) {
- oSelf._oTextbox.setAttribute("autocomplete","on");
- }
- else {
- oSelf._oTextbox.setAttribute("autocomplete","off");
+YAHOO.widget.AutoComplete.prototype._onWindowUnload = function(v,oSelf) {
+ if(oSelf && oSelf._elTextbox && oSelf.allowBrowserAutocomplete) {
+ oSelf._elTextbox.setAttribute("autocomplete","on");
}
};
@@ -2445,13 +2502,14 @@ YAHOO.widget.DataSource.prototype._doQueryCache = function(oCallbackFn, sQuery,
var aCache = this._aCache;
var nCacheLength = (aCache) ? aCache.length : 0;
var bMatchContains = this.queryMatchContains;
+ var sOrigQuery;
// If cache is enabled...
if((this.maxCacheEntries > 0) && aCache && (nCacheLength > 0)) {
this.cacheQueryEvent.fire(this, oParent, sQuery);
// If case is unimportant, normalize query now instead of in loops
if(!this.queryMatchCase) {
- var sOrigQuery = sQuery;
+ sOrigQuery = sQuery;
sQuery = sQuery.toLowerCase();
}
@@ -2622,8 +2680,7 @@ YAHOO.widget.DS_XHR.ERROR_DATAXHR = "XHR response failed";
/////////////////////////////////////////////////////////////////////////////
/**
- * Alias to YUI Connection Manager. Allows implementers to specify their own
- * subclasses of the YUI Connection Manager utility.
+ * Alias to YUI Connection Manager, to allow implementers to customize the utility.
*
* @property connMgr
* @type Object
@@ -2805,9 +2862,27 @@ YAHOO.widget.DS_XHR.prototype.parseResponse = function(sQuery, oResponse, oParen
switch (this.responseType) {
case YAHOO.widget.DS_XHR.TYPE_JSON:
var jsonList, jsonObjParsed;
- // Check for JSON lib but divert KHTML clients
- var isNotMac = (navigator.userAgent.toLowerCase().indexOf('khtml')== -1);
- if(oResponse.parseJSON && isNotMac) {
+ // Check for YUI JSON
+ if(YAHOO.lang.JSON) {
+ // Use the JSON utility if available
+ jsonObjParsed = YAHOO.lang.JSON.parse(oResponse);
+ if(!jsonObjParsed) {
+ bError = true;
+ break;
+ }
+ else {
+ try {
+ // eval is necessary here since aSchema[0] is of unknown depth
+ jsonList = eval("jsonObjParsed." + aSchema[0]);
+ }
+ catch(e) {
+ bError = true;
+ break;
+ }
+ }
+ }
+ // Check for JSON lib
+ else if(oResponse.parseJSON) {
// Use the new JSON utility if available
jsonObjParsed = oResponse.parseJSON();
if(!jsonObjParsed) {
@@ -2824,8 +2899,8 @@ YAHOO.widget.DS_XHR.prototype.parseResponse = function(sQuery, oResponse, oParen
}
}
}
- else if(window.JSON && isNotMac) {
- // Use older JSON lib if available
+ // Use older JSON lib if available
+ else if(window.JSON) {
jsonObjParsed = JSON.parse(oResponse);
if(!jsonObjParsed) {
bError = true;
@@ -2887,7 +2962,7 @@ YAHOO.widget.DS_XHR.prototype.parseResponse = function(sQuery, oResponse, oParen
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 = [];
@@ -2988,6 +3063,285 @@ YAHOO.widget.DS_XHR.prototype.parseResponse = function(sQuery, oResponse, oParen
YAHOO.widget.DS_XHR.prototype._oConn = null;
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Implementation of YAHOO.widget.DataSource using the Get Utility to generate
+ * dynamic SCRIPT nodes for data retrieval.
+ *
+ * @class DS_ScriptNode
+ * @constructor
+ * @extends YAHOO.widget.DataSource
+ * @param sUri {String} URI to the script location that will return data.
+ * @param aSchema {String[]} Data schema definition of results.
+ * @param oConfigs {Object} (optional) Object literal of config params.
+ */
+YAHOO.widget.DS_ScriptNode = function(sUri, aSchema, oConfigs) {
+ // Set any config params passed in to override defaults
+ if(oConfigs && (oConfigs.constructor == Object)) {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!YAHOO.lang.isArray(aSchema) || !YAHOO.lang.isString(sUri)) {
+ return;
+ }
+
+ this.schema = aSchema;
+ this.scriptURI = sUri;
+
+ this._init();
+};
+
+YAHOO.widget.DS_ScriptNode.prototype = new YAHOO.widget.DataSource();
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Alias to YUI Get Utility. Allows implementers to specify their own
+ * subclasses of the YUI Get Utility.
+ *
+ * @property getUtility
+ * @type Object
+ * @default YAHOO.util.Get
+ */
+YAHOO.widget.DS_ScriptNode.prototype.getUtility = YAHOO.util.Get;
+
+/**
+ * URI to the script that returns data.
+ *
+ * @property scriptURI
+ * @type String
+ */
+YAHOO.widget.DS_ScriptNode.prototype.scriptURI = null;
+
+/**
+ * Query string parameter name sent to scriptURI. For instance, requests will be
+ * sent to <scriptURI>?<scriptQueryParam>=queryString
+ *
+ * @property scriptQueryParam
+ * @type String
+ * @default "query"
+ */
+YAHOO.widget.DS_ScriptNode.prototype.scriptQueryParam = "query";
+
+/**
+ * Defines request/response management in the following manner:
+ *
+ *
+ *
ignoreStaleResponses
+ *
Send all requests, but handle only the response for the most recently sent request.
+ *
allowAll
+ *
Send all requests and handle all responses.
+ *
+ *
+ * @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
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:
+*
+*
push
+*
Basic push button that can execute a user-specified command when
+* pressed.
+*
link
+*
Navigates to a specified url when pressed.
+*
submit
+*
Submits the parent form when pressed.
+*
reset
+*
Resets the parent form when pressed.
+*
checkbox
+*
Maintains a "checked" state that can be toggled on and off.
+*
radio
+*
Maintains a "checked" state that can be toggled on and off. Use with
+* the ButtonGroup class to create a set of controls that are mutually
+* exclusive; checking one button in the set will uncheck all others in
+* the group.
+*
menu
+*
When pressed will show/hide a menu.
+*
split
+*
Can execute a user-specified command or display a menu when pressed.
+*
+* @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:
+ *
String specifying the id attribute of the
+ * <select> element used to create the menu.
+ *
Object specifying the <div> element
+ * used to create the menu.
+ *
Object specifying the <select> element
+ * used to create the menu.
+ *
Array of object literals, each representing a set of
+ * YAHOO.widget.MenuItem
+ * configuration attributes.
+ *
Array of strings representing the text labels for each menu
+ * item in the menu.
+ *
+ * @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 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: {
+ * 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. }
+ * @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 <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"+(M=="link"?"":"")+""+O+">";return N;},addStateCSSClasses:function(M){var N=this.get("type");if(I.isString(M)){if(M!="activeoption"){this.addClass(this.CSS_CLASS_NAME+("-"+M));}this.addClass("yui-"+N+("-button-"+M));}},removeStateCSSClasses:function(M){var N=this.get("type");if(I.isString(M)){this.removeClass(this.CSS_CLASS_NAME+("-"+M));this.removeClass("yui-"+N+("-button-"+M));}},createHiddenFields:function(){this.removeHiddenFields();var R=this.getForm(),U,N,P,S,T,O,Q,M;if(R&&!this.get("disabled")){N=this.get("type");P=(N=="checkbox"||N=="radio");if(P||(E==this)){U=F((P?N:"hidden"),this.get("name"),this.get("value"),this.get("checked"));if(U){if(P){U.style.display="none";}R.appendChild(U);}}S=this._menu;if(J&&S&&(S instanceof J)){M=S.srcElement;T=this.get("selectedMenuItem");if(T){if(M&&M.nodeName.toUpperCase()=="SELECT"){R.appendChild(M);M.selectedIndex=T.index;}else{Q=(T.value===null||T.value==="")?T.cfg.getProperty("text"):T.value;O=this.get("name");if(Q&&O){M=F("hidden",(O+"_options"),Q);R.appendChild(M);}}}}if(U&&M){this._hiddenFields=[U,M];}else{if(!U&&M){this._hiddenFields=M;}else{if(U&&!M){this._hiddenFields=U;}}}return this._hiddenFields;}},removeHiddenFields:function(){var P=this._hiddenFields,N,O;function M(Q){if(G.inDocument(Q)){Q.parentNode.removeChild(Q);}}if(P){if(I.isArray(P)){N=P.length;if(N>0){O=N-1;do{M(P[O]);}while(O--);}}else{M(P);}this._hiddenFields=null;}},submitForm:function(){var P=this.getForm(),O=this.get("srcelement"),N=false,M;if(P){if(this.get("type")=="submit"||(O&&O.type=="submit")){E=this;}if(YAHOO.env.ua.ie){N=P.fireEvent("onsubmit");}else{M=document.createEvent("HTMLEvents");M.initEvent("submit",true,true);N=P.dispatchEvent(M);}if((YAHOO.env.ua.ie||YAHOO.env.ua.webkit)&&N){P.submit();}}return N;},init:function(M,T){var O=T.type=="link"?"a":"button",Q=T.srcelement,S=M.getElementsByTagName(O)[0],R;if(!S){R=M.getElementsByTagName("input")[0];if(R){S=document.createElement("button");S.setAttribute("type","button");R.parentNode.replaceChild(S,R);}}this._button=S;YAHOO.widget.Button.superclass.init.call(this,M,T);
+D[this.get("id")]=this;this.addClass(this.CSS_CLASS_NAME);this.addClass("yui-"+this.get("type")+"-button");L.on(this._button,"focus",this._onFocus,null,this);this.on("mouseover",this._onMouseOver);this.on("click",this._onClick);this.on("appendTo",this._onAppendTo);var V=this.get("container"),N=this.get("element"),U=G.inDocument(N),P;if(V){if(Q&&Q!=N){P=Q.parentNode;if(P){P.removeChild(Q);}}if(I.isString(V)){L.onContentReady(V,function(){this.appendTo(V);},null,this);}else{this.appendTo(V);}}else{if(!U&&Q&&Q!=N){P=Q.parentNode;if(P){this.fireEvent("beforeAppendTo",{type:"beforeAppendTo",target:P});P.replaceChild(N,Q);this.fireEvent("appendTo",{type:"appendTo",target:P});}}else{if(this.get("type")!="link"&&U&&Q&&Q==N){this._addListenersToForm();}}}},initAttributes:function(N){var M=N||{};YAHOO.widget.Button.superclass.initAttributes.call(this,M);this.setAttributeConfig("type",{value:(M.type||"push"),validator:I.isString,writeOnce:true,method:this._setType});this.setAttributeConfig("label",{value:M.label,validator:I.isString,method:this._setLabel});this.setAttributeConfig("value",{value:M.value});this.setAttributeConfig("name",{value:M.name,validator:I.isString});this.setAttributeConfig("tabindex",{value:M.tabindex,validator:I.isNumber,method:this._setTabIndex});this.configureAttribute("title",{value:M.title,validator:I.isString,method:this._setTitle});this.setAttributeConfig("disabled",{value:(M.disabled||false),validator:I.isBoolean,method:this._setDisabled});this.setAttributeConfig("href",{value:M.href,validator:I.isString,method:this._setHref});this.setAttributeConfig("target",{value:M.target,validator:I.isString,method:this._setTarget});this.setAttributeConfig("checked",{value:(M.checked||false),validator:I.isBoolean,method:this._setChecked});this.setAttributeConfig("container",{value:M.container,writeOnce:true});this.setAttributeConfig("srcelement",{value:M.srcelement,writeOnce:true});this.setAttributeConfig("menu",{value:null,method:this._setMenu,writeOnce:true});this.setAttributeConfig("lazyloadmenu",{value:(M.lazyloadmenu===false?false:true),validator:I.isBoolean,writeOnce:true});this.setAttributeConfig("menuclassname",{value:(M.menuclassname||"yui-button-menu"),validator:I.isString,method:this._setMenuClassName,writeOnce:true});this.setAttributeConfig("selectedMenuItem",{value:null,method:this._setSelectedMenuItem});this.setAttributeConfig("onclick",{value:M.onclick,method:this._setOnClick});this.setAttributeConfig("focusmenu",{value:(M.focusmenu===false?false:true),validator:I.isBoolean});},focus:function(){if(!this.get("disabled")){this._button.focus();}},blur:function(){if(!this.get("disabled")){this._button.blur();}},hasFocus:function(){return(C==this);},isActive:function(){return this.hasClass(this.CSS_CLASS_NAME+"-active");},getMenu:function(){return this._menu;},getForm:function(){return this._button.form;},getHiddenFields:function(){return this._hiddenFields;},destroy:function(){var O=this.get("element"),N=O.parentNode,M=this._menu,Q;if(M){if(K&&K.find(M)){K.remove(M);}M.destroy();}L.purgeElement(O);L.purgeElement(this._button);L.removeListener(document,"mouseup",this._onDocumentMouseUp);L.removeListener(document,"keyup",this._onDocumentKeyUp);L.removeListener(document,"mousedown",this._onDocumentMouseDown);var P=this.getForm();if(P){L.removeListener(P,"reset",this._onFormReset);L.removeListener(P,"submit",this.createHiddenFields);}this.unsubscribeAll();if(N){N.removeChild(O);}delete D[this.get("id")];Q=G.getElementsByClassName(this.CSS_CLASS_NAME,this.NODE_NAME,P);if(I.isArray(Q)&&Q.length===0){L.removeListener(P,"keypress",YAHOO.widget.Button.onFormKeyPress);}},fireEvent:function(N,M){var O=arguments[0];if(this.DOM_EVENTS[O]&&this.get("disabled")){return ;}return YAHOO.widget.Button.superclass.fireEvent.apply(this,arguments);},toString:function(){return("Button "+this.get("id"));}});YAHOO.widget.Button.onFormKeyPress=function(Q){var O=L.getTarget(Q),R=L.getCharCode(Q),P=O.nodeName&&O.nodeName.toUpperCase(),M=O.type,S=false,U,V,N,W;function T(Z){var Y,X;switch(Z.nodeName.toUpperCase()){case"INPUT":case"BUTTON":if(Z.type=="submit"&&!Z.disabled){if(!S&&!N){N=Z;}if(V&&!W){W=Z;}}break;default:Y=Z.id;if(Y){U=D[Y];if(U){S=true;if(!U.get("disabled")){X=U.get("srcelement");if(!V&&(U.get("type")=="submit"||(X&&X.type=="submit"))){V=U;}}}}break;}}if(R==13&&((P=="INPUT"&&(M=="text"||M=="password"||M=="checkbox"||M=="radio"||M=="file"))||P=="SELECT")){G.getElementsBy(T,"*",this);if(N){N.focus();}else{if(!N&&V){if(W){L.preventDefault(Q);}V.submitForm();}}}};YAHOO.widget.Button.addHiddenFieldsToForm=function(M){var R=G.getElementsByClassName(YAHOO.widget.Button.prototype.CSS_CLASS_NAME,"*",M),P=R.length,Q,N,O;if(P>0){for(O=0;O
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;F0){this.addButtons(J);}function F(K){return(K.type=="radio");}J=C.getElementsBy(F,"input",this.get("element"));if(J.length>0){this.addButtons(J);}this.on("keydown",this._onKeyDown);this.on("appendTo",this._onAppendTo);var G=this.get("container");if(G){if(D.isString(G)){B.onContentReady(G,function(){this.appendTo(G);},null,this);}else{this.appendTo(G);}}},initAttributes:function(G){var F=G||{};YAHOO.widget.ButtonGroup.superclass.initAttributes.call(this,F);this.setAttributeConfig("name",{value:F.name,validator:D.isString});this.setAttributeConfig("disabled",{value:(F.disabled||false),validator:D.isBoolean,method:this._setDisabled});this.setAttributeConfig("value",{value:F.value});this.setAttributeConfig("container",{value:F.container,writeOnce:true});this.setAttributeConfig("checkedButton",{value:null});},addButton:function(J){var L,K,G,F,H,I;if(J instanceof A&&J.get("type")=="radio"){L=J;}else{if(!D.isString(J)&&!J.nodeName){J.type="radio";L=new A(J);}else{L=new A(J,{type:"radio"});}}if(L){F=this._buttons.length;H=L.get("name");I=this.get("name");L.index=F;this._buttons[F]=L;E[L.get("id")]=L;if(H!=I){L.set("name",I);}if(this.get("disabled")){L.set("disabled",true);}if(L.get("checked")){this.set("checkedButton",L);}K=L.get("element");G=this.get("element");if(K.parentNode!=G){G.appendChild(K);}L.on("checkedChange",this._onButtonCheckedChange,L,this);return L;}},addButtons:function(G){var H,I,J,F;if(D.isArray(G)){H=G.length;J=[];if(H>0){for(F=0;F0){return J;}}}},removeButton:function(H){var I=this.getButton(H),G,F;if(I){this._buttons.splice(H,1);delete E[I.get("id")];I.removeListener("checkedChange",this._onButtonCheckedChange);I.destroy();G=this._buttons.length;if(G>0){F=this._buttons.length-1;do{this._buttons[F].index=F;}while(F--);}}},getButton:function(F){if(D.isNumber(F)){return this._buttons[F];}},getButtons:function(){return this._buttons;},getCount:function(){return this._buttons.length;},focus:function(H){var I,G,F;if(D.isNumber(H)){I=this._buttons[H];if(I){I.focus();}}else{G=this.getCount();for(F=0;F0){G=this._buttons.length-1;do{this._buttons[G].destroy();}while(G--);}B.purgeElement(H);F.removeChild(H);},toString:function(){return("ButtonGroup "+this.get("id"));}});})();YAHOO.register("button",YAHOO.widget.Button,{version:"2.5.0",build:"895"});
\ No newline at end of file
diff --git a/lib/yui/button/button.js b/lib/yui/button/button.js
new file mode 100644
index 0000000000..ff3a1aa0b9
--- /dev/null
+++ b/lib/yui/button/button.js
@@ -0,0 +1,4670 @@
+/*
+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
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:
+*
+*
push
+*
Basic push button that can execute a user-specified command when
+* pressed.
+*
link
+*
Navigates to a specified url when pressed.
+*
submit
+*
Submits the parent form when pressed.
+*
reset
+*
Resets the parent form when pressed.
+*
checkbox
+*
Maintains a "checked" state that can be toggled on and off.
+*
radio
+*
Maintains a "checked" state that can be toggled on and off. Use with
+* the ButtonGroup class to create a set of controls that are mutually
+* exclusive; checking one button in the set will uncheck all others in
+* the group.
+*
menu
+*
When pressed will show/hide a menu.
+*
split
+*
Can execute a user-specified command or display a menu when pressed.
+*
+* @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:
+ *
String specifying the id attribute of the
+ * <select> element used to create the menu.
+ *
Object specifying the <div> element
+ * used to create the menu.
+ *
Object specifying the <select> element
+ * used to create the menu.
+ *
Array of object literals, each representing a set of
+ * YAHOO.widget.MenuItem
+ * configuration attributes.
+ *
Array of strings representing the text labels for each menu
+ * item in the menu.
+ *
+ * @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 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: {
+ * 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. }
+ * @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 <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 0000000000..9be3d958c7
Binary files /dev/null and b/lib/yui/calendar/assets/calgrad.png differ
diff --git a/lib/yui/calendar/assets/skins/sam/calendar-skin.css b/lib/yui/calendar/assets/skins/sam/calendar-skin.css
index 66a6df4b11..2cb9a73b36 100755
--- a/lib/yui/calendar/assets/skins/sam/calendar-skin.css
+++ b/lib/yui/calendar/assets/skins/sam/calendar-skin.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
*/
/**
* SAM
@@ -79,6 +79,7 @@ version: 2.3.0
border-collapse:collapse;
font:100% sans-serif;
text-align:center;
+ margin:0;
}
/* NAVBAR BOUNDING BOX */
@@ -86,6 +87,7 @@ version: 2.3.0
background:transparent;
border:none;
vertical-align:middle;
+ padding:0;
}
/* NAVBAR TEXT CONTAINER */
@@ -129,6 +131,11 @@ version: 2.3.0
height:2em;
}
+.yui-skin-sam .yui-calendar .calweekdayrow th {
+ padding:0;
+ border:none;
+}
+
/* WEEKDAY (Su, Mo, Tu...) HEADER CELLS */
.yui-skin-sam .yui-calendar .calweekdaycell {
color:#000;
@@ -148,16 +155,17 @@ version: 2.3.0
font-size:85%;
font-style:normal;
font-weight:normal;
+ border:none;
}
.yui-skin-sam .yui-calendar .calrowhead {
text-align:right;
- padding-right:2px;
+ padding:0 2px 0 0;
}
.yui-skin-sam .yui-calendar .calrowfoot {
text-align:left;
- padding-left:2px;
+ padding:0 0 0 2px;
}
/* NORMAL CELLS */
@@ -228,4 +236,126 @@ version: 2.3.0
.yui-skin-sam .yui-calendar td.calcell.highlight1 { background-color:#ccff99; }
.yui-skin-sam .yui-calendar td.calcell.highlight2 { background-color:#99ccff; }
.yui-skin-sam .yui-calendar td.calcell.highlight3 { background-color:#ffcccc; }
-.yui-skin-sam .yui-calendar td.calcell.highlight4 { background-color:#ccff99; }
\ No newline at end of file
+.yui-skin-sam .yui-calendar td.calcell.highlight4 { background-color:#ccff99; }
+
+/* CalendarNavigator */
+
+/* MONTH/YEAR LABEL */
+.yui-skin-sam .yui-calendar a.calnav {
+ border: 1px solid #f2f2f2;
+ padding:0 4px;
+ text-decoration:none;
+ color:#000;
+ zoom:1;
+}
+
+.yui-skin-sam .yui-calendar a.calnav:hover {
+ background: url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0;
+ border-color:#A0A0A0;
+ cursor:pointer;
+}
+
+/* NAVIGATOR MASK */
+.yui-skin-sam .yui-calcontainer .yui-cal-nav-mask {
+ background-color:#000;
+ opacity:0.25;
+ *filter:alpha(opacity=25); /* IE */
+}
+
+/* NAVIGATOR BOUNDING BOX */
+.yui-skin-sam .yui-calcontainer .yui-cal-nav {
+ font-family:arial,helvetica,clean,sans-serif;
+ font-size:93%;
+ border:1px solid #808080;
+ left:50%;
+ margin-left:-7em;
+ width:14em;
+ padding:0;
+ top:2.5em;
+ background-color:#f2f2f2;
+}
+
+.yui-skin-sam .yui-calcontainer.withtitle .yui-cal-nav {
+ top:4.5em;
+}
+
+/* NAVIGATOR BOUNDING BOX */
+.yui-skin-sam .yui-calcontainer.multi .yui-cal-nav {
+ width:16em;
+ margin-left:-8em;
+}
+
+/* NAVIGATOR YEAR/MONTH/BUTTON/ERROR BOUNDING BLOCKS */
+.yui-skin-sam .yui-calcontainer .yui-cal-nav-y,
+.yui-skin-sam .yui-calcontainer .yui-cal-nav-m,
+.yui-skin-sam .yui-calcontainer .yui-cal-nav-b {
+ padding:5px 10px 5px 10px;
+}
+
+.yui-skin-sam .yui-calcontainer .yui-cal-nav-b {
+ text-align:center;
+}
+
+.yui-skin-sam .yui-calcontainer .yui-cal-nav-e {
+ margin-top:5px;
+ padding:5px;
+ background-color:#EDF5FF;
+ border-top:1px solid black;
+ display:none;
+}
+
+/* NAVIGATOR LABELS */
+.yui-skin-sam .yui-calcontainer .yui-cal-nav label {
+ display:block;
+ font-weight:bold;
+}
+
+/* NAVIGATOR MONTH CONTROL */
+.yui-skin-sam .yui-calcontainer .yui-cal-nav-mc {
+ width:100%;
+ _width:auto; /* IE6, IE7 Quirks don't handle 100% well */
+}
+
+/* NAVIGATOR MONTH CONTROL, VALIDATION ERROR */
+.yui-skin-sam .yui-calcontainer .yui-cal-nav-y input.yui-invalid {
+ background-color:#FFEE69;
+ border: 1px solid #000;
+}
+
+/* NAVIGATOR YEAR CONTROL */
+.yui-skin-sam .yui-calcontainer .yui-cal-nav-yc {
+ width:4em;
+}
+
+/* NAVIGATOR BUTTONS */
+
+/* BUTTON WRAPPER */
+.yui-skin-sam .yui-calcontainer .yui-cal-nav .yui-cal-nav-btn {
+ border:1px solid #808080;
+ background: url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0;
+ background-color:#ccc;
+ margin: auto .15em;
+}
+
+/* BUTTON (based on button-skin.css) */
+.yui-skin-sam .yui-calcontainer .yui-cal-nav .yui-cal-nav-btn button {
+ padding:0 8px;
+ font-size:93%;
+ line-height: 2; /* ~24px */
+ *line-height: 1.7; /* For IE */
+ min-height: 2em; /* For Gecko */
+ *min-height: auto; /* For IE */
+ color: #000;
+}
+
+/* DEFAULT BUTTONS */
+/* NOTE: IE6 will only pickup the yui-default specifier from the multiple class specifier */
+.yui-skin-sam .yui-calcontainer .yui-cal-nav .yui-cal-nav-btn.yui-default {
+ border:1px solid #304369;
+ background-color: #426fd9;
+ background: url(../../../../assets/skins/sam/sprite.png) repeat-x 0 -1400px;
+}
+
+.yui-skin-sam .yui-calcontainer .yui-cal-nav .yui-cal-nav-btn.yui-default button {
+ color:#fff;
+}
diff --git a/lib/yui/calendar/assets/skins/sam/calendar.css b/lib/yui/calendar/assets/skins/sam/calendar.css
index 2b6d11a196..53d4a7bd72 100755
--- a/lib/yui/calendar/assets/skins/sam/calendar.css
+++ b/lib/yui/calendar/assets/skins/sam/calendar.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-calcontainer{position:relative;float:left;_overflow:hidden;}.yui-calcontainer iframe{position:absolute;border:none;margin:0;padding:0;z-index:0;width:100%;height:100%;left:0px;top:0px;}.yui-calcontainer iframe.fixedsize{width:50em;height:50em;top:-1px;left:-1px;}.yui-calcontainer.multi .groupcal{z-index:1;float:left;position:relative;}.yui-calcontainer .title{position:relative;z-index:1;}.yui-calcontainer .close-icon{position:absolute;z-index:1;}.yui-calendar{position:relative;}.yui-calendar .calnavleft{position:absolute;z-index:1;}.yui-calendar .calnavright{position:absolute;z-index:1;}.yui-calendar .calheader{position:relative;width:100%;text-align:center;}.yui-calendar .calbody a:hover{background:inherit;}p#clear{clear:left;padding-top:10px;}.yui-skin-sam .yui-calcontainer{background-color:#f2f2f2;border:1px solid #808080;padding:10px;}.yui-skin-sam .yui-calcontainer.multi{padding:0 5px 0 5px;}.yui-skin-sam .yui-calcontainer.multi .groupcal{background-color:transparent;border:none;padding:10px 5px 10px 5px;margin:0;}.yui-skin-sam .yui-calcontainer .title{background:url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0;border-bottom:1px solid #cccccc;font:100% sans-serif;color:#000;font-weight:bold;height:auto;padding:.4em;margin:0 -10px 10px -10px;top:0;left:0;text-align:left;}.yui-skin-sam .yui-calcontainer.multi .title{margin:0 -5px 0 -5px;}.yui-skin-sam .yui-calcontainer.withtitle{padding-top:0;}.yui-skin-sam .yui-calcontainer .calclose{background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -300px;width:25px;height:15px;top:.4em;right:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar{border-spacing:0;border-collapse:collapse;font:100% sans-serif;text-align:center;}.yui-skin-sam .yui-calendar .calhead{background:transparent;border:none;vertical-align:middle;}.yui-skin-sam .yui-calendar .calheader{background:transparent;font-weight:bold;padding:0 0 .6em 0;text-align:center;}.yui-skin-sam .yui-calendar .calheader img{border:none;}.yui-skin-sam .yui-calendar .calnavleft{background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -450px;width:25px;height:15px;top:0;bottom:0;left:-10px;margin-left:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar .calnavright{background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -500px;width:25px;height:15px;top:0;bottom:0;right:-10px;margin-right:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar .calweekdayrow{height:2em;}.yui-skin-sam .yui-calendar .calweekdaycell{color:#000;font-weight:bold;text-align:center;width:2em;}.yui-skin-sam .yui-calendar .calfoot{background-color:#f2f2f2;}.yui-skin-sam .yui-calendar .calrowhead,.yui-skin-sam .yui-calendar .calrowfoot{color:#a6a6a6;font-size:85%;font-style:normal;font-weight:normal;}.yui-skin-sam .yui-calendar .calrowhead{text-align:right;padding-right:2px;}.yui-skin-sam .yui-calendar .calrowfoot{text-align:left;padding-left:2px;}.yui-skin-sam .yui-calendar td.calcell{border:1px solid #cccccc;background:#fff;padding:1px;height:1.6em;line-height:1.6em;text-align:center;white-space:nowrap;}.yui-skin-sam .yui-calendar td.calcell a{color:#0066cc;display:block;height:100%;text-decoration:none;}.yui-skin-sam .yui-calendar td.calcell.today{background-color:#000;}.yui-skin-sam .yui-calendar td.calcell.today a{background-color:#fff;}.yui-skin-sam .yui-calendar td.calcell.oom{background-color:#cccccc;color:#a6a6a6;cursor:default;}.yui-skin-sam .yui-calendar td.calcell.selected{background-color:#fff;color:#000;}.yui-skin-sam .yui-calendar td.calcell.selected a{background-color:#b3d4ff;color:#000;}.yui-skin-sam .yui-calendar td.calcell.calcellhover{background-color:#426fd9;color:#fff;cursor:pointer;}.yui-skin-sam .yui-calendar td.calcell.calcellhover a{background-color:#426fd9;color:#fff;}.yui-skin-sam .yui-calendar td.calcell.previous{color:#e0e0e0;}.yui-skin-sam .yui-calendar td.calcell.restricted{text-decoration:line-through;}.yui-skin-sam .yui-calendar td.calcell.highlight1{background-color:#ccff99;}.yui-skin-sam .yui-calendar td.calcell.highlight2{background-color:#99ccff;}.yui-skin-sam .yui-calendar td.calcell.highlight3{background-color:#ffcccc;}.yui-skin-sam .yui-calendar td.calcell.highlight4{background-color:#ccff99;}
+.yui-calcontainer{position:relative;float:left;_overflow:hidden;}.yui-calcontainer iframe{position:absolute;border:none;margin:0;padding:0;z-index:0;width:100%;height:100%;left:0px;top:0px;}.yui-calcontainer iframe.fixedsize{width:50em;height:50em;top:-1px;left:-1px;}.yui-calcontainer.multi .groupcal{z-index:1;float:left;position:relative;}.yui-calcontainer .title{position:relative;z-index:1;}.yui-calcontainer .close-icon{position:absolute;z-index:1;}.yui-calendar{position:relative;}.yui-calendar .calnavleft{position:absolute;z-index:1;}.yui-calendar .calnavright{position:absolute;z-index:1;}.yui-calendar .calheader{position:relative;width:100%;text-align:center;}.yui-calcontainer .yui-cal-nav-mask{position:absolute;z-index:2;margin:0;padding:0;width:100%;height:100%;_width:0;_height:0;left:0;top:0;display:none;}.yui-calcontainer .yui-cal-nav{position:absolute;z-index:3;top:0;display:none;}.yui-calcontainer .yui-cal-nav .yui-cal-nav-btn{display:-moz-inline-box;display:inline-block;}.yui-calcontainer .yui-cal-nav .yui-cal-nav-btn button{display:block;*display:inline-block;*overflow:visible;border:none;background-color:transparent;cursor:pointer;}.yui-calendar .calbody a:hover{background:inherit;}p#clear{clear:left;padding-top:10px;}.yui-skin-sam .yui-calcontainer{background-color:#f2f2f2;border:1px solid #808080;padding:10px;}.yui-skin-sam .yui-calcontainer.multi{padding:0 5px 0 5px;}.yui-skin-sam .yui-calcontainer.multi .groupcal{background-color:transparent;border:none;padding:10px 5px 10px 5px;margin:0;}.yui-skin-sam .yui-calcontainer .title{background:url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0;border-bottom:1px solid #cccccc;font:100% sans-serif;color:#000;font-weight:bold;height:auto;padding:.4em;margin:0 -10px 10px -10px;top:0;left:0;text-align:left;}.yui-skin-sam .yui-calcontainer.multi .title{margin:0 -5px 0 -5px;}.yui-skin-sam .yui-calcontainer.withtitle{padding-top:0;}.yui-skin-sam .yui-calcontainer .calclose{background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -300px;width:25px;height:15px;top:.4em;right:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar{border-spacing:0;border-collapse:collapse;font:100% sans-serif;text-align:center;margin:0;}.yui-skin-sam .yui-calendar .calhead{background:transparent;border:none;vertical-align:middle;padding:0;}.yui-skin-sam .yui-calendar .calheader{background:transparent;font-weight:bold;padding:0 0 .6em 0;text-align:center;}.yui-skin-sam .yui-calendar .calheader img{border:none;}.yui-skin-sam .yui-calendar .calnavleft{background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -450px;width:25px;height:15px;top:0;bottom:0;left:-10px;margin-left:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar .calnavright{background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -500px;width:25px;height:15px;top:0;bottom:0;right:-10px;margin-right:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar .calweekdayrow{height:2em;}.yui-skin-sam .yui-calendar .calweekdayrow th{padding:0;border:none;}.yui-skin-sam .yui-calendar .calweekdaycell{color:#000;font-weight:bold;text-align:center;width:2em;}.yui-skin-sam .yui-calendar .calfoot{background-color:#f2f2f2;}.yui-skin-sam .yui-calendar .calrowhead,.yui-skin-sam .yui-calendar .calrowfoot{color:#a6a6a6;font-size:85%;font-style:normal;font-weight:normal;border:none;}.yui-skin-sam .yui-calendar .calrowhead{text-align:right;padding:0 2px 0 0;}.yui-skin-sam .yui-calendar .calrowfoot{text-align:left;padding:0 0 0 2px;}.yui-skin-sam .yui-calendar td.calcell{border:1px solid #cccccc;background:#fff;padding:1px;height:1.6em;line-height:1.6em;text-align:center;white-space:nowrap;}.yui-skin-sam .yui-calendar td.calcell a{color:#0066cc;display:block;height:100%;text-decoration:none;}.yui-skin-sam .yui-calendar td.calcell.today{background-color:#000;}.yui-skin-sam .yui-calendar td.calcell.today a{background-color:#fff;}.yui-skin-sam .yui-calendar td.calcell.oom{background-color:#cccccc;color:#a6a6a6;cursor:default;}.yui-skin-sam .yui-calendar td.calcell.selected{background-color:#fff;color:#000;}.yui-skin-sam .yui-calendar td.calcell.selected a{background-color:#b3d4ff;color:#000;}.yui-skin-sam .yui-calendar td.calcell.calcellhover{background-color:#426fd9;color:#fff;cursor:pointer;}.yui-skin-sam .yui-calendar td.calcell.calcellhover a{background-color:#426fd9;color:#fff;}.yui-skin-sam .yui-calendar td.calcell.previous{color:#e0e0e0;}.yui-skin-sam .yui-calendar td.calcell.restricted{text-decoration:line-through;}.yui-skin-sam .yui-calendar td.calcell.highlight1{background-color:#ccff99;}.yui-skin-sam .yui-calendar td.calcell.highlight2{background-color:#99ccff;}.yui-skin-sam .yui-calendar td.calcell.highlight3{background-color:#ffcccc;}.yui-skin-sam .yui-calendar td.calcell.highlight4{background-color:#ccff99;}.yui-skin-sam .yui-calendar a.calnav{border:1px solid #f2f2f2;padding:0 4px;text-decoration:none;color:#000;zoom:1;}.yui-skin-sam .yui-calendar a.calnav:hover{background:url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0;border-color:#A0A0A0;cursor:pointer;}.yui-skin-sam .yui-calcontainer .yui-cal-nav-mask{background-color:#000;opacity:0.25;*filter:alpha(opacity=25);}.yui-skin-sam .yui-calcontainer .yui-cal-nav{font-family:arial,helvetica,clean,sans-serif;font-size:93%;border:1px solid #808080;left:50%;margin-left:-7em;width:14em;padding:0;top:2.5em;background-color:#f2f2f2;}.yui-skin-sam .yui-calcontainer.withtitle .yui-cal-nav{top:4.5em;}.yui-skin-sam .yui-calcontainer.multi .yui-cal-nav{width:16em;margin-left:-8em;}.yui-skin-sam .yui-calcontainer .yui-cal-nav-y,.yui-skin-sam .yui-calcontainer .yui-cal-nav-m,.yui-skin-sam .yui-calcontainer .yui-cal-nav-b{padding:5px 10px 5px 10px;}.yui-skin-sam .yui-calcontainer .yui-cal-nav-b{text-align:center;}.yui-skin-sam .yui-calcontainer .yui-cal-nav-e{margin-top:5px;padding:5px;background-color:#EDF5FF;border-top:1px solid black;display:none;}.yui-skin-sam .yui-calcontainer .yui-cal-nav label{display:block;font-weight:bold;}.yui-skin-sam .yui-calcontainer .yui-cal-nav-mc{width:100%;_width:auto;}.yui-skin-sam .yui-calcontainer .yui-cal-nav-y input.yui-invalid{background-color:#FFEE69;border:1px solid #000;}.yui-skin-sam .yui-calcontainer .yui-cal-nav-yc{width:4em;}.yui-skin-sam .yui-calcontainer .yui-cal-nav .yui-cal-nav-btn{border:1px solid #808080;background:url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0;background-color:#ccc;margin:auto .15em;}.yui-skin-sam .yui-calcontainer .yui-cal-nav .yui-cal-nav-btn button{padding:0 8px;font-size:93%;line-height:2;*line-height:1.7;min-height:2em;*min-height:auto;color:#000;}.yui-skin-sam .yui-calcontainer .yui-cal-nav .yui-cal-nav-btn.yui-default{border:1px solid #304369;background-color:#426fd9;background:url(../../../../assets/skins/sam/sprite.png) repeat-x 0 -1400px;}.yui-skin-sam .yui-calcontainer .yui-cal-nav .yui-cal-nav-btn.yui-default button{color:#fff;}
diff --git a/lib/yui/calendar/calendar-debug.js b/lib/yui/calendar/calendar-debug.js
index 47a54b3d7d..621b403db5 100755
--- a/lib/yui/calendar/calendar-debug.js
+++ b/lib/yui/calendar/calendar-debug.js
@@ -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
*/
(function () {
@@ -18,26 +18,20 @@ version: 2.3.0
* @param {Object} owner The owner Object to which this Config Object belongs
*/
YAHOO.util.Config = function (owner) {
-
+
if (owner) {
-
this.init(owner);
-
- }
-
- if (!owner) {
-
- YAHOO.log("No owner specified for Config object", "error");
-
}
-
+
+ if (!owner) { YAHOO.log("No owner specified for Config object", "error", "Config"); }
+
};
var Lang = YAHOO.lang,
- CustomEvent = YAHOO.util.CustomEvent,
+ CustomEvent = YAHOO.util.CustomEvent,
Config = YAHOO.util.Config;
-
+
/**
* Constant representing the CustomEvent type for the config changed event.
@@ -157,7 +151,7 @@ version: 2.3.0
* @param {value} Object The value of the correct type for the property
*/
fireEvent: function ( key, value ) {
- YAHOO.log("Firing Config event: " + key + "=" + value, "info");
+ YAHOO.log("Firing Config event: " + key + "=" + value, "info", "Config");
var property = this.config[key];
if (property && property.event) {
@@ -174,7 +168,7 @@ version: 2.3.0
*/
addProperty: function ( key, propertyObject ) {
key = key.toLowerCase();
- YAHOO.log("Added property: " + key, "info");
+ YAHOO.log("Added property: " + key, "info", "Config");
this.config[key] = propertyObject;
@@ -252,11 +246,11 @@ version: 2.3.0
!Lang.isUndefined(this.initialConfig[key])) {
this.setProperty(key, this.initialConfig[key]);
+
+ return true;
}
- return true;
-
} else {
return false;
@@ -279,7 +273,7 @@ version: 2.3.0
var property;
key = key.toLowerCase();
- YAHOO.log("setProperty: " + key + "=" + value, "info");
+ YAHOO.log("setProperty: " + key + "=" + value, "info", "Config");
if (this.queueInProgress && ! silent) {
// Currently running through a queue...
@@ -318,7 +312,7 @@ version: 2.3.0
queueProperty: function (key, value) {
key = key.toLowerCase();
- YAHOO.log("queueProperty: " + key + "=" + value, "info");
+ YAHOO.log("queueProperty: " + key + "=" + value, "info", "Config");
var property = this.config[key],
foundDuplicate = false,
@@ -358,7 +352,7 @@ version: 2.3.0
if (queueItem) {
queueItemKey = queueItem[0];
queueItemValue = queueItem[1];
-
+
if (queueItemKey == key) {
/*
@@ -386,38 +380,38 @@ version: 2.3.0
}
if (property.supercedes) {
-
+
sLen = property.supercedes.length;
-
+
for (s = 0; s < sLen; s++) {
-
+
supercedesCheck = property.supercedes[s];
qLen = this.eventQueue.length;
-
+
for (q = 0; q < qLen; q++) {
queueItemCheck = this.eventQueue[q];
-
+
if (queueItemCheck) {
queueItemCheckKey = queueItemCheck[0];
queueItemCheckValue = queueItemCheck[1];
-
+
if (queueItemCheckKey ==
supercedesCheck.toLowerCase() ) {
-
+
this.eventQueue.push([queueItemCheckKey,
queueItemCheckValue]);
-
+
this.eventQueue[q] = null;
break;
-
+
}
}
}
}
}
- YAHOO.log("Config event queue: " + this.outputEventQueue(), "info");
-
+ YAHOO.log("Config event queue: " + this.outputEventQueue(), "info", "Config");
+
return true;
} else {
return false;
@@ -465,13 +459,23 @@ version: 2.3.0
*/
applyConfig: function (userConfig, init) {
- var prop;
-
+ var sKey,
+ oConfig;
+
if (init) {
- this.initialConfig = userConfig;
+ oConfig = {};
+ for (sKey in userConfig) {
+ if (Lang.hasOwnProperty(userConfig, sKey)) {
+ oConfig[sKey.toLowerCase()] = userConfig[sKey];
+ }
+ }
+ this.initialConfig = oConfig;
}
- for (prop in userConfig) {
- this.queueProperty(prop, userConfig[prop]);
+
+ for (sKey in userConfig) {
+ if (Lang.hasOwnProperty(userConfig, sKey)) {
+ this.queueProperty(sKey, userConfig[sKey]);
+ }
}
},
@@ -539,19 +543,12 @@ version: 2.3.0
var property = this.config[key.toLowerCase()];
if (property && property.event) {
-
if (!Config.alreadySubscribed(property.event, handler, obj)) {
-
property.event.subscribe(handler, obj, override);
-
}
-
return true;
-
} else {
-
return false;
-
}
},
@@ -671,28 +668,20 @@ version: 2.3.0
i;
if (nSubscribers > 0) {
-
i = nSubscribers - 1;
-
do {
-
subsc = evt.subscribers[i];
-
if (subsc && subsc.obj == obj && subsc.fn == fn) {
-
return true;
-
- }
-
+ }
}
while (i--);
-
}
-
+
return false;
-
+
};
-
+
YAHOO.lang.augmentProto(Config, YAHOO.util.EventProvider);
}());
@@ -764,7 +753,6 @@ YAHOO.widget.DateMath = {
var newMonth = date.getMonth() + amount;
var years = 0;
-
if (newMonth < 0) {
while (newMonth < 0) {
newMonth += 12;
@@ -776,23 +764,55 @@ YAHOO.widget.DateMath = {
years += 1;
}
}
-
+
d.setMonth(newMonth);
d.setFullYear(date.getFullYear() + years);
break;
case this.DAY:
- d.setDate(date.getDate() + amount);
+ this._addDays(d, amount);
+ // d.setDate(date.getDate() + amount);
break;
case this.YEAR:
d.setFullYear(date.getFullYear() + amount);
break;
case this.WEEK:
- d.setDate(date.getDate() + (amount * 7));
+ this._addDays(d, (amount * 7));
+ // d.setDate(date.getDate() + (amount * 7));
break;
}
return d;
},
+ /**
+ * Private helper method to account for bug in Safari 2 (webkit < 420)
+ * when Date.setDate(n) is called with n less than -128 or greater than 127.
+ *
+ * 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
@@ -860,7 +880,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);
},
/**
@@ -896,7 +916,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);
@@ -940,7 +960,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;
},
@@ -966,14 +986,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
*/
@@ -985,18 +1037,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.:
+*
+* var c = new YAHOO.widget.Calendar("calContainer", configOptions);
+*
+* or:
+*
+* var containerDiv = YAHOO.util.Dom.get("calContainer");
+* var c = new YAHOO.widget.Calendar(containerDiv, configOptions);
*
*
+*
+* 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";
- html[html.length] = "
";
- html[html.length] = '
';
- html[html.length] = '
';
+ while (tagName != "td" && ! YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
- var renderLeft, renderRight = false;
+ if (!defSelector && tagName == "a" && YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTOR)) {
+ defSelector = true;
+ }
- if (this.parent) {
- if (this.index === 0) {
- renderLeft = true;
- }
- if (this.index == (this.parent.cfg.getProperty("pages") -1)) {
- renderRight = true;
+ target = target.parentNode;
+ tagName = target.tagName.toLowerCase();
+ // TODO: No need to go all the way up to html.
+ if (tagName == "html") {
+ return;
+ }
}
- } else {
- renderLeft = true;
- renderRight = true;
- }
- var cal = this.parent || this;
-
- if (renderLeft) {
- var leftArrow = this.cfg.getProperty(defCfg.NAV_ARROW_LEFT.key);
- // Check for deprecated customization - If someone set IMG_ROOT, but didn't set NAV_ARROW_LEFT, then set NAV_ARROW_LEFT to the old deprecated value
- if (leftArrow === null && YAHOO.widget.Calendar.IMG_ROOT !== null) {
- leftArrow = YAHOO.widget.Calendar.IMG_ROOT + DEPR_NAV_LEFT;
- }
- var leftStyle = (leftArrow === null) ? "" : ' style="background-image:url(' + leftArrow + ')"';
- html[html.length] = '';
- }
-
- html[html.length] = this.buildMonthLabel();
-
- if (renderRight) {
- var rightArrow = this.cfg.getProperty(defCfg.NAV_ARROW_RIGHT.key);
- if (rightArrow === null && YAHOO.widget.Calendar.IMG_ROOT !== null) {
- rightArrow = YAHOO.widget.Calendar.IMG_ROOT + DEPR_NAV_RIGHT;
+ if (defSelector) {
+ // Stop link href navigation for default renderer
+ YAHOO.util.Event.preventDefault(e);
}
- var rightStyle = (rightArrow === null) ? "" : ' style="background-image:url(' + rightArrow + ')"';
- html[html.length] = '';
- }
-
- html[html.length] = '
\n
\n
';
-
- if (this.cfg.getProperty(defCfg.SHOW_WEEKDAYS.key)) {
- html = this.buildWeekdays(html);
- }
- html[html.length] = '';
-
- return html;
-};
-
-/**
-* Renders the Calendar's weekday headers.
-* @method buildWeekdays
-* @param {Array} html The current working HTML array
-* @return {Array} The current working HTML array
-*/
-YAHOO.widget.Calendar.prototype.buildWeekdays = function(html) {
+ cell = target;
- var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG;
+ if (YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_SELECTABLE)) {
+ index = cell.id.split("cell")[1];
+ d = cal.cellDates[index];
+ date = YAHOO.widget.DateMath.getDate(d[0],d[1]-1,d[2]);
+
+ var link;
- html[html.length] = '
';
+ cal.logger.log("Selecting cell " + index + " via click", "info");
+ if (cal.Options.MULTI_SELECT) {
+ link = cell.getElementsByTagName("a")[0];
+ if (link) {
+ link.blur();
+ }
- if (this.cfg.getProperty(defCfg.SHOW_WEEK_HEADER.key)) {
- html[html.length] = '
';
- }
+ /**
+ * 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
+ */
+ doCellMouseOver : function(e, cal) {
+ var target;
+ if (e) {
+ target = YAHOO.util.Event.getTarget(e);
+ } else {
+ target = this;
+ }
- html[html.length] = '
';
+ while (target.tagName && target.tagName.toLowerCase() != "td") {
+ target = target.parentNode;
+ if (!target.tagName || target.tagName.toLowerCase() == "html") {
+ return;
+ }
+ }
- return html;
-};
+ if (YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
+ YAHOO.util.Dom.addClass(target, cal.Style.CSS_CELL_HOVER);
+ }
+ },
-/**
-* Renders the calendar body.
-* @method renderBody
-* @param {Date} workingDate The current working Date being used for the render process
-* @param {Array} html The current working HTML array
-* @return {Array} The current working HTML array
-*/
-YAHOO.widget.Calendar.prototype.renderBody = function(workingDate, html) {
- this.logger.log("Rendering body", "info");
- var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG;
+ /**
+ * 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
+ */
+ doCellMouseOut : function(e, cal) {
+ var target;
+ if (e) {
+ target = YAHOO.util.Event.getTarget(e);
+ } else {
+ target = this;
+ }
- var startDay = this.cfg.getProperty(defCfg.START_WEEKDAY.key);
+ while (target.tagName && target.tagName.toLowerCase() != "td") {
+ target = target.parentNode;
+ if (!target.tagName || target.tagName.toLowerCase() == "html") {
+ return;
+ }
+ }
- this.preMonthDays = workingDate.getDay();
- if (startDay > 0) {
- this.preMonthDays -= startDay;
- }
- if (this.preMonthDays < 0) {
- this.preMonthDays += 7;
- }
-
- this.monthDays = YAHOO.widget.DateMath.findMonthEnd(workingDate).getDate();
- this.postMonthDays = YAHOO.widget.Calendar.DISPLAY_DAYS-this.preMonthDays-this.monthDays;
- this.logger.log(this.preMonthDays + " preciding out-of-month days", "info");
- this.logger.log(this.monthDays + " month days", "info");
- this.logger.log(this.postMonthDays + " post-month days", "info");
-
- workingDate = YAHOO.widget.DateMath.subtract(workingDate, YAHOO.widget.DateMath.DAY, this.preMonthDays);
- this.logger.log("Calendar page starts on " + workingDate, "info");
-
- var weekNum,weekClass;
- var weekPrefix = "w";
- var cellPrefix = "_cell";
- var workingDayPrefix = "wd";
- var dayPrefix = "d";
-
- var cellRenderers;
- var renderer;
-
- var todayYear = this.today.getFullYear();
- var todayMonth = this.today.getMonth();
- var todayDate = this.today.getDate();
-
- var useDate = this.cfg.getProperty(defCfg.PAGEDATE.key);
- var hideBlankWeeks = this.cfg.getProperty(defCfg.HIDE_BLANK_WEEKS.key);
- var showWeekFooter = this.cfg.getProperty(defCfg.SHOW_WEEK_FOOTER.key);
- var showWeekHeader = this.cfg.getProperty(defCfg.SHOW_WEEK_HEADER.key);
- var mindate = this.cfg.getProperty(defCfg.MINDATE.key);
- var maxdate = this.cfg.getProperty(defCfg.MAXDATE.key);
-
- if (mindate) {
- mindate = YAHOO.widget.DateMath.clearTime(mindate);
- }
- if (maxdate) {
- maxdate = YAHOO.widget.DateMath.clearTime(maxdate);
- }
+ if (YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
+ YAHOO.util.Dom.removeClass(target, cal.Style.CSS_CELL_HOVER);
+ }
+ },
- html[html.length] = '';
+ setupConfig : function() {
- var i = 0;
-
- var tempDiv = document.createElement("div");
- var cell = document.createElement("td");
- tempDiv.appendChild(cell);
+ var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG;
- var jan1 = new Date(useDate.getFullYear(),0,1);
+ /**
+ * 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 } );
- var cal = this.parent || this;
+ /**
+ * 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 } );
- for (var r=0;r<6;r++) {
+ /**
+ * 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 } );
- weekNum = YAHOO.widget.DateMath.getWeekNumber(workingDate, useDate.getFullYear(), startDay);
- weekClass = weekPrefix + weekNum;
+ /**
+ * 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 } );
- // Local OOM check for performance, since we already have pagedate
- if (r !== 0 && hideBlankWeeks === true && workingDate.getMonth() != useDate.getMonth()) {
- break;
- } else {
+ /**
+ * 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 } );
- html[html.length] = '
';
-
- if (showWeekHeader) { html = this.renderRowHeader(weekNum, html); }
-
- for (var d=0;d<7;d++){ // Render actual days
+ /**
+ * 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 } );
- cellRenderers = [];
- renderer = null;
+ /**
+ * 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 } );
- this.clearElement(cell);
- cell.className = this.Style.CSS_CELL;
- cell.id = this.id + cellPrefix + i;
- this.logger.log("Rendering cell " + cell.id + " (" + workingDate.getFullYear() + "-" + (workingDate.getMonth()+1) + "-" + workingDate.getDate() + ")", "cellrender");
+ /**
+ * 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 " "
+ */
+ this.cfg.addProperty(defCfg.MY_LABEL_MONTH_SUFFIX.key, { value:defCfg.MY_LABEL_MONTH_SUFFIX.value, handler:this.configLocale } );
+
+ /**
+ * 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 } );
- if (workingDate.getDate() == todayDate &&
- workingDate.getMonth() == todayMonth &&
- workingDate.getFullYear() == todayYear) {
- cellRenderers[cellRenderers.length]=cal.renderCellStyleToday;
- }
-
- var workingArray = [workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()];
- this.cellDates[this.cellDates.length] = workingArray; // Add this date to cellDates
-
- // Local OOM check for performance, since we already have pagedate
- if (workingDate.getMonth() != useDate.getMonth()) {
- cellRenderers[cellRenderers.length]=cal.renderCellNotThisMonth;
- } else {
- YAHOO.util.Dom.addClass(cell, workingDayPrefix + workingDate.getDay());
- YAHOO.util.Dom.addClass(cell, dayPrefix + workingDate.getDate());
-
- for (var s=0;s
+ * Setting this property to null (default value) or false, will disable the CalendarNavigator UI.
+ *
+ *
+ * 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).
+ *
+ *
+ *
strings
+ *
Object : An object with the properties shown below, defining the string labels to use in the Navigator's UI
+ *
+ *
month
String : The string to use for the month label. Defaults to "Month".
+ *
year
String : The string to use for the year label. Defaults to "Year".
+ *
submit
String : The string to use for the submit button label. Defaults to "Okay".
+ *
cancel
String : The string to use for the cancel button label. Defaults to "Cancel".
+ *
invalidYear
String : The string to use for invalid year values. Defaults to "Year needs to be a number".
+ *
+ *
+ *
monthFormat
String : The month format to use. Either YAHOO.widget.Calendar.LONG, or YAHOO.widget.Calendar.SHORT. Defaults to YAHOO.widget.Calendar.LONG
+ *
initialFocus
String : Either "year" or "month" specifying which input control should get initial focus. Defaults to "year"
';
+
+ return html;
+ },
+
+ /**
+ * Renders the calendar body.
+ * @method renderBody
+ * @param {Date} workingDate The current working Date being used for the render process
+ * @param {Array} html The current working HTML array
+ * @return {Array} The current working HTML array
+ */
+ renderBody : function(workingDate, html) {
+ this.logger.log("Rendering body", "render");
+ var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG;
+
+ var startDay = this.cfg.getProperty(defCfg.START_WEEKDAY.key);
+
+ this.preMonthDays = workingDate.getDay();
+ if (startDay > 0) {
+ this.preMonthDays -= startDay;
+ }
+ if (this.preMonthDays < 0) {
+ this.preMonthDays += 7;
+ }
+
+ this.monthDays = YAHOO.widget.DateMath.findMonthEnd(workingDate).getDate();
+ this.postMonthDays = YAHOO.widget.Calendar.DISPLAY_DAYS-this.preMonthDays-this.monthDays;
+ this.logger.log(this.preMonthDays + " preciding out-of-month days", "render");
+ this.logger.log(this.monthDays + " month days", "render");
+ this.logger.log(this.postMonthDays + " post-month days", "render");
+
+ workingDate = YAHOO.widget.DateMath.subtract(workingDate, YAHOO.widget.DateMath.DAY, this.preMonthDays);
+ this.logger.log("Calendar page starts on " + workingDate, "render");
+
+ var weekNum,weekClass;
+ var weekPrefix = "w";
+ var cellPrefix = "_cell";
+ var workingDayPrefix = "wd";
+ var dayPrefix = "d";
+
+ var cellRenderers;
+ var renderer;
+
+ var todayYear = this.today.getFullYear();
+ var todayMonth = this.today.getMonth();
+ var todayDate = this.today.getDate();
+
+ var useDate = this.cfg.getProperty(defCfg.PAGEDATE.key);
+ var hideBlankWeeks = this.cfg.getProperty(defCfg.HIDE_BLANK_WEEKS.key);
+ var showWeekFooter = this.cfg.getProperty(defCfg.SHOW_WEEK_FOOTER.key);
+ var showWeekHeader = this.cfg.getProperty(defCfg.SHOW_WEEK_HEADER.key);
+ var mindate = this.cfg.getProperty(defCfg.MINDATE.key);
+ var maxdate = this.cfg.getProperty(defCfg.MAXDATE.key);
+
+ if (mindate) {
+ mindate = YAHOO.widget.DateMath.clearTime(mindate);
+ }
+ if (maxdate) {
+ maxdate = YAHOO.widget.DateMath.clearTime(maxdate);
+ }
+
+ html[html.length] = '';
+
+ var i = 0;
+
+ var tempDiv = document.createElement("div");
+ var cell = document.createElement("td");
+ tempDiv.appendChild(cell);
+
+ var cal = this.parent || this;
+
+ for (var r=0;r<6;r++) {
+
+ weekNum = YAHOO.widget.DateMath.getWeekNumber(workingDate, useDate.getFullYear(), startDay);
+ weekClass = weekPrefix + weekNum;
+
+ // Local OOM check for performance, since we already have pagedate
+ if (r !== 0 && hideBlankWeeks === true && workingDate.getMonth() != useDate.getMonth()) {
+ break;
+ } else {
+
+ html[html.length] = '
';
+
+ if (showWeekHeader) { html = this.renderRowHeader(weekNum, html); }
+
+ for (var d=0;d<7;d++){ // Render actual days
+
+ cellRenderers = [];
+
+ this.clearElement(cell);
+ cell.className = this.Style.CSS_CELL;
+ cell.id = this.id + cellPrefix + i;
+ this.logger.log("Rendering cell " + cell.id + " (" + workingDate.getFullYear() + "-" + (workingDate.getMonth()+1) + "-" + workingDate.getDate() + ")", "cellrender");
+
+ if (workingDate.getDate() == todayDate &&
+ workingDate.getMonth() == todayMonth &&
+ workingDate.getFullYear() == todayYear) {
+ cellRenderers[cellRenderers.length]=cal.renderCellStyleToday;
+ }
+
+ var workingArray = [workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()];
+ this.cellDates[this.cellDates.length] = workingArray; // Add this date to cellDates
+
+ // Local OOM check for performance, since we already have pagedate
+ if (workingDate.getMonth() != useDate.getMonth()) {
+ cellRenderers[cellRenderers.length]=cal.renderCellNotThisMonth;
+ } else {
+ YAHOO.util.Dom.addClass(cell, workingDayPrefix + workingDate.getDay());
+ YAHOO.util.Dom.addClass(cell, dayPrefix + workingDate.getDate());
+
+ for (var s=0;s= 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;
+ }
+ }
+
+ }
+
+ if (this._indexOfSelectedFieldArray(workingArray) > -1) {
+ cellRenderers[cellRenderers.length]=cal.renderCellStyleSelected;
+ }
+
+ 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;
+ }
+
+ 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;
+ }
+ }
+
+ workingDate.setTime(workingDate.getTime() + YAHOO.widget.DateMath.ONE_DAY_MS);
+
+ if (i >= 0 && i <= 6) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TOP);
+ }
+ if ((i % 7) === 0) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_LEFT);
+ }
+ if (((i+1) % 7) === 0) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_RIGHT);
+ }
+
+ var postDays = this.postMonthDays;
+ if (hideBlankWeeks && postDays >= 7) {
+ var blankWeeks = Math.floor(postDays/7);
+ for (var p=0;p= ((this.preMonthDays+postDays+this.monthDays)-7)) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_BOTTOM);
+ }
+
+ html[html.length] = tempDiv.innerHTML;
+ i++;
+ }
+
+ if (showWeekFooter) { html = this.renderRowFooter(weekNum, html); }
+
+ html[html.length] = '
';
+ }
+ }
+
+ html[html.length] = '';
+
+ return html;
+ },
+
+ /**
+ * Renders the calendar footer. In the default implementation, there is
+ * no footer.
+ * @method renderFooter
+ * @param {Array} html The current working HTML array
+ * @return {Array} The current working HTML array
+ */
+ renderFooter : function(html) { return html; },
+
+ /**
+ * Renders the calendar after it has been configured. The render() method has a specific call chain that will execute
+ * when the method is called: renderHeader, renderBody, renderFooter.
+ * Refer to the documentation for those methods for information on
+ * individual render tasks.
+ * @method render
+ */
+ render : function() {
+ this.beforeRenderEvent.fire();
+
+ var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG;
+
+ // Find starting day of the current month
+ var workingDate = YAHOO.widget.DateMath.findMonthStart(this.cfg.getProperty(defCfg.PAGEDATE.key));
+
+ this.resetRenderers();
+ this.cellDates.length = 0;
- YAHOO.util.Event.purgeElement(this.oDomContainer, true);
+ YAHOO.util.Event.purgeElement(this.oDomContainer, true);
- var html = [];
+ var html = [];
+
+ html[html.length] = '
';
+ html = this.renderHeader(html);
+ html = this.renderBody(workingDate, html);
+ html = this.renderFooter(html);
+ html[html.length] = '
';
- html[html.length] = '
';
- html = this.renderHeader(html);
- html = this.renderBody(workingDate, html);
- html = this.renderFooter(html);
- html[html.length] = '
';
+ this.oDomContainer.innerHTML = html.join("\n");
- this.oDomContainer.innerHTML = html.join("\n");
+ this.applyListeners();
+ this.cells = this.oDomContainer.getElementsByTagName("td");
+
+ this.cfg.refireEvent(defCfg.TITLE.key);
+ this.cfg.refireEvent(defCfg.CLOSE.key);
+ this.cfg.refireEvent(defCfg.IFRAME.key);
+
+ this.renderEvent.fire();
+ },
- this.applyListeners();
- this.cells = this.oDomContainer.getElementsByTagName("td");
+ /**
+ * Applies the Calendar's DOM listeners to applicable elements.
+ * @method applyListeners
+ */
+ applyListeners : function() {
+ var root = this.oDomContainer;
+ var cal = this.parent || this;
+ var anchor = "a";
+ var mousedown = "mousedown";
+
+ var linkLeft = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_LEFT, anchor, root);
+ var linkRight = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_RIGHT, anchor, root);
+
+ if (linkLeft && linkLeft.length > 0) {
+ this.linkLeft = linkLeft[0];
+ YAHOO.util.Event.addListener(this.linkLeft, mousedown, cal.previousMonth, cal, true);
+ }
- this.cfg.refireEvent(defCfg.TITLE.key);
- this.cfg.refireEvent(defCfg.CLOSE.key);
- this.cfg.refireEvent(defCfg.IFRAME.key);
+ if (linkRight && linkRight.length > 0) {
+ this.linkRight = linkRight[0];
+ YAHOO.util.Event.addListener(this.linkRight, mousedown, cal.nextMonth, cal, true);
+ }
- this.renderEvent.fire();
-};
+ if (cal.cfg.getProperty("navigator") !== null) {
+ this.applyNavListeners();
+ }
-/**
-* Applies the Calendar's DOM listeners to applicable elements.
-* @method applyListeners
-*/
-YAHOO.widget.Calendar.prototype.applyListeners = function() {
+ if (this.domEventMap) {
+ var el,elements;
+ for (var cls in this.domEventMap) {
+ if (YAHOO.lang.hasOwnProperty(this.domEventMap, cls)) {
+ var items = this.domEventMap[cls];
- var root = this.oDomContainer;
- var cal = this.parent || this;
+ if (! (items instanceof Array)) {
+ items = [items];
+ }
+
+ for (var i=0;i 0) {
- this.linkLeft = linkLeft[0];
- YAHOO.util.Event.addListener(this.linkLeft, mousedown, cal.previousMonth, cal, true);
- }
+ var E = YAHOO.util.Event;
- if (linkRight && linkRight.length > 0) {
- this.linkRight = linkRight[0];
- YAHOO.util.Event.addListener(this.linkRight, mousedown, cal.nextMonth, cal, true);
- }
+ var calParent = this.parent || this;
+ var cal = this;
- if (this.domEventMap) {
- var el,elements;
- for (var cls in this.domEventMap) {
- if (YAHOO.lang.hasOwnProperty(this.domEventMap, cls)) {
- var items = this.domEventMap[cls];
+ var navBtns = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV, "a", this.oDomContainer);
- if (! (items instanceof Array)) {
- items = [items];
- }
+ if (navBtns.length > 0) {
- for (var i=0;i
+ * The returned index can be used to lookup the cell HTMLElement
+ * using the Calendar's cells array or passed to selectCell to select
+ * cells by index.
+ *
+ *
+ * See cells, selectCell.
+ *
+ * @method getCellIndex
+ * @param {Date} date JavaScript Date object, for which to find a cell index.
+ * @return {Number} The index of the date in Calendars cellDates/cells arrays, or -1 if the date
+ * is not on the curently rendered Calendar page.
+ */
+ getCellIndex : function(date) {
+ var idx = -1;
+ if (date) {
+ var m = date.getMonth(),
+ y = date.getFullYear(),
+ d = date.getDate(),
+ dates = this.cellDates;
+
+ for (var i = 0; i < dates.length; ++i) {
+ var cellDate = dates[i];
+ if (cellDate[0] === y && cellDate[1] === m+1 && cellDate[2] === d) {
+ idx = i;
+ break;
}
}
}
+ return idx;
+ },
+
+ // BEGIN BUILT-IN TABLE CELL RENDERERS
+
+ /**
+ * 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
+ */
+ renderOutOfBoundsDate : function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOB);
+ cell.innerHTML = workingDate.getDate();
+ return YAHOO.widget.Calendar.STOP_RENDER;
+ },
+
+ /**
+ * 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
+ */
+ renderRowHeader : function(weekNum, html) {
+ html[html.length] = '
' + weekNum + '
';
+ return html;
+ },
+
+ /**
+ * Renders the row footer for a week.
+ * @method renderRowFooter
+ * @param {Number} weekNum The week number of the current row
+ * @param {Array} cell The current working HTML array
+ */
+ renderRowFooter : function(weekNum, html) {
+ html[html.length] = '
' + weekNum + '
';
+ return html;
+ },
+
+ /**
+ * Renders a single standard calendar cell in the calendar widget table.
+ * All logic for determining how a standard default cell will be rendered is
+ * encapsulated in this method, and must be accounted for when extending the
+ * widget class.
+ * @method renderCellDefault
+ * @param {Date} workingDate The current working Date object being used to generate the calendar
+ * @param {HTMLTableCellElement} cell The current working cell in the calendar
+ */
+ renderCellDefault : function(workingDate, cell) {
+ cell.innerHTML = '' + this.buildDayLabel(workingDate) + "";
+ },
+
+ /**
+ * Styles a selectable cell.
+ * @method styleCellDefault
+ * @param {Date} workingDate The current working Date object being used to generate the calendar
+ * @param {HTMLTableCellElement} cell The current working cell in the calendar
+ */
+ styleCellDefault : function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTABLE);
+ },
+
+
+ /**
+ * Renders a single standard calendar cell using the CSS hightlight1 style
+ * @method renderCellStyleHighlight1
+ * @param {Date} workingDate The current working Date object being used to generate the calendar
+ * @param {HTMLTableCellElement} cell The current working cell in the calendar
+ */
+ renderCellStyleHighlight1 : function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT1);
+ },
+
+ /**
+ * Renders a single standard calendar cell using the CSS hightlight2 style
+ * @method renderCellStyleHighlight2
+ * @param {Date} workingDate The current working Date object being used to generate the calendar
+ * @param {HTMLTableCellElement} cell The current working cell in the calendar
+ */
+ renderCellStyleHighlight2 : function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT2);
+ },
+
+ /**
+ * Renders a single standard calendar cell using the CSS hightlight3 style
+ * @method renderCellStyleHighlight3
+ * @param {Date} workingDate The current working Date object being used to generate the calendar
+ * @param {HTMLTableCellElement} cell The current working cell in the calendar
+ */
+ renderCellStyleHighlight3 : function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT3);
+ },
+
+ /**
+ * Renders a single standard calendar cell using the CSS hightlight4 style
+ * @method renderCellStyleHighlight4
+ * @param {Date} workingDate The current working Date object being used to generate the calendar
+ * @param {HTMLTableCellElement} cell The current working cell in the calendar
+ */
+ renderCellStyleHighlight4 : function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT4);
+ },
+
+ /**
+ * Applies the default style used for rendering today's date to the current calendar cell
+ * @method renderCellStyleToday
+ * @param {Date} workingDate The current working Date object being used to generate the calendar
+ * @param {HTMLTableCellElement} cell The current working cell in the calendar
+ */
+ renderCellStyleToday : function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TODAY);
+ },
+
+ /**
+ * Applies the default style used for rendering selected dates to the current calendar cell
+ * @method renderCellStyleSelected
+ * @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
+ */
+ renderCellStyleSelected : function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTED);
+ },
+
+ /**
+ * Applies the default style used for rendering dates that are not a part of the current
+ * month (preceding or trailing the cells for the current month)
+ * @method renderCellNotThisMonth
+ * @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
+ */
+ renderCellNotThisMonth : function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOM);
+ cell.innerHTML=workingDate.getDate();
+ return YAHOO.widget.Calendar.STOP_RENDER;
+ },
+
+ /**
+ * Renders the current calendar cell as a non-selectable "black-out" date using the default
+ * restricted style.
+ * @method renderBodyCellRestricted
+ * @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
+ */
+ renderBodyCellRestricted : function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL);
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_RESTRICTED);
+ cell.innerHTML=workingDate.getDate();
+ return YAHOO.widget.Calendar.STOP_RENDER;
+ },
+
+ // END BUILT-IN TABLE CELL RENDERERS
+
+ // BEGIN MONTH NAVIGATION METHODS
+
+ /**
+ * Adds the designated number of months to the current calendar month, and sets the current
+ * calendar page date to the new month.
+ * @method addMonths
+ * @param {Number} count The number of months to add to the current calendar
+ */
+ addMonths : function(count) {
+ var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key;
+ this.cfg.setProperty(cfgPageDate, YAHOO.widget.DateMath.add(this.cfg.getProperty(cfgPageDate), YAHOO.widget.DateMath.MONTH, count));
+ this.resetRenderers();
+ this.changePageEvent.fire();
+ },
+
+ /**
+ * Subtracts the designated number of months from the current calendar month, and sets the current
+ * calendar page date to the new month.
+ * @method subtractMonths
+ * @param {Number} count The number of months to subtract from the current calendar
+ */
+ subtractMonths : function(count) {
+ var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key;
+ this.cfg.setProperty(cfgPageDate, YAHOO.widget.DateMath.subtract(this.cfg.getProperty(cfgPageDate), YAHOO.widget.DateMath.MONTH, count));
+ this.resetRenderers();
+ this.changePageEvent.fire();
+ },
+
+ /**
+ * Adds the designated number of years to the current calendar, and sets the current
+ * calendar page date to the new month.
+ * @method addYears
+ * @param {Number} count The number of years to add to the current calendar
+ */
+ addYears : function(count) {
+ var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key;
+ this.cfg.setProperty(cfgPageDate, YAHOO.widget.DateMath.add(this.cfg.getProperty(cfgPageDate), YAHOO.widget.DateMath.YEAR, count));
+ this.resetRenderers();
+ this.changePageEvent.fire();
+ },
+
+ /**
+ * Subtcats the designated number of years from the current calendar, and sets the current
+ * calendar page date to the new month.
+ * @method subtractYears
+ * @param {Number} count The number of years to subtract from the current calendar
+ */
+ subtractYears : function(count) {
+ var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key;
+ this.cfg.setProperty(cfgPageDate, YAHOO.widget.DateMath.subtract(this.cfg.getProperty(cfgPageDate), YAHOO.widget.DateMath.YEAR, count));
+ this.resetRenderers();
+ this.changePageEvent.fire();
+ },
+
+ /**
+ * Navigates to the next month page in the calendar widget.
+ * @method nextMonth
+ */
+ nextMonth : function() {
+ this.addMonths(1);
+ },
+
+ /**
+ * Navigates to the previous month page in the calendar widget.
+ * @method previousMonth
+ */
+ previousMonth : function() {
+ this.subtractMonths(1);
+ },
+
+ /**
+ * Navigates to the next year in the currently selected month in the calendar widget.
+ * @method nextYear
+ */
+ nextYear : function() {
+ this.addYears(1);
+ },
+
+ /**
+ * Navigates to the previous year in the currently selected month in the calendar widget.
+ * @method previousYear
+ */
+ previousYear : function() {
+ this.subtractYears(1);
+ },
+
+ // END MONTH NAVIGATION METHODS
+
+ // BEGIN SELECTION METHODS
+
+ /**
+ * Resets the calendar widget to the originally selected month and year, and
+ * sets the calendar to the initial selection(s).
+ * @method reset
+ */
+ reset : function() {
+ var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG;
+ this.cfg.resetProperty(defCfg.SELECTED.key);
+ this.cfg.resetProperty(defCfg.PAGEDATE.key);
+ this.resetEvent.fire();
+ },
+
+ /**
+ * Clears the selected dates in the current calendar widget and sets the calendar
+ * to the current month and year.
+ * @method clear
+ */
+ clear : function() {
+ var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG;
+ this.cfg.setProperty(defCfg.SELECTED.key, []);
+ this.cfg.setProperty(defCfg.PAGEDATE.key, new Date(this.today.getTime()));
+ this.clearEvent.fire();
+ },
+
+ /**
+ * Selects a date or a collection of dates on the current calendar. This method, by default,
+ * does not call the render method explicitly. Once selection has completed, render must be
+ * called for the changes to be reflected visually.
+ *
+ * Any dates which are OOB (out of bounds, not selectable) will not be selected and the array of
+ * selected dates passed to the selectEvent will not contain OOB dates.
+ *
+ * If all dates are OOB, the no state change will occur; beforeSelect and select events will not be fired.
+ *
+ * @method select
+ * @param {String/Date/Date[]} date The date string of dates to select in the current calendar. Valid formats are
+ * individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
+ * Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
+ * This method can also take a JavaScript Date object or an array of Date objects.
+ * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected.
+ */
+ select : function(date) {
+ this.logger.log("Select: " + date, "info");
+
+ var aToBeSelected = this._toFieldArray(date);
+ this.logger.log("Selection field array: " + aToBeSelected, "info");
+
+ // Filtered array of valid dates
+ var validDates = [];
+ var selected = [];
+ var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key;
+
+ for (var a=0; a < aToBeSelected.length; ++a) {
+ var toSelect = aToBeSelected[a];
+
+ if (!this.isDateOOB(this._toDate(toSelect))) {
+
+ if (validDates.length === 0) {
+ this.beforeSelectEvent.fire();
+ selected = this.cfg.getProperty(cfgSelected);
+ }
+
+ validDates.push(toSelect);
+
+ if (this._indexOfSelectedFieldArray(toSelect) == -1) {
+ selected[selected.length] = toSelect;
+ }
+ }
+ }
+
+ if (validDates.length === 0) { this.logger.log("All provided dates were OOB. beforeSelect and select events not fired", "info"); }
+
+ if (validDates.length > 0) {
+ if (this.parent) {
+ this.parent.cfg.setProperty(cfgSelected, selected);
+ } else {
+ this.cfg.setProperty(cfgSelected, selected);
+ }
+ this.selectEvent.fire(validDates);
+ }
+
+ return this.getSelectedDates();
+ },
+
+ /**
+ * Selects a date on the current calendar by referencing the index of the cell that should be selected.
+ * This method is used to easily select a single cell (usually with a mouse click) without having to do
+ * a full render. The selected style is applied to the cell directly.
+ *
+ * If the cell is not marked with the CSS_CELL_SELECTABLE class (as is the case by default for out of month
+ * or out of bounds cells), it will not be selected and in such a case beforeSelect and select events will not be fired.
+ *
+ * @method selectCell
+ * @param {Number} cellIndex The index of the cell to select in the current calendar.
+ * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected.
+ */
+ selectCell : function(cellIndex) {
+
+ var cell = this.cells[cellIndex];
+ var cellDate = this.cellDates[cellIndex];
+ var dCellDate = this._toDate(cellDate);
+ this.logger.log("Select: " + dCellDate, "info");
+
+ var selectable = YAHOO.util.Dom.hasClass(cell, this.Style.CSS_CELL_SELECTABLE);
+ if (!selectable) {this.logger.log("The cell at cellIndex:" + cellIndex + " is not a selectable cell. beforeSelect, select events not fired", "info"); }
+
+ if (selectable) {
+
+ this.beforeSelectEvent.fire();
+
+ var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key;
+ var selected = this.cfg.getProperty(cfgSelected);
+
+ var selectDate = cellDate.concat();
+
+ if (this._indexOfSelectedFieldArray(selectDate) == -1) {
+ selected[selected.length] = selectDate;
+ }
+ if (this.parent) {
+ this.parent.cfg.setProperty(cfgSelected, selected);
+ } else {
+ this.cfg.setProperty(cfgSelected, selected);
+ }
+ this.renderCellStyleSelected(dCellDate,cell);
+ this.selectEvent.fire([selectDate]);
+
+ this.doCellMouseOut.call(cell, null, this);
+ }
+
+ return this.getSelectedDates();
+ },
+
+ /**
+ * Deselects a date or a collection of dates on the current calendar. This method, by default,
+ * does not call the render method explicitly. Once deselection has completed, render must be
+ * called for the changes to be reflected visually.
+ *
+ * The method will not attempt to deselect any dates which are OOB (out of bounds, and hence not selectable)
+ * and the array of deselected dates passed to the deselectEvent will not contain any OOB dates.
+ *
+ * If all dates are OOB, beforeDeselect and deselect events will not be fired.
+ *
+ * @method deselect
+ * @param {String/Date/Date[]} date The date string of dates to deselect in the current calendar. Valid formats are
+ * individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
+ * Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
+ * This method can also take a JavaScript Date object or an array of Date objects.
+ * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected.
+ */
+ deselect : function(date) {
+ this.logger.log("Deselect: " + date, "info");
+
+ var aToBeDeselected = this._toFieldArray(date);
+ this.logger.log("Deselection field array: " + aToBeDeselected, "info");
+
+ var validDates = [];
+ var selected = [];
+ var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key;
+
+ for (var a=0; a < aToBeDeselected.length; ++a) {
+ var toDeselect = aToBeDeselected[a];
+
+ if (!this.isDateOOB(this._toDate(toDeselect))) {
+
+ if (validDates.length === 0) {
+ this.beforeDeselectEvent.fire();
+ selected = this.cfg.getProperty(cfgSelected);
+ }
+
+ validDates.push(toDeselect);
+
+ var index = this._indexOfSelectedFieldArray(toDeselect);
+ if (index != -1) {
+ selected.splice(index,1);
+ }
+ }
+ }
+
+ if (validDates.length === 0) { this.logger.log("All provided dates were OOB. beforeDeselect and deselect events not fired");}
+
+ if (validDates.length > 0) {
+ if (this.parent) {
+ this.parent.cfg.setProperty(cfgSelected, selected);
+ } else {
+ this.cfg.setProperty(cfgSelected, selected);
+ }
+ this.deselectEvent.fire(validDates);
+ }
+
+ return this.getSelectedDates();
+ },
+
+ /**
+ * Deselects a date on the current calendar by referencing the index of the cell that should be deselected.
+ * This method is used to easily deselect a single cell (usually with a mouse click) without having to do
+ * a full render. The selected style is removed from the cell directly.
+ *
+ * If the cell is not marked with the CSS_CELL_SELECTABLE class (as is the case by default for out of month
+ * or out of bounds cells), the method will not attempt to deselect it and in such a case, beforeDeselect and
+ * deselect events will not be fired.
+ *
+ * @method deselectCell
+ * @param {Number} cellIndex The index of the cell to deselect in the current calendar.
+ * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected.
+ */
+ deselectCell : function(cellIndex) {
+ var cell = this.cells[cellIndex];
+ var cellDate = this.cellDates[cellIndex];
+ var cellDateIndex = this._indexOfSelectedFieldArray(cellDate);
+
+ var selectable = YAHOO.util.Dom.hasClass(cell, this.Style.CSS_CELL_SELECTABLE);
+ if (!selectable) { this.logger.log("The cell at cellIndex:" + cellIndex + " is not a selectable/deselectable cell", "info"); }
+
+ if (selectable) {
+
+ this.beforeDeselectEvent.fire();
+
+ var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG;
+ var selected = this.cfg.getProperty(defCfg.SELECTED.key);
+
+ var dCellDate = this._toDate(cellDate);
+ var selectDate = cellDate.concat();
+
+ if (cellDateIndex > -1) {
+ if (this.cfg.getProperty(defCfg.PAGEDATE.key).getMonth() == dCellDate.getMonth() &&
+ this.cfg.getProperty(defCfg.PAGEDATE.key).getFullYear() == dCellDate.getFullYear()) {
+ YAHOO.util.Dom.removeClass(cell, this.Style.CSS_CELL_SELECTED);
+ }
+ selected.splice(cellDateIndex, 1);
+ }
+
+ if (this.parent) {
+ this.parent.cfg.setProperty(defCfg.SELECTED.key, selected);
+ } else {
+ this.cfg.setProperty(defCfg.SELECTED.key, selected);
+ }
+
+ this.deselectEvent.fire(selectDate);
+ }
+
+ return this.getSelectedDates();
+ },
+
+ /**
+ * Deselects all dates on the current calendar.
+ * @method deselectAll
+ * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected.
+ * Assuming that this function executes properly, the return value should be an empty array.
+ * However, the empty array is returned for the sake of being able to check the selection status
+ * of the calendar.
+ */
+ deselectAll : function() {
+ this.beforeDeselectEvent.fire();
+
+ var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key;
+
+ var selected = this.cfg.getProperty(cfgSelected);
+ var count = selected.length;
+ var sel = selected.concat();
+
+ if (this.parent) {
+ this.parent.cfg.setProperty(cfgSelected, []);
+ } else {
+ this.cfg.setProperty(cfgSelected, []);
+ }
+
+ if (count > 0) {
+ this.deselectEvent.fire(sel);
+ }
+
+ return this.getSelectedDates();
+ },
+
+ // END SELECTION METHODS
+
+ // BEGIN TYPE CONVERSION METHODS
+
+ /**
+ * Converts a date (either a JavaScript Date object, or a date string) to the internal data structure
+ * used to represent dates: [[yyyy,mm,dd],[yyyy,mm,dd]].
+ * @method _toFieldArray
+ * @private
+ * @param {String/Date/Date[]} date The date string of dates to deselect in the current calendar. Valid formats are
+ * individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
+ * Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
+ * This method can also take a JavaScript Date object or an array of Date objects.
+ * @return {Array[](Number[])} Array of date field arrays
+ */
+ _toFieldArray : function(date) {
+ var returnDate = [];
+
+ if (date instanceof Date) {
+ returnDate = [[date.getFullYear(), date.getMonth()+1, date.getDate()]];
+ } else if (YAHOO.lang.isString(date)) {
+ returnDate = this._parseDates(date);
+ } else if (YAHOO.lang.isArray(date)) {
+ for (var i=0;i maxDate.getTime()));
+ },
+
+ /**
+ * Parses a pagedate configuration property value. The value can either be specified as a string of form "mm/yyyy" or a Date object
+ * and is parsed into a Date object normalized to the first day of the month. If no value is passed in, the month and year from today's date are used to create the Date object
+ * @method _parsePageDate
+ * @private
+ * @param {Date|String} date Pagedate value which needs to be parsed
+ * @return {Date} The Date object representing the pagedate
+ */
+ _parsePageDate : function(date) {
+ var parsedDate;
+
+ var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG;
+
+ if (date) {
+ if (date instanceof Date) {
+ parsedDate = YAHOO.widget.DateMath.findMonthStart(date);
+ } else {
+ var month, year, aMonthYear;
+ aMonthYear = date.split(this.cfg.getProperty(defCfg.DATE_FIELD_DELIMITER.key));
+ month = parseInt(aMonthYear[this.cfg.getProperty(defCfg.MY_MONTH_POSITION.key)-1], 10)-1;
+ year = parseInt(aMonthYear[this.cfg.getProperty(defCfg.MY_YEAR_POSITION.key)-1], 10);
+
+ parsedDate = YAHOO.widget.DateMath.getDate(year, month, 1);
+ }
+ } else {
+ parsedDate = YAHOO.widget.DateMath.getDate(this.today.getFullYear(), this.today.getMonth(), 1);
+ }
+ return parsedDate;
+ },
+
+ // END UTILITY METHODS
+
+ // BEGIN EVENT HANDLERS
+
+ /**
+ * Event executed before a date is selected in the calendar widget.
+ * @deprecated Event handlers for this event should be susbcribed to beforeSelectEvent.
+ */
+ onBeforeSelect : function() {
+ if (this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MULTI_SELECT.key) === false) {
+ if (this.parent) {
+ this.parent.callChildFunction("clearAllBodyCellStyles", this.Style.CSS_CELL_SELECTED);
+ this.parent.deselectAll();
+ } else {
+ this.clearAllBodyCellStyles(this.Style.CSS_CELL_SELECTED);
+ this.deselectAll();
+ }
+ }
+ },
+
+ /**
+ * Event executed when a date is selected in the calendar widget.
+ * @param {Array} selected An array of date field arrays representing which date or dates were selected. Example: [ [2006,8,6],[2006,8,7],[2006,8,8] ]
+ * @deprecated Event handlers for this event should be susbcribed to selectEvent.
+ */
+ onSelect : function(selected) { },
+
+ /**
+ * Event executed before a date is deselected in the calendar widget.
+ * @deprecated Event handlers for this event should be susbcribed to beforeDeselectEvent.
+ */
+ onBeforeDeselect : function() { },
+
+ /**
+ * Event executed when a date is deselected in the calendar widget.
+ * @param {Array} selected An array of date field arrays representing which date or dates were deselected. Example: [ [2006,8,6],[2006,8,7],[2006,8,8] ]
+ * @deprecated Event handlers for this event should be susbcribed to deselectEvent.
+ */
+ onDeselect : function(deselected) { },
+
+ /**
+ * Event executed when the user navigates to a different calendar page.
+ * @deprecated Event handlers for this event should be susbcribed to changePageEvent.
+ */
+ onChangePage : function() {
+ this.render();
+ },
+
+ /**
+ * Event executed when the calendar widget is rendered.
+ * @deprecated Event handlers for this event should be susbcribed to renderEvent.
+ */
+ onRender : function() { },
+
+ /**
+ * Event executed when the calendar widget is reset to its original state.
+ * @deprecated Event handlers for this event should be susbcribed to resetEvemt.
+ */
+ onReset : function() { this.render(); },
+
+ /**
+ * Event executed when the calendar widget is completely cleared to the current month with no selections.
+ * @deprecated Event handlers for this event should be susbcribed to clearEvent.
+ */
+ onClear : function() { this.render(); },
+
+ /**
+ * Validates the calendar widget. This method has no default implementation
+ * and must be extended by subclassing the widget.
+ * @return Should return true if the widget validates, and false if
+ * it doesn't.
+ * @type Boolean
+ */
+ validate : function() { return true; },
+
+ // END EVENT HANDLERS
+
+ // BEGIN DATE PARSE METHODS
+
+ /**
+ * Converts a date string to a date field array
+ * @private
+ * @param {String} sDate Date string. Valid formats are mm/dd and mm/dd/yyyy.
+ * @return A date field array representing the string passed to the method
+ * @type Array[](Number[])
+ */
+ _parseDate : function(sDate) {
+ var aDate = sDate.split(this.Locale.DATE_FIELD_DELIMITER);
+ var rArray;
+
+ if (aDate.length == 2) {
+ rArray = [aDate[this.Locale.MD_MONTH_POSITION-1],aDate[this.Locale.MD_DAY_POSITION-1]];
+ rArray.type = YAHOO.widget.Calendar.MONTH_DAY;
+ } else {
+ rArray = [aDate[this.Locale.MDY_YEAR_POSITION-1],aDate[this.Locale.MDY_MONTH_POSITION-1],aDate[this.Locale.MDY_DAY_POSITION-1]];
+ rArray.type = YAHOO.widget.Calendar.DATE;
+ }
+
+ for (var i=0;i
+*
+*
+*
+* The tables for the calendars ("cal1_0" and "cal1_1") will be inserted into those containers.
+*
+*
+* 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.:
+*
+* var c = new YAHOO.widget.CalendarGroup("calContainer", configOptions);
+*
+* or:
+*
+* var containerDiv = YAHOO.util.Dom.get("calContainer");
+* var c = new YAHOO.widget.CalendarGroup(containerDiv, configOptions);
+*
+*
+*
+* 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] = '
' + weekNum + '
';
- return html;
-};
+ this.oDomContainer = YAHOO.util.Dom.get(container);
+ if (!this.oDomContainer) { this.logger.log("Container not found in document.", "error"); }
-/**
-* Renders the row footer for a week.
-* @method renderRowFooter
-* @param {Number} weekNum The week number of the current row
-* @param {Array} cell The current working HTML array
-*/
-YAHOO.widget.Calendar.prototype.renderRowFooter = function(weekNum, html) {
- html[html.length] = '
' + weekNum + '
';
- return html;
-};
+ if (!this.oDomContainer.id) {
+ this.oDomContainer.id = YAHOO.util.Dom.generateId();
+ }
+ if (!id) {
+ id = this.oDomContainer.id + "_t";
+ }
-/**
-* Renders a single standard calendar cell in the calendar widget table.
-* All logic for determining how a standard default cell will be rendered is
-* encapsulated in this method, and must be accounted for when extending the
-* widget class.
-* @method renderCellDefault
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.renderCellDefault = function(workingDate, cell) {
- cell.innerHTML = '' + this.buildDayLabel(workingDate) + "";
-};
+ /**
+ * The unique id associated with the CalendarGroup
+ * @property id
+ * @type String
+ */
+ this.id = id;
-/**
-* Styles a selectable cell.
-* @method styleCellDefault
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.styleCellDefault = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTABLE);
-};
+ /**
+ * The unique id associated with the CalendarGroup container
+ * @property containerId
+ * @type String
+ */
+ this.containerId = this.oDomContainer.id;
+ this.logger = new YAHOO.widget.LogWriter("CalendarGroup " + this.id);
+ this.initEvents();
+ this.initStyles();
-/**
-* Renders a single standard calendar cell using the CSS hightlight1 style
-* @method renderCellStyleHighlight1
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.renderCellStyleHighlight1 = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT1);
-};
+ /**
+ * The collection of Calendar pages contained within the CalendarGroup
+ * @property pages
+ * @type YAHOO.widget.Calendar[]
+ */
+ this.pages = [];
-/**
-* Renders a single standard calendar cell using the CSS hightlight2 style
-* @method renderCellStyleHighlight2
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.renderCellStyleHighlight2 = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT2);
-};
+ YAHOO.util.Dom.addClass(this.oDomContainer, YAHOO.widget.CalendarGroup.CSS_CONTAINER);
+ YAHOO.util.Dom.addClass(this.oDomContainer, YAHOO.widget.CalendarGroup.CSS_MULTI_UP);
-/**
-* Renders a single standard calendar cell using the CSS hightlight3 style
-* @method renderCellStyleHighlight3
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.renderCellStyleHighlight3 = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT3);
-};
+ /**
+ * The Config object used to hold the configuration variables for the CalendarGroup
+ * @property cfg
+ * @type YAHOO.util.Config
+ */
+ this.cfg = new YAHOO.util.Config(this);
-/**
-* Renders a single standard calendar cell using the CSS hightlight4 style
-* @method renderCellStyleHighlight4
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.renderCellStyleHighlight4 = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT4);
-};
+ /**
+ * The local object which contains the CalendarGroup's options
+ * @property Options
+ * @type Object
+ */
+ this.Options = {};
-/**
-* Applies the default style used for rendering today's date to the current calendar cell
-* @method renderCellStyleToday
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.renderCellStyleToday = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TODAY);
-};
+ /**
+ * The local object which contains the CalendarGroup's locale settings
+ * @property Locale
+ * @type Object
+ */
+ this.Locale = {};
-/**
-* Applies the default style used for rendering selected dates to the current calendar cell
-* @method renderCellStyleSelected
-* @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.renderCellStyleSelected = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTED);
-};
+ this.setupConfig();
-/**
-* Applies the default style used for rendering dates that are not a part of the current
-* month (preceding or trailing the cells for the current month)
-* @method renderCellNotThisMonth
-* @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.renderCellNotThisMonth = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOM);
- cell.innerHTML=workingDate.getDate();
- return YAHOO.widget.Calendar.STOP_RENDER;
-};
+ if (config) {
+ this.cfg.applyConfig(config, true);
+ }
-/**
-* Renders the current calendar cell as a non-selectable "black-out" date using the default
-* restricted style.
-* @method renderBodyCellRestricted
-* @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.renderBodyCellRestricted = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL);
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_RESTRICTED);
- cell.innerHTML=workingDate.getDate();
- return YAHOO.widget.Calendar.STOP_RENDER;
-};
+ this.cfg.fireQueue();
-// END BUILT-IN TABLE CELL RENDERERS
+ // OPERA HACK FOR MISWRAPPED FLOATS
+ if (YAHOO.env.ua.opera){
+ this.renderEvent.subscribe(this._fixWidth, this, true);
+ this.showEvent.subscribe(this._fixWidth, this, true);
+ }
-// BEGIN MONTH NAVIGATION METHODS
+ this.logger.log("Initialized " + this.pages.length + "-page CalendarGroup", "info");
+ },
-/**
-* Adds the designated number of months to the current calendar month, and sets the current
-* calendar page date to the new month.
-* @method addMonths
-* @param {Number} count The number of months to add to the current calendar
-*/
-YAHOO.widget.Calendar.prototype.addMonths = function(count) {
- var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key;
- this.cfg.setProperty(cfgPageDate, YAHOO.widget.DateMath.add(this.cfg.getProperty(cfgPageDate), YAHOO.widget.DateMath.MONTH, count));
- this.resetRenderers();
- this.changePageEvent.fire();
-};
+ setupConfig : function() {
-/**
-* Subtracts the designated number of months from the current calendar month, and sets the current
-* calendar page date to the new month.
-* @method subtractMonths
-* @param {Number} count The number of months to subtract from the current calendar
-*/
-YAHOO.widget.Calendar.prototype.subtractMonths = function(count) {
- var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key;
- this.cfg.setProperty(cfgPageDate, YAHOO.widget.DateMath.subtract(this.cfg.getProperty(cfgPageDate), YAHOO.widget.DateMath.MONTH, count));
- this.resetRenderers();
- this.changePageEvent.fire();
-};
+ var defCfg = YAHOO.widget.CalendarGroup._DEFAULT_CONFIG;
-/**
-* Adds the designated number of years to the current calendar, and sets the current
-* calendar page date to the new month.
-* @method addYears
-* @param {Number} count The number of years to add to the current calendar
-*/
-YAHOO.widget.Calendar.prototype.addYears = function(count) {
- var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key;
- this.cfg.setProperty(cfgPageDate, YAHOO.widget.DateMath.add(this.cfg.getProperty(cfgPageDate), YAHOO.widget.DateMath.YEAR, count));
- this.resetRenderers();
- this.changePageEvent.fire();
-};
+ /**
+ * The number of pages to include in the CalendarGroup. This value can only be set once, in the CalendarGroup's constructor arguments.
+ * @config pages
+ * @type Number
+ * @default 2
+ */
+ this.cfg.addProperty(defCfg.PAGES.key, { value:defCfg.PAGES.value, validator:this.cfg.checkNumber, handler:this.configPages } );
-/**
-* Subtcats the designated number of years from the current calendar, and sets the current
-* calendar page date to the new month.
-* @method subtractYears
-* @param {Number} count The number of years to subtract from the current calendar
-*/
-YAHOO.widget.Calendar.prototype.subtractYears = function(count) {
- var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key;
- this.cfg.setProperty(cfgPageDate, YAHOO.widget.DateMath.subtract(this.cfg.getProperty(cfgPageDate), YAHOO.widget.DateMath.YEAR, count));
- this.resetRenderers();
- this.changePageEvent.fire();
-};
+ /**
+ * 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 } );
-/**
-* Navigates to the next month page in the calendar widget.
-* @method nextMonth
-*/
-YAHOO.widget.Calendar.prototype.nextMonth = function() {
- this.addMonths(1);
-};
+ /**
+ * 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 } );
-/**
-* Navigates to the previous month page in the calendar widget.
-* @method previousMonth
-*/
-YAHOO.widget.Calendar.prototype.previousMonth = function() {
- this.subtractMonths(1);
-};
+ /**
+ * The title to display above the CalendarGroup's month header
+ * @config title
+ * @type String
+ * @default ""
+ */
+ this.cfg.addProperty(defCfg.TITLE.key, { value:defCfg.TITLE.value, handler:this.configTitle } );
-/**
-* Navigates to the next year in the currently selected month in the calendar widget.
-* @method nextYear
-*/
-YAHOO.widget.Calendar.prototype.nextYear = function() {
- this.addYears(1);
-};
+ /**
+ * Whether or not a close button should be displayed for this CalendarGroup
+ * @config close
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty(defCfg.CLOSE.key, { value:defCfg.CLOSE.value, handler:this.configClose } );
-/**
-* Navigates to the previous year in the currently selected month in the calendar widget.
-* @method previousYear
-*/
-YAHOO.widget.Calendar.prototype.previousYear = function() {
- this.subtractYears(1);
-};
+ /**
+ * 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.delegateConfig } );
+
+ /**
+ * 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.delegateConfig } );
+
+ // 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.delegateConfig, 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.delegateConfig, 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.delegateConfig, 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.delegateConfig, 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.delegateConfig, 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.delegateConfig, 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.delegateConfig } );
+
+ /**
+ * 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.delegateConfig } );
+
+ // 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.delegateConfig } );
+
+ /**
+ * 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.delegateConfig } );
+
+ /**
+ * 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.delegateConfig } );
+
+ /**
+ * 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.delegateConfig } );
+
+ /**
+ * 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.delegateConfig } );
+
+ /**
+ * 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.delegateConfig } );
+
+ /**
+ * 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.delegateConfig } );
+
+ /**
+ * 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.delegateConfig } );
+
+ /**
+ * 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.delegateConfig } );
+
+ /**
+ * 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.delegateConfig } );
+
+ /**
+ * 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.delegateConfig } );
+
+ /**
+ * 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.delegateConfig, 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.delegateConfig, 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.delegateConfig, 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.delegateConfig, 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.delegateConfig, 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.delegateConfig, 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.delegateConfig, 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.delegateConfig, 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.delegateConfig, validator:this.cfg.checkNumber } );
+
+ /**
+ * The suffix used after the month when rendering the Calendar header
+ * @config MY_LABEL_MONTH_SUFFIX
+ * @type String
+ * @default " "
+ */
+ this.cfg.addProperty(defCfg.MY_LABEL_MONTH_SUFFIX.key, { value:defCfg.MY_LABEL_MONTH_SUFFIX.value, handler:this.delegateConfig } );
+
+ /**
+ * 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.delegateConfig } );
-// END MONTH NAVIGATION METHODS
+ /**
+ * Configuration for the Month Year Navigation UI. By default it is disabled
+ * @config NAV
+ * @type Object
+ * @default null
+ */
+ this.cfg.addProperty(defCfg.NAV.key, { value:defCfg.NAV.value, handler:this.configNavigator } );
+ },
-// BEGIN SELECTION METHODS
+ /**
+ * Initializes CalendarGroup's built-in CustomEvents
+ * @method initEvents
+ */
+ initEvents : function() {
+ var me = this;
+ var strEvent = "Event";
-/**
-* Resets the calendar widget to the originally selected month and year, and
-* sets the calendar to the initial selection(s).
-* @method reset
-*/
-YAHOO.widget.Calendar.prototype.reset = function() {
- var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG;
- this.cfg.resetProperty(defCfg.SELECTED.key);
- this.cfg.resetProperty(defCfg.PAGEDATE.key);
- this.resetEvent.fire();
-};
+ /**
+ * Proxy subscriber to subscribe to the CalendarGroup's child Calendars' CustomEvents
+ * @method sub
+ * @private
+ * @param {Function} fn The function to subscribe to this CustomEvent
+ * @param {Object} obj The CustomEvent's scope object
+ * @param {Boolean} bOverride Whether or not to apply scope correction
+ */
+ var sub = function(fn, obj, bOverride) {
+ for (var p=0;p 0) {
- if (this.parent) {
- this.parent.cfg.setProperty(cfgSelected, selected);
- } else {
- this.cfg.setProperty(cfgSelected, selected);
+ /**
+ * The default Config handler for the "pagedate" property
+ * @method configPageDate
+ * @param {String} type The CustomEvent type (usually the property name)
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+ */
+ configPageDate : function(type, args, obj) {
+ var val = args[0];
+ var firstPageDate;
+
+ var cfgPageDate = YAHOO.widget.CalendarGroup._DEFAULT_CONFIG.PAGEDATE.key;
+
+ for (var p=0;p 0) ? this.pages[0].cfg.getProperty(cfgSelected) : [];
+ this.cfg.setProperty(cfgSelected, selected, true);
+ },
- if (this._indexOfSelectedFieldArray(selectDate) == -1) {
- selected[selected.length] = selectDate;
- }
- if (this.parent) {
- this.parent.cfg.setProperty(cfgSelected, selected);
- } else {
- this.cfg.setProperty(cfgSelected, selected);
+
+ /**
+ * Delegates a configuration property to the CustomEvents associated with the CalendarGroup's children
+ * @method delegateConfig
+ * @param {String} type The CustomEvent type (usually the property name)
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+ */
+ delegateConfig : function(type, args, obj) {
+ var val = args[0];
+ var cal;
+
+ for (var p=0;p 0) {
- if (this.parent) {
- this.parent.cfg.setProperty(cfgSelected, selected);
- } else {
- this.cfg.setProperty(cfgSelected, selected);
+ for (var p=0; p -1) {
- if (this.cfg.getProperty(defCfg.PAGEDATE.key).getMonth() == dCellDate.getMonth() &&
- this.cfg.getProperty(defCfg.PAGEDATE.key).getFullYear() == dCellDate.getFullYear()) {
- YAHOO.util.Dom.removeClass(cell, this.Style.CSS_CELL_SELECTED);
+ var cfgPageDate = YAHOO.widget.CalendarGroup._DEFAULT_CONFIG.PAGEDATE.key;
+
+ year = parseInt(year, 10);
+ for (var p=0;p0) {
+ year+=1;
}
- selected.splice(cellDateIndex, 1);
+ cal.setYear(year);
}
+ },
- if (this.parent) {
- this.parent.cfg.setProperty(defCfg.SELECTED.key, selected);
- } else {
- this.cfg.setProperty(defCfg.SELECTED.key, selected);
+ /**
+ * Calls the render function of all child calendars within the group.
+ * @method render
+ */
+ render : function() {
+ this.renderHeader();
+ for (var p=0;p
+ *
If MULTI_SELECT is false, selectCell will select the cell at the specified index for only the last displayed Calendar page.
+ *
If MULTI_SELECT is true, selectCell will select the cell at the specified index, on each displayed Calendar page.
+ *
+ * @method selectCell
+ * @param {Number} cellIndex The index of the cell to be selected.
+ * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected.
+ */
+ selectCell : function(cellIndex) {
+ for (var p=0;p 0) {
- this.deselectEvent.fire(sel);
- }
-
- return this.getSelectedDates();
-};
-
-// END SELECTION METHODS
-
-// BEGIN TYPE CONVERSION METHODS
-
-/**
-* Converts a date (either a JavaScript Date object, or a date string) to the internal data structure
-* used to represent dates: [[yyyy,mm,dd],[yyyy,mm,dd]].
-* @method _toFieldArray
-* @private
-* @param {String/Date/Date[]} date The date string of dates to deselect in the current calendar. Valid formats are
-* individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
-* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
-* This method can also take a JavaScript Date object or an array of Date objects.
-* @return {Array[](Number[])} Array of date field arrays
-*/
-YAHOO.widget.Calendar.prototype._toFieldArray = function(date) {
- var returnDate = [];
-
- if (date instanceof Date) {
- returnDate = [[date.getFullYear(), date.getMonth()+1, date.getDate()]];
- } else if (YAHOO.lang.isString(date)) {
- returnDate = this._parseDates(date);
- } else if (YAHOO.lang.isArray(date)) {
- for (var i=0;i maxDate.getTime()));
-};
-
-/**
- * Parses a pagedate configuration property value. The value can either be specified as a string of form "mm/yyyy" or a Date object
- * and is parsed into a Date object normalized to the first day of the month. If no value is passed in, the month and year from today's date are used to create the Date object
- * @method _parsePageDate
- * @private
- * @param {Date|String} date Pagedate value which needs to be parsed
- * @return {Date} The Date object representing the pagedate
- */
-YAHOO.widget.Calendar.prototype._parsePageDate = function(date) {
- var parsedDate;
+ return this.getSelectedDates();
+ },
- var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG;
-
- if (date) {
- if (date instanceof Date) {
- parsedDate = YAHOO.widget.DateMath.findMonthStart(date);
- } else {
- var month, year, aMonthYear;
- aMonthYear = date.split(this.cfg.getProperty(defCfg.DATE_FIELD_DELIMITER.key));
- month = parseInt(aMonthYear[this.cfg.getProperty(defCfg.MY_MONTH_POSITION.key)-1], 10)-1;
- year = parseInt(aMonthYear[this.cfg.getProperty(defCfg.MY_YEAR_POSITION.key)-1], 10);
-
- parsedDate = new Date(year, month, 1);
+ /**
+ * Resets the calendar widget to the originally selected month and year, and
+ * sets the calendar to the initial selection(s).
+ * @method reset
+ */
+ reset : function() {
+ for (var p=0;p=0;--p) {
+ var cal = this.pages[p];
+ cal.previousMonth();
+ }
+ },
+
+ /**
+ * Navigates to the next year in the currently selected month in the calendar widget.
+ * @method nextYear
+ */
+ nextYear : function() {
+ for (var p=0;p 11)) {
+ var DM = YAHOO.widget.DateMath;
+ var newDate = DM.add(date, DM.MONTH, iMonth-date.getMonth());
+ date.setTime(newDate.getTime());
+ } else {
+ date.setMonth(iMonth);
+ }
+ },
+
+ /**
+ * Fixes the width of the CalendarGroup container element, to account for miswrapped floats
+ * @method _fixWidth
+ * @private
+ */
+ _fixWidth : function() {
+ var w = 0;
+ for (var p=0;p 0) {
+ this.oDomContainer.style.width = w + "px";
}
+ },
+
+ /**
+ * Returns a string representation of the object.
+ * @method toString
+ * @return {String} A string representation of the CalendarGroup object.
+ */
+ toString : function() {
+ return "CalendarGroup " + this.id;
}
};
/**
-* The private method used for adding cell renderers to the local render stack.
-* This method is called by other methods that set the renderer type prior to the method call.
-* @method _addRenderer
-* @private
-* @param {String} type The type string that indicates the type of date renderer being added.
-* Values are YAHOO.widget.Calendar.DATE, YAHOO.widget.Calendar.MONTH_DAY, YAHOO.widget.Calendar.WEEKDAY,
-* YAHOO.widget.Calendar.RANGE, YAHOO.widget.Calendar.MONTH
-* @param {Array} aDates An array of dates used to construct the renderer. The format varies based
-* on the renderer type
-* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer.
-*/
-YAHOO.widget.Calendar.prototype._addRenderer = function(type, aDates, fnRender) {
- var add = [type,aDates,fnRender];
- this.renderStack.unshift(add);
- this._renderStack = this.renderStack.concat();
-};
-
-/**
-* Adds a month to the render stack. The function reference passed to this method will be executed
-* when a date cell matches the month passed to this method.
-* @method addMonthRenderer
-* @param {Number} month The month (1-12) to associate with this renderer
-* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer.
-*/
-YAHOO.widget.Calendar.prototype.addMonthRenderer = function(month, fnRender) {
- this._addRenderer(YAHOO.widget.Calendar.MONTH,[month],fnRender);
-};
-
-/**
-* Adds a weekday to the render stack. The function reference passed to this method will be executed
-* when a date cell matches the weekday passed to this method.
-* @method addWeekdayRenderer
-* @param {Number} weekday The weekday (0-6) to associate with this renderer
-* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer.
-*/
-YAHOO.widget.Calendar.prototype.addWeekdayRenderer = function(weekday, fnRender) {
- this._addRenderer(YAHOO.widget.Calendar.WEEKDAY,[weekday],fnRender);
-};
-
-// END RENDERER METHODS
-
-// BEGIN CSS METHODS
-
-/**
-* Removes all styles from all body cells in the current calendar table.
-* @method clearAllBodyCellStyles
-* @param {style} The CSS class name to remove from all calendar body cells
+* CSS class representing the container for the calendar
+* @property YAHOO.widget.CalendarGroup.CSS_CONTAINER
+* @static
+* @final
+* @type String
*/
-YAHOO.widget.Calendar.prototype.clearAllBodyCellStyles = function(style) {
- for (var c=0;cStyle.CSS_CLOSE property now represents the CSS class used to render the close icon
+* @type String
*/
-YAHOO.widget.Calendar.prototype.getSelectedDates = function() {
- var returnDates = [];
- var selected = this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key);
-
- for (var d=0;d
-*
-*
-*
-* The tables for the calendars ("cal1_0" and "cal1_1") will be inserted into those containers.
-* @namespace YAHOO.widget
-* @class CalendarGroup
-* @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
+* @deprecated The old Calendar2up class is no longer necessary, since CalendarGroup renders in a 2up view by default.
*/
-YAHOO.widget.CalendarGroup = function(id, containerId, config) {
- if (arguments.length > 0) {
- this.init(id, containerId, config);
- }
-};
+YAHOO.widget.Cal2up = YAHOO.widget.Calendar2up;
/**
-* Initializes the calendar group. All subclasses must call this method in order for the
-* group to be initialized properly.
-* @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.CalendarGroup.prototype.init = function(id, containerId, config) {
- this.logger = new YAHOO.widget.LogWriter("CalendarGroup " + id);
- this.initEvents();
- this.initStyles();
-
- /**
- * The collection of Calendar pages contained within the CalendarGroup
- * @property pages
- * @type YAHOO.widget.Calendar[]
- */
- this.pages = [];
-
- /**
- * The unique id associated with the CalendarGroup
- * @property id
- * @type String
- */
- this.id = id;
-
- /**
- * The unique id associated with the CalendarGroup container
- * @property containerId
- * @type String
- */
- this.containerId = containerId;
-
- /**
- * The outer containing element for the CalendarGroup
- * @property oDomContainer
- * @type HTMLElement
- */
- this.oDomContainer = document.getElementById(containerId);
-
- YAHOO.util.Dom.addClass(this.oDomContainer, YAHOO.widget.CalendarGroup.CSS_CONTAINER);
- YAHOO.util.Dom.addClass(this.oDomContainer, YAHOO.widget.CalendarGroup.CSS_MULTI_UP);
-
- /**
- * The Config object used to hold the configuration variables for the CalendarGroup
- * @property cfg
- * @type YAHOO.util.Config
- */
- this.cfg = new YAHOO.util.Config(this);
-
- /**
- * The local object which contains the CalendarGroup's options
- * @property Options
- * @type Object
- */
- this.Options = {};
-
- /**
- * The local object which contains the CalendarGroup's locale settings
- * @property Locale
- * @type Object
- */
- this.Locale = {};
-
- this.setupConfig();
-
- if (config) {
- this.cfg.applyConfig(config, true);
- }
-
- this.cfg.fireQueue();
-
- // OPERA HACK FOR MISWRAPPED FLOATS
- if (YAHOO.env.ua.opera){
- this.renderEvent.subscribe(this._fixWidth, this, true);
- }
- this.logger.log("Initialized " + this.pages.length + "-page CalendarGroup", "info");
+ * The CalendarNavigator is used along with a Calendar/CalendarGroup to
+ * provide a Month/Year popup navigation control, allowing the user to navigate
+ * to a specific month/year in the Calendar/CalendarGroup without having to
+ * scroll through months sequentially
+ *
+ * @namespace YAHOO.widget
+ * @class CalendarNavigator
+ * @constructor
+ * @param {Calendar|CalendarGroup} cal The instance of the Calendar or CalendarGroup to which this CalendarNavigator should be attached.
+ */
+YAHOO.widget.CalendarNavigator = function(cal) {
+ this.init(cal);
};
-
-YAHOO.widget.CalendarGroup.prototype.setupConfig = function() {
-
- var defCfg = YAHOO.widget.CalendarGroup._DEFAULT_CONFIG;
-
- /**
- * The number of pages to include in the CalendarGroup. This value can only be set once, in the CalendarGroup's constructor arguments.
- * @config pages
- * @type Number
- * @default 2
- */
- this.cfg.addProperty(defCfg.PAGES.key, { value:defCfg.PAGES.value, validator:this.cfg.checkNumber, handler:this.configPages } );
+(function() {
+ // Setup static properties (inside anon fn, so that we can use shortcuts)
+ var CN = YAHOO.widget.CalendarNavigator;
/**
- * 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 } );
+ * YAHOO.widget.CalendarNavigator.CLASSES contains constants
+ * for the class values applied to the CalendarNaviatgator's
+ * DOM elements
+ * @property YAHOO.widget.CalendarNavigator.CLASSES
+ * @type Object
+ * @static
+ */
+ CN.CLASSES = {
+ /**
+ * Class applied to the Calendar Navigator's bounding box
+ * @property YAHOO.widget.CalendarNavigator.CLASSES.NAV
+ * @type String
+ * @static
+ */
+ NAV :"yui-cal-nav",
+ /**
+ * Class applied to the Calendar/CalendarGroup's bounding box to indicate
+ * the Navigator is currently visible
+ * @property YAHOO.widget.CalendarNavigator.CLASSES.NAV_VISIBLE
+ * @type String
+ * @static
+ */
+ NAV_VISIBLE: "yui-cal-nav-visible",
+ /**
+ * Class applied to the Navigator mask's bounding box
+ * @property YAHOO.widget.CalendarNavigator.CLASSES.MASK
+ * @type String
+ * @static
+ */
+ MASK : "yui-cal-nav-mask",
+ /**
+ * Class applied to the year label/control bounding box
+ * @property YAHOO.widget.CalendarNavigator.CLASSES.YEAR
+ * @type String
+ * @static
+ */
+ YEAR : "yui-cal-nav-y",
+ /**
+ * Class applied to the month label/control bounding box
+ * @property YAHOO.widget.CalendarNavigator.CLASSES.MONTH
+ * @type String
+ * @static
+ */
+ MONTH : "yui-cal-nav-m",
+ /**
+ * Class applied to the submit/cancel button's bounding box
+ * @property YAHOO.widget.CalendarNavigator.CLASSES.BUTTONS
+ * @type String
+ * @static
+ */
+ BUTTONS : "yui-cal-nav-b",
+ /**
+ * Class applied to buttons wrapping element
+ * @property YAHOO.widget.CalendarNavigator.CLASSES.BUTTON
+ * @type String
+ * @static
+ */
+ BUTTON : "yui-cal-nav-btn",
+ /**
+ * Class applied to the validation error area's bounding box
+ * @property YAHOO.widget.CalendarNavigator.CLASSES.ERROR
+ * @type String
+ * @static
+ */
+ ERROR : "yui-cal-nav-e",
+ /**
+ * Class applied to the year input control
+ * @property YAHOO.widget.CalendarNavigator.CLASSES.YEAR_CTRL
+ * @type String
+ * @static
+ */
+ YEAR_CTRL : "yui-cal-nav-yc",
+ /**
+ * Class applied to the month input control
+ * @property YAHOO.widget.CalendarNavigator.CLASSES.MONTH_CTRL
+ * @type String
+ * @static
+ */
+ MONTH_CTRL : "yui-cal-nav-mc",
+ /**
+ * Class applied to controls with invalid data (e.g. a year input field with invalid an year)
+ * @property YAHOO.widget.CalendarNavigator.CLASSES.INVALID
+ * @type String
+ * @static
+ */
+ INVALID : "yui-invalid",
+ /**
+ * Class applied to default controls
+ * @property YAHOO.widget.CalendarNavigator.CLASSES.DEFAULT
+ * @type String
+ * @static
+ */
+ DEFAULT : "yui-default"
+ };
/**
- * 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 } );
+ * Object literal containing the default configuration values for the CalendarNavigator
+ * The configuration object is expected to follow the format below, with the properties being
+ * case sensitive.
+ *