autocomplete-list-min.js revision ce76332f7c5a79a0abc3c9e457804818ff5affea
YUI.add("autocomplete-list",function(B){var E=B.Node,F=B.Array,D="input",A="inputNode",C="tray",I="trayNode",G="trayVisible",H=B.Base.create("autocompleteList",B.Widget,[B.AutoCompleteBase],{initializer:function(){this._events=[];},destructor:function(){this._unbindInput();while(this._events.length){this._events.pop().detach();}},bindUI:function(){this._bindInput();this._bindTray();},renderUI:function(){this._contentBox=this.get("contentBox");this._renderInput();this._renderTray();},syncUI:function(){this._syncInput();this._syncTray();},hideTray:function(){this.set(G,false);},showTray:function(){this.set(G,true);},_addResult:function(J){var K=E.create(H.HTML_TEMPLATE.resultNode.replace("{result}",J));K.addClass(this.getClassName("result")).setAttrs({id:B.stamp(K),role:"option"});this._trayNode.append(K);},_bindTray:function(){this._events.concat([this.after("resultsChange",this._afterResultsChange,this),this.after("trayVisibleChange",this._afterTrayVisibleChange,this)]);},_clearTray:function(){this._trayNode.setContent("");},_renderInput:function(){var J=this.get(A);if(!J){J=E.create(H.HTML_TEMPLATE[A]);this._contentBox.appendChild(J);this.set(A,J);}J.addClass(this.getClassName(D));J.setAttrs({"aria-autocomplete":"list",role:"combobox"});this._inputNode=J;},_renderTray:function(){var K,J=this.get(I);if(!J){J=E.create(H.HTML_TEMPLATE[I]);this._contentBox.appendChild(J);this.set(I,J);}J.addClass(this.getClassName(C));if(!(K=J.get("id"))){J.set("id",K=B.stamp(J));}J.set("role","listbox");this._inputNode.set("aria-owns",K);this._trayNode=J;},_syncTray:function(){this._syncTrayVisibility();this._syncTrayResults();},_syncTrayResults:function(J){if(!J){J=this.get("results");}this._clearTray();F.each(J,this._addResult,this);},_syncTrayVisibility:function(J){if(J===undefined){J=this.get(G);}this._trayNode.toggleClass(this.getClassName("hidden"),!J);this._trayNode.set("aria-hidden",!J);this._inputNode.set("aria-expanded",J);},_afterResultsChange:function(J){this._syncTrayResults(J.newVal);this.set(G,!!J.newVal.length);},_afterTrayVisibleChange:function(J){this._syncTrayVisibility(!!J.newVal);}},{ATTRS:{trayNode:{setter:B.one,writeOnce:"initOnly"},trayVisible:{value:false}},CSS_PREFIX:B.ClassNameManager.getClassName("aclist"),HTML_PARSER:{inputNode:function(J){return J.one("input."+this.getClassName(D)+",input[type=text]");},trayNode:function(J){return J.one("."+this.getClassName(C));}},HTML_TEMPLATE:{inputNode:'<input type="text">',resultNode:"<li>{result}</li>",trayNode:"<ul/>"}});B.AutoCompleteList=H;},"@VERSION@",{skinnable:true,requires:["autocomplete-base","widget"]});