From: Matthias Schmidt Date: Fri, 26 Aug 2016 07:51:37 +0000 (+0200) Subject: Add proper enableOptions support for select option type X-Git-Tag: 3.0.0_Beta_1~495 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=dc3ab016f2887491c563afbde14b242e5f6c9baf;p=GitHub%2FWoltLab%2FWCF.git Add proper enableOptions support for select option type --- diff --git a/com.woltlab.wcf/templates/booleanOptionType.tpl b/com.woltlab.wcf/templates/booleanOptionType.tpl index 92fd14be1e..4729f86a47 100644 --- a/com.woltlab.wcf/templates/booleanOptionType.tpl +++ b/com.woltlab.wcf/templates/booleanOptionType.tpl @@ -1,4 +1,4 @@ -
    +
    1. diff --git a/com.woltlab.wcf/templates/selectOptionType.tpl b/com.woltlab.wcf/templates/selectOptionType.tpl index ddfb5f9b3c..9d325fa1b1 100644 --- a/com.woltlab.wcf/templates/selectOptionType.tpl +++ b/com.woltlab.wcf/templates/selectOptionType.tpl @@ -1,4 +1,4 @@ -required} required{/if}{if $disableOptions || $enableOptions} class="jsEnablesOptions" data-is-boolean="true" data-disable-options="[ {@$disableOptions}]" data-enable-options="[ {@$enableOptions}]"{/if}> {if !$allowEmptyValue|empty}{/if} {foreach from=$selectOptions key=key item=selectOption} diff --git a/wcfsetup/install/files/acp/templates/booleanOptionType.tpl b/wcfsetup/install/files/acp/templates/booleanOptionType.tpl index 92fd14be1e..4729f86a47 100644 --- a/wcfsetup/install/files/acp/templates/booleanOptionType.tpl +++ b/wcfsetup/install/files/acp/templates/booleanOptionType.tpl @@ -1,4 +1,4 @@ -
        +
        1. diff --git a/wcfsetup/install/files/acp/templates/selectOptionType.tpl b/wcfsetup/install/files/acp/templates/selectOptionType.tpl index d05e0ffd09..9343d83c47 100644 --- a/wcfsetup/install/files/acp/templates/selectOptionType.tpl +++ b/wcfsetup/install/files/acp/templates/selectOptionType.tpl @@ -1,4 +1,4 @@ - {if !$allowEmptyValue|empty}{/if} {foreach from=$selectOptions key=key item=selectOption} diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 6d83b88fd2..d0ec456fc5 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -3819,15 +3819,15 @@ WCF.Option.Handler = Class.extend({ _change: function(option) { option = $(option); - var $disableOptions = eval(option.data('disableOptions')); - var $enableOptions = eval(option.data('enableOptions')); + var disableOptions = eval(option.data('disableOptions')); + var enableOptions = eval(option.data('enableOptions')); // determine action by type switch(option.getTagName()) { case 'input': switch(option.attr('type')) { case 'checkbox': - this._execute(option.prop('checked'), $disableOptions, $enableOptions); + this._execute(option.prop('checked'), disableOptions, enableOptions); break; case 'radio': @@ -3837,7 +3837,7 @@ WCF.Option.Handler = Class.extend({ isActive = false; } - this._execute(isActive, $disableOptions, $enableOptions); + this._execute(isActive, disableOptions, enableOptions); } break; } @@ -3845,29 +3845,36 @@ WCF.Option.Handler = Class.extend({ case 'select': var $value = option.val(); - var $disableOptions = $enableOptions = []; + var relevantDisableOptions = []; + var relevantEnableOptions = []; - if (option.data('disableOptions').length > 0) { - for (var $index in option.data('disableOptions')) { - var $item = option.data('disableOptions')[$index]; + if (disableOptions.length > 0) { + for (var $index in disableOptions) { + var $item = disableOptions[$index]; if ($item.value == $value) { - $disableOptions.push($item.option); + relevantDisableOptions.push($item.option); + } + else { + relevantEnableOptions.push($item.option); } } } - if (option.data('enableOptions').length > 0) { - for (var $index in option.data('enableOptions')) { - var $item = option.data('enableOptions')[$index]; + if (enableOptions.length > 0) { + for (var $index in enableOptions) { + var $item = enableOptions[$index]; if ($item.value == $value) { - $enableOptions.push($item.option); + relevantEnableOptions.push($item.option); + } + else { + relevantDisableOptions.push($item.option); } } } - this._execute(true, $disableOptions, $enableOptions); + this._execute(true, relevantDisableOptions, relevantEnableOptions); break; } }, @@ -3934,6 +3941,12 @@ WCF.Option.Handler = Class.extend({ if ($tagName == 'select' || ($tagName == 'input' && (element.attr('type') == 'checkbox' || element.attr('type') == 'file' || element.attr('type') == 'radio'))) { if (enable) element.enable(); else element.disable(); + + if (element.parents('.optionTypeBoolean:eq(0)')) { + var noElement = $('#' + element.wcfIdentify() + '_no'); + if (enable) noElement.enable(); + else noElement.disable(); + } } else { if (enable) element.removeAttr('readonly');