From: nicolasconnault
- * Fix approach and original findings are available here:
- * http://brianary.blogspot.com/2006/03/safari-date-bug.html
- *
- * NOTE:Validation on argument values is not performed. It is the caller's responsibility to ensure
- * arguments are valid as per the ECMAScript-262 Date object specification for the new Date(year, month[, date]) constructor.
- * To construct the placeholder for the calendar widget, the code is as
-* follows:
-*
- *
- *
- * @class AutoComplete
- * @constructor
- * @param elInput {HTMLElement} DOM element reference of an input field.
- * @param elInput {String} String ID of an input field.
- * @param elContainer {HTMLElement} DOM element reference of an existing DIV.
- * @param elContainer {String} String ID of an existing DIV.
- * @param oDataSource {YAHOO.widget.DataSource} DataSource instance.
- * @param oConfigs {Object} (optional) Object literal of configuration params.
- */
-YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) {
- if(elInput && elContainer && oDataSource) {
- // Validate DataSource
- if(oDataSource instanceof YAHOO.widget.DataSource) {
- this.dataSource = oDataSource;
- }
- else {
- YAHOO.log("Could not instantiate AutoComplete due to an invalid DataSource", "error", this.toString());
- return;
- }
-
- // Validate input element
- if(YAHOO.util.Dom.inDocument(elInput)) {
- if(YAHOO.lang.isString(elInput)) {
- this._sName = "instance" + YAHOO.widget.AutoComplete._nIndex + " " + elInput;
- this._elTextbox = document.getElementById(elInput);
- }
- else {
- this._sName = (elInput.id) ?
- "instance" + YAHOO.widget.AutoComplete._nIndex + " " + elInput.id:
- "instance" + YAHOO.widget.AutoComplete._nIndex;
- this._elTextbox = elInput;
- }
- 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());
- return;
- }
-
- // Validate container element
- if(YAHOO.util.Dom.inDocument(elContainer)) {
- if(YAHOO.lang.isString(elContainer)) {
- this._elContainer = document.getElementById(elContainer);
- }
- else {
- this._elContainer = elContainer;
- }
- 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._elContainer.parentNode;
- var elTag = elParent.tagName.toLowerCase();
- if(elTag == "div") {
- YAHOO.util.Dom.addClass(elParent, "yui-ac");
- }
- else {
- YAHOO.log("Could not find the wrapper element for skinning", "warn", this.toString());
- }
- }
- else {
- YAHOO.log("Could not instantiate AutoComplete due to an invalid container element", "error", this.toString());
- return;
- }
-
- // Set any config params passed in to override defaults
- if(oConfigs && (oConfigs.constructor == Object)) {
- for(var sConfig in oConfigs) {
- if(sConfig) {
- this[sConfig] = oConfigs[sConfig];
- }
- }
- }
-
- // Initialization sequence
- this._initContainer();
- this._initProps();
- this._initList();
- this._initContainerHelpers();
-
- // Set up events
- var oSelf = this;
- var elTextbox = this._elTextbox;
- // Events are actually for the content module within the container
- var elContent = this._elContent;
-
- // Dom events
- 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);
- 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);
-
- // Finish up
- elTextbox.setAttribute("autocomplete","off");
- YAHOO.widget.AutoComplete._nIndex++;
- YAHOO.log("AutoComplete initialized","info",this.toString());
- }
- // Required arguments were not found
- else {
- YAHOO.log("Could not instantiate AutoComplete due invalid arguments", "error", this.toString());
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * The DataSource object that encapsulates the data used for auto completion.
- * This object should be an inherited object from YAHOO.widget.DataSource.
- *
- * @property dataSource
- * @type YAHOO.widget.DataSource
- */
-YAHOO.widget.AutoComplete.prototype.dataSource = null;
-
-/**
- * Number of characters that must be entered before querying for results. A negative value
- * effectively turns off the widget. A value of 0 allows queries of null or empty string
- * values.
- *
- * @property minQueryLength
- * @type Number
- * @default 1
- */
-YAHOO.widget.AutoComplete.prototype.minQueryLength = 1;
-
-/**
- * Maximum number of results to display in results container.
- *
- * @property maxResultsDisplayed
- * @type Number
- * @default 10
- */
-YAHOO.widget.AutoComplete.prototype.maxResultsDisplayed = 10;
-
-/**
- * Number of seconds to delay before submitting a query request. If a query
- * request is received before a previous one has completed its delay, the
- * previous request is cancelled and the new request is set to the delay.
- * Implementers should take care when setting this value very low (i.e., less
- * than 0.2) with low latency DataSources and the typeAhead feature enabled, as
- * fast typers may see unexpected behavior.
- *
- * @property queryDelay
- * @type Number
- * @default 0.2
- */
-YAHOO.widget.AutoComplete.prototype.queryDelay = 0.2;
-
-/**
- * Class name of a highlighted item within results container.
- *
- * @property highlightClassName
- * @type String
- * @default "yui-ac-highlight"
- */
-YAHOO.widget.AutoComplete.prototype.highlightClassName = "yui-ac-highlight";
-
-/**
- * Class name of a pre-highlighted item within results container.
- *
- * @property prehighlightClassName
- * @type String
- */
-YAHOO.widget.AutoComplete.prototype.prehighlightClassName = null;
-
-/**
- * Query delimiter. A single character separator for multiple delimited
- * selections. Multiple delimiter characteres may be defined as an array of
- * strings. A null value or empty string indicates that query results cannot
- * be delimited. This feature is not recommended if you need forceSelection to
- * be true.
- *
- * @property delimChar
- * @type String | String[]
- */
-YAHOO.widget.AutoComplete.prototype.delimChar = null;
-
-/**
- * Whether or not the first item in results container should be automatically highlighted
- * on expand.
- *
- * @property autoHighlight
- * @type Boolean
- * @default true
- */
-YAHOO.widget.AutoComplete.prototype.autoHighlight = true;
-
-/**
- * Whether or not the input field should be automatically updated
- * with the first query result as the user types, auto-selecting the substring
- * that the user has not typed.
- *
- * @property typeAhead
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.typeAhead = false;
-
-/**
- * Whether or not to animate the expansion/collapse of the results container in the
- * horizontal direction.
- *
- * @property animHoriz
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.animHoriz = false;
-
-/**
- * Whether or not to animate the expansion/collapse of the results container in the
- * vertical direction.
- *
- * @property animVert
- * @type Boolean
- * @default true
- */
-YAHOO.widget.AutoComplete.prototype.animVert = true;
-
-/**
- * Speed of container expand/collapse animation, in seconds..
- *
- * @property animSpeed
- * @type Number
- * @default 0.3
- */
-YAHOO.widget.AutoComplete.prototype.animSpeed = 0.3;
-
-/**
- * Whether or not to force the user's selection to match one of the query
- * results. Enabling this feature essentially transforms the input field into a
- * <select> field. This feature is not recommended with delimiter character(s)
- * defined.
- *
- * @property forceSelection
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.forceSelection = false;
-
-/**
- * Whether or not to allow browsers to cache user-typed input in the input
- * field. Disabling this feature will prevent the widget from setting the
- * autocomplete="off" on the input field. When autocomplete="off"
- * and users click the back button after form submission, user-typed input can
- * be prefilled by the browser from its cache. This caching of user input may
- * not be desired for sensitive data, such as credit card numbers, in which
- * case, implementers should consider setting allowBrowserAutocomplete to false.
- *
- * @property allowBrowserAutocomplete
- * @type Boolean
- * @default true
- */
-YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete = true;
-
-/**
- * Whether or not the results container should always be displayed.
- * Enabling this feature displays the container when the widget is instantiated
- * and prevents the toggling of the container to a collapsed state.
- *
- * @property alwaysShowContainer
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.alwaysShowContainer = false;
-
-/**
- * Whether or not to use an iFrame to layer over Windows form elements in
- * IE. Set to true only when the results container will be on top of a
- * <select> field in IE and thus exposed to the IE z-index bug (i.e.,
- * 5.5 < IE < 7).
- *
- * @property useIFrame
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.useIFrame = false;
-
-/**
- * Whether or not the results container should have a shadow.
- *
- * @property useShadow
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.useShadow = false;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
- /**
- * Public accessor to the unique name of the AutoComplete instance.
- *
- * @method toString
- * @return {String} Unique name of the AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.toString = function() {
- return "AutoComplete " + this._sName;
-};
-
- /**
- * Returns true if container is in an expanded state, false otherwise.
- *
- * @method isContainerOpen
- * @return {Boolean} Returns true if container is in an expanded state, false otherwise.
- */
-YAHOO.widget.AutoComplete.prototype.isContainerOpen = function() {
- return this._bContainerOpen;
-};
-
-/**
- * Public accessor to the internal array of DOM <li> elements that
- * display query results within the results container.
- *
- * @method getListItems
- * @return {HTMLElement[]} Array of <li> elements within the results container.
- */
-YAHOO.widget.AutoComplete.prototype.getListItems = function() {
- return this._aListItems;
-};
-
-/**
- * Public accessor to the data held in an <li> element of the
- * results container.
- *
- * @method getListItemData
- * @return {Object | Object[]} Object or array of result data or null
- */
-YAHOO.widget.AutoComplete.prototype.getListItemData = function(oListItem) {
- if(oListItem._oResultData) {
- return oListItem._oResultData;
- }
- else {
- return false;
- }
-};
-
-/**
- * Sets HTML markup for the results container header. This markup will be
- * inserted within a <div> tag with a class of "yui-ac-hd".
- *
- * @method setHeader
- * @param sHeader {String} HTML markup for results container header.
- */
-YAHOO.widget.AutoComplete.prototype.setHeader = function(sHeader) {
- if(this._elHeader) {
- var elHeader = this._elHeader;
- if(sHeader) {
- elHeader.innerHTML = sHeader;
- elHeader.style.display = "block";
- }
- else {
- elHeader.innerHTML = "";
- elHeader.style.display = "none";
- }
- }
-};
-
-/**
- * Sets HTML markup for the results container footer. This markup will be
- * inserted within a <div> tag with a class of "yui-ac-ft".
- *
- * @method setFooter
- * @param sFooter {String} HTML markup for results container footer.
- */
-YAHOO.widget.AutoComplete.prototype.setFooter = function(sFooter) {
- if(this._elFooter) {
- var elFooter = this._elFooter;
- if(sFooter) {
- elFooter.innerHTML = sFooter;
- elFooter.style.display = "block";
- }
- else {
- elFooter.innerHTML = "";
- elFooter.style.display = "none";
- }
- }
-};
-
-/**
- * Sets HTML markup for the results container body. This markup will be
- * inserted within a <div> tag with a class of "yui-ac-bd".
- *
- * @method setBody
- * @param sBody {String} HTML markup for results container body.
- */
-YAHOO.widget.AutoComplete.prototype.setBody = function(sBody) {
- 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;
- }
-};
-
-/**
- * Overridable method that converts a result item object into HTML markup
- * for display. Return data values are accessible via the oResultItem object,
- * and the key return value will always be oResultItem[0]. Markup will be
- * displayed within <li> element tags in the container.
- *
- * @method formatResult
- * @param oResultItem {Object} Result item representing one query result. Data is held in an array.
- * @param sQuery {String} The current query string.
- * @return {String} HTML markup of formatted result data.
- */
-YAHOO.widget.AutoComplete.prototype.formatResult = function(oResultItem, sQuery) {
- var sResult = oResultItem[0];
- if(sResult) {
- return sResult;
- }
- else {
- return "";
- }
-};
-
-/**
- * Overridable method called before container expands allows implementers to access data
- * and DOM elements.
- *
- * @method doBeforeExpandContainer
- * @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(elTextbox, elContainer, sQuery, aResults) {
- return true;
-};
-
-/**
- * Makes query request to the DataSource.
- *
- * @method sendQuery
- * @param sQuery {String} Query string.
- */
-YAHOO.widget.AutoComplete.prototype.sendQuery = function(sQuery) {
- this._sendQuery(sQuery);
-};
-
-/**
- * Overridable method gives implementers access to the query before it gets sent.
- *
- * @method doBeforeSendQuery
- * @param sQuery {String} Query string.
- * @return {String} Query string.
- */
-YAHOO.widget.AutoComplete.prototype.doBeforeSendQuery = function(sQuery) {
- return sQuery;
-};
-
-/**
- * Nulls out the entire AutoComplete instance and related objects, removes attached
- * event listeners, and clears out DOM elements inside the container. After
- * calling this method, the instance reference should be expliclitly nulled by
- * implementer, as in myDataTable = null. Use with caution!
- *
- * @method destroy
- */
-YAHOO.widget.AutoComplete.prototype.destroy = function() {
- var instanceName = this.toString();
- var elInput = this._elTextbox;
- var elContainer = this._elContainer;
-
- // Unhook custom events
- 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);
- YAHOO.util.Event.purgeElement(elContainer, true);
-
- // Remove DOM elements
- elContainer.innerHTML = "";
-
- // Null out objects
- for(var key in this) {
- if(YAHOO.lang.hasOwnProperty(this, key)) {
- this[key] = null;
- }
- }
-
- YAHOO.log("AutoComplete instance destroyed: " + instanceName);
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public events
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Fired when the input field receives focus.
- *
- * @event textboxFocusEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.textboxFocusEvent = null;
-
-/**
- * Fired when the input field receives key input.
- *
- * @event textboxKeyEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param nKeycode {Number} The keycode number.
- */
-YAHOO.widget.AutoComplete.prototype.textboxKeyEvent = null;
-
-/**
- * Fired when the AutoComplete instance makes a query to the DataSource.
- *
- * @event dataRequestEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param sQuery {String} The query string.
- */
-YAHOO.widget.AutoComplete.prototype.dataRequestEvent = null;
-
-/**
- * Fired when the AutoComplete instance receives query results from the data
- * source.
- *
- * @event dataReturnEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param sQuery {String} The query string.
- * @param aResults {Object[]} Results array.
- */
-YAHOO.widget.AutoComplete.prototype.dataReturnEvent = null;
-
-/**
- * Fired when the AutoComplete instance does not receive query results from the
- * DataSource due to an error.
- *
- * @event dataErrorEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param sQuery {String} The query string.
- */
-YAHOO.widget.AutoComplete.prototype.dataErrorEvent = null;
-
-/**
- * Fired when the results container is expanded.
- *
- * @event containerExpandEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.containerExpandEvent = null;
-
-/**
- * Fired when the input field has been prefilled by the type-ahead
- * feature.
- *
- * @event typeAheadEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param sQuery {String} The query string.
- * @param sPrefill {String} The prefill string.
- */
-YAHOO.widget.AutoComplete.prototype.typeAheadEvent = null;
-
-/**
- * Fired when result item has been moused over.
- *
- * @event itemMouseOverEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param elItem {HTMLElement} The <li> element item moused to.
- */
-YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent = null;
-
-/**
- * Fired when result item has been moused out.
- *
- * @event itemMouseOutEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param elItem {HTMLElement} The <li> element item moused from.
- */
-YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent = null;
-
-/**
- * Fired when result item has been arrowed to.
- *
- * @event itemArrowToEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param elItem {HTMLElement} The <li> element item arrowed to.
- */
-YAHOO.widget.AutoComplete.prototype.itemArrowToEvent = null;
-
-/**
- * Fired when result item has been arrowed away from.
- *
- * @event itemArrowFromEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param elItem {HTMLElement} The <li> element item arrowed from.
- */
-YAHOO.widget.AutoComplete.prototype.itemArrowFromEvent = null;
-
-/**
- * Fired when an item is selected via mouse click, ENTER key, or TAB key.
- *
- * @event itemSelectEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param elItem {HTMLElement} The selected <li> element item.
- * @param oData {Object} The data returned for the item, either as an object,
- * or mapped from the schema into an array.
- */
-YAHOO.widget.AutoComplete.prototype.itemSelectEvent = null;
-
-/**
- * Fired when a user selection does not match any of the displayed result items.
- *
- * @event unmatchedItemSelectEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent = null;
-
-/**
- * Fired if forceSelection is enabled and the user's input has been cleared
- * because it did not match one of the returned query results.
- *
- * @event selectionEnforceEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent = null;
-
-/**
- * Fired when the results container is collapsed.
- *
- * @event containerCollapseEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.containerCollapseEvent = null;
-
-/**
- * Fired when the input field loses focus.
- *
- * @event textboxBlurEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.textboxBlurEvent = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Internal class variable to index multiple AutoComplete instances.
- *
- * @property _nIndex
- * @type Number
- * @default 0
- * @private
- */
-YAHOO.widget.AutoComplete._nIndex = 0;
-
-/**
- * Name of AutoComplete instance.
- *
- * @property _sName
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._sName = null;
-
-/**
- * Text input field DOM element.
- *
- * @property _elTextbox
- * @type HTMLElement
- * @private
- */
-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
- * but the user has already moved on, do not proceed with auto complete behavior.
- *
- * @property _bFocused
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._bFocused = true;
-
-/**
- * Animation instance for container expand/collapse.
- *
- * @property _oAnim
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._oAnim = null;
-
-/**
- * Whether or not the results container is currently open.
- *
- * @property _bContainerOpen
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._bContainerOpen = false;
-
-/**
- * Whether or not the mouse is currently over the results
- * container. This is necessary in order to prevent clicks on container items
- * from being text input field blur events.
- *
- * @property _bOverContainer
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._bOverContainer = false;
-
-/**
- * Array of <li> elements references that contain query results within the
- * results container.
- *
- * @property _aListItems
- * @type HTMLElement[]
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._aListItems = null;
-
-/**
- * Number of <li> elements currently displayed in results container.
- *
- * @property _nDisplayedItems
- * @type Number
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._nDisplayedItems = 0;
-
-/**
- * Internal count of <li> elements displayed and hidden in results container.
- *
- * @property _maxResultsDisplayed
- * @type Number
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed = 0;
-
-/**
- * Current query string
- *
- * @property _sCurQuery
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._sCurQuery = null;
-
-/**
- * Past queries this session (for saving delimited queries).
- *
- * @property _sSavedQuery
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._sSavedQuery = null;
-
-/**
- * Pointer to the currently highlighted <li> element in the container.
- *
- * @property _oCurItem
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._oCurItem = null;
-
-/**
- * Whether or not an item has been selected since the container was populated
- * with results. Reset to false by _populateList, and set to true when item is
- * selected.
- *
- * @property _bItemSelected
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._bItemSelected = false;
-
-/**
- * Key code of the last key pressed in textbox.
- *
- * @property _nKeyCode
- * @type Number
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._nKeyCode = null;
-
-/**
- * Delay timeout ID.
- *
- * @property _nDelayID
- * @type Number
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._nDelayID = -1;
-
-/**
- * Src to iFrame used when useIFrame = true. Supports implementations over SSL
- * as well.
- *
- * @property _iFrameSrc
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._iFrameSrc = "javascript:false;";
-
-/**
- * For users typing via certain IMEs, queries must be triggered by intervals,
- * since key events yet supported across all browsers for all IMEs.
- *
- * @property _queryInterval
- * @type Object
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._queryInterval = null;
-
-/**
- * Internal tracker to last known textbox value, used to determine whether or not
- * to trigger a query via interval for certain IME users.
- *
- * @event _sLastTextboxValue
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._sLastTextboxValue = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Updates and validates latest public config properties.
- *
- * @method __initProps
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._initProps = function() {
- // Correct any invalid values
- 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) && (delimChar.length > 0)) {
- 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._elContent, {}, this.animSpeed);
- }
- else {
- this._oAnim.duration = this.animSpeed;
- }
- }
- if(this.forceSelection && delimChar) {
- YAHOO.log("The forceSelection feature has been enabled with delimChar defined.","warn", this.toString());
- }
-};
-
-/**
- * Initializes the results container helpers if they are enabled and do
- * not exist
- *
- * @method _initContainerHelpers
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._initContainerHelpers = function() {
- 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);
- }
-};
-
-/**
- * Initializes the results container once at object creation
- *
- * @method _initContainer
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._initContainer = function() {
- YAHOO.util.Dom.addClass(this._elContainer, "yui-ac-container");
-
- 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());
- }
-};
-
-/**
- * Clears out contents of container body and creates up to
- * YAHOO.widget.AutoComplete#maxResultsDisplayed <li> elements in an
- * <ul> element.
- *
- * @method _initList
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._initList = function() {
- this._aListItems = [];
- while(this._elBody.hasChildNodes()) {
- var oldListItems = this.getListItems();
- if(oldListItems) {
- for(var oldi = oldListItems.length-1; oldi >= 0; oldi--) {
- oldListItems[oldi] = null;
- }
- }
- this._elBody.innerHTML = "";
- }
-
- var oList = document.createElement("ul");
- oList = this._elBody.appendChild(oList);
- for(var i=0; i
- *
- *
- *
- * @property asyncMode
- * @type String
- * @default "allowAll"
- */
-YAHOO.widget.DS_ScriptNode.prototype.asyncMode = "allowAll";
-
-/**
- * Callback string parameter name sent to scriptURI. For instance, requests will be
- * sent to <scriptURI>?<scriptCallbackParam>=callbackFunction
- *
- * @property scriptCallbackParam
- * @type String
- * @default "callback"
- */
-YAHOO.widget.DS_ScriptNode.prototype.scriptCallbackParam = "callback";
-
-/**
- * Global array of callback functions, one for each request sent.
- *
- * @property callbacks
- * @type Function[]
- * @static
- */
-YAHOO.widget.DS_ScriptNode.callbacks = [];
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Unique ID to track requests.
- *
- * @property _nId
- * @type Number
- * @private
- * @static
- */
-YAHOO.widget.DS_ScriptNode._nId = 0;
-
-/**
- * Counter for pending requests. When this is 0, it is safe to purge callbacks
- * array.
- *
- * @property _nPending
- * @type Number
- * @private
- * @static
- */
-YAHOO.widget.DS_ScriptNode._nPending = 0;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Queries the live data source. Results are passed back to a callback function.
- *
- * @method doQuery
- * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
- * @param sQuery {String} Query string.
- * @param oParent {Object} The object instance that has requested data.
- */
-YAHOO.widget.DS_ScriptNode.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
- var oSelf = this;
-
- // If there are no global pending requests, it is safe to purge global callback stack and global counter
- if(YAHOO.widget.DS_ScriptNode._nPending === 0) {
- YAHOO.widget.DS_ScriptNode.callbacks = [];
- YAHOO.widget.DS_ScriptNode._nId = 0;
- }
-
- // ID for this request
- var id = YAHOO.widget.DS_ScriptNode._nId;
- YAHOO.widget.DS_ScriptNode._nId++;
-
- // Dynamically add handler function with a closure to the callback stack
- YAHOO.widget.DS_ScriptNode.callbacks[id] = function(oResponse) {
- if((oSelf.asyncMode !== "ignoreStaleResponses")||
- (id === YAHOO.widget.DS_ScriptNode.callbacks.length-1)) { // Must ignore stale responses
- oSelf.handleResponse(oResponse, oCallbackFn, sQuery, oParent);
- }
- else {
- 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--;
-};
-
-
-/****************************************************************************/
-/****************************************************************************/
-/****************************************************************************/
-
-/**
- * Implementation of YAHOO.widget.DataSource using a native Javascript function as
- * its live data source.
- *
- * @class DS_JSFunction
- * @constructor
- * @extends YAHOO.widget.DataSource
- * @param oFunction {HTMLFunction} In-memory Javascript function that returns query results as an array of objects.
- * @param oConfigs {Object} (optional) Object literal of config params.
- */
-YAHOO.widget.DS_JSFunction = function(oFunction, 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.isFunction(oFunction)) {
- YAHOO.log("Could not instantiate JSFunction DataSource due to invalid arguments", "error", this.toString());
- return;
- }
- else {
- this.dataFunction = oFunction;
- this._init();
- YAHOO.log("JS Function DataSource initialized","info",this.toString());
- }
-};
-
-YAHOO.widget.DS_JSFunction.prototype = new YAHOO.widget.DataSource();
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * In-memory Javascript function that returns query results.
- *
- * @property dataFunction
- * @type HTMLFunction
- */
-YAHOO.widget.DS_JSFunction.prototype.dataFunction = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Queries the live data source defined by function for results. 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_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);
- YAHOO.log(YAHOO.widget.DataSource.ERROR_DATANULL, "error", this.toString());
- return;
- }
-
- 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);
- return;
-};
-
-
-/****************************************************************************/
-/****************************************************************************/
-/****************************************************************************/
-
-/**
- * Implementation of YAHOO.widget.DataSource using a native Javascript array as
- * its live data source.
- *
- * @class DS_JSArray
- * @constructor
- * @extends YAHOO.widget.DataSource
- * @param aData {String[]} In-memory Javascript array of simple string data.
- * @param oConfigs {Object} (optional) Object literal of config params.
- */
-YAHOO.widget.DS_JSArray = function(aData, 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(aData)) {
- YAHOO.log("Could not instantiate JSArray DataSource due to invalid arguments", "error", this.toString());
- return;
- }
- else {
- this.data = aData;
- this._init();
- YAHOO.log("JS Array DataSource initialized","info",this.toString());
- }
-};
-
-YAHOO.widget.DS_JSArray.prototype = new YAHOO.widget.DataSource();
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * In-memory Javascript array of strings.
- *
- * @property data
- * @type Array
- */
-YAHOO.widget.DS_JSArray.prototype.data = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Queries the live data source defined by data for results. 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_JSArray.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
- var i;
- var aData = this.data; // the array
- var aResults = []; // container for results
- var bMatchFound = false;
- var bMatchContains = this.queryMatchContains;
- if(sQuery) {
- if(!this.queryMatchCase) {
- sQuery = sQuery.toLowerCase();
- }
-
- // Loop through each element of the array...
- // which can be a string or an array of strings
- 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);
-
- // A STARTSWITH match is when the query is found at the beginning of the key string...
- if((!bMatchContains && (sKeyIndex === 0)) ||
- // A CONTAINS match is when the query is found anywhere within the key string...
- (bMatchContains && (sKeyIndex > -1))) {
- // Stash a match into aResults[].
- 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);
- YAHOO.log("Results returned for query \"" + sQuery +
- "\": " + YAHOO.lang.dump(aResults), "info", this.toString());
- oCallbackFn(sQuery, aResults, oParent);
-};
-
-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
deleted file mode 100755
index 77eacceb94..0000000000
--- a/lib/yui/autocomplete/autocomplete-min.js
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
-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
-*/
-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
- *
- *
- * @class AutoComplete
- * @constructor
- * @param elInput {HTMLElement} DOM element reference of an input field.
- * @param elInput {String} String ID of an input field.
- * @param elContainer {HTMLElement} DOM element reference of an existing DIV.
- * @param elContainer {String} String ID of an existing DIV.
- * @param oDataSource {YAHOO.widget.DataSource} DataSource instance.
- * @param oConfigs {Object} (optional) Object literal of configuration params.
- */
-YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) {
- if(elInput && elContainer && oDataSource) {
- // Validate DataSource
- if(oDataSource instanceof YAHOO.widget.DataSource) {
- this.dataSource = oDataSource;
- }
- else {
- return;
- }
-
- // Validate input element
- if(YAHOO.util.Dom.inDocument(elInput)) {
- if(YAHOO.lang.isString(elInput)) {
- this._sName = "instance" + YAHOO.widget.AutoComplete._nIndex + " " + elInput;
- this._elTextbox = document.getElementById(elInput);
- }
- else {
- this._sName = (elInput.id) ?
- "instance" + YAHOO.widget.AutoComplete._nIndex + " " + elInput.id:
- "instance" + YAHOO.widget.AutoComplete._nIndex;
- this._elTextbox = elInput;
- }
- YAHOO.util.Dom.addClass(this._elTextbox, "yui-ac-input");
- }
- else {
- return;
- }
-
- // Validate container element
- if(YAHOO.util.Dom.inDocument(elContainer)) {
- if(YAHOO.lang.isString(elContainer)) {
- this._elContainer = document.getElementById(elContainer);
- }
- else {
- this._elContainer = elContainer;
- }
- if(this._elContainer.style.display == "none") {
- }
-
- // For skinning
- var elParent = this._elContainer.parentNode;
- var elTag = elParent.tagName.toLowerCase();
- if(elTag == "div") {
- YAHOO.util.Dom.addClass(elParent, "yui-ac");
- }
- else {
- }
- }
- else {
- return;
- }
-
- // Set any config params passed in to override defaults
- if(oConfigs && (oConfigs.constructor == Object)) {
- for(var sConfig in oConfigs) {
- if(sConfig) {
- this[sConfig] = oConfigs[sConfig];
- }
- }
- }
-
- // Initialization sequence
- this._initContainer();
- this._initProps();
- this._initList();
- this._initContainerHelpers();
-
- // Set up events
- var oSelf = this;
- var elTextbox = this._elTextbox;
- // Events are actually for the content module within the container
- var elContent = this._elContent;
-
- // Dom events
- 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);
- 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);
-
- // Finish up
- elTextbox.setAttribute("autocomplete","off");
- YAHOO.widget.AutoComplete._nIndex++;
- }
- // Required arguments were not found
- else {
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * The DataSource object that encapsulates the data used for auto completion.
- * This object should be an inherited object from YAHOO.widget.DataSource.
- *
- * @property dataSource
- * @type YAHOO.widget.DataSource
- */
-YAHOO.widget.AutoComplete.prototype.dataSource = null;
-
-/**
- * Number of characters that must be entered before querying for results. A negative value
- * effectively turns off the widget. A value of 0 allows queries of null or empty string
- * values.
- *
- * @property minQueryLength
- * @type Number
- * @default 1
- */
-YAHOO.widget.AutoComplete.prototype.minQueryLength = 1;
-
-/**
- * Maximum number of results to display in results container.
- *
- * @property maxResultsDisplayed
- * @type Number
- * @default 10
- */
-YAHOO.widget.AutoComplete.prototype.maxResultsDisplayed = 10;
-
-/**
- * Number of seconds to delay before submitting a query request. If a query
- * request is received before a previous one has completed its delay, the
- * previous request is cancelled and the new request is set to the delay.
- * Implementers should take care when setting this value very low (i.e., less
- * than 0.2) with low latency DataSources and the typeAhead feature enabled, as
- * fast typers may see unexpected behavior.
- *
- * @property queryDelay
- * @type Number
- * @default 0.2
- */
-YAHOO.widget.AutoComplete.prototype.queryDelay = 0.2;
-
-/**
- * Class name of a highlighted item within results container.
- *
- * @property highlightClassName
- * @type String
- * @default "yui-ac-highlight"
- */
-YAHOO.widget.AutoComplete.prototype.highlightClassName = "yui-ac-highlight";
-
-/**
- * Class name of a pre-highlighted item within results container.
- *
- * @property prehighlightClassName
- * @type String
- */
-YAHOO.widget.AutoComplete.prototype.prehighlightClassName = null;
-
-/**
- * Query delimiter. A single character separator for multiple delimited
- * selections. Multiple delimiter characteres may be defined as an array of
- * strings. A null value or empty string indicates that query results cannot
- * be delimited. This feature is not recommended if you need forceSelection to
- * be true.
- *
- * @property delimChar
- * @type String | String[]
- */
-YAHOO.widget.AutoComplete.prototype.delimChar = null;
-
-/**
- * Whether or not the first item in results container should be automatically highlighted
- * on expand.
- *
- * @property autoHighlight
- * @type Boolean
- * @default true
- */
-YAHOO.widget.AutoComplete.prototype.autoHighlight = true;
-
-/**
- * Whether or not the input field should be automatically updated
- * with the first query result as the user types, auto-selecting the substring
- * that the user has not typed.
- *
- * @property typeAhead
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.typeAhead = false;
-
-/**
- * Whether or not to animate the expansion/collapse of the results container in the
- * horizontal direction.
- *
- * @property animHoriz
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.animHoriz = false;
-
-/**
- * Whether or not to animate the expansion/collapse of the results container in the
- * vertical direction.
- *
- * @property animVert
- * @type Boolean
- * @default true
- */
-YAHOO.widget.AutoComplete.prototype.animVert = true;
-
-/**
- * Speed of container expand/collapse animation, in seconds..
- *
- * @property animSpeed
- * @type Number
- * @default 0.3
- */
-YAHOO.widget.AutoComplete.prototype.animSpeed = 0.3;
-
-/**
- * Whether or not to force the user's selection to match one of the query
- * results. Enabling this feature essentially transforms the input field into a
- * <select> field. This feature is not recommended with delimiter character(s)
- * defined.
- *
- * @property forceSelection
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.forceSelection = false;
-
-/**
- * Whether or not to allow browsers to cache user-typed input in the input
- * field. Disabling this feature will prevent the widget from setting the
- * autocomplete="off" on the input field. When autocomplete="off"
- * and users click the back button after form submission, user-typed input can
- * be prefilled by the browser from its cache. This caching of user input may
- * not be desired for sensitive data, such as credit card numbers, in which
- * case, implementers should consider setting allowBrowserAutocomplete to false.
- *
- * @property allowBrowserAutocomplete
- * @type Boolean
- * @default true
- */
-YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete = true;
-
-/**
- * Whether or not the results container should always be displayed.
- * Enabling this feature displays the container when the widget is instantiated
- * and prevents the toggling of the container to a collapsed state.
- *
- * @property alwaysShowContainer
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.alwaysShowContainer = false;
-
-/**
- * Whether or not to use an iFrame to layer over Windows form elements in
- * IE. Set to true only when the results container will be on top of a
- * <select> field in IE and thus exposed to the IE z-index bug (i.e.,
- * 5.5 < IE < 7).
- *
- * @property useIFrame
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.useIFrame = false;
-
-/**
- * Whether or not the results container should have a shadow.
- *
- * @property useShadow
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.useShadow = false;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
- /**
- * Public accessor to the unique name of the AutoComplete instance.
- *
- * @method toString
- * @return {String} Unique name of the AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.toString = function() {
- return "AutoComplete " + this._sName;
-};
-
- /**
- * Returns true if container is in an expanded state, false otherwise.
- *
- * @method isContainerOpen
- * @return {Boolean} Returns true if container is in an expanded state, false otherwise.
- */
-YAHOO.widget.AutoComplete.prototype.isContainerOpen = function() {
- return this._bContainerOpen;
-};
-
-/**
- * Public accessor to the internal array of DOM <li> elements that
- * display query results within the results container.
- *
- * @method getListItems
- * @return {HTMLElement[]} Array of <li> elements within the results container.
- */
-YAHOO.widget.AutoComplete.prototype.getListItems = function() {
- return this._aListItems;
-};
-
-/**
- * Public accessor to the data held in an <li> element of the
- * results container.
- *
- * @method getListItemData
- * @return {Object | Object[]} Object or array of result data or null
- */
-YAHOO.widget.AutoComplete.prototype.getListItemData = function(oListItem) {
- if(oListItem._oResultData) {
- return oListItem._oResultData;
- }
- else {
- return false;
- }
-};
-
-/**
- * Sets HTML markup for the results container header. This markup will be
- * inserted within a <div> tag with a class of "yui-ac-hd".
- *
- * @method setHeader
- * @param sHeader {String} HTML markup for results container header.
- */
-YAHOO.widget.AutoComplete.prototype.setHeader = function(sHeader) {
- if(this._elHeader) {
- var elHeader = this._elHeader;
- if(sHeader) {
- elHeader.innerHTML = sHeader;
- elHeader.style.display = "block";
- }
- else {
- elHeader.innerHTML = "";
- elHeader.style.display = "none";
- }
- }
-};
-
-/**
- * Sets HTML markup for the results container footer. This markup will be
- * inserted within a <div> tag with a class of "yui-ac-ft".
- *
- * @method setFooter
- * @param sFooter {String} HTML markup for results container footer.
- */
-YAHOO.widget.AutoComplete.prototype.setFooter = function(sFooter) {
- if(this._elFooter) {
- var elFooter = this._elFooter;
- if(sFooter) {
- elFooter.innerHTML = sFooter;
- elFooter.style.display = "block";
- }
- else {
- elFooter.innerHTML = "";
- elFooter.style.display = "none";
- }
- }
-};
-
-/**
- * Sets HTML markup for the results container body. This markup will be
- * inserted within a <div> tag with a class of "yui-ac-bd".
- *
- * @method setBody
- * @param sBody {String} HTML markup for results container body.
- */
-YAHOO.widget.AutoComplete.prototype.setBody = function(sBody) {
- 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;
- }
-};
-
-/**
- * Overridable method that converts a result item object into HTML markup
- * for display. Return data values are accessible via the oResultItem object,
- * and the key return value will always be oResultItem[0]. Markup will be
- * displayed within <li> element tags in the container.
- *
- * @method formatResult
- * @param oResultItem {Object} Result item representing one query result. Data is held in an array.
- * @param sQuery {String} The current query string.
- * @return {String} HTML markup of formatted result data.
- */
-YAHOO.widget.AutoComplete.prototype.formatResult = function(oResultItem, sQuery) {
- var sResult = oResultItem[0];
- if(sResult) {
- return sResult;
- }
- else {
- return "";
- }
-};
-
-/**
- * Overridable method called before container expands allows implementers to access data
- * and DOM elements.
- *
- * @method doBeforeExpandContainer
- * @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(elTextbox, elContainer, sQuery, aResults) {
- return true;
-};
-
-/**
- * Makes query request to the DataSource.
- *
- * @method sendQuery
- * @param sQuery {String} Query string.
- */
-YAHOO.widget.AutoComplete.prototype.sendQuery = function(sQuery) {
- this._sendQuery(sQuery);
-};
-
-/**
- * Overridable method gives implementers access to the query before it gets sent.
- *
- * @method doBeforeSendQuery
- * @param sQuery {String} Query string.
- * @return {String} Query string.
- */
-YAHOO.widget.AutoComplete.prototype.doBeforeSendQuery = function(sQuery) {
- return sQuery;
-};
-
-/**
- * Nulls out the entire AutoComplete instance and related objects, removes attached
- * event listeners, and clears out DOM elements inside the container. After
- * calling this method, the instance reference should be expliclitly nulled by
- * implementer, as in myDataTable = null. Use with caution!
- *
- * @method destroy
- */
-YAHOO.widget.AutoComplete.prototype.destroy = function() {
- var instanceName = this.toString();
- var elInput = this._elTextbox;
- var elContainer = this._elContainer;
-
- // Unhook custom events
- 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);
- YAHOO.util.Event.purgeElement(elContainer, true);
-
- // Remove DOM elements
- elContainer.innerHTML = "";
-
- // Null out objects
- for(var key in this) {
- if(YAHOO.lang.hasOwnProperty(this, key)) {
- this[key] = null;
- }
- }
-
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public events
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Fired when the input field receives focus.
- *
- * @event textboxFocusEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.textboxFocusEvent = null;
-
-/**
- * Fired when the input field receives key input.
- *
- * @event textboxKeyEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param nKeycode {Number} The keycode number.
- */
-YAHOO.widget.AutoComplete.prototype.textboxKeyEvent = null;
-
-/**
- * Fired when the AutoComplete instance makes a query to the DataSource.
- *
- * @event dataRequestEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param sQuery {String} The query string.
- */
-YAHOO.widget.AutoComplete.prototype.dataRequestEvent = null;
-
-/**
- * Fired when the AutoComplete instance receives query results from the data
- * source.
- *
- * @event dataReturnEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param sQuery {String} The query string.
- * @param aResults {Object[]} Results array.
- */
-YAHOO.widget.AutoComplete.prototype.dataReturnEvent = null;
-
-/**
- * Fired when the AutoComplete instance does not receive query results from the
- * DataSource due to an error.
- *
- * @event dataErrorEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param sQuery {String} The query string.
- */
-YAHOO.widget.AutoComplete.prototype.dataErrorEvent = null;
-
-/**
- * Fired when the results container is expanded.
- *
- * @event containerExpandEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.containerExpandEvent = null;
-
-/**
- * Fired when the input field has been prefilled by the type-ahead
- * feature.
- *
- * @event typeAheadEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param sQuery {String} The query string.
- * @param sPrefill {String} The prefill string.
- */
-YAHOO.widget.AutoComplete.prototype.typeAheadEvent = null;
-
-/**
- * Fired when result item has been moused over.
- *
- * @event itemMouseOverEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param elItem {HTMLElement} The <li> element item moused to.
- */
-YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent = null;
-
-/**
- * Fired when result item has been moused out.
- *
- * @event itemMouseOutEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param elItem {HTMLElement} The <li> element item moused from.
- */
-YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent = null;
-
-/**
- * Fired when result item has been arrowed to.
- *
- * @event itemArrowToEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param elItem {HTMLElement} The <li> element item arrowed to.
- */
-YAHOO.widget.AutoComplete.prototype.itemArrowToEvent = null;
-
-/**
- * Fired when result item has been arrowed away from.
- *
- * @event itemArrowFromEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param elItem {HTMLElement} The <li> element item arrowed from.
- */
-YAHOO.widget.AutoComplete.prototype.itemArrowFromEvent = null;
-
-/**
- * Fired when an item is selected via mouse click, ENTER key, or TAB key.
- *
- * @event itemSelectEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- * @param elItem {HTMLElement} The selected <li> element item.
- * @param oData {Object} The data returned for the item, either as an object,
- * or mapped from the schema into an array.
- */
-YAHOO.widget.AutoComplete.prototype.itemSelectEvent = null;
-
-/**
- * Fired when a user selection does not match any of the displayed result items.
- *
- * @event unmatchedItemSelectEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent = null;
-
-/**
- * Fired if forceSelection is enabled and the user's input has been cleared
- * because it did not match one of the returned query results.
- *
- * @event selectionEnforceEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent = null;
-
-/**
- * Fired when the results container is collapsed.
- *
- * @event containerCollapseEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.containerCollapseEvent = null;
-
-/**
- * Fired when the input field loses focus.
- *
- * @event textboxBlurEvent
- * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.textboxBlurEvent = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Internal class variable to index multiple AutoComplete instances.
- *
- * @property _nIndex
- * @type Number
- * @default 0
- * @private
- */
-YAHOO.widget.AutoComplete._nIndex = 0;
-
-/**
- * Name of AutoComplete instance.
- *
- * @property _sName
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._sName = null;
-
-/**
- * Text input field DOM element.
- *
- * @property _elTextbox
- * @type HTMLElement
- * @private
- */
-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
- * but the user has already moved on, do not proceed with auto complete behavior.
- *
- * @property _bFocused
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._bFocused = true;
-
-/**
- * Animation instance for container expand/collapse.
- *
- * @property _oAnim
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._oAnim = null;
-
-/**
- * Whether or not the results container is currently open.
- *
- * @property _bContainerOpen
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._bContainerOpen = false;
-
-/**
- * Whether or not the mouse is currently over the results
- * container. This is necessary in order to prevent clicks on container items
- * from being text input field blur events.
- *
- * @property _bOverContainer
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._bOverContainer = false;
-
-/**
- * Array of <li> elements references that contain query results within the
- * results container.
- *
- * @property _aListItems
- * @type HTMLElement[]
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._aListItems = null;
-
-/**
- * Number of <li> elements currently displayed in results container.
- *
- * @property _nDisplayedItems
- * @type Number
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._nDisplayedItems = 0;
-
-/**
- * Internal count of <li> elements displayed and hidden in results container.
- *
- * @property _maxResultsDisplayed
- * @type Number
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed = 0;
-
-/**
- * Current query string
- *
- * @property _sCurQuery
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._sCurQuery = null;
-
-/**
- * Past queries this session (for saving delimited queries).
- *
- * @property _sSavedQuery
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._sSavedQuery = null;
-
-/**
- * Pointer to the currently highlighted <li> element in the container.
- *
- * @property _oCurItem
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._oCurItem = null;
-
-/**
- * Whether or not an item has been selected since the container was populated
- * with results. Reset to false by _populateList, and set to true when item is
- * selected.
- *
- * @property _bItemSelected
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._bItemSelected = false;
-
-/**
- * Key code of the last key pressed in textbox.
- *
- * @property _nKeyCode
- * @type Number
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._nKeyCode = null;
-
-/**
- * Delay timeout ID.
- *
- * @property _nDelayID
- * @type Number
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._nDelayID = -1;
-
-/**
- * Src to iFrame used when useIFrame = true. Supports implementations over SSL
- * as well.
- *
- * @property _iFrameSrc
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._iFrameSrc = "javascript:false;";
-
-/**
- * For users typing via certain IMEs, queries must be triggered by intervals,
- * since key events yet supported across all browsers for all IMEs.
- *
- * @property _queryInterval
- * @type Object
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._queryInterval = null;
-
-/**
- * Internal tracker to last known textbox value, used to determine whether or not
- * to trigger a query via interval for certain IME users.
- *
- * @event _sLastTextboxValue
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._sLastTextboxValue = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Updates and validates latest public config properties.
- *
- * @method __initProps
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._initProps = function() {
- // Correct any invalid values
- 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) && (delimChar.length > 0)) {
- 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._elContent, {}, this.animSpeed);
- }
- else {
- this._oAnim.duration = this.animSpeed;
- }
- }
- if(this.forceSelection && delimChar) {
- }
-};
-
-/**
- * Initializes the results container helpers if they are enabled and do
- * not exist
- *
- * @method _initContainerHelpers
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._initContainerHelpers = function() {
- 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);
- }
-};
-
-/**
- * Initializes the results container once at object creation
- *
- * @method _initContainer
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._initContainer = function() {
- YAHOO.util.Dom.addClass(this._elContainer, "yui-ac-container");
-
- 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 {
- }
-};
-
-/**
- * Clears out contents of container body and creates up to
- * YAHOO.widget.AutoComplete#maxResultsDisplayed <li> elements in an
- * <ul> element.
- *
- * @method _initList
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._initList = function() {
- this._aListItems = [];
- while(this._elBody.hasChildNodes()) {
- var oldListItems = this.getListItems();
- if(oldListItems) {
- for(var oldi = oldListItems.length-1; oldi >= 0; oldi--) {
- oldListItems[oldi] = null;
- }
- }
- this._elBody.innerHTML = "";
- }
-
- var oList = document.createElement("ul");
- oList = this._elBody.appendChild(oList);
- for(var i=0; i
- *
- *
- *
- * @property asyncMode
- * @type String
- * @default "allowAll"
- */
-YAHOO.widget.DS_ScriptNode.prototype.asyncMode = "allowAll";
-
-/**
- * Callback string parameter name sent to scriptURI. For instance, requests will be
- * sent to <scriptURI>?<scriptCallbackParam>=callbackFunction
- *
- * @property scriptCallbackParam
- * @type String
- * @default "callback"
- */
-YAHOO.widget.DS_ScriptNode.prototype.scriptCallbackParam = "callback";
-
-/**
- * Global array of callback functions, one for each request sent.
- *
- * @property callbacks
- * @type Function[]
- * @static
- */
-YAHOO.widget.DS_ScriptNode.callbacks = [];
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Unique ID to track requests.
- *
- * @property _nId
- * @type Number
- * @private
- * @static
- */
-YAHOO.widget.DS_ScriptNode._nId = 0;
-
-/**
- * Counter for pending requests. When this is 0, it is safe to purge callbacks
- * array.
- *
- * @property _nPending
- * @type Number
- * @private
- * @static
- */
-YAHOO.widget.DS_ScriptNode._nPending = 0;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Queries the live data source. Results are passed back to a callback function.
- *
- * @method doQuery
- * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
- * @param sQuery {String} Query string.
- * @param oParent {Object} The object instance that has requested data.
- */
-YAHOO.widget.DS_ScriptNode.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
- var oSelf = this;
-
- // If there are no global pending requests, it is safe to purge global callback stack and global counter
- if(YAHOO.widget.DS_ScriptNode._nPending === 0) {
- YAHOO.widget.DS_ScriptNode.callbacks = [];
- YAHOO.widget.DS_ScriptNode._nId = 0;
- }
-
- // ID for this request
- var id = YAHOO.widget.DS_ScriptNode._nId;
- YAHOO.widget.DS_ScriptNode._nId++;
-
- // Dynamically add handler function with a closure to the callback stack
- YAHOO.widget.DS_ScriptNode.callbacks[id] = function(oResponse) {
- if((oSelf.asyncMode !== "ignoreStaleResponses")||
- (id === YAHOO.widget.DS_ScriptNode.callbacks.length-1)) { // Must ignore stale responses
- oSelf.handleResponse(oResponse, oCallbackFn, sQuery, oParent);
- }
- else {
- }
-
- delete YAHOO.widget.DS_ScriptNode.callbacks[id];
- };
-
- // We are now creating a request
- YAHOO.widget.DS_ScriptNode._nPending++;
-
- var sUri = this.scriptURI+"&"+ this.scriptQueryParam+"="+sQuery+"&"+
- this.scriptCallbackParam+"=YAHOO.widget.DS_ScriptNode.callbacks["+id+"]";
- this.getUtility.script(sUri,
- {autopurge:true,
- onsuccess:YAHOO.widget.DS_ScriptNode._bumpPendingDown,
- onfail:YAHOO.widget.DS_ScriptNode._bumpPendingDown});
-};
-
-/**
- * Parses JSON response data into an array of result objects and passes it to
- * the callback function.
- *
- * @method handleResponse
- * @param oResponse {Object} The raw response data to parse.
- * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
- * @param sQuery {String} Query string.
- * @param oParent {Object} The object instance that has requested data.
- */
-YAHOO.widget.DS_ScriptNode.prototype.handleResponse = function(oResponse, oCallbackFn, sQuery, oParent) {
- var aSchema = this.schema;
- var aResults = [];
- var bError = false;
-
- var jsonList, jsonObjParsed;
-
- // Parse the JSON response as a string
- try {
- // Grab the object member that contains an array of all reponses...
- // ...eval is necessary here since aSchema[0] is of unknown depth
- jsonList = eval("(oResponse." + aSchema[0]+")");
- }
- catch(e) {
- bError = true;
- }
-
- if(!jsonList) {
- bError = true;
- jsonList = [];
- }
-
- else if(!YAHOO.lang.isArray(jsonList)) {
- jsonList = [jsonList];
- }
-
- // Loop through the array of all responses...
- for(var i = jsonList.length-1; i >= 0 ; i--) {
- var aResultItem = [];
- var jsonResult = jsonList[i];
- // ...and loop through each data field value of each response
- for(var j = aSchema.length-1; j >= 1 ; j--) {
- // ...and capture data into an array mapped according to the schema...
- var dataFieldValue = jsonResult[aSchema[j]];
- if(!dataFieldValue) {
- dataFieldValue = "";
- }
- aResultItem.unshift(dataFieldValue);
- }
- // If schema isn't well defined, pass along the entire result object
- if(aResultItem.length == 1) {
- aResultItem.push(jsonResult);
- }
- // Capture the array of data field values in an array of results
- aResults.unshift(aResultItem);
- }
-
- if(bError) {
- aResults = null;
- }
-
- if(aResults === null) {
- this.dataErrorEvent.fire(this, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATAPARSE);
- aResults = [];
- }
- else {
- var resultObj = {};
- resultObj.query = decodeURIComponent(sQuery);
- resultObj.results = aResults;
- this._addCacheElem(resultObj);
-
- this.getResultsEvent.fire(this, oParent, sQuery, aResults);
- }
-
- oCallbackFn(sQuery, aResults, oParent);
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Any success/failure response should decrement counter.
- *
- * @method _bumpPendingDown
- * @private
- */
-YAHOO.widget.DS_ScriptNode._bumpPendingDown = function() {
- YAHOO.widget.DS_ScriptNode._nPending--;
-};
-
-
-/****************************************************************************/
-/****************************************************************************/
-/****************************************************************************/
-
-/**
- * Implementation of YAHOO.widget.DataSource using a native Javascript function as
- * its live data source.
- *
- * @class DS_JSFunction
- * @constructor
- * @extends YAHOO.widget.DataSource
- * @param oFunction {HTMLFunction} In-memory Javascript function that returns query results as an array of objects.
- * @param oConfigs {Object} (optional) Object literal of config params.
- */
-YAHOO.widget.DS_JSFunction = function(oFunction, 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.isFunction(oFunction)) {
- return;
- }
- else {
- this.dataFunction = oFunction;
- this._init();
- }
-};
-
-YAHOO.widget.DS_JSFunction.prototype = new YAHOO.widget.DataSource();
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * In-memory Javascript function that returns query results.
- *
- * @property dataFunction
- * @type HTMLFunction
- */
-YAHOO.widget.DS_JSFunction.prototype.dataFunction = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Queries the live data source defined by function for results. 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_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;
-};
-
-
-/****************************************************************************/
-/****************************************************************************/
-/****************************************************************************/
-
-/**
- * Implementation of YAHOO.widget.DataSource using a native Javascript array as
- * its live data source.
- *
- * @class DS_JSArray
- * @constructor
- * @extends YAHOO.widget.DataSource
- * @param aData {String[]} In-memory Javascript array of simple string data.
- * @param oConfigs {Object} (optional) Object literal of config params.
- */
-YAHOO.widget.DS_JSArray = function(aData, 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(aData)) {
- return;
- }
- else {
- this.data = aData;
- this._init();
- }
-};
-
-YAHOO.widget.DS_JSArray.prototype = new YAHOO.widget.DataSource();
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * In-memory Javascript array of strings.
- *
- * @property data
- * @type Array
- */
-YAHOO.widget.DS_JSArray.prototype.data = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Queries the live data source defined by data for results. 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_JSArray.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
- var i;
- var aData = this.data; // the array
- var aResults = []; // container for results
- var bMatchFound = false;
- var bMatchContains = this.queryMatchContains;
- if(sQuery) {
- if(!this.queryMatchCase) {
- sQuery = sQuery.toLowerCase();
- }
-
- // Loop through each element of the array...
- // which can be a string or an array of strings
- 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);
-
- // A STARTSWITH match is when the query is found at the beginning of the key string...
- if((!bMatchContains && (sKeyIndex === 0)) ||
- // A CONTAINS match is when the query is found anywhere within the key string...
- (bMatchContains && (sKeyIndex > -1))) {
- // Stash a match into aResults[].
- 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.5.0", build: "895"});
diff --git a/lib/yui/calendar/README b/lib/yui/calendar/README
deleted file mode 100755
index 9de846581b..0000000000
--- a/lib/yui/calendar/README
+++ /dev/null
@@ -1,357 +0,0 @@
-Calendar Release Notes
-
-*** 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/calendar-debug.js b/lib/yui/calendar/calendar-debug.js
deleted file mode 100755
index 621b403db5..0000000000
--- a/lib/yui/calendar/calendar-debug.js
+++ /dev/null
@@ -1,6821 +0,0 @@
-/*
-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 () {
-
- /**
- * Config is a utility used within an Object to allow the implementer to
- * maintain a list of local configuration properties and listen for changes
- * to those properties dynamically using CustomEvent. The initial values are
- * also maintained so that the configuration can be reset at any given point
- * to its initial state.
- * @namespace YAHOO.util
- * @class Config
- * @constructor
- * @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", "Config"); }
-
- };
-
-
- var Lang = YAHOO.lang,
- CustomEvent = YAHOO.util.CustomEvent,
- Config = YAHOO.util.Config;
-
-
- /**
- * Constant representing the CustomEvent type for the config changed event.
- * @property YAHOO.util.Config.CONFIG_CHANGED_EVENT
- * @private
- * @static
- * @final
- */
- Config.CONFIG_CHANGED_EVENT = "configChanged";
-
- /**
- * Constant representing the boolean type string
- * @property YAHOO.util.Config.BOOLEAN_TYPE
- * @private
- * @static
- * @final
- */
- Config.BOOLEAN_TYPE = "boolean";
-
- Config.prototype = {
-
- /**
- * Object reference to the owner of this Config Object
- * @property owner
- * @type Object
- */
- owner: null,
-
- /**
- * Boolean flag that specifies whether a queue is currently
- * being executed
- * @property queueInProgress
- * @type Boolean
- */
- queueInProgress: false,
-
- /**
- * Maintains the local collection of configuration property objects and
- * their specified values
- * @property config
- * @private
- * @type Object
- */
- config: null,
-
- /**
- * Maintains the local collection of configuration property objects as
- * they were initially applied.
- * This object is used when resetting a property.
- * @property initialConfig
- * @private
- * @type Object
- */
- initialConfig: null,
-
- /**
- * Maintains the local, normalized CustomEvent queue
- * @property eventQueue
- * @private
- * @type Object
- */
- eventQueue: null,
-
- /**
- * Custom Event, notifying subscribers when Config properties are set
- * (setProperty is called without the silent flag
- * @event configChangedEvent
- */
- configChangedEvent: null,
-
- /**
- * Initializes the configuration Object and all of its local members.
- * @method init
- * @param {Object} owner The owner Object to which this Config
- * Object belongs
- */
- init: function (owner) {
-
- this.owner = owner;
-
- this.configChangedEvent =
- this.createEvent(Config.CONFIG_CHANGED_EVENT);
-
- this.configChangedEvent.signature = CustomEvent.LIST;
- this.queueInProgress = false;
- this.config = {};
- this.initialConfig = {};
- this.eventQueue = [];
-
- },
-
- /**
- * Validates that the value passed in is a Boolean.
- * @method checkBoolean
- * @param {Object} val The value to validate
- * @return {Boolean} true, if the value is valid
- */
- checkBoolean: function (val) {
- return (typeof val == Config.BOOLEAN_TYPE);
- },
-
- /**
- * Validates that the value passed in is a number.
- * @method checkNumber
- * @param {Object} val The value to validate
- * @return {Boolean} true, if the value is valid
- */
- checkNumber: function (val) {
- return (!isNaN(val));
- },
-
- /**
- * Fires a configuration property event using the specified value.
- * @method fireEvent
- * @private
- * @param {String} key The configuration property's name
- * @param {value} Object The value of the correct type for the property
- */
- fireEvent: function ( key, value ) {
- YAHOO.log("Firing Config event: " + key + "=" + value, "info", "Config");
- var property = this.config[key];
-
- if (property && property.event) {
- property.event.fire(value);
- }
- },
-
- /**
- * Adds a property to the Config Object's private config hash.
- * @method addProperty
- * @param {String} key The configuration property's name
- * @param {Object} propertyObject The Object containing all of this
- * property's arguments
- */
- addProperty: function ( key, propertyObject ) {
- key = key.toLowerCase();
- YAHOO.log("Added property: " + key, "info", "Config");
-
- this.config[key] = propertyObject;
-
- propertyObject.event = this.createEvent(key, { scope: this.owner });
- propertyObject.event.signature = CustomEvent.LIST;
-
-
- propertyObject.key = key;
-
- if (propertyObject.handler) {
- propertyObject.event.subscribe(propertyObject.handler,
- this.owner);
- }
-
- this.setProperty(key, propertyObject.value, true);
-
- if (! propertyObject.suppressEvent) {
- this.queueProperty(key, propertyObject.value);
- }
-
- },
-
- /**
- * Returns a key-value configuration map of the values currently set in
- * the Config Object.
- * @method getConfig
- * @return {Object} The current config, represented in a key-value map
- */
- getConfig: function () {
-
- var cfg = {},
- prop,
- property;
-
- for (prop in this.config) {
- property = this.config[prop];
- if (property && property.event) {
- cfg[prop] = property.value;
- }
- }
-
- return cfg;
- },
-
- /**
- * Returns the value of specified property.
- * @method getProperty
- * @param {String} key The name of the property
- * @return {Object} The value of the specified property
- */
- getProperty: function (key) {
- var property = this.config[key.toLowerCase()];
- if (property && property.event) {
- return property.value;
- } else {
- return undefined;
- }
- },
-
- /**
- * Resets the specified property's value to its initial value.
- * @method resetProperty
- * @param {String} key The name of the property
- * @return {Boolean} True is the property was reset, false if not
- */
- resetProperty: function (key) {
-
- key = key.toLowerCase();
-
- var property = this.config[key];
-
- if (property && property.event) {
-
- if (this.initialConfig[key] &&
- !Lang.isUndefined(this.initialConfig[key])) {
-
- this.setProperty(key, this.initialConfig[key]);
-
- return true;
-
- }
-
- } else {
-
- return false;
- }
-
- },
-
- /**
- * Sets the value of a property. If the silent property is passed as
- * true, the property's event will not be fired.
- * @method setProperty
- * @param {String} key The name of the property
- * @param {String} value The value to set the property to
- * @param {Boolean} silent Whether the value should be set silently,
- * without firing the property event.
- * @return {Boolean} True, if the set was successful, false if it failed.
- */
- setProperty: function (key, value, silent) {
-
- var property;
-
- key = key.toLowerCase();
- YAHOO.log("setProperty: " + key + "=" + value, "info", "Config");
-
- if (this.queueInProgress && ! silent) {
- // Currently running through a queue...
- this.queueProperty(key,value);
- return true;
-
- } else {
- property = this.config[key];
- if (property && property.event) {
- if (property.validator && !property.validator(value)) {
- return false;
- } else {
- property.value = value;
- if (! silent) {
- this.fireEvent(key, value);
- this.configChangedEvent.fire([key, value]);
- }
- return true;
- }
- } else {
- return false;
- }
- }
- },
-
- /**
- * Sets the value of a property and queues its event to execute. If the
- * event is already scheduled to execute, it is
- * moved from its current position to the end of the queue.
- * @method queueProperty
- * @param {String} key The name of the property
- * @param {String} value The value to set the property to
- * @return {Boolean} true, if the set was successful, false if
- * it failed.
- */
- queueProperty: function (key, value) {
-
- key = key.toLowerCase();
- YAHOO.log("queueProperty: " + key + "=" + value, "info", "Config");
-
- var property = this.config[key],
- foundDuplicate = false,
- iLen,
- queueItem,
- queueItemKey,
- queueItemValue,
- sLen,
- supercedesCheck,
- qLen,
- queueItemCheck,
- queueItemCheckKey,
- queueItemCheckValue,
- i,
- s,
- q;
-
- if (property && property.event) {
-
- if (!Lang.isUndefined(value) && property.validator &&
- !property.validator(value)) { // validator
- return false;
- } else {
-
- if (!Lang.isUndefined(value)) {
- property.value = value;
- } else {
- value = property.value;
- }
-
- foundDuplicate = false;
- iLen = this.eventQueue.length;
-
- for (i = 0; i < iLen; i++) {
- queueItem = this.eventQueue[i];
-
- if (queueItem) {
- queueItemKey = queueItem[0];
- queueItemValue = queueItem[1];
-
- if (queueItemKey == key) {
-
- /*
- found a dupe... push to end of queue, null
- current item, and break
- */
-
- this.eventQueue[i] = null;
-
- this.eventQueue.push(
- [key, (!Lang.isUndefined(value) ?
- value : queueItemValue)]);
-
- foundDuplicate = true;
- break;
- }
- }
- }
-
- // this is a refire, or a new property in the queue
-
- if (! foundDuplicate && !Lang.isUndefined(value)) {
- this.eventQueue.push([key, value]);
- }
- }
-
- 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", "Config");
-
- return true;
- } else {
- return false;
- }
- },
-
- /**
- * Fires the event for a property using the property's current value.
- * @method refireEvent
- * @param {String} key The name of the property
- */
- refireEvent: function (key) {
-
- key = key.toLowerCase();
-
- var property = this.config[key];
-
- if (property && property.event &&
-
- !Lang.isUndefined(property.value)) {
-
- if (this.queueInProgress) {
-
- this.queueProperty(key);
-
- } else {
-
- this.fireEvent(key, property.value);
-
- }
-
- }
- },
-
- /**
- * Applies a key-value Object literal to the configuration, replacing
- * any existing values, and queueing the property events.
- * Although the values will be set, fireQueue() must be called for their
- * associated events to execute.
- * @method applyConfig
- * @param {Object} userConfig The configuration Object literal
- * @param {Boolean} init When set to true, the initialConfig will
- * be set to the userConfig passed in, so that calling a reset will
- * reset the properties to the passed values.
- */
- applyConfig: function (userConfig, init) {
-
- var sKey,
- oConfig;
-
- if (init) {
- oConfig = {};
- for (sKey in userConfig) {
- if (Lang.hasOwnProperty(userConfig, sKey)) {
- oConfig[sKey.toLowerCase()] = userConfig[sKey];
- }
- }
- this.initialConfig = oConfig;
- }
-
- for (sKey in userConfig) {
- if (Lang.hasOwnProperty(userConfig, sKey)) {
- this.queueProperty(sKey, userConfig[sKey]);
- }
- }
- },
-
- /**
- * Refires the events for all configuration properties using their
- * current values.
- * @method refresh
- */
- refresh: function () {
-
- var prop;
-
- for (prop in this.config) {
- this.refireEvent(prop);
- }
- },
-
- /**
- * Fires the normalized list of queued property change events
- * @method fireQueue
- */
- fireQueue: function () {
-
- var i,
- queueItem,
- key,
- value,
- property;
-
- this.queueInProgress = true;
- for (i = 0;i < this.eventQueue.length; i++) {
- queueItem = this.eventQueue[i];
- if (queueItem) {
-
- key = queueItem[0];
- value = queueItem[1];
- property = this.config[key];
-
- property.value = value;
-
- this.fireEvent(key,value);
- }
- }
-
- this.queueInProgress = false;
- this.eventQueue = [];
- },
-
- /**
- * Subscribes an external handler to the change event for any
- * given property.
- * @method subscribeToConfigEvent
- * @param {String} key The property name
- * @param {Function} handler The handler function to use subscribe to
- * the property's event
- * @param {Object} obj The Object to use for scoping the event handler
- * (see CustomEvent documentation)
- * @param {Boolean} override Optional. If true, will override "this"
- * within the handler to map to the scope Object passed into the method.
- * @return {Boolean} True, if the subscription was successful,
- * otherwise false.
- */
- subscribeToConfigEvent: function (key, handler, obj, override) {
-
- 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;
- }
-
- },
-
- /**
- * Unsubscribes an external handler from the change event for any
- * given property.
- * @method unsubscribeFromConfigEvent
- * @param {String} key The property name
- * @param {Function} handler The handler function to use subscribe to
- * the property's event
- * @param {Object} obj The Object to use for scoping the event
- * handler (see CustomEvent documentation)
- * @return {Boolean} True, if the unsubscription was successful,
- * otherwise false.
- */
- unsubscribeFromConfigEvent: function (key, handler, obj) {
- var property = this.config[key.toLowerCase()];
- if (property && property.event) {
- return property.event.unsubscribe(handler, obj);
- } else {
- return false;
- }
- },
-
- /**
- * Returns a string representation of the Config object
- * @method toString
- * @return {String} The Config object in string format.
- */
- toString: function () {
- var output = "Config";
- if (this.owner) {
- output += " [" + this.owner.toString() + "]";
- }
- return output;
- },
-
- /**
- * Returns a string representation of the Config object's current
- * CustomEvent queue
- * @method outputEventQueue
- * @return {String} The string list of CustomEvents currently queued
- * for execution
- */
- outputEventQueue: function () {
-
- var output = "",
- queueItem,
- q,
- nQueue = this.eventQueue.length;
-
- for (q = 0; q < nQueue; q++) {
- queueItem = this.eventQueue[q];
- if (queueItem) {
- output += queueItem[0] + "=" + queueItem[1] + ", ";
- }
- }
- return output;
- },
-
- /**
- * Sets all properties to null, unsubscribes all listeners from each
- * property's change event and all listeners from the configChangedEvent.
- * @method destroy
- */
- destroy: function () {
-
- var oConfig = this.config,
- sProperty,
- oProperty;
-
-
- for (sProperty in oConfig) {
-
- if (Lang.hasOwnProperty(oConfig, sProperty)) {
-
- oProperty = oConfig[sProperty];
-
- oProperty.event.unsubscribeAll();
- oProperty.event = null;
-
- }
-
- }
-
- this.configChangedEvent.unsubscribeAll();
-
- this.configChangedEvent = null;
- this.owner = null;
- this.config = null;
- this.initialConfig = null;
- this.eventQueue = null;
-
- }
-
- };
-
-
-
- /**
- * Checks to determine if a particular function/Object pair are already
- * subscribed to the specified CustomEvent
- * @method YAHOO.util.Config.alreadySubscribed
- * @static
- * @param {YAHOO.util.CustomEvent} evt The CustomEvent for which to check
- * the subscriptions
- * @param {Function} fn The function to look for in the subscribers list
- * @param {Object} obj The execution scope Object for the subscription
- * @return {Boolean} true, if the function/Object pair is already subscribed
- * to the CustomEvent passed in
- */
- Config.alreadySubscribed = function (evt, fn, obj) {
-
- var nSubscribers = evt.subscribers.length,
- subsc,
- 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);
-
-}());
-
-/**
-* YAHOO.widget.DateMath is used for simple date manipulation. The class is a static utility
-* used for adding, subtracting, and comparing dates.
-* @namespace YAHOO.widget
-* @class DateMath
-*/
-YAHOO.widget.DateMath = {
- /**
- * Constant field representing Day
- * @property DAY
- * @static
- * @final
- * @type String
- */
- DAY : "D",
-
- /**
- * Constant field representing Week
- * @property WEEK
- * @static
- * @final
- * @type String
- */
- WEEK : "W",
-
- /**
- * Constant field representing Year
- * @property YEAR
- * @static
- * @final
- * @type String
- */
- YEAR : "Y",
-
- /**
- * Constant field representing Month
- * @property MONTH
- * @static
- * @final
- * @type String
- */
- MONTH : "M",
-
- /**
- * Constant field representing one day, in milliseconds
- * @property ONE_DAY_MS
- * @static
- * @final
- * @type Number
- */
- ONE_DAY_MS : 1000*60*60*24,
-
- /**
- * Adds the specified amount of time to the this instance.
- * @method add
- * @param {Date} date The JavaScript Date object to perform addition on
- * @param {String} field The field constant to be used for performing addition.
- * @param {Number} amount The number of units (measured in the field constant) to add to the date.
- * @return {Date} The resulting Date object
- */
- add : function(date, field, amount) {
- var d = new Date(date.getTime());
- switch (field) {
- case this.MONTH:
- var newMonth = date.getMonth() + amount;
- var years = 0;
-
- if (newMonth < 0) {
- while (newMonth < 0) {
- newMonth += 12;
- years -= 1;
- }
- } else if (newMonth > 11) {
- while (newMonth > 11) {
- newMonth -= 12;
- years += 1;
- }
- }
-
- d.setMonth(newMonth);
- d.setFullYear(date.getFullYear() + years);
- break;
- case this.DAY:
- this._addDays(d, amount);
- // d.setDate(date.getDate() + amount);
- break;
- case this.YEAR:
- d.setFullYear(date.getFullYear() + amount);
- break;
- case this.WEEK:
- 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.
- *
-* NOTE: As of 2.4.0, the constructor's ID argument is optional. -* The Calendar can be constructed by simply providing a container ID string, -* or a reference to a container DIV HTMLElement (the element needs to exist -* in the document). -* -* E.g.: -*
-* If not provided, the ID will be generated from the container DIV ID by adding an "_t" suffix. -* For example if an ID is not provided, and the container's ID is "calContainer", the Calendar's ID will be set to "calContainer_t". -*
-* -* @namespace YAHOO.widget -* @class Calendar -* @constructor -* @param {String} id 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.apply(this, arguments); -}; - -/** -* The path to be used for images loaded for the Calendar -* @property YAHOO.widget.Calendar.IMG_ROOT -* @static -* @deprecated You can now customize images by overriding the calclose, calnavleft and calnavright default CSS classes for the close icon, left arrow and right arrow respectively -* @type String -*/ -YAHOO.widget.Calendar.IMG_ROOT = null; - -/** -* Type constant used for renderers to represent an individual date (M/D/Y) -* @property YAHOO.widget.Calendar.DATE -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.DATE = "D"; - -/** -* Type constant used for renderers to represent an individual date across any year (M/D) -* @property YAHOO.widget.Calendar.MONTH_DAY -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.MONTH_DAY = "MD"; - -/** -* Type constant used for renderers to represent a weekday -* @property YAHOO.widget.Calendar.WEEKDAY -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.WEEKDAY = "WD"; - -/** -* Type constant used for renderers to represent a range of individual dates (M/D/Y-M/D/Y) -* @property YAHOO.widget.Calendar.RANGE -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.RANGE = "R"; - -/** -* Type constant used for renderers to represent a month across any year -* @property YAHOO.widget.Calendar.MONTH -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.MONTH = "M"; - -/** -* Constant that represents the total number of date cells that are displayed in a given month -* @property YAHOO.widget.Calendar.DISPLAY_DAYS -* @static -* @final -* @type Number -*/ -YAHOO.widget.Calendar.DISPLAY_DAYS = 42; - -/** -* Constant used for halting the execution of the remainder of the render stack -* @property YAHOO.widget.Calendar.STOP_RENDER -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.STOP_RENDER = "S"; - -/** -* Constant used to represent short date field string formats (e.g. Tu or Feb) -* @property YAHOO.widget.Calendar.SHORT -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.SHORT = "short"; - -/** -* Constant used to represent long date field string formats (e.g. Monday or February) -* @property YAHOO.widget.Calendar.LONG -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.LONG = "long"; - -/** -* Constant used to represent medium date field string formats (e.g. Mon) -* @property YAHOO.widget.Calendar.MEDIUM -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.MEDIUM = "medium"; - -/** -* Constant used to represent single character date field string formats (e.g. M, T, W) -* @property YAHOO.widget.Calendar.ONE_CHAR -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.ONE_CHAR = "1char"; - -/** -* The set of default Config property keys and values for the Calendar -* @property YAHOO.widget.Calendar._DEFAULT_CONFIG -* @final -* @static -* @private -* @type Object -*/ -YAHOO.widget.Calendar._DEFAULT_CONFIG = { - // Default values for pagedate and selected are not class level constants - they are set during instance creation - PAGEDATE : {key:"pagedate", value:null}, - SELECTED : {key:"selected", value:null}, - TITLE : {key:"title", value:""}, - CLOSE : {key:"close", value:false}, - IFRAME : {key:"iframe", value:(YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) ? true : false}, - MINDATE : {key:"mindate", value:null}, - MAXDATE : {key:"maxdate", value:null}, - MULTI_SELECT : {key:"multi_select", value:false}, - START_WEEKDAY : {key:"start_weekday", value:0}, - SHOW_WEEKDAYS : {key:"show_weekdays", value:true}, - SHOW_WEEK_HEADER : {key:"show_week_header", value:false}, - SHOW_WEEK_FOOTER : {key:"show_week_footer", value:false}, - HIDE_BLANK_WEEKS : {key:"hide_blank_weeks", value:false}, - NAV_ARROW_LEFT: {key:"nav_arrow_left", value:null} , - NAV_ARROW_RIGHT : {key:"nav_arrow_right", value:null} , - MONTHS_SHORT : {key:"months_short", value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]}, - MONTHS_LONG: {key:"months_long", value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]}, - WEEKDAYS_1CHAR: {key:"weekdays_1char", value:["S", "M", "T", "W", "T", "F", "S"]}, - WEEKDAYS_SHORT: {key:"weekdays_short", value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]}, - WEEKDAYS_MEDIUM: {key:"weekdays_medium", value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]}, - WEEKDAYS_LONG: {key:"weekdays_long", value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]}, - LOCALE_MONTHS:{key:"locale_months", value:"long"}, - LOCALE_WEEKDAYS:{key:"locale_weekdays", value:"short"}, - DATE_DELIMITER:{key:"date_delimiter", value:","}, - DATE_FIELD_DELIMITER:{key:"date_field_delimiter", value:"/"}, - DATE_RANGE_DELIMITER:{key:"date_range_delimiter", value:"-"}, - MY_MONTH_POSITION:{key:"my_month_position", value:1}, - MY_YEAR_POSITION:{key:"my_year_position", value:2}, - MD_MONTH_POSITION:{key:"md_month_position", value:1}, - MD_DAY_POSITION:{key:"md_day_position", value:2}, - MDY_MONTH_POSITION:{key:"mdy_month_position", value:1}, - MDY_DAY_POSITION:{key:"mdy_day_position", value:2}, - MDY_YEAR_POSITION:{key:"mdy_year_position", value:3}, - 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:""}, - NAV: {key:"navigator", value: null} -}; - -/** -* The set of Custom Event types supported by the Calendar -* @property YAHOO.widget.Calendar._EVENT_TYPES -* @final -* @static -* @private -* @type Object -*/ -YAHOO.widget.Calendar._EVENT_TYPES = { - BEFORE_SELECT : "beforeSelect", - SELECT : "select", - BEFORE_DESELECT : "beforeDeselect", - DESELECT : "deselect", - CHANGE_PAGE : "changePage", - BEFORE_RENDER : "beforeRender", - RENDER : "render", - RESET : "reset", - 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" -}; - -/** -* The set of default style constants for the Calendar -* @property YAHOO.widget.Calendar._STYLES -* @final -* @static -* @private -* @type Object -*/ -YAHOO.widget.Calendar._STYLES = { - CSS_ROW_HEADER: "calrowhead", - CSS_ROW_FOOTER: "calrowfoot", - CSS_CELL : "calcell", - CSS_CELL_SELECTOR : "selector", - CSS_CELL_SELECTED : "selected", - CSS_CELL_SELECTABLE : "selectable", - CSS_CELL_RESTRICTED : "restricted", - CSS_CELL_TODAY : "today", - CSS_CELL_OOM : "oom", - CSS_CELL_OOB : "previous", - CSS_HEADER : "calheader", - CSS_HEADER_TEXT : "calhead", - CSS_BODY : "calbody", - CSS_WEEKDAY_CELL : "calweekdaycell", - CSS_WEEKDAY_ROW : "calweekdayrow", - CSS_FOOTER : "calfoot", - CSS_CALENDAR : "yui-calendar", - CSS_SINGLE : "single", - 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", - CSS_CELL_RIGHT : "calcellright", - CSS_CELL_BOTTOM : "calcellbottom", - CSS_CELL_HOVER : "calcellhover", - CSS_CELL_HIGHLIGHT1 : "highlight1", - CSS_CELL_HIGHLIGHT2 : "highlight2", - CSS_CELL_HIGHLIGHT3 : "highlight3", - CSS_CELL_HIGHLIGHT4 : "highlight4" -}; - -YAHOO.widget.Calendar.prototype = { - - /** - * The configuration object used to set up the calendars various locale and style options. - * @property Config - * @private - * @deprecated Configuration properties should be set by calling Calendar.cfg.setProperty. - * @type Object - */ - Config : null, - - /** - * The parent CalendarGroup, only to be set explicitly by the parent group - * @property parent - * @type CalendarGroup - */ - parent : null, - - /** - * The index of this item in the parent group - * @property index - * @type Number - */ - index : -1, - - /** - * The collection of calendar table cells - * @property cells - * @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 - * @type Array[](Number[]) - */ - cellDates : null, - - /** - * 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 - * @type HTMLElement - */ - oDomContainer : null, - - /** - * A Date object representing today's date. - * @property today - * @type Date - */ - today : null, - - /** - * The list of render functions, along with required parameters, used to render cells. - * @property renderStack - * @type Array[] - */ - renderStack : null, - - /** - * A copy of the initial render functions created before rendering. - * @property _renderStack - * @private - * @type Array - */ - _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 - * @private - * @type Array - */ - _selectedDates : null, - - /** - * A map of DOM event handlers to attach to cells associated with specific CSS class names - * @property domEventMap - * @type Object - */ - 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; - } - 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; - }, - - /** - * 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); - - 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 (!this.oDomContainer.id) { - this.oDomContainer.id = YAHOO.util.Dom.generateId(); - } - if (!id) { - id = this.oDomContainer.id + "_t"; - } - - this.id = id; - this.containerId = this.oDomContainer.id; - - this.logger = new YAHOO.widget.LogWriter("Calendar " + this.id); - this.initEvents(); - - this.today = new Date(); - YAHOO.widget.DateMath.clearTime(this.today); - - /** - * 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 - */ - 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; - } - } - } - } - }, - - /** - * Default handler for the "title" property - * @method configTitle - */ - configTitle : function(type, args, obj) { - var title = args[0]; - - // "" 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(" "); - } - } - }, - - /** - * 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(" "); - } - this.createCloseButton(); - } else { - this.removeCloseButton(); - if (!title) { - this.removeTitleBar(); - } - } - }, - - /** - * Initializes Calendar's built-in CustomEvents - * @method initEvents - */ - initEvents : function() { - - var defEvents = YAHOO.widget.Calendar._EVENT_TYPES; - - /** - * Fired before a selection is made - * @event beforeSelectEvent - */ - this.beforeSelectEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_SELECT); - - /** - * 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); - - /** - * Fired before a selection is made - * @event beforeDeselectEvent - */ - this.beforeDeselectEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_DESELECT); - - /** - * 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); - - /** - * Fired when the Calendar page is changed - * @event changePageEvent - */ - this.changePageEvent = new YAHOO.util.CustomEvent(defEvents.CHANGE_PAGE); - - /** - * Fired before the Calendar is rendered - * @event beforeRenderEvent - */ - this.beforeRenderEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_RENDER); - - /** - * Fired when the Calendar is rendered - * @event renderEvent - */ - this.renderEvent = new YAHOO.util.CustomEvent(defEvents.RENDER); - - /** - * Fired when the Calendar is reset - * @event resetEvent - */ - this.resetEvent = new YAHOO.util.CustomEvent(defEvents.RESET); - - /** - * Fired when the Calendar is cleared - * @event clearEvent - */ - this.clearEvent = new YAHOO.util.CustomEvent(defEvents.CLEAR); - - /** - * Fired just before the Calendar is to be shown - * @event beforeShowEvent - */ - this.beforeShowEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_SHOW); - - /** - * Fired after the Calendar is shown - * @event showEvent - */ - this.showEvent = new YAHOO.util.CustomEvent(defEvents.SHOW); - - /** - * Fired just before the Calendar is to be hidden - * @event beforeHideEvent - */ - this.beforeHideEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_HIDE); - - /** - * Fired after the Calendar is hidden - * @event hideEvent - */ - this.hideEvent = new YAHOO.util.CustomEvent(defEvents.HIDE); - - /** - * Fired just before the CalendarNavigator is to be shown - * @event beforeShowNavEvent - */ - this.beforeShowNavEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_SHOW_NAV); - - /** - * Fired after the CalendarNavigator is shown - * @event showNavEvent - */ - this.showNavEvent = new YAHOO.util.CustomEvent(defEvents.SHOW_NAV); - - /** - * Fired just before the CalendarNavigator is to be hidden - * @event beforeHideNavEvent - */ - this.beforeHideNavEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_HIDE_NAV); - - /** - * Fired after the CalendarNavigator is hidden - * @event hideNavEvent - */ - this.hideNavEvent = new YAHOO.util.CustomEvent(defEvents.HIDE_NAV); - - /** - * Fired just before the CalendarNavigator is to be rendered - * @event beforeRenderNavEvent - */ - this.beforeRenderNavEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_RENDER_NAV); - - /** - * Fired after the CalendarNavigator is rendered - * @event renderNavEvent - */ - this.renderNavEvent = new YAHOO.util.CustomEvent(defEvents.RENDER_NAV); - - 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 - */ - 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)) { - - if (!defSelector && tagName == "a" && YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTOR)) { - defSelector = true; - } - - target = target.parentNode; - tagName = target.tagName.toLowerCase(); - // TODO: No need to go all the way up to html. - if (tagName == "html") { - return; - } - } - - 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 = YAHOO.widget.DateMath.getDate(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(); - } - - var cellDate = cal.cellDates[index]; - var cellDateIndex = cal._indexOfSelectedFieldArray(cellDate); - - if (cellDateIndex > -1) { - cal.deselectCell(index); - } else { - cal.selectCell(index); - } - - } else { - link = cell.getElementsByTagName("a")[0]; - if (link) { - link.blur(); - } - 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 - */ - doCellMouseOver : function(e, cal) { - var target; - if (e) { - target = YAHOO.util.Event.getTarget(e); - } else { - target = this; - } - - while (target.tagName && target.tagName.toLowerCase() != "td") { - target = target.parentNode; - if (!target.tagName || 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 - */ - doCellMouseOut : function(e, cal) { - var target; - if (e) { - target = YAHOO.util.Event.getTarget(e); - } else { - target = this; - } - - while (target.tagName && target.tagName.toLowerCase() != "td") { - target = target.parentNode; - if (!target.tagName || 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); - } - }, - - 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 " " - */ - 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 } ); - - /** - * Configuration for the Month/Year CalendarNavigator UI which allows the user to jump directly to a - * specific Month/Year without having to scroll sequentially through months. - *- * 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). - *
- *E.g.
- *- * var navConfig = { - * strings: { - * month:"Calendar Month", - * year:"Calendar Year", - * submit: "Submit", - * cancel: "Cancel", - * invalidYear: "Please enter a valid year" - * }, - * monthFormat: YAHOO.widget.Calendar.SHORT, - * initialFocus: "month" - * } - *- * @config navigator - * @type {Object|Boolean} - * @default null - */ - this.cfg.addProperty(defCfg.NAV.key, { value:defCfg.NAV.value, handler:this.configNavigator } ); - }, - - /** - * The default handler for the "pagedate" property - * @method configPageDate - */ - configPageDate : function(type, args, obj) { - this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key, this._parsePageDate(args[0]), true); - }, - - /** - * The default handler for the "mindate" property - * @method configMinDate - */ - configMinDate : function(type, args, obj) { - var val = args[0]; - if (YAHOO.lang.isString(val)) { - val = this._parseDate(val); - this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MINDATE.key, YAHOO.widget.DateMath.getDate(val[0],(val[1]-1),val[2])); - } - }, - - /** - * The default handler for the "maxdate" property - * @method configMaxDate - */ - configMaxDate : function(type, args, obj) { - var val = args[0]; - if (YAHOO.lang.isString(val)) { - val = this._parseDate(val); - this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MAXDATE.key, YAHOO.widget.DateMath.getDate(val[0],(val[1]-1),val[2])); - } - }, - - /** - * The default handler for the "selected" property - * @method configSelected - */ - configSelected : function(type, args, obj) { - var selected = args[0]; - var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key; - - if (selected) { - if (YAHOO.lang.isString(selected)) { - this.cfg.setProperty(cfgSelected, this._parseDates(selected), true); - } - } - if (! this._selectedDates) { - this._selectedDates = this.cfg.getProperty(cfgSelected); - } - }, - - /** - * The default handler for all configuration options properties - * @method configOptions - */ - configOptions : function(type, args, obj) { - this.Options[type.toUpperCase()] = args[0]; - }, - - /** - * The default handler for all configuration locale properties - * @method configLocale - */ - configLocale : function(type, args, obj) { - var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; - this.Locale[type.toUpperCase()] = args[0]; - - this.cfg.refireEvent(defCfg.LOCALE_MONTHS.key); - this.cfg.refireEvent(defCfg.LOCALE_WEEKDAYS.key); - }, - - /** - * The default handler for all configuration locale field length properties - * @method configLocaleValues - */ - configLocaleValues : function(type, args, obj) { - var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; - - type = type.toLowerCase(); - var val = args[0]; - - switch (type) { - case defCfg.LOCALE_MONTHS.key: - switch (val) { - case YAHOO.widget.Calendar.SHORT: - this.Locale.LOCALE_MONTHS = this.cfg.getProperty(defCfg.MONTHS_SHORT.key).concat(); - break; - case YAHOO.widget.Calendar.LONG: - this.Locale.LOCALE_MONTHS = this.cfg.getProperty(defCfg.MONTHS_LONG.key).concat(); - break; - } - 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
- * 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] = '-* NOTE: As of 2.4.0, the constructor's ID argument is optional. -* The CalendarGroup can be constructed by simply providing a container ID string, -* or a reference to a container DIV HTMLElement (the element needs to exist -* in the document). -* -* E.g.: -*
-* If not provided, the ID will be generated from the container DIV ID by adding an "_t" suffix. -* For example if an ID is not provided, and the container's ID is "calContainer", the CalendarGroup's ID will be set to "calContainer_t". -*
-* -* @namespace YAHOO.widget -* @class CalendarGroup -* @constructor -* @param {String} id optional The id of the table element that will represent the CalendarGroup widget. As of 2.4.0, this argument is optional. -* @param {String | HTMLElement} container The id of the container div element that will wrap the CalendarGroup table, or a reference to a DIV element which exists in the document. -* @param {Object} config optional The configuration object containing the initial configuration values for the CalendarGroup. -*/ -YAHOO.widget.CalendarGroup = function(id, containerId, config) { - if (arguments.length > 0) { - this.init.apply(this, arguments); - } -}; - -YAHOO.widget.CalendarGroup.prototype = { - - /** - * 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) { - - // Normalize 2.4.0, pre 2.4.0 args - var nArgs = this._parseArgs(arguments); - - 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 (!this.oDomContainer.id) { - this.oDomContainer.id = YAHOO.util.Dom.generateId(); - } - if (!id) { - id = this.oDomContainer.id + "_t"; - } - - /** - * 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 = this.oDomContainer.id; - - this.logger = new YAHOO.widget.LogWriter("CalendarGroup " + this.id); - this.initEvents(); - this.initStyles(); - - /** - * The collection of Calendar pages contained within the CalendarGroup - * @property pages - * @type YAHOO.widget.Calendar[] - */ - this.pages = []; - - 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.showEvent.subscribe(this._fixWidth, this, true); - } - - this.logger.log("Initialized " + this.pages.length + "-page CalendarGroup", "info"); - }, - - 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 } ); - - /** - * 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 CalendarGroup'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 CalendarGroup - * @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.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 } ); - - /** - * 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 } ); - }, - - /** - * Initializes CalendarGroup's built-in CustomEvents - * @method initEvents - */ - initEvents : function() { - var me = this; - var strEvent = "Event"; - - /** - * 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- * The method is also registered as an HTMLElement resize listener on the Calendars container element. - *
- * @protected - * @method _syncMask - */ - _syncMask : function() { - var c = this.cal.oDomContainer; - if (c && this.maskEl) { - var r = YAHOO.util.Dom.getRegion(c); - YAHOO.util.Dom.setStyle(this.maskEl, "width", r.right - r.left + "px"); - YAHOO.util.Dom.setStyle(this.maskEl, "height", r.bottom - r.top + "px"); - } - }, - - /** - * Renders the contents of the navigator - * - * @method renderNavContents - * - * @param {Array} html The HTML buffer to append the HTML to. - * @return {Array} A reference to the buffer passed in. - */ - renderNavContents : function(html) { - var NAV = YAHOO.widget.CalendarNavigator, - C = NAV.CLASSES, - h = html; // just to use a shorter name - - h[h.length] = '- * The method will call applyKeyListeners, to setup keyboard specific - * listeners - *
- * @method applyListeners - */ - applyListeners : function() { - var E = YAHOO.util.Event; - - function yearUpdateHandler() { - if (this.validate()) { - this.setYear(this._getYearFromUI()); - } - } - - function monthUpdateHandler() { - this.setMonth(this._getMonthFromUI()); - } - - E.on(this.submitEl, "click", this.submit, this, true); - E.on(this.cancelEl, "click", this.cancel, this, true); - E.on(this.yearEl, "blur", yearUpdateHandler, this, true); - E.on(this.monthEl, "change", monthUpdateHandler, this, true); - - if (this.__isIEQuirks) { - YAHOO.util.Event.on(this.cal.oDomContainer, "resize", this._syncMask, this, true); - } - - this.applyKeyListeners(); - }, - - /** - * Removes/purges DOM event listeners from the rendered elements - * - * @method purgeListeners - */ - purgeListeners : function() { - var E = YAHOO.util.Event; - E.removeListener(this.submitEl, "click", this.submit); - E.removeListener(this.cancelEl, "click", this.cancel); - E.removeListener(this.yearEl, "blur"); - E.removeListener(this.monthEl, "change"); - if (this.__isIEQuirks) { - E.removeListener(this.cal.oDomContainer, "resize", this._syncMask); - } - - this.purgeKeyListeners(); - }, - - /** - * Attaches DOM listeners for keyboard support. - * Tab/Shift-Tab looping, Enter Key Submit on Year element, - * Up/Down/PgUp/PgDown year increment on Year element - *- * NOTE: MacOSX Safari 2.x doesn't let you tab to buttons and - * MacOSX Gecko does not let you tab to buttons or select controls, - * so for these browsers, Tab/Shift-Tab looping is limited to the - * elements which can be reached using the tab key. - *
- * @method applyKeyListeners - */ - applyKeyListeners : function() { - var E = YAHOO.util.Event; - - // IE doesn't fire keypress for arrow/pg keys (non-char keys) - var ua = YAHOO.env.ua; - var arrowEvt = (ua.ie) ? "keydown" : "keypress"; - - // - IE doesn't fire keypress for non-char keys - // - Opera doesn't allow us to cancel keydown or keypress for tab, but - // changes focus successfully on keydown (keypress is too late to change focus - opera's already moved on). - var tabEvt = (ua.ie || ua.opera) ? "keydown" : "keypress"; - - // Everyone likes keypress for Enter (char keys) - whoo hoo! - E.on(this.yearEl, "keypress", this._handleEnterKey, this, true); - - E.on(this.yearEl, arrowEvt, this._handleDirectionKeys, this, true); - E.on(this.lastCtrl, tabEvt, this._handleTabKey, this, true); - E.on(this.firstCtrl, tabEvt, this._handleShiftTabKey, this, true); - }, - - /** - * Removes/purges DOM listeners for keyboard support - * - * @method purgeKeyListeners - */ - purgeKeyListeners : function() { - var E = YAHOO.util.Event; - - var arrowEvt = (YAHOO.env.ua.ie) ? "keydown" : "keypress"; - var tabEvt = (YAHOO.env.ua.ie || YAHOO.env.ua.opera) ? "keydown" : "keypress"; - - E.removeListener(this.yearEl, "keypress", this._handleEnterKey); - E.removeListener(this.yearEl, arrowEvt, this._handleDirectionKeys); - E.removeListener(this.lastCtrl, tabEvt, this._handleTabKey); - E.removeListener(this.firstCtrl, tabEvt, this._handleShiftTabKey); - }, - - /** - * Updates the Calendar/CalendarGroup's pagedate with the currently set month and year if valid. - *- * If the currently set month/year is invalid, a validation error will be displayed and the - * Calendar/CalendarGroup's pagedate will not be updated. - *
- * @method submit - */ - submit : function() { - if (this.validate()) { - this.hide(); - - this.setMonth(this._getMonthFromUI()); - this.setYear(this._getYearFromUI()); - - var cal = this.cal; - var nav = this; - - function update() { - cal.setYear(nav.getYear()); - cal.setMonth(nav.getMonth()); - cal.render(); - } - // Artificial delay, just to help the user see something changed - var delay = YAHOO.widget.CalendarNavigator.UPDATE_DELAY; - if (delay > 0) { - window.setTimeout(update, delay); - } else { - update(); - } - } - }, - - /** - * Hides the navigator and mask, without updating the Calendar/CalendarGroup's state - * - * @method cancel - */ - cancel : function() { - this.hide(); - }, - - /** - * Validates the current state of the UI controls - * - * @method validate - * @return {Boolean} true, if the current UI state contains valid values, false if not - */ - validate : function() { - if (this._getYearFromUI() !== null) { - this.clearErrors(); - return true; - } else { - this.setYearError(); - this.setError(this.__getCfg("invalidYear", true)); - return false; - } - }, - - /** - * Displays an error message in the Navigator's error panel - * @method setError - * @param {String} msg The error message to display - */ - setError : function(msg) { - if (this.errorEl) { - this.errorEl.innerHTML = msg; - this._show(this.errorEl, true); - } - }, - - /** - * Clears the navigator's error message and hides the error panel - * @method clearError - */ - clearError : function() { - if (this.errorEl) { - this.errorEl.innerHTML = ""; - this._show(this.errorEl, false); - } - }, - - /** - * Displays the validation error UI for the year control - * @method setYearError - */ - setYearError : function() { - YAHOO.util.Dom.addClass(this.yearEl, YAHOO.widget.CalendarNavigator.CLASSES.INVALID); - }, - - /** - * Removes the validation error UI for the year control - * @method clearYearError - */ - clearYearError : function() { - YAHOO.util.Dom.removeClass(this.yearEl, YAHOO.widget.CalendarNavigator.CLASSES.INVALID); - }, - - /** - * Clears all validation and error messages in the UI - * @method clearErrors - */ - clearErrors : function() { - this.clearError(); - this.clearYearError(); - }, - - /** - * Sets the initial focus, based on the configured value - * @method setInitialFocus - */ - setInitialFocus : function() { - var el = this.submitEl; - var f = this.__getCfg("initialFocus"); - - if (f && f.toLowerCase) { - f = f.toLowerCase(); - if (f == "year") { - el = this.yearEl; - try { - this.yearEl.select(); - } catch (e) { - // Ignore; - } - } else if (f == "month") { - el = this.monthEl; - } - } - - if (el && YAHOO.lang.isFunction(el.focus)) { - try { - el.focus(); - } catch (e) { - // TODO: Fall back if focus fails? - } - } - }, - - /** - * Removes all renderered HTML elements for the Navigator from - * the DOM, purges event listeners and clears (nulls) any property - * references to HTML references - * @method erase - */ - erase : function() { - if (this.__rendered) { - this.purgeListeners(); - - // Clear out innerHTML references - this.yearEl = null; - this.monthEl = null; - this.errorEl = null; - this.submitEl = null; - this.cancelEl = null; - this.firstCtrl = null; - this.lastCtrl = null; - if (this.navEl) { - this.navEl.innerHTML = ""; - } - - var p = this.navEl.parentNode; - if (p) { - p.removeChild(this.navEl); - } - this.navEl = null; - - var pm = this.maskEl.parentNode; - if (pm) { - pm.removeChild(this.maskEl); - } - this.maskEl = null; - this.__rendered = false; - } - }, - - /** - * Destroys the Navigator object and any HTML references - * @method destroy - */ - destroy : function() { - this.erase(); - this._doc = null; - this.cal = null; - this.id = null; - }, - - /** - * Protected implementation to handle how UI elements are - * hidden/shown. - * - * @method _show - * @protected - */ - _show : function(el, bShow) { - if (el) { - YAHOO.util.Dom.setStyle(el, "display", (bShow) ? "block" : "none"); - } - }, - - /** - * Returns the month value (index), from the month UI element - * @protected - * @method _getMonthFromUI - * @return {Number} The month index, or 0 if a UI element for the month - * is not found - */ - _getMonthFromUI : function() { - if (this.monthEl) { - return this.monthEl.selectedIndex; - } else { - return 0; // Default to Jan - } - }, - - /** - * Returns the year value, from the Navitator's year UI element - * @protected - * @method _getYearFromUI - * @return {Number} The year value set in the UI, if valid. null is returned if - * the UI does not contain a valid year value. - */ - _getYearFromUI : function() { - var NAV = YAHOO.widget.CalendarNavigator; - - var yr = null; - if (this.yearEl) { - var value = this.yearEl.value; - value = value.replace(NAV.TRIM, "$1"); - - if (NAV.YR_PATTERN.test(value)) { - yr = parseInt(value, 10); - } - } - return yr; - }, - - /** - * Updates the Navigator's year UI, based on the year value set on the Navigator object - * @protected - * @method _updateYearUI - */ - _updateYearUI : function() { - if (this.yearEl && this._year !== null) { - this.yearEl.value = this._year; - } - }, - - /** - * Updates the Navigator's month UI, based on the month value set on the Navigator object - * @protected - * @method _updateMonthUI - */ - _updateMonthUI : function() { - if (this.monthEl) { - this.monthEl.selectedIndex = this._month; - } - }, - - /** - * Sets up references to the first and last focusable element in the Navigator's UI - * in terms of tab order (Naviagator's firstEl and lastEl properties). The references - * are used to control modality by looping around from the first to the last control - * and visa versa for tab/shift-tab navigation. - *- * See applyKeyListeners - *
- * @protected - * @method _setFirstLastElements - */ - _setFirstLastElements : function() { - this.firstCtrl = this.monthEl; - this.lastCtrl = this.cancelEl; - - // Special handling for MacOSX. - // - Safari 2.x can't focus on buttons - // - Gecko can't focus on select boxes or buttons - if (this.__isMac) { - if (YAHOO.env.ua.webkit && YAHOO.env.ua.webkit < 420){ - this.firstCtrl = this.monthEl; - this.lastCtrl = this.yearEl; - } - if (YAHOO.env.ua.gecko) { - this.firstCtrl = this.yearEl; - this.lastCtrl = this.yearEl; - } - } - }, - - /** - * Default Keyboard event handler to capture Enter - * on the Navigator's year control (yearEl) - * - * @method _handleEnterKey - * @protected - * @param {Event} e The DOM event being handled - */ - _handleEnterKey : function(e) { - var KEYS = YAHOO.util.KeyListener.KEY; - - if (YAHOO.util.Event.getCharCode(e) == KEYS.ENTER) { - YAHOO.util.Event.preventDefault(e); - this.submit(); - } - }, - - /** - * Default Keyboard event handler to capture up/down/pgup/pgdown - * on the Navigator's year control (yearEl). - * - * @method _handleDirectionKeys - * @protected - * @param {Event} e The DOM event being handled - */ - _handleDirectionKeys : function(e) { - var E = YAHOO.util.Event; - var KEYS = YAHOO.util.KeyListener.KEY; - var NAV = YAHOO.widget.CalendarNavigator; - - var value = (this.yearEl.value) ? parseInt(this.yearEl.value, 10) : null; - if (isFinite(value)) { - var dir = false; - switch(E.getCharCode(e)) { - case KEYS.UP: - this.yearEl.value = value + NAV.YR_MINOR_INC; - dir = true; - break; - case KEYS.DOWN: - this.yearEl.value = Math.max(value - NAV.YR_MINOR_INC, 0); - dir = true; - break; - case KEYS.PAGE_UP: - this.yearEl.value = value + NAV.YR_MAJOR_INC; - dir = true; - break; - case KEYS.PAGE_DOWN: - this.yearEl.value = Math.max(value - NAV.YR_MAJOR_INC, 0); - dir = true; - break; - default: - break; - } - if (dir) { - E.preventDefault(e); - try { - this.yearEl.select(); - } catch(e) { - // Ignore - } - } - } - }, - - /** - * Default Keyboard event handler to capture Tab - * on the last control (lastCtrl) in the Navigator. - * - * @method _handleTabKey - * @protected - * @param {Event} e The DOM event being handled - */ - _handleTabKey : function(e) { - var E = YAHOO.util.Event; - var KEYS = YAHOO.util.KeyListener.KEY; - - if (E.getCharCode(e) == KEYS.TAB && !e.shiftKey) { - try { - E.preventDefault(e); - this.firstCtrl.focus(); - } catch (e) { - // Ignore - mainly for focus edge cases - } - } - }, - - /** - * Default Keyboard event handler to capture Shift-Tab - * on the first control (firstCtrl) in the Navigator. - * - * @method _handleShiftTabKey - * @protected - * @param {Event} e The DOM event being handled - */ - _handleShiftTabKey : function(e) { - var E = YAHOO.util.Event; - var KEYS = YAHOO.util.KeyListener.KEY; - - if (e.shiftKey && E.getCharCode(e) == KEYS.TAB) { - try { - E.preventDefault(e); - this.lastCtrl.focus(); - } catch (e) { - // Ignore - mainly for focus edge cases - } - } - }, - - /** - * Retrieve Navigator configuration values from - * the parent Calendar/CalendarGroup's config value. - *- * If it has not been set in the user provided configuration, the method will - * return the default value of the configuration property, as set in _DEFAULT_CFG - *
- * @private - * @method __getCfg - * @param {String} Case sensitive property name. - * @param {Boolean} true, if the property is a string property, false if not. - * @return The value of the configuration property - */ - __getCfg : function(prop, bIsStr) { - var DEF_CFG = YAHOO.widget.CalendarNavigator._DEFAULT_CFG; - var cfg = this.cal.cfg.getProperty("navigator"); - - if (bIsStr) { - return (cfg !== true && cfg.strings && cfg.strings[prop]) ? cfg.strings[prop] : DEF_CFG.strings[prop]; - } else { - return (cfg !== true && cfg[prop]) ? cfg[prop] : DEF_CFG[prop]; - } - }, - - /** - * Private flag, to identify MacOS - * @private - * @property __isMac - */ - __isMac : (navigator.userAgent.toLowerCase().indexOf("macintosh") != -1) - -}; - -YAHOO.register("calendar", YAHOO.widget.Calendar, {version: "2.5.0", build: "895"}); diff --git a/lib/yui/calendar/calendar-min.js b/lib/yui/calendar/calendar-min.js deleted file mode 100755 index cb632508c5..0000000000 --- a/lib/yui/calendar/calendar-min.js +++ /dev/null @@ -1,18 +0,0 @@ -/* -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(){YAHOO.util.Config=function(D){if(D){this.init(D);}};var B=YAHOO.lang,C=YAHOO.util.CustomEvent,A=YAHOO.util.Config;A.CONFIG_CHANGED_EVENT="configChanged";A.BOOLEAN_TYPE="boolean";A.prototype={owner:null,queueInProgress:false,config:null,initialConfig:null,eventQueue:null,configChangedEvent:null,init:function(D){this.owner=D;this.configChangedEvent=this.createEvent(A.CONFIG_CHANGED_EVENT);this.configChangedEvent.signature=C.LIST;this.queueInProgress=false;this.config={};this.initialConfig={};this.eventQueue=[];},checkBoolean:function(D){return(typeof D==A.BOOLEAN_TYPE);},checkNumber:function(D){return(!isNaN(D));},fireEvent:function(D,F){var E=this.config[D];if(E&&E.event){E.event.fire(F);}},addProperty:function(E,D){E=E.toLowerCase();this.config[E]=D;D.event=this.createEvent(E,{scope:this.owner});D.event.signature=C.LIST;D.key=E;if(D.handler){D.event.subscribe(D.handler,this.owner);}this.setProperty(E,D.value,true);if(!D.suppressEvent){this.queueProperty(E,D.value);}},getConfig:function(){var D={},F,E;for(F in this.config){E=this.config[F];if(E&&E.event){D[F]=E.value;}}return D;},getProperty:function(D){var E=this.config[D.toLowerCase()];if(E&&E.event){return E.value;}else{return undefined;}},resetProperty:function(D){D=D.toLowerCase();var E=this.config[D];if(E&&E.event){if(this.initialConfig[D]&&!B.isUndefined(this.initialConfig[D])){this.setProperty(D,this.initialConfig[D]);return true;}}else{return false;}},setProperty:function(E,G,D){var F;E=E.toLowerCase();if(this.queueInProgress&&!D){this.queueProperty(E,G);return true;}else{F=this.config[E];if(F&&F.event){if(F.validator&&!F.validator(G)){return false;}else{F.value=G;if(!D){this.fireEvent(E,G);this.configChangedEvent.fire([E,G]);}return true;}}else{return false;}}},queueProperty:function(S,P){S=S.toLowerCase();var R=this.config[S],K=false,J,G,H,I,O,Q,F,M,N,D,L,T,E;if(R&&R.event){if(!B.isUndefined(P)&&R.validator&&!R.validator(P)){return false;}else{if(!B.isUndefined(P)){R.value=P;}else{P=R.value;}K=false;J=this.eventQueue.length;for(L=0;L- * 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 - * @param {Date} date The JavaScript Date object to perform subtraction on - * @param {Number} field The this field constant to be used for performing subtraction. - * @param {Number} amount The number of units (measured in the field constant) to subtract from the date. - * @return {Date} The resulting Date object - */ - subtract : function(date, field, amount) { - return this.add(date, field, (amount*-1)); - }, - - /** - * Determines whether a given date is before another date on the calendar. - * @method before - * @param {Date} date The Date object to compare with the compare argument - * @param {Date} compareTo The Date object to use for the comparison - * @return {Boolean} true if the date occurs before the compared date; false if not. - */ - before : function(date, compareTo) { - var ms = compareTo.getTime(); - if (date.getTime() < ms) { - return true; - } else { - return false; - } - }, - - /** - * Determines whether a given date is after another date on the calendar. - * @method after - * @param {Date} date The Date object to compare with the compare argument - * @param {Date} compareTo The Date object to use for the comparison - * @return {Boolean} true if the date occurs after the compared date; false if not. - */ - after : function(date, compareTo) { - var ms = compareTo.getTime(); - if (date.getTime() > ms) { - return true; - } else { - return false; - } - }, - - /** - * Determines whether a given date is between two other dates on the calendar. - * @method between - * @param {Date} date The date to check for - * @param {Date} dateBegin The start of the range - * @param {Date} dateEnd The end of the range - * @return {Boolean} true if the date occurs between the compared dates; false if not. - */ - between : function(date, dateBegin, dateEnd) { - if (this.after(date, dateBegin) && this.before(date, dateEnd)) { - return true; - } else { - return false; - } - }, - - /** - * Retrieves a JavaScript Date object representing January 1 of any given year. - * @method getJan1 - * @param {Number} calendarYear The calendar year for which to retrieve January 1 - * @return {Date} January 1 of the calendar year specified. - */ - getJan1 : function(calendarYear) { - return this.getDate(calendarYear,0,1); - }, - - /** - * Calculates the number of days the specified date is from January 1 of the specified calendar year. - * Passing January 1 to this function would return an offset value of zero. - * @method getDayOffset - * @param {Date} date The JavaScript date for which to find the offset - * @param {Number} calendarYear The calendar year to use for determining the offset - * @return {Number} The number of days since January 1 of the given year - */ - getDayOffset : function(date, calendarYear) { - var beginYear = this.getJan1(calendarYear); // Find the start of the year. This will be in week 1. - - // Find the number of days the passed in date is away from the calendar year start - var dayOffset = Math.ceil((date.getTime()-beginYear.getTime()) / this.ONE_DAY_MS); - return dayOffset; - }, - - /** - * Calculates the week number for the given date. This function assumes that week 1 is the - * week in which January 1 appears, regardless of whether the week consists of a full 7 days. - * The calendar year can be specified to help find what a the week number would be for a given - * date if the date overlaps years. For instance, a week may be considered week 1 of 2005, or - * week 53 of 2004. Specifying the optional calendarYear allows one to make this distinction - * easily. - * @method getWeekNumber - * @param {Date} date The JavaScript date for which to find the week number - * @param {Number} calendarYear OPTIONAL - The calendar year to use for determining the week number. Default is - * the calendar year of parameter "date". - * @return {Number} The week number of the given date. - */ - getWeekNumber : function(date, calendarYear) { - date = this.clearTime(date); - var nearestThurs = new Date(date.getTime() + (4 * this.ONE_DAY_MS) - ((date.getDay()) * this.ONE_DAY_MS)); - - 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); - return weekNum; - }, - - /** - * Determines if a given week overlaps two different years. - * @method isYearOverlapWeek - * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week. - * @return {Boolean} true if the date overlaps two different years. - */ - isYearOverlapWeek : function(weekBeginDate) { - var overlaps = false; - var nextWeek = this.add(weekBeginDate, this.DAY, 6); - if (nextWeek.getFullYear() != weekBeginDate.getFullYear()) { - overlaps = true; - } - return overlaps; - }, - - /** - * Determines if a given week overlaps two different months. - * @method isMonthOverlapWeek - * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week. - * @return {Boolean} true if the date overlaps two different months. - */ - isMonthOverlapWeek : function(weekBeginDate) { - var overlaps = false; - var nextWeek = this.add(weekBeginDate, this.DAY, 6); - if (nextWeek.getMonth() != weekBeginDate.getMonth()) { - overlaps = true; - } - return overlaps; - }, - - /** - * Gets the first day of a month containing a given date. - * @method findMonthStart - * @param {Date} date The JavaScript Date used to calculate the month start - * @return {Date} The JavaScript Date representing the first day of the month - */ - findMonthStart : function(date) { - var start = this.getDate(date.getFullYear(), date.getMonth(), 1); - return start; - }, - - /** - * Gets the last day of a month containing a given date. - * @method findMonthEnd - * @param {Date} date The JavaScript Date used to calculate the month end - * @return {Date} The JavaScript Date representing the last day of the month - */ - findMonthEnd : function(date) { - var start = this.findMonthStart(date); - var nextMonth = this.add(start, this.MONTH, 1); - var end = this.subtract(nextMonth, this.DAY, 1); - return end; - }, - - /** - * Clears the time fields from a given date, effectively setting the time to 12 noon. - * @method clearTime - * @param {Date} date The JavaScript Date for which the time fields will be cleared - * @return {Date} The JavaScript Date cleared of all time fields - */ - 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. -* @module calendar -* @title Calendar -* @namespace YAHOO.widget -* @requires yahoo,dom,event -*/ - -/** -* Calendar is the base class for the Calendar widget. In its most basic -* implementation, it has the ability to render a calendar widget on the page -* that can be manipulated to select a single date, move back and forth between -* months and years. -*To construct the placeholder for the calendar widget, the code is as -* follows: -*
-* NOTE: As of 2.4.0, the constructor's ID argument is optional. -* The Calendar can be constructed by simply providing a container ID string, -* or a reference to a container DIV HTMLElement (the element needs to exist -* in the document). -* -* E.g.: -*
-* If not provided, the ID will be generated from the container DIV ID by adding an "_t" suffix. -* For example if an ID is not provided, and the container's ID is "calContainer", the Calendar's ID will be set to "calContainer_t". -*
-* -* @namespace YAHOO.widget -* @class Calendar -* @constructor -* @param {String} id 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.apply(this, arguments); -}; - -/** -* The path to be used for images loaded for the Calendar -* @property YAHOO.widget.Calendar.IMG_ROOT -* @static -* @deprecated You can now customize images by overriding the calclose, calnavleft and calnavright default CSS classes for the close icon, left arrow and right arrow respectively -* @type String -*/ -YAHOO.widget.Calendar.IMG_ROOT = null; - -/** -* Type constant used for renderers to represent an individual date (M/D/Y) -* @property YAHOO.widget.Calendar.DATE -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.DATE = "D"; - -/** -* Type constant used for renderers to represent an individual date across any year (M/D) -* @property YAHOO.widget.Calendar.MONTH_DAY -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.MONTH_DAY = "MD"; - -/** -* Type constant used for renderers to represent a weekday -* @property YAHOO.widget.Calendar.WEEKDAY -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.WEEKDAY = "WD"; - -/** -* Type constant used for renderers to represent a range of individual dates (M/D/Y-M/D/Y) -* @property YAHOO.widget.Calendar.RANGE -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.RANGE = "R"; - -/** -* Type constant used for renderers to represent a month across any year -* @property YAHOO.widget.Calendar.MONTH -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.MONTH = "M"; - -/** -* Constant that represents the total number of date cells that are displayed in a given month -* @property YAHOO.widget.Calendar.DISPLAY_DAYS -* @static -* @final -* @type Number -*/ -YAHOO.widget.Calendar.DISPLAY_DAYS = 42; - -/** -* Constant used for halting the execution of the remainder of the render stack -* @property YAHOO.widget.Calendar.STOP_RENDER -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.STOP_RENDER = "S"; - -/** -* Constant used to represent short date field string formats (e.g. Tu or Feb) -* @property YAHOO.widget.Calendar.SHORT -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.SHORT = "short"; - -/** -* Constant used to represent long date field string formats (e.g. Monday or February) -* @property YAHOO.widget.Calendar.LONG -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.LONG = "long"; - -/** -* Constant used to represent medium date field string formats (e.g. Mon) -* @property YAHOO.widget.Calendar.MEDIUM -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.MEDIUM = "medium"; - -/** -* Constant used to represent single character date field string formats (e.g. M, T, W) -* @property YAHOO.widget.Calendar.ONE_CHAR -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.ONE_CHAR = "1char"; - -/** -* The set of default Config property keys and values for the Calendar -* @property YAHOO.widget.Calendar._DEFAULT_CONFIG -* @final -* @static -* @private -* @type Object -*/ -YAHOO.widget.Calendar._DEFAULT_CONFIG = { - // Default values for pagedate and selected are not class level constants - they are set during instance creation - PAGEDATE : {key:"pagedate", value:null}, - SELECTED : {key:"selected", value:null}, - TITLE : {key:"title", value:""}, - CLOSE : {key:"close", value:false}, - IFRAME : {key:"iframe", value:(YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) ? true : false}, - MINDATE : {key:"mindate", value:null}, - MAXDATE : {key:"maxdate", value:null}, - MULTI_SELECT : {key:"multi_select", value:false}, - START_WEEKDAY : {key:"start_weekday", value:0}, - SHOW_WEEKDAYS : {key:"show_weekdays", value:true}, - SHOW_WEEK_HEADER : {key:"show_week_header", value:false}, - SHOW_WEEK_FOOTER : {key:"show_week_footer", value:false}, - HIDE_BLANK_WEEKS : {key:"hide_blank_weeks", value:false}, - NAV_ARROW_LEFT: {key:"nav_arrow_left", value:null} , - NAV_ARROW_RIGHT : {key:"nav_arrow_right", value:null} , - MONTHS_SHORT : {key:"months_short", value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]}, - MONTHS_LONG: {key:"months_long", value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]}, - WEEKDAYS_1CHAR: {key:"weekdays_1char", value:["S", "M", "T", "W", "T", "F", "S"]}, - WEEKDAYS_SHORT: {key:"weekdays_short", value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]}, - WEEKDAYS_MEDIUM: {key:"weekdays_medium", value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]}, - WEEKDAYS_LONG: {key:"weekdays_long", value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]}, - LOCALE_MONTHS:{key:"locale_months", value:"long"}, - LOCALE_WEEKDAYS:{key:"locale_weekdays", value:"short"}, - DATE_DELIMITER:{key:"date_delimiter", value:","}, - DATE_FIELD_DELIMITER:{key:"date_field_delimiter", value:"/"}, - DATE_RANGE_DELIMITER:{key:"date_range_delimiter", value:"-"}, - MY_MONTH_POSITION:{key:"my_month_position", value:1}, - MY_YEAR_POSITION:{key:"my_year_position", value:2}, - MD_MONTH_POSITION:{key:"md_month_position", value:1}, - MD_DAY_POSITION:{key:"md_day_position", value:2}, - MDY_MONTH_POSITION:{key:"mdy_month_position", value:1}, - MDY_DAY_POSITION:{key:"mdy_day_position", value:2}, - MDY_YEAR_POSITION:{key:"mdy_year_position", value:3}, - 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:""}, - NAV: {key:"navigator", value: null} -}; - -/** -* The set of Custom Event types supported by the Calendar -* @property YAHOO.widget.Calendar._EVENT_TYPES -* @final -* @static -* @private -* @type Object -*/ -YAHOO.widget.Calendar._EVENT_TYPES = { - BEFORE_SELECT : "beforeSelect", - SELECT : "select", - BEFORE_DESELECT : "beforeDeselect", - DESELECT : "deselect", - CHANGE_PAGE : "changePage", - BEFORE_RENDER : "beforeRender", - RENDER : "render", - RESET : "reset", - 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" -}; - -/** -* The set of default style constants for the Calendar -* @property YAHOO.widget.Calendar._STYLES -* @final -* @static -* @private -* @type Object -*/ -YAHOO.widget.Calendar._STYLES = { - CSS_ROW_HEADER: "calrowhead", - CSS_ROW_FOOTER: "calrowfoot", - CSS_CELL : "calcell", - CSS_CELL_SELECTOR : "selector", - CSS_CELL_SELECTED : "selected", - CSS_CELL_SELECTABLE : "selectable", - CSS_CELL_RESTRICTED : "restricted", - CSS_CELL_TODAY : "today", - CSS_CELL_OOM : "oom", - CSS_CELL_OOB : "previous", - CSS_HEADER : "calheader", - CSS_HEADER_TEXT : "calhead", - CSS_BODY : "calbody", - CSS_WEEKDAY_CELL : "calweekdaycell", - CSS_WEEKDAY_ROW : "calweekdayrow", - CSS_FOOTER : "calfoot", - CSS_CALENDAR : "yui-calendar", - CSS_SINGLE : "single", - 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", - CSS_CELL_RIGHT : "calcellright", - CSS_CELL_BOTTOM : "calcellbottom", - CSS_CELL_HOVER : "calcellhover", - CSS_CELL_HIGHLIGHT1 : "highlight1", - CSS_CELL_HIGHLIGHT2 : "highlight2", - CSS_CELL_HIGHLIGHT3 : "highlight3", - CSS_CELL_HIGHLIGHT4 : "highlight4" -}; - -YAHOO.widget.Calendar.prototype = { - - /** - * The configuration object used to set up the calendars various locale and style options. - * @property Config - * @private - * @deprecated Configuration properties should be set by calling Calendar.cfg.setProperty. - * @type Object - */ - Config : null, - - /** - * The parent CalendarGroup, only to be set explicitly by the parent group - * @property parent - * @type CalendarGroup - */ - parent : null, - - /** - * The index of this item in the parent group - * @property index - * @type Number - */ - index : -1, - - /** - * The collection of calendar table cells - * @property cells - * @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 - * @type Array[](Number[]) - */ - cellDates : null, - - /** - * 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 - * @type HTMLElement - */ - oDomContainer : null, - - /** - * A Date object representing today's date. - * @property today - * @type Date - */ - today : null, - - /** - * The list of render functions, along with required parameters, used to render cells. - * @property renderStack - * @type Array[] - */ - renderStack : null, - - /** - * A copy of the initial render functions created before rendering. - * @property _renderStack - * @private - * @type Array - */ - _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 - * @private - * @type Array - */ - _selectedDates : null, - - /** - * A map of DOM event handlers to attach to cells associated with specific CSS class names - * @property domEventMap - * @type Object - */ - 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; - } - break; - default: // 3+ - nArgs.id = args[0]; - nArgs.container = args[1]; - nArgs.config = args[2]; - break; - } - } else { - } - return nArgs; - }, - - /** - * 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); - - id = nArgs.id; - container = nArgs.container; - config = nArgs.config; - - this.oDomContainer = YAHOO.util.Dom.get(container); - - if (!this.oDomContainer.id) { - this.oDomContainer.id = YAHOO.util.Dom.generateId(); - } - if (!id) { - id = this.oDomContainer.id + "_t"; - } - - this.id = id; - this.containerId = this.oDomContainer.id; - - this.initEvents(); - - this.today = new Date(); - YAHOO.widget.DateMath.clearTime(this.today); - - /** - * 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 - */ - 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; - } - } - } - } - }, - - /** - * Default handler for the "title" property - * @method configTitle - */ - configTitle : function(type, args, obj) { - var title = args[0]; - - // "" 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(" "); - } - } - }, - - /** - * 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(" "); - } - this.createCloseButton(); - } else { - this.removeCloseButton(); - if (!title) { - this.removeTitleBar(); - } - } - }, - - /** - * Initializes Calendar's built-in CustomEvents - * @method initEvents - */ - initEvents : function() { - - var defEvents = YAHOO.widget.Calendar._EVENT_TYPES; - - /** - * Fired before a selection is made - * @event beforeSelectEvent - */ - this.beforeSelectEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_SELECT); - - /** - * 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); - - /** - * Fired before a selection is made - * @event beforeDeselectEvent - */ - this.beforeDeselectEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_DESELECT); - - /** - * 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); - - /** - * Fired when the Calendar page is changed - * @event changePageEvent - */ - this.changePageEvent = new YAHOO.util.CustomEvent(defEvents.CHANGE_PAGE); - - /** - * Fired before the Calendar is rendered - * @event beforeRenderEvent - */ - this.beforeRenderEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_RENDER); - - /** - * Fired when the Calendar is rendered - * @event renderEvent - */ - this.renderEvent = new YAHOO.util.CustomEvent(defEvents.RENDER); - - /** - * Fired when the Calendar is reset - * @event resetEvent - */ - this.resetEvent = new YAHOO.util.CustomEvent(defEvents.RESET); - - /** - * Fired when the Calendar is cleared - * @event clearEvent - */ - this.clearEvent = new YAHOO.util.CustomEvent(defEvents.CLEAR); - - /** - * Fired just before the Calendar is to be shown - * @event beforeShowEvent - */ - this.beforeShowEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_SHOW); - - /** - * Fired after the Calendar is shown - * @event showEvent - */ - this.showEvent = new YAHOO.util.CustomEvent(defEvents.SHOW); - - /** - * Fired just before the Calendar is to be hidden - * @event beforeHideEvent - */ - this.beforeHideEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_HIDE); - - /** - * Fired after the Calendar is hidden - * @event hideEvent - */ - this.hideEvent = new YAHOO.util.CustomEvent(defEvents.HIDE); - - /** - * Fired just before the CalendarNavigator is to be shown - * @event beforeShowNavEvent - */ - this.beforeShowNavEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_SHOW_NAV); - - /** - * Fired after the CalendarNavigator is shown - * @event showNavEvent - */ - this.showNavEvent = new YAHOO.util.CustomEvent(defEvents.SHOW_NAV); - - /** - * Fired just before the CalendarNavigator is to be hidden - * @event beforeHideNavEvent - */ - this.beforeHideNavEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_HIDE_NAV); - - /** - * Fired after the CalendarNavigator is hidden - * @event hideNavEvent - */ - this.hideNavEvent = new YAHOO.util.CustomEvent(defEvents.HIDE_NAV); - - /** - * Fired just before the CalendarNavigator is to be rendered - * @event beforeRenderNavEvent - */ - this.beforeRenderNavEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_RENDER_NAV); - - /** - * Fired after the CalendarNavigator is rendered - * @event renderNavEvent - */ - this.renderNavEvent = new YAHOO.util.CustomEvent(defEvents.RENDER_NAV); - - 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 - */ - 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)) { - - if (!defSelector && tagName == "a" && YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTOR)) { - defSelector = true; - } - - target = target.parentNode; - tagName = target.tagName.toLowerCase(); - // TODO: No need to go all the way up to html. - if (tagName == "html") { - return; - } - } - - 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 = YAHOO.widget.DateMath.getDate(d[0],d[1]-1,d[2]); - - var link; - - if (cal.Options.MULTI_SELECT) { - link = cell.getElementsByTagName("a")[0]; - if (link) { - link.blur(); - } - - var cellDate = cal.cellDates[index]; - var cellDateIndex = cal._indexOfSelectedFieldArray(cellDate); - - if (cellDateIndex > -1) { - cal.deselectCell(index); - } else { - cal.selectCell(index); - } - - } else { - link = cell.getElementsByTagName("a")[0]; - if (link) { - link.blur(); - } - 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 - */ - doCellMouseOver : function(e, cal) { - var target; - if (e) { - target = YAHOO.util.Event.getTarget(e); - } else { - target = this; - } - - while (target.tagName && target.tagName.toLowerCase() != "td") { - target = target.parentNode; - if (!target.tagName || 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 - */ - doCellMouseOut : function(e, cal) { - var target; - if (e) { - target = YAHOO.util.Event.getTarget(e); - } else { - target = this; - } - - while (target.tagName && target.tagName.toLowerCase() != "td") { - target = target.parentNode; - if (!target.tagName || 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); - } - }, - - 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 " " - */ - 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 } ); - - /** - * Configuration for the Month/Year CalendarNavigator UI which allows the user to jump directly to a - * specific Month/Year without having to scroll sequentially through months. - *- * 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). - *
- *E.g.
- *- * var navConfig = { - * strings: { - * month:"Calendar Month", - * year:"Calendar Year", - * submit: "Submit", - * cancel: "Cancel", - * invalidYear: "Please enter a valid year" - * }, - * monthFormat: YAHOO.widget.Calendar.SHORT, - * initialFocus: "month" - * } - *- * @config navigator - * @type {Object|Boolean} - * @default null - */ - this.cfg.addProperty(defCfg.NAV.key, { value:defCfg.NAV.value, handler:this.configNavigator } ); - }, - - /** - * The default handler for the "pagedate" property - * @method configPageDate - */ - configPageDate : function(type, args, obj) { - this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key, this._parsePageDate(args[0]), true); - }, - - /** - * The default handler for the "mindate" property - * @method configMinDate - */ - configMinDate : function(type, args, obj) { - var val = args[0]; - if (YAHOO.lang.isString(val)) { - val = this._parseDate(val); - this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MINDATE.key, YAHOO.widget.DateMath.getDate(val[0],(val[1]-1),val[2])); - } - }, - - /** - * The default handler for the "maxdate" property - * @method configMaxDate - */ - configMaxDate : function(type, args, obj) { - var val = args[0]; - if (YAHOO.lang.isString(val)) { - val = this._parseDate(val); - this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MAXDATE.key, YAHOO.widget.DateMath.getDate(val[0],(val[1]-1),val[2])); - } - }, - - /** - * The default handler for the "selected" property - * @method configSelected - */ - configSelected : function(type, args, obj) { - var selected = args[0]; - var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key; - - if (selected) { - if (YAHOO.lang.isString(selected)) { - this.cfg.setProperty(cfgSelected, this._parseDates(selected), true); - } - } - if (! this._selectedDates) { - this._selectedDates = this.cfg.getProperty(cfgSelected); - } - }, - - /** - * The default handler for all configuration options properties - * @method configOptions - */ - configOptions : function(type, args, obj) { - this.Options[type.toUpperCase()] = args[0]; - }, - - /** - * The default handler for all configuration locale properties - * @method configLocale - */ - configLocale : function(type, args, obj) { - var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; - this.Locale[type.toUpperCase()] = args[0]; - - this.cfg.refireEvent(defCfg.LOCALE_MONTHS.key); - this.cfg.refireEvent(defCfg.LOCALE_WEEKDAYS.key); - }, - - /** - * The default handler for all configuration locale field length properties - * @method configLocaleValues - */ - configLocaleValues : function(type, args, obj) { - var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; - - type = type.toLowerCase(); - var val = args[0]; - - switch (type) { - case defCfg.LOCALE_MONTHS.key: - switch (val) { - case YAHOO.widget.Calendar.SHORT: - this.Locale.LOCALE_MONTHS = this.cfg.getProperty(defCfg.MONTHS_SHORT.key).concat(); - break; - case YAHOO.widget.Calendar.LONG: - this.Locale.LOCALE_MONTHS = this.cfg.getProperty(defCfg.MONTHS_LONG.key).concat(); - break; - } - 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
- * 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] = '-* NOTE: As of 2.4.0, the constructor's ID argument is optional. -* The CalendarGroup can be constructed by simply providing a container ID string, -* or a reference to a container DIV HTMLElement (the element needs to exist -* in the document). -* -* E.g.: -*
-* If not provided, the ID will be generated from the container DIV ID by adding an "_t" suffix. -* For example if an ID is not provided, and the container's ID is "calContainer", the CalendarGroup's ID will be set to "calContainer_t". -*
-* -* @namespace YAHOO.widget -* @class CalendarGroup -* @constructor -* @param {String} id optional The id of the table element that will represent the CalendarGroup widget. As of 2.4.0, this argument is optional. -* @param {String | HTMLElement} container The id of the container div element that will wrap the CalendarGroup table, or a reference to a DIV element which exists in the document. -* @param {Object} config optional The configuration object containing the initial configuration values for the CalendarGroup. -*/ -YAHOO.widget.CalendarGroup = function(id, containerId, config) { - if (arguments.length > 0) { - this.init.apply(this, arguments); - } -}; - -YAHOO.widget.CalendarGroup.prototype = { - - /** - * 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) { - - // Normalize 2.4.0, pre 2.4.0 args - var nArgs = this._parseArgs(arguments); - - id = nArgs.id; - container = nArgs.container; - config = nArgs.config; - - this.oDomContainer = YAHOO.util.Dom.get(container); - - if (!this.oDomContainer.id) { - this.oDomContainer.id = YAHOO.util.Dom.generateId(); - } - if (!id) { - id = this.oDomContainer.id + "_t"; - } - - /** - * 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 = this.oDomContainer.id; - - this.initEvents(); - this.initStyles(); - - /** - * The collection of Calendar pages contained within the CalendarGroup - * @property pages - * @type YAHOO.widget.Calendar[] - */ - this.pages = []; - - 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.showEvent.subscribe(this._fixWidth, this, true); - } - - }, - - 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 } ); - - /** - * 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 CalendarGroup'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 CalendarGroup - * @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.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 } ); - - /** - * 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 } ); - }, - - /** - * Initializes CalendarGroup's built-in CustomEvents - * @method initEvents - */ - initEvents : function() { - var me = this; - var strEvent = "Event"; - - /** - * 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- * The method is also registered as an HTMLElement resize listener on the Calendars container element. - *
- * @protected - * @method _syncMask - */ - _syncMask : function() { - var c = this.cal.oDomContainer; - if (c && this.maskEl) { - var r = YAHOO.util.Dom.getRegion(c); - YAHOO.util.Dom.setStyle(this.maskEl, "width", r.right - r.left + "px"); - YAHOO.util.Dom.setStyle(this.maskEl, "height", r.bottom - r.top + "px"); - } - }, - - /** - * Renders the contents of the navigator - * - * @method renderNavContents - * - * @param {Array} html The HTML buffer to append the HTML to. - * @return {Array} A reference to the buffer passed in. - */ - renderNavContents : function(html) { - var NAV = YAHOO.widget.CalendarNavigator, - C = NAV.CLASSES, - h = html; // just to use a shorter name - - h[h.length] = '- * The method will call applyKeyListeners, to setup keyboard specific - * listeners - *
- * @method applyListeners - */ - applyListeners : function() { - var E = YAHOO.util.Event; - - function yearUpdateHandler() { - if (this.validate()) { - this.setYear(this._getYearFromUI()); - } - } - - function monthUpdateHandler() { - this.setMonth(this._getMonthFromUI()); - } - - E.on(this.submitEl, "click", this.submit, this, true); - E.on(this.cancelEl, "click", this.cancel, this, true); - E.on(this.yearEl, "blur", yearUpdateHandler, this, true); - E.on(this.monthEl, "change", monthUpdateHandler, this, true); - - if (this.__isIEQuirks) { - YAHOO.util.Event.on(this.cal.oDomContainer, "resize", this._syncMask, this, true); - } - - this.applyKeyListeners(); - }, - - /** - * Removes/purges DOM event listeners from the rendered elements - * - * @method purgeListeners - */ - purgeListeners : function() { - var E = YAHOO.util.Event; - E.removeListener(this.submitEl, "click", this.submit); - E.removeListener(this.cancelEl, "click", this.cancel); - E.removeListener(this.yearEl, "blur"); - E.removeListener(this.monthEl, "change"); - if (this.__isIEQuirks) { - E.removeListener(this.cal.oDomContainer, "resize", this._syncMask); - } - - this.purgeKeyListeners(); - }, - - /** - * Attaches DOM listeners for keyboard support. - * Tab/Shift-Tab looping, Enter Key Submit on Year element, - * Up/Down/PgUp/PgDown year increment on Year element - *- * NOTE: MacOSX Safari 2.x doesn't let you tab to buttons and - * MacOSX Gecko does not let you tab to buttons or select controls, - * so for these browsers, Tab/Shift-Tab looping is limited to the - * elements which can be reached using the tab key. - *
- * @method applyKeyListeners - */ - applyKeyListeners : function() { - var E = YAHOO.util.Event; - - // IE doesn't fire keypress for arrow/pg keys (non-char keys) - var ua = YAHOO.env.ua; - var arrowEvt = (ua.ie) ? "keydown" : "keypress"; - - // - IE doesn't fire keypress for non-char keys - // - Opera doesn't allow us to cancel keydown or keypress for tab, but - // changes focus successfully on keydown (keypress is too late to change focus - opera's already moved on). - var tabEvt = (ua.ie || ua.opera) ? "keydown" : "keypress"; - - // Everyone likes keypress for Enter (char keys) - whoo hoo! - E.on(this.yearEl, "keypress", this._handleEnterKey, this, true); - - E.on(this.yearEl, arrowEvt, this._handleDirectionKeys, this, true); - E.on(this.lastCtrl, tabEvt, this._handleTabKey, this, true); - E.on(this.firstCtrl, tabEvt, this._handleShiftTabKey, this, true); - }, - - /** - * Removes/purges DOM listeners for keyboard support - * - * @method purgeKeyListeners - */ - purgeKeyListeners : function() { - var E = YAHOO.util.Event; - - var arrowEvt = (YAHOO.env.ua.ie) ? "keydown" : "keypress"; - var tabEvt = (YAHOO.env.ua.ie || YAHOO.env.ua.opera) ? "keydown" : "keypress"; - - E.removeListener(this.yearEl, "keypress", this._handleEnterKey); - E.removeListener(this.yearEl, arrowEvt, this._handleDirectionKeys); - E.removeListener(this.lastCtrl, tabEvt, this._handleTabKey); - E.removeListener(this.firstCtrl, tabEvt, this._handleShiftTabKey); - }, - - /** - * Updates the Calendar/CalendarGroup's pagedate with the currently set month and year if valid. - *- * If the currently set month/year is invalid, a validation error will be displayed and the - * Calendar/CalendarGroup's pagedate will not be updated. - *
- * @method submit - */ - submit : function() { - if (this.validate()) { - this.hide(); - - this.setMonth(this._getMonthFromUI()); - this.setYear(this._getYearFromUI()); - - var cal = this.cal; - var nav = this; - - function update() { - cal.setYear(nav.getYear()); - cal.setMonth(nav.getMonth()); - cal.render(); - } - // Artificial delay, just to help the user see something changed - var delay = YAHOO.widget.CalendarNavigator.UPDATE_DELAY; - if (delay > 0) { - window.setTimeout(update, delay); - } else { - update(); - } - } - }, - - /** - * Hides the navigator and mask, without updating the Calendar/CalendarGroup's state - * - * @method cancel - */ - cancel : function() { - this.hide(); - }, - - /** - * Validates the current state of the UI controls - * - * @method validate - * @return {Boolean} true, if the current UI state contains valid values, false if not - */ - validate : function() { - if (this._getYearFromUI() !== null) { - this.clearErrors(); - return true; - } else { - this.setYearError(); - this.setError(this.__getCfg("invalidYear", true)); - return false; - } - }, - - /** - * Displays an error message in the Navigator's error panel - * @method setError - * @param {String} msg The error message to display - */ - setError : function(msg) { - if (this.errorEl) { - this.errorEl.innerHTML = msg; - this._show(this.errorEl, true); - } - }, - - /** - * Clears the navigator's error message and hides the error panel - * @method clearError - */ - clearError : function() { - if (this.errorEl) { - this.errorEl.innerHTML = ""; - this._show(this.errorEl, false); - } - }, - - /** - * Displays the validation error UI for the year control - * @method setYearError - */ - setYearError : function() { - YAHOO.util.Dom.addClass(this.yearEl, YAHOO.widget.CalendarNavigator.CLASSES.INVALID); - }, - - /** - * Removes the validation error UI for the year control - * @method clearYearError - */ - clearYearError : function() { - YAHOO.util.Dom.removeClass(this.yearEl, YAHOO.widget.CalendarNavigator.CLASSES.INVALID); - }, - - /** - * Clears all validation and error messages in the UI - * @method clearErrors - */ - clearErrors : function() { - this.clearError(); - this.clearYearError(); - }, - - /** - * Sets the initial focus, based on the configured value - * @method setInitialFocus - */ - setInitialFocus : function() { - var el = this.submitEl; - var f = this.__getCfg("initialFocus"); - - if (f && f.toLowerCase) { - f = f.toLowerCase(); - if (f == "year") { - el = this.yearEl; - try { - this.yearEl.select(); - } catch (e) { - // Ignore; - } - } else if (f == "month") { - el = this.monthEl; - } - } - - if (el && YAHOO.lang.isFunction(el.focus)) { - try { - el.focus(); - } catch (e) { - // TODO: Fall back if focus fails? - } - } - }, - - /** - * Removes all renderered HTML elements for the Navigator from - * the DOM, purges event listeners and clears (nulls) any property - * references to HTML references - * @method erase - */ - erase : function() { - if (this.__rendered) { - this.purgeListeners(); - - // Clear out innerHTML references - this.yearEl = null; - this.monthEl = null; - this.errorEl = null; - this.submitEl = null; - this.cancelEl = null; - this.firstCtrl = null; - this.lastCtrl = null; - if (this.navEl) { - this.navEl.innerHTML = ""; - } - - var p = this.navEl.parentNode; - if (p) { - p.removeChild(this.navEl); - } - this.navEl = null; - - var pm = this.maskEl.parentNode; - if (pm) { - pm.removeChild(this.maskEl); - } - this.maskEl = null; - this.__rendered = false; - } - }, - - /** - * Destroys the Navigator object and any HTML references - * @method destroy - */ - destroy : function() { - this.erase(); - this._doc = null; - this.cal = null; - this.id = null; - }, - - /** - * Protected implementation to handle how UI elements are - * hidden/shown. - * - * @method _show - * @protected - */ - _show : function(el, bShow) { - if (el) { - YAHOO.util.Dom.setStyle(el, "display", (bShow) ? "block" : "none"); - } - }, - - /** - * Returns the month value (index), from the month UI element - * @protected - * @method _getMonthFromUI - * @return {Number} The month index, or 0 if a UI element for the month - * is not found - */ - _getMonthFromUI : function() { - if (this.monthEl) { - return this.monthEl.selectedIndex; - } else { - return 0; // Default to Jan - } - }, - - /** - * Returns the year value, from the Navitator's year UI element - * @protected - * @method _getYearFromUI - * @return {Number} The year value set in the UI, if valid. null is returned if - * the UI does not contain a valid year value. - */ - _getYearFromUI : function() { - var NAV = YAHOO.widget.CalendarNavigator; - - var yr = null; - if (this.yearEl) { - var value = this.yearEl.value; - value = value.replace(NAV.TRIM, "$1"); - - if (NAV.YR_PATTERN.test(value)) { - yr = parseInt(value, 10); - } - } - return yr; - }, - - /** - * Updates the Navigator's year UI, based on the year value set on the Navigator object - * @protected - * @method _updateYearUI - */ - _updateYearUI : function() { - if (this.yearEl && this._year !== null) { - this.yearEl.value = this._year; - } - }, - - /** - * Updates the Navigator's month UI, based on the month value set on the Navigator object - * @protected - * @method _updateMonthUI - */ - _updateMonthUI : function() { - if (this.monthEl) { - this.monthEl.selectedIndex = this._month; - } - }, - - /** - * Sets up references to the first and last focusable element in the Navigator's UI - * in terms of tab order (Naviagator's firstEl and lastEl properties). The references - * are used to control modality by looping around from the first to the last control - * and visa versa for tab/shift-tab navigation. - *- * See applyKeyListeners - *
- * @protected - * @method _setFirstLastElements - */ - _setFirstLastElements : function() { - this.firstCtrl = this.monthEl; - this.lastCtrl = this.cancelEl; - - // Special handling for MacOSX. - // - Safari 2.x can't focus on buttons - // - Gecko can't focus on select boxes or buttons - if (this.__isMac) { - if (YAHOO.env.ua.webkit && YAHOO.env.ua.webkit < 420){ - this.firstCtrl = this.monthEl; - this.lastCtrl = this.yearEl; - } - if (YAHOO.env.ua.gecko) { - this.firstCtrl = this.yearEl; - this.lastCtrl = this.yearEl; - } - } - }, - - /** - * Default Keyboard event handler to capture Enter - * on the Navigator's year control (yearEl) - * - * @method _handleEnterKey - * @protected - * @param {Event} e The DOM event being handled - */ - _handleEnterKey : function(e) { - var KEYS = YAHOO.util.KeyListener.KEY; - - if (YAHOO.util.Event.getCharCode(e) == KEYS.ENTER) { - YAHOO.util.Event.preventDefault(e); - this.submit(); - } - }, - - /** - * Default Keyboard event handler to capture up/down/pgup/pgdown - * on the Navigator's year control (yearEl). - * - * @method _handleDirectionKeys - * @protected - * @param {Event} e The DOM event being handled - */ - _handleDirectionKeys : function(e) { - var E = YAHOO.util.Event; - var KEYS = YAHOO.util.KeyListener.KEY; - var NAV = YAHOO.widget.CalendarNavigator; - - var value = (this.yearEl.value) ? parseInt(this.yearEl.value, 10) : null; - if (isFinite(value)) { - var dir = false; - switch(E.getCharCode(e)) { - case KEYS.UP: - this.yearEl.value = value + NAV.YR_MINOR_INC; - dir = true; - break; - case KEYS.DOWN: - this.yearEl.value = Math.max(value - NAV.YR_MINOR_INC, 0); - dir = true; - break; - case KEYS.PAGE_UP: - this.yearEl.value = value + NAV.YR_MAJOR_INC; - dir = true; - break; - case KEYS.PAGE_DOWN: - this.yearEl.value = Math.max(value - NAV.YR_MAJOR_INC, 0); - dir = true; - break; - default: - break; - } - if (dir) { - E.preventDefault(e); - try { - this.yearEl.select(); - } catch(e) { - // Ignore - } - } - } - }, - - /** - * Default Keyboard event handler to capture Tab - * on the last control (lastCtrl) in the Navigator. - * - * @method _handleTabKey - * @protected - * @param {Event} e The DOM event being handled - */ - _handleTabKey : function(e) { - var E = YAHOO.util.Event; - var KEYS = YAHOO.util.KeyListener.KEY; - - if (E.getCharCode(e) == KEYS.TAB && !e.shiftKey) { - try { - E.preventDefault(e); - this.firstCtrl.focus(); - } catch (e) { - // Ignore - mainly for focus edge cases - } - } - }, - - /** - * Default Keyboard event handler to capture Shift-Tab - * on the first control (firstCtrl) in the Navigator. - * - * @method _handleShiftTabKey - * @protected - * @param {Event} e The DOM event being handled - */ - _handleShiftTabKey : function(e) { - var E = YAHOO.util.Event; - var KEYS = YAHOO.util.KeyListener.KEY; - - if (e.shiftKey && E.getCharCode(e) == KEYS.TAB) { - try { - E.preventDefault(e); - this.lastCtrl.focus(); - } catch (e) { - // Ignore - mainly for focus edge cases - } - } - }, - - /** - * Retrieve Navigator configuration values from - * the parent Calendar/CalendarGroup's config value. - *- * If it has not been set in the user provided configuration, the method will - * return the default value of the configuration property, as set in _DEFAULT_CFG - *
- * @private - * @method __getCfg - * @param {String} Case sensitive property name. - * @param {Boolean} true, if the property is a string property, false if not. - * @return The value of the configuration property - */ - __getCfg : function(prop, bIsStr) { - var DEF_CFG = YAHOO.widget.CalendarNavigator._DEFAULT_CFG; - var cfg = this.cal.cfg.getProperty("navigator"); - - if (bIsStr) { - return (cfg !== true && cfg.strings && cfg.strings[prop]) ? cfg.strings[prop] : DEF_CFG.strings[prop]; - } else { - return (cfg !== true && cfg[prop]) ? cfg[prop] : DEF_CFG[prop]; - } - }, - - /** - * Private flag, to identify MacOS - * @private - * @property __isMac - */ - __isMac : (navigator.userAgent.toLowerCase().indexOf("macintosh") != -1) - -}; - -YAHOO.register("calendar", YAHOO.widget.Calendar, {version: "2.5.0", build: "895"}); diff --git a/lib/yui/colorpicker/assets/colorpicker_core.css b/lib/yui/colorpicker/assets/colorpicker_core.css deleted file mode 100755 index a6742cc627..0000000000 --- a/lib/yui/colorpicker/assets/colorpicker_core.css +++ /dev/null @@ -1,6 +0,0 @@ -/* -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 -*/ diff --git a/lib/yui/colorpicker/assets/hue_thumb.png b/lib/yui/colorpicker/assets/hue_thumb.png deleted file mode 100755 index 14d5db4862..0000000000 Binary files a/lib/yui/colorpicker/assets/hue_thumb.png and /dev/null differ diff --git a/lib/yui/colorpicker/assets/picker_mask.png b/lib/yui/colorpicker/assets/picker_mask.png deleted file mode 100755 index f8d91932b3..0000000000 Binary files a/lib/yui/colorpicker/assets/picker_mask.png and /dev/null differ diff --git a/lib/yui/colorpicker/assets/picker_thumb.png b/lib/yui/colorpicker/assets/picker_thumb.png deleted file mode 100755 index 78445a2fe0..0000000000 Binary files a/lib/yui/colorpicker/assets/picker_thumb.png and /dev/null differ diff --git a/lib/yui/connection/README b/lib/yui/connection/README deleted file mode 100755 index a4116f0ac3..0000000000 --- a/lib/yui/connection/README +++ /dev/null @@ -1,267 +0,0 @@ -Connection Manager Release Notes - -*** version 2.5.0 *** - -* setForm() can now detects HTTPS in the URI for file upload transactions. The -third, boolean argument for HTTPS when using IE is no longer necessary. - -* [FIXED] SF1882101. POST transactions without a message will now have a -Content-Length value set to 0 for FF 2.x. This is accomplished by passing a -value of empty string instead of null to XHR's send(). All other A-Grade -browsers remain unaffected and perform correctly. - -*** version 2.4.0 *** - -* [FIXED] SF1804153. Transactions initialized with setForm() now properly clear -the POST data field after each transaction. - -* The callback object can accept a new member, cache, defined with a boolean -value. If set to false (e.g., var callback = { cache:false };), a timestamp -will be appended to the URI to override HTTP GET caching. This timestamp value -will appear as rnd=timestamp in the request querystring. - -* Custom Events startEvent, completeEvent, and abortEvent now receive -callback.argument, if defined, in addition to the transaction ID. Each Custom -Event's function handler receives two arguments -- the event type as the first -argument, and an array as the second argument. The first element in the array -is the transaction ID, and the second element are any arguments defined in the -callback object. - -*** version 2.3.1 *** - -* setDefaultPostHeader() can now be overloaded with a boolean, string, or -number. By default, POST transactions send the following Content-Type header: -'application/x-www-form-urlencoded; charset=UTF-8'. - -A custom Content-Type header can now be set by passing its value to -setDefaultPostHeader(). - -* HTML form submissions now send a Content-Type header of "application/x-www- -form-urlencoded", omitting the charset=UTF-8 value. - -* setDefaultXhrHeader() can now be overloaded with a boolean, string, or number. -By default, all transactions send a custom header of "X-Requested- -With:XMLHttpRequest". - -This default header value can be overridden by passing the desired value as an -argument to setDefaultPostHeader(). - -* The file upload iframe's event listener is now explicitly removed before the -iframe is destroyed. - -*** version 2.3.0 *** - -* Custom Events are introduced in Connection Manager. These events -- for a -non-file upload transaction -- are: - - * startEvent - * completeEvent - * successEvent - * failureEvent - * abortEvent - -For transactions involving file upload with an HTML form, the events are: - - * startEvent - * completeEvent - * uploadEvent - * abortEvent - -* Event utility is a now Connection Manager dependency. - -* abort() and isCallInProgress() are now functional for file upload -transactions. - -* NOTE: The native XHR implementation in Safari 2.0.4 has been confirmed to leak -memory. - -* UPDATE: The XHR implementation in Safari 3.0 beta(and WebKit builds) now -appear to handle HTTP 204 responses correctly. XHR in Opera, as of 9.21, still -does not produce a valid HTTP status code with an HTTP 204 response. - -*** version 2.2.2 *** - -* No revisions. - -*** version 2.2.1 *** - -* setForm() will include the correct name-value of the HTML Submit button -clicked where multiple HTML Submit button options are present in an HTML form. -To enable this feature, include the Event utility source file as a dependency -before the Connection Manager source file. - -* The XHR implementation in IE6 and IE7, Opera, and Safari do not properly -handle an HTTP 204 response. IE6/7 will instead return a Win error 1223. -handleTransactionResponse() will treat 1223 as an HTTP 204, and route the -response appropriately to the success callback. createResponseObject() will -normalize the response object's status and statusText values to 204 and "No -Content" respectively. However, no headers are returned. - -Opera and Safari provide no discernable response with HTTP 204(e.g., response -object's properties are undefined). This response will trigger the failure -callback with a status of 0 and statusText of "communication failure". - -*** version 2.2.0 *** - -* initHeader() now accepts a third argument as a boolean. When set to true, -this specific header will automatically be sent with each transaction. -Otherwise, the header will be set and sent for the specific transaction only. -Example: initHeader('X-YUI-State','Beta', true); all transactions will send this -header. - * resetDefaultHeaders() will clear the default headers collection. - -* All Connection Mananger transactions will broadcast the header: "X-Requested- -With: XMLHttpRequest". - * This can be turned off: YAHOO.util.Connect.setDefaultXhrHeader(false); - -* The HTTP method argument in asyncRequest is now case-insensitive. - -* uploadFile() will now correctly handle the absence of a callback object, -allowing the transaction to complete silently. - -*** version 0.12.2 *** - -* The Opera/Connection Manager concurrent object condition, described in version -0.12.0, no longer tests applies for Opera, version 9.10. - -*** version 0.12.1 *** - -* connection-debug.js corrected and synchronized with connection.js. Code -inconsistencies between the two files existed in 0.12.0. - -*** version 0.12.0 *** - -* When uploading files via setForm() and asyncRequest includes a POST data -argument, appendPostData() will create hidden input fields for each postData -label/value and append each field to the form object. - -* setForm() returns the assembled label/value string of the parsed HTML form -fields. - -* NOTE: Opera 9.02 does not allow for more than 12 concurrent Connection Manager -objects. - -The following example creates 12 requests in a loop: -for(var n=0; n<=12; i++){ - conn[n] = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback); -} - -If n > 13, Opera 9.02 will crash. Connection manager objects count n must be <= -12 at all times. This condition was not present in Opera version 9.01. - -This condition does not apply to other A-Grade browsers ( -http://developer.yahoo.com/yui/articles/gbs/gbs_browser-chart.html) - -*** version 0.11.3 *** - -* YUI Event dependency for file uploading is now optional. - -* uploadFile() now sets unique IDs for each file upload transaction to prevent -iframe collisions with parallel uploads. - -* The callback object now has property responseXML to provide support for file -upload transactions that return an XML document. - -* setForm() will verify if a select option value attribute is present and use -its value, including empty string, before using the text node value. - -* Modified polling mechanism in handleReadyState() and -handleTransactionResponse() to prevent infinite polling if JavaScript errors -occur in the user-defined callback. - -* createFrame() will now accept a boolean argument of true to set the frame -source to "javascript:false" to prevent IE from throwing security warnings in an -HTTPS environment. - -* setHeader() now enumerates through the _http_header object using -hasOwnProperty() to prevent collisions with members added to Object via -prototype. - -* If using setForm() and asyncRequest includes a POST data argument, the data -will be concatenated to the HTML form POST message. - -*** version 0.11.2 *** - -* No revisions. - -*** version 0.11.1 *** - -* uploadFile() now verifies the existence of callback.upload before invoking -callback, with or without object scope. - -*** version 0.11.0 *** - -* Each transaction can be defined with a timeout threshold, in milliseconds, -through the callback object. If the threshold is reached, and the transaction -hasn't yet completed, the transaction will call abort(). - -* abort() will now accept a callback object as the second argument. The -failure callback will receive a response object to indicate the transaction was -aborted. - -* setForm() will now support file uploads by setting the second argument to -true (e.g., YAHOO.util.Connect.setForm(formObject, true). File upload does not -use the callback success or failure handler. Instead, it uses a new callback -object handler: upload. - -* HTML form submit will no longer submit form fields without a defined name -attribute. - -* The default POST header of 'Content-Type','application/x-www-form-urlencoded' -can be overridden by calling setDefaultPostHeader(false). This -will remove the default header from non-HTML form, POST submissions. - -* setHeader() now enumerates through the _http_header object with -propertyIsEnumerable to prevent collisions with members added to Object via -prototype. - -*** version 0.10.0 *** - -* handleTransactionResponse() now treats the full HTTP 2xx range as a success -case, instead of just HTTP 200. - -* To accommodate multiple field values in Mozilla/Firefox, multiple initHeader -calls with the same label will now result in the values concatenated to a -comma- delimited string value. -Example: -Setting Content-Type:'application/x-www-form-urlencoded' and Content- -Type:'text/xml' will result in Content-Type:'application/x-www-form-urlencoded, -text/xml'. - -* Default polling interval lowered to 50ms. - -* YAHOO.util.Connect.setPollingInterval() will allow you to set a polling -interval -- in milliseconds -- to override the default value. - -* YAHOO.util.Connect.getResponseHeader[headerLabel] now supported as a response -object property to provide symmetry with the native XHR object's property. -Example: -YAHOO.util.Connect.getResponseHeader['Content-Length'] will return the value -for the Content-Length header, if the header is available. - -* YAHOO.util.Connect.allResponseHeaders property renamed to -getAllResponseHeaders to provide symmetry with the native XHR object's -property. - -* YAHOO.util.Connect.setForm() now supports HTTP GET as well as HTTP POST. - -* YAHOO.util.Connect.setForm() now accepts an HTML form object as well as its -name attribute value. - -* YAHOO.util.Connect.setForm() will not submit HTML form fields that are -disabled or do not have a name attribute value. - -* [FIXED] Response exceptions result in infinite callback loop in -Mozilla/Firefox. - -* [FIXED] YAHOO.util.Connect.abort() now properly clears polling interval. - -* [FIXED] isCallInProgress() now verifies whether XHR instance still exists, -and returns false if the connection object is no longer available. - -*** version 0.9.0 *** - -* Initial release - - - diff --git a/lib/yui/connection/connection-debug.js b/lib/yui/connection/connection-debug.js deleted file mode 100755 index 999a041452..0000000000 --- a/lib/yui/connection/connection-debug.js +++ /dev/null @@ -1,1395 +0,0 @@ -/* -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 -*/ -/** - * The Connection Manager provides a simplified interface to the XMLHttpRequest - * object. It handles cross-browser instantiantion of XMLHttpRequest, negotiates the - * interactive states and server response, returning the results to a pre-defined - * callback you create. - * - * @namespace YAHOO.util - * @module connection - * @requires yahoo - * @requires event - */ - -/** - * The Connection Manager singleton provides methods for creating and managing - * asynchronous transactions. - * - * @class Connect - */ - -YAHOO.util.Connect = -{ - /** - * @description Array of MSFT ActiveX ids for XMLHttpRequest. - * @property _msxml_progid - * @private - * @static - * @type array - */ - _msxml_progid:[ - 'Microsoft.XMLHTTP', - 'MSXML2.XMLHTTP.3.0', - 'MSXML2.XMLHTTP' - ], - - /** - * @description Object literal of HTTP header(s) - * @property _http_header - * @private - * @static - * @type object - */ - _http_headers:{}, - - /** - * @description Determines if HTTP headers are set. - * @property _has_http_headers - * @private - * @static - * @type boolean - */ - _has_http_headers:false, - - /** - * @description Determines if a default header of - * Content-Type of 'application/x-www-form-urlencoded' - * will be added to any client HTTP headers sent for POST - * transactions. - * @property _use_default_post_header - * @private - * @static - * @type boolean - */ - _use_default_post_header:true, - - /** - * @description The default header used for POST transactions. - * @property _default_post_header - * @private - * @static - * @type boolean - */ - _default_post_header:'application/x-www-form-urlencoded; charset=UTF-8', - - /** - * @description The default header used for transactions involving the - * use of HTML forms. - * @property _default_form_header - * @private - * @static - * @type boolean - */ - _default_form_header:'application/x-www-form-urlencoded', - - /** - * @description Determines if a default header of - * 'X-Requested-With: XMLHttpRequest' - * will be added to each transaction. - * @property _use_default_xhr_header - * @private - * @static - * @type boolean - */ - _use_default_xhr_header:true, - - /** - * @description The default header value for the label - * "X-Requested-With". This is sent with each - * transaction, by default, to identify the - * request as being made by YUI Connection Manager. - * @property _default_xhr_header - * @private - * @static - * @type boolean - */ - _default_xhr_header:'XMLHttpRequest', - - /** - * @description Determines if custom, default headers - * are set for each transaction. - * @property _has_default_header - * @private - * @static - * @type boolean - */ - _has_default_headers:true, - - /** - * @description Determines if custom, default headers - * are set for each transaction. - * @property _has_default_header - * @private - * @static - * @type boolean - */ - _default_headers:{}, - - /** - * @description Property modified by setForm() to determine if the data - * should be submitted as an HTML form. - * @property _isFormSubmit - * @private - * @static - * @type boolean - */ - _isFormSubmit:false, - - /** - * @description Property modified by setForm() to determine if a file(s) - * upload is expected. - * @property _isFileUpload - * @private - * @static - * @type boolean - */ - _isFileUpload:false, - - /** - * @description Property modified by setForm() to set a reference to the HTML - * form node if the desired action is file upload. - * @property _formNode - * @private - * @static - * @type object - */ - _formNode:null, - - /** - * @description Property modified by setForm() to set the HTML form data - * for each transaction. - * @property _sFormData - * @private - * @static - * @type string - */ - _sFormData:null, - - /** - * @description Collection of polling references to the polling mechanism in handleReadyState. - * @property _poll - * @private - * @static - * @type object - */ - _poll:{}, - - /** - * @description Queue of timeout values for each transaction callback with a defined timeout value. - * @property _timeOut - * @private - * @static - * @type object - */ - _timeOut:{}, - - /** - * @description The polling frequency, in milliseconds, for HandleReadyState. - * when attempting to determine a transaction's XHR readyState. - * The default is 50 milliseconds. - * @property _polling_interval - * @private - * @static - * @type int - */ - _polling_interval:50, - - /** - * @description A transaction counter that increments the transaction id for each transaction. - * @property _transaction_id - * @private - * @static - * @type int - */ - _transaction_id:0, - - /** - * @description Tracks the name-value pair of the "clicked" submit button if multiple submit - * buttons are present in an HTML form; and, if YAHOO.util.Event is available. - * @property _submitElementValue - * @private - * @static - * @type string - */ - _submitElementValue:null, - - /** - * @description Determines whether YAHOO.util.Event is available and returns true or false. - * If true, an event listener is bound at the document level to trap click events that - * resolve to a target type of "Submit". This listener will enable setForm() to determine - * the clicked "Submit" value in a multi-Submit button, HTML form. - * @property _hasSubmitListener - * @private - * @static - */ - _hasSubmitListener:(function() - { - if(YAHOO.util.Event){ - YAHOO.util.Event.addListener( - document, - 'click', - function(e){ - var obj = YAHOO.util.Event.getTarget(e); - if(obj.nodeName.toLowerCase() == 'input' && (obj.type && obj.type.toLowerCase() == 'submit')){ - YAHOO.util.Connect._submitElementValue = encodeURIComponent(obj.name) + "=" + encodeURIComponent(obj.value); - } - }); - return true; - } - return false; - })(), - - /** - * @description Custom event that fires at the start of a transaction - * @property startEvent - * @private - * @static - * @type CustomEvent - */ - startEvent: new YAHOO.util.CustomEvent('start'), - - /** - * @description Custom event that fires when a transaction response has completed. - * @property completeEvent - * @private - * @static - * @type CustomEvent - */ - completeEvent: new YAHOO.util.CustomEvent('complete'), - - /** - * @description Custom event that fires when handleTransactionResponse() determines a - * response in the HTTP 2xx range. - * @property successEvent - * @private - * @static - * @type CustomEvent - */ - successEvent: new YAHOO.util.CustomEvent('success'), - - /** - * @description Custom event that fires when handleTransactionResponse() determines a - * response in the HTTP 4xx/5xx range. - * @property failureEvent - * @private - * @static - * @type CustomEvent - */ - failureEvent: new YAHOO.util.CustomEvent('failure'), - - /** - * @description Custom event that fires when handleTransactionResponse() determines a - * response in the HTTP 4xx/5xx range. - * @property failureEvent - * @private - * @static - * @type CustomEvent - */ - uploadEvent: new YAHOO.util.CustomEvent('upload'), - - /** - * @description Custom event that fires when a transaction is successfully aborted. - * @property abortEvent - * @private - * @static - * @type CustomEvent - */ - abortEvent: new YAHOO.util.CustomEvent('abort'), - - /** - * @description A reference table that maps callback custom events members to its specific - * event name. - * @property _customEvents - * @private - * @static - * @type object - */ - _customEvents: - { - onStart:['startEvent', 'start'], - onComplete:['completeEvent', 'complete'], - onSuccess:['successEvent', 'success'], - onFailure:['failureEvent', 'failure'], - onUpload:['uploadEvent', 'upload'], - onAbort:['abortEvent', 'abort'] - }, - - /** - * @description Member to add an ActiveX id to the existing xml_progid array. - * In the event(unlikely) a new ActiveX id is introduced, it can be added - * without internal code modifications. - * @method setProgId - * @public - * @static - * @param {string} id The ActiveX id to be added to initialize the XHR object. - * @return void - */ - setProgId:function(id) - { - this._msxml_progid.unshift(id); - YAHOO.log('ActiveX Program Id ' + id + ' added to _msxml_progid.', 'info', 'Connection'); - }, - - /** - * @description Member to override the default POST header. - * @method setDefaultPostHeader - * @public - * @static - * @param {boolean} b Set and use default header - true or false . - * @return void - */ - setDefaultPostHeader:function(b) - { - if(typeof b == 'string'){ - this._default_post_header = b; - YAHOO.log('Default POST header set to ' + b, 'info', 'Connection'); - } - else if(typeof b == 'boolean'){ - this._use_default_post_header = b; - } - }, - - /** - * @description Member to override the default transaction header.. - * @method setDefaultXhrHeader - * @public - * @static - * @param {boolean} b Set and use default header - true or false . - * @return void - */ - setDefaultXhrHeader:function(b) - { - if(typeof b == 'string'){ - this._default_xhr_header = b; - YAHOO.log('Default XHR header set to ' + b, 'info', 'Connection'); - } - else{ - this._use_default_xhr_header = b; - } - }, - - /** - * @description Member to modify the default polling interval. - * @method setPollingInterval - * @public - * @static - * @param {int} i The polling interval in milliseconds. - * @return void - */ - setPollingInterval:function(i) - { - if(typeof i == 'number' && isFinite(i)){ - this._polling_interval = i; - YAHOO.log('Default polling interval set to ' + i +'ms', 'info', 'Connection'); - } - }, - - /** - * @description Instantiates a XMLHttpRequest object and returns an object with two properties: - * the XMLHttpRequest instance and the transaction id. - * @method createXhrObject - * @private - * @static - * @param {int} transactionId Property containing the transaction id for this transaction. - * @return object - */ - createXhrObject:function(transactionId) - { - var obj,http; - try - { - // Instantiates XMLHttpRequest in non-IE browsers and assigns to http. - http = new XMLHttpRequest(); - // Object literal with http and tId properties - obj = { conn:http, tId:transactionId }; - YAHOO.log('XHR object created for transaction ' + transactionId, 'info', 'Connection'); - } - catch(e) - { - for(var i=0; i