mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/9388] Add support for making <select> options able to toggle settings.
PHPBB3-9388
This commit is contained in:
parent
d4fc060bcd
commit
2e025f1655
2 changed files with 27 additions and 1 deletions
|
@ -1475,6 +1475,21 @@ phpbb.toggleDisplay = function(id, action, type) {
|
|||
$('#' + id).css('display', ((action === 1) ? type : 'none'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
|
@ -364,8 +364,9 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
|
|||
if ($tpl_type[0] == 'select')
|
||||
{
|
||||
$size = (isset($tpl_type[1])) ? (int) $tpl_type[1] : 1;
|
||||
$data_toggle = (!empty($tpl_type[2])) ? ' data-toggable-settings="true"' : '';
|
||||
|
||||
$tpl = '<select id="' . $key . '" name="' . $name . '"' . (($size > 1) ? ' size="' . $size . '"' : '') . '>' . $return . '</select>';
|
||||
$tpl = '<select id="' . $key . '" name="' . $name . '"' . (($size > 1) ? ' size="' . $size . '"' : '') . $data_toggle . '>' . $return . '</select>';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue