Plugin Directory

Changeset 3364054


Ignore:
Timestamp:
09/18/2025 03:00:37 PM (6 months ago)
Author:
ryhowa
Message:

Added tag ver 1.1.2

Location:
faq-accordion-schema/trunk
Files:
3 edited

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) {
     1jQuery(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) {
    341        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    });
    944
    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        }
    2450    });
    2551});
  • faq-accordion-schema/trunk/faq-accordion-schema.php

    r3364015 r3364054  
    77 * Automatically builds the accordion by simply including headings and text withing the shortcode.
    88 * Includes options to enable/disable schema markup, add custom styles, and choose whether to override or respect theme styles.
    9  * Version: 1.1.1
     9 * Version: 1.1.2
    1010 * Author: Ryan Howard
    1111 * Author URI: https://www.ryanhoward.dev
  • faq-accordion-schema/trunk/readme.txt

    r3364015 r3364054  
    55Tested up to: 6.8
    66Requires PHP: 7.2
    7 Stable tag: 1.1.1
     7Stable tag: 1.1.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8282== Changelog ==
    8383
     84= 1.1.2 =
     85* Added js changes
     86
    8487= 1.1.1 =
    8588* 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.