4,090
edits
No edit summary Tag: Manual revert |
No edit summary |
||
Line 464: | Line 464: | ||
$(this).text('[FILTER]'); | $(this).text('[FILTER]'); | ||
resetButton.css('display', 'inline-block'); // Show the reset button | resetButton.css('display', 'inline-block'); // Show the reset button | ||
// Attach click handler to document | |||
$(document).on('mousedown.hideFilters', function(event) { | |||
var isOutsideFilters = !filtersDiv.is(event.target) && filtersDiv.has(event.target).length === 0; | |||
var isOnToggle = $(event.target).closest('.general-toggle').length > 0; | |||
if (isOutsideFilters && !isOnToggle) { | |||
filtersDiv.removeClass('is-visible').slideUp(100, function() { | |||
$(this).css('display', 'none'); | |||
}); | |||
$('.general-toggle').text('[FILTER]'); | |||
resetButton.css('display', 'none'); // Hide the reset button when filters are not visible | |||
// Remove the document click handler | |||
$(document).off('mousedown.hideFilters'); | |||
} | |||
}); | |||
} else { | } else { | ||
filtersDiv.slideUp(100, function() { | filtersDiv.slideUp(100, function() { | ||
$(this).css('display', 'none'); | $(this).css('display', 'none'); | ||
}); | }); | ||
$(this).text('[FILTER]'); | $(this).text('[FILTER]'); | ||
resetButton.css('display', 'none'); // Hide the reset button when filters are not visible | resetButton.css('display', 'none'); // Hide the reset button when filters are not visible | ||
// Remove the document click handler | |||
$(document).off('mousedown.hideFilters'); | |||
} | } | ||
Line 479: | Line 495: | ||
}); | }); | ||
// Specific Toggle for Filter Sections like TYPE, ENTITY, etc. | // Specific Toggle for Filter Sections like TYPE, ENTITY, etc. | ||
$('.open-filter').click(function(event) { | $('.open-filter').click(function(event) { | ||
Line 627: | Line 642: | ||
}); | }); | ||
// Hide filters when window is scrolled | |||
$(window).on('scroll', function() { | $(window).on('scroll', function() { | ||
var filtersDiv = $('#filters'); | var filtersDiv = $('#filters'); |