Don't query the DOM unnecessarily.

This commit is contained in:
William Boman 2014-10-25 03:38:27 +02:00
parent fdf1c40824
commit 3d10e2dcb5

View File

@ -4,8 +4,10 @@ $(function() {
interval: 5000 interval: 5000
}); });
var $filter_by = $('#filter-by');
// Filter icons // Filter icons
if($('#filter-by').length) { if($filter_by.length) {
var $filter_val = $('#filter-val'); var $filter_val = $('#filter-val');
var $filter = $('#filter'); var $filter = $('#filter');
var $other = $('#new, #web-application, #form-control, #medical, #currency, #text-editor, #directional, #video-player, #brand, #file-type, #spinner, #payment, #chart'); var $other = $('#new, #web-application, #form-control, #medical, #currency, #text-editor, #directional, #video-player, #brand, #file-type, #spinner, #payment, #chart');
@ -16,11 +18,11 @@ $(function() {
$clear.click(function(e) { $clear.click(function(e) {
e.preventDefault(); e.preventDefault();
$('#filter-by').val('').trigger('keyup').focus(); $filter_by.val('').trigger('keyup').focus();
}); });
$('#filter-by').keyup(function() { $filter_by.keyup(function() {
var $this = $(this); var $this = $(this);
var val = $this.val(); var val = $this.val();
$filter.toggle(!!val); $filter.toggle(!!val);