[ticket/6466] Improve behavior of select and properly save role

PHPBB3-6466
This commit is contained in:
Marc Alexander 2015-05-29 16:44:12 +02:00
parent 467c794b97
commit fc00447520
2 changed files with 18 additions and 4 deletions

View file

@ -44,12 +44,13 @@
<div class="dropdown-container dropdown-button-control roles-options" data-alt-text="{LA_ROLE_DESCRIPTION}">
<span title="Roles" class="button icon-button tools-icon dropdown-trigger dropdown-select">{L_NO_ROLE_ASSIGNED}</span>
<div class="dropdown hidden">
<ul class="dropdown-contents" id="role{p_mask.S_ROW_COUNT}{p_mask.f_mask.S_ROW_COUNT}">
<ul class="dropdown-contents" id="role{p_mask.S_ROW_COUNT}{p_mask.f_mask.S_ROW_COUNT}" >
{% for role in loops.role_options %}
<li data-id="{{ role.ID }}" data-target-id="advanced{p_mask.S_ROW_COUNT}{p_mask.f_mask.S_ROW_COUNT}" data-title="{{ role.TITLE }}">{{ role.ROLE_NAME }}</li>
<li data-id="{{ role.ID }}" data-target-id="advanced{p_mask.S_ROW_COUNT}{p_mask.f_mask.S_ROW_COUNT}" data-title="{{ role.TITLE }}"{% if role.SELECTED == true %} data-selected="{{ role.SELECTED }}"{% endif %}>{{ role.ROLE_NAME }}</li>
{% endfor %}
</ul>
</div>
<input type="hidden" name="role[{p_mask.f_mask.UG_ID}][{p_mask.f_mask.FORUM_ID}]" />
</div>
</dd>
<!-- ELSE -->

View file

@ -198,7 +198,16 @@ $(function() {
// Prepare highlighting of select options and settings update
$options.each(function () {
$(this).on('mouseover', function (e) {
var $this = $(this);
var $roles_options = $this.closest('.roles-options');
// Correctly show selected option
if (typeof $this.attr('data-selected') !== 'undefined') {
$this.closest('.roles-options').children('span').text($this.text());
$('')
}
$this.on('mouseover', function (e) {
var $this = $(this);
$options.removeClass('roles-highlight');
$this.addClass('roles-highlight');
@ -210,7 +219,11 @@ $(function() {
init_colours($this.attr('data-target-id').replace('advanced', ''));
// Set selected setting
$this.closest('.roles-options').children('span').text($this.text());
$roles_options.children('span').text($this.text());
$roles_options.children('input[type=hidden]').val($this.attr('data-id'));
// Trigger hiding of selection options
$('body').trigger('click');
});
});
});