From 8ca09823b6ac6f87185938dd971a8ce86d8694df Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sun, 27 Feb 2011 14:10:09 +0100 Subject: [PATCH 1/1] Allow quicksearch to be called on 0 or several inputs at once. Signed-off-by: Florent Bruneau --- htdocs/javascript/xorg.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/htdocs/javascript/xorg.js b/htdocs/javascript/xorg.js index 7cd95ae..e808504 100644 --- a/htdocs/javascript/xorg.js +++ b/htdocs/javascript/xorg.js @@ -911,8 +911,13 @@ function sendTestEmail(token, hruid) updateSelection(); } }).mouseup(function() { - if (!($(this).find('a').is(':hover'))) { - $(this).find('a').click(); + var sel = $(this).find('a'); + try { + if (!sel.is(':hover')) { + sel.click(); + } + } catch (e) { + sel.click(); } }); return data; @@ -1012,14 +1017,14 @@ function sendTestEmail(token, hruid) $.fn.extend({ quickSearch: function(options) { - var $this = this; - var $input = $this.get(0); + return this.each(function() { + var $this = $(this); + var $input = this; var $popup; var previous = null; var pending = false; var disabled = false; var updatePopup; - var loadingClass; options = options || { }; options = $.extend({ @@ -1038,12 +1043,11 @@ function sendTestEmail(token, hruid) $(this).popWin(840, 600); } }, options); - console.log(options); options.loadingClass = $this.css('text-align') === 'right' ? options.loadingClassRight : options.loadingClassLeft; $this.attr('autocomplete', 'off'); - $popup = buildPopup(this, options.destination, function() { + $popup = buildPopup($this, options.destination, function() { options.selectAction.apply(this, arguments); $(this).click(function() { $popup.hide(); @@ -1105,7 +1109,7 @@ function sendTestEmail(token, hruid) updatePopup = doUpdatePopup; - return this.keyup(function(e) { + return $this.keyup(function(e) { if (e.keyCode !== 27 /* escape */ && e.keyCode !== 13 /* enter */ && e.keyCode !== 9 /* tab */ && e.keyCode !== 38 /* up */ && e.keyCode !== 40 /* down */) { @@ -1140,7 +1144,7 @@ function sendTestEmail(token, hruid) .blur(function() { return $popup.hide(true); }) - .focus(updatePopup); + .focus(updatePopup);}); } }); }(jQuery)); -- 2.1.4