D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
ksclnmuac
/
public_html
/
grievance
/
assets
/
js
/
Filename :
faq.js
back
Copy
var accordion = $('body').find('[data-behavior="accordion"]'); var expandedClass = 'is-expanded'; $.each(accordion, function () { // loop through all accordions on the page var accordionItems = $(this).find('[data-binding="expand-accordion-item"]'); $.each(accordionItems, function () { // loop through all accordion items of each accordion var $this = $(this); var triggerBtn = $this.find('[data-binding="expand-accordion-trigger"]'); var setHeight = function (nV) { // set height of inner content for smooth animation var innerContent = nV.find('.accordion__content-inner')[0], maxHeight = $(innerContent).outerHeight(), content = nV.find('.accordion__content')[0]; if (!content.style.height || content.style.height === '0px') { $(content).css('height', maxHeight); } else { $(content).css('height', '0px'); } }; var toggleClasses = function (event) { var clickedItem = event.currentTarget; var currentItem = $(clickedItem).parent(); var clickedContent = $(currentItem).find('.accordion__content') $(currentItem).toggleClass(expandedClass); setHeight(currentItem); if ($(currentItem).hasClass('is-expanded')) { $(clickedItem).attr('aria-selected', 'true'); $(clickedItem).attr('aria-expanded', 'true'); $(clickedContent).attr('aria-hidden', 'false'); } else { $(clickedItem).attr('aria-selected', 'false'); $(clickedItem).attr('aria-expanded', 'false'); $(clickedContent).attr('aria-hidden', 'true'); } } triggerBtn.on('click', event, function (e) { e.preventDefault(); toggleClasses(event); }); // open tabs if the spacebar or enter button is clicked whilst they are in focus $(triggerBtn).on('keydown', event, function (e) { if (e.keyCode === 13 || e.keyCode === 32) { e.preventDefault(); toggleClasses(event); } }); }); });