From 4648b6afca94c07ebb617191f1197831d37e4601 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Wed, 27 Nov 2013 17:44:52 +0100 Subject: [PATCH] Tag autocomplete aligned to right only in top nav --- public_html/media/js/core.js | 37 +++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/public_html/media/js/core.js b/public_html/media/js/core.js index 1dc61c19..eb760fcf 100644 --- a/public_html/media/js/core.js +++ b/public_html/media/js/core.js @@ -208,22 +208,9 @@ $(function() { $('.autocomplete').each(function() { - var searchInput = $(this); - searchInput - // don't navigate away from the field on tab when selecting an item - .bind('keydown', function(event) + var options = { - if (event.keyCode === $.ui.keyCode.TAB && $(this).data('autocomplete').menu.active) - { - event.preventDefault(); - } - }).autocomplete({ minLength: 1, - position: - { - my: 'right top', - at: 'right bottom' - }, source: function(request, response) { var term = extractLast(request.term); @@ -247,7 +234,27 @@ $(function() this.value = terms.join(' '); return false; } - }); + }; + + if ($(this).parents('#top-nav').length != 0) + { + options['position'] = + { + my: 'right top', + at: 'right bottom' + }; + } + + var searchInput = $(this); + searchInput + // don't navigate away from the field on tab when selecting an item + .bind('keydown', function(event) + { + if (event.keyCode === $.ui.keyCode.TAB && $(this).data('autocomplete').menu.active) + { + event.preventDefault(); + } + }).autocomplete(options); }); });