Project:Frequently Asked Questions
Version:6.x-1.x-dev
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Just love the faq.module .. I have a little support question please ..

As my site has a lot of question and every time a user clicks a link to open the answer (with toggle), they have a lot of answers open and then have to scroll down to the next one.

Is it perhaps possible that when they click on the next link that the previous answer closes? Just to keep it nice and tight :)

Look forward to any reply, and thank you.
Lilian

Comments

#1

I can see an advantage of this and the existing method, so if implimented can it be switchable :)

#2

I would also be very interested in this, one could categorize the questions and open the categories in another page, but this solution has it's uses... this should also work for the categories showing on the same page, selecting one would close the previous...

#3

This is working for me:

1. Add this to faq.css:

.faq .collapsible {
display: block;
}

.faq .collapsed {
display: none;
}

2. In faq.js, starting at line 218, change this:

if (Drupal.jsEnabled) {
  $(document).ready(function () {
    // hide/show answer to question
    $('div.faq-dd-hide-answer').hide();
    $('div.faq-dt-hide-answer').click(function() {
      $(this).next('div.faq-dd-hide-answer').slideToggle();
      return false;
    });


    // hide/show q/a for a category
    $('div.faq-qa-hide').hide();
    $('div.faq-qa-header .faq-header').click(function() {
      $(this).parent().next('div.faq-qa-hide').slideToggle();
      return false;
    });

with this:

if (Drupal.jsEnabled) {
  $(document).ready(function () {
    // hide/show answer to question
    $('div.faq-dd-hide-answer').addClass("collapsible collapsed");
    $('div.faq-dt-hide-answer').click(function() {
      $('div.faq-dd-hide-answer').not($(this).next('div.faq-dd-hide-answer')).addClass("collapsed");
      $(this).next('div.faq-dd-hide-answer').toggleClass("collapsed");
      return false;
    });


    // hide/show q/a for a category
    $('div.faq-qa-hide').addClass("collapsible collapsed");
    $('div.faq-qa-header .faq-header').click(function() {
      $('div.faq-qa-hide').not($(this).parent().next('div.faq-qa-hide')).addClass("collapsed");
      $(this).parent().next('div.faq-qa-hide').toggleClass("collapsed");
      return false;
    });

Works for both questions and categories. No fancy sliding, though, and not configurable.

What it does: instead of a slideToggle on the clicked question it applies the default Drupal classes collapsible/collapsed to all questions.

AttachmentSize
faq.js_.patch 1.12 KB
faq.css_.patch 288 bytes

#4

This is actually "Accordeon" UI Pattern. Very nice feature indeed.

#5

Status:active» needs review

#6

Is it true this tweak wont work at version 5.x?

I tried but it just expanded all FAQ's

#7

Status:needs review» fixed

I've added this to the Drupal 6 branch, and it'll be included in the next release. I also made it configurable - so you can have the current behaviour or the new option.

With Drupal 7 almost upon us, I won't be adding this feature to the Drupal 5 branch as it is now feature frozen.

#8

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#9

Released in faq 6.x-1.9.

nobody click here