<div class="spoilerBox jsSpoilerBox">
<div class="jsOnly spoilerBoxHeader">
- <a class="button small jsSpoilerToggle"{if $buttonLabel} data-has-custom-label="true"{/if}>{if $buttonLabel}{$buttonLabel}{else}{lang}wcf.bbcode.spoiler.show{/lang}{/if}</a>
+ <a href="#" id="spoiler-button-{@$spoilerID}" role="button" aria-expanded="false" aria-controls="spoiler-content-{@$spoilerID}" class="button small jsSpoilerToggle"{if $buttonLabel} data-has-custom-label="true"{/if}>{if $buttonLabel}{$buttonLabel}{else}{lang}wcf.bbcode.spoiler.show{/lang}{/if}</a>
</div>
- <div class="spoilerBoxContent" style="display: none">
+ <div class="spoilerBoxContent" style="display: none" id="spoiler-content-{@$spoilerID}" aria-hidden="true" aria-labelledby="spoiler-button-{@$spoilerID}">
<!-- META_CODE_INNER_CONTENT -->
</div>
event.preventDefault();
toggleButton.classList.toggle('active');
- window[(toggleButton.classList.contains('active') ? 'elShow' : 'elHide')](container);
+ var isActive = toggleButton.classList.contains('active');
+ window[(isActive ? 'elShow' : 'elHide')](container);
+ elAttr(toggleButton, 'aria-expanded', isActive);
+ elAttr(container, 'aria-hidden', !isActive);
if (!elDataBool(toggleButton, 'has-custom-label')) {
toggleButton.textContent = (toggleButton.classList.contains('active')) ? '{lang}wcf.bbcode.spoiler.hide{/lang}' : '{lang}wcf.bbcode.spoiler.show{/lang}';
*/
public function replaceTag(array $data) {
WCF::getTPL()->assign([
- 'buttonLabel' => $data['label']
+ 'buttonLabel' => $data['label'],
+ 'spoilerID' => substr(StringUtil::getRandomID(), 0, 8)
]);
return WCF::getTPL()->fetch((HtmlBBCodeParser::getInstance()->getIsGoogleAmp() ? 'spoilerAmpMetaCode' : 'spoilerMetaCode'));
}