don't depend on the order of events (focus has two variants in jQuery)

This commit is contained in:
Florian Staudacher 2014-02-18 12:48:23 +01:00
parent 69a1718d08
commit b0502ef07e

View file

@ -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;
}
});