From: Florent Bruneau Date: Sun, 27 Feb 2011 13:10:09 +0000 (+0100) Subject: Allow quicksearch to be called on 0 or several inputs at once. X-Git-Tag: xorg/1.1.0~127 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=8ca09823b6ac6f87185938dd971a8ce86d8694df;hp=c8985ea9386282128d20e0fe8424bee2727da5b7;p=platal.git Allow quicksearch to be called on 0 or several inputs at once. Signed-off-by: Florent Bruneau --- 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));