(function(window, document) { var CompletionDialog = function(options) { this.options = options } CompletionDialog.prototype = { show: function() { this.showCompletions() }, showCompletions: function(searchString, completions) { this.searchString = searchString; this.completions = completions; if(!this.initialized) { initialize.call(this); this.initialized=true; } var container = this.getDisplayElement() clearChildren(container); if(searchString===undefined) { this.container.className = "dialog"; createDivInside(container).innerHTML=this.options.initialSearchText || "Begin typing" } else { this.container.className = "dialog completions"; var searchBar = createDivInside(container) searchBar.innerHTML=searchString searchBar.className="searchBar" searchResults = createDivInside(container) searchResults.className="searchResults" if(completions.length<=0) { var resultDiv = createDivInside(searchResults) resultDiv.className="noResults" resultDiv.innerHTML="No results found" } else { for(var i=0;i0) { self.currentSelection-=1; } self.showCompletions(self.searchString, self.completions) } else if(keyChar==="down") { if(self.currentSelection= 1) { elem.removeChild(elem.firstChild); } } } var completionCSS = ".dialog {"+ "position:fixed;"+ "background-color: #ebebeb;" + "z-index: 99999998;" + "border: 1px solid #b3b3b3;" + "font-size: 12px;" + "text-align:left;"+ "color: black;" + "padding:10px;"+ "border-radius: 4px;" + "font-family: Lucida Grande, Arial, Sans;" + "}"+ ".completions {"+ "width:400px;"+ "}"+ ".completions .searchBar {"+ "height: 15px;"+ "border-bottom: 1px solid #b3b3b3;"+ "}"+ ".completions .searchResults {"+ "}"+ ".completions .searchResults .selected{"+ "background-color:#aaa;"+ "border-radius: 4px;" + "}"+ ".completions div{"+ "padding:4px;"+ "}"+ ".completions div strong{"+ "font-weight:bold;"+ "}"+ ".completions .noResults{"+ "color:#555;"+ "}"; window.CompletionDialog = CompletionDialog; }(window, document))