📄 autocomplete-debug.js
字号:
//////////////////////////////////////////////////////////////////////////////** * Internal class variable to index multiple AutoComplete instances. * * @property _nIndex * @type Number * @default 0 * @private */YAHOO.widget.AutoComplete._nIndex = 0;/** * Name of AutoComplete instance. * * @property _sName * @type String * @private */YAHOO.widget.AutoComplete.prototype._sName = null;/** * Text input field DOM element. * * @property _elTextbox * @type HTMLElement * @private */YAHOO.widget.AutoComplete.prototype._elTextbox = null;/** * Container DOM element. * * @property _elContainer * @type HTMLElement * @private */YAHOO.widget.AutoComplete.prototype._elContainer = null;/** * Reference to content element within container element. * * @property _elContent * @type HTMLElement * @private */YAHOO.widget.AutoComplete.prototype._elContent = null;/** * Reference to header element within content element. * * @property _elHeader * @type HTMLElement * @private */YAHOO.widget.AutoComplete.prototype._elHeader = null;/** * Reference to body element within content element. * * @property _elBody * @type HTMLElement * @private */YAHOO.widget.AutoComplete.prototype._elBody = null;/** * Reference to footer element within content element. * * @property _elFooter * @type HTMLElement * @private */YAHOO.widget.AutoComplete.prototype._elFooter = null;/** * Reference to shadow element within container element. * * @property _elShadow * @type HTMLElement * @private */YAHOO.widget.AutoComplete.prototype._elShadow = null;/** * Reference to iframe element within container element. * * @property _elIFrame * @type HTMLElement * @private */YAHOO.widget.AutoComplete.prototype._elIFrame = null;/** * Whether or not the input field is currently in focus. If query results come back * but the user has already moved on, do not proceed with auto complete behavior. * * @property _bFocused * @type Boolean * @private */YAHOO.widget.AutoComplete.prototype._bFocused = null;/** * Animation instance for container expand/collapse. * * @property _oAnim * @type Boolean * @private */YAHOO.widget.AutoComplete.prototype._oAnim = null;/** * Whether or not the results container is currently open. * * @property _bContainerOpen * @type Boolean * @private */YAHOO.widget.AutoComplete.prototype._bContainerOpen = false;/** * Whether or not the mouse is currently over the results * container. This is necessary in order to prevent clicks on container items * from being text input field blur events. * * @property _bOverContainer * @type Boolean * @private */YAHOO.widget.AutoComplete.prototype._bOverContainer = false;/** * Internal reference to <ul> elements that contains query results within the * results container. * * @property _elList * @type HTMLElement * @private */YAHOO.widget.AutoComplete.prototype._elList = null;/* * Array of <li> elements references that contain query results within the * results container. * * @property _aListItemEls * @type HTMLElement[] * @private *///YAHOO.widget.AutoComplete.prototype._aListItemEls = 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;/** * Selections from previous queries (for saving delimited queries). * * @property _sPastSelections * @type String * @default "" * @private */YAHOO.widget.AutoComplete.prototype._sPastSelections = "";/** * Stores initial input value used to determine if textboxChangeEvent should be fired. * * @property _sInitInputValue * @type String * @private */YAHOO.widget.AutoComplete.prototype._sInitInputValue = null;/** * Pointer to the currently highlighted <li> element in the container. * * @property _elCurListItem * @type HTMLElement * @private */YAHOO.widget.AutoComplete.prototype._elCurListItem = 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;/** * TypeAhead delay timeout ID. * * @property _nTypeAheadDelayID * @type Number * @private */YAHOO.widget.AutoComplete.prototype._nTypeAheadDelayID = -1;/** * Src to iFrame used when useIFrame = true. Supports implementations over SSL * as well. * * @property _iFrameSrc * @type String * @private */YAHOO.widget.AutoComplete.prototype._iFrameSrc = "javascript:false;";/** * For users typing via certain IMEs, queries must be triggered by intervals, * since key events yet supported across all browsers for all IMEs. * * @property _queryInterval * @type Object * @private */YAHOO.widget.AutoComplete.prototype._queryInterval = null;/** * Internal tracker to last known textbox value, used to determine whether or not * to trigger a query via interval for certain IME users. * * @event _sLastTextboxValue * @type String * @private */YAHOO.widget.AutoComplete.prototype._sLastTextboxValue = null;///////////////////////////////////////////////////////////////////////////////// Private methods////////////////////////////////////////////////////////////////////////////////** * Updates and validates latest public config properties. * * @method __initProps * @private */YAHOO.widget.AutoComplete.prototype._initProps = function() { // Correct any invalid values var minQueryLength = this.minQueryLength; if(!YAHOO.lang.isNumber(minQueryLength)) { this.minQueryLength = 1; } var maxResultsDisplayed = this.maxResultsDisplayed; if(!YAHOO.lang.isNumber(maxResultsDisplayed) || (maxResultsDisplayed < 1)) { this.maxResultsDisplayed = 10; } var queryDelay = this.queryDelay; if(!YAHOO.lang.isNumber(queryDelay) || (queryDelay < 0)) { this.queryDelay = 0.2; } var typeAheadDelay = this.typeAheadDelay; if(!YAHOO.lang.isNumber(typeAheadDelay) || (typeAheadDelay < 0)) { this.typeAheadDelay = 0.2; } var delimChar = this.delimChar; if(YAHOO.lang.isString(delimChar) && (delimChar.length > 0)) { this.delimChar = [delimChar]; } else if(!YAHOO.lang.isArray(delimChar)) { this.delimChar = null; } var animSpeed = this.animSpeed; if((this.animHoriz || this.animVert) && YAHOO.util.Anim) { if(!YAHOO.lang.isNumber(animSpeed) || (animSpeed < 0)) { this.animSpeed = 0.3; } if(!this._oAnim ) { this._oAnim = new YAHOO.util.Anim(this._elContent, {}, this.animSpeed); } else { this._oAnim.duration = this.animSpeed; } } if(this.forceSelection && delimChar) { YAHOO.log("The forceSelection feature has been enabled with delimChar defined.","warn", this.toString()); }};/** * Initializes the results container helpers if they are enabled and do * not exist * * @method _initContainerHelperEls * @private */YAHOO.widget.AutoComplete.prototype._initContainerHelperEls = function() { if(this.useShadow && !this._elShadow) { var elShadow = document.createElement("div"); elShadow.className = "yui-ac-shadow"; elShadow.style.width = 0; elShadow.style.height = 0; this._elShadow = this._elContainer.appendChild(elShadow); } if(this.useIFrame && !this._elIFrame) { var elIFrame = document.createElement("iframe"); elIFrame.src = this._iFrameSrc; elIFrame.frameBorder = 0; elIFrame.scrolling = "no"; elIFrame.style.position = "absolute"; elIFrame.style.width = 0; elIFrame.style.height = 0; elIFrame.tabIndex = -1; elIFrame.style.padding = 0; this._elIFrame = this._elContainer.appendChild(elIFrame); }};/** * Initializes the results container once at object creation * * @method _initContainerEl * @private */YAHOO.widget.AutoComplete.prototype._initContainerEl = function() { YAHOO.util.Dom.addClass(this._elContainer, "yui-ac-container"); if(!this._elContent) { // The elContent div is assigned DOM listeners and // helps size the iframe and shadow properly var elContent = document.createElement("div"); elContent.className = "yui-ac-content"; elContent.style.display = "none"; this._elContent = this._elContainer.appendChild(elContent); var elHeader = document.createElement("div"); elHeader.className = "yui-ac-hd"; elHeader.style.display = "none"; this._elHeader = this._elContent.appendChild(elHeader); var elBody = document.createElement("div"); elBody.className = "yui-ac-bd"; this._elBody = this._elContent.appendChild(elBody);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -