Skip to content

Instantly share code, notes, and snippets.

@freddielore
Last active March 23, 2022 16:53
Show Gist options
  • Select an option

  • Save freddielore/02715f126e4953aab3f2e61373f9cd23 to your computer and use it in GitHub Desktop.

Select an option

Save freddielore/02715f126e4953aab3f2e61373f9cd23 to your computer and use it in GitHub Desktop.

Revisions

  1. freddielore revised this gist Dec 12, 2020. 1 changed file with 25 additions and 25 deletions.
    50 changes: 25 additions & 25 deletions yoast-faq.js
    Original file line number Diff line number Diff line change
    @@ -1,34 +1,34 @@
    (function($){

    var yoast = {
    accordion: function(){
    $('.wp-block-yoast-faq-block').find('.schema-faq-question').click(function(){
    //Expand or collapse this panel
    $(this).nextAll('.schema-faq-answer').eq(0).slideToggle('fast', function(){

    jQuery(document).ready(function($){
    var yoast = {
    accordion: function(){
    $('.wp-block-yoast-faq-block').find('.schema-faq-question').click(function(){
    //Expand or collapse this panel
    $(this).nextAll('.schema-faq-answer').eq(0).slideToggle('fast', function(){
    if( $(this).hasClass('collapse') ){
    $(this).removeClass('collapse');
    }
    else{
    $(this).addClass('collapse');
    }
    });

    //Hide the other panels
    $(".schema-faq-answer").not( $(this).nextAll('.schema-faq-answer').eq(0) ).slideUp('fast');
    });

    $('.wp-block-yoast-faq-block .schema-faq-question').click(function(){
    $('.wp-block-yoast-faq-block .schema-faq-question').not( $(this) ).removeClass('collapse');
    if( $(this).hasClass('collapse') ){
    $(this).removeClass('collapse');
    }
    else{
    $(this).addClass('collapse');
    }
    });

    //Hide the other panels
    $(".schema-faq-answer").not( $(this).nextAll('.schema-faq-answer').eq(0) ).slideUp('fast');
    });

    $('.wp-block-yoast-faq-block .schema-faq-question').click(function(){
    $('.wp-block-yoast-faq-block .schema-faq-question').not( $(this) ).removeClass('collapse');
    if( $(this).hasClass('collapse') ){
    $(this).removeClass('collapse');
    }
    else{
    $(this).addClass('collapse');
    }
    });
    }
    };

    yoast.accordion();
    }
    };

    })(jQuery)
    yoast.accordion();
    });
  2. freddielore revised this gist Dec 18, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion yoast-faq.js
    Original file line number Diff line number Diff line change
    @@ -29,6 +29,6 @@
    }
    };

    // yoast.accordion();
    yoast.accordion();

    })(jQuery)
  3. freddielore revised this gist Dec 18, 2019. 1 changed file with 30 additions and 0 deletions.
    30 changes: 30 additions & 0 deletions yoast-faq.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    /* Accordion
    ------------------------------------------------------------ */
    .schema-faq-question{
    cursor: pointer;
    }

    .schema-faq-question:before{
    width: 16px;
    height: 20px;
    display: inline-block;
    content: "+";
    margin-right: 5px;
    vertical-align: top;
    }

    .schema-faq-question.collapse:before{
    content: "-";
    }

    .schema-faq-question:hover{
    opacity: 0.8;
    }

    .schema-faq-answer{
    display: none;
    padding-left: 1em;
    }
    .schema-faq-answer.default{
    display: block;
    }
  4. freddielore created this gist Dec 18, 2019.
    34 changes: 34 additions & 0 deletions yoast-faq.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    (function($){

    var yoast = {
    accordion: function(){
    $('.wp-block-yoast-faq-block').find('.schema-faq-question').click(function(){
    //Expand or collapse this panel
    $(this).nextAll('.schema-faq-answer').eq(0).slideToggle('fast', function(){
    if( $(this).hasClass('collapse') ){
    $(this).removeClass('collapse');
    }
    else{
    $(this).addClass('collapse');
    }
    });

    //Hide the other panels
    $(".schema-faq-answer").not( $(this).nextAll('.schema-faq-answer').eq(0) ).slideUp('fast');
    });

    $('.wp-block-yoast-faq-block .schema-faq-question').click(function(){
    $('.wp-block-yoast-faq-block .schema-faq-question').not( $(this) ).removeClass('collapse');
    if( $(this).hasClass('collapse') ){
    $(this).removeClass('collapse');
    }
    else{
    $(this).addClass('collapse');
    }
    });
    }
    };

    // yoast.accordion();

    })(jQuery)