update YUI to 2.8.0r4

This commit is contained in:
Graham Knop 2009-09-21 12:54:44 -05:00
parent 27f474ec64
commit 2d28e0c0ba
2007 changed files with 344487 additions and 210070 deletions

View file

@ -1,8 +1,8 @@
/*
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 2.6.0
version: 2.8.0r4
*/
/////////////////////////////////////////////////////////////////////////////
//
@ -72,7 +72,7 @@ YAHOO.widget.DS_XHR.TYPE_FLAT = YAHOO.util.DataSourceBase.TYPE_TEXT;
YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) {
if(elInput && elContainer && oDataSource) {
// Validate DataSource
if(oDataSource instanceof YAHOO.util.DataSourceBase) {
if(oDataSource && YAHOO.lang.isFunction(oDataSource.sendRequest)) {
this.dataSource = oDataSource;
}
else {
@ -332,8 +332,9 @@ YAHOO.widget.AutoComplete.prototype.queryDelay = 0.2;
YAHOO.widget.AutoComplete.prototype.typeAheadDelay = 0.5;
/**
* When IME usage is detected, AutoComplete will switch to querying the input
* value at the given interval rather than per key event.
* When IME usage is detected or interval detection is explicitly enabled,
* AutoComplete will detect the input value at the given interval and send a
* query if the value has changed.
*
* @property queryInterval
* @type Number
@ -482,7 +483,7 @@ YAHOO.widget.AutoComplete.prototype.useShadow = false;
/**
* Whether or not the input field should be updated with selections.
*
* @property supressInputUpdate
* @property suppressInputUpdate
* @type Boolean
* @default false
*/
@ -511,6 +512,17 @@ YAHOO.widget.AutoComplete.prototype.resultTypeList = true;
*/
YAHOO.widget.AutoComplete.prototype.queryQuestionMark = true;
/**
* If true, before each time the container expands, the container element will be
* positioned to snap to the bottom-left corner of the input element. If
* autoSnapContainer is set to false, this positioning will not be done.
*
* @property autoSnapContainer
* @type Boolean
* @default true
*/
YAHOO.widget.AutoComplete.prototype.autoSnapContainer = true;
/////////////////////////////////////////////////////////////////////////////
//
// Public methods
@ -548,13 +560,13 @@ YAHOO.widget.AutoComplete.prototype.getContainerEl = function() {
};
/**
* Returns true if widget instance is currently focused.
* Returns true if widget instance is currently active.
*
* @method isFocused
* @return {Boolean} Returns true if widget instance is currently focused.
* @return {Boolean} Returns true if widget instance is currently active.
*/
YAHOO.widget.AutoComplete.prototype.isFocused = function() {
return (this._bFocused === null) ? false : this._bFocused;
return this._bFocused;
};
/**
@ -637,7 +649,7 @@ YAHOO.widget.AutoComplete.prototype.setHeader = function(sHeader) {
var elHeader = this._elHeader;
if(sHeader) {
elHeader.innerHTML = sHeader;
elHeader.style.display = "block";
elHeader.style.display = "";
}
else {
elHeader.innerHTML = "";
@ -658,7 +670,7 @@ YAHOO.widget.AutoComplete.prototype.setFooter = function(sFooter) {
var elFooter = this._elFooter;
if(sFooter) {
elFooter.innerHTML = sFooter;
elFooter.style.display = "block";
elFooter.style.display = "";
}
else {
elFooter.innerHTML = "";
@ -680,7 +692,7 @@ YAHOO.widget.AutoComplete.prototype.setBody = function(sBody) {
YAHOO.util.Event.purgeElement(elBody, true);
if(sBody) {
elBody.innerHTML = sBody;
elBody.style.display = "block";
elBody.style.display = "";
}
else {
elBody.innerHTML = "";
@ -698,6 +710,7 @@ YAHOO.widget.AutoComplete.prototype.setBody = function(sBody) {
*
* @method generateRequest
* @param sQuery {String} Query string
* @return {MIXED} Request
*/
YAHOO.widget.AutoComplete.prototype.generateRequest = function(sQuery) {
var dataType = this.dataSource.dataType;
@ -732,12 +745,36 @@ YAHOO.widget.AutoComplete.prototype.generateRequest = function(sQuery) {
* @param sQuery {String} Query string.
*/
YAHOO.widget.AutoComplete.prototype.sendQuery = function(sQuery) {
// Adjust programatically sent queries to look like they input by user
// Activate focus for a new interaction
this._bFocused = true;
// Adjust programatically sent queries to look like they were input by user
// when delimiters are enabled
var newQuery = (this.delimChar) ? this._elTextbox.value + sQuery : sQuery;
this._sendQuery(newQuery);
};
/**
* Snaps container to bottom-left corner of input element
*
* @method snapContainer
*/
YAHOO.widget.AutoComplete.prototype.snapContainer = function() {
var oTextbox = this._elTextbox,
pos = YAHOO.util.Dom.getXY(oTextbox);
pos[1] += YAHOO.util.Dom.get(oTextbox).offsetHeight + 2;
YAHOO.util.Dom.setXY(this._elContainer,pos);
};
/**
* Expands container.
*
* @method expandContainer
*/
YAHOO.widget.AutoComplete.prototype.expandContainer = function() {
this._toggleContainer(true);
};
/**
* Collapses container.
*
@ -747,6 +784,19 @@ YAHOO.widget.AutoComplete.prototype.collapseContainer = function() {
this._toggleContainer(false);
};
/**
* Clears entire list of suggestions.
*
* @method clearList
*/
YAHOO.widget.AutoComplete.prototype.clearList = function() {
var allItems = this._elList.childNodes,
i=allItems.length-1;
for(; i>-1; i--) {
allItems[i].style.display = "none";
}
};
/**
* Handles subset matching for when queryMatchSubset is enabled.
*
@ -803,6 +853,11 @@ YAHOO.widget.AutoComplete.prototype.preparseRawResponse = function(oRequest, oFu
*/
YAHOO.widget.AutoComplete.prototype.filterResults = function(sQuery, oFullResponse, oParsedResponse, oCallback) {
// If AC has passed a query string value back to itself, grab it
if(oCallback && oCallback.argument && oCallback.argument.query) {
sQuery = oCallback.argument.query;
}
// Only if a query string is available to match against
if(sQuery && sQuery !== "") {
// First make a copy of the oParseResponse
@ -811,13 +866,13 @@ YAHOO.widget.AutoComplete.prototype.filterResults = function(sQuery, oFullRespon
var oAC = oCallback.scope,
oDS = this,
allResults = oParsedResponse.results, // the array of results
filteredResults = [], // container for filtered results
bMatchFound = false,
filteredResults = [], // container for filtered results,
nMax = oAC.maxResultsDisplayed, // max to find
bMatchCase = (oDS.queryMatchCase || oAC.queryMatchCase), // backward compat
bMatchContains = (oDS.queryMatchContains || oAC.queryMatchContains); // backward compat
// Loop through each result object...
for(var i = allResults.length-1; i >= 0; i--) {
for(var i=0, len=allResults.length; i<len; i++) {
var oResult = allResults[i];
// Grab the data to match against from the result object...
@ -853,9 +908,14 @@ YAHOO.widget.AutoComplete.prototype.filterResults = function(sQuery, oFullRespon
// A CONTAINS match is when the query is found anywhere within the key string...
(bMatchContains && (sKeyIndex > -1))) {
// Stash the match
filteredResults.unshift(oResult);
filteredResults.push(oResult);
}
}
// Filter no more if maxResultsDisplayed is reached
if(len>nMax && filteredResults.length===nMax) {
break;
}
}
oParsedResponse.results = filteredResults;
YAHOO.log("Filtered " + filteredResults.length + " results against query \"" + sQuery + "\": " + YAHOO.lang.dump(filteredResults), "info", this.toString());
@ -931,7 +991,7 @@ YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer = function(elTextbox
* 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!
* implementer, as in myAutoComplete = null. Use with caution!
*
* @method destroy
*/
@ -1028,6 +1088,7 @@ YAHOO.widget.AutoComplete.prototype.dataReturnEvent = null;
* @event dataErrorEvent
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @param sQuery {String} The query string.
* @param oResponse {Object} The response object, if available.
*/
YAHOO.widget.AutoComplete.prototype.dataErrorEvent = null;
@ -1044,8 +1105,6 @@ YAHOO.widget.AutoComplete.prototype.containerPopulateEvent = null;
*
* @event containerExpandEvent
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @param sQuery {String} The query string.
* @param aResults {Object[]} Results array.
*/
YAHOO.widget.AutoComplete.prototype.containerExpandEvent = null;
@ -1122,6 +1181,7 @@ YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent = null;
*
* @event selectionEnforceEvent
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @param sClearedValue {String} The cleared value (including delimiters if applicable).
*/
YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent = null;
@ -1247,14 +1307,14 @@ YAHOO.widget.AutoComplete.prototype._elShadow = null;
YAHOO.widget.AutoComplete.prototype._elIFrame = null;
/**
* Whether or not the input field is currently in focus. If query results come back
* Whether or not the widget instance is currently active. 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 = null;
YAHOO.widget.AutoComplete.prototype._bFocused = false;
/**
* Animation instance for container expand/collapse.
@ -1360,6 +1420,15 @@ YAHOO.widget.AutoComplete.prototype._sInitInputValue = null;
*/
YAHOO.widget.AutoComplete.prototype._elCurListItem = null;
/**
* Pointer to the currently pre-highlighted &lt;li&gt; element in the container.
*
* @property _elCurPrehighlightItem
* @type HTMLElement
* @private
*/
YAHOO.widget.AutoComplete.prototype._elCurPrehighlightItem = 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
@ -1505,8 +1574,10 @@ YAHOO.widget.AutoComplete.prototype._initContainerHelperEls = function() {
elIFrame.style.position = "absolute";
elIFrame.style.width = 0;
elIFrame.style.height = 0;
elIFrame.tabIndex = -1;
elIFrame.style.padding = 0;
elIFrame.tabIndex = -1;
elIFrame.role = "presentation";
elIFrame.title = "Presentational iframe shim";
this._elIFrame = this._elContainer.appendChild(elIFrame);
}
};
@ -1557,10 +1628,10 @@ YAHOO.widget.AutoComplete.prototype._initContainerEl = function() {
* @private
*/
YAHOO.widget.AutoComplete.prototype._initListEl = function() {
var nListLength = this.maxResultsDisplayed;
var nListLength = this.maxResultsDisplayed,
elList = this._elList || document.createElement("ul"),
elListItem;
var elList = this._elList || document.createElement("ul");
var elListItem;
while(elList.childNodes.length < nListLength) {
elListItem = document.createElement("li");
elListItem.style.display = "none";
@ -1574,13 +1645,31 @@ YAHOO.widget.AutoComplete.prototype._initListEl = function() {
this._elList = elBody.appendChild(elList);
}
this._elBody.style.display = "";
};
/**
* Focuses input field.
*
* @method _focus
* @private
*/
YAHOO.widget.AutoComplete.prototype._focus = function() {
// http://developer.mozilla.org/en/docs/index.php?title=Key-navigable_custom_DHTML_widgets
var oSelf = this;
setTimeout(function() {
try {
oSelf._elTextbox.focus();
}
catch(e) {
}
},0);
};
/**
* Enables interval detection for IME support.
*
* @method _enableIntervalDetection
* @re
* @private
*/
YAHOO.widget.AutoComplete.prototype._enableIntervalDetection = function() {
@ -1591,6 +1680,19 @@ YAHOO.widget.AutoComplete.prototype._enableIntervalDetection = function() {
}
};
/**
* Enables interval detection for a less performant but brute force mechanism to
* detect input values at an interval set by queryInterval and send queries if
* input value has changed. Needed to support right-click+paste or shift+insert
* edge cases. Please note that intervals are cleared at the end of each interaction,
* so enableIntervalDetection must be called for each new interaction. The
* recommended approach is to call it in response to textboxFocusEvent.
*
* @method enableIntervalDetection
*/
YAHOO.widget.AutoComplete.prototype.enableIntervalDetection =
YAHOO.widget.AutoComplete.prototype._enableIntervalDetection;
/**
* Enables query triggers based on text input detection by intervals (rather
* than by key events).
@ -1664,44 +1766,12 @@ YAHOO.widget.AutoComplete.prototype._sendQuery = function(sQuery) {
return;
}
// Delimiter has been enabled
var aDelimChar = (this.delimChar) ? this.delimChar : null;
if(aDelimChar) {
// Loop through all possible delimiters and find the rightmost one in the query
// A " " may be a false positive if they are defined as delimiters AND
// are used to separate delimited queries
var nDelimIndex = -1;
for(var i = aDelimChar.length-1; i >= 0; i--) {
var nNewIndex = sQuery.lastIndexOf(aDelimChar[i]);
if(nNewIndex > nDelimIndex) {
nDelimIndex = nNewIndex;
}
}
// If we think the last delimiter is a space (" "), make sure it is NOT
// a false positive by also checking the char directly before it
if(aDelimChar[i] == " ") {
for (var j = aDelimChar.length-1; j >= 0; j--) {
if(sQuery[nDelimIndex - 1] == aDelimChar[j]) {
nDelimIndex--;
break;
}
}
}
// A delimiter has been found in the query so extract the latest query from past selections
if(nDelimIndex > -1) {
var nQueryStart = nDelimIndex + 1;
// Trim any white space from the beginning...
while(sQuery.charAt(nQueryStart) == " ") {
nQueryStart += 1;
}
// ...and save the rest of the string for later
this._sPastSelections = sQuery.substring(0,nQueryStart);
// Here is the query itself
sQuery = sQuery.substr(nQueryStart);
}
// No delimiter found in the query, so there are no selections from past queries
else {
this._sPastSelections = "";
}
if(this.delimChar) {
var extraction = this._extractQuery(sQuery);
// Here is the query itself
sQuery = extraction.query;
// ...and save the rest of the string for later
this._sPastSelections = extraction.previous;
}
// Don't search queries that are too short
@ -1726,7 +1796,7 @@ YAHOO.widget.AutoComplete.prototype._sendQuery = function(sQuery) {
}
}
if(this.responseStripAfter) {
if(this.dataSource.responseStripAfter) {
this.dataSource.doBeforeParseData = this.preparseRawResponse;
}
if(this.applyLocalFilter) {
@ -1747,6 +1817,19 @@ YAHOO.widget.AutoComplete.prototype._sendQuery = function(sQuery) {
});
};
/**
* Populates the given &lt;li&gt; element with return value from formatResult().
*
* @method _populateListItem
* @param elListItem {HTMLElement} The LI element.
* @param oResult {Object} The result object.
* @param sCurQuery {String} The query string.
* @private
*/
YAHOO.widget.AutoComplete.prototype._populateListItem = function(elListItem, oResult, sQuery) {
elListItem.innerHTML = this.formatResult(oResult, sQuery, elListItem._sResultMatch);
};
/**
* Populates the array of &lt;li&gt; elements in the container with query
* results.
@ -1772,16 +1855,8 @@ YAHOO.widget.AutoComplete.prototype._populateList = function(sQuery, oResponse,
if(ok && !oResponse.error) {
this.dataReturnEvent.fire(this, sQuery, oResponse.results);
// Continue only if instance is still focused (i.e., user hasn't already moved on)
// Null indicates initialized state, which is ok too
if(this._bFocused || (this._bFocused === null)) {
//TODO: is this still necessary?
/*var isOpera = (YAHOO.env.ua.opera);
var contentStyle = this._elContent.style;
contentStyle.width = (!isOpera) ? null : "";
contentStyle.height = (!isOpera) ? null : "";*/
// Continue only if instance is still active (i.e., user hasn't already moved on)
if(this._bFocused) {
// Store state for this interaction
var sCurQuery = decodeURIComponent(sQuery);
this._sCurQuery = sCurQuery;
@ -1839,7 +1914,7 @@ YAHOO.widget.AutoComplete.prototype._populateList = function(sQuery, oResponse,
// The matching value, including backward compatibility for array format and safety net
elListItem._sResultMatch = (YAHOO.lang.isString(oResult)) ? oResult : (YAHOO.lang.isArray(oResult)) ? oResult[0] : (oResult[sMatchKey] || "");
elListItem._oResultData = oResult; // Additional data
elListItem.innerHTML = this.formatResult(oResult, sCurQuery, elListItem._sResultMatch);
this._populateListItem(elListItem, oResult, sCurQuery);
elListItem.style.display = "";
}
@ -1869,8 +1944,10 @@ YAHOO.widget.AutoComplete.prototype._populateList = function(sQuery, oResponse,
this._toggleHighlight(this._elCurListItem,"from");
}
// Pre-expansion stuff
ok = this._doBeforeExpandContainer(this._elTextbox, this._elContainer, sQuery, allResults);
// Expand the container
ok = this.doBeforeExpandContainer(this._elTextbox, this._elContainer, sQuery, allResults);
this._toggleContainer(ok);
}
else {
@ -1883,12 +1960,32 @@ YAHOO.widget.AutoComplete.prototype._populateList = function(sQuery, oResponse,
}
// Error
else {
this.dataErrorEvent.fire(this, sQuery);
this.dataErrorEvent.fire(this, sQuery, oResponse);
}
YAHOO.log("Could not populate list", "info", this.toString());
};
/**
* Called before container expands, by default snaps container to the
* bottom-left corner of the input element, then calls public overrideable method.
*
* @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.
* @private
*/
YAHOO.widget.AutoComplete.prototype._doBeforeExpandContainer = function(elTextbox, elContainer, sQuery, aResults) {
if(this.autoSnapContainer) {
this.snapContainer();
}
return this.doBeforeExpandContainer(elTextbox, elContainer, sQuery, aResults);
};
/**
* When forceSelection is true and the user attempts
* leave the text input box without selecting an item from the query results,
@ -1898,20 +1995,10 @@ YAHOO.widget.AutoComplete.prototype._populateList = function(sQuery, oResponse,
* @private
*/
YAHOO.widget.AutoComplete.prototype._clearSelection = function() {
var sValue = this._elTextbox.value;
//TODO: need to check against all delimChars?
var sChar = (this.delimChar) ? this.delimChar[0] : null;
var nIndex = (sChar) ? sValue.lastIndexOf(sChar, sValue.length-2) : -1;
if(nIndex > -1) {
this._elTextbox.value = sValue.substring(0,nIndex);
}
else {
this._elTextbox.value = "";
}
this._sPastSelections = this._elTextbox.value;
// Fire custom event
this.selectionEnforceEvent.fire(this);
var extraction = (this.delimChar) ? this._extractQuery(this._elTextbox.value) :
{previous:"",query:this._elTextbox.value};
this._elTextbox.value = extraction.previous;
this.selectionEnforceEvent.fire(this, extraction.query);
YAHOO.log("Selection enforced", "info", this.toString());
};
@ -1927,7 +2014,7 @@ YAHOO.widget.AutoComplete.prototype._clearSelection = function() {
YAHOO.widget.AutoComplete.prototype._textMatchesOption = function() {
var elMatch = null;
for(var i = this._nDisplayedItems-1; i >= 0 ; i--) {
for(var i=0; i<this._nDisplayedItems; i++) {
var elListItem = this._elList.childNodes[i];
var sMatch = ("" + elListItem._sResultMatch).toLowerCase();
if(sMatch == this._sCurQuery.toLowerCase()) {
@ -1996,6 +2083,63 @@ YAHOO.widget.AutoComplete.prototype._selectText = function(elTextbox, nStart, nE
}
};
/**
* Extracts rightmost query from delimited string.
*
* @method _extractQuery
* @param sQuery {String} String to parse
* @return {Object} Object literal containing properties "query" and "previous".
* @private
*/
YAHOO.widget.AutoComplete.prototype._extractQuery = function(sQuery) {
var aDelimChar = this.delimChar,
nDelimIndex = -1,
nNewIndex, nQueryStart,
i = aDelimChar.length-1,
sPrevious;
// Loop through all possible delimiters and find the rightmost one in the query
// A " " may be a false positive if they are defined as delimiters AND
// are used to separate delimited queries
for(; i >= 0; i--) {
nNewIndex = sQuery.lastIndexOf(aDelimChar[i]);
if(nNewIndex > nDelimIndex) {
nDelimIndex = nNewIndex;
}
}
// If we think the last delimiter is a space (" "), make sure it is NOT
// a false positive by also checking the char directly before it
if(aDelimChar[i] == " ") {
for (var j = aDelimChar.length-1; j >= 0; j--) {
if(sQuery[nDelimIndex - 1] == aDelimChar[j]) {
nDelimIndex--;
break;
}
}
}
// A delimiter has been found in the query so extract the latest query from past selections
if(nDelimIndex > -1) {
nQueryStart = nDelimIndex + 1;
// Trim any white space from the beginning...
while(sQuery.charAt(nQueryStart) == " ") {
nQueryStart += 1;
}
// ...and save the rest of the string for later
sPrevious = sQuery.substring(0,nQueryStart);
// Here is the query itself
sQuery = sQuery.substr(nQueryStart);
}
// No delimiter found in the query, so there are no selections from past queries
else {
sPrevious = "";
}
return {
previous: sPrevious,
query: sQuery
};
};
/**
* Syncs results container with its helpers.
*
@ -2045,6 +2189,8 @@ YAHOO.widget.AutoComplete.prototype._toggleContainerHelpers = function(bShow) {
* @private
*/
YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
YAHOO.log("Toggling container " + ((bShow) ? "open" : "closed"), "info", this.toString());
var elContainer = this._elContainer;
// If implementer has container always open and it's already open, don't mess with it
@ -2060,8 +2206,7 @@ YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
this._sCurQuery = null;
// Container is already closed, so don't bother with changing the UI
if(!this._bContainerOpen) {
this._elContent.style.display = "none";
if(this._elContent.style.display == "none") {
return;
}
}
@ -2180,7 +2325,8 @@ YAHOO.widget.AutoComplete.prototype._toggleHighlight = function(elNewListItem, s
};
/**
* Toggles the pre-highlight on or off for an item in the container.
* Toggles the pre-highlight on or off for an item in the container, and also cleans
* up pre-highlighting of any previous item.
*
* @method _togglePrehighlight
* @param elNewListItem {HTMLElement} The &lt;li&gt; element item to receive highlight behavior.
@ -2188,14 +2334,19 @@ YAHOO.widget.AutoComplete.prototype._toggleHighlight = function(elNewListItem, s
* @private
*/
YAHOO.widget.AutoComplete.prototype._togglePrehighlight = function(elNewListItem, sType) {
var sPrehighlight = this.prehighlightClassName;
if(this._elCurPrehighlightItem) {
YAHOO.util.Dom.removeClass(this._elCurPrehighlightItem, sPrehighlight);
}
if(elNewListItem == this._elCurListItem) {
return;
}
var sPrehighlight = this.prehighlightClassName;
if((sType == "mouseover") && sPrehighlight) {
// Apply prehighlight to new item
YAHOO.util.Dom.addClass(elNewListItem, sPrehighlight);
this._elCurPrehighlightItem = elNewListItem;
}
else {
// Remove prehighlight from old item
@ -2293,8 +2444,8 @@ YAHOO.widget.AutoComplete.prototype._jumpSelection = function() {
YAHOO.widget.AutoComplete.prototype._moveSelection = function(nKeyCode) {
if(this._bContainerOpen) {
// Determine current item's id number
var elCurListItem = this._elCurListItem;
var nCurItemIndex = -1;
var elCurListItem = this._elCurListItem,
nCurItemIndex = -1;
if(elCurListItem) {
nCurItemIndex = elCurListItem._nItemIndex;
@ -2330,12 +2481,13 @@ YAHOO.widget.AutoComplete.prototype._moveSelection = function(nKeyCode) {
return;
}
var elNewListItem = this._elList.childNodes[nNewItemIndex];
var elNewListItem = this._elList.childNodes[nNewItemIndex],
// Scroll the container if necessary
var elContent = this._elContent;
var scrollOn = ((YAHOO.util.Dom.getStyle(elContent,"overflow") == "auto") ||
(YAHOO.util.Dom.getStyle(elContent,"overflowY") == "auto"));
elContent = this._elContent,
sOF = YAHOO.util.Dom.getStyle(elContent,"overflow"),
sOFY = YAHOO.util.Dom.getStyle(elContent,"overflowY"),
scrollOn = ((sOF == "auto") || (sOF == "scroll") || (sOFY == "auto") || (sOFY == "scroll"));
if(scrollOn && (nNewItemIndex > -1) &&
(nNewItemIndex < this._nDisplayedItems)) {
// User is keying down
@ -2382,60 +2534,6 @@ YAHOO.widget.AutoComplete.prototype._moveSelection = function(nKeyCode) {
//
/////////////////////////////////////////////////////////////////////////////
/**
* Handles &lt;li&gt; element mouseover events in the container.
*
* @method _onItemMouseover
* @param v {HTMLEvent} The mouseover event.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
/*YAHOO.widget.AutoComplete.prototype._onItemMouseover = function(v,oSelf) {
if(oSelf.prehighlightClassName) {
oSelf._togglePrehighlight(this,"mouseover");
}
else {
oSelf._toggleHighlight(this,"to");
}
oSelf.itemMouseOverEvent.fire(oSelf, this);
YAHOO.log("Item moused over", "info", oSelf.toString());
};*/
/**
* Handles &lt;li&gt; element mouseout events in the container.
*
* @method _onItemMouseout
* @param v {HTMLEvent} The mouseout event.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
/*YAHOO.widget.AutoComplete.prototype._onItemMouseout = function(v,oSelf) {
if(oSelf.prehighlightClassName) {
oSelf._togglePrehighlight(this,"mouseout");
}
else {
oSelf._toggleHighlight(this,"from");
}
oSelf.itemMouseOutEvent.fire(oSelf, this);
YAHOO.log("Item moused out", "info", oSelf.toString());
};*/
/**
* Handles &lt;li&gt; element click events in the container.
*
* @method _onItemMouseclick
* @param v {HTMLEvent} The click event.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
/*YAHOO.widget.AutoComplete.prototype._onItemMouseclick = function(v,oSelf) {
// In case item has not been moused over
oSelf._toggleHighlight(this,"to");
oSelf._selectItem(this);
};*/
/**
* Handles container mouseover events.
*
@ -2566,7 +2664,7 @@ YAHOO.widget.AutoComplete.prototype._onContainerClick = function(v,oSelf) {
* @private
*/
YAHOO.widget.AutoComplete.prototype._onContainerScroll = function(v,oSelf) {
oSelf._elTextbox.focus();
oSelf._focus();
};
/**
@ -2735,9 +2833,6 @@ YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp = function(v,oSelf) {
}
// Clear previous timeout
/*if(oSelf._nTypeAheadDelayID != -1) {
clearTimeout(oSelf._nTypeAheadDelayID);
}*/
if(oSelf._nDelayID != -1) {
clearTimeout(oSelf._nDelayID);
}
@ -2746,12 +2841,6 @@ YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp = function(v,oSelf) {
oSelf._nDelayID = setTimeout(function(){
oSelf._sendQuery(sText);
},(oSelf.queryDelay * 1000));
//= nDelayID;
//else {
// No delay so send request immediately
//oSelf._sendQuery(sText);
//}
};
/**
@ -2782,7 +2871,7 @@ YAHOO.widget.AutoComplete.prototype._onTextboxFocus = function (v,oSelf) {
* @private
*/
YAHOO.widget.AutoComplete.prototype._onTextboxBlur = function (v,oSelf) {
// Don't treat as a blur if it was a selection via mouse click
// Is a true blur
if(!oSelf._bOverContainer || (oSelf._nKeyCode == 9)) {
// Current query needs to be validated as a selection
if(!oSelf._bItemSelected) {
@ -2808,9 +2897,6 @@ YAHOO.widget.AutoComplete.prototype._onTextboxBlur = function (v,oSelf) {
}
}
if(oSelf._bContainerOpen) {
oSelf._toggleContainer(false);
}
oSelf._clearInterval();
oSelf._bFocused = false;
if(oSelf._sInitInputValue !== oSelf._elTextbox.value) {
@ -2818,6 +2904,12 @@ YAHOO.widget.AutoComplete.prototype._onTextboxBlur = function (v,oSelf) {
}
oSelf.textboxBlurEvent.fire(oSelf);
YAHOO.log("Textbox blurred", "info", oSelf.toString());
oSelf._toggleContainer(false);
}
// Not a true blur if it was a selection via mouse click
else {
oSelf._focus();
}
};
@ -2914,4 +3006,4 @@ YAHOO.widget.AutoComplete._cloneObject = function(o) {
YAHOO.register("autocomplete", YAHOO.widget.AutoComplete, {version: "2.6.0", build: "1321"});
YAHOO.register("autocomplete", YAHOO.widget.AutoComplete, {version: "2.8.0r4", build: "2449"});