From 79abd7cb5c796cb80686b782eaefef5226f31126 Mon Sep 17 00:00:00 2001 From: Waseem Daher Date: Thu, 15 Nov 2012 22:13:52 -0500 Subject: [PATCH] Make searchbox shrinking idempotent. The existing code shortens the searchbox each time it receives focus. Unfortunately, this means that if it receives focus twice in a row, it shrinks twice in a row. (For some reason, the '/' hotkey does this). So, instead, make it idempotent -- if we're already shrunk, don't shrink us again. (imported from commit 8179963bbd00822d15d92609d89f572d2de7800c) --- zephyr/static/js/search.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/zephyr/static/js/search.js b/zephyr/static/js/search.js index 2b556eff21..0510198ac6 100644 --- a/zephyr/static/js/search.js +++ b/zephyr/static/js/search.js @@ -112,14 +112,16 @@ function clear_search_cache() { } exports.focus_search = function () { - // Shrink the searchbox to make room for the buttons. - var search_query = $('#search_query'); - var new_width = search_query.width() - - $('.search_button').outerWidth(true)*3; - search_query.width(new_width); - $("#search_arrows").addClass("input-append"); - $('.search_button').show(); - disable_search_arrows_if(false, ["up", "down"]); + if (!$('.search_button').is(':visible')) { + // Shrink the searchbox to make room for the buttons. + var search_query = $('#search_query'); + var new_width = search_query.width() - + $('.search_button').outerWidth(true)*3; + search_query.width(new_width); + $("#search_arrows").addClass("input-append"); + $('.search_button').show(); + disable_search_arrows_if(false, ["up", "down"]); + } }; exports.initiate_search = function () {