Enable/Disable element instead of hiding the whole element
authorJoshua Rüsweg <josh@bastelstu.be>
Tue, 7 Aug 2018 17:47:35 +0000 (19:47 +0200)
committerJoshua Rüsweg <josh@bastelstu.be>
Tue, 7 Aug 2018 17:47:35 +0000 (19:47 +0200)
See #2665

wcfsetup/install/files/acp/templates/trophyAdd.tpl

index 64a9b883bef02c59dc646957f393f60bf658ccd9..bbf79fd30ab172d47cc8cd0b80710c93ee66b9d7 100644 (file)
                        var awardAutomatically = elBySel('input[name=awardAutomatically]').checked;
                        elBySelAll('.conditionSection', null, window[(awardAutomatically ? 'elShow' : 'elHide')]);
                        
+                       var revokeCheckbox = elBySel('#revokeAutomaticallyDL input');
                        if (awardAutomatically) {
-                               elShow(elById('revokeAutomaticallyDL'));
+                               elById('revokeAutomaticallyDL').classList.remove('disabled');
+                               revokeCheckbox.disabled = false;
                        }
                        else {
-                               elHide(elById('revokeAutomaticallyDL'));
+                               elById('revokeAutomaticallyDL').classList.add('disabled');
+                               revokeCheckbox.disabled = true;
+                               revokeCheckbox.checked = false;
                        }
                });
                
                                </dd>
                        </dl>
                        
-                       <dl id="revokeAutomaticallyDL"{if !$awardAutomatically} style="display: none;"{/if}>
+                       <dl id="revokeAutomaticallyDL"{if !$awardAutomatically} class="disabled"{/if}>
                                <dt></dt>
                                <dd>
-                                       <label><input type="checkbox" name="revokeAutomatically" value="1"{if $revokeAutomatically} checked{/if}> {lang}wcf.acp.trophy.revokeAutomatically{/lang}</label>
+                                       <label><input type="checkbox" name="revokeAutomatically" value="1"{if $revokeAutomatically && $awardAutomatically} checked{/if}{if !$awardAutomatically} disabled{/if}> {lang}wcf.acp.trophy.revokeAutomatically{/lang}</label>
                                </dd>
                        </dl>