Changeset 3364054
- Timestamp:
- 09/18/2025 03:00:37 PM (6 months ago)
- Location:
- faq-accordion-schema/trunk
- Files:
-
- 3 edited
-
assets/js/accordion.js (modified) (1 diff)
-
faq-accordion-schema.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
faq-accordion-schema/trunk/assets/js/accordion.js
r3362323 r3364054 1 jQuery(document).ready(function($) { 2 $('.faq-accordion .accordion-header').on('click', function(e) { 1 jQuery(function ($) { 2 function toggleItem($header) { 3 const $acc = $header.closest('.faq-accordion'); 4 const $content = $header.next('.accordion-content'); 5 const $icon = $header.find('.accordion-icon'); 6 const isExpanded = $header.attr('aria-expanded') === 'true'; 7 8 const $allHeaders = $acc.find('.accordion-header'); 9 const $allContents = $acc.find('.accordion-content'); 10 11 $allHeaders.not($header) 12 .attr('aria-expanded', 'false') 13 .removeClass('active') 14 .find('.accordion-icon').removeClass('rotated'); 15 16 $allContents.not($content) 17 .stop(true, true) 18 .slideUp(300, function () { 19 $(this).css('display', 'none').attr('aria-hidden', 'true').removeClass('is-open'); 20 }); 21 22 if (isExpanded) { 23 $header.attr('aria-expanded', 'false').removeClass('active'); 24 $icon.removeClass('rotated'); 25 $content.stop(true, true).slideUp(300, function () { 26 $(this).css('display', 'none').attr('aria-hidden', 'true').removeClass('is-open'); 27 }); 28 } else { 29 $header.attr('aria-expanded', 'true').addClass('active'); 30 $icon.addClass('rotated'); 31 $content 32 .attr('aria-hidden', 'false') 33 .stop(true, true) 34 .slideDown(300, function () { 35 $(this).css('display', 'flex').addClass('is-open'); 36 }); 37 } 38 } 39 40 $(document).on('click', '.faq-accordion .accordion-header', function (e) { 3 41 e.preventDefault(); 4 const $header = $(this); 5 const $content = $header.next('.accordion-content'); 6 const $icon = $header.find('.accordion-icon'); 7 const $allContents = $header.closest('.faq-accordion').find('.accordion-content'); 8 const $allHeaders = $header.closest('.faq-accordion').find('.accordion-header'); 42 toggleItem($(this)); 43 }); 9 44 10 const isExpanded = $header.attr('aria-expanded') === 'true'; 11 $header.attr('aria-expanded', !isExpanded); 12 $content.attr('aria-hidden', isExpanded); 13 14 $allContents.not($content).slideUp(300); 15 $allHeaders.not($header).attr('aria-expanded', 'false'); 16 $allContents.not($content).attr('aria-hidden', 'true'); 17 $allHeaders.not($header).removeClass('active'); 18 19 $content.slideToggle(300); 20 $header.toggleClass('active'); 21 22 $allHeaders.not($header).find('.accordion-icon').removeClass('rotated'); 23 $icon.toggleClass('rotated'); 45 $(document).on('keydown', '.faq-accordion .accordion-header', function (e) { 46 if (e.key === 'Enter' || e.key === ' ') { 47 e.preventDefault(); 48 toggleItem($(this)); 49 } 24 50 }); 25 51 }); -
faq-accordion-schema/trunk/faq-accordion-schema.php
r3364015 r3364054 7 7 * Automatically builds the accordion by simply including headings and text withing the shortcode. 8 8 * Includes options to enable/disable schema markup, add custom styles, and choose whether to override or respect theme styles. 9 * Version: 1.1. 19 * Version: 1.1.2 10 10 * Author: Ryan Howard 11 11 * Author URI: https://www.ryanhoward.dev -
faq-accordion-schema/trunk/readme.txt
r3364015 r3364054 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.2 7 Stable tag: 1.1. 17 Stable tag: 1.1.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 82 82 == Changelog == 83 83 84 = 1.1.2 = 85 * Added js changes 86 84 87 = 1.1.1 = 85 88 * Improved accordion behavior: now opens with `display:flex` instead of `block` for better layout handling.
Note: See TracChangeset
for help on using the changeset viewer.