398 lines
15 KiB
JavaScript
398 lines
15 KiB
JavaScript
/******/ (() => { // webpackBootstrap
|
|
/******/ "use strict";
|
|
/******/ var __webpack_modules__ = ({
|
|
|
|
/***/ "./src/modules/CollapsePanel.js":
|
|
/*!**************************************!*\
|
|
!*** ./src/modules/CollapsePanel.js ***!
|
|
\**************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
class CollapsePanel {
|
|
constructor() {
|
|
this.init();
|
|
}
|
|
init() {
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
this.addToggleCollapseListener('.accordion-toggle');
|
|
});
|
|
}
|
|
addToggleCollapseListener(selector) {
|
|
this.toggles = document.querySelectorAll(selector);
|
|
this.toggles.forEach(toggle => {
|
|
toggle.addEventListener('click', () => {
|
|
toggle.parentNode.parentNode.classList.toggle('active');
|
|
});
|
|
});
|
|
}
|
|
}
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (CollapsePanel);
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/modules/NavControl.js":
|
|
/*!***********************************!*\
|
|
!*** ./src/modules/NavControl.js ***!
|
|
\***********************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
class Nav {
|
|
constructor() {
|
|
this.toggleMenuBtn = document.getElementById('toggle-nav');
|
|
this.toggleSlideOutMenu = document.getElementById('slide-out-menu');
|
|
this.accordions = document.querySelectorAll('#slide-out-menu .accordion');
|
|
this.init();
|
|
}
|
|
init() {
|
|
// Open and Close the Nav Menu
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
this.toggleMenuBtn.addEventListener('click', () => this.toggleNavMenu());
|
|
});
|
|
}
|
|
toggleNavMenu() {
|
|
this.toggleMenuBtn.classList.toggle('active');
|
|
this.toggleSlideOutMenu.classList.toggle('open');
|
|
document.body.classList.toggle('noScroll');
|
|
this.collapseAllAccordions();
|
|
}
|
|
collapseAllAccordions() {
|
|
setTimeout(() => {
|
|
this.accordions.forEach(accordion => {
|
|
accordion.classList.remove('active');
|
|
});
|
|
}, 600);
|
|
}
|
|
}
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Nav);
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/modules/PageTransitions.js":
|
|
/*!****************************************!*\
|
|
!*** ./src/modules/PageTransitions.js ***!
|
|
\****************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony import */ var _CollapsePanel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./CollapsePanel */ "./src/modules/CollapsePanel.js");
|
|
/* harmony import */ var _NavControl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./NavControl */ "./src/modules/NavControl.js");
|
|
|
|
|
|
class PageTransitions {
|
|
constructor() {
|
|
this.init();
|
|
}
|
|
init() {
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
this.addLinkClickListener('a');
|
|
this.addFormSubmitListener('form');
|
|
});
|
|
}
|
|
addLinkClickListener(selector) {
|
|
this.links = document.querySelectorAll(selector);
|
|
this.links.forEach(link => {
|
|
link.addEventListener('click', e => {
|
|
e.preventDefault();
|
|
if (link.href === window.location.href) {
|
|
return;
|
|
}
|
|
this.navControl = new _NavControl__WEBPACK_IMPORTED_MODULE_1__["default"]();
|
|
if (this.navControl.toggleMenuBtn.classList.contains('active')) {
|
|
this.navControl.toggleNavMenu();
|
|
}
|
|
if (!this.isExternalLink(link) && this.isWordPressAdminLink(link)) {
|
|
window.location.href = link.href; // Navigate normally
|
|
} else if (!this.isExternalLink(link)) {
|
|
this.animatePageTransition(() => {
|
|
this.loadContent(link.getAttribute('href'), 'content-container');
|
|
});
|
|
} else if (this.isExternalLink(link)) {
|
|
link.setAttribute('target', '_blank');
|
|
window.open(link, '_system');
|
|
}
|
|
});
|
|
});
|
|
}
|
|
addFormSubmitListener(selector) {
|
|
this.forms = document.querySelectorAll(selector);
|
|
this.forms.forEach(form => {
|
|
form.addEventListener('submit', e => {
|
|
e.preventDefault();
|
|
if (this.navControl.toggleMenuBtn.classList.contains('active')) {
|
|
this.navControl.toggleNavMenu();
|
|
}
|
|
this.animatePageTransition(() => {
|
|
this.submitFormAsync(form);
|
|
});
|
|
});
|
|
});
|
|
}
|
|
animatePageTransition(callback) {
|
|
const contentContainer = document.getElementById('content-container');
|
|
|
|
// Add the transition class
|
|
this.addTransitionClass(contentContainer);
|
|
|
|
// Wait for the transition to complete
|
|
callback(); // Call the callback function (loading content) after the transition
|
|
}
|
|
addTransitionClass(element) {
|
|
element.classList.add('page-transition');
|
|
}
|
|
removeTransitionClass(element) {
|
|
element.classList.remove('page-transition');
|
|
}
|
|
loadContent(targetUrl, elementId) {
|
|
const contentContainer = document.getElementById('content-container');
|
|
fetch(targetUrl).then(response => response.text()).then(data => {
|
|
this.updateContent(data, elementId);
|
|
history.pushState(null, null, targetUrl);
|
|
}).catch(error => console.error('Error fetching content:', error));
|
|
}
|
|
submitFormAsync(form) {
|
|
const formData = new FormData(form);
|
|
fetch(form.action, {
|
|
method: 'POST',
|
|
body: formData
|
|
}).then(response => response.text()).then(data => {
|
|
// Assuming the response contains the new content to be loaded
|
|
const targetUrl = form.action; // You might need to adjust this based on your server's response
|
|
const elementId = 'content-container';
|
|
|
|
// Clear the search form
|
|
form.reset(); // Reset the form to clear input values
|
|
|
|
// Update content, push state, and remove transition class
|
|
this.updateContent(data, elementId);
|
|
history.pushState(null, null, targetUrl);
|
|
|
|
// Trigger removal of transition class after fetching data
|
|
const contentContainer = document.getElementById(elementId);
|
|
setTimeout(() => {
|
|
this.removeTransitionClass(contentContainer);
|
|
}, 300);
|
|
}).catch(error => console.error('Error submitting form:', error));
|
|
}
|
|
updateContent(data, elementId) {
|
|
const contentContainer = document.getElementById('content-container');
|
|
const parsedData = new DOMParser().parseFromString(data, 'text/html');
|
|
const targetElement = parsedData.getElementById(elementId);
|
|
if (targetElement) {
|
|
const newContent = targetElement.innerHTML;
|
|
|
|
// Update the content container
|
|
// Trigger removal of transition class after fetching data
|
|
setTimeout(() => {
|
|
this.removeTransitionClass(contentContainer);
|
|
contentContainer.innerHTML = newContent;
|
|
}, 300);
|
|
|
|
// Update the page title
|
|
const newTitle = parsedData.querySelector('title');
|
|
if (newTitle) {
|
|
document.title = newTitle.textContent;
|
|
}
|
|
|
|
// Initialize or update dynamic components
|
|
this.collapsePanel = new _CollapsePanel__WEBPACK_IMPORTED_MODULE_0__["default"]();
|
|
this.collapsePanel.addToggleCollapseListener('#content-container .accordion-toggle');
|
|
this.addLinkClickListener('#content-container a');
|
|
} else {
|
|
console.error(`Element with ID '${elementId}' not found in the fetched data`);
|
|
}
|
|
}
|
|
|
|
// Function to check if a link is external
|
|
isExternalLink(link) {
|
|
const currentDomain = window.location.hostname;
|
|
const linkDomain = link.hostname;
|
|
return linkDomain !== currentDomain;
|
|
}
|
|
isWordPressAdminLink(link) {
|
|
// Customize the condition based on your WordPress admin URL structure
|
|
const adminUrlRegex = /^.*\/wp-admin\//;
|
|
return adminUrlRegex.test(link.href);
|
|
}
|
|
}
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (PageTransitions);
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/modules/SplashScreen.js":
|
|
/*!*************************************!*\
|
|
!*** ./src/modules/SplashScreen.js ***!
|
|
\*************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
class SplashScreen {
|
|
constructor() {
|
|
this.splashScreen = document.getElementById('splash-screen');
|
|
this.enterButton = document.getElementById('app-enter');
|
|
this.headerNav = document.getElementById('header-nav');
|
|
this.footerNav = document.getElementById('footer-nav');
|
|
this.init();
|
|
}
|
|
init() {
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
this.checkFirstVisit();
|
|
});
|
|
}
|
|
checkFirstVisit() {
|
|
if (!sessionStorage.getItem('visited')) {
|
|
this.showSplashScreen();
|
|
this.addEventListeners();
|
|
}
|
|
}
|
|
showSplashScreen() {
|
|
this.splashScreen.classList.remove('hidden');
|
|
this.headerNav.classList.add('out-of-view');
|
|
this.footerNav.classList.add('out-of-view');
|
|
}
|
|
hideSplashScreen() {
|
|
this.splashScreen.classList.add('close');
|
|
setTimeout(() => {
|
|
this.headerNav.classList.add('in-view');
|
|
this.footerNav.classList.add('in-view');
|
|
this.splashScreen.classList.add('hidden');
|
|
}, 600);
|
|
setTimeout(() => {
|
|
this.headerNav.classList.remove('out-of-view');
|
|
this.footerNav.classList.remove('out-of-view');
|
|
this.headerNav.classList.remove('in-view');
|
|
this.footerNav.classList.remove('in-view');
|
|
}, 2000);
|
|
}
|
|
addEventListeners() {
|
|
this.enterButton.addEventListener('click', () => {
|
|
this.hideSplashScreen();
|
|
sessionStorage.setItem('visited', true);
|
|
});
|
|
}
|
|
}
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SplashScreen);
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/modules/TestModule.js":
|
|
/*!***********************************!*\
|
|
!*** ./src/modules/TestModule.js ***!
|
|
\***********************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
class Test {
|
|
constructor() {
|
|
console.log('This Module is for testing purposes');
|
|
}
|
|
}
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Test);
|
|
|
|
/***/ })
|
|
|
|
/******/ });
|
|
/************************************************************************/
|
|
/******/ // The module cache
|
|
/******/ var __webpack_module_cache__ = {};
|
|
/******/
|
|
/******/ // The require function
|
|
/******/ function __webpack_require__(moduleId) {
|
|
/******/ // Check if module is in cache
|
|
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
/******/ if (cachedModule !== undefined) {
|
|
/******/ return cachedModule.exports;
|
|
/******/ }
|
|
/******/ // Create a new module (and put it into the cache)
|
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
/******/ // no module.id needed
|
|
/******/ // no module.loaded needed
|
|
/******/ exports: {}
|
|
/******/ };
|
|
/******/
|
|
/******/ // Execute the module function
|
|
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
/******/
|
|
/******/ // Return the exports of the module
|
|
/******/ return module.exports;
|
|
/******/ }
|
|
/******/
|
|
/************************************************************************/
|
|
/******/ /* webpack/runtime/define property getters */
|
|
/******/ (() => {
|
|
/******/ // define getter functions for harmony exports
|
|
/******/ __webpack_require__.d = (exports, definition) => {
|
|
/******/ for(var key in definition) {
|
|
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
/******/ }
|
|
/******/ }
|
|
/******/ };
|
|
/******/ })();
|
|
/******/
|
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
/******/ (() => {
|
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
/******/ })();
|
|
/******/
|
|
/******/ /* webpack/runtime/make namespace object */
|
|
/******/ (() => {
|
|
/******/ // define __esModule on exports
|
|
/******/ __webpack_require__.r = (exports) => {
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
/******/ }
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
/******/ };
|
|
/******/ })();
|
|
/******/
|
|
/************************************************************************/
|
|
var __webpack_exports__ = {};
|
|
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
(() => {
|
|
/*!**********************!*\
|
|
!*** ./src/index.js ***!
|
|
\**********************/
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony import */ var _modules_TestModule__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./modules/TestModule */ "./src/modules/TestModule.js");
|
|
/* harmony import */ var _modules_NavControl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./modules/NavControl */ "./src/modules/NavControl.js");
|
|
/* harmony import */ var _modules_CollapsePanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./modules/CollapsePanel */ "./src/modules/CollapsePanel.js");
|
|
/* harmony import */ var _modules_SplashScreen__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./modules/SplashScreen */ "./src/modules/SplashScreen.js");
|
|
/* harmony import */ var _modules_PageTransitions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./modules/PageTransitions */ "./src/modules/PageTransitions.js");
|
|
// Our modules / classes
|
|
// Import modules e.g import MobileMenu from "./modules/MobileMenu"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Instantiate a new object using our modules/classes
|
|
// e.g var mobileMenu = new MobileMenu()
|
|
|
|
const testModule = new _modules_TestModule__WEBPACK_IMPORTED_MODULE_0__["default"]();
|
|
const navControl = new _modules_NavControl__WEBPACK_IMPORTED_MODULE_1__["default"]();
|
|
const collapsePanel = new _modules_CollapsePanel__WEBPACK_IMPORTED_MODULE_2__["default"]();
|
|
const splashScreen = new _modules_SplashScreen__WEBPACK_IMPORTED_MODULE_3__["default"]();
|
|
const pageTransitions = new _modules_PageTransitions__WEBPACK_IMPORTED_MODULE_4__["default"]();
|
|
})();
|
|
|
|
/******/ })()
|
|
;
|
|
//# sourceMappingURL=index.js.map
|