WordPress.org

Forums

Q and A Focus Plus FAQ
[resolved] Anchor plus minus sign in non-accordion (4 posts)

  1. t3rra
    Member
    Posted 1 year ago #

    When it is not in accordion behaviour and open multiple question opened and closed, anchor plus and minus sign does not behave exactly as it should. following code will fix it.

    jQuery(document).ready(function ($) {
        var faqContainer = $(".qafp-faqs"); // <- add
        $("div[id^=qafp-faq]").each(function () {
            var num = this.id.match(/qafp-faq(\d+)/)[1];
            var faq = $("#qafp-faq" + num);
            //var faqContainer = $(".qafp-faqs"); // <- remove
            if (faqContainer.is(".collapsible")) {
                faq.find(".qafp-faq-anchor").bind("click", function () {
                    if (faqContainer.is(".accordion")) $(".qafp-faq-answer").not("#qafp-faq" + num + " .qafp-faq-answer").hide();
                    if (faqContainer.is(".animation-fade")) faq.find(".qafp-faq-answer").fadeToggle();
                    else if (faqContainer.is(".animation-slide")) faq.find(".qafp-faq-answer").slideToggle();
                    else faq.find(".qafp-faq-answer").toggle(); if (faqContainer.is(".focus")) {
                        theOffset = $(this).offset();
                        $(window).scrollTop(theOffset.top - 50)
                    }
                    return false
                });
                $(".expand-all.expand").bind("click", function () {
                    $(".expand-all.expand").hide();
                    $(".expand-all.collapse").show();
                    if (faqContainer.is(".animation-fade")) $(".qafp-faq-answer").fadeIn(400);
                    else if (faqContainer.is(".animation-slide")) $(".qafp-faq-answer").slideDown();
                    else $(".qafp-faq-answer").show()
                });
                $(".expand-all.collapse").bind("click", function () {
                    $(".expand-all.collapse").hide();
                    $(".expand-all.expand").show();
                    if (faqContainer.is(".animation-fade")) $(".qafp-faq-answer").fadeOut(400);
                    else if (faqContainer.is(".animation-slide")) $(".qafp-faq-answer").slideUp();
                    else $(".qafp-faq-answer").hide()
                })
            }
        });
        $(".qafp-faq-anchor").click(function () {
            if ($(this).find('.qafp-fa-caret-right').hasClass('qafp-fa-open')) {
                $(this).find('.qafp-fa-caret-right').removeClass('qafp-fa-open');
            } else {
                if (faqContainer.is(".accordion")) // <- add
                  $('.qafp-fa-open').removeClass("qafp-fa-open", 1000);
                $(this).find(".qafp-fa-caret-right").addClass("qafp-fa-open", 1000);
                return false;
            }
        });
        $("#qafp_searchform").submit(function () {
            link = $(this).find("#qafp_search_link").val();
            query = $(this).find(".qafp_search").val();
            query = query.split(" ").join("+");
            link = link + query;
            location.href = link;
            return false
        })
    });

    [Moderator Note: Please post code or markup between backticks or use the code button. Or better still - use a pastebin. Your posted code may now have been permanently damaged by the forum's parser.]

    https://wordpress.org/plugins/q-and-a-focus-plus-faq/

  2. t3rra
    Member
    Posted 1 year ago #

    Does not seem to have been damaged though.. FYI javascript file was first beatified using online javascript beatifier and then modified.

    jQuery(document).ready(function ($) {
        var faqContainer = $(".qafp-faqs"); // <- add
        $("div[id^=qafp-faq]").each(function () {
            var num = this.id.match(/qafp-faq(\d+)/)[1];
            var faq = $("#qafp-faq" + num);
            //var faqContainer = $(".qafp-faqs"); // <- remove
            if (faqContainer.is(".collapsible")) {
                faq.find(".qafp-faq-anchor").bind("click", function () {
                    if (faqContainer.is(".accordion")) $(".qafp-faq-answer").not("#qafp-faq" + num + " .qafp-faq-answer").hide();
                    if (faqContainer.is(".animation-fade")) faq.find(".qafp-faq-answer").fadeToggle();
                    else if (faqContainer.is(".animation-slide")) faq.find(".qafp-faq-answer").slideToggle();
                    else faq.find(".qafp-faq-answer").toggle(); if (faqContainer.is(".focus")) {
                        theOffset = $(this).offset();
                        $(window).scrollTop(theOffset.top - 50)
                    }
                    return false
                });
                $(".expand-all.expand").bind("click", function () {
                    $(".expand-all.expand").hide();
                    $(".expand-all.collapse").show();
                    if (faqContainer.is(".animation-fade")) $(".qafp-faq-answer").fadeIn(400);
                    else if (faqContainer.is(".animation-slide")) $(".qafp-faq-answer").slideDown();
                    else $(".qafp-faq-answer").show()
                });
                $(".expand-all.collapse").bind("click", function () {
                    $(".expand-all.collapse").hide();
                    $(".expand-all.expand").show();
                    if (faqContainer.is(".animation-fade")) $(".qafp-faq-answer").fadeOut(400);
                    else if (faqContainer.is(".animation-slide")) $(".qafp-faq-answer").slideUp();
                    else $(".qafp-faq-answer").hide()
                })
            }
        });
        $(".qafp-faq-anchor").click(function () {
            if ($(this).find('.qafp-fa-caret-right').hasClass('qafp-fa-open')) {
                $(this).find('.qafp-fa-caret-right').removeClass('qafp-fa-open');
            } else {
                if (faqContainer.is(".accordion")) // <- add
                  $('.qafp-fa-open').removeClass("qafp-fa-open", 1000);
                $(this).find(".qafp-fa-caret-right").addClass("qafp-fa-open", 1000);
                return false;
            }
        });
        $("#qafp_searchform").submit(function () {
            link = $(this).find("#qafp_search_link").val();
            query = $(this).find(".qafp_search").val();
            query = query.split(" ").join("+");
            link = link + query;
            location.href = link;
            return false
        })
    });
  3. ELsMystERy
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks, will look into this as soon as I can and get back with you.

  4. ELsMystERy
    Member
    Plugin Author

    Posted 1 year ago #

    This will be in the next update.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Q and A Focus Plus FAQ
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags