Today I just felt on pieces of JS code like :
Code: Select all
// Hide active dropdowns when click event happens outside
$body.click(function(e) {
var $parents = $(e.target).parents();
if (!$parents.is(phpbb.dropdownVisibleContainers)) {
$(phpbb.dropdownHandles).each(phpbb.toggleDropdown);
}
});
Code: Select all
$('#phpbb').click(function() {
var $this = $(this);
if (!$this.is('.live-search') && !$this.parents().is('.live-search')) {
$('.live-search').hide();
}
});
I really think such a wide scope should be avoided as it could easily mess with other click events set at a lower scope. I did not analyse the whole code yet, but just reading this I think we should start thinking about doing this differently.