aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/assets/javascript
diff options
context:
space:
mode:
authorCesar G <prototech91@gmail.com>2014-05-06 17:50:22 -0700
committerCesar G <prototech91@gmail.com>2014-05-08 08:35:38 -0700
commit2e025f1655293d3032f04907e5d74a812e1a659a (patch)
treec600a31cbcbd116e076ba67df399cc5c4db45914 /phpBB/assets/javascript
parentd4fc060bcd61228fdf78da4f2d290a7a17546c46 (diff)
downloadforums-2e025f1655293d3032f04907e5d74a812e1a659a.tar
forums-2e025f1655293d3032f04907e5d74a812e1a659a.tar.gz
forums-2e025f1655293d3032f04907e5d74a812e1a659a.tar.bz2
forums-2e025f1655293d3032f04907e5d74a812e1a659a.tar.xz
forums-2e025f1655293d3032f04907e5d74a812e1a659a.zip
[ticket/9388] Add support for making <select> options able to toggle settings.
PHPBB3-9388
Diffstat (limited to 'phpBB/assets/javascript')
-rw-r--r--phpBB/assets/javascript/core.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js
index ae8583ddbf..2502ca6a1c 100644
--- a/phpBB/assets/javascript/core.js
+++ b/phpBB/assets/javascript/core.js
@@ -1476,6 +1476,21 @@ phpbb.toggleDisplay = function(id, action, type) {
}
/**
+* Toggle additional settings based on the selected
+* option of select element.
+*
+* @param jQuery el jQuery select element object.
+* @return undefined
+*/
+phpbb.toggleSelectSettings = function(el) {
+ el.children().each(function() {
+ var option = $(this),
+ setting = $(option.data('toggle-setting'));
+ setting.toggle(option.is(':selected'));
+ });
+};
+
+/**
* Get function from name.
* Based on http://stackoverflow.com/a/359910
*
@@ -1516,6 +1531,16 @@ $(document).ready(function() {
// Update browser history URL to point to specific post in viewtopic.php
// when using view=unread#unread link.
phpbb.history.replaceUrl($('#unread[data-url]').data('url'));
+
+ // Hide settings that are not selected via select element.
+ $('select[data-toggable-settings]').each(function() {
+ var select = $(this);
+
+ select.change(function() {
+ phpbb.toggleSelectSettings(select);
+ });
+ phpbb.toggleSelectSettings(select);
+ });
});
})(jQuery); // Avoid conflicts with other libraries