From b0502ef07ee11f2be659e75568a5390adc8988e5 Mon Sep 17 00:00:00 2001 From: Florian Staudacher Date: Tue, 18 Feb 2014 12:48:23 +0100 Subject: [PATCH] don't depend on the order of events (focus has two variants in jQuery) --- app/assets/javascripts/app/views/header_view.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/app/views/header_view.js b/app/assets/javascripts/app/views/header_view.js index bb0643e75..821ec468d 100644 --- a/app/assets/javascripts/app/views/header_view.js +++ b/app/assets/javascripts/app/views/header_view.js @@ -36,7 +36,10 @@ app.views.Header = app.views.Base.extend({ }, toggleSearchActive: function(ev) { - $(ev.target).toggleClass('active', ev.type=='focusin'); + // jQuery produces two events for focus/blur (for bubbling) + // don't rely on which event arrives first, by allowing for both variants + var is_active = (_.indexOf(['focus','focusin'], ev.type) != -1); + $(ev.target).toggleClass('active', is_active); return false; } });