From 4343e0c5923e12f58b07fca97200f8904bafba50 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 3 Sep 2019 15:30:02 -0400 Subject: [PATCH] Update autocomplete.js --- view/js/autocomplete.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index 18deaa1d30..bb3577fb9b 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -286,6 +286,31 @@ function string2bb(element) { }; })( jQuery ); +(function( $ ) { + $.fn.name_autocomplete = function(backend_url, typ, autosubmit, onselect) { + if(typeof typ === 'undefined') typ = ''; + if(typeof autosubmit === 'undefined') autosubmit = false; + + // Autocomplete contacts + names = { + match: /(^)([^\n]+)$/, + index: 2, + search: function(term, callback) { contact_search(term, callback, backend_url, typ); }, + replace: trim_replace, + template: contact_format, + }; + + this.attr('autocomplete','off'); + var a = this.textcomplete([names], {className:'acpopup', zIndex:10000}); + + if(autosubmit) + a.on('textComplete:select', function(e,value,strategy) { submit_form(this); }); + + if(typeof onselect !== 'undefined') + a.on('textComplete:select', function(e, value, strategy) { onselect(value); }); + }; +})( jQuery ); + (function( $ ) { $.fn.bbco_autocomplete = function(type) { -- 2.39.5