From bf3e63a75b8fbc9d613ec3fd6289a178731692e4 Mon Sep 17 00:00:00 2001 From: Reed Loden Date: Mon, 5 Jul 2010 02:42:01 -0500 Subject: Bug 455810 - Add autocomplete support to the keywords field * Special thanks to Guy Pyrzak for the original patch [r=mkanat a=mkanat] --- js/field.js | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/field.js b/js/field.js index 39b272f92..20485bcc8 100644 --- a/js/field.js +++ b/js/field.js @@ -16,6 +16,7 @@ * * Contributor(s): Max Kanat-Alexander * Guy Pyrzak + * Reed Loden */ /* This library assumes that the needed YUI libraries have been loaded @@ -621,8 +622,8 @@ YAHOO.bugzilla.userAutocomplete = { userAutoComp.autoHighlight = false; // this is a throttle to determine the delay of the query from typing // set this higher to cause fewer calls to the server - userAutoComp.queryDelay = 0.05 - userAutoComp.useIFrame = true + userAutoComp.queryDelay = 0.05; + userAutoComp.useIFrame = true; userAutoComp.resultTypeList = false; if( multiple == true ){ userAutoComp.delimChar = [","," "]; @@ -631,3 +632,32 @@ YAHOO.bugzilla.userAutocomplete = { } }; +YAHOO.bugzilla.keywordAutocomplete = { + dataSource : null, + init_ds : function(){ + this.dataSource = new YAHOO.util.LocalDataSource( YAHOO.bugzilla.keyword_array ); + }, + init : function( field, container ) { + if( this.dataSource == null ){ + this.init_ds(); + } + var keywordAutoComp = new YAHOO.widget.AutoComplete(field, container, this.dataSource); + keywordAutoComp.maxResultsDisplayed = YAHOO.bugzilla.keyword_array.length; + keywordAutoComp.minQueryLength = 0; + keywordAutoComp.useIFrame = true; + keywordAutoComp.delimChar = [","," "]; + keywordAutoComp.resultTypeList = false; + keywordAutoComp.queryDelay = 0; + /* Causes all the possibilities in the keyword to appear when a user + * focuses on the textbox + */ + keywordAutoComp.textboxFocusEvent.subscribe( function(){ + var sInputValue = YAHOO.util.Dom.get('keywords').value; + if( sInputValue.length === 0 ){ + this.sendQuery(sInputValue); + this.collapseContainer(); + this.expandContainer(); + } + }); + } +}; -- cgit v1.2.3-24-g4f1b