From ebba42c53cdeb2c62d331656356f3d6483fb3e53 Mon Sep 17 00:00:00 2001 From: Chris Hallberg <crhallberg@gmail.com> Date: Wed, 2 Dec 2015 12:26:31 -0500 Subject: [PATCH] autocomplete v0.6 --- themes/bootstrap3/js/autocomplete.js | 41 ++++++++++++++-------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/themes/bootstrap3/js/autocomplete.js b/themes/bootstrap3/js/autocomplete.js index a8aab37ea25..61c61346103 100644 --- a/themes/bootstrap3/js/autocomplete.js +++ b/themes/bootstrap3/js/autocomplete.js @@ -1,5 +1,5 @@ /** - * vufind.typeahead.js 0.5 + * vufind.typeahead.js 0.6 * ~ @crhallberg */ (function ( $ ) { @@ -63,7 +63,6 @@ align(input, $.fn.autocomplete.element); } - $.fn.autocomplete.cache = {}; function search(input, element) { if (xhr) xhr.abort(); if (input.val().length >= options.minLength) { @@ -268,26 +267,28 @@ }); }; - $.fn.autocomplete.element = false; - $.fn.autocomplete.options = { - ajaxDelay: 200, - cache: true, - hidingClass: 'hidden', - highlight: true, - loadingString: 'Loading...', - maxResults: 20, - minLength: 3 - }; - var xhr = false; var timer = false; - $.fn.autocomplete.ajax = function(ops) { - if (timer) clearTimeout(timer); - if (xhr) xhr.abort(); - timer = setTimeout( - function() { xhr = $.ajax(ops); }, - $.fn.autocomplete.options.ajaxDelay - ); + if (typeof $.fn.autocomplete.cache === 'undefined') { + $.fn.autocomplete.cache = {}; + $.fn.autocomplete.element = false; + $.fn.autocomplete.options = { + ajaxDelay: 200, + cache: true, + hidingClass: 'hidden', + highlight: true, + loadingString: 'Loading...', + maxResults: 20, + minLength: 3 + }; + $.fn.autocomplete.ajax = function(ops) { + if (timer) clearTimeout(timer); + if (xhr) xhr.abort(); + timer = setTimeout( + function() { xhr = $.ajax(ops); }, + $.fn.autocomplete.options.ajaxDelay + ); + } } }( jQuery )); -- GitLab