From 7a27debb110fd3ac98372ae26459da58bfc5ee75 Mon Sep 17 00:00:00 2001 From: Chris Hallberg <crhallberg@gmail.com> Date: Mon, 7 Dec 2015 10:21:55 -0500 Subject: [PATCH] Autocomplete updates, including PR533. --- themes/bootstrap3/js/autocomplete.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/themes/bootstrap3/js/autocomplete.js b/themes/bootstrap3/js/autocomplete.js index 996e0217cdb..5fd98e262be 100644 --- a/themes/bootstrap3/js/autocomplete.js +++ b/themes/bootstrap3/js/autocomplete.js @@ -1,5 +1,5 @@ /** - * vufind.typeahead.js 0.6 + * vufind.typeahead.js 0.8 * ~ @crhallberg */ (function ( $ ) { @@ -18,9 +18,7 @@ function populate(value, input, eventType) { input.val(value); hide(); - if (typeof options.onselection !== 'undefined') { - options.onselection(value, input, eventType); - } + input.trigger('autocomplete:select', {value: value, eventType: eventType}); } function createList(data, input) { @@ -58,7 +56,7 @@ } $.fn.autocomplete.element.html(shell); $.fn.autocomplete.element.find('.item').mousedown(function() { - populate($(this).attr('data-value'), input, {mouse: true}) + populate($(this).attr('data-value'), input, {mouse: true}); }); align(input, $.fn.autocomplete.element); } @@ -99,10 +97,10 @@ var offset = input[0].getBoundingClientRect(); element.css({ position: 'absolute', - top: offset.top + offset.height, + top: offset.top + offset.height + document.body.scrollTop, left: offset.left, - maxWidth: offset.width * 2, minWidth: offset.width, + maxWidth: input.closest('form').width(), zIndex: 50 }); } @@ -111,9 +109,12 @@ if (typeof element === 'undefined') { element = $('<div/>') .addClass('autocomplete-results hidden') - .text('<i class="item loading">'+options.loadingString+'</i>'); + .html('<i class="item loading">'+options.loadingString+'</i>'); align(input, element); $('body').append(element); + $(window).resize(function() { + align(input, element); + }); } input.data('selected', -1); -- GitLab