mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 04:23:46 +00:00
search: Remove redundant re-declaration of variables for search box.
This is just a minor refactor.
This commit is contained in:
@@ -42,6 +42,8 @@ exports.update_button_visibility = function () {
|
||||
};
|
||||
|
||||
exports.initialize = function () {
|
||||
var search_query_box = $('#search_query');
|
||||
var searchbox_form = $('#searchbox_form');
|
||||
|
||||
// Data storage for the typeahead.
|
||||
// This maps a search string to an object with a "description" field.
|
||||
@@ -50,7 +52,7 @@ exports.initialize = function () {
|
||||
// just represents the key of the hash, so it's redundant.)
|
||||
var search_object = {};
|
||||
|
||||
$("#search_query").typeahead({
|
||||
search_query_box.typeahead({
|
||||
source: function (query) {
|
||||
var suggestions = search_suggestion.get_suggestions(query);
|
||||
// Update our global search_object hash
|
||||
@@ -74,7 +76,7 @@ exports.initialize = function () {
|
||||
},
|
||||
});
|
||||
|
||||
$('#searchbox_form').on('compositionend', function () {
|
||||
searchbox_form.on('compositionend', function () {
|
||||
// Set `is_using_input_method` to true if enter is pressed to exit
|
||||
// the input tool popover and get the text in the search bar. Then
|
||||
// we suppress searching triggered by this enter key by checking
|
||||
@@ -83,10 +85,9 @@ exports.initialize = function () {
|
||||
is_using_input_method = true;
|
||||
});
|
||||
|
||||
$("#searchbox_form").keydown(function (e) {
|
||||
searchbox_form.keydown(function (e) {
|
||||
exports.update_button_visibility();
|
||||
var code = e.which;
|
||||
var search_query_box = $("#search_query");
|
||||
if (code === 13 && search_query_box.is(":focus")) {
|
||||
// Don't submit the form so that the typeahead can instead
|
||||
// handle our Enter keypress. Any searching that needs
|
||||
@@ -100,7 +101,6 @@ exports.initialize = function () {
|
||||
return;
|
||||
}
|
||||
var code = e.which;
|
||||
var search_query_box = $("#search_query");
|
||||
if (code === 13 && search_query_box.is(":focus")) {
|
||||
// We just pressed enter and the box had focus, which
|
||||
// means we didn't use the typeahead at all. In that
|
||||
@@ -119,9 +119,8 @@ exports.initialize = function () {
|
||||
// more work to re-order everything and make them private.
|
||||
$('#search_exit').on('click', exports.clear_search);
|
||||
|
||||
var query = $('#search_query');
|
||||
query.on('focus', exports.focus_search);
|
||||
query.on('blur' , function () {
|
||||
search_query_box.on('focus', exports.focus_search);
|
||||
search_query_box.on('blur' , function () {
|
||||
// The search query box is a visual cue as to
|
||||
// whether search or narrowing is active. If
|
||||
// the user blurs the search box, then we should
|
||||
@@ -139,7 +138,7 @@ exports.initialize = function () {
|
||||
|
||||
setTimeout(function () {
|
||||
var search_string = narrow_state.search_string();
|
||||
query.val(search_string);
|
||||
search_query_box.val(search_string);
|
||||
exports.update_button_visibility();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user