mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 08:25:46 +01:00
Reduce DOM queries for Search elements
This commit is contained in:
@@ -413,21 +413,25 @@ var socket,
|
|||||||
|
|
||||||
|
|
||||||
app.updateHeader = function(err, data) {
|
app.updateHeader = function(err, data) {
|
||||||
$('#search-button').off().on('click', function(e) {
|
var searchButton = $("#search-button"),
|
||||||
|
searchFields = $("#search-fields"),
|
||||||
|
searchInput = $('#search-fields input');
|
||||||
|
|
||||||
|
function dismissSearch(){
|
||||||
|
searchFields.hide();
|
||||||
|
searchButton.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
searchButton.off().on('click', function(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
$('#search-fields').removeClass('hide').show();
|
|
||||||
|
searchFields.removeClass('hide').show();
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
$('#search-fields input').focus();
|
|
||||||
|
|
||||||
$('#search-form').on('submit', function() {
|
searchInput.focus();
|
||||||
$('#search-fields').hide();
|
|
||||||
$('#search-button').show();
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#search-fields input').on('blur', function() {
|
$('#search-form').on('submit', dismissSearch);
|
||||||
$('#search-fields').hide();
|
searchInput.on('blur', dismissSearch);
|
||||||
$('#search-button').show();
|
|
||||||
});
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -442,7 +446,7 @@ var socket,
|
|||||||
$('#logged-out-menu').addClass('hide');
|
$('#logged-out-menu').addClass('hide');
|
||||||
$('#logged-in-menu').removeClass('hide');
|
$('#logged-in-menu').removeClass('hide');
|
||||||
|
|
||||||
$('#search-button').removeClass("hide").show();
|
searchButton.removeClass("hide").show();
|
||||||
|
|
||||||
var userLabel = loggedInMenu.find('#user_label');
|
var userLabel = loggedInMenu.find('#user_label');
|
||||||
|
|
||||||
@@ -462,10 +466,10 @@ var socket,
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (allowGuestSearching) {
|
if (allowGuestSearching) {
|
||||||
$('#search-button').removeClass("hide").show();
|
searchButton.removeClass("hide").show();
|
||||||
$('#mobile-search-button').removeClass("hide").show();
|
$('#mobile-search-button').removeClass("hide").show();
|
||||||
} else {
|
} else {
|
||||||
$('#search-button').addClass("hide").hide();
|
searchButton.addClass("hide").hide();
|
||||||
$('#mobile-search-button').addClass("hide").hide();
|
$('#mobile-search-button').addClass("hide").hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user