added these pages: about, faq, contact, blog, blogs, all tour pages.

This commit is contained in:
vargha1
2026-09-21 15:38:15 +03:30
parent eab161aa5c
commit de38302be3
27 changed files with 9157 additions and 1014 deletions

View File

@@ -122,8 +122,7 @@
}
/* ---------- FAQ accordion ---------- */
var accordion = document.querySelector('[data-accordion]');
if (accordion) {
Array.prototype.forEach.call(document.querySelectorAll('[data-accordion]'), function (accordion) {
accordion.addEventListener('click', function (e) {
var btn = e.target.closest('.acc__q');
if (!btn) return;
@@ -133,7 +132,7 @@
});
btn.setAttribute('aria-expanded', String(!open));
});
}
});
/* ---------- date field: text placeholder, native picker on focus ---------- */
var dateField = document.querySelector('[data-datefield]');
@@ -253,7 +252,9 @@
'price-asc': function (a, b) { return Number(a.dataset.price) - Number(b.dataset.price); },
'price-desc': function (a, b) { return Number(b.dataset.price) - Number(a.dataset.price); },
rating: function (a, b) { return Number(b.dataset.rating) - Number(a.dataset.rating); },
duration: function (a, b) { return durationDays(a) - durationDays(b); }
duration: function (a, b) { return durationDays(a) - durationDays(b); },
oldest: function (a, b) { return Number(a.dataset.added) - Number(b.dataset.added); },
title: function (a, b) { return a.dataset.title.localeCompare(b.dataset.title); }
};
function durationDays(el) {
@@ -314,8 +315,9 @@
/* built from numbers only, so the markup here is safe to assign as HTML */
function countText(start, shownCount) {
var total = matches.length;
if (!total) return 'No tours found';
var noun = total === 1 ? 'tour' : 'tours';
var base = (countEl && countEl.getAttribute('data-noun')) || 'tour';
if (!total) return 'No ' + base + 's found';
var noun = total === 1 ? base : base + 's';
if (shownCount === total) return 'Showing <b>' + total + '</b> ' + noun;
return 'Showing <b>' + (start + 1) + '&ndash;' + (start + shownCount) +
'</b> of <b>' + total + '</b> ' + noun;
@@ -351,7 +353,7 @@
function setHighlight(el, on) {
el.classList.toggle('is-active', on);
var card = el.querySelector('.dcard');
var card = el.querySelector('.dcard, .acard');
var badge = el.querySelector('.ring-badge--card');
if (card) card.classList.toggle('is-active', on);
if (badge) badge.classList.toggle('ring-badge--accent', on);
@@ -370,7 +372,7 @@
if (next < 1 || next > totalPages || next === page) return;
page = next;
render();
var list = document.getElementById('tour-list');
var list = grid.closest('section');
if (list) list.scrollIntoView({ block: 'start', behavior: 'smooth' });
}
@@ -416,4 +418,125 @@
apply();
}
/* ---------- single article: share, reviews ---------- */
var post = document.getElementById('post');
if (post) {
var pageUrl = encodeURIComponent(window.location.href);
var shareTargets = {
telegram: 'https://t.me/share/url?url=',
facebook: 'https://www.facebook.com/sharer/sharer.php?u=',
whatsapp: 'https://wa.me/?text='
};
Array.prototype.forEach.call(post.querySelectorAll('[data-share]'), function (a) {
var base = shareTargets[a.getAttribute('data-share')];
if (base) a.href = base + pageUrl;
});
var copyBtn = post.querySelector('[data-copy-link]');
if (copyBtn) {
var copyLabel = copyBtn.textContent;
copyBtn.addEventListener('click', function () {
var done = function () {
copyBtn.textContent = 'Link copied';
copyBtn.classList.add('is-done');
window.setTimeout(function () {
copyBtn.textContent = copyLabel;
copyBtn.classList.remove('is-done');
}, 2000);
};
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(window.location.href).then(done, function () {});
}
});
}
var reviewList = document.getElementById('reviewList');
var reviewMore = document.getElementById('reviewMore');
if (reviewList && reviewMore) {
var moreLabel = reviewMore.querySelector('span');
reviewMore.addEventListener('click', function () {
var open = reviewList.classList.toggle('is-collapsed') === false;
reviewMore.setAttribute('aria-expanded', String(open));
moreLabel.textContent = open ? 'Show fewer reviews' : 'Show all reviews';
});
}
/* a thumb is a toggle, and up and down are mutually exclusive */
post.addEventListener('click', function (e) {
var vote = e.target.closest('.vote');
if (!vote) return;
var pressed = vote.getAttribute('aria-pressed') !== 'true';
Array.prototype.forEach.call(vote.parentNode.querySelectorAll('.vote'), function (v) {
v.setAttribute('aria-pressed', 'false');
});
vote.setAttribute('aria-pressed', String(pressed));
});
var reviewForm = document.getElementById('reviewForm');
var reviewStatus = document.getElementById('reviewStatus');
if (reviewForm && reviewStatus) {
reviewForm.addEventListener('submit', function (e) {
e.preventDefault();
var bad = null;
Array.prototype.forEach.call(reviewForm.querySelectorAll('.rinput'), function (field) {
var ok = field.value.trim() !== '' && field.checkValidity();
field.setAttribute('aria-invalid', String(!ok));
if (!ok && !bad) bad = field;
});
reviewStatus.classList.toggle('is-error', !!bad);
if (bad) {
reviewStatus.textContent = 'Please fill in your name, a valid email and your review.';
bad.focus();
return;
}
reviewStatus.textContent = 'Thanks! Your review has been submitted for approval.';
reviewForm.reset();
});
}
}
/* ---------- FAQ page: category nav follows the scroll ---------- */
var catLinks = Array.prototype.slice.call(document.querySelectorAll('.catnav__link'));
if (catLinks.length && 'IntersectionObserver' in window) {
var setCat = function (id) {
catLinks.forEach(function (a) {
var on = a.getAttribute('href') === '#' + id;
a.classList.toggle('is-active', on);
if (on) a.setAttribute('aria-current', 'true');
else a.removeAttribute('aria-current');
});
};
var catObserver = new IntersectionObserver(function (entries) {
entries.forEach(function (entry) {
if (entry.isIntersecting) setCat(entry.target.id);
});
}, { rootMargin: '-30% 0px -60% 0px' });
catLinks.forEach(function (a) {
var target = document.querySelector(a.getAttribute('href'));
if (target) catObserver.observe(target);
});
}
/* ---------- contact ticket form ---------- */
var ticketForm = document.getElementById('ticketForm');
var ticketStatus = document.getElementById('ticketStatus');
if (ticketForm && ticketStatus) {
ticketForm.addEventListener('submit', function (e) {
e.preventDefault();
var bad = null;
Array.prototype.forEach.call(ticketForm.querySelectorAll('.rinput'), function (field) {
var ok = field.value.trim() !== '' && field.checkValidity();
field.setAttribute('aria-invalid', String(!ok));
if (!ok && !bad) bad = field;
});
ticketStatus.classList.toggle('is-error', !!bad);
if (bad) {
ticketStatus.textContent = 'Please fill in your name, a valid email and your message.';
bad.focus();
return;
}
ticketStatus.textContent = 'Thanks! Your ticket has been sent. We will reply by email.';
ticketForm.reset();
});
}
})();