⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autocomplete.js

📁 SugarCRM5.1 开源PHP客户关系管理系统
💻 JS
📖 第 1 页 / 共 5 页
字号:
    else {        this._oContainer._oContent._oFooter.innerHTML = "";        this._oContainer._oContent._oFooter.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(sBody) {        if(this._oContainer._oContent._oBody) {            this._oContainer._oContent._oBody.innerHTML = sBody;            this._oContainer._oContent._oBody.style.display = "block";            this._oContainer._oContent.style.display = "block";        }    }    else {        this._oContainer._oContent._oBody.innerHTML = "";        this._oContainer._oContent.style.display = "none";    }    this._maxResultsDisplayed = 0;};/** * 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 * @return {Boolean} Return true to continue expanding container, false to cancel the expand. */YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer = function(oResultItem, sQuery) {    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);};///////////////////////////////////////////////////////////////////////////////// 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&gt 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. * Note that this event may not behave as expected when delimiter characters * have been defined.  * * @event unmatchedItemSelectEvent * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. * @param sQuery {String} The user-typed query string. */YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent = null;/** * 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 _oTextbox * @type HTMLElement * @private */YAHOO.widget.AutoComplete.prototype._oTextbox = 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;/** * Container DOM element. * * @property _oContainer * @type HTMLElement * @private */YAHOO.widget.AutoComplete.prototype._oContainer = 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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -