-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathotfm-spoiler-min.js
1 lines (1 loc) · 1.81 KB
/
otfm-spoiler-min.js
1
jQuery(document).ready(function($){$('.otfm-sp__title').click(function(){$(this).parent().toggleClass('js-otfm-sp__opened js-otfm-sp__closed');if($(this).parent().hasClass('js-otfm-sp__opened')){$(this).parent().attr('aria-expanded','true')}else{$(this).parent().attr('aria-expanded','false')}});$('.otfm-sp__wrapper:not([role="button"])').each(function(){$(this).attr('role','button')});$('.otfm-sp__wrapper:not([tabindex="0"])').each(function(){$(this).attr('tabindex','0')});$('.otfm-sp__wrapper:not([aria-expanded="false"])').each(function(){$(this).attr('aria-expanded','false')});var c='<div class="otfm-sp__content" style="height:0;opacity:0;visibility:hidden;"></div>';$('.wp-block-otfm-box-spoiler-start').each(function(){$(this).removeClass('js-otfm-sp-box__closed').addClass('js-otfm-sp__closed');var a=$(this).nextUntil('.wp-block-otfm-box-spoiler-end');if(a.next().hasClass('wp-block-otfm-box-spoiler-end')&&!a.next().hasClass('wp-block-otfm-box-spoiler-start')){$(a).detach().appendTo(this).wrapAll(c)}else{$(this).addClass('js-otfm-sp__no_closed_tag').next().detach().appendTo(this).wrapAll(c)}});$('#ogs_cr_st').remove();$('.otfm-sp__wrapper').keydown(function(a){var b=a.which;switch(b){case 38:$(this).removeClass('js-otfm-sp__opened').addClass('js-otfm-sp__closed').attr('aria-expanded','false');a.preventDefault();break;case 40:$(this).removeClass('js-otfm-sp__closed').addClass('js-otfm-sp__opened').attr('aria-expanded','true');a.preventDefault();break;case 13:case 32:$(this).toggleClass('js-otfm-sp__opened js-otfm-sp__closed');if($(this).hasClass('js-otfm-sp__opened')){$(this).attr('aria-expanded','true')}else{$(this).attr('aria-expanded','false')}a.preventDefault();break;case 35:$('.otfm-sp__wrapper').last().focus();a.preventDefault();break;case 36:$('.otfm-sp__wrapper').first().focus();a.preventDefault();break;default:}})});