Final prep for production

This commit is contained in:
Thanakorn S
2026-05-12 13:55:39 +07:00
parent adfd5ef017
commit 5c6a478b40
58 changed files with 15114 additions and 26 deletions
+7
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+9
View File
@@ -0,0 +1,9 @@
/*!
* replaceme.js - text rotating component in vanilla JavaScript
* @version 1.1.0
* @author Adrian Klimek
* @link https://adrianklimek.github.io/replaceme/
* @copyright Addrian Klimek 2016
* @license MIT
*/
!function(a,b){"use strict";function c(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}function d(){"function"==typeof b&&b.fn.extend({ReplaceMe:function(a){return this.each(function(){new e(this,a)})}})}function e(a,b){var d={animation:"animated fadeIn",speed:2e3,separator:",",hoverStop:!1,clickChange:!1,loopCount:"infinite",autoRun:!0,onInit:!1,onChange:!1,onComplete:!1};if("object"==typeof b?this.options=c(d,b):this.options=d,"undefined"==typeof a)throw new Error('ReplaceMe [constructor]: "element" parameter is required');if("object"==typeof a)this.element=a;else{if("string"!=typeof a)throw new Error('ReplaceMe [constructor]: wrong "element" parameter');this.element=document.querySelector(a)}this.init()}e.prototype.init=function(){"function"==typeof this.options.onInit&&this.options.onInit(),this.words=this.escapeHTML(this.element.innerHTML).split(this.options.separator),this.count=this.words.length,this.position=this.loopCount=0,this.running=!1,this.bindAll(),this.options.autoRun===!0&&this.start()},e.prototype.bindAll=function(){this.options.hoverStop===!0&&(this.element.addEventListener("mouseover",this.pause.bind(this)),this.element.addEventListener("mouseout",this.start.bind(this))),this.options.clickChange===!0&&this.element.addEventListener("click",this.change.bind(this))},e.prototype.changeAnimation=function(){this.change(),this.loop=setTimeout(this.changeAnimation.bind(this),this.options.speed)},e.prototype.start=function(){this.running!==!0&&(this.running=!0,this.changeWord(this.words[this.position]),this.position++),this.loop=setTimeout(this.changeAnimation.bind(this),this.options.speed)},e.prototype.change=function(){return this.position>this.count-1&&(this.position=0,this.loopCount++,this.loopCount>=this.options.loopCount)?void this.stop():(this.changeWord(this.words[this.position]),this.position++,void("function"==typeof this.options.onChange&&this.options.onChange()))},e.prototype.stop=function(){this.running=!1,this.position=this.loopCount=0,this.pause(),"function"==typeof this.options.onComplete&&this.options.onComplete()},e.prototype.pause=function(){clearTimeout(this.loop)},e.prototype.changeWord=function(a){this.element.innerHTML='<span class="'+this.options.animation+'" style="display:inline-block;">'+a+"</span>"},e.prototype.escapeHTML=function(a){var b=/<\/?\w+\s*[^>]*>/g;return b.test(a)===!0?a.replace(b,""):a},a.ReplaceMe=e,d()}(window,window.jQuery);
+136
View File
@@ -0,0 +1,136 @@
/* Description: Custom JS file */
/* Navigation*/
// Collapse the navbar by adding the top-nav-collapse class
window.onscroll = function () {
scrollFunction();
scrollFunctionBTT(); // back to top button
};
window.onload = function () {
scrollFunction();
};
function scrollFunction() {
if (document.documentElement.scrollTop > 30) {
document.getElementById("navbarExample").classList.add("top-nav-collapse");
} else if ( document.documentElement.scrollTop < 30 ) {
document.getElementById("navbarExample").classList.remove("top-nav-collapse");
}
}
// Navbar on mobile
let elements = document.querySelectorAll(".nav-link:not(.dropdown-toggle)");
for (let i = 0; i < elements.length; i++) {
elements[i].addEventListener("click", () => {
document.querySelector(".offcanvas-collapse").classList.toggle("open");
});
}
document.querySelector(".navbar-toggler").addEventListener("click", () => {
document.querySelector(".offcanvas-collapse").classList.toggle("open");
});
// Hover on desktop
function toggleDropdown(e) {
const _d = e.target.closest(".dropdown");
let _m = document.querySelector(".dropdown-menu", _d);
setTimeout(
function () {
const shouldOpen = _d.matches(":hover");
_m.classList.toggle("show", shouldOpen);
_d.classList.toggle("show", shouldOpen);
_d.setAttribute("aria-expanded", shouldOpen);
},
e.type === "mouseleave" ? 300 : 0
);
}
// On hover
const dropdownCheck = document.querySelector('.dropdown');
if (dropdownCheck !== null) {
document.querySelector(".dropdown").addEventListener("mouseleave", toggleDropdown);
document.querySelector(".dropdown").addEventListener("mouseover", toggleDropdown);
// On click
document.querySelector(".dropdown").addEventListener("click", (e) => {
const _d = e.target.closest(".dropdown");
let _m = document.querySelector(".dropdown-menu", _d);
if (_d.classList.contains("show")) {
_m.classList.remove("show");
_d.classList.remove("show");
} else {
_m.classList.add("show");
_d.classList.add("show");
}
});
}
/* Rotating Text - Word Cycle */
var checkReplace = document.querySelector('.replace-me');
if (checkReplace !== null) {
var replace = new ReplaceMe(document.querySelector('.replace-me'), {
animation: 'animated fadeIn', // Animation class or classes
speed: 2000, // Delay between each phrase in miliseconds
separator: ',', // Phrases separator
hoverStop: false, // Stop rotator on phrase hover
clickChange: false, // Change phrase on click
loopCount: 'infinite', // Loop Count - 'infinite' or number
autoRun: true, // Run rotator automatically
onInit: false, // Function
onChange: false, // Function
onComplete: false // Function
});
}
/* Card Slider - Swiper */
var cardSlider = new Swiper('.card-slider', {
autoplay: {
delay: 4000,
disableOnInteraction: false
},
loop: true,
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev'
},
slidesPerView: 3,
spaceBetween: 70,
breakpoints: {
// when window is <= 767px
767: {
slidesPerView: 1
},
// when window is <= 991px
991: {
slidesPerView: 2,
spaceBetween: 40
}
}
});
/* Back To Top Button */
// Get the button
myButton = document.getElementById("myBtn");
// When the user scrolls down 20px from the top of the document, show the button
function scrollFunctionBTT() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
myButton.style.display = "block";
} else {
myButton.style.display = "none";
}
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0; // for Safari
document.documentElement.scrollTop = 0; // for Chrome, Firefox, IE and Opera
}
+13
View File
File diff suppressed because one or more lines are too long