From: Coleman Watts Date: Wed, 29 Jan 2014 21:25:43 +0000 (-0800) Subject: CRM-10760 - Autocomplte - Remove unused function with the same name X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b89e44bdc0ca2ee25f00a2357c837bb445f58f65;p=civicrm-core.git CRM-10760 - Autocomplte - Remove unused function with the same name --- diff --git a/js/rest.js b/js/rest.js index 6a35914161..4f4e1e7147 100644 --- a/js/rest.js +++ b/js/rest.js @@ -172,78 +172,4 @@ var CRM = CRM || {}; return CRM.api.call(this, entity, action, params, options); }; - /** - * FIXME: This function is not documented, is not used anywhere in the codebase, and doesn't - * clearly differentiate field elements which store the "contact id" versus the "contact label". - * My guess is that it's designed more for "quick-search" and less for "CRUD forms". - * - * @param params - * @param options - * @return {*} - */ - $.fn.crmAutocomplete = function (params, options) { - if (typeof params == 'undefined') params = {}; - if (typeof options == 'undefined') options = {}; - params = $().extend({ - rowCount:35, - json:1, - entity:'Contact', - action:'getquick', - sequential:1 - }, params); - - options = $().extend({}, { - field :'name', - skip : ['id','contact_id','contact_type','contact_is_deleted',"email_id",'address_id', 'country_id'], - result: function(data){ - return false; - }, - formatItem: function(data,i,max,value,term){ - var tmp = []; - for (attr in data) { - if ($.inArray (attr, options.skip) == -1 && data[attr]) { - tmp.push(data[attr]); - } - } - return tmp.join(' :: '); - }, - parse: function (data){ - var acd = new Array(); - for(cid in data.values){ - delete data.values[cid]["data"];// to be removed once quicksearch doesn't return data - acd.push({ data:data.values[cid], value:data.values[cid].sort_name, result:data.values[cid].sort_name }); - } - return acd; - }, - delay:100, - width:250, - minChars:1 - }, options - ); - var contactUrl = CRM.url('civicrm/ajax/rest', params); - - return this.each(function() { - var selector = this; - if (typeof $.fn.autocomplete != 'function') - $.fn.autocomplete = cj.fn.autocomplete;//to work around the fubar cj - var extraP = {}; - extraP [options.field] = function () {return $(selector).val();}; - $(this).autocomplete( contactUrl, { - extraParams:extraP, - formatItem: function(data,i,max,value,term){ - return options.formatItem(data,i,max,value,term); - }, - parse: function(data){ return options.parse(data);}, - width: options.width, - delay:options.delay, - max:25, - dataType:'json', - minChars:options.minChars, - selectFirst: true - }).result(function(event, data, formatted) { - options.result(data); - }); - }); - } - })(jQuery, CRM);