mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/6466] Support form reset and do not loose role upon resubmit
PHPBB3-6466
This commit is contained in:
@@ -141,15 +141,20 @@ phpbb.positionTooltip = function ($element) {
|
||||
*/
|
||||
phpbb.prepareRolesDropdown = function () {
|
||||
var $options = $('.roles-options li');
|
||||
var $rolesOptions = $options.closest('.roles-options');
|
||||
var $span = $rolesOptions.children('span');
|
||||
|
||||
// Prepare highlighting of select options and settings update
|
||||
$options.each(function () {
|
||||
var $this = $(this);
|
||||
var $rolesOptions = $this.closest('.roles-options');
|
||||
|
||||
// Correctly show selected option
|
||||
if (typeof $this.attr('data-selected') !== 'undefined') {
|
||||
$this.closest('.roles-options').children('span').text($this.text());
|
||||
$rolesOptions.closest('.roles-options')
|
||||
.children('span')
|
||||
.text($this.text())
|
||||
.attr('data-default', $this.text())
|
||||
.attr('data-default-val', $this.attr('data-id'));
|
||||
}
|
||||
|
||||
$this.on('mouseover', function () {
|
||||
@@ -164,13 +169,28 @@ phpbb.prepareRolesDropdown = function () {
|
||||
init_colours($this.attr('data-target-id').replace('advanced', ''));
|
||||
|
||||
// Set selected setting
|
||||
$rolesOptions.children('span').text($this.text());
|
||||
$rolesOptions.children('input[type=hidden]').val($this.attr('data-id'));
|
||||
$rolesOptions.children('span')
|
||||
.text($this.text());
|
||||
$rolesOptions.children('input[type=hidden]')
|
||||
.val($this.attr('data-id'));
|
||||
|
||||
// Trigger hiding of selection options
|
||||
$('body').trigger('click');
|
||||
});
|
||||
});
|
||||
|
||||
// Save default text of drop down if there is no default set yet
|
||||
if (typeof $span.attr('data-default') === 'undefined') {
|
||||
$span.attr('data-default', $span.text());
|
||||
}
|
||||
|
||||
// Prepare resetting drop down on form reset
|
||||
$options.closest('form').on('reset', function () {
|
||||
$span.text($span.attr('data-default'));
|
||||
$rolesOptions.children('input[type=hidden]')
|
||||
.val($span.attr('data-id'));
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Run onload functions for RolesDropdown and tooltips
|
||||
|
Reference in New Issue
Block a user