/*
Copyright (c) 2007, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
version: 2.3.0
*/
/**
* The AutoComplete control provides the front-end logic for text-entry suggestion and
* completion functionality.
*
* @module autocomplete
* @requires yahoo, dom, event, datasource
* @optional animation, connection
* @namespace YAHOO.widget
* @title AutoComplete Widget
*/
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
/**
* The AutoComplete class provides the customizable functionality of a plug-and-play DHTML
* auto completion widget. Some key features:
* <ul>
* <li>The drop down container can "roll down" or "fly out" via configurable
* animation</li>
* <li>UI look-and-feel customizable through CSS, including container
* attributes, borders, position, fonts, etc</li>
* </ul>
*
* @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.
*/
// Validate DataSource
this.dataSource = oDataSource;
}
else {
YAHOO.log("Could not instantiate AutoComplete due to an invalid DataSource", "error", this.toString());
return;
}
// Validate input element
}
else {
}
}
else {
YAHOO.log("Could not instantiate AutoComplete due to an invalid input element", "error", this.toString());
return;
}
// Validate container element
}
else {
this._oContainer = elContainer;
}
YAHOO.log("The container may not display properly if display is set to \"none\" in CSS", "warn", this.toString());
}
// For skinning
if(elTag == "div") {
break;
}
else {
}
}
if(elTag != "div") {
}
}
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(sConfig) {
}
}
}
// Initialization sequence
this._initContainer();
this._initProps();
this._initList();
this._initContainerHelpers();
// Set up events
var oSelf = this;
// Events are actually for the content module within the container
// Dom events
}
// Custom events
// Finish up
}
// 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
*/
/**
* 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
*/
/**
* Maximum number of results to display in results container.
*
* @property maxResultsDisplayed
* @type Number
* @default 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
*/
/**
* Class name of a highlighted item within results container.
*
* @property highlightClassName
* @type String
* @default "yui-ac-highlight"
*/
/**
* Class name of a pre-highlighted item within results container.
*
* @property prehighlightClassName
* @type String
*/
/**
* 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[]
*/
/**
* Whether or not the first item in results container should be automatically highlighted
* on expand.
*
* @property autoHighlight
* @type Boolean
* @default 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
*/
/**
* horizontal direction.
*
* @property animHoriz
* @type Boolean
* @default false
*/
/**
* vertical direction.
*
* @property animVert
* @type Boolean
* @default true
*/
/**
*
* @property animSpeed
* @type Number
* @default 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
*/
/**
* 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
*/
/**
* 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
*/
/**
* 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
*/
/**
* Whether or not the results container should have a shadow.
*
* @property useShadow
* @type Boolean
* @default false
*/
/////////////////////////////////////////////////////////////////////////////
//
// Public methods
//
/////////////////////////////////////////////////////////////////////////////
/**
* Public accessor to the unique name of the AutoComplete instance.
*
* @method toString
* @return {String} Unique name of the AutoComplete instance.
*/
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.
*/
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.
*/
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
*/
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.
*/
if(sHeader) {
}
}
else {
}
};
/**
* 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.
*/
if(sFooter) {
}
}
else {
}
};
/**
* 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.
*/
if(sBody) {
}
}
else {
}
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.
*/
if(sResult) {
return sResult;
}
else {
return "";
}
};
/**
* Overridable method called before container expands allows implementers to access data
* and DOM elements.
*
* @method doBeforeExpandContainer
* @param oTextbox {HTMLElement} The text input box.
* @param oContainer {HTMLElement} The container element.
* @param sQuery {String} The query string.
* @param aResults {Object[]} An array of query results.
* @return {Boolean} Return true to continue expanding container, false to cancel the expand.
*/
YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer = function(oTextbox, oContainer, sQuery, aResults) {
return true;
};
/**
* Makes query request to the DataSource.
*
* @method sendQuery
* @param sQuery {String} Query string.
*/
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.
*/
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
*/
var instanceName = this.toString();
var elContainer = this._oContainer;
// Unhook custom events
this.textboxFocusEvent.unsubscribe();
this.textboxKeyEvent.unsubscribe();
this.dataRequestEvent.unsubscribe();
this.dataReturnEvent.unsubscribe();
this.dataErrorEvent.unsubscribe();
this.containerExpandEvent.unsubscribe();
this.typeAheadEvent.unsubscribe();
this.itemMouseOverEvent.unsubscribe();
this.itemMouseOutEvent.unsubscribe();
this.itemArrowToEvent.unsubscribe();
this.itemArrowFromEvent.unsubscribe();
this.itemSelectEvent.unsubscribe();
this.unmatchedItemSelectEvent.unsubscribe();
this.selectionEnforceEvent.unsubscribe();
this.containerCollapseEvent.unsubscribe();
this.textboxBlurEvent.unsubscribe();
// Unhook DOM events
// Remove DOM elements
// Null out objects
for(var key in this) {
if(this.hasOwnProperty(key)) {
this[key] = null;
}
}
};
/////////////////////////////////////////////////////////////////////////////
//
// Public events
//
/////////////////////////////////////////////////////////////////////////////
/**
* Fired when the input field receives focus.
*
* @event textboxFocusEvent
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
*/
/**
* Fired when the input field receives key input.
*
* @event textboxKeyEvent
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @param nKeycode {Number} The keycode number.
*/
/**
* 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.
*/
/**
* 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.
*/
/**
* 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.
*/
/**
* Fired when the results container is expanded.
*
* @event containerExpandEvent
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
*/
/**
* 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.
*/
/**
* 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.
*/
/**
* 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.
*/
/**
* 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.
*/
/**
* 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.
*/
/**
* 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.
*/
/**
* Fired when a user selection does not match any of the displayed result items.
* Note that this event may not behave as expected when delimiter characters
* have been defined.
*
* @event unmatchedItemSelectEvent
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @param sQuery {String} The user-typed query string.
*/
/**
* 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.
*/
/**
* Fired when the results container is collapsed.
*
* @event containerCollapseEvent
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
*/
/**
* Fired when the input field loses focus.
*
* @event textboxBlurEvent
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
*/
/////////////////////////////////////////////////////////////////////////////
//
// Private member variables
//
/////////////////////////////////////////////////////////////////////////////
/**
* Internal class variable to index multiple AutoComplete instances.
*
* @property _nIndex
* @type Number
* @default 0
* @private
*/
/**
* Name of AutoComplete instance.
*
* @property _sName
* @type String
* @private
*/
/**
* Text input field DOM element.
*
* @property _oTextbox
* @type HTMLElement
* @private
*/
/**
* 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
*/
/**
*
* @property _oAnim
* @type Boolean
* @private
*/
/**
* Container DOM element.
*
* @property _oContainer
* @type HTMLElement
* @private
*/
/**
* Whether or not the results container is currently open.
*
* @property _bContainerOpen
* @type Boolean
* @private
*/
/**
* 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
*/
/**
* Array of <li> elements references that contain query results within the
* results container.
*
* @property _aListItems
* @type HTMLElement[]
* @private
*/
/**
* Number of <li> elements currently displayed in results container.
*
* @property _nDisplayedItems
* @type Number
* @private
*/
/**
* Internal count of <li> elements displayed and hidden in results container.
*
* @property _maxResultsDisplayed
* @type Number
* @private
*/
/**
* Current query string
*
* @property _sCurQuery
* @type String
* @private
*/
/**
* Past queries this session (for saving delimited queries).
*
* @property _sSavedQuery
* @type String
* @private
*/
/**
* Pointer to the currently highlighted <li> element in the container.
*
* @property _oCurItem
* @type HTMLElement
* @private
*/
/**
* 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
*/
/**
* Key code of the last key pressed in textbox.
*
* @property _nKeyCode
* @type Number
* @private
*/
/**
* Delay timeout ID.
*
* @property _nDelayID
* @type Number
* @private
*/
/**
* Src to iFrame used when useIFrame = true. Supports implementations over SSL
* as well.
*
* @property _iFrameSrc
* @type String
* @private
*/
/**
* 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
*/
/**
* 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
*/
/////////////////////////////////////////////////////////////////////////////
//
// Private methods
//
/////////////////////////////////////////////////////////////////////////////
/**
* Updates and validates latest public config properties.
*
* @method __initProps
* @private
*/
// Correct any invalid values
var minQueryLength = this.minQueryLength;
this.minQueryLength = 1;
}
var maxResultsDisplayed = this.maxResultsDisplayed;
this.maxResultsDisplayed = 10;
}
var queryDelay = this.queryDelay;
this.queryDelay = 0.2;
}
}
this.delimChar = null;
}
this.animSpeed = 0.3;
}
if(!this._oAnim ) {
}
else {
}
}
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
*/
}
}
};
/**
* Initializes the results container once at object creation
*
* @method _initContainer
* @private
*/
if(!this._oContainer._oContent) {
// The oContent div helps size the iframe and shadow properly
}
else {
}
};
/**
* Clears out contents of container body and creates up to
* YAHOO.widget.AutoComplete#maxResultsDisplayed <li> elements in an
* <ul> element.
*
* @method _initList
* @private
*/
this._aListItems = [];
var oldListItems = this.getListItems();
if(oldListItems) {
oldListItems[oldi] = null;
}
}
}
for(var i=0; i<this.maxResultsDisplayed; i++) {
this._aListItems[i] = oItem;
this._initListItem(oItem, i);
}
this._maxResultsDisplayed = this.maxResultsDisplayed;
};
/**
* Initializes each <li> element in the container list.
*
* @method _initListItem
* @param oItem {HTMLElement} The <li> DOM element.
* @param nItemIndex {Number} The index of the element.
* @private
*/
var oSelf = this;
};
/**
* Enables interval detection for Korean IME support.
*
* @method _onIMEDetected
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
};
/**
* Enables query triggers based on text input detection by intervals (rather
* than by key events).
*
* @method _enableIntervalDetection
* @private
*/
var lastValue = this._sLastTextboxValue;
this._sLastTextboxValue = currValue;
this._sendQuery(currValue);
}
};
/**
* Cancels text input detection by intervals.
*
* @method _cancelIntervalDetection
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
if(oSelf._queryInterval) {
}
};
/**
* Whether or not key is functional or should be ignored. Note that the right
* arrow key is NOT an ignored key since it triggers queries for certain intl
* charsets.
*
* @method _isIgnoreKey
* @param nKeycode {Number} Code of key pressed.
* @return {Boolean} True if key should be ignored, false otherwise.
* @private
*/
/*(nKeyCode >= 36 && nKeyCode <= 38) || // home,left,up
(nKeyCode == 40) || // down*/
return true;
}
return false;
};
/**
* Makes query request to the DataSource.
*
* @method _sendQuery
* @param sQuery {String} Query string.
* @private
*/
// Widget has been effectively turned off
if(this.minQueryLength == -1) {
this._toggleContainer(false);
return;
}
// Delimiter has been enabled
if(aDelimChar) {
// Loop through all possible delimiters and find the latest one
// A " " may be a false positive if they are defined as delimiters AND
// are used to separate delimited queries
var nDelimIndex = -1;
if(nNewIndex > nDelimIndex) {
}
}
// 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] == " ") {
nDelimIndex--;
break;
}
}
}
// A delimiter has been found so extract the latest query
if(nDelimIndex > -1) {
// Trim any white space from the beginning...
nQueryStart += 1;
}
// ...and save the rest of the string for later
// Here is the query itself
}
this._sSavedQuery = null;
}
}
// Don't search queries that are too short
if(this._nDelayID != -1) {
clearTimeout(this._nDelayID);
}
this._toggleContainer(false);
return;
}
};
/**
* Populates the array of <li> elements in the container with query
* results. This method is passed to YAHOO.widget.DataSource#getResults as a
* callback function so results from the DataSource instance are returned to the
* AutoComplete instance.
*
* @method _populateList
* @param sQuery {String} The query string.
* @param aResults {Object[]} An array of query result objects from the DataSource.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
if(aResults === null) {
}
return;
}
oSelf._bItemSelected = false;
}
if(nItems > 0) {
// Fill items with data
var oResultItemi = aResults[i];
}
// Empty out remaining items if any
oItemj._sResultKey = null;
oItemj._oResultData = null;
}
// Expand the container
if(oSelf.autoHighlight) {
// Go to the first item
}
else {
}
}
else {
oSelf._toggleContainer(false);
}
};
/**
* When forceSelection is true and the user attempts
* leave the text input box without selecting an item from the query results,
* the user selection is cleared.
*
* @method _clearSelection
* @private
*/
if(nIndex > -1) {
}
else {
}
// Fire custom event
this.selectionEnforceEvent.fire(this);
};
/**
* Whether or not user-typed value in the text input box matches any of the
* query results.
*
* @method _textMatchesOption
* @return {HTMLElement} Matching list item element if user-input text matches
* a result, null otherwise.
* @private
*/
var foundMatch = null;
var oItem = this._aListItems[i];
foundMatch = oItem;
break;
}
}
return(foundMatch);
};
/**
* Updates in the text input box with the first query result as the user types,
* selecting the substring that the user has not typed.
*
* @method _typeAhead
* @param oItem {HTMLElement} The <li> element item whose data populates the input field.
* @param sQuery {String} Query string.
* @private
*/
// Don't update if turned off
return;
}
// Don't update with type-ahead if text selection is not supported
return;
}
// Select the portion of text that the user has not typed
this._updateValue(oItem);
};
/**
* Selects text in the input field.
*
* @method _selectText
* @param oTextbox {HTMLElement} Text input box element in which to select text.
* @param nStart {Number} Starting index of text string to select.
* @param nEnd {Number} Ending index of text selection.
* @private
*/
}
oTextRange.select();
}
else {
}
};
/**
* Syncs results container with its helpers.
*
* @method _toggleContainerHelpers
* @param bShow {Boolean} True if container is expanded, false if collapsed
* @private
*/
var bFireEvent = false;
bFireEvent = true;
if(bShow) {
}
else {
}
}
bFireEvent = true;
if(bShow) {
}
else {
}
}
};
/**
* Animates expansion or collapse of the container.
*
* @method _toggleContainer
* @param bShow {Boolean} True if container should be expanded, false if container should be collapsed
* @private
*/
var oContainer = this._oContainer;
// Implementer has container always open so don't mess with it
if(this.alwaysShowContainer && this._bContainerOpen) {
return;
}
// Clear contents of container
if(!bShow) {
var aItems = this._aListItems;
}
}
if(this._oCurItem) {
}
this._oCurItem = null;
this._nDisplayedItems = 0;
this._sCurQuery = null;
}
// Container is already closed
if(!bShow && !this._bContainerOpen) {
return;
}
// If animation is enabled...
// If helpers need to be collapsed, do it right away...
// but if helpers need to be expanded, wait until after the container expands
if(!bShow) {
this._toggleContainerHelpers(bShow);
}
if(oAnim.isAnimated()) {
}
// Clone container to grab current size offscreen
// Current size of the container is the EXPANDED size
// Calculate COLLAPSED sizes based on horiz and vert anim
// Set animation sizes
// If opening anew, set to a collapsed size...
if(bShow && !this._bContainerOpen) {
}
// Else, set it to its last known size.
else {
}
oClone = null;
var oSelf = this;
var onAnimComplete = function() {
// Finish the collapse
if(bShow) {
}
else {
}
};
// Display container and animate it
this._bContainerOpen = bShow;
}
// Else don't animate, just show or hide
else {
if(bShow) {
this.containerExpandEvent.fire(this);
}
else {
this.containerCollapseEvent.fire(this);
}
this._toggleContainerHelpers(bShow);
this._bContainerOpen = bShow;
}
};
/**
* Toggles the highlight on or off for an item in the container, and also cleans
* up highlighting of any previous item.
*
* @method _toggleHighlight
* @param oNewItem {HTMLElement} The <li> element item to receive highlight behavior.
* @param sType {String} Type "mouseover" will toggle highlight on, and "mouseout" will toggle highlight off.
* @private
*/
var sHighlight = this.highlightClassName;
if(this._oCurItem) {
// Remove highlight from old item
}
// Apply highlight to new item
}
};
/**
* Toggles the pre-highlight on or off for an item in the container.
*
* @method _togglePrehighlight
* @param oNewItem {HTMLElement} The <li> element item to receive highlight behavior.
* @param sType {String} Type "mouseover" will toggle highlight on, and "mouseout" will toggle highlight off.
* @private
*/
return;
}
var sPrehighlight = this.prehighlightClassName;
// Apply prehighlight to new item
}
else {
// Remove prehighlight from old item
}
};
/**
* Updates the text input box value with selected query result. If a delimiter
* has been defined, then the value gets appended with the delimiter.
*
* @method _updateValue
* @param oItem {HTMLElement} The <li> element item with which to update the value.
* @private
*/
var sSavedQuery = this._sSavedQuery;
// First clear text field
// Grab data to put into text field
if(sDelimChar) {
if(sSavedQuery) {
}
if(sDelimChar != " ") {
}
}
// scroll to bottom of textarea if necessary
}
// move cursor to end
};
/**
* Selects a result item from the container
*
* @method _selectItem
* @param oItem {HTMLElement} The selected <li> element item.
* @private
*/
this._bItemSelected = true;
this._updateValue(oItem);
this._cancelIntervalDetection(this);
this._toggleContainer(false);
};
/**
* If an item is highlighted in the container, the right arrow key jumps to the
* end of the textbox and selects the highlighted item, otherwise the container
* is closed.
*
* @method _jumpSelection
* @private
*/
if(this._oCurItem) {
this._selectItem(this._oCurItem);
}
else {
this._toggleContainer(false);
}
};
/**
* Triggered by up and down arrow keys, changes the current highlighted
* <li> element item. Scrolls container if necessary.
*
* @method _moveSelection
* @param nKeyCode {Number} Code of key pressed.
* @private
*/
if(this._bContainerOpen) {
// Determine current item's id number
var nCurItemIndex = -1;
if(oCurItem) {
}
// Out of bounds
return;
}
if(oCurItem) {
// Unhighlight current item
}
if(nNewItemIndex == -1) {
// Go back to query (remove type-ahead string)
if(this.delimChar && this._sSavedQuery) {
if(!this._textMatchesOption()) {
}
else {
}
}
else {
}
this._oCurItem = null;
return;
}
if(nNewItemIndex == -2) {
// Close container
this._toggleContainer(false);
return;
}
// Scroll the container if necessary
(nNewItemIndex < this._nDisplayedItems)) {
// User is keying down
if(nKeyCode == 40) {
// Bottom of selected item is below scroll area...
// Set bottom of scroll area to bottom of selected item
}
// Bottom of selected item is above scroll area...
// Set top of selected item to top of scroll area
}
}
// User is keying up
else {
// Top of selected item is above scroll area
// Set top of scroll area to top of selected item
}
// Top of selected item is below scroll area
// Set bottom of selected item to bottom of scroll area
this._oContainer._oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - oContent.offsetHeight;
}
}
}
if(this.typeAhead) {
this._updateValue(oNewItem);
}
}
};
/////////////////////////////////////////////////////////////////////////////
//
// Private event handlers
//
/////////////////////////////////////////////////////////////////////////////
/**
* Handles <li> element mouseover events in the container.
*
* @method _onItemMouseover
* @param v {HTMLEvent} The mouseover event.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
if(oSelf.prehighlightClassName) {
}
else {
}
};
/**
* Handles <li> element mouseout events in the container.
*
* @method _onItemMouseout
* @param v {HTMLEvent} The mouseout event.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
if(oSelf.prehighlightClassName) {
}
else {
}
};
/**
* Handles <li> element click events in the container.
*
* @method _onItemMouseclick
* @param v {HTMLEvent} The click event.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
// In case item has not been moused over
oSelf._selectItem(this);
};
/**
* Handles container mouseover events.
*
* @method _onContainerMouseover
* @param v {HTMLEvent} The mouseover event.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
oSelf._bOverContainer = true;
};
/**
* Handles container mouseout events.
*
* @method _onContainerMouseout
* @param v {HTMLEvent} The mouseout event.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
oSelf._bOverContainer = false;
// If container is still active
}
};
/**
* Handles container scroll events.
*
* @method _onContainerScroll
* @param v {HTMLEvent} The scroll event.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
};
/**
* Handles container resize events.
*
* @method _onContainerResize
* @param v {HTMLEvent} The resize event.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
};
/**
* Handles textbox keydown events of functional keys, mainly for UI behavior.
*
* @method _onTextboxKeyDown
* @param v {HTMLEvent} The keydown event.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
switch (nKeyCode) {
case 9: // tab
// select an item or clear out
if(oSelf._bContainerOpen) {
}
}
}
else {
oSelf._toggleContainer(false);
}
break;
case 13: // enter
if(oSelf._bContainerOpen) {
}
}
}
else {
oSelf._toggleContainer(false);
}
break;
case 27: // esc
oSelf._toggleContainer(false);
return;
case 39: // right
break;
case 38: // up
break;
case 40: // down
break;
default:
break;
}
};
/**
* Handles textbox keypress events.
* @method _onTextboxKeyPress
* @param v {HTMLEvent} The keypress event.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
//Expose only to Mac browsers, where stopEvent is ineffective on keydown events (bug 790337)
if(isMac) {
switch (nKeyCode) {
case 9: // tab
}
break;
case 13: // enter
}
break;
case 38: // up
case 40: // down
break;
default:
break;
}
}
//TODO: (?) limit only to non-IE, non-Mac-FF for Korean IME support (bug 811948)
// Korean IME detected
else if(nKeyCode == 229) {
}
};
/**
* Handles textbox keyup events that trigger queries.
*
* @method _onTextboxKeyUp
* @param v {HTMLEvent} The keyup event.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
// Check to see if any of the public properties have been updated
oSelf._initProps();
// Filter out chars that don't trigger queries
return;
}
else {
oSelf._bItemSelected = false;
}
// Set timeout on the request
var nDelayID =
}
}
else {
// No delay so send request immediately
}
};
/**
* Handles text input box receiving focus.
*
* @method _onTextboxFocus
* @param v {HTMLEvent} The focus event.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
if(!oSelf._bItemSelected) {
}
};
/**
* Handles text input box losing focus.
*
* @method _onTextboxBlur
* @param v {HTMLEvent} The focus event.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
// Don't treat as a blur if it was a selection via mouse click
// Current query needs to be validated
if(!oSelf._bItemSelected) {
if(oSelf.forceSelection) {
}
else {
}
}
else {
}
}
if(oSelf._bContainerOpen) {
oSelf._toggleContainer(false);
}
}
};
/**
* Handles form submission event.
*
* @method _onFormSubmit
* @param v {HTMLEvent} The submit event.
* @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
* @private
*/
}
else {
}
};
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
/**
* The DataSource classes manages sending a request and returning response from a live
* database. Supported data include local JavaScript arrays and objects and databases
* accessible via XHR connections. Supported response formats include JavaScript arrays,
* JSON, XML, and flat-file textual data.
*
* @class DataSource
* @constructor
*/
/* abstract class */
};
/////////////////////////////////////////////////////////////////////////////
//
// Public constants
//
/////////////////////////////////////////////////////////////////////////////
/**
* Error message for null data responses.
*
* @property ERROR_DATANULL
* @type String
* @static
* @final
*/
/**
* Error message for data responses with parsing errors.
*
* @property ERROR_DATAPARSE
* @type String
* @static
* @final
*/
/////////////////////////////////////////////////////////////////////////////
//
// Public member variables
//
/////////////////////////////////////////////////////////////////////////////
/**
* Max size of the local cache. Set to 0 to turn off caching. Caching is
* useful to reduce the number of server connections. Recommended only for data
* sources that return comprehensive results for queries or when stale data is
* not an issue.
*
* @property maxCacheEntries
* @type Number
* @default 15
*/
/**
* Use this to fine-tune the matching algorithm used against JS Array types of
* DataSource and DataSource caches. If queryMatchContains is true, then the JS
* Array or cache returns results that "contain" the query string. By default,
* queryMatchContains is set to false, so that only results that "start with"
* the query string are returned.
*
* @property queryMatchContains
* @type Boolean
* @default false
*/
/**
* Enables query subset matching. If caching is on and queryMatchSubset is
* true, substrings of queries will return matching cached results. For
* instance, if the first query is for "abc" susequent queries that start with
* "abc", like "abcd", will be queried against the cache, and not the live data
* source. Recommended only for DataSources that return comprehensive results
* for queries with very few characters.
*
* @property queryMatchSubset
* @type Boolean
* @default false
*
*/
/**
* Enables case-sensitivity in the matching algorithm used against JS Array
* types of DataSources and DataSource caches. If queryMatchCase is true, only
* case-sensitive matches will return.
*
* @property queryMatchCase
* @type Boolean
* @default false
*/
/////////////////////////////////////////////////////////////////////////////
//
// Public methods
//
/////////////////////////////////////////////////////////////////////////////
/**
* Public accessor to the unique name of the DataSource instance.
*
* @method toString
* @return {String} Unique name of the DataSource instance
*/
return "DataSource " + this._sName;
};
/**
* Retrieves query results, first checking the local cache, then making the
* query request to the live data source as defined by the function doQuery.
*
* @method getResults
* @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.
*/
// First look in cache
// Not in cache, so get results from server
}
};
/**
* Abstract method implemented by subclasses to make a query to the live data
* source. Must call the callback function with the response returned from the
* query. Populates cache (if enabled).
*
* @method doQuery
* @param oCallbackFn {HTMLFunction} Callback function implemented by oParent to which to return results.
* @param sQuery {String} Query string.
* @param oParent {Object} The object instance that has requested data.
*/
/* override this */
};
/**
* Flushes cache.
*
* @method flushCache
*/
if(this._aCache) {
this._aCache = [];
}
if(this._aCacheHelper) {
this._aCacheHelper = [];
}
this.cacheFlushEvent.fire(this);
};
/////////////////////////////////////////////////////////////////////////////
//
// Public events
//
/////////////////////////////////////////////////////////////////////////////
/**
* Fired when a query is made to the live data source.
*
* @event queryEvent
* @param oSelf {Object} The DataSource instance.
* @param oParent {Object} The requesting object.
* @param sQuery {String} The query string.
*/
/**
* Fired when a query is made to the local cache.
*
* @event cacheQueryEvent
* @param oSelf {Object} The DataSource instance.
* @param oParent {Object} The requesting object.
* @param sQuery {String} The query string.
*/
/**
* Fired when data is retrieved from the live data source.
*
* @event getResultsEvent
* @param oSelf {Object} The DataSource instance.
* @param oParent {Object} The requesting object.
* @param sQuery {String} The query string.
* @param aResults {Object[]} Array of result objects.
*/
/**
* Fired when data is retrieved from the local cache.
*
* @event getCachedResultsEvent
* @param oSelf {Object} The DataSource instance.
* @param oParent {Object} The requesting object.
* @param sQuery {String} The query string.
* @param aResults {Object[]} Array of result objects.
*/
/**
* Fired when an error is encountered with the live data source.
*
* @event dataErrorEvent
* @param oSelf {Object} The DataSource instance.
* @param oParent {Object} The requesting object.
* @param sQuery {String} The query string.
* @param sMsg {String} Error message string
*/
/**
* Fired when the local cache is flushed.
*
* @event cacheFlushEvent
* @param oSelf {Object} The DataSource instance
*/
/////////////////////////////////////////////////////////////////////////////
//
// Private member variables
//
/////////////////////////////////////////////////////////////////////////////
/**
* Internal class variable to index multiple DataSource instances.
*
* @property _nIndex
* @type Number
* @private
* @static
*/
/**
* Name of DataSource instance.
*
* @property _sName
* @type String
* @private
*/
/**
* Local cache of data result objects indexed chronologically.
*
* @property _aCache
* @type Object[]
* @private
*/
/////////////////////////////////////////////////////////////////////////////
//
// Private methods
//
/////////////////////////////////////////////////////////////////////////////
/**
* Initializes DataSource instance.
*
* @method _init
* @private
*/
// Validate and initialize public configs
var maxCacheEntries = this.maxCacheEntries;
maxCacheEntries = 0;
}
// Initialize local cache
this._aCache = [];
}
};
/**
* Adds a result object to the local cache, evicting the oldest element if the
* cache is full. Newer items will have higher indexes, the oldest item will have
* index of 0.
*
* @method _addCacheElem
* @param oResult {Object} Data result object, including array of results.
* @private
*/
// Don't add if anything important is missing.
return;
}
// If the cache is full, make room by removing from index=0
}
// Add to cache, at the end of the array
};
/**
* Queries the local cache for results. If query has been cached, the callback
* function is called with the results, and the cached is refreshed so that it
* is now the newest element.
*
* @method _doQueryCache
* @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.
* @return aResults {Object[]} Array of results from local cache if found, otherwise null.
* @private
*/
var aResults = [];
var bMatchFound = false;
var bMatchContains = this.queryMatchContains;
// If cache is enabled...
// If case is unimportant, normalize query now instead of in loops
if(!this.queryMatchCase) {
var sOrigQuery = sQuery;
}
// Loop through each cached element's query property...
// If case is unimportant, normalize match key for comparison
var matchKey = (!this.queryMatchCase) ?
// If a cached match key exactly matches the query...
// Stash all result objects into aResult[] and stop looping through the cache.
bMatchFound = true;
// The matching cache element was not the most recent,
// so now we need to refresh the cache.
if(i != nCacheLength-1) {
// Remove element from its original location
// Add element as newest
this._addCacheElem(resultObj);
}
break;
}
// Else if this query is not an exact match and subset matching is enabled...
else if(this.queryMatchSubset) {
// Loop through substrings of each cached element's query property...
// If a substring of a cached sQuery exactly matches the query...
bMatchFound = true;
// Go through each cached result object to match against the query...
var aRecord = aAllResultItems[k];
var sKeyIndex = (this.queryMatchCase) ?
// A STARTSWITH match is when the query is found at the beginning of the key string...
// A CONTAINS match is when the query is found anywhere within the key string...
// Stash a match into aResults[].
}
}
// Add the subset match result set object as the newest element to cache,
// and stop looping through the cache.
resultObj = {};
this._addCacheElem(resultObj);
break;
}
}
if(bMatchFound) {
break;
}
}
}
// If there was a match, send along the results.
if(bMatchFound) {
}
}
return aResults;
};
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
/**
* Implementation of YAHOO.widget.DataSource using XML HTTP requests that return
* query results.
*
* @class DS_XHR
* @extends YAHOO.widget.DataSource
* @requires connection
* @constructor
* @param sScriptURI {String} Absolute or relative URI to script that returns query
* results as JSON, XML, or delimited flat-file data.
* @param aSchema {String[]} Data schema definition of results.
* @param oConfigs {Object} (optional) Object literal of config params.
*/
// Set any config params passed in to override defaults
}
}
// Initialization sequence
YAHOO.log("Could not instantiate XHR DataSource due to invalid arguments", "error", this.toString());
return;
}
this.scriptURI = sScriptURI;
this._init();
};
/////////////////////////////////////////////////////////////////////////////
//
// Public constants
//
/////////////////////////////////////////////////////////////////////////////
/**
* JSON data type.
*
* @property TYPE_JSON
* @type Number
* @static
* @final
*/
/**
* XML data type.
*
* @property TYPE_XML
* @type Number
* @static
* @final
*/
/**
* Flat-file data type.
*
* @property TYPE_FLAT
* @type Number
* @static
* @final
*/
/**
* Error message for XHR failure.
*
* @property ERROR_DATAXHR
* @type String
* @static
* @final
*/
/////////////////////////////////////////////////////////////////////////////
//
// Public member variables
//
/////////////////////////////////////////////////////////////////////////////
/**
* Alias to YUI Connection Manager. Allows implementers to specify their own
* subclasses of the YUI Connection Manager utility.
*
* @property connMgr
* @type Object
* @default YAHOO.util.Connect
*/
/**
* Number of milliseconds the XHR connection will wait for a server response. A
* a value of zero indicates the XHR connection will wait forever. Any value
* greater than zero will use the Connection utility's Auto-Abort feature.
*
* @property connTimeout
* @type Number
* @default 0
*/
/**
* Absolute or relative URI to script that returns query results. For instance,
* queries will be sent to <scriptURI>?<scriptQueryParam>=userinput
*
* @property scriptURI
* @type String
*/
/**
* Query string parameter name sent to scriptURI. For instance, queries will be
* sent to <scriptURI>?<scriptQueryParam>=userinput
*
* @property scriptQueryParam
* @type String
* @default "query"
*/
/**
* this string when you want to send additional query parameters to your script.
* When defined, queries will be sent to
* <scriptURI>?<scriptQueryParam>=userinput&<scriptQueryAppend>
*
* @property scriptQueryAppend
* @type String
* @default ""
*/
/**
* XHR response data type. Other types that may be defined are YAHOO.widget.DS_XHR.TYPE_XML
* and YAHOO.widget.DS_XHR.TYPE_FLAT.
*
* @property responseType
* @type String
* @default YAHOO.widget.DS_XHR.TYPE_JSON
*/
/**
* String after which to strip results. If the results from the XHR are sent
* back as HTML, the gzip HTML comment appears at the end of the data and should
* be ignored.
*
* @property responseStripAfter
* @type String
* @default "\n<!-"
*/
/////////////////////////////////////////////////////////////////////////////
//
// Public methods
//
/////////////////////////////////////////////////////////////////////////////
/**
* Queries the live data source defined by scriptURI 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.
*/
}
var oResponse = null;
var oSelf = this;
/*
* Sets up ajax request callback
*
* @param {object} oReq HTTPXMLRequest object
* @private
*/
var responseSuccess = function(oResp) {
// Response ID does not match last made request ID.
return;
}
//DEBUG
/*YAHOO.log(oResp.responseXML.getElementsByTagName("Result"),'warn');
for(var foo in oResp) {
YAHOO.log(foo + ": "+oResp[foo],'warn');
}
YAHOO.log('responseXML.xml: '+oResp.responseXML.xml,'warn');*/
if(!isXML) {
}
else {
}
if(oResp === null) {
return;
}
var resultObj = {};
if(aResults === null) {
aResults = [];
}
else {
}
};
var responseFailure = function(oResp) {
return;
};
var oCallback = {
};
}
if(this._oConn) {
}
};
/**
* Parses raw response data into an array of result objects. The result data key
* is always stashed in the [0] element of each result object.
*
* @method parseResponse
* @param sQuery {String} Query string.
* @param oResponse {Object} The raw response data to parse.
* @param oParent {Object} The object instance that has requested data.
* @returns {Object[]} Array of result objects.
*/
var aResults = [];
var bError = false;
// Strip out comment at the end of results
if(nEnd != -1) {
}
switch (this.responseType) {
var jsonList, jsonObjParsed;
// Check for JSON lib but divert KHTML clients
// Use the new JSON utility if available
if(!jsonObjParsed) {
bError = true;
}
else {
try {
// eval is necessary here since aSchema[0] is of unknown depth
}
catch(e) {
bError = true;
break;
}
}
}
// Use older JSON lib if available
if(!jsonObjParsed) {
bError = true;
break;
}
else {
try {
// eval is necessary here since aSchema[0] is of unknown depth
}
catch(e) {
bError = true;
break;
}
}
}
else {
// Parse the JSON response as a string
try {
// Trim leading spaces
}
// Invalid JSON response
bError = true;
break;
}
// Empty (but not invalid) JSON response
break;
}
// Turn the string into an object literal...
// ...eval is necessary here
if(!jsonObjRaw) {
bError = true;
break;
}
// Grab the object member that contains an array of all reponses...
// ...eval is necessary here since aSchema[0] is of unknown depth
}
catch(e) {
bError = true;
break;
}
}
if(!jsonList) {
bError = true;
break;
}
}
// Loop through the array of all responses...
var aResultItem = [];
var jsonResult = jsonList[i];
// ...and loop through each data field value of each response
// ...and capture data into an array mapped according to the schema...
if(!dataFieldValue) {
dataFieldValue = "";
}
//YAHOO.log("data: " + i + " value:" +j+" = "+dataFieldValue,"debug",this.toString());
}
// If schema isn't well defined, pass along the entire result object
}
// Capture the array of data field values in an array of results
}
break;
// Get the collection of results
if(!xmlList) {
bError = true;
break;
}
// Loop through each result
//YAHOO.log("Result"+k+" is "+result.attributes.item(0).firstChild.nodeValue,"debug",this.toString());
var aFieldSet = [];
// Loop through each data field in each result using the schema
//YAHOO.log(aSchema[m]+" is "+result.attributes.getNamedItem(aSchema[m]).firstChild.nodeValue);
var sValue = null;
// Values may be held in an attribute...
if(xmlAttr) {
//YAHOO.log("Attr value is "+sValue,"debug",this.toString());
}
// ...or in a node
else{
//YAHOO.log("Node value is "+sValue,"debug",this.toString());
}
else {
sValue = "";
//YAHOO.log("Value not found","debug",this.toString());
}
}
// Capture the schema-mapped data field values into an array
}
// Capture each array of values into an array of results
}
break;
// Delete the last line delimiter at the end of the data if it exists
}
}
}
break;
default:
break;
}
sQuery = null;
oResponse = null;
oParent = null;
if(bError) {
return null;
}
else {
return aResults;
}
};
/////////////////////////////////////////////////////////////////////////////
//
// Private member variables
//
/////////////////////////////////////////////////////////////////////////////
/**
* XHR connection object.
*
* @property _oConn
* @type Object
* @private
*/
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
/**
* 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.
*/
// Set any config params passed in to override defaults
}
}
// Initialization sequence
YAHOO.log("Could not instantiate JSFunction DataSource due to invalid arguments", "error", this.toString());
return;
}
else {
this.dataFunction = oFunction;
this._init();
}
};
/////////////////////////////////////////////////////////////////////////////
//
// Public member variables
//
/////////////////////////////////////////////////////////////////////////////
/**
* In-memory Javascript function that returns query results.
*
* @property dataFunction
* @type HTMLFunction
*/
/////////////////////////////////////////////////////////////////////////////
//
// 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.
*/
var oFunction = this.dataFunction;
var aResults = [];
if(aResults === null) {
return;
}
var resultObj = {};
this._addCacheElem(resultObj);
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.
*/
// Set any config params passed in to override defaults
}
}
// Initialization sequence
YAHOO.log("Could not instantiate JSArray DataSource due to invalid arguments", "error", this.toString());
return;
}
else {
this._init();
}
};
/////////////////////////////////////////////////////////////////////////////
//
// Public member variables
//
/////////////////////////////////////////////////////////////////////////////
/**
* In-memory Javascript array of strings.
*
* @property data
* @type Array
*/
/////////////////////////////////////////////////////////////////////////////
//
// 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.
*/
var i;
var aResults = []; // container for results
var bMatchFound = false;
var bMatchContains = this.queryMatchContains;
if(sQuery) {
if(!this.queryMatchCase) {
}
// Loop through each element of the array...
// which can be a string or an array of strings
var aDataset = [];
}
}
var sKeyIndex = (this.queryMatchCase) ?
// A STARTSWITH match is when the query is found at the beginning of the key string...
// A CONTAINS match is when the query is found anywhere within the key string...
// Stash a match into aResults[].
}
}
}
}
else {
}
}
}
}
};