FAQ page bug fixes
- link to the first question didnt worked (first question has ID of 0, which was treated as false) - sometimes the copy button didnt worked (was returning from the script without being in a function)
This commit is contained in:
parent
aa431b3436
commit
223309c428
|
@ -1,30 +1,33 @@
|
|||
$(document).ready(function() {
|
||||
var hash = decodeURIComponent(location.hash.substr(1))
|
||||
|
||||
if (hash.startsWith("faq")) {
|
||||
// use an function so we can return early
|
||||
function displayFaq(hash) {
|
||||
var faqId = parseInt(hash.substr(3)) - 1 // IDs in faq start from 0
|
||||
|
||||
// Check if FAQ is a number and is not lower than 0
|
||||
if (!faqId || faqId < 0) {
|
||||
if (isNaN(faqId) || faqId < 0) {
|
||||
return
|
||||
}
|
||||
|
||||
var selectedCollapse = $("#faqcollapse-heading-" + faqId)
|
||||
|
||||
// Check if element exists
|
||||
if (!selectedCollapse.length) {
|
||||
return
|
||||
if (selectedCollapse.length) {
|
||||
// Toggle collapse
|
||||
selectedCollapse.parent().find(".collapse").collapse({
|
||||
toggle: true
|
||||
})
|
||||
|
||||
// Scroll body
|
||||
$("html,body").animate({
|
||||
scrollTop: selectedCollapse.offset().top - 60
|
||||
}, "slow")
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle collapse
|
||||
selectedCollapse.parent().find(".collapse").collapse({
|
||||
toggle: true
|
||||
})
|
||||
|
||||
// Scroll body
|
||||
$("html,body").animate({
|
||||
scrollTop: selectedCollapse.offset().top - 60
|
||||
},"slow")
|
||||
if (hash.startsWith("faq")) {
|
||||
displayFaq(hash)
|
||||
}
|
||||
|
||||
$(".copy-faq-url").click(function (e) {
|
||||
|
|
Loading…
Reference in New Issue