From c521380273be66ed99e2f16ba914a033a6bf3250 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 26 Oct 2013 16:35:59 +0300 Subject: [PATCH] [ticket/11956] Move code that hides dropdowns to assets PHPBB3-11956 --- phpBB/assets/javascript/core.js | 20 +++++++++++++++++++- phpBB/styles/prosilver/template/forum_fn.js | 9 --------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index e19729c4ab..efb945a117 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -829,6 +829,16 @@ phpbb.applyCodeEditor = function(textarea) { }); }; +/** +* List of classes that toggle dropdown menu, +* list of classes that contain visible dropdown menu +* +* Add your own classes to strings with comma (probably you +* will never need to do that) +*/ +phpbb.dropdownHandles = '.dropdown-container.dropdown-visible .dropdown-toggle'; +phpbb.dropdownVisibleContainers = '.dropdown-container.dropdown-visible'; + /** * Dropdown toggle event handler * This handler is used by phpBB.registerDropdown() and other functions @@ -841,7 +851,7 @@ phpbb.toggleDropdown = function() { if (!visible) { // Hide other dropdown menus - $('.dropdown-container.dropdown-visible .dropdown-toggle').each(phpbb.toggleDropdown); + $(phpbb.dropdownHandles).each(phpbb.toggleDropdown); // Figure out direction of dropdown var direction = options.direction, @@ -952,6 +962,14 @@ $(document).ready(function() { $('textarea[data-bbcode]').each(function() { phpbb.applyCodeEditor(this); }); + + // 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); + } + }); }); })(jQuery); // Avoid conflicts with other libraries diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index c6301bad15..a01e7fd405 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -939,15 +939,6 @@ function parse_document(container) $('#' + this.getAttribute('data-focus')).focus(); }); - // Hide active dropdowns when click event happens outside - $('#phpbb').click(function(e) { - - var parents = $(e.target).parents(); - if (!parents.is('.dropdown-container.dropdown-visible')) { - $('.dropdown-container.dropdown-visible .dropdown-toggle').each(phpbb.toggleDropdown); - } - }); - parse_document($('body')); }); })(jQuery);