Created
November 27, 2013 04:26
-
-
Save glebcha/7670660 to your computer and use it in GitHub Desktop.
Pseudo-accordion used to open/hide FAQ questions, copied as is and can be implemented easily.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var animatedQuestions = function () { | |
var questions = $('.question-outer'); | |
if (questions.length !== 0) { | |
var openQuestion = function (event) { | |
event.preventDefault(); | |
var target = event ? event.target : window.event.srcElement; | |
var parent = target.parentNode.parentNode.parentNode; | |
var qshort = parent.children[0]; | |
var qfull = parent.children[parent.children.length-1]; | |
$(qfull).slideDown().delay(500); | |
$(qshort).slideUp(); | |
}; | |
var closeQuestion = function (event) { | |
event.preventDefault(); | |
var target = event ? event.target : window.event.srcElement; | |
var parent = target.parentNode.parentNode.parentNode.parentNode || target.parentNode.parentNode.parentNode.parentNode.parentNode; | |
var qshort = parent.children[0]; | |
var qfull = parent.children[parent.children.length-1]; | |
$(qfull).slideUp(); | |
$(qshort).slideDown().delay(500); | |
}; | |
for (var i = 0; i < questions.length; i++) { | |
var question = questions[i]; | |
var qShort = question.children[0]; | |
var qFull = question.children[question.children.length-1]; | |
var qOpen = qShort.querySelector('.question-link'); | |
var qClose = qFull.querySelector('.close-question'); | |
$(qOpen).bind('click', openQuestion); | |
$(qClose).bind('click', closeQuestion); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment