Files
NAN_Student_Handbook/assets/js/index.js
2024-01-19 02:13:37 -05:00

318 lines
12 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.toggles = document.querySelectorAll('.accordion-toggle');
this.init();
}
init() {
document.addEventListener('DOMContentLoaded', () => {
this.addToggleCollapseListener();
});
}
addToggleCollapseListener() {
this.toggles.forEach(toggle => {
toggle.addEventListener('click', () => {
toggle.parentNode.parentNode.classList.toggle('active');
});
});
}
addNewToggleCollapseListener() {
this.toggles = document.querySelectorAll('#content-container .accordion-toggle');
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.toggleCollapse();
this.events();
}
events() {
// Open and Close the Nav Menu
this.toggleMenuBtn.addEventListener('click', () => this.toggleNavMenu());
}
toggleNavMenu() {
this.toggleMenuBtn.classList.toggle('active');
this.toggleSlideOutMenu.classList.toggle('open');
document.body.classList.toggle('noScroll');
this.toggleCollapse();
}
toggleCollapse() {
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");
// Import the CollapsePanel class
class PageTransitions {
constructor() {
this.init();
}
init() {
document.addEventListener('DOMContentLoaded', () => {
this.addLinkClickListener();
});
}
addLinkClickListener() {
this.links = document.querySelectorAll('a');
this.links.forEach(link => {
link.addEventListener('click', e => {
e.preventDefault();
if (this.isExternalLink(link)) {
link.setAttribute('target', '_blank');
}
this.loadContent(link.getAttribute('href'), 'content-container');
});
});
}
addNewLinkClickListener() {
this.newlinks = document.querySelectorAll('#content-container a');
console.log(this.newlinks);
this.newlinks.forEach(link => {
link.addEventListener('click', e => {
e.preventDefault();
if (this.isExternalLink(link)) {
link.setAttribute('target', '_blank');
}
this.loadContent(link.getAttribute('href'), 'content-container');
});
});
}
loadContent(targetUrl, elementId) {
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));
}
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;
// If you want to replace the content instead of appending:
contentContainer.innerHTML = newContent;
// Create an instance of CollapsePanel and call toggleCollapse
this.collapsePanel = new _CollapsePanel__WEBPACK_IMPORTED_MODULE_0__["default"]();
this.collapsePanel.addNewToggleCollapseListener();
this.addNewLinkClickListener();
} 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;
}
}
/* 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.enterBtn = document.getElementById('app-enter');
this.splashScreen = document.getElementById('splash-screen');
this.headerNav = document.getElementById('header-nav');
this.footerNav = document.getElementById('footer-nav');
this.events();
}
events() {
// Open and Close the Nav Menu
if (this.enterBtn) {
this.enterBtn.addEventListener('click', () => this.enterApp());
}
}
enterApp() {
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);
}
}
/* 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