diff options
author | Vjacheslav Trushkin <cyberalien@gmail.com> | 2013-10-26 16:35:59 +0300 |
---|---|---|
committer | Vjacheslav Trushkin <cyberalien@gmail.com> | 2013-10-26 16:35:59 +0300 |
commit | c521380273be66ed99e2f16ba914a033a6bf3250 (patch) | |
tree | 255a516475b687618126813015ac4a86c07b3ff7 /phpBB/assets/javascript | |
parent | 368b3f0d9e6af2fe625c2955130399cefb86e41b (diff) | |
download | forums-c521380273be66ed99e2f16ba914a033a6bf3250.tar forums-c521380273be66ed99e2f16ba914a033a6bf3250.tar.gz forums-c521380273be66ed99e2f16ba914a033a6bf3250.tar.bz2 forums-c521380273be66ed99e2f16ba914a033a6bf3250.tar.xz forums-c521380273be66ed99e2f16ba914a033a6bf3250.zip |
[ticket/11956] Move code that hides dropdowns to assets
PHPBB3-11956
Diffstat (limited to 'phpBB/assets/javascript')
-rw-r--r-- | phpBB/assets/javascript/core.js | 20 |
1 files changed, 19 insertions, 1 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 @@ -830,6 +830,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 |