/******/ (function(modules) { // webpackBootstrap /******/ // install a JSONP callback for chunk loading /******/ function webpackJsonpCallback(data) { /******/ var chunkIds = data[0]; /******/ var moreModules = data[1]; /******/ /******/ /******/ // add "moreModules" to the modules object, /******/ // then flag all "chunkIds" as loaded and fire callback /******/ var moduleId, chunkId, i = 0, resolves = []; /******/ for(;i < chunkIds.length; i++) { /******/ chunkId = chunkIds[i]; /******/ if(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) { /******/ resolves.push(installedChunks[chunkId][0]); /******/ } /******/ installedChunks[chunkId] = 0; /******/ } /******/ for(moduleId in moreModules) { /******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) { /******/ modules[moduleId] = moreModules[moduleId]; /******/ } /******/ } /******/ if(parentJsonpFunction) parentJsonpFunction(data); /******/ /******/ while(resolves.length) { /******/ resolves.shift()(); /******/ } /******/ /******/ }; /******/ /******/ /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // object to store loaded and loading chunks /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched /******/ // Promise = chunk loading, 0 = chunk loaded /******/ var installedChunks = { /******/ "main": 0 /******/ }; /******/ /******/ /******/ /******/ // script path function /******/ function jsonpScriptSrc(chunkId) { /******/ return __webpack_require__.p + "" + ({"js/addressBook":"js/addressBook","js/appointments":"js/appointments","js/cart":"js/cart","js/checkoutRegistration":"js/checkoutRegistration","js/checkout~js/hubbox.val":"js/checkout~js/hubbox.val","js/checkout":"js/checkout","js/hubbox.val":"js/hubbox.val","js/contactUs":"js/contactUs","js/globaleAnalytics":"js/globaleAnalytics","js/login":"js/login","js/newsletter":"js/newsletter","js/orderHistory":"js/orderHistory","js/paymentInstruments":"js/paymentInstruments","js/paypalCreditFinancingOptions.val":"js/paypalCreditFinancingOptions.val","js/paypalMFRA.val":"js/paypalMFRA.val","js/paypalUtils.val":"js/paypalUtils.val","js/productDetail~js/productTile~js/search":"js/productDetail~js/productTile~js/search","js/productDetail":"js/productDetail","js/productTile":"js/productTile","js/search":"js/search","js/profile":"js/profile","js/storeLocator":"js/storeLocator","js/wishlist":"js/wishlist"}[chunkId]||chunkId) + ".js" /******/ } /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ // This file contains only the entry chunk. /******/ // The chunk loading function for additional chunks /******/ __webpack_require__.e = function requireEnsure(chunkId) { /******/ var promises = []; /******/ /******/ /******/ // JSONP chunk loading for javascript /******/ /******/ var installedChunkData = installedChunks[chunkId]; /******/ if(installedChunkData !== 0) { // 0 means "already installed". /******/ /******/ // a Promise means "currently loading". /******/ if(installedChunkData) { /******/ promises.push(installedChunkData[2]); /******/ } else { /******/ // setup Promise in chunk cache /******/ var promise = new Promise(function(resolve, reject) { /******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; /******/ }); /******/ promises.push(installedChunkData[2] = promise); /******/ /******/ // start chunk loading /******/ var script = document.createElement('script'); /******/ var onScriptComplete; /******/ /******/ script.charset = 'utf-8'; /******/ script.timeout = 120; /******/ if (__webpack_require__.nc) { /******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } /******/ script.src = jsonpScriptSrc(chunkId); /******/ /******/ // create error before stack unwound to get useful stacktrace later /******/ var error = new Error(); /******/ onScriptComplete = function (event) { /******/ // avoid mem leaks in IE. /******/ script.onerror = script.onload = null; /******/ clearTimeout(timeout); /******/ var chunk = installedChunks[chunkId]; /******/ if(chunk !== 0) { /******/ if(chunk) { /******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); /******/ var realSrc = event && event.target && event.target.src; /******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'; /******/ error.name = 'ChunkLoadError'; /******/ error.type = errorType; /******/ error.request = realSrc; /******/ chunk[1](error); /******/ } /******/ installedChunks[chunkId] = undefined; /******/ } /******/ }; /******/ var timeout = setTimeout(function(){ /******/ onScriptComplete({ type: 'timeout', target: script }); /******/ }, 120000); /******/ script.onerror = script.onload = onScriptComplete; /******/ document.head.appendChild(script); /******/ } /******/ } /******/ return Promise.all(promises); /******/ }; /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // on error function for async loading /******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; /******/ /******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; /******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray); /******/ jsonpArray.push = webpackJsonpCallback; /******/ jsonpArray = jsonpArray.slice(); /******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); /******/ var parentJsonpFunction = oldJsonpFunction; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 0); /******/ }) /************************************************************************/ /******/ ({ /***/ "./cartridges/app_bee_base/cartridge/client/default/js/internal/appConfig.plain.js": /*!*****************************************************************************************!*\ !*** ./cartridges/app_bee_base/cartridge/client/default/js/internal/appConfig.plain.js ***! \*****************************************************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./cartridges/app_bee_base/cartridge/client/default/js/internal/appConfig.js (referenced with cjs require) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /** * Read the application configuration directly. */ let _ref = window.beesfra || {}, app = _ref.app; if (!app) { app = {}; } const appConfig = app; /* harmony default export */ __webpack_exports__["default"] = (appConfig); /***/ }), /***/ "./cartridges/app_bee_base/cartridge/client/default/js/util/debounce.js": /*!******************************************************************************!*\ !*** ./cartridges/app_bee_base/cartridge/client/default/js/util/debounce.js ***! \******************************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony default export */ __webpack_exports__["default"] = (function (fn, time) { let timeout; return function () { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } clearTimeout(timeout); timeout = setTimeout(() => fn.apply(this, args), time); }; }); /***/ }), /***/ "./cartridges/app_hobbs/cartridge/client/default/js/index.js": /*!********************************************************************************!*\ !*** ./cartridges/app_hobbs/cartridge/client/default/js/index.js + 10 modules ***! \********************************************************************************/ /*! no exports provided */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/int_cloudinary_sfra/cartridge/client/default/js/main.js (<- Module uses injected variables ($)) */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/util.js because of ./cartridges/app_tfg/cartridge/client/default/js/appointments.js */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_hobbs/cartridge/client/default/scss/style.scss (<- Module is not an ECMAScript module) */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/jquery/dist/jquery.js (<- Module is not an ECMAScript module) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // CONCATENATED MODULE: ./cartridges/app_tfg/cartridge/client/default/js/util/loadProjectChunks.val.js /* eslint-disable */ /* harmony default export */ var loadProjectChunks_val = (projectScripts => { if (projectScripts) { projectScripts.forEach(file => { switch (file) { case 'appointments': __webpack_require__.e(/*! import() | js/appointments */ "js/appointments").then(__webpack_require__.bind(null, /*! ../chunks/appointments */ "./cartridges/app_tfg/cartridge/client/default/js/chunks/appointments.js")); break; case 'contactUs': __webpack_require__.e(/*! import() | js/contactUs */ "js/contactUs").then(__webpack_require__.bind(null, /*! ../chunks/contactUs */ "./cartridges/app_tfg/cartridge/client/default/js/chunks/contactUs.js")); break; case 'globaleAnalytics': __webpack_require__.e(/*! import() | js/globaleAnalytics */ "js/globaleAnalytics").then(__webpack_require__.bind(null, /*! ../chunks/globaleAnalytics */ "./cartridges/app_tfg/cartridge/client/default/js/chunks/globaleAnalytics.js")); break; case 'hubbox.val': Promise.all(/*! import() | js/hubbox.val */[__webpack_require__.e("js/checkout~js/hubbox.val"), __webpack_require__.e("js/hubbox.val")]).then(__webpack_require__.bind(null, /*! ../../../../../../int_hubbox_sfra_tfg/cartridge/client/default/js/chunks/hubbox.val */ "./cartridges/int_hubbox_sfra_tfg/cartridge/client/default/js/chunks/hubbox.val.js")); break; case 'paypalCreditFinancingOptions.val': __webpack_require__.e(/*! import() | js/paypalCreditFinancingOptions.val */ "js/paypalCreditFinancingOptions.val").then(__webpack_require__.bind(null, /*! ../../../../../../int_paypal_sfra_tfg/cartridge/client/default/js/chunks/paypalCreditFinancingOptions.val */ "./cartridges/int_paypal_sfra_tfg/cartridge/client/default/js/chunks/paypalCreditFinancingOptions.val.js")); break; case 'paypalMFRA.val': __webpack_require__.e(/*! import() | js/paypalMFRA.val */ "js/paypalMFRA.val").then(__webpack_require__.bind(null, /*! ../../../../../../int_paypal_sfra_tfg/cartridge/client/default/js/chunks/paypalMFRA.val */ "./cartridges/int_paypal_sfra_tfg/cartridge/client/default/js/chunks/paypalMFRA.val.js")); break; case 'paypalUtils.val': __webpack_require__.e(/*! import() | js/paypalUtils.val */ "js/paypalUtils.val").then(__webpack_require__.bind(null, /*! ../../../../../../int_paypal_sfra_tfg/cartridge/client/default/js/chunks/paypalUtils.val */ "./cartridges/int_paypal_sfra_tfg/cartridge/client/default/js/chunks/paypalUtils.val.js")); break; case 'newsletter': __webpack_require__.e(/*! import() | js/newsletter */ "js/newsletter").then(__webpack_require__.bind(null, /*! ../../../../../../plugin_newsletter_tfg/cartridge/client/default/js/chunks/newsletter */ "./cartridges/plugin_newsletter_tfg/cartridge/client/default/js/chunks/newsletter.js")); break; case 'wishlist': __webpack_require__.e(/*! import() | js/wishlist */ "js/wishlist").then(__webpack_require__.bind(null, /*! ../../../../../../plugin_wishlists_tfg/cartridge/client/default/js/chunks/wishlist */ "./cartridges/plugin_wishlists_tfg/cartridge/client/default/js/chunks/wishlist.js")); break; default: if (true) { console.error(`Unknown chunk "${file}".`); // eslint-disable-line no-console } } }); } }); // eslint-disable-line eol-last // CONCATENATED MODULE: ./cartridges/app_bee_base/cartridge/client/default/js/internal/appConfig.js /** * Get the storefront config provided via script tag. * * Depending on the configuration it uses Redux or read it directly */ let app; if (false) {} else { app = __webpack_require__(/*! ./appConfig.plain */ "./cartridges/app_bee_base/cartridge/client/default/js/internal/appConfig.plain.js").default; // eslint-disable-line global-require } const appConfig = app; /* harmony default export */ var internal_appConfig = (appConfig); // CONCATENATED MODULE: ./cartridges/app_bee_base/cartridge/client/default/js/util/loadChunks.val.js /* harmony default export */ var loadChunks_val = (additionalScripts => { if (additionalScripts) { additionalScripts.forEach(file => { switch (file) { case 'addressBook': __webpack_require__.e(/*! import() | js/addressBook */ "js/addressBook").then(__webpack_require__.bind(null, /*! storefront/sfra/addressBook */ "./cartridges/app_tfg/cartridge/client/default/js/sfra/addressBook.js")); break; case 'cart': __webpack_require__.e(/*! import() | js/cart */ "js/cart").then(__webpack_require__.bind(null, /*! storefront/sfra/cart */ "./cartridges/app_tfg/cartridge/client/default/js/sfra/cart.js")); break; case 'checkout': Promise.all(/*! import() | js/checkout */[__webpack_require__.e("js/checkout~js/hubbox.val"), __webpack_require__.e("js/checkout")]).then(__webpack_require__.bind(null, /*! storefront/sfra/checkout */ "./cartridges/app_tfg/cartridge/client/default/js/sfra/checkout.js")); break; case 'checkoutRegistration': __webpack_require__.e(/*! import() | js/checkoutRegistration */ "js/checkoutRegistration").then(__webpack_require__.bind(null, /*! storefront/sfra/checkoutRegistration */ "./cartridges/app_tfg/cartridge/client/default/js/sfra/checkoutRegistration.js")); break; case 'login': __webpack_require__.e(/*! import() | js/login */ "js/login").then(__webpack_require__.bind(null, /*! storefront/sfra/login */ "./cartridges/app_tfg/cartridge/client/default/js/sfra/login.js")); break; case 'orderHistory': __webpack_require__.e(/*! import() | js/orderHistory */ "js/orderHistory").then(__webpack_require__.bind(null, /*! storefront/sfra/orderHistory */ "./cartridges/app_tfg/cartridge/client/default/js/sfra/orderHistory.js")); break; case 'paymentInstruments': __webpack_require__.e(/*! import() | js/paymentInstruments */ "js/paymentInstruments").then(__webpack_require__.bind(null, /*! storefront/sfra/paymentInstruments */ "./cartridges/app_tfg/cartridge/client/default/js/sfra/paymentInstruments.js")); break; case 'productDetail': Promise.all(/*! import() | js/productDetail */[__webpack_require__.e("js/productDetail~js/productTile~js/search"), __webpack_require__.e("js/productDetail")]).then(__webpack_require__.bind(null, /*! storefront/sfra/productDetail */ "./cartridges/app_tfg/cartridge/client/default/js/sfra/productDetail.js")); break; case 'productTile': Promise.all(/*! import() | js/productTile */[__webpack_require__.e("js/productDetail~js/productTile~js/search"), __webpack_require__.e("js/productTile")]).then(__webpack_require__.bind(null, /*! storefront/sfra/productTile */ "./cartridges/app_tfg/cartridge/client/default/js/sfra/productTile.js")); break; case 'profile': __webpack_require__.e(/*! import() | js/profile */ "js/profile").then(__webpack_require__.bind(null, /*! storefront/sfra/profile */ "./cartridges/app_tfg/cartridge/client/default/js/sfra/profile.js")); break; case 'search': Promise.all(/*! import() | js/search */[__webpack_require__.e("js/productDetail~js/productTile~js/search"), __webpack_require__.e("js/search")]).then(__webpack_require__.bind(null, /*! storefront/sfra/search */ "./cartridges/app_tfg/cartridge/client/default/js/sfra/search.js")); break; case 'storeLocator': __webpack_require__.e(/*! import() | js/storeLocator */ "js/storeLocator").then(__webpack_require__.bind(null, /*! storefront/sfra/storeLocator */ "./cartridges/app_tfg/cartridge/client/default/js/sfra/storeLocator.js")); break; default: if (true) { console.error(`Unknown chunk "${file}".`); // eslint-disable-line no-console } } }); } }); // eslint-disable-line eol-last // CONCATENATED MODULE: ./cartridges/app_bee_base/cartridge/client/default/js/initApp.js /** * Initializes the application. * * Sets the publicPath for Webpack and provides the loadChunks function to load the needed client side scripts. */ const basePath = internal_appConfig.basePath; // set public path if needed. If webpack-dev-server is running this has a value assigned. if (!__webpack_require__.p && basePath) { // eslint-disable-line camelcase __webpack_require__.p = basePath; // eslint-disable-line camelcase } /** * Loads the needed scripts provided via the additionalScripts config. */ function loadChunks() { // eslint-disable-line import/prefer-default-export const additionalScripts = internal_appConfig.additionalScripts; if (additionalScripts) { loadChunks_val(additionalScripts); } } // CONCATENATED MODULE: ./cartridges/app_tfg/cartridge/client/default/js/initApp.js /** * Loads the needed scripts provided via the projectScripts config. */ function loadProjectChunks() { // eslint-disable-line import/prefer-default-export const projectScripts = internal_appConfig.projectScripts; if (projectScripts) { loadProjectChunks_val(projectScripts); } } // EXTERNAL MODULE: ./node_modules/jquery/dist/jquery.js var jquery = __webpack_require__("./node_modules/jquery/dist/jquery.js"); var jquery_default = /*#__PURE__*/__webpack_require__.n(jquery); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/util.js + 1 modules var util = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/util.js"); // CONCATENATED MODULE: ./cartridges/int_cloudinary_tfg/cartridge/client/default/js/components/cloudinaryWidgets.js /* eslint-disable no-undef */ /* eslint-disable prefer-template */ /* eslint-disable prefer-arrow-callback */ /* eslint-disable jquery/no-data */ /* eslint-disable jquery/no-each */ /** * This is the main entry point for the brand. */ window.renderCloudinaryGalleryWidget = function () { let imgUrls; let galleryOptions; const $cldEl = jquery_default()('.cloudinary-data-container'); const cloudinaryObj = $cldEl.data('cloudinary'); if (cloudinaryObj) { if (cloudinaryObj.galleryEnabled && typeof cloudinary !== 'undefined') { galleryOptions = cloudinaryObj.images.galleryWidget.options; window.cldGallery = cloudinary.galleryWidget(galleryOptions); // eslint-disable-line no-undef cldGallery.render(); // eslint-disable-line no-undef } else if (cloudinaryObj.images && cloudinaryObj.images.imageURLs) { imgUrls = cloudinaryObj.images.imageURLs || ''; } } // removing custom code below as feature was introduced to the Gallery base code in the last v1.1.34 // $(document).on('click', '#cld-gallery', function (event) { // setTimeout(() => { // let tryAgain = false; // Retry checking is the zoom-in rendered // // Avoiding the mutationObserver due to the DOM complexity // // eslint-disable-next-line no-restricted-syntax // for (const el of document.getElementsByClassName(event.target.className)) { // if (el.style && el.style.cursor === 'zoom-in') { // el.dispatchEvent(new PointerEvent('pointerdown')); // el.dispatchEvent(new PointerEvent('pointerup')); // return; // } // if (el.style && el.style.cursor === 'zoom-out') { // tryAgain = true; // } // } // for // if (tryAgain) { // event.target.click(); // } // }, 50); // setTimeout // }); return imgUrls; }; window.renderCloudinarySetGalleryWidgets = function () { let cldObj; let cldSetImages; jquery_default()('.cloudinary-set-data-container').each(function () { cldObj = jquery_default()(this).data('cloudinary'); cldSetImages = jquery_default()(this).data('cloudinary-set-images'); if (cldObj && cldObj.isEnabled && cldSetImages && cldSetImages.galleryWidget && cldObj.galleryEnabled && typeof cloudinary !== 'undefined') { window.cldGallery = cloudinary.galleryWidget(cldSetImages.galleryWidget.options); // eslint-disable-line no-undef cldGallery.render(); // eslint-disable-line no-undef } }); }; window.renderCloudinaryVideoPlayer = function () { let videoPlayerID; let cldObj; let cld; let player; const cldURLs = []; jquery_default()('.cloudinary-data-container').each(function () { cldObj = jquery_default()(this).data('cloudinary'); videoPlayerID = jquery_default()(this).data('cloudinary-video-player-id'); if (cldObj && cldObj.video && cldObj.video.videoURL && cldObj.video.videoURL !== '' && cldObj.video.videoURL !== 'null') { if (cldObj.videoPlayerEnabled && typeof cloudinary !== 'undefined') { cld = cloudinary.Cloudinary.new({ cloud_name: cldObj.cloudName }); // eslint-disable-line no-undef player = cld.videoPlayer('cld-video-player' + (videoPlayerID ? '-' + videoPlayerID : ''), cldObj.video.widgetOptions); player.source(cldObj.video.videoURL, {}).play(); player.transformation(cldObj.video.widgetOptions.transformations); } else { cldURLs.push(cldObj.video.videoURL); } } }); return cldURLs; }; window.makeCloudinaryImagesResponsive = function () { const $cldResponsiveImgTags = jquery_default()('.cld-responsive'); if (typeof cloudinary !== 'undefined') { if ($cldResponsiveImgTags && $cldResponsiveImgTags.length > 0) { window.cldObj = window.cldObj || cloudinary.Cloudinary.new(); // eslint-disable-line no-undef window.cldObj.responsive(); // eslint-disable-line no-undef } } }; /* harmony default export */ var cloudinaryWidgets = (() => { jquery_default()(document).ready(function () { window.renderCloudinaryGalleryWidget(); window.renderCloudinaryVideoPlayer(); window.renderCloudinarySetGalleryWidgets(); window.makeCloudinaryImagesResponsive(); }); jquery_default()(document).on('product:afterAttributeSelect', function () { window.makeCloudinaryImagesResponsive(); }); jquery_default()(document).on('click', '.product-tile__swatch', function () { // eslint-disable-next-line jquery/no-closest const tile = jquery_default()(this).closest('.product-tile'); // eslint-disable-next-line jquery/no-find const img = jquery_default()(tile).find('.tile-image'); // eslint-disable-next-line jquery/no-attr jquery_default()(img).attr('src', jquery_default()(this).data('image')); jquery_default()(img).attr('srcset', jquery_default()(this).data('srcset')); jquery_default()(img).attr('sizes', jquery_default()(this).data('sizes')); window.makeCloudinaryImagesResponsive(); }); }); // EXTERNAL MODULE: ./cartridges/int_cloudinary_sfra/cartridge/client/default/js/main.js var main = __webpack_require__("./cartridges/int_cloudinary_sfra/cartridge/client/default/js/main.js"); // CONCATENATED MODULE: ./cartridges/int_cloudinary_tfg/cartridge/client/default/js/main.js // eslint-disable-next-line no-undef jquery_default()(document).ready(() => { Object(util["default"])(cloudinaryWidgets); }); // CONCATENATED MODULE: ./cartridges/app_tfg/cartridge/client/default/js/sfra/main.js // EXTERNAL MODULE: ./cartridges/app_hobbs/cartridge/client/default/scss/style.scss var style = __webpack_require__("./cartridges/app_hobbs/cartridge/client/default/scss/style.scss"); var style_default = /*#__PURE__*/__webpack_require__.n(style); // CONCATENATED MODULE: ./cartridges/app_tfg/cartridge/client/default/js/mainStyle.js /** * Load the main stylesheet. * * Stylesheet will be built and extracted to CSS using Webpack. */ // import style from '../less/style.less'; /* harmony default export */ var mainStyle = (style_default.a); // CONCATENATED MODULE: ./cartridges/app_tfg/cartridge/client/default/js/index.js /** * This is the main entry point for the application. */ // eslint-disable-next-line import/named // Initialize the application // call the main module /* * Load the main stylesheet. * * Stylesheet will be built and extracted to CSS using Webpack. */ loadChunks(); // load additional needed chunks loadProjectChunks(); // load additional needed chunks filterCookieValue(); function contentEventInitData() { const element = document.querySelectorAll('.content-block-event'); element.forEach(ele => { if (ele.getAttribute('data-listener') !== 'true') { ele.setAttribute('data-listener', 'true'); ele.addEventListener('click', () => { const indx = Array.from(document.getElementsByClassName('content-block-event')).indexOf(ele); const contentSlotId = `home-content-${indx + 1}`; const clickEventData = { event: 'contentBlockClick', contentBlockId: contentSlotId }; window.dataLayer.push(clickEventData); }); } }); } function filterCookieValue() { const decodedCookie = decodeURIComponent(document.cookie); const cookieArray = decodedCookie.split(';'); for (let i = 0; i < cookieArray.length; i++) { let cookieItem = cookieArray[i]; while (cookieItem.charAt(0) === ' ') { cookieItem = cookieItem.substring(1); } const cookiePair = cookieItem.split('='); // filter the cookie value to remove script tags if (cookiePair[1].indexOf('script') > -1) { const filteredValue = cookiePair[1].replace(/)<[^<]*)*<\/script\s*>/gi, ''); // eslint-disable-next-line prefer-template document.cookie = cookiePair[0] + '=' + filteredValue + '; path=/'; } } } document.addEventListener('DOMContentLoaded', contentEventInitData); document.addEventListener('product:carousel-init', contentEventInitData); // CONCATENATED MODULE: ./cartridges/app_hobbs/cartridge/client/default/js/index.js /** * This is the main entry point for the brand. */ // call the main module /***/ }), /***/ "./cartridges/app_hobbs/cartridge/client/default/scss/style.scss": /*!***********************************************************************!*\ !*** ./cartridges/app_hobbs/cartridge/client/default/scss/style.scss ***! \***********************************************************************/ /*! no static exports found */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { // extracted by extract-css-chunks-webpack-plugin module.exports = {"breakpoint-sm-max":"767px","breakpoint-md-min":"768px","breakpoint-md-max":"991px","breakpoint-lg-min":"992px","breakpoint-lg-max":"1199px","breakpoint-xl-min":"1200px"}; /***/ }), /***/ "./cartridges/app_storefront_base/cartridge/client/default/js/checkout/formErrors.js": /*!*******************************************************************************************!*\ !*** ./cartridges/app_storefront_base/cartridge/client/default/js/checkout/formErrors.js ***! \*******************************************************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module uses injected variables ($) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* WEBPACK VAR INJECTION */(function($) { /** * Display error messages and highlight form fields with errors. * @param {string} parentSelector - the form which contains the fields * @param {Object} fieldErrors - the fields with errors */ function loadFormErrors(parentSelector, fieldErrors) { // eslint-disable-line // Display error messages and highlight form fields with errors. $.each(fieldErrors, function (attr) { $('*[name=' + attr + ']', parentSelector).addClass('is-invalid').siblings('.invalid-feedback').html(fieldErrors[attr]); }); } /** * Clear the form errors. * @param {string} parentSelector - the parent form selector. */ function clearPreviousErrors(parentSelector) { $(parentSelector).find('.form-control.is-invalid').removeClass('is-invalid'); $('.error-message').hide(); } /* harmony default export */ __webpack_exports__["default"] = ({ loadFormErrors: loadFormErrors, clearPreviousErrors: clearPreviousErrors }); /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"))) /***/ }), /***/ "./cartridges/app_storefront_base/cartridge/client/default/js/components/clientSideValidation.js": /*!*******************************************************************************************************!*\ !*** ./cartridges/app_storefront_base/cartridge/client/default/js/components/clientSideValidation.js ***! \*******************************************************************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module uses injected variables ($) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* WEBPACK VAR INJECTION */(function($) { /** * Validate whole form. Requires `this` to be set to form object * @param {jQuery.event} event - Event to be canceled if form is invalid. * @returns {boolean} - Flag to indicate if form is valid */ function _validateForm(event) { var valid = true; if (this.checkValidity && !this.checkValidity()) { // safari valid = false; if (event) { event.preventDefault(); event.stopPropagation(); event.stopImmediatePropagation(); } $(this).find('input, select, textarea').each(function () { if (!this.validity.valid) { $(this).trigger('invalid', this.validity); } }); } return valid; } /** * Remove all validation. Should be called every time before revalidating form * @param {element} form - Form to be cleared * @returns {void} */ function clearForm(form) { $(form).find('.form-control.is-invalid').removeClass('is-invalid'); } /* harmony default export */ __webpack_exports__["default"] = ({ invalid: function invalid() { $('form input, form select, form textarea').on('invalid', function (e) { e.preventDefault(); this.setCustomValidity(''); if (!this.validity.valid) { var validationMessage = this.validationMessage; $(this).addClass('is-invalid'); if (this.validity.patternMismatch && $(this).data('pattern-mismatch')) { validationMessage = $(this).data('pattern-mismatch'); } if ((this.validity.rangeOverflow || this.validity.rangeUnderflow) && $(this).data('range-error')) { validationMessage = $(this).data('range-error'); } if ((this.validity.tooLong || this.validity.tooShort) && $(this).data('range-error')) { validationMessage = $(this).data('range-error'); } if (this.validity.valueMissing && $(this).data('missing-error')) { validationMessage = $(this).data('missing-error'); } $(this).parents('.form-group').find('.invalid-feedback').text(validationMessage); } }); }, submit: function submit() { $('form').on('submit', function (e) { return _validateForm.call(this, e); }); }, buttonClick: function buttonClick() { $('form button[type="submit"], form input[type="submit"]').on('click', function () { // clear all errors when trying to submit the form clearForm($(this).parents('form')); }); }, functions: { validateForm: function validateForm(form, event) { _validateForm.call($(form), event || null); }, clearForm: clearForm } }); /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"))) /***/ }), /***/ "./cartridges/app_storefront_base/cartridge/client/default/js/components/collapsibleItem.js": /*!**************************************************************************************************!*\ !*** ./cartridges/app_storefront_base/cartridge/client/default/js/components/collapsibleItem.js ***! \**************************************************************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module uses injected variables ($) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* WEBPACK VAR INJECTION */(function($) { /* harmony default export */ __webpack_exports__["default"] = (function () { var sizes = ['xs', 'sm', 'md', 'lg', 'xl']; sizes.forEach(function (size) { var selector = '.collapsible-' + size + ' .title, .collapsible-' + size + '>.card-header'; $('body').on('click', selector, function (e) { e.preventDefault(); $(this).parents('.collapsible-' + size).toggleClass('active'); }); }); }); /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"))) /***/ }), /***/ "./cartridges/app_storefront_base/cartridge/client/default/js/components/countrySelector.js": /*!**************************************************************************************************!*\ !*** ./cartridges/app_storefront_base/cartridge/client/default/js/components/countrySelector.js ***! \**************************************************************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module uses injected variables ($) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* WEBPACK VAR INJECTION */(function($) {/* harmony import */ var _keyboardAccessibility__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardAccessibility */ "./cartridges/app_storefront_base/cartridge/client/default/js/components/keyboardAccessibility.js"); var keyboardAccessibility = _keyboardAccessibility__WEBPACK_IMPORTED_MODULE_0__["default"]; /* harmony default export */ __webpack_exports__["default"] = (function () { $('.country-selector a').click(function (e) { e.preventDefault(); var action = $('.page').data('action'); var localeCode = $(this).data('locale'); var localeCurrencyCode = $(this).data('currencycode'); var queryString = $('.page').data('querystring'); var url = $('.country-selector').data('url'); $.ajax({ url: url, type: 'get', dataType: 'json', data: { code: localeCode, queryString: queryString, CurrencyCode: localeCurrencyCode, action: action }, success: function success(response) { $.spinner().stop(); if (response && response.redirectUrl) { window.location.href = response.redirectUrl; } }, error: function error() { $.spinner().stop(); } }); }); keyboardAccessibility('.navbar-header .country-selector', { 40: function _($countryOptions) { // down if ($(this).is(':focus')) { $countryOptions.first().focus(); } else { $(':focus').next().focus(); } }, 38: function _($countryOptions) { // up if ($countryOptions.first().is(':focus') || $(this).is(':focus')) { $(this).focus(); $(this).removeClass('show'); } else { $(':focus').prev().focus(); } }, 27: function _() { // escape $(this).focus(); $(this).removeClass('show').children('.dropdown-menu').removeClass('show'); }, 9: function _() { // tab $(this).removeClass('show').children('.dropdown-menu').removeClass('show'); } }, function () { if (!$(this).hasClass('show')) { $(this).addClass('show'); } return $(this).find('.dropdown-country-selector').children('a'); }); $('.navbar-header .country-selector').on('focusin', function () { $(this).addClass('show').children('.dropdown-menu').addClass('show'); }); }); /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"))) /***/ }), /***/ "./cartridges/app_storefront_base/cartridge/client/default/js/components/footer.js": /*!*****************************************************************************************!*\ !*** ./cartridges/app_storefront_base/cartridge/client/default/js/components/footer.js ***! \*****************************************************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module uses injected variables ($) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* WEBPACK VAR INJECTION */(function($) { /* harmony default export */ __webpack_exports__["default"] = (function () { $('.back-to-top').click(function () { $('html, body').animate({ scrollTop: 0 }, 500); }); }); /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"))) /***/ }), /***/ "./cartridges/app_storefront_base/cartridge/client/default/js/components/keyboardAccessibility.js": /*!********************************************************************************************************!*\ !*** ./cartridges/app_storefront_base/cartridge/client/default/js/components/keyboardAccessibility.js ***! \********************************************************************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module uses injected variables ($) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* WEBPACK VAR INJECTION */(function($) { /* harmony default export */ __webpack_exports__["default"] = (function (selector, keyFunctions, preFunction) { $(selector).on('keydown', function (e) { var key = e.which; var supportedKeyCodes = [37, 38, 39, 40, 27]; if (supportedKeyCodes.indexOf(key) >= 0) { e.preventDefault(); } var returnedScope = preFunction.call(this); if (keyFunctions[key]) { keyFunctions[key].call(this, returnedScope); } }); }); /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"))) /***/ }), /***/ "./cartridges/app_storefront_base/cartridge/client/default/js/components/search.js": /*!*****************************************************************************************!*\ !*** ./cartridges/app_storefront_base/cartridge/client/default/js/components/search.js ***! \*****************************************************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module uses injected variables ($) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* WEBPACK VAR INJECTION */(function($) {/* harmony import */ var lodash_debounce__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash/debounce */ "./node_modules/lodash/debounce.js"); /* harmony import */ var lodash_debounce__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_debounce__WEBPACK_IMPORTED_MODULE_0__); var debounce = lodash_debounce__WEBPACK_IMPORTED_MODULE_0___default.a; var endpoint = $('.suggestions-wrapper').data('url'); var minChars = 3; /** * Retrieves Suggestions element relative to scope * * @param {Object} scope - Search input field DOM element * @return {JQuery} - .suggestions-wrapper element */ function getSuggestionsWrapper(scope) { return $(scope).siblings('.suggestions-wrapper'); } /** * Determines whether DOM element is inside the .search-mobile class * * @param {Object} scope - DOM element, usually the input.search-field element * @return {boolean} - Whether DOM element is inside div.search-mobile */ function isMobileSearch(scope) { return !!$(scope).closest('.search-mobile').length; } /** * Remove modal classes needed for mobile suggestions * */ function clearModals() { $('body').removeClass('modal-open'); $('.suggestions').removeClass('modal'); } /** * Apply modal classes needed for mobile suggestions * * @param {Object} scope - Search input field DOM element */ function applyModals(scope) { if (isMobileSearch(scope)) { $('body').addClass('modal-open'); getSuggestionsWrapper(scope).find('.suggestions').addClass('modal'); } } /** * Tear down Suggestions panel */ function tearDownSuggestions() { $('input.search-field').val(''); clearModals(); $('.search-mobile .suggestions').unbind('scroll'); $('.suggestions-wrapper').empty(); } /** * Toggle search field icon from search to close and vice-versa * * @param {string} action - Action to toggle to */ function toggleSuggestionsIcon(action) { var mobileSearchIcon = '.search-mobile span.'; var iconSearch = 'fa-search'; var iconSearchClose = 'fa-close'; if (action === 'close') { $(mobileSearchIcon + iconSearch).removeClass(iconSearch).addClass(iconSearchClose); } else { $(mobileSearchIcon + iconSearchClose).removeClass(iconSearchClose).addClass(iconSearch); } } /** * Determines whether the "More Content Below" icon should be displayed * * @param {Object} scope - DOM element, usually the input.search-field element */ function handleMoreContentBelowIcon(scope) { if ($(scope).scrollTop() + $(scope).innerHeight() >= $(scope)[0].scrollHeight) { $('.more-below').fadeOut(); } else { $('.more-below').fadeIn(); } } /** * Positions Suggestions panel on page * * @param {Object} scope - DOM element, usually the input.search-field element */ function positionSuggestions(scope) { var outerHeight; var $scope; var $suggestions; var top; if (isMobileSearch(scope)) { $scope = $(scope); top = $scope.offset().top; outerHeight = $scope.outerHeight(); $suggestions = getSuggestionsWrapper(scope).find('.suggestions'); $suggestions.css('top', top + outerHeight); handleMoreContentBelowIcon(scope); // Unfortunately, we have to bind this dynamically, as the live scroll event was not // properly detecting dynamic suggestions element's scroll event $suggestions.scroll(function () { handleMoreContentBelowIcon(this); }); } } /** * Process Ajax response for SearchServices-GetSuggestions * * @param {Object|string} response - Empty object literal if null response or string with rendered * suggestions template contents */ function processResponse(response) { var $suggestionsWrapper = getSuggestionsWrapper(this).empty(); $.spinner().stop(); if (!(typeof response === 'object')) { $suggestionsWrapper.append(response).show(); positionSuggestions(this); if (isMobileSearch(this)) { toggleSuggestionsIcon('close'); applyModals(this); } } else { $suggestionsWrapper.hide(); } } /** * Retrieve suggestions * * @param {Object} scope - Search field DOM element */ function getSuggestions(scope) { if ($(scope).val().length >= minChars) { $.spinner().start(); $.ajax({ context: scope, url: endpoint + encodeURIComponent($(scope).val()), method: 'GET', success: processResponse, error: function error() { $.spinner().stop(); } }); } else { toggleSuggestionsIcon('search'); clearModals(); getSuggestionsWrapper(scope).empty(); } } /* harmony default export */ __webpack_exports__["default"] = (function () { $('input.search-field').each(function () { /** * Use debounce to avoid making an Ajax call on every single key press by waiting a few * hundred milliseconds before making the request. Without debounce, the user sees the * browser blink with every key press. */ var debounceSuggestions = debounce(getSuggestions, 300); $(this).on('keyup click', function (e) { debounceSuggestions(this, e); }); }); $('body').on('click', function (e) { if (!$('.suggestions').has(e.target).length && !$(e.target).hasClass('search-field')) { $('.suggestions').hide(); } }); $('body').on('click touchend', '.search-mobile span.fa-close', function () { $('.suggestions').hide(); toggleSuggestionsIcon('search'); tearDownSuggestions(); }); }); /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"))) /***/ }), /***/ "./cartridges/app_storefront_base/cartridge/client/default/js/components/spinner.js": /*!******************************************************************************************!*\ !*** ./cartridges/app_storefront_base/cartridge/client/default/js/components/spinner.js ***! \******************************************************************************************/ /*! no static exports found */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function($) { /** * Show a spinner inside a given element * @param {element} $target - Element to block by the veil and spinner. * Pass body to block the whole page. */ function addSpinner($target) { var $veil = $('
'); $veil.append('
'); if ($target.get(0).tagName === 'IMG') { $target.after($veil); $veil.css({ width: $target.width(), height: $target.height() }); if ($target.parent().css('position') === 'static') { $target.parent().css('position', 'relative'); } } else { $target.append($veil); if ($target.css('position') === 'static') { $target.parent().css('position', 'relative'); $target.parent().addClass('veiled'); } if ($target.get(0).tagName === 'BODY') { $veil.find('.spinner').css('position', 'fixed'); } } $veil.click(function (e) { e.stopPropagation(); }); } /** * Remove existing spinner * @param {element} $veil - jQuery pointer to the veil element */ function removeSpinner($veil) { if ($veil.parent().hasClass('veiled')) { $veil.parent().css('position', ''); $veil.parent().removeClass('veiled'); } $veil.off('click'); $veil.remove(); } // element level spinner: $.fn.spinner = function () { var $element = $(this); var Fn = function Fn() { this.start = function () { if ($element.length) { addSpinner($element); } }; this.stop = function () { if ($element.length) { var $veil = $('.veil'); removeSpinner($veil); } }; }; return new Fn(); }; // page-level spinner: $.spinner = function () { var Fn = function Fn() { this.start = function () { addSpinner($('body')); }; this.stop = function () { removeSpinner($('.veil')); }; }; return new Fn(); }; /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"))) /***/ }), /***/ "./cartridges/app_storefront_base/cartridge/client/default/js/main.js": /*!****************************************************************************!*\ !*** ./cartridges/app_storefront_base/cartridge/client/default/js/main.js ***! \****************************************************************************/ /*! no exports provided */ /*! ModuleConcatenation bailout: Module uses injected variables ($) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* WEBPACK VAR INJECTION */(function($) {/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util */ "./cartridges/app_tfg/cartridge/client/default/js/util.js"); // window.jQuery = window.$ = require('jquery'); var processInclude = _util__WEBPACK_IMPORTED_MODULE_0__["default"]; $(document).ready(function () { processInclude(__webpack_require__(/*! ./components/menu */ "./cartridges/app_tfg/cartridge/client/default/js/components/menu.js")); processInclude(__webpack_require__(/*! ./components/cookie */ "./cartridges/app_tfg/cartridge/client/default/js/components/cookie.js")); processInclude(__webpack_require__(/*! ./components/consentTracking */ "./cartridges/app_tfg/cartridge/client/default/js/components/consentTracking.js")); processInclude(__webpack_require__(/*! ./components/footer */ "./cartridges/app_storefront_base/cartridge/client/default/js/components/footer.js")); processInclude(__webpack_require__(/*! ./components/miniCart */ "./cartridges/app_tfg/cartridge/client/default/js/components/miniCart.js")); processInclude(__webpack_require__(/*! ./components/collapsibleItem */ "./cartridges/app_storefront_base/cartridge/client/default/js/components/collapsibleItem.js")); processInclude(__webpack_require__(/*! ./components/search */ "./cartridges/int_cloudinary_sfra/cartridge/client/default/js/components/search.js")); processInclude(__webpack_require__(/*! ./components/clientSideValidation */ "./cartridges/int_gtm/cartridge/client/default/js/components/clientSideValidation.js")); processInclude(__webpack_require__(/*! ./components/countrySelector */ "./cartridges/app_storefront_base/cartridge/client/default/js/components/countrySelector.js")); }); __webpack_require__(/*! ./thirdParty/bootstrap */ "./cartridges/app_storefront_base/cartridge/client/default/js/thirdParty/bootstrap.js"); __webpack_require__(/*! ./components/spinner */ "./cartridges/app_tfg/cartridge/client/default/js/components/spinner.js"); /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"))) /***/ }), /***/ "./cartridges/app_storefront_base/cartridge/client/default/js/thirdParty/bootstrap.js": /*!********************************************************************************************!*\ !*** ./cartridges/app_storefront_base/cartridge/client/default/js/thirdParty/bootstrap.js ***! \********************************************************************************************/ /*! no static exports found */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { __webpack_require__(/*! bootstrap/js/src/util.js */ "./node_modules/bootstrap/js/src/util.js"); __webpack_require__(/*! bootstrap/js/src/alert.js */ "./node_modules/bootstrap/js/src/alert.js"); // require('bootstrap/js/src/button.js'); __webpack_require__(/*! bootstrap/js/src/carousel.js */ "./node_modules/bootstrap/js/src/carousel.js"); __webpack_require__(/*! bootstrap/js/src/collapse.js */ "./node_modules/bootstrap/js/src/collapse.js"); // require('bootstrap/js/src/dropdown.js'); __webpack_require__(/*! bootstrap/js/src/modal.js */ "./node_modules/bootstrap/js/src/modal.js"); __webpack_require__(/*! bootstrap/js/src/scrollspy.js */ "./node_modules/bootstrap/js/src/scrollspy.js"); __webpack_require__(/*! bootstrap/js/src/tab.js */ "./node_modules/bootstrap/js/src/tab.js"); // require('bootstrap/js/src/tooltip.js'); // require('bootstrap/js/src/popover.js'); /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/checkout/checkoutDom.js": /*!********************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/checkout/checkoutDom.js ***! \********************************************************************************/ /*! exports provided: SELECTORS, EVENTS, clientSideValidationUpdate, reinitClientSideValidation, isRedirectResponse, updateView, attachCustomValidationEvents */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SELECTORS", function() { return SELECTORS; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EVENTS", function() { return EVENTS; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clientSideValidationUpdate", function() { return clientSideValidationUpdate; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reinitClientSideValidation", function() { return reinitClientSideValidation; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isRedirectResponse", function() { return isRedirectResponse; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateView", function() { return updateView; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "attachCustomValidationEvents", function() { return attachCustomValidationEvents; }); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util */ "./cartridges/app_tfg/cartridge/client/default/js/util.js"); /* harmony import */ var _util_scrollTo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/scrollTo */ "./cartridges/app_tfg/cartridge/client/default/js/util/scrollTo.js"); /* harmony import */ var _util_domutils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/domutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); /* harmony import */ var _components_clientSideValidation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../components/clientSideValidation */ "./cartridges/int_gtm/cartridge/client/default/js/components/clientSideValidation.js"); /* harmony import */ var _formErrors__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./formErrors */ "./cartridges/app_tfg/cartridge/client/default/js/checkout/formErrors.js"); const SELECTORS = { HEADER: '.checkout-header', CONTENT: '.checkout', STEP_FORM: '.checkout-step__form', PROGRESS_STEP: '.checkout__progress-step-number', SHIPPING_FORM: '.checkout-shipping__form', BILLING_FORM: '.checkout-billing__form', SUMMARY_FORM: '.checkout-summary__form', STEP_CONTENT: '.page', SHIPPING_TYPE: { TYPE: '.checkout-shipping__type', CURRENT_TYPE: '.checkout-shipping__type.active' }, SAVED_ADDRESS: { SHIPMENT_SELECTOR: '.saved-addresses', SAVED_ADDRESS_CONTAINER: '.saved-addresses__pane', SAVED_ADDRESS_INPUT: '.saved-addresses__address-input' }, SHIPPING_ADDRESS: { FIELDS: '.checkout-shipping__address', NEW_FIELDS: '.saved-addresses__new-fields', SAVE_TOGGLE: '.checkout-shipping__shipment__save-address', get LINE1() { return `${this.FIELDS} #addressOne`; }, get STATE() { return `${this.FIELDS} #stateCode`; }, get CITY() { return `${this.FIELDS} #city`; }, get POSTAL_CODE() { return `${this.FIELDS} #postalCode`; } }, SHIPPING_METHODS: { CONTAINER: '.checkout-shipping__method-list', METHOD: '.checkout-shipping__method', METHOD_INPUT: '.checkout-shipping__method-input' }, GIFT: { CONTAINER: '.checkout-shipping__gift', INPUT: '.checkout-shipping__gift-input', MESSAGE_INPUT: '.checkout-shipping__gift-message', MESSAGE_TEXT_AREA: '#giftMessage', SYMBOLS_LEFT: '.checkout-shipping__symbols-left-count', GIFT_PACKAGING_CHECKBOX: '.checkout-shipping__gift-content' }, BILLING_ADDRESS: { CARD: '.checkout-billing__address-card', SAME_AS_SHIPPING: '.checkout-billing__copy-shipping-input' }, PAYMENT_METHODS: { GIFT_CARD_FORM: '.checkout-billing__gift-card-form', CREDIT_CARD_FORM: '.checkout-billing__credit-card-form', INPUT: '.checkout-billing__payment-input', CONTENT: '.checkout-billing__payment-content', CREDIT_CARD: { DATE: '#expirationDate', MONTH: '#expirationMonth', YEAR: '#expirationYear', NEW_CVV: '.checkout-billing__cvv--new', SAVED_CVV: '.checkout-billing__cvv--saved', CVV_TOOLTIP: '.checkout-billing__cvv__tooltip-wrapper', NEW_LABEL: '.checkout-billing__payment-selector--CREDIT_CARD', SAVED_LABEL: '.checkout-billing__payment-selector--SAVED_CREDIT_CARD', SAVED_FORM: '.checkout-billing__payment-form--SAVED_CREDIT_CARD', SAVED_DROPDOWN_CONTAINER: '.saved-cards__container', SAVED_DROPDOWN: '#savedCards', NUMBER_GROUP: '.checkout-billing__credit-card-number', DATE_GROUP: '.checkout-billing__credit-card-expiry', NEW_OPTION: '.checkout-billing__payment--CREDIT_CARD' }, APPLE_PAY: { OPTION: '.checkout-billing__payment--DW_APPLE_PAY' } }, SUBMIT: '.checkout-billing__submit-btn', ERRORS: { CONTAINER: '.checkout-step__errors', CONTENT: '.error-summary' }, SUMMARY: '.summary' }; const EVENTS = { SAVED_ADDRESS: { ADDRESS_SELECTED: 'savedAddress:selected' }, BILLING: { USE_SHIPPING_AS_BILLING_TOGGLED: 'useShippingAsBilling:toggle' }, ADYENCONTENT: 'adyen3dsModalContent', UPDATEVIEW: 'checkout:updatedview', TRIGGER_SHIPPING_VALIDATION: 'checkout:shippingValidate' }; const showComponent = selector => { const component = document.querySelector(selector); if (component) { component.classList.remove('d-none'); Object(_util_scrollTo__WEBPACK_IMPORTED_MODULE_2__["default"])(component); } }; const hideComponent = selector => { const component = document.querySelector(selector); if (component) { component.classList.add('d-none'); } }; const appendEmptyStage = (selector, content) => { const component = document.querySelector(selector); if (component) { if (content && content.length) { const container = document.createElement('div'); container.innerHTML = content; component.appendChild(container); } } }; const handleCreditCardExpiryErrors = fieldErrors => { const modifiedErrors = Object.assign(fieldErrors); const dateField = document.querySelector(SELECTORS.PAYMENT_METHODS.CREDIT_CARD.DATE); const monthField = document.querySelector(SELECTORS.PAYMENT_METHODS.CREDIT_CARD.MONTH); const yearField = document.querySelector(SELECTORS.PAYMENT_METHODS.CREDIT_CARD.YEAR); if (dateField && monthField && yearField) { const expiryErrors = Object.keys(modifiedErrors).filter(name => name === monthField.name || name === yearField.name).map(name => modifiedErrors[name]); if (expiryErrors.length) { modifiedErrors[dateField.name] = expiryErrors.join(' '); } } return modifiedErrors; }; const processFieldErrors = fieldErrors => handleCreditCardExpiryErrors(fieldErrors); const redirectTo = redirectUrl => { const stepForm = document.querySelector(SELECTORS.STEP_FORM); if (stepForm) { jquery__WEBPACK_IMPORTED_MODULE_0___default()(stepForm).spinner().start(); } // Executing the redirect in the main thread can cause IE to hang when leaving // the site, e.g. to get to a payer auth page setTimeout(() => { window.location = redirectUrl; }); }; const clientSideValidationUpdate = async () => { const shippingForm = document.querySelector(SELECTORS.SHIPPING_FORM); _components_clientSideValidation__WEBPACK_IMPORTED_MODULE_4__["default"].functions.clearForm(shippingForm, true); }; const reinitClientSideValidation = () => { Object(_util__WEBPACK_IMPORTED_MODULE_1__["default"])(_components_clientSideValidation__WEBPACK_IMPORTED_MODULE_4__["default"]); }; const isRedirectResponse = content => { if (content) { const errorUrl = content.error && content.redirectUrl; const paypalUrl = content.paypalProcessorResult && content.paypalProcessorResult.success && content.paypalBaseUrl; return content.continueUrl || paypalUrl || errorUrl; } return false; }; /** * Handles backend responses that contain rendered content for checkout components * * @param {Object} content Content returned by an AJAX request */ const updateView = async content => { if (content.continueUrl) { redirectTo(content.continueUrl); return; } if (content.paypalProcessorResult && content.paypalProcessorResult.success && content.paypalBaseUrl) { redirectTo(content.paypalBaseUrl + content.paypalProcessorResult.paypalToken); return; } if (content.error) { if (content.redirectUrl) { redirectTo(content.redirectUrl); return; } if (content.errorContent) { await Object(_util_domutils__WEBPACK_IMPORTED_MODULE_3__["updateComponent"])(SELECTORS.ERRORS.CONTENT, content.errorContent); showComponent(SELECTORS.ERRORS.CONTAINER); } if (content.fieldErrors) { if (content.fieldErrors.length) { content.fieldErrors.forEach(error => { if (Object.keys(error).length) { Object(_formErrors__WEBPACK_IMPORTED_MODULE_5__["loadFormErrors"])(document, processFieldErrors(error)); } }); } } } else { await Object(_util_domutils__WEBPACK_IMPORTED_MODULE_3__["updateComponent"])(SELECTORS.ERRORS.CONTENT, ''); hideComponent(SELECTORS.ERRORS.CONTAINER); } if (content.addressSelectorContent) { await Object(_util_domutils__WEBPACK_IMPORTED_MODULE_3__["updateComponent"])(SELECTORS.SAVED_ADDRESS.SHIPMENT_SELECTOR, content.addressSelectorContent); } if (content.shippingMethodsContent) { await Object(_util_domutils__WEBPACK_IMPORTED_MODULE_3__["updateComponent"])(SELECTORS.SHIPPING_METHODS.CONTAINER, content.shippingMethodsContent); reinitClientSideValidation(); // Required for HubBox } if (content.giftContent) { await Object(_util_domutils__WEBPACK_IMPORTED_MODULE_3__["updateComponent"])(SELECTORS.GIFT.CONTAINER, content.giftContent); } if (content.billingAddressContent) { await Object(_util_domutils__WEBPACK_IMPORTED_MODULE_3__["updateComponent"])(SELECTORS.BILLING_ADDRESS.CARD, content.billingAddressContent); reinitClientSideValidation(); } if (content.summaryContent) { await Object(_util_domutils__WEBPACK_IMPORTED_MODULE_3__["updateComponent"])(SELECTORS.SUMMARY, content.summaryContent); } if (content.giftCardFormContent) { await Object(_util_domutils__WEBPACK_IMPORTED_MODULE_3__["updateComponent"])(SELECTORS.PAYMENT_METHODS.GIFT_CARD_FORM, content.giftCardFormContent); } if (content.skipStepContent) { appendEmptyStage(SELECTORS.CONTENT, content.skipStepContent); } else if (content.stepContent) { await Object(_util_domutils__WEBPACK_IMPORTED_MODULE_3__["updateComponent"])(SELECTORS.CONTENT, content.stepContent); showComponent(SELECTORS.CONTENT); reinitClientSideValidation(); } if (content.adyenAction) { document.dispatchEvent(new CustomEvent(EVENTS.ADYENCONTENT, { detail: { adyenAction: content.adyenAction, orderToken: content.orderToken } })); } document.dispatchEvent(new CustomEvent(EVENTS.UPDATEVIEW, { detail: { stage: content.currentStage, action: content.action } })); }; const attachCustomValidationEvents = () => { document.addEventListener(EVENTS.TRIGGER_SHIPPING_VALIDATION, () => { _components_clientSideValidation__WEBPACK_IMPORTED_MODULE_4__["default"].functions.validateForm(SELECTORS.SHIPPING_FORM); }); }; /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/checkout/formErrors.js": /*!*******************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/checkout/formErrors.js ***! \*******************************************************************************/ /*! exports provided: loadFormErrors, clearPreviousErrors */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadFormErrors", function() { return loadFormErrors; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clearPreviousErrors", function() { return clearPreviousErrors; }); /* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~base */ "./cartridges/app_storefront_base/cartridge/client/default/js/checkout/formErrors.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _util_scrollTo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/scrollTo */ "./cartridges/app_tfg/cartridge/client/default/js/util/scrollTo.js"); /* harmony import */ var _util_domutils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/domutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); const SELECTORS = { COLLAPSE: '.collapse', TABS: '[data-toggle="tab"]' }; const baseLoadFormErrors = _base__WEBPACK_IMPORTED_MODULE_0__["default"].loadFormErrors; const loadFormErrors = (parentSelector, fieldErrors) => { baseLoadFormErrors.call(null, parentSelector, fieldErrors); const errorFields = Object(_util_domutils__WEBPACK_IMPORTED_MODULE_3__["find"])('.is-invalid:not([type="hidden"])', parentSelector); if (errorFields && errorFields.length > 0) { if (!Object(_util_domutils__WEBPACK_IMPORTED_MODULE_3__["visible"])(errorFields[0])) { const collapse = errorFields[0].closest(SELECTORS.COLLAPSE); if (collapse) { jquery__WEBPACK_IMPORTED_MODULE_1___default()(collapse).on('shown.bs.collapse', () => { Object(_util_scrollTo__WEBPACK_IMPORTED_MODULE_2__["default"])(errorFields[0]); errorFields[0].focus(); }); jquery__WEBPACK_IMPORTED_MODULE_1___default()(collapse).collapse('show'); } } else { Object(_util_scrollTo__WEBPACK_IMPORTED_MODULE_2__["default"])(errorFields[0]); errorFields[0].focus(); } } }; const clearPreviousErrors = _base__WEBPACK_IMPORTED_MODULE_0__["default"].clearPreviousErrors; /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/ajax.js": /*!***************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/ajax.js ***! \***************************************************************************/ /*! exports provided: installAjaxHandlers, functions */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "installAjaxHandlers", function() { return installAjaxHandlers; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "functions", function() { return functions; }); const CALLBACKS = []; const handleAjaxResponse = (url, responseContent) => { CALLBACKS.forEach(cb => { if (typeof cb === 'function') { cb(responseContent); } if (typeof cb === 'object' && typeof cb.func === 'function' && (!cb.urlFilter || url.indexOf(cb.urlFilter) >= 0)) { cb.func(responseContent); } }); }; /** * Extend the AJAX mechanisms that get used to allow for handling logic after they;ve been completed * (i.e. jQuery's ajaxComplete event, but using vanilla JS is sooo much better for reasons) */ const installAjaxHandlers = () => { const originals = { open: XMLHttpRequest.prototype.open, fetch: window.Response && window.Response.prototype && { blob: window.Response.prototype.blob, json: window.Response.prototype.json, text: window.Response.prototype.text } }; // Attach to all calls to the fetch response's handlers if (originals.fetch) { Object.keys(originals.fetch).forEach(originalName => { const original = originals.fetch[originalName]; if (original) { window.Response.prototype[originalName] = function () { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return original.apply(this, args).then(responseContent => { handleAjaxResponse(this.url, responseContent); return responseContent; }); }; } }); } // Attach to all calls using XMLHttpRequest (which would include jQuery calls in the base) if (originals.open) { XMLHttpRequest.prototype.open = function () { this.addEventListener('readystatechange', function () { if (this.readyState === XMLHttpRequest.DONE) { handleAjaxResponse(this.responseURL, this.responseText); } }, false); for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } originals.open.apply(this, args); }; } }; const functions = { // Attaches a callback which will be executed when an AJAX request completes. // Either a function or an object can be provided: // - Functions get called after each AJAX request completes // and receive response content as a parameter (be it text or a JSON object) // - Objects can contain a urlFilter and a func field; if the former is a string, // that is contained in an AJAX request's url, then the latter is treated as // a function and is used as a callback onComplete(cb) { if (CALLBACKS.indexOf(cb) < 0) { CALLBACKS.push(cb); } } }; /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/backToTop.js": /*!********************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/backToTop.js ***! \********************************************************************************/ /*! exports provided: addBackToTopHandler, default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addBackToTopHandler", function() { return addBackToTopHandler; }); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _util_debounce__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/debounce */ "./cartridges/app_bee_base/cartridge/client/default/js/util/debounce.js"); const CONSTANTS = { TRIGGER_OFFSET: 800, SCROLL_INTERVAL: 150 }; const SELECTORS = { BACK_TO_TOP: '.back-to-top' }; const EVENTS = { BACK_SHOW: 'backtotop:show', BACK_HIDE: 'backtotop:hide' }; const addBackToTopHandler = bttSelector => { const backToTopSelector = bttSelector || SELECTORS.BACK_TO_TOP; const backToTopLinks = document.querySelectorAll(backToTopSelector); if (backToTopLinks) { backToTopLinks.forEach(backToTopLink => { const holder = backToTopLink.dataset.containerSelector === undefined ? window : document.querySelector(backToTopLink.dataset.containerSelector); const scrollHandler = Object(_util_debounce__WEBPACK_IMPORTED_MODULE_1__["default"])(() => { const triggerOffset = backToTopLink.dataset.triggerOffset || CONSTANTS.TRIGGER_OFFSET; const y = holder.pageYOffset || holder.scrollTop; if (y >= triggerOffset) { backToTopLink.classList.add('active'); } else { backToTopLink.classList.remove('active'); } }, CONSTANTS.SCROLL_INTERVAL); holder.addEventListener('scroll', scrollHandler); backToTopLink.addEventListener('click', () => { const container = backToTopLink.dataset.containerSelector === undefined ? jquery__WEBPACK_IMPORTED_MODULE_0___default()('html, body') : jquery__WEBPACK_IMPORTED_MODULE_0___default()(backToTopLink.dataset.containerSelector); container.animate({ scrollTop: 0 }, 500); }); document.addEventListener(EVENTS.BACK_SHOW, () => { backToTopLink.classList.remove('d-none'); }); document.addEventListener(EVENTS.BACK_HIDE, () => { backToTopLink.classList.add('d-none'); }); }); } }; /** * show and use back to top. */ /* harmony default export */ __webpack_exports__["default"] = (() => { addBackToTopHandler(); }); /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/clientSideNav.js": /*!************************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/clientSideNav.js ***! \************************************************************************************/ /*! exports provided: NAV_EVENTS, clientSideNav */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NAV_EVENTS", function() { return NAV_EVENTS; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clientSideNav", function() { return clientSideNav; }); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _intlTelInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./intlTelInput */ "./cartridges/app_tfg/cartridge/client/default/js/components/intlTelInput.js"); /* harmony import */ var _intlTelInput__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_intlTelInput__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var lzutf8_light__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lzutf8-light */ "./node_modules/lzutf8-light/build/production/lzutf8-light.js"); /* harmony import */ var lzutf8_light__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lzutf8_light__WEBPACK_IMPORTED_MODULE_2__); /* harmony import */ var _util_scrollTo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/scrollTo */ "./cartridges/app_tfg/cartridge/client/default/js/util/scrollTo.js"); /* harmony import */ var _util_domutils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../util/domutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); /* harmony import */ var _util_fetchutils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util/fetchutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/fetchutils.js"); /* harmony import */ var _util_urlutils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../util/urlutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/urlutils.js"); /* harmony import */ var _header__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./header */ "./cartridges/app_tfg/cartridge/client/default/js/components/header.js"); /* eslint-disable jquery/no-attr */ // eslint-disable-line import/named const CONTENT_CACHE = {}; let STATE_CACHE = null; const NAV_EVENTS = { NAV_BACK: 'nav:back', NAV_CONTENT: 'nav:content' }; const getUpdateUrl = function getUpdateUrl(triggerUrl) { let useFullUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; let paramsBlacklist = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; let target = triggerUrl || window.location.href; if (!useFullUrl) { const loc = window.location; const base = `${loc.protocol}//${loc.hostname}${loc.pathname}`; const triggerUrlParts = target.split('?'); if (triggerUrlParts.length > 1) { target = `${base}?${triggerUrlParts[1]}`; } } return Object(_util_urlutils__WEBPACK_IMPORTED_MODULE_6__["removeParamsFromUrl"])(target, ['navAjax', ...paramsBlacklist]); }; /** * Pushes a history state on the stack * * @param {string} targetSelector Selector for the element updated during the current step * @param {string} content The content corresponding to the current step * @param {boolean} [scrollTarget] If provided, the window will be scrolled to that element on restore * @param {boolean} [useFullUrl] If truthy, the passed in URL will replace the location, instead of just the QS * @param {string} [url=window.location.href] The update URL used during the current step */ const addHistoryStep = (historyMethod, targetSelector, content, scrollTarget, paramsBlacklist, useFullUrl, url) => { if (targetSelector && content) { const compressedContent = Object(lzutf8_light__WEBPACK_IMPORTED_MODULE_2__["compress"])(content); const updateUrl = getUpdateUrl(url, useFullUrl, paramsBlacklist); const stateObj = { targetSelector, content: updateUrl, scrollTarget }; CONTENT_CACHE[updateUrl] = compressedContent; window.history[historyMethod](stateObj, document.title, updateUrl); STATE_CACHE = stateObj; } }; const pushHistoryStep = function pushHistoryStep() { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } addHistoryStep('pushState', ...args); }; const replaceHistoryStep = function replaceHistoryStep() { for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } addHistoryStep('replaceState', ...args); }; /** * Attaches a popstate event listener, which handles back navigation */ const initHistoryHandling = () => { window.onpopstate = e => { if (e.state && e.state.targetSelector && e.state.content) { const target = document.querySelector(e.state.targetSelector); if (target) { const content = CONTENT_CACHE[e.state.content]; if (content) { target.innerHTML = Object(lzutf8_light__WEBPACK_IMPORTED_MODULE_2__["decompress"])(content); delete CONTENT_CACHE[e.state.content]; } } if (e.state.scrollTarget) { Object(_util_scrollTo__WEBPACK_IMPORTED_MODULE_3__["default"])(e.state.scrollTarget); } document.dispatchEvent(new CustomEvent(NAV_EVENTS.NAV_BACK)); } }; }; const populateFormValuesInCurrentStep = paramsBlacklist => { const stateObj = window.history.state || STATE_CACHE; const targetSelector = stateObj.targetSelector, scrollTarget = stateObj.scrollTarget; if (targetSelector) { const target = document.querySelector(targetSelector); if (target) { Object(_util_domutils__WEBPACK_IMPORTED_MODULE_4__["refreshAttributes"])(targetSelector); replaceHistoryStep(targetSelector, target.innerHTML, scrollTarget, paramsBlacklist); } } }; /** * Executes a nav update over AJAX * * @param {Element} trigger The element that triggered the update * @param {string} targetSelector Selector for the update target * @param {string} [contentKey] If provided, and the response is JSON, this field will be returned from it * @param {boolean} [scrollTarget] If provided, the window will be scrolled to that element after the update * @param {boolean} [append=false] If true, the fetched content will be appended to the target * @param {RenderCallback} [renderer] If provided will be called instead of the standard renderer * @param {UpdateCallback} [callback] If provided will be called after the target is updated */ const handleUpdate = async (trigger, config) => { const targetSelector = config.targetSelector, contentKey = config.contentKey, scrollTarget = config.scrollTarget, ignoreScroll = config.ignoreScroll, paramsBlacklist = config.paramsBlacklist, _config$append = config.append, append = _config$append === void 0 ? false : _config$append, renderer = config.renderer, callback = config.callback, urlInputSelector = config.urlInputSelector; const _ref = await Object(_util_fetchutils__WEBPACK_IMPORTED_MODULE_5__["loadContent"])(trigger, null, { navAjax: true }), url = _ref.url, type = _ref.type, content = _ref.content; let responseContent; if (type === _util_fetchutils__WEBPACK_IMPORTED_MODULE_5__["CONTENT_TYPES"].JSON && content) { if (contentKey) { responseContent = content[contentKey]; } else { responseContent = content; } } else if (type === _util_fetchutils__WEBPACK_IMPORTED_MODULE_5__["CONTENT_TYPES"].TEXT) { responseContent = content; } if (responseContent) { let overrideUrl = null; let useFullUrl = false; const target = document.querySelector(targetSelector); // This ensures that any values the customer entered will get restored on back navigation populateFormValuesInCurrentStep(paramsBlacklist); if (target) { if (typeof renderer === 'function') { await renderer(content, append); const $dialCode = jquery__WEBPACK_IMPORTED_MODULE_0___default()('#dialCode'); if ($dialCode) { const allowedCountries = $dialCode.attr('allowedLocales'); const defaultCountryCode = $dialCode.attr('defaultCountryCode'); const $onlyCountries = allowedCountries ? allowedCountries.split(',') : ''; jquery__WEBPACK_IMPORTED_MODULE_0___default()('#dialCode').intlTelInput({ allowDropdown: true, initialCountry: defaultCountryCode, formatOnDisplay: true, separateDialCode: true, page: 'checkout-page', onlyCountries: $onlyCountries, dropdownContainer: jquery__WEBPACK_IMPORTED_MODULE_0___default()('.country-dial-code') }); } } else if (append) { target.insertAdjacentHTML('beforeend', responseContent); } else { target.innerHTML = responseContent; } const paymentForm = document.querySelector(ignoreScroll); const horizontalFilterOn = document.querySelector('.horizontal-filter-container'); const isPagination = trigger && trigger.classList.contains('paging__page'); if (scrollTarget && paymentForm == null && !horizontalFilterOn || isPagination) { Object(_util_scrollTo__WEBPACK_IMPORTED_MODULE_3__["default"])(scrollTarget); } if (callback) { callback(trigger, target, responseContent); } if (urlInputSelector) { const urlInput = document.querySelector(urlInputSelector); if (urlInput) { useFullUrl = true; overrideUrl = urlInput.value.trim(); } } pushHistoryStep(targetSelector, target.innerHTML, scrollTarget, paramsBlacklist, useFullUrl, overrideUrl || url); setTimeout(() => { document.dispatchEvent(new CustomEvent(NAV_EVENTS.NAV_CONTENT)); document.dispatchEvent(new CustomEvent(_header__WEBPACK_IMPORTED_MODULE_7__["EVENTS"].UPDATE_HEADER)); }, 10); } } }; /** * Initializes the navigation logic by persisting the content of the element * retrieved with the provided parent selector in an initial history state, * which is used as an indicator for the start of the history chain, * right before the content for the first client-side navigation is rendered * * @param {string} targetSelector Selector for the root element */ const initNav = targetSelector => { const target = document.querySelector(targetSelector); if (target) { const content = target.innerHTML; replaceHistoryStep(targetSelector, content); } }; /** * Attaches listeners to the configured AJAX update triggers * * @param {Object[]} config Config objects for the navigation logic */ const initTriggers = configs => { configs.forEach(config => { const triggerSelector = config.triggerSelector, targetSelector = config.targetSelector; if (targetSelector) { (config.interactionEvents || ['submit', 'click']).forEach(evt => { Object(_util_domutils__WEBPACK_IMPORTED_MODULE_4__["onEvent"])(document, evt, triggerSelector, e => { const hasAction = e.delegateTarget.href || e.delegateTarget.dataset.action; if (evt === 'click' && hasAction || evt === 'submit' && e.delegateTarget.action) { e.preventDefault(); handleUpdate(e.delegateTarget, config); } }); }); Object(_util_domutils__WEBPACK_IMPORTED_MODULE_4__["onEvent"])(document, 'change', triggerSelector, e => { if (e.delegateTarget.tagName.toLowerCase() === 'select') { const selectedOption = e.delegateTarget.options[e.delegateTarget.selectedIndex]; if (selectedOption && selectedOption.value) { const value = selectedOption.value; const hasUrl = value.startsWith('http') || value.startsWith('/'); if (hasUrl) { selectedOption.dataset.action = value; handleUpdate(selectedOption, config); } } } }); } }); }; /** * Callback for a nav update operation * * @callback UpdateCallback * @param {Element} trigger The element that triggered the update * @param {Element} target The updated target */ /** * Callback for the replaces that standard render process * * @callback RenderCallback * @param {Response} response The AJAX response to render */ /** * Module that handles updating page components over AJAX * and updating the URL and history to match those changes * * @param {string} navParentSelector Selector to use to populate the initial state of the page * @param {Object[]} config Config objects for the navigation logic * @param {string} config[].triggerSelector Selector for the navigation trigger element(s) * @param {string} config[].targetSelector Selector for the element to update * @param {boolean} [config[].scrollTarget] If provided, the window will be scrolled to that element after the update * @param {boolean} [config[].append=false] If true, the fetched content will be appended to the target * @param {string[]} [config[].interactionEvents] Can replace the default ['click', 'submit'] as navigation triggers * @param {RenderCallback} [config[].renderer] If provided will be called instead of the standard renderer * @param {UpdateCallback} [config[].callback] If provided will be called after the target is updated */ const clientSideNav = (navParentSelector, config) => { initNav(navParentSelector); initTriggers(config); initHistoryHandling(); }; /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/clientSideValidation.js": /*!*******************************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/clientSideValidation.js ***! \*******************************************************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module uses injected variables ($) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* WEBPACK VAR INJECTION */(function($) {/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~base */ "./cartridges/app_storefront_base/cartridge/client/default/js/components/clientSideValidation.js"); /* harmony import */ var _util_domutils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/domutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); /* harmony import */ var _addressForm__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./addressForm */ "./cartridges/int_loqate_tfg/cartridge/client/default/js/components/addressForm.js"); /* harmony import */ var _util_scrollTo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/scrollTo */ "./cartridges/app_tfg/cartridge/client/default/js/util/scrollTo.js"); // eslint-disable-line import/named const baseSubmit = _base__WEBPACK_IMPORTED_MODULE_0__["default"].submit; const baseClearForm = _base__WEBPACK_IMPORTED_MODULE_0__["default"].functions.clearForm; const baseInvalid = _base__WEBPACK_IMPORTED_MODULE_0__["default"].invalid; /** * Validate whole form. Requires `this` to be set to form object * @param {jQuery.event} event - Event to be canceled if form is invalid. * @returns {boolean} - Flag to indicate if form is valid */ function validateForm(event) { let valid = true; if (this.checkValidity && !this.checkValidity()) { // safari valid = false; if (event) { event.preventDefault(); event.stopPropagation(); event.stopImmediatePropagation(); } // eslint-disable-next-line jquery/no-each, jquery/no-find, no-undef $(this).find('input, select').each(function () { if (!this.validity.valid) { // eslint-disable-next-line jquery/no-trigger, no-undef $(this).trigger('invalid', this.validity); } }); } return valid; } function scrollToFirstError(parent) { setTimeout(() => { const errorEl = parent.querySelector('.form-control.is-invalid:not([disabled])'); if (errorEl) { Object(_util_scrollTo__WEBPACK_IMPORTED_MODULE_3__["default"])(errorEl); errorEl.focus(); } }, 1); } /** * Remove all validation. Should be called every time before revalidating form * @param {element} form - Form to be cleared * @returns {void} */ _base__WEBPACK_IMPORTED_MODULE_0__["default"].functions.clearForm = (form, resetValidity) => { baseClearForm.call(undefined, form); if (!resetValidity) { form.querySelectorAll('.form-control').forEach(el => { if (el.required) { Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["addClassIfNeeded"])(el, 'is-valid'); } }); } }; _base__WEBPACK_IMPORTED_MODULE_0__["default"].functions.invalidate = (formGroup, message) => { const validatedMessage = message || ''; const els = formGroup.querySelectorAll('input, select, textarea, .form-control'); const feedbackContainer = formGroup.querySelector('.invalid-feedback'); els.forEach(el => { if (el.required) { el.classList.toggle('is-invalid', validatedMessage); el.classList.toggle('is-valid', !validatedMessage); } }); if (feedbackContainer) { feedbackContainer.textContent = validatedMessage; } scrollToFirstError(formGroup); }; _base__WEBPACK_IMPORTED_MODULE_0__["default"].submit = () => { document.querySelectorAll('form').forEach(form => { form.addEventListener('submit', () => { // Dispatch event to show hidden address fields on submit if there are any errors document.dispatchEvent(new CustomEvent(_addressForm__WEBPACK_IMPORTED_MODULE_2__["ADDRESS_FORM_EVENTS"].SUBMIT)); scrollToFirstError(form); }); }); baseSubmit(); }; document.addEventListener('product:afterAttributeSelect', () => { baseSubmit(); baseInvalid(); }); _base__WEBPACK_IMPORTED_MODULE_0__["default"].buttonClick = () => { // Changes the handler of the base event to the overridden clearForm function, // so that the valid class is added to the fields and they can be styled appropriately Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["onEvent"])(document, 'click', 'form button[type="submit"], form input[type="submit"]', e => { // clear all errors when trying to submit the form _base__WEBPACK_IMPORTED_MODULE_0__["default"].functions.clearForm(e.delegateTarget.closest('form')); }); }; _base__WEBPACK_IMPORTED_MODULE_0__["default"].functions.loginValidation = (formGroup, message) => { const validatedMessage = message || ''; const els = formGroup.querySelectorAll('input, select, textarea, .form-control'); els.forEach(el => { if (el.required) { el.classList.toggle('is-invalid', validatedMessage); el.classList.toggle('is-valid', !validatedMessage); } }); }; _base__WEBPACK_IMPORTED_MODULE_0__["default"].functions.validateForm = form => { validateForm.call(document.querySelector(form), null); }; /* harmony default export */ __webpack_exports__["default"] = (_base__WEBPACK_IMPORTED_MODULE_0__["default"]); /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"))) /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/consentTracking.js": /*!**************************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/consentTracking.js ***! \**************************************************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./cartridges/app_storefront_base/cartridge/client/default/js/main.js (referenced with cjs require) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony default export */ __webpack_exports__["default"] = (() => {}); /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/cookie.js": /*!*****************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/cookie.js ***! \*****************************************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./cartridges/app_storefront_base/cartridge/client/default/js/main.js (referenced with cjs require) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony default export */ __webpack_exports__["default"] = (function () { if (document.querySelector('.valid-cookie-warning')) { const cookiesAccepted = window.localStorage.getItem('cookiesAccepted'); const cookieWarningMessageContainer = document.querySelector('.cookie-warning-messaging'); if (!cookiesAccepted) { cookieWarningMessageContainer.classList.add('d-block'); cookieWarningMessageContainer.classList.remove('d-none'); } else { cookieWarningMessageContainer.classList.add('d-none'); cookieWarningMessageContainer.classList.remove('d-block'); window.__rmcp = [1, 2, 3, 4, 5]; // eslint-disable-line no-underscore-dangle } document.querySelector('.valid-cookie-warning .btn').addEventListener('click', () => { window.localStorage.setItem('cookiesAccepted', 'cookiesAccepted'); window.__rmcp = [1, 2, 3, 4, 5]; // eslint-disable-line no-underscore-dangle }); } }); /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/flyoutUnderHeader.js": /*!****************************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/flyoutUnderHeader.js ***! \****************************************************************************************/ /*! exports provided: EVENTS, initFlyout */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EVENTS", function() { return EVENTS; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initFlyout", function() { return initFlyout; }); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _util_domutils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/domutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); /* harmony import */ var _header__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./header */ "./cartridges/app_tfg/cartridge/client/default/js/components/header.js"); const EVENTS = { FLYOUT_OPEN: 'flyout:opened', FLYOUT_CLOSE: 'flyout:closed', BACK_SHOW: 'backtotop:show', BACK_HIDE: 'backtotop:hide' }; const SELECTORS = { CONTENT: '[class*="__container "]' }; /** * Updates the total height of the minicart container so it can be aligned with the header * * @param {Element} container The minicart container * @param {Number} [pageHeaderHeight=] The height of the header to align against */ const recalculateContainer = function recalculateContainer(container, callback) { let pageHeaderHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _header__WEBPACK_IMPORTED_MODULE_2__["functions"].getHeaderHeight(); container.style.top = `${pageHeaderHeight}px`; container.style.height = `calc(100% - ${pageHeaderHeight}px)`; if (typeof callback === 'function') { callback(container, pageHeaderHeight); } }; /** * Ensures that the flyout elements' height gets recalculated when the header resizes * * @param {Element} container The flyout container */ const initFlyout = function initFlyout(container, callback) { let toggleClass = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'show'; ['scroll', 'resize'].forEach(evt => { window.addEventListener(evt, () => { if (container.classList.contains(toggleClass)) { recalculateContainer(container, callback); } }); }); /** * Dispatch UPDATE_HEADER in order to update the sticky header * listen for UPDATE_HEADER in order to calculate the flyout's dimensions after header is updated */ document.dispatchEvent(new CustomEvent(_header__WEBPACK_IMPORTED_MODULE_2__["EVENTS"].UPDATE_HEADER)); document.addEventListener(_header__WEBPACK_IMPORTED_MODULE_2__["EVENTS"].UPDATE_HEADER, () => { recalculateContainer(container, callback); }); _header__WEBPACK_IMPORTED_MODULE_2__["functions"].onHeightChange(recalculateContainer.bind(null, container, callback)); if (Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["isIOS"])()) { const inputs = container.querySelectorAll('input'); const content = container.querySelector(SELECTORS.CONTENT); inputs.forEach(input => { input.addEventListener('focus', () => { setTimeout(() => { jquery__WEBPACK_IMPORTED_MODULE_0___default()(content).scrollTop(jquery__WEBPACK_IMPORTED_MODULE_0___default()(input).offset().top - 20); }, 500); }); }); } jquery__WEBPACK_IMPORTED_MODULE_0___default()(container).on('shown.bs.collapse', () => { document.dispatchEvent(new CustomEvent(EVENTS.FLYOUT_OPEN, { detail: { flyout: container, content: container.querySelector(SELECTORS.CONTENT) } })); }).on('hidden.bs.collapse', () => { document.dispatchEvent(new CustomEvent(EVENTS.FLYOUT_CLOSE, { detail: { flyout: container, content: container.querySelector(SELECTORS.CONTENT) } })); }); jquery__WEBPACK_IMPORTED_MODULE_0___default()(container).on('shown.bs.collapse', () => { recalculateContainer(container, callback); }); document.addEventListener(EVENTS.FLYOUT_OPEN, e => { if (container.classList.contains('show') && e.detail.flyout !== container) { jquery__WEBPACK_IMPORTED_MODULE_0___default()(container).collapse('hide'); } document.dispatchEvent(new CustomEvent(EVENTS.BACK_HIDE)); }); document.addEventListener(EVENTS.FLYOUT_CLOSE, () => { document.dispatchEvent(new CustomEvent(EVENTS.BACK_SHOW)); }); recalculateContainer(container, callback); }; /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/forms.js": /*!****************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/forms.js ***! \****************************************************************************/ /*! exports provided: FORM_EVENTS, initForms */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FORM_EVENTS", function() { return FORM_EVENTS; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initForms", function() { return initForms; }); /* harmony import */ var _util_debounce__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util/debounce */ "./cartridges/app_bee_base/cartridge/client/default/js/util/debounce.js"); /* harmony import */ var _util_domutils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/domutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); /* harmony import */ var _thirdParty_bootstrap_toggleFormElementsStates__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../thirdParty/bootstrap/toggleFormElementsStates */ "./cartridges/app_tfg/cartridge/client/default/js/thirdParty/bootstrap/toggleFormElementsStates.js"); /* harmony import */ var _clientSideNav__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./clientSideNav */ "./cartridges/app_tfg/cartridge/client/default/js/components/clientSideNav.js"); /* harmony import */ var _addressForm__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./addressForm */ "./cartridges/int_loqate_tfg/cartridge/client/default/js/components/addressForm.js"); // eslint-disable-line import/named const SELECTORS = { FORMS: 'form', PREFILLED: ':-webkit-autofill', FORM_SUBMIT: '.btn[type="submit"]', FORM_RADIOS: 'form input[type="radio"]', FORM_FIELDS: 'form input:not([type="radio"]):not([type="checkbox"]), form select, form textarea' }; const FORM_EVENTS = { SUBMIT_STATE_CHANGE: 'form:submit-state-chage' }; const DISABLE_INCOMPLETE_FORMS_SUBMIT = window.beesfra && window.beesfra.config && window.beesfra.config.disableIncompleteFormsSubmit; const handleFormValidity = form => { const buttons = form.querySelectorAll(SELECTORS.FORM_SUBMIT); const fields = form.querySelectorAll(SELECTORS.FORM_FIELDS); const requiredFieldsPopulated = Array.from(fields).every(field => field.disabled || !field.required || field.value); const radioButtons = form.querySelectorAll(SELECTORS.FORM_RADIOS); const radioGroups = Array.from(radioButtons).reduce((groups, radioButton) => { groups[radioButton.name] = groups[radioButton.name] || []; groups[radioButton.name].push(radioButton); return groups; }, {}); const radiosChecked = Object.values(radioGroups).every(group => group.some(radio => radio.disabled || radio.checked)); const formIncomplete = !requiredFieldsPopulated || !radiosChecked; if (DISABLE_INCOMPLETE_FORMS_SUBMIT) { buttons.forEach(button => { button.classList.toggle('disabled', formIncomplete); }); } document.dispatchEvent(new CustomEvent(FORM_EVENTS.SUBMIT_STATE_CHANGE, { detail: { form, formIncomplete } })); }; /** * Visually disableds the submit button of each form which doesn not have * all its required fields populated and vice-versa. * They don't get actually disabled so they can still be used in case issues * occur with the logic, the normal validation should prevent any data issues */ const toggleSubmitState = () => { ['change', 'keyup'].forEach(event => { Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["onEvent"])(document, event, SELECTORS.FORM_FIELDS, Object(_util_debounce__WEBPACK_IMPORTED_MODULE_0__["default"])(e => { handleFormValidity(e.delegateTarget.form || e.delegateTarget); }, 300)); }); [_clientSideNav__WEBPACK_IMPORTED_MODULE_3__["NAV_EVENTS"].NAV_BACK, _clientSideNav__WEBPACK_IMPORTED_MODULE_3__["NAV_EVENTS"].NAV_CONTENT, _thirdParty_bootstrap_toggleFormElementsStates__WEBPACK_IMPORTED_MODULE_2__["COLLAPSE_EVENTS"].FORMS_STATE_CHANGED, _addressForm__WEBPACK_IMPORTED_MODULE_4__["ADDRESS_FORM_EVENTS"].POPULATE].forEach(evt => { document.addEventListener(evt, () => { document.querySelectorAll(SELECTORS.FORMS).forEach(handleFormValidity); }); }); document.querySelectorAll(SELECTORS.FORMS).forEach(handleFormValidity); }; /** * On WebKit browsers fields that get their values prefilled from e.g. saved passwords * don't get their placeholders removed on load. This causes a design issue with the floating labels. * The code below iterates and does a focus-blur on each of those fields to force them to behave per design. * Only runs on Chrome-like browsers using the vendor-prefixed selector as this seems to be OK on other browsers. */ const fixWebkitPrefilledFieldLabels = () => { try { const affectedForms = []; const prefilledFields = Array.from(document.querySelectorAll(SELECTORS.PREFILLED)); prefilledFields.forEach(field => { field.focus({ preventScroll: true }); field.blur(); if (affectedForms.indexOf(field.form) < 0) { affectedForms.push(field.form); } }); if (DISABLE_INCOMPLETE_FORMS_SUBMIT) { affectedForms.forEach(handleFormValidity); } } catch (e) {// Not on a WebKit-based browser } }; const initForms = () => { toggleSubmitState(); fixWebkitPrefilledFieldLabels(); }; /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/header.js": /*!*****************************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/header.js + 1 modules ***! \*****************************************************************************************/ /*! exports provided: SELECTORS, EVENTS, initBannerClose, functions, initResizeHandler, initHandleNewsletterValidation, pdComponentsJs, searchfocus, removeEmoji, initScroll, initComponents */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/components/flyoutUnderHeader.js because of ./cartridges/app_tfg/cartridge/client/default/js/appointments/appointments.js */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js because of ./cartridges/app_tfg/cartridge/client/default/js/sfra/productDetail.js */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/util/fetchutils.js because of ./cartridges/app_tfg/cartridge/client/default/js/sfra/productDetail.js */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/choices.js/public/assets/scripts/choices.min.js (<- Module is not an ECMAScript module) */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/css-element-queries/index.js (<- Module is not an ECMAScript module) */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/jquery/dist/jquery.js (<- Module is not an ECMAScript module) */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/countrySelectorChoice.mustache (<- Module is not an ECMAScript module) */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/countrysSelectorItem.mustache (<- Module is not an ECMAScript module) */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/partials/countryAttributes.mustache (<- Module is not an ECMAScript module) */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/partials/countryContent.mustache (<- Module is not an ECMAScript module) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, "SELECTORS", function() { return /* binding */ header_SELECTORS; }); __webpack_require__.d(__webpack_exports__, "EVENTS", function() { return /* binding */ header_EVENTS; }); __webpack_require__.d(__webpack_exports__, "initBannerClose", function() { return /* binding */ initBannerClose; }); __webpack_require__.d(__webpack_exports__, "functions", function() { return /* binding */ functions; }); __webpack_require__.d(__webpack_exports__, "initResizeHandler", function() { return /* binding */ initResizeHandler; }); __webpack_require__.d(__webpack_exports__, "initHandleNewsletterValidation", function() { return /* binding */ initHandleNewsletterValidation; }); __webpack_require__.d(__webpack_exports__, "pdComponentsJs", function() { return /* binding */ pdComponentsJs; }); __webpack_require__.d(__webpack_exports__, "searchfocus", function() { return /* binding */ searchfocus; }); __webpack_require__.d(__webpack_exports__, "removeEmoji", function() { return /* binding */ removeEmoji; }); __webpack_require__.d(__webpack_exports__, "initScroll", function() { return /* binding */ initScroll; }); __webpack_require__.d(__webpack_exports__, "initComponents", function() { return /* binding */ initComponents; }); // EXTERNAL MODULE: ./node_modules/jquery/dist/jquery.js var jquery = __webpack_require__("./node_modules/jquery/dist/jquery.js"); var jquery_default = /*#__PURE__*/__webpack_require__.n(jquery); // EXTERNAL MODULE: ./node_modules/css-element-queries/index.js var css_element_queries = __webpack_require__("./node_modules/css-element-queries/index.js"); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js + 1 modules var domutils = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); // EXTERNAL MODULE: ./node_modules/choices.js/public/assets/scripts/choices.min.js var choices_min = __webpack_require__("./node_modules/choices.js/public/assets/scripts/choices.min.js"); var choices_min_default = /*#__PURE__*/__webpack_require__.n(choices_min); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/flyoutUnderHeader.js var flyoutUnderHeader = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/components/flyoutUnderHeader.js"); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/util/fetchutils.js + 1 modules var fetchutils = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/util/fetchutils.js"); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/countrysSelectorItem.mustache var countrysSelectorItem_mustache = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/countrysSelectorItem.mustache"); var countrysSelectorItem_mustache_default = /*#__PURE__*/__webpack_require__.n(countrysSelectorItem_mustache); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/countrySelectorChoice.mustache var countrySelectorChoice_mustache = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/countrySelectorChoice.mustache"); var countrySelectorChoice_mustache_default = /*#__PURE__*/__webpack_require__.n(countrySelectorChoice_mustache); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/partials/countryContent.mustache var countryContent_mustache = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/partials/countryContent.mustache"); var countryContent_mustache_default = /*#__PURE__*/__webpack_require__.n(countryContent_mustache); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/partials/countryAttributes.mustache var countryAttributes_mustache = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/partials/countryAttributes.mustache"); var countryAttributes_mustache_default = /*#__PURE__*/__webpack_require__.n(countryAttributes_mustache); // CONCATENATED MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/header/countrySelector.js // eslint-disable-line import/named const CONSTANTS = { DROPDOWN_LIST_MAX_HEIGHT_OFFSET: 20 }; const GLOBALS = { GATEWAY: { COUNTRY_CHOICES: null, LANGUAGE_CHOICES: null, CURRENCY_CHOICES: null }, CONTAINER: { COUNTRY_CHOICES: null, LANGUAGE_CHOICES: null, CURRENCY_CHOICES: null } }; const clearExistingDropdown = async () => { ['GATEWAY', 'CONTAINER'].forEach(containerType => { if (GLOBALS[containerType].COUNTRY_CHOICES && GLOBALS[containerType].COUNTRY_CHOICES.initialised) { GLOBALS[containerType].COUNTRY_CHOICES.destroy(); } if (GLOBALS[containerType].LANGUAGE_CHOICES && GLOBALS[containerType].LANGUAGE_CHOICES.initialised) { GLOBALS[containerType].LANGUAGE_CHOICES.destroy(); } if (GLOBALS[containerType].CURRENCY_CHOICES && GLOBALS[containerType].CURRENCY_CHOICES.initialised) { GLOBALS[containerType].CURRENCY_CHOICES.destroy(); } }); }; const CLASSES = { DROPDOWN_LIST: 'choices__list--dropdown' }; const EVENTS = { UPDATE_HEADER: 'header:update' }; const SELECTORS = { GATEWAY: '#countryGateway', CONTAINER: '.country-selector__pane', FORM: '.country-selector__form', FORM_ERROR: '.error-summary', DROPDOWN_CONTAINER: '.country-selector__form__field', LOCATION_DROPDOWN: '.country-selector__form__input--location', LANGUAGE_DROPDOWN: '.country-selector__form__input--language', CURRENCY_DROPDOWN: '.country-selector__form__input--currency', LANGUAGE_INPUT: '[type="hidden"][name="language"]', CURRENCY_INPUT: '[type="hidden"][name="currency"]', PAGE_LOCALE_LOADER: '.js-page-locale-loader', PAGE_LOCALE_LOADER_MOBILE: '.js-page-locale-loader-mobile' }; /** * Renders the Mustache template for the card item or option * @param {Function} templateFunc The item template function provided by the Choice library * @param {Function} template The Hogan renderer to use to render the content * @param {Object} classNames The Choice class names hash, provided by the library * @param {Object} data The item state hash, provided by the library * @return {string} The result of calling the templating function with the rendered Hogan template */ const renderCountryOption = (templateFunc, template, classNames, data) => { const content = template.render({ classNames, data, countryCode: data.value.toLowerCase() }, { content: countryContent_mustache_default.a, attributes: countryAttributes_mustache_default.a }); return templateFunc(content); }; const handleDropdownBehavior = (choices, options, singleOptionBehaviors, singleOptionBehavior) => { const container = choices.containerOuter.element.closest(SELECTORS.DROPDOWN_CONTAINER); if (options.length <= 1) { switch (singleOptionBehavior) { case singleOptionBehaviors.HIDE: container.classList.add('d-none'); break; case singleOptionBehaviors.DISABLE: choices.disable(); break; default: } } else { choices.enable(); container.classList.remove('d-none'); } }; const initCountryChange = (countryDropdown, languageChoices, currencyChoices, singleOptionBehaviors, singleOptionBehavior) => { const form = countryDropdown.form; const countries = Object(domutils["getJSONData"])(countryDropdown, 'countries', []); countryDropdown.addEventListener('change', e => { const selectedCountryCode = e.detail.value; const selectedCountry = countries.find(country => country.id === selectedCountryCode); if (selectedCountry) { const languageInput = form.querySelector(SELECTORS.LANGUAGE_INPUT); const currencyInput = form.querySelector(SELECTORS.CURRENCY_INPUT); if (selectedCountry.locales.length) { languageInput.value = selectedCountry.locales[0].id; } if (selectedCountry.currencies.length) { currencyInput.value = selectedCountry.currencies[0].code; } if (languageChoices) { const languages = selectedCountry.locales.map((locale, index) => ({ value: locale.id, label: locale.languageName, selected: index === 0 })); languageChoices.setChoices(languages, 'value', 'label', true); handleDropdownBehavior(languageChoices, languages, singleOptionBehaviors, singleOptionBehavior); languageChoices.passedElement.element.addEventListener('change', evt => { languageInput.value = evt.detail.value; }); } if (currencyChoices) { const currencies = selectedCountry.currencies.map((currency, index) => ({ value: currency.code, label: `${currency.code} ${currency.symbol}`, selected: index === 0 })); currencyChoices.setChoices(currencies, 'value', 'label', true); handleDropdownBehavior(currencyChoices, currencies, singleOptionBehaviors, singleOptionBehavior); currencyChoices.passedElement.element.addEventListener('change', evt => { currencyInput.value = evt.detail.value; }); } } }); }; const initDropdownHeightCalculation = countryDropdown => { const getDropdown = el => { const dropdown = el.parentElement.nextElementSibling; if (dropdown && dropdown.classList.contains(CLASSES.DROPDOWN_LIST)) { return dropdown; } return null; }; const setDropdownMaxHeight = (dropdown, maxHeight) => { const children = Array.from(dropdown.children); const maxHeightValue = maxHeight ? `${maxHeight}px` : null; dropdown.style.maxHeight = maxHeightValue; children.forEach(child => { child.style.maxHeight = maxHeightValue; }); }; countryDropdown.addEventListener('showDropdown', e => { const dropdown = getDropdown(e.target); if (dropdown) { const viewportHeight = window.innerHeight; const _dropdown$getBounding = dropdown.getBoundingClientRect(), height = _dropdown$getBounding.height, top = _dropdown$getBounding.top; if (height + top >= viewportHeight - CONSTANTS.DROPDOWN_LIST_MAX_HEIGHT_OFFSET) { const maxHeight = viewportHeight - top - CONSTANTS.DROPDOWN_LIST_MAX_HEIGHT_OFFSET; setDropdownMaxHeight(dropdown, maxHeight); } else { setDropdownMaxHeight(dropdown); } } }); countryDropdown.addEventListener('hideDropdown', e => { const dropdown = getDropdown(e.target); if (dropdown) { setDropdownMaxHeight(dropdown); } }); }; const initDropdowns = (countryDropdown, languageDropdown, currencyDropdown, singleOptionBehaviors, singleOptionBehavior, containerType) => { const choicesOptions = { shouldSort: true, searchEnabled: false, itemSelectText: '', position: 'bottom', sortFn(a, b) { return a.label.trim() > b.label.trim() ? 1 : -1; } }; const countryOptions = { callbackOnCreateTemplates: template => ({ item: renderCountryOption.bind(null, template, countrysSelectorItem_mustache_default.a), choice: renderCountryOption.bind(null, template, countrySelectorChoice_mustache_default.a) }) }; // eslint-disable-next-line no-unused-vars, max-len GLOBALS[containerType].COUNTRY_CHOICES = new choices_min_default.a(countryDropdown, Object.assign({}, choicesOptions, countryOptions)); GLOBALS[containerType].LANGUAGE_CHOICES = languageDropdown && new choices_min_default.a(languageDropdown, choicesOptions); GLOBALS[containerType].CURRENCY_CHOICES = currencyDropdown && new choices_min_default.a(currencyDropdown, choicesOptions); // eslint-disable-next-line max-len initCountryChange(countryDropdown, GLOBALS[containerType].LANGUAGE_CHOICES, GLOBALS[containerType].CURRENCY_CHOICES, singleOptionBehaviors, singleOptionBehavior); initDropdownHeightCalculation(countryDropdown); // Prevent scrolling issues on iOS }; const initForm = form => { form.addEventListener('submit', async e => { e.preventDefault(); const formError = form.querySelector(SELECTORS.FORM_ERROR); if (formError) { formError.remove(); } const _ref = await Object(fetchutils["loadContent"])(form), content = _ref.content; if (content.errorContent) { form.innerHTML = content.errorContent + form.innerHTML; } if (content.redirectUrl) { // Ensure the cookie policy gets displayed after the redirect window.localStorage.removeItem('previousSid'); window.location.href = content.redirectUrl; } }); }; const initGateway = gatewayContainer => { const header = document.querySelector(header_SELECTORS.HEADER); jquery_default()(gatewayContainer).modal('show'); jquery_default()(gatewayContainer).on('shown.bs.modal', () => { header.classList.remove('header-z-index'); /** * position: [sticky | fixed] forces the country gateway's z-index not to function properly * causing it to act like an element with the lowest z-index * */ header.classList.add('position-static'); }); jquery_default()(gatewayContainer).on('hidden.bs.modal', () => { header.classList.add('header-z-index'); header.classList.remove('position-static'); document.dispatchEvent(new CustomEvent(EVENTS.UPDATE_HEADER)); }); }; // After Page Locale Content Load const countrySelector_afterPageLocaleContentLoad = async function afterPageLocaleContentLoad() { let containerType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; const gatewayContainer = document.querySelector(SELECTORS.GATEWAY); const flyoutContainer = document.querySelector(SELECTORS.CONTAINER); if (gatewayContainer && containerType === 'GATEWAY') { initGateway(gatewayContainer); } if (flyoutContainer) { Object(flyoutUnderHeader["initFlyout"])(flyoutContainer); document.dispatchEvent(new CustomEvent('flyout:opened', { detail: { flyout: flyoutContainer, content: flyoutContainer.querySelector('[class*="__container "]') } })); } [gatewayContainer, flyoutContainer].forEach(container => { if (container) { const selectionForm = container.querySelector(SELECTORS.FORM); const countryDropdown = container.querySelector(SELECTORS.LOCATION_DROPDOWN); const languageDropdown = container.querySelector(SELECTORS.LANGUAGE_DROPDOWN); const currencyDropdown = container.querySelector(SELECTORS.CURRENCY_DROPDOWN); if (selectionForm) { initForm(selectionForm); } if (countryDropdown) { clearExistingDropdown(); initDropdowns(countryDropdown, languageDropdown, currencyDropdown, Object(domutils["getJSONData"])(selectionForm, 'selectBehaviors', {}), selectionForm.dataset.selectBehavior, containerType); } } }); }; // PAGE_LOCALE_LOADER const loadPageLocale = async () => { const pageLocale = document.querySelector(SELECTORS.PAGE_LOCALE_LOADER); if (window.innerWidth > 767) { if (pageLocale) { const _ref2 = await Object(fetchutils["loadContent"])(pageLocale, null, null, false), content = _ref2.content; pageLocale.innerHTML = content; countrySelector_afterPageLocaleContentLoad('GATEWAY'); } const selectorObj = document.querySelector('.country-selector-link'); selectorObj.addEventListener('click', async () => { const _ref3 = await Object(fetchutils["loadContent"])(selectorObj, null, null, false), content = _ref3.content; pageLocale.innerHTML = content; countrySelector_afterPageLocaleContentLoad('CONTAINER'); }); } }; // PAGE_LOCALE_LOADER_MOBILE const loadPageLocaleMobile = async () => { const pageLocaleMobile = document.querySelector(SELECTORS.PAGE_LOCALE_LOADER_MOBILE); if (window.innerWidth < 769) { if (pageLocaleMobile) { const _ref4 = await Object(fetchutils["loadContent"])(pageLocaleMobile, null, null, false), content = _ref4.content; pageLocaleMobile.innerHTML = content; } const selectorObj = pageLocaleMobile.querySelector('.country-selector-link'); selectorObj.addEventListener('click', async () => { const _ref5 = await Object(fetchutils["loadContent"])(selectorObj, null, null, false), content = _ref5.content; pageLocaleMobile.innerHTML = content; countrySelector_afterPageLocaleContentLoad('CONTAINER'); }); } }; /* harmony default export */ var countrySelector = (async () => { const link = document.querySelector('.globale-selector'); const countrySelectorLink = document.querySelector('.js-page-locale-loader'); if (!link && countrySelectorLink) { loadPageLocale(); loadPageLocaleMobile(); } }); // CONCATENATED MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/header.js /* eslint-disable jquery/no-html */ /* eslint-disable jquery/no-find */ /* eslint-disable jquery/no-text */ /* eslint-disable jquery/no-ajax */ // eslint-disable-line import/named const header_SELECTORS = { HEADER: '.header-sticky', BOTTOM_BANNER: '.header-banner-bottom', BANNER_CLOSE_BUTTON: '.close-button', MENU_CATS: '.cat-Imagery' }; const CACHE = { RESIZE_SENSOR: null, RESIZE_HANDLERS: [] }; const header_EVENTS = { UPDATE_HEADER: 'header:update' }; const handleResizeEvents = height => { CACHE.RESIZE_HANDLERS.forEach(handler => { handler(height); }); }; const initBannerClose = () => { const headerBottomBanner = document.querySelector(header_SELECTORS.BOTTOM_BANNER); if (headerBottomBanner) { Object(domutils["onEvent"])(headerBottomBanner, 'click', header_SELECTORS.BANNER_CLOSE_BUTTON, () => { const cookieName = headerBottomBanner.dataset.closeCookie; document.cookie = `${cookieName}=true; path=/`; headerBottomBanner.remove(); }); } }; const functions = { getHeaderHeight() { let header = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document.querySelector(header_SELECTORS.HEADER); if (header) { const headerRectangle = header.getBoundingClientRect(); const headerOffset = headerRectangle.top; const headerHeight = header.offsetHeight; const headerDisplacement = Math.ceil(headerHeight + headerOffset); return headerDisplacement; } return 0; }, onHeightChange(cb) { CACHE.RESIZE_HANDLERS.push(cb); } }; const initResizeHandler = () => { const header = document.querySelector(header_SELECTORS.HEADER); if (header) { CACHE.RESIZE_SENSOR = new css_element_queries["ResizeSensor"](header, () => { handleResizeEvents(functions.getHeaderHeight(header)); }); } }; const initHandleNewsletterValidation = () => { jquery_default()(document).on('submit', '.email-newsletter__form:not(".validated")', function (e) { e.preventDefault(); const $form = jquery_default()(this); const emailField = document.querySelector('.email-newsletter__email-input'); // eslint-disable-next-line jquery/no-attr const requrestUrl = jquery_default()(this).attr('data-emailvalidate'); const dataObj = new FormData(); dataObj.append('email', emailField.value); if (emailField) { jquery_default.a.ajax({ url: requrestUrl, contentType: false, processData: false, type: 'post', data: dataObj, success(data) { if (!data.success) { $form.find('.invalid-feedback').html(data.error); emailField.classList.add('is-invalid'); } else { // eslint-disable-next-line jquery/no-class $form.addClass('validated'); // eslint-disable-next-line jquery/no-trigger $form.trigger('submit'); } } }); return false; } return true; }); }; const pdComponentsJs = () => { jquery_default()(document).ready(() => { jquery_default()('.show-more').on('click', function () { // eslint-disable-next-line jquery/no-class jquery_default()('.mission-copy-sign').removeClass('limit-height'); // eslint-disable-next-line jquery/no-class, jquery/no-parent jquery_default()(this).parent('.readmore-wrapper').removeClass('d-flex').addClass('d-none'); }); }); }; const searchfocus = () => { jquery_default()(document).ready(() => { jquery_default()('.header-search').on('click', () => { // eslint-disable-next-line jquery/no-class jquery_default()('.clearfix-self .search-field').focus(); }); }); }; const removeEmoji = () => { jquery_default()(document).on('change keyup', '.removeEmoji', function () { // eslint-disable-next-line max-len const regex = /(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/g; jquery_default()(this).val(jquery_default()(this).val().replace(regex, '')); // eslint-disable-line jquery/no-val }); }; const initScroll = () => { let startX; // To store the starting touch position let scrollLeft; // To store the current scroll position jquery_default()('.cat-Imagery').on('touchstart', function (e) { const touch = e.originalEvent.touches[0]; // Get the touch event startX = touch.pageX - jquery_default()(this).offset().left; // Calculate start position relative to container scrollLeft = jquery_default()(this).scrollLeft(); // Get current scroll position }); jquery_default()('.cat-Imagery').on('touchmove', function (e) { const touch = e.originalEvent.touches[0]; // Get the touch event const x = touch.pageX - jquery_default()(this).offset().left; // Calculate current position const walk = (x - startX) * 1.5; // Calculate how far to scroll jquery_default()(this).scrollLeft(scrollLeft - walk); // Scroll the container }); }; const initComponents = () => { countrySelector(); }; /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/countrySelectorChoice.mustache": /*!*******************************************************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/countrySelectorChoice.mustache ***! \*******************************************************************************************************************/ /*! no static exports found */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var H = __webpack_require__(/*! hogan.js */ "./node_modules/hogan.js/lib/hogan.js"); module.exports = function() { var T = new H.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("
");t.b(t.rp("");return t.fl(); },partials: {"attributes}} data-choice data-select-text=\"\" data-choice-selectable > {{> content}}
", H);return T; }(); /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/countrysSelectorItem.mustache": /*!******************************************************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/countrysSelectorItem.mustache ***! \******************************************************************************************************************/ /*! no static exports found */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var H = __webpack_require__(/*! hogan.js */ "./node_modules/hogan.js/lib/hogan.js"); module.exports = function() { var T = new H.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("
");t.b(t.rp("");return t.fl(); },partials: {"attributes}} data-item > {{> content}}
", H);return T; }(); /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/partials/countryAttributes.mustache": /*!************************************************************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/partials/countryAttributes.mustache ***! \************************************************************************************************************************/ /*! no static exports found */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var H = __webpack_require__(/*! hogan.js */ "./node_modules/hogan.js/lib/hogan.js"); module.exports = function() { var T = new H.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("class=\" country-selector__form__field__option ");t.b(t.v(t.d("classNames.item",c,p,0)));t.b(" ");t.b(t.v(t.d("classNames.itemChoice",c,p,0)));t.b(" ");if(t.s(t.d("data.highlighted",c,p,1),c,p,0,113,146,"{{ }}")){t.rs(c,p,function(c,p,t){t.b(" ");t.b(t.v(t.d("classNames.highlightedState",c,p,0)));t.b(" ");});c.pop();}t.b(" ");if(!t.s(t.d("data.highlighted",c,p,1),c,p,1,0,0,"")){t.b(" ");t.b(t.v(t.d("classNames.itemSelectable",c,p,0)));t.b(" ");};t.b(" ");if(t.s(t.d("data.disabled",c,p,1),c,p,0,260,318,"{{ }}")){t.rs(c,p,function(c,p,t){t.b(" ");t.b(t.v(t.d("classNames.itemDisabled",c,p,0)));t.b(" ");t.b(t.v(t.d("classNames.disabledState",c,p,0)));t.b(" ");});c.pop();}t.b(" \" data-id=\"");t.b(t.v(t.d("data.id",c,p,0)));t.b("\" data-value=\"");t.b(t.v(t.d("data.value",c,p,0)));t.b("\"");return t.fl(); },partials: {}, subs: { }}, "class=\" country-selector__form__field__option {{classNames.item}} {{classNames.itemChoice}} {{#data.highlighted}} {{classNames.highlightedState}} {{/data.highlighted}} {{^data.highlighted}} {{classNames.itemSelectable}} {{/data.highlighted}} {{#data.disabled}} {{classNames.itemDisabled}} {{classNames.disabledState}} {{/data.disabled}} \" data-id=\"{{data.id}}\" data-value=\"{{data.value}}\"", H);return T; }(); /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/partials/countryContent.mustache": /*!*********************************************************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/header/templates/partials/countryContent.mustache ***! \*********************************************************************************************************************/ /*! no static exports found */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var H = __webpack_require__(/*! hogan.js */ "./node_modules/hogan.js/lib/hogan.js"); module.exports = function() { var T = new H.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b(" ");t.b(t.v(t.d("data.label",c,p,0)));t.b("");return t.fl(); },partials: {}, subs: { }}, " {{data.label}}", H);return T; }(); /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/intlTelInput.js": /*!***********************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/intlTelInput.js ***! \***********************************************************************************/ /*! no static exports found */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* * International Telephone Input v12.1.3 * https://github.com/jackocnr/intl-tel-input.git * Licensed under the MIT license */ // wrap in UMD - see https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js (function (factory) { if (true) { !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js")], __WEBPACK_AMD_DEFINE_RESULT__ = ($ => { factory($, window, document); }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else {} })(($, window, document, undefined) => { // these vars persist through all instances of the plugin const pluginName = 'intlTelInput'; let id = 1; // give each instance it's own id for namespaced event handling const defaults = { // whether or not to allow the dropdown allowDropdown: true, // if there is just a dial code in the input: remove it on blur, and re-add it on focus autoHideDialCode: true, // add a placeholder in the input with an example number for the selected country autoPlaceholder: 'polite', // modify the auto placeholder customPlaceholder: null, // append menu to a specific element dropdownContainer: '', // don't display these countries excludeCountries: [], // format the input value during initialisation and on setNumber formatOnDisplay: true, // geoIp lookup function geoIpLookup: null, // inject a hidden input with this name, and on submit, populate it with the result of getNumber hiddenInput: '', // initial country initialCountry: '', // don't insert international dial codes nationalMode: true, // display only these countries onlyCountries: [], // number type to use for placeholders placeholderNumberType: 'MOBILE', // the countries at the top of the list. defaults to united states and united kingdom preferredCountries: [], // display the country dial code next to the selected flag so it's not part of the typed number separateDialCode: false, // specify the path to the libphonenumber script to enable validation/formatting utilsScript: '', page: '' }; const keys = { UP: 38, DOWN: 40, ENTER: 13, ESC: 27, PLUS: 43, A: 65, Z: 90, SPACE: 32, TAB: 9 }; // https://en.wikipedia.org/wiki/List_of_North_American_Numbering_Plan_area_codes#Non-geographic_area_codes const regionlessNanpNumbers = ['800', '822', '833', '844', '855', '866', '877', '880', '881', '882', '883', '884', '885', '886', '887', '888', '889']; // keep track of if the window.load event has fired as impossible to check after the fact $(window).on('load', () => { // UPDATE: use a public static field so we can fudge it in the tests $.fn[pluginName].windowLoaded = true; }); function Plugin(element, options) { this.telInput = $(element); this.options = $.extend({}, defaults, options); // event namespace this.ns = `.${pluginName}${id++}`; // Chrome, FF, Safari, IE9+ this.isGoodBrowser = Boolean(element.setSelectionRange); this.hadInitialPlaceholder = Boolean($(element).attr('placeholder')); } Plugin.prototype = { _init() { // if in nationalMode, disable options relating to dial codes if (this.options.nationalMode) { this.options.autoHideDialCode = false; } // if separateDialCode then doesn't make sense to A) insert dial code into input (autoHideDialCode), and B) display national numbers (because we're displaying the country dial code next to them) if (this.options.separateDialCode) { this.options.autoHideDialCode = this.options.nationalMode = false; } // we cannot just test screen size as some smartphones/website meta tags will report desktop resolutions // Note: for some reason jasmine breaks if you put this in the main Plugin function with the rest of these declarations // Note: to target Android Mobiles (and not Tablets), we must find "Android" and "Mobile" this.isMobile = /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); if (this.isMobile) { // trigger the mobile dropdown css $('body').addClass(`iti-mobile ${this.options.page}`); // on mobile, we want a full screen dropdown, so we must append it to the body if (!this.options.dropdownContainer) { this.options.dropdownContainer = 'body'; } } // we return these deferred objects from the _init() call so they can be watched, and then we resolve them when each specific request returns // Note: again, jasmine breaks when I put these in the Plugin function this.autoCountryDeferred = new $.Deferred(); this.utilsScriptDeferred = new $.Deferred(); // in various situations there could be no country selected initially, but we need to be able to assume this variable exists this.selectedCountryData = {}; // process all the data: onlyCountries, excludeCountries, preferredCountries etc this._processCountryData(); // generate the markup this._generateMarkup(); // set the initial state of the input value and the selected flag this._setInitialState(); document.querySelector('#dialCode').value = document.querySelector('.selected-dial-code').innerHTML; // start all of the event listeners: autoHideDialCode, input keydown, selectedFlag click this._initListeners(); // utils script, and auto country this._initRequests(); // return the deferreds return [this.autoCountryDeferred, this.utilsScriptDeferred]; }, /** ****************** * PRIVATE METHODS ******************* */ // prepare all of the country data, including onlyCountries, excludeCountries and preferredCountries options _processCountryData() { // process onlyCountries or excludeCountries array if present this._processAllCountries(); // process the countryCodes map this._processCountryCodes(); // process the preferredCountries this._processPreferredCountries(); }, // add a country code to this.countryCodes _addCountryCode(iso2, dialCode, priority) { if (!(dialCode in this.countryCodes)) { this.countryCodes[dialCode] = []; } const index = priority || 0; this.countryCodes[dialCode][index] = iso2; }, // process onlyCountries or excludeCountries array if present _processAllCountries() { if (this.options.onlyCountries.length) { const lowerCaseOnlyCountries = this.options.onlyCountries.map(country => country.toLowerCase()); this.countries = allCountries.filter(country => lowerCaseOnlyCountries.indexOf(country.iso2) > -1); } else if (this.options.excludeCountries.length) { const lowerCaseExcludeCountries = this.options.excludeCountries.map(country => country.toLowerCase()); this.countries = allCountries.filter(country => lowerCaseExcludeCountries.indexOf(country.iso2) === -1); } else { this.countries = allCountries; } }, // process the countryCodes map _processCountryCodes() { this.countryCodes = {}; for (let i = 0; i < this.countries.length; i++) { const c = this.countries[i]; this._addCountryCode(c.iso2, c.dialCode, c.priority); // area codes if (c.areaCodes) { for (let j = 0; j < c.areaCodes.length; j++) { // full dial code is country code + dial code this._addCountryCode(c.iso2, c.dialCode + c.areaCodes[j]); } } } }, // process preferred countries - iterate through the preferences, fetching the country data for each one _processPreferredCountries() { this.preferredCountries = []; for (let i = 0; i < this.options.preferredCountries.length; i++) { const countryCode = this.options.preferredCountries[i].toLowerCase(); const countryData = this._getCountryData(countryCode, false, true); if (countryData) { this.preferredCountries.push(countryData); } } }, // generate all of the markup for the plugin: the selected flag overlay, and the dropdown _generateMarkup() { // prevent autocomplete as there's no safe, cross-browser event we can react to, so it can easily put the plugin in an inconsistent state e.g. the wrong flag selected for the autocompleted number, which on submit could mean the wrong number is saved (esp in nationalMode) this.telInput.attr('autocomplete', 'off'); // containers (mostly for positioning) let parentClass = 'intl-tel-input'; if (this.options.allowDropdown) { parentClass += ' allow-dropdown'; } if (this.options.separateDialCode) { parentClass += ' separate-dial-code'; } this.telInput.wrap($('
', { class: parentClass })); this.flagsContainer = $('
', { class: 'flag-container' }).insertBefore(this.telInput); // currently selected flag (displayed to left of input) const selectedFlag = $('
', { class: 'selected-flag' }); selectedFlag.appendTo(this.flagsContainer); this.selectedFlagInner = $('
', { class: 'iti-flag' }).appendTo(selectedFlag); if (this.options.separateDialCode) { this.selectedDialCode = $('
', { class: 'selected-dial-code' }).appendTo(selectedFlag); } if (this.options.allowDropdown) { // make element focusable and tab naviagable selectedFlag.attr('tabindex', '0'); // CSS triangle $('
', { class: 'iti-arrow' }).appendTo(selectedFlag); // country dropdown: preferred countries, then divider, then all countries this.countryList = $('
    ', { class: 'country-list hide' }); if (this.preferredCountries.length) { this._appendListItems(this.preferredCountries, 'preferred'); $('
  • ', { class: 'divider' }).appendTo(this.countryList); } this._appendListItems(this.countries, ''); // this is useful in lots of places this.countryListItems = this.countryList.children('.country'); // create dropdownContainer markup if (this.options.dropdownContainer) { this.dropdown = $('
    ', { class: 'intl-tel-input iti-container' }).append(this.countryList); } else { this.countryList.appendTo(this.flagsContainer); } } else { // a little hack so we don't break anything this.countryListItems = $(); } if (this.options.hiddenInput) { this.hiddenInput = $('', { type: 'hidden', name: this.options.hiddenInput }).insertBefore(this.telInput); } }, // add a country
  • to the countryList
      container _appendListItems(countries, className) { // we create so many DOM elements, it is faster to build a temp string // and then add everything to the DOM in one go at the end let tmp = '
      Countries
      '; // for each country for (let i = 0; i < countries.length; i++) { const c = countries[i]; // open the list item tmp += `
    • `; // add the flag tmp += `
      `; // and the country name and dial code tmp += `${c.name}`; // close the list item tmp += '
    • '; } this.countryList.append(tmp); }, // set the initial state of the input value and the selected flag by: // 1. extracting a dial code from the given number // 2. using explicit initialCountry // 3. picking the first preferred country // 4. picking the first country _setInitialState() { const val = this.telInput.val(); // if we already have a dial code, and it's not a regionlessNanp, we can go ahead and set the flag, else fall back to the default country // UPDATE: actually we do want to set the flag for a regionlessNanp in one situation: if we're in nationalMode and there's no initialCountry - otherwise we lose the +1 and we're left with an invalid number if (this._getDialCode(val) && (!this._isRegionlessNanp(val) || this.options.nationalMode && !this.options.initialCountry)) { this._updateFlagFromNumber(val); } else if (this.options.initialCountry !== 'auto') { // see if we should select a flag if (this.options.initialCountry) { this._setFlag(this.options.initialCountry.toLowerCase()); } else { // no dial code and no initialCountry, so default to first in list this.defaultCountry = this.preferredCountries.length ? this.preferredCountries[0].iso2 : this.countries[0].iso2; if (!val) { this._setFlag(this.defaultCountry); } } // if empty and no nationalMode and no autoHideDialCode then insert the default dial code if (!val && !this.options.nationalMode && !this.options.autoHideDialCode && !this.options.separateDialCode) { this.telInput.val(`+${this.selectedCountryData.dialCode}`); } } // NOTE: if initialCountry is set to auto, that will be handled separately // format if (val) { // this wont be run after _updateDialCode as that's only called if no val this._updateValFromNumber(val); } }, // initialise the main event listeners: input keyup, and click selected flag _initListeners() { this._initKeyListeners(); if (this.options.autoHideDialCode) { this._initFocusListeners(); } if (this.options.allowDropdown) { this._initDropdownListeners(); } if (this.hiddenInput) { this._initHiddenInputListener(); } }, // update hidden input on form submit _initHiddenInputListener() { const that = this; const form = this.telInput.closest('form'); if (form.length) { form.submit(() => { that.hiddenInput.val(that.getNumber()); }); } }, // initialise the dropdown listeners _initDropdownListeners() { const that = this; // hack for input nested inside label: clicking the selected-flag to open the dropdown would then automatically trigger a 2nd click on the input which would close it again const label = this.telInput.closest('label'); if (label.length) { label.on(`click${this.ns}`, e => { // if the dropdown is closed, then focus the input, else ignore the click if (that.countryList.hasClass('hide')) { that.telInput.focus(); } else { e.preventDefault(); } }); } // toggle country dropdown on click const selectedFlag = this.selectedFlagInner.parent(); selectedFlag.on(`click${this.ns}`, e => { // only intercept this event if we're opening the dropdown // else let it bubble up to the top ("click-off-to-close" listener) // we cannot just stopPropagation as it may be needed to close another instance if (that.countryList.hasClass('hide') && !that.telInput.prop('disabled') && !that.telInput.prop('readonly')) { that._showDropdown(); } }); // open dropdown list if currently focused this.flagsContainer.on(`keydown${that.ns}`, e => { const isDropdownHidden = that.countryList.hasClass('hide'); if (isDropdownHidden && (e.which == keys.UP || e.which == keys.DOWN || e.which == keys.SPACE || e.which == keys.ENTER)) { // prevent form from being submitted if "ENTER" was pressed e.preventDefault(); // prevent event from being handled again by document e.stopPropagation(); that._showDropdown(); } // allow navigation from dropdown to input on TAB if (e.which == keys.TAB) { that._closeDropdown(); } }); }, // init many requests: utils script / geo ip lookup _initRequests() { const that = this; // if the user has specified the path to the utils script, fetch it on window.load, else resolve if (this.options.utilsScript) { // if the plugin is being initialised after the window.load event has already been fired if ($.fn[pluginName].windowLoaded) { $.fn[pluginName].loadUtils(this.options.utilsScript, this.utilsScriptDeferred); } else { // wait until the load event so we don't block any other requests e.g. the flags image $(window).on('load', () => { $.fn[pluginName].loadUtils(that.options.utilsScript, that.utilsScriptDeferred); }); } } else { this.utilsScriptDeferred.resolve(); } if (this.options.initialCountry === 'auto') { this._loadAutoCountry(); } else { this.autoCountryDeferred.resolve(); } }, // perform the geo ip lookup _loadAutoCountry() { const that = this; // 3 options: // 1) already loaded (we're done) // 2) not already started loading (start) // 3) already started loading (do nothing - just wait for loading callback to fire) if ($.fn[pluginName].autoCountry) { this.handleAutoCountry(); } else if (!$.fn[pluginName].startedLoadingAutoCountry) { // don't do this twice! $.fn[pluginName].startedLoadingAutoCountry = true; if (typeof this.options.geoIpLookup === 'function') { this.options.geoIpLookup(countryCode => { $.fn[pluginName].autoCountry = countryCode.toLowerCase(); // tell all instances the auto country is ready // TODO: this should just be the current instances // UPDATE: use setTimeout in case their geoIpLookup function calls this callback straight away (e.g. if they have already done the geo ip lookup somewhere else). Using setTimeout means that the current thread of execution will finish before executing this, which allows the plugin to finish initialising. setTimeout(() => { $('.intl-tel-input input').intlTelInput('handleAutoCountry'); }); }); } } }, // initialize any key listeners _initKeyListeners() { const that = this; // update flag on keyup // (keep this listener separate otherwise the setTimeout breaks all the tests) this.telInput.on(`keyup${this.ns}`, () => { if (that._updateFlagFromNumber(that.telInput.val())) { that._triggerCountryChange(); } }); // update flag on cut/paste events (now supported in all major browsers) this.telInput.on(`cut${this.ns} paste${this.ns}`, () => { // hack because "paste" event is fired before input is updated setTimeout(() => { if (that._updateFlagFromNumber(that.telInput.val())) { that._triggerCountryChange(); } }); }); }, // adhere to the input's maxlength attr _cap(number) { const max = this.telInput.attr('maxlength'); return max && number.length > max ? number.substr(0, max) : number; }, // listen for mousedown, focus and blur _initFocusListeners() { const that = this; // mousedown decides where the cursor goes, so if we're focusing we must preventDefault as we'll be inserting the dial code, and we want the cursor to be at the end no matter where they click this.telInput.on(`mousedown${this.ns}`, e => { if (!that.telInput.is(':focus') && !that.telInput.val()) { e.preventDefault(); // but this also cancels the focus, so we must trigger that manually that.telInput.focus(); } }); // on focus: if empty, insert the dial code for the currently selected flag this.telInput.on(`focus${this.ns}`, e => { if (!that.telInput.val() && !that.telInput.prop('readonly') && that.selectedCountryData.dialCode) { // insert the dial code that.telInput.val(`+${that.selectedCountryData.dialCode}`); // after auto-inserting a dial code, if the first key they hit is '+' then assume they are entering a new number, so remove the dial code. use keypress instead of keydown because keydown gets triggered for the shift key (required to hit the + key), and instead of keyup because that shows the new '+' before removing the old one that.telInput.one(`keypress.plus${that.ns}`, e => { if (e.which == keys.PLUS) { that.telInput.val(''); } }); // after tabbing in, make sure the cursor is at the end we must use setTimeout to get outside of the focus handler as it seems the selection happens after that setTimeout(() => { const input = that.telInput[0]; if (that.isGoodBrowser) { const len = that.telInput.val().length; input.setSelectionRange(len, len); } }); } }); // on blur or form submit: if just a dial code then remove it const form = this.telInput.prop('form'); if (form) { $(form).on(`submit${this.ns}`, () => { that._removeEmptyDialCode(); }); } this.telInput.on(`blur${this.ns}`, () => { that._removeEmptyDialCode(); }); }, _removeEmptyDialCode() { const value = this.telInput.val(); const startsPlus = value.charAt(0) == '+'; if (startsPlus) { const numeric = this._getNumeric(value); // if just a plus, or if just a dial code if (!numeric || this.selectedCountryData.dialCode == numeric) { this.telInput.val(''); } } // remove the keypress listener we added on focus this.telInput.off(`keypress.plus${this.ns}`); }, // extract the numeric digits from the given string _getNumeric(s) { return s.replace(/\D/g, ''); }, // show the dropdown _showDropdown() { this._setDropdownPosition(); // update highlighting and scroll to active list item const activeListItem = this.countryList.children('.active'); if (activeListItem.length) { this._highlightListItem(activeListItem); this._scrollTo(activeListItem); } // bind all the dropdown-related listeners: mouseover, click, click-off, keydown this._bindDropdownListeners(); // update the arrow this.selectedFlagInner.children('.iti-arrow').addClass('up'); this.telInput.trigger('open:countrydropdown'); }, // decide where to position dropdown (depends on position within viewport, and scroll) _setDropdownPosition() { const that = this; if (this.options.dropdownContainer) { this.dropdown.appendTo(this.options.dropdownContainer); } // show the menu and grab the dropdown height this.dropdownHeight = this.countryList.removeClass('hide').outerHeight(); if (!this.isMobile) { const pos = this.telInput.offset(); const inputTop = pos.top; const windowTop = $(window).scrollTop(); // dropdownFitsBelow = (dropdownBottom < windowBottom) const dropdownFitsBelow = inputTop + this.telInput.outerHeight() + this.dropdownHeight < windowTop + $(window).height(); const dropdownFitsAbove = inputTop - this.dropdownHeight > windowTop; // by default, the dropdown will be below the input. If we want to position it above the input, we add the dropup class. this.countryList.toggleClass('dropup', !dropdownFitsBelow && dropdownFitsAbove); // if dropdownContainer is enabled, calculate postion if (this.options.dropdownContainer) { // by default the dropdown will be directly over the input because it's not in the flow. If we want to position it below, we need to add some extra top value. const extraTop = !dropdownFitsBelow && dropdownFitsAbove ? 0 : this.telInput.innerHeight(); // calculate placement this.dropdown.css({ top: inputTop + extraTop, left: pos.left }); // close menu on window scroll $(window).on(`scroll${this.ns}`, () => { that._closeDropdown(); }); } } }, // we only bind dropdown listeners when the dropdown is open _bindDropdownListeners() { const that = this; // when mouse over a list item, just highlight that one // we add the class "highlight", so if they hit "enter" we know which one to select this.countryList.on(`mouseover${this.ns}`, '.country', function (e) { that._highlightListItem($(this)); }); // listen for country selection this.countryList.on(`click${this.ns}`, '.country', function (e) { that._selectListItem($(this)); }); // click off to close // (except when this initial opening click is bubbling up) // we cannot just stopPropagation as it may be needed to close another instance let isOpening = true; $('html').on(`click${this.ns}`, e => { if (!isOpening) { that._closeDropdown(); } isOpening = false; }); // listen for up/down scrolling, enter to select, or letters to jump to country name. // use keydown as keypress doesn't fire for non-char keys and we want to catch if they // just hit down and hold it to scroll down (no keyup event). // listen on the document because that's where key events are triggered if no input has focus let query = ''; let queryTimer = null; $(document).on(`keydown${this.ns}`, e => { // prevent down key from scrolling the whole page, // and enter key from submitting a form etc e.preventDefault(); if (e.which == keys.UP || e.which == keys.DOWN) { // up and down to navigate that._handleUpDownKey(e.which); } else if (e.which == keys.ENTER) { // enter to select that._handleEnterKey(); } else if (e.which == keys.ESC) { // esc to close that._closeDropdown(); } else if (e.which >= keys.A && e.which <= keys.Z || e.which == keys.SPACE) { // upper case letters (note: keyup/keydown only return upper case letters) // jump to countries that start with the query string if (queryTimer) { clearTimeout(queryTimer); } query += String.fromCharCode(e.which); that._searchForCountry(query); // if the timer hits 1 second, reset the query queryTimer = setTimeout(() => { query = ''; }, 1e3); } }); }, // highlight the next/prev item in the list (and ensure it is visible) _handleUpDownKey(key) { const current = this.countryList.children('.highlight').first(); let next = key == keys.UP ? current.prev() : current.next(); if (next.length) { // skip the divider if (next.hasClass('divider')) { next = key == keys.UP ? next.prev() : next.next(); } this._highlightListItem(next); this._scrollTo(next); } }, // select the currently highlighted item _handleEnterKey() { const currentCountry = this.countryList.children('.highlight').first(); if (currentCountry.length) { this._selectListItem(currentCountry); } }, // find the first list item whose name starts with the query string _searchForCountry(query) { for (let i = 0; i < this.countries.length; i++) { if (this._startsWith(this.countries[i].name, query)) { const listItem = this.countryList.children(`[data-country-code=${this.countries[i].iso2}]`).not('.preferred'); // update highlighting and scroll this._highlightListItem(listItem); this._scrollTo(listItem, true); break; } } }, // check if (uppercase) string a starts with string b _startsWith(a, b) { return a.substr(0, b.length).toUpperCase() == b; }, // update the input's value to the given val (format first if possible) // NOTE: this is called from _setInitialState, handleUtils and setNumber _updateValFromNumber(number) { if (this.options.formatOnDisplay && window.intlTelInputUtils && this.selectedCountryData) { const format = !this.options.separateDialCode && (this.options.nationalMode || number.charAt(0) != '+') ? intlTelInputUtils.numberFormat.NATIONAL : intlTelInputUtils.numberFormat.INTERNATIONAL; number = intlTelInputUtils.formatNumber(number, this.selectedCountryData.iso2, format); } number = this._beforeSetNumber(number); this.telInput.val(number); }, // check if need to select a new flag based on the given number // Note: called from _setInitialState, keyup handler, setNumber _updateFlagFromNumber(number) { // if we're in nationalMode and we already have US/Canada selected, make sure the number starts with a +1 so _getDialCode will be able to extract the area code // update: if we dont yet have selectedCountryData, but we're here (trying to update the flag from the number), that means we're initialising the plugin with a number that already has a dial code, so fine to ignore this bit if (number && this.options.nationalMode && this.selectedCountryData.dialCode == '1' && number.charAt(0) != '+') { if (number.charAt(0) != '1') { number = `1${number}`; } number = `+${number}`; } // try and extract valid dial code from input const dialCode = this._getDialCode(number); let countryCode = null; const numeric = this._getNumeric(number); if (dialCode) { // check if one of the matching countries is already selected const countryCodes = this.countryCodes[this._getNumeric(dialCode)]; const alreadySelected = $.inArray(this.selectedCountryData.iso2, countryCodes) > -1; // check if the given number contains a NANP area code i.e. the only dialCode that could be extracted was +1 (instead of say +1204) and the actual number's length is >=4 const isNanpAreaCode = dialCode == '+1' && numeric.length >= 4; const nanpSelected = this.selectedCountryData.dialCode == '1'; // only update the flag if: // A) NOT (we currently have a NANP flag selected, and the number is a regionlessNanp) // AND // B) either a matching country is not already selected OR the number contains a NANP area code (ensure the flag is set to the first matching country) if (!(nanpSelected && this._isRegionlessNanp(numeric)) && (!alreadySelected || isNanpAreaCode)) { // if using onlyCountries option, countryCodes[0] may be empty, so we must find the first non-empty index for (let j = 0; j < countryCodes.length; j++) { if (countryCodes[j]) { countryCode = countryCodes[j]; break; } } } } else if (number.charAt(0) == '+' && numeric.length) { // invalid dial code, so empty // Note: use getNumeric here because the number has not been formatted yet, so could contain bad chars countryCode = ''; } else if (!number || number == '+') { // empty, or just a plus, so default countryCode = this.defaultCountry; } if (countryCode !== null) { return this._setFlag(countryCode); } return false; }, // check if the given number is a regionless NANP number (expects the number to contain an international dial code) _isRegionlessNanp(number) { const numeric = this._getNumeric(number); if (numeric.charAt(0) == '1') { const areaCode = numeric.substr(1, 3); return $.inArray(areaCode, regionlessNanpNumbers) > -1; } return false; }, // remove highlighting from other list items and highlight the given item _highlightListItem(listItem) { this.countryListItems.removeClass('highlight'); listItem.addClass('highlight'); }, // find the country data for the given country code // the ignoreOnlyCountriesOption is only used during init() while parsing the onlyCountries array _getCountryData(countryCode, ignoreOnlyCountriesOption, allowFail) { const countryList = ignoreOnlyCountriesOption ? allCountries : this.countries; for (let i = 0; i < countryList.length; i++) { if (countryList[i].iso2 == countryCode) { return countryList[i]; } } if (allowFail) { return null; } throw new Error(`No country data for '${countryCode}'`); }, // select the given flag, update the placeholder and the active list item // Note: called from _setInitialState, _updateFlagFromNumber, _selectListItem, setCountry _setFlag(countryCode) { const prevCountry = this.selectedCountryData.iso2 ? this.selectedCountryData : {}; // do this first as it will throw an error and stop if countryCode is invalid this.selectedCountryData = countryCode ? this._getCountryData(countryCode, false, false) : {}; // update the defaultCountry - we only need the iso2 from now on, so just store that if (this.selectedCountryData.iso2) { this.defaultCountry = this.selectedCountryData.iso2; } this.selectedFlagInner.attr('class', `iti-flag ${countryCode}`); // update the selected country's title attribute const title = countryCode ? `${this.selectedCountryData.name}: +${this.selectedCountryData.dialCode}` : 'Unknown'; this.selectedFlagInner.parent().attr('title', title); if (this.options.separateDialCode) { const dialCode = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : ''; const parent = this.telInput.parent(); if (prevCountry.dialCode) { parent.removeClass(`iti-sdc-${prevCountry.dialCode.length + 1}`); } if (dialCode) { parent.addClass(`iti-sdc-${dialCode.length}`); } this.selectedDialCode.text(dialCode); } // and the input's placeholder this._updatePlaceholder(); // update the active list item this.countryListItems.removeClass('active'); if (countryCode) { this.countryListItems.find(`.iti-flag.${countryCode}`).first().closest('.country').addClass('active'); } // return if the flag has changed or not return prevCountry.iso2 !== countryCode; }, // update the input placeholder to an example number from the currently selected country _updatePlaceholder() { const shouldSetPlaceholder = this.options.autoPlaceholder === 'aggressive' || !this.hadInitialPlaceholder && (this.options.autoPlaceholder === true || this.options.autoPlaceholder === 'polite'); if (window.intlTelInputUtils && shouldSetPlaceholder) { const numberType = intlTelInputUtils.numberType[this.options.placeholderNumberType]; let placeholder = this.selectedCountryData.iso2 ? intlTelInputUtils.getExampleNumber(this.selectedCountryData.iso2, this.options.nationalMode, numberType) : ''; placeholder = this._beforeSetNumber(placeholder); if (typeof this.options.customPlaceholder === 'function') { placeholder = this.options.customPlaceholder(placeholder, this.selectedCountryData); } this.telInput.attr('placeholder', placeholder); } }, // called when the user selects a list item from the dropdown _selectListItem(listItem) { // update selected flag and active list item const flagChanged = this._setFlag(listItem.attr('data-country-code')); this._closeDropdown(); this._updateDialCode(listItem.attr('data-dial-code'), true); // focus the input this.telInput.focus(); // put cursor at end - this fix is required for FF and IE11 (with nationalMode=false i.e. auto inserting dial code), who try to put the cursor at the beginning the first time if (this.isGoodBrowser) { const len = this.telInput.val().length; this.telInput[0].setSelectionRange(len, len); } if (flagChanged) { this._triggerCountryChange(); } }, // close the dropdown and unbind any listeners _closeDropdown() { this.countryList.addClass('hide'); // update the arrow this.selectedFlagInner.children('.iti-arrow').removeClass('up'); // unbind key events $(document).off(this.ns); // unbind click-off-to-close $('html').off(this.ns); // unbind hover and click listeners this.countryList.off(this.ns); // remove menu from container if (this.options.dropdownContainer) { if (!this.isMobile) { $(window).off(`scroll${this.ns}`); } this.dropdown.detach(); } this.telInput.trigger('close:countrydropdown'); }, // check if an element is visible within it's container, else scroll until it is _scrollTo(element, middle) { const container = this.countryList; const containerHeight = container.height(); const containerTop = container.offset().top; const containerBottom = containerTop + containerHeight; const elementHeight = element.outerHeight(); const elementTop = element.offset().top; const elementBottom = elementTop + elementHeight; let newScrollTop = elementTop - containerTop + container.scrollTop(); const middleOffset = containerHeight / 2 - elementHeight / 2; if (elementTop < containerTop) { // scroll up if (middle) { newScrollTop -= middleOffset; } container.scrollTop(newScrollTop); } else if (elementBottom > containerBottom) { // scroll down if (middle) { newScrollTop += middleOffset; } const heightDifference = containerHeight - elementHeight; container.scrollTop(newScrollTop - heightDifference); } }, // replace any existing dial code with the new one // Note: called from _selectListItem and setCountry _updateDialCode(newDialCode, hasSelectedListItem) { const inputVal = this.telInput.val(); let newNumber; // save having to pass this every time newDialCode = `+${newDialCode}`; if (inputVal.charAt(0) == '+') { // there's a plus so we're dealing with a replacement (doesn't matter if nationalMode or not) const prevDialCode = this._getDialCode(inputVal); if (prevDialCode) { // current number contains a valid dial code, so replace it newNumber = inputVal.replace(prevDialCode, newDialCode); } else { // current number contains an invalid dial code, so ditch it // (no way to determine where the invalid dial code ends and the rest of the number begins) newNumber = newDialCode; } } else if (this.options.nationalMode || this.options.separateDialCode) { // don't do anything return; } else { // nationalMode is disabled if (inputVal) { // there is an existing value with no dial code: prefix the new dial code newNumber = newDialCode + inputVal; } else if (hasSelectedListItem || !this.options.autoHideDialCode) { // no existing value and either they've just selected a list item, or autoHideDialCode is disabled: insert new dial code newNumber = newDialCode; } else { return; } } this.telInput.val(newNumber); }, // try and extract a valid international dial code from a full telephone number // Note: returns the raw string inc plus character and any whitespace/dots etc _getDialCode(number) { let dialCode = ''; // only interested in international numbers (starting with a plus) if (number.charAt(0) == '+') { let numericChars = ''; // iterate over chars for (let i = 0; i < number.length; i++) { const c = number.charAt(i); // if char is number if ($.isNumeric(c)) { numericChars += c; // if current numericChars make a valid dial code if (this.countryCodes[numericChars]) { // store the actual raw string (useful for matching later) dialCode = number.substr(0, i + 1); } // longest dial code is 4 chars if (numericChars.length == 4) { break; } } } } return dialCode; }, // get the input val, adding the dial code if separateDialCode is enabled _getFullNumber() { const val = $.trim(this.telInput.val()); const dialCode = this.selectedCountryData.dialCode; let prefix; const numericVal = this._getNumeric(val); // normalized means ensure starts with a 1, so we can match against the full dial code const normalizedVal = numericVal.charAt(0) == '1' ? numericVal : `1${numericVal}`; if (this.options.separateDialCode) { prefix = `+${dialCode}`; } else if (val.charAt(0) != '+' && val.charAt(0) != '1' && dialCode && dialCode.charAt(0) == '1' && dialCode.length == 4 && dialCode != normalizedVal.substr(0, 4)) { // if the user has entered a national NANP number, then ensure it includes the full dial code / area code prefix = dialCode.substr(1); } else { prefix = ''; } return prefix + val; }, // remove the dial code if separateDialCode is enabled _beforeSetNumber(number) { if (this.options.separateDialCode) { let dialCode = this._getDialCode(number); if (dialCode) { // US dialCode is "+1", which is what we want // CA dialCode is "+1 123", which is wrong - should be "+1" (as it has multiple area codes) // AS dialCode is "+1 684", which is what we want // Solution: if the country has area codes, then revert to just the dial code if (this.selectedCountryData.areaCodes !== null) { dialCode = `+${this.selectedCountryData.dialCode}`; } // a lot of numbers will have a space separating the dial code and the main number, and some NANP numbers will have a hyphen e.g. +1 684-733-1234 - in both cases we want to get rid of it // NOTE: don't just trim all non-numerics as may want to preserve an open parenthesis etc const start = number[dialCode.length] === ' ' || number[dialCode.length] === '-' ? dialCode.length + 1 : dialCode.length; number = number.substr(start); } } return this._cap(number); }, // trigger the 'countrychange' event _triggerCountryChange() { this.telInput.trigger('countrychange', this.selectedCountryData); }, /** ************************ * SECRET PUBLIC METHODS ************************* */ // this is called when the geoip call returns handleAutoCountry() { if (this.options.initialCountry === 'auto') { // we must set this even if there is an initial val in the input: in case the initial val is invalid and they delete it - they should see their auto country this.defaultCountry = $.fn[pluginName].autoCountry; // if there's no initial value in the input, then update the flag if (!this.telInput.val()) { this.setCountry(this.defaultCountry); } this.autoCountryDeferred.resolve(); } }, // this is called when the utils request completes handleUtils() { // if the request was successful if (window.intlTelInputUtils) { // if there's an initial value in the input, then format it if (this.telInput.val()) { this._updateValFromNumber(this.telInput.val()); } this._updatePlaceholder(); } this.utilsScriptDeferred.resolve(); }, /** ****************** * PUBLIC METHODS ******************* */ // remove plugin destroy() { if (this.allowDropdown) { // make sure the dropdown is closed (and unbind listeners) this._closeDropdown(); // click event to open dropdown this.selectedFlagInner.parent().off(this.ns); // label click hack this.telInput.closest('label').off(this.ns); } // unbind submit event handler on form if (this.options.autoHideDialCode) { const form = this.telInput.prop('form'); if (form) { $(form).off(this.ns); } } // unbind all events: key events, and focus/blur events if autoHideDialCode=true this.telInput.off(this.ns); // remove markup (but leave the original input) const container = this.telInput.parent(); container.before(this.telInput).remove(); }, // get the extension from the current number getExtension() { if (window.intlTelInputUtils) { return intlTelInputUtils.getExtension(this._getFullNumber(), this.selectedCountryData.iso2); } return ''; }, // format the number to the given format getNumber(format) { if (window.intlTelInputUtils) { return intlTelInputUtils.formatNumber(this._getFullNumber(), this.selectedCountryData.iso2, format); } return ''; }, // get the type of the entered number e.g. landline/mobile getNumberType() { if (window.intlTelInputUtils) { return intlTelInputUtils.getNumberType(this._getFullNumber(), this.selectedCountryData.iso2); } return -99; }, // get the country data for the currently selected flag getSelectedCountryData() { return this.selectedCountryData; }, // get the validation error getValidationError() { if (window.intlTelInputUtils) { return intlTelInputUtils.getValidationError(this._getFullNumber(), this.selectedCountryData.iso2); } return -99; }, // validate the input val - assumes the global function isValidNumber (from utilsScript) isValidNumber() { const val = $.trim(this._getFullNumber()); const countryCode = this.options.nationalMode ? this.selectedCountryData.iso2 : ''; return window.intlTelInputUtils ? intlTelInputUtils.isValidNumber(val, countryCode) : null; }, // update the selected flag, and update the input val accordingly setCountry(countryCode) { countryCode = countryCode.toLowerCase(); // check if already selected if (!this.selectedFlagInner.hasClass(countryCode)) { this._setFlag(countryCode); this._updateDialCode(this.selectedCountryData.dialCode, false); this._triggerCountryChange(); } }, // set the input value and update the flag setNumber(number) { // we must update the flag first, which updates this.selectedCountryData, which is used for formatting the number before displaying it const flagChanged = this._updateFlagFromNumber(number); this._updateValFromNumber(number); if (flagChanged) { this._triggerCountryChange(); } }, // set the placeholder number typ setPlaceholderNumberType(type) { this.options.placeholderNumberType = type; this._updatePlaceholder(); } }; // using https://github.com/jquery-boilerplate/jquery-boilerplate/wiki/Extending-jQuery-Boilerplate // (adapted to allow public functions) $.fn[pluginName] = function (options) { const args = arguments; // Is the first parameter an object (options), or was omitted, // instantiate a new instance of the plugin. if (options === undefined || typeof options === 'object') { // collect all of the deferred objects for all instances created with this selector const deferreds = []; this.each(function () { if (!$.data(this, `plugin_${pluginName}`)) { const instance = new Plugin(this, options); const instanceDeferreds = instance._init(); // we now have 2 deffereds: 1 for auto country, 1 for utils script deferreds.push(instanceDeferreds[0]); deferreds.push(instanceDeferreds[1]); $.data(this, `plugin_${pluginName}`, instance); } }); // return the promise from the "master" deferred object that tracks all the others return $.when.apply(null, deferreds); } if (typeof options === 'string' && options[0] !== '_') { // If the first parameter is a string and it doesn't start // with an underscore or "contains" the `init`-function, // treat this as a call to a public method. // Cache the method call to make it possible to return a value let returns; this.each(function () { const instance = $.data(this, `plugin_${pluginName}`); // Tests that there's already a plugin-instance // and checks that the requested public method exists if (instance instanceof Plugin && typeof instance[options] === 'function') { // Call the method of our plugin instance, // and pass it the supplied arguments. returns = instance[options](...Array.prototype.slice.call(args, 1)); } // Allow instances to be destroyed via the 'destroy' method if (options === 'destroy') { $.data(this, `plugin_${pluginName}`, null); } }); // If the earlier cached method gives a value back return the value, // otherwise return this to preserve chainability. return returns !== undefined ? returns : this; } }; /** ****************** * STATIC METHODS ******************* */ // get the country data object $.fn[pluginName].getCountryData = function () { return allCountries; }; // load the utils script $.fn[pluginName].loadUtils = function (path, utilsScriptDeferred) { if (!$.fn[pluginName].loadedUtilsScript) { // don't do this twice! (dont just check if window.intlTelInputUtils exists as if init plugin multiple times in quick succession, it may not have finished loading yet) $.fn[pluginName].loadedUtilsScript = true; // dont use $.getScript as it prevents caching $.ajax({ type: 'GET', url: path, complete() { // tell all instances that the utils request is complete $('.intl-tel-input input').intlTelInput('handleUtils'); }, dataType: 'script', cache: true }); } else if (utilsScriptDeferred) { utilsScriptDeferred.resolve(); } }; // default options $.fn[pluginName].defaults = defaults; // version $.fn[pluginName].version = '12.1.3'; // Array of country objects for the flag dropdown. // Here is the criteria for the plugin to support a given country/territory // - It has an iso2 code: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 // - It has it's own country calling code (it is not a sub-region of another country): https://en.wikipedia.org/wiki/List_of_country_calling_codes // - It has a flag in the region-flags project: https://github.com/behdad/region-flags/tree/gh-pages/png // - It is supported by libphonenumber (it must be listed on this page): https://github.com/googlei18n/libphonenumber/blob/master/resources/ShortNumberMetadata.xml // Each country array has the following information: // [ // Country name, // iso2 code, // International dial code, // Order (if >1 country with same dial code), // Area codes // ] var allCountries = [['Afghanistan', 'af', '93'], ['Albania', 'al', '355'], ['Algeria', 'dz', '213'], ['American Samoa', 'as', '1684'], ['Andorra', 'ad', '376'], ['Angola', 'ao', '244'], ['Anguilla', 'ai', '1264'], ['Antigua and Barbuda', 'ag', '1268'], ['Argentina', 'ar', '54'], ['Armenia', 'am', '374'], ['Aruba', 'aw', '297'], ['Australia', 'au', '61', 0], ['Austria', 'at', '43'], ['Azerbaijan', 'az', '994'], ['Bahamas', 'bs', '1242'], ['Bahrain', 'bh', '973'], ['Bangladesh', 'bd', '880'], ['Barbados', 'bb', '1246'], ['Belarus', 'by', '375'], ['Belgium', 'be', '32'], ['Belize', 'bz', '501'], ['Benin', 'bj', '229'], ['Bermuda', 'bm', '1441'], ['Bhutan', 'bt', '975'], ['Bolivia', 'bo', '591'], ['Bosnia and Herzegovina', 'ba', '387'], ['Botswana', 'bw', '267'], ['Brazil', 'br', '55'], ['British Indian Ocean Territory', 'io', '246'], ['British Virgin Islands', 'vg', '1284'], ['Brunei', 'bn', '673'], ['Bulgaria', 'bg', '359'], ['Burkina Faso', 'bf', '226'], ['Burundi', 'bi', '257'], ['Cambodia', 'kh', '855'], ['Cameroon', 'cm', '237'], ['Canada', 'ca', '1', 1, ['204', '226', '236', '249', '250', '289', '306', '343', '365', '387', '403', '416', '418', '431', '437', '438', '450', '506', '514', '519', '548', '579', '581', '587', '604', '613', '639', '647', '672', '705', '709', '742', '778', '780', '782', '807', '819', '825', '867', '873', '902', '905']], ['Cape Verde', 'cv', '238'], ['Caribbean Netherlands', 'bq', '599', 1], ['Cayman Islands', 'ky', '1345'], ['Central African Republic', 'cf', '236'], ['Chad', 'td', '235'], ['Chile', 'cl', '56'], ['China', 'cn', '86'], ['Christmas Island', 'cx', '61', 2], ['Cocos (Keeling) Islands', 'cc', '61', 1], ['Colombia', 'co', '57'], ['Comoros', 'km', '269'], ['Congo (DRC)', 'cd', '243'], ['Congo (Republic)', 'cg', '242'], ['Cook Islands', 'ck', '682'], ['Costa Rica', 'cr', '506'], ['Côte d’Ivoire', 'ci', '225'], ['Croatia', 'hr', '385'], ['Cuba', 'cu', '53'], ['Curaçao', 'cw', '599', 0], ['Cyprus', 'cy', '357'], ['Czech Republic', 'cz', '420'], ['Denmark', 'dk', '45'], ['Djibouti', 'dj', '253'], ['Dominica', 'dm', '1767'], ['Dominican Republic', 'do', '1', 2, ['809', '829', '849']], ['Ecuador', 'ec', '593'], ['Egypt', 'eg', '20'], ['El Salvador', 'sv', '503'], ['Equatorial Guinea', 'gq', '240'], ['Eritrea', 'er', '291'], ['Estonia', 'ee', '372'], ['Ethiopia', 'et', '251'], ['Falkland Islands', 'fk', '500'], ['Faroe Islands', 'fo', '298'], ['Fiji', 'fj', '679'], ['Finland', 'fi', '358', 0], ['France', 'fr', '33'], ['French Guiana', 'gf', '594'], ['French Polynesia', 'pf', '689'], ['Gabon', 'ga', '241'], ['Gambia', 'gm', '220'], ['Georgia', 'ge', '995'], ['Germany', 'de', '49'], ['Ghana', 'gh', '233'], ['Gibraltar', 'gi', '350'], ['Greece', 'gr', '30'], ['Greenland', 'gl', '299'], ['Grenada', 'gd', '1473'], ['Guadeloupe', 'gp', '590', 0], ['Guam', 'gu', '1671'], ['Guatemala', 'gt', '502'], ['Guernsey', 'gg', '44', 1], ['Guinea', 'gn', '224'], ['Guinea-Bissau', 'gw', '245'], ['Guyana', 'gy', '592'], ['Haiti', 'ht', '509'], ['Honduras', 'hn', '504'], ['Hong Kong', 'hk', '852'], ['Hungary', 'hu', '36'], ['Iceland', 'is', '354'], ['India', 'in', '91'], ['Indonesia', 'id', '62'], ['Iran', 'ir', '98'], ['Iraq', 'iq', '964'], ['Ireland', 'ie', '353'], ['Isle of Man', 'im', '44', 2], ['Israel', 'il', '972'], ['Italy', 'it', '39', 0], ['Jamaica', 'jm', '1876'], ['Japan', 'jp', '81'], ['Jersey', 'je', '44', 3], ['Jordan', 'jo', '962'], ['Kazakhstan', 'kz', '7', 1], ['Kenya', 'ke', '254'], ['Kiribati', 'ki', '686'], ['Kosovo', 'xk', '383'], ['Kuwait', 'kw', '965'], ['Kyrgyzstan', 'kg', '996'], ['Laos', 'la', '856'], ['Latvia', 'lv', '371'], ['Lebanon', 'lb', '961'], ['Lesotho', 'ls', '266'], ['Liberia', 'lr', '231'], ['Libya', 'ly', '218'], ['Liechtenstein', 'li', '423'], ['Lithuania', 'lt', '370'], ['Luxembourg', 'lu', '352'], ['Macau', 'mo', '853'], ['Macedonia', 'mk', '389'], ['Madagascar', 'mg', '261'], ['Malawi', 'mw', '265'], ['Malaysia', 'my', '60'], ['Maldives', 'mv', '960'], ['Mali', 'ml', '223'], ['Malta', 'mt', '356'], ['Marshall Islands', 'mh', '692'], ['Martinique', 'mq', '596'], ['Mauritania', 'mr', '222'], ['Mauritius', 'mu', '230'], ['Mayotte', 'yt', '262', 1], ['Mexico', 'mx', '52'], ['Micronesia', 'fm', '691'], ['Moldova', 'md', '373'], ['Monaco', 'mc', '377'], ['Mongolia', 'mn', '976'], ['Montenegro', 'me', '382'], ['Montserrat', 'ms', '1664'], ['Morocco', 'ma', '212', 0], ['Mozambique', 'mz', '258'], ['Myanmar (Burma)', 'mm', '95'], ['Namibia', 'na', '264'], ['Nauru', 'nr', '674'], ['Nepal', 'np', '977'], ['Netherlands', 'nl', '31'], ['New Caledonia', 'nc', '687'], ['New Zealand', 'nz', '64'], ['Nicaragua', 'ni', '505'], ['Niger', 'ne', '227'], ['Nigeria', 'ng', '234'], ['Niue', 'nu', '683'], ['Norfolk Island', 'nf', '672'], ['North Korea', 'kp', '850'], ['Northern Mariana Islands', 'mp', '1670'], ['Norway', 'no', '47', 0], ['Oman', 'om', '968'], ['Pakistan', 'pk', '92'], ['Palau', 'pw', '680'], ['Palestine', 'ps', '970'], ['Panama', 'pa', '507'], ['Papua New Guinea', 'pg', '675'], ['Paraguay', 'py', '595'], ['Peru', 'pe', '51'], ['Philippines', 'ph', '63'], ['Poland', 'pl', '48'], ['Portugal', 'pt', '351'], ['Puerto Rico', 'pr', '1', 3, ['787', '939']], ['Qatar', 'qa', '974'], ['Réunion', 're', '262', 0], ['Romania', 'ro', '40'], ['Russia', 'ru', '7', 0], ['Rwanda', 'rw', '250'], ['Saint Barthélemy', 'bl', '590', 1], ['Saint Helena', 'sh', '290'], ['Saint Kitts and Nevis', 'kn', '1869'], ['Saint Lucia', 'lc', '1758'], ['Saint Martin', 'mf', '590', 2], ['Saint Pierre and Miquelon', 'pm', '508'], ['Saint Vincent and the Grenadines', 'vc', '1784'], ['Samoa', 'ws', '685'], ['San Marino', 'sm', '378'], ['São Tomé and Príncipe', 'st', '239'], ['Saudi Arabia', 'sa', '966'], ['Senegal', 'sn', '221'], ['Serbia', 'rs', '381'], ['Seychelles', 'sc', '248'], ['Sierra Leone', 'sl', '232'], ['Singapore', 'sg', '65'], ['Sint Maarten', 'sx', '1721'], ['Slovakia', 'sk', '421'], ['Slovenia', 'si', '386'], ['Solomon Islands', 'sb', '677'], ['Somalia', 'so', '252'], ['South Africa', 'za', '27'], ['South Korea', 'kr', '82'], ['South Sudan', 'ss', '211'], ['Spain', 'es', '34'], ['Sri Lanka', 'lk', '94'], ['Sudan', 'sd', '249'], ['Suriname', 'sr', '597'], ['Svalbard and Jan Mayen', 'sj', '47', 1], ['Swaziland', 'sz', '268'], ['Sweden', 'se', '46'], ['Switzerland', 'ch', '41'], ['Syria', 'sy', '963'], ['Taiwan', 'tw', '886'], ['Tajikistan', 'tj', '992'], ['Tanzania', 'tz', '255'], ['Thailand', 'th', '66'], ['Timor-Leste', 'tl', '670'], ['Togo', 'tg', '228'], ['Tokelau', 'tk', '690'], ['Tonga', 'to', '676'], ['Trinidad and Tobago', 'tt', '1868'], ['Tunisia', 'tn', '216'], ['Turkey', 'tr', '90'], ['Turkmenistan', 'tm', '993'], ['Turks and Caicos Islands', 'tc', '1649'], ['Tuvalu', 'tv', '688'], ['U.S. Virgin Islands', 'vi', '1340'], ['Uganda', 'ug', '256'], ['Ukraine', 'ua', '380'], ['United Arab Emirates', 'ae', '971'], ['United Kingdom', 'gb', '44', 0], ['United States', 'us', '1', 0], ['Uruguay', 'uy', '598'], ['Uzbekistan', 'uz', '998'], ['Vanuatu', 'vu', '678'], ['Vatican City', 'va', '39', 1], ['Venezuela', 've', '58'], ['Vietnam', 'vn', '84'], ['Wallis and Futuna', 'wf', '681'], ['Western Sahara', 'eh', '212', 1], ['Yemen', 'ye', '967'], ['Zambia', 'zm', '260'], ['Zimbabwe', 'zw', '263'], ['Åland Islands', 'ax', '358', 1]]; // loop over all of the countries above for (let i = 0; i < allCountries.length; i++) { const c = allCountries[i]; allCountries[i] = { name: c[0], iso2: c[1], dialCode: c[2], priority: c[3] || 0, areaCodes: c[4] || null }; } }); /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/menu.js": /*!***************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/menu.js ***! \***************************************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./cartridges/app_storefront_base/cartridge/client/default/js/main.js (referenced with cjs require) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _util_domutils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/domutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); /* harmony import */ var _flyoutUnderHeader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./flyoutUnderHeader */ "./cartridges/app_tfg/cartridge/client/default/js/components/flyoutUnderHeader.js"); // eslint-disable-line import/named const CLASSES = { MENU: 'nav-menu', MENU_LEFT: 'nav-menu--left', MENU_RIGHT: 'nav-menu--right', MENU_VISIBLE: 'nav-menu--visible', MENU_TOGGLED: 'nav-menu--toggled', BACKGROUND_VISIBLE: 'show', MENU_TOGGLER_ACTIVE: 'expanded', BODY_MENU_TOGGLED_LEFT: 'nav-menu-toggled--left', BODY_MENU_TOGGLED_RIGHT: 'nav-menu-toggled--right', MENU_SLIDE: 'nav-menu--slide', TOUCH_FOCUS: 'touch-focus', CATEGORY_COLLAPSE: 'collapse' }; const ATTRIBUTES = { TOGGLE: 'data-toggle', DISABLED_TOGGLE: 'data-mobile-toggle' }; const SELECTORS = { MENU: `.${CLASSES.MENU}`, MENU_BODY: '.nav-menu__body', MENU_LINK: '.nav-menu__item-link', BACK_LINK: '.nav-menu__back-link', BACK_LINK_CONTAINER: '.nav-menu__back', SECOND_LEVEL_CATEGORIES: '.nav-menu__body .nav-menu__items--level-2', THIRD_LEVEL_CATEGORIES: '.nav-menu__body .nav-menu__items--level-3', MENU_TOGGLES: `[data-toggle='.${CLASSES.MENU}']`, BACKGROUND: '.modal-background', TOP_LEVEL_LINK: '.nav-menu__body .nav-menu__items--level-1 > .nav-menu__item > .nav-menu__item-link', TOGGLE: `[${ATTRIBUTES.TOGGLE}]`, DISABLED_TOGGLE: `[${ATTRIBUTES.DISABLED_TOGGLE}]`, get TOP_LEVEL_NAV_MENU_LINKS() { return `${this.MENU_LINK}--level-1`; }, get SECOND_LEVEL_NAV_MENU_LINKS() { return `${this.MENU_LINK}--level-2`; }, get EXPANDED_NAV_MENU_LINKS() { return `${this.MENU_LINK}[aria-expanded="true"]`; }, get COLLAPSE_NAV_MENU_LINKS() { return `${this.TOP_LEVEL_NAV_MENU_LINKS}, ${this.SECOND_LEVEL_NAV_MENU_LINKS}`; } }; const slideMenu = menu => menu.classList.contains(CLASSES.MENU_SLIDE); const hasSubMenus = el => el.parentElement.querySelectorAll(SELECTORS.SECOND_LEVEL_CATEGORIES).length > 0; const hideMenuOnTypeChange = (menu, menuToggles) => { window.addEventListener('resize', () => { if (Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["isLG"])()) { const activeCollapseLinks = menu.querySelectorAll(SELECTORS.EXPANDED_NAV_MENU_LINKS); // Prevents expanded subcategory levels from leaving the desktop-style menu invisible activeCollapseLinks.forEach(link => { let action; if (link.matches(SELECTORS.TOP_LEVEL_NAV_MENU_LINKS)) { action = 'hide'; } else if (link.matches(SELECTORS.SECOND_LEVEL_NAV_MENU_LINKS)) { action = 'show'; } if (action) { jquery__WEBPACK_IMPORTED_MODULE_0___default()(link.dataset.target).collapse(action); } }); // Closest the mobile-style menu if (menu.classList.contains(CLASSES.MENU_VISIBLE)) { menuToggles[0].click(); } } }); }; const toggleCollapsesBehavior = menu => { ['load', 'resize'].forEach(event => { window.addEventListener(event, () => { const collapseSelector = slideMenu(menu) ? SELECTORS.COLLAPSE_NAV_MENU_LINKS : SELECTORS.TOP_LEVEL_NAV_MENU_LINKS; const collapseTriggers = document.querySelectorAll(collapseSelector); const menuSelector = document.querySelector(SELECTORS.MENU); const menuCategories = document.querySelectorAll(SELECTORS.THIRD_LEVEL_CATEGORIES); menuCategories.forEach(categoryList => { if (Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["isLG"])() || !slideMenu(menu)) { categoryList.classList.remove(CLASSES.CATEGORY_COLLAPSE); } else { categoryList.classList.add(CLASSES.CATEGORY_COLLAPSE); } }); if (Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["isLG"])()) { menuSelector.classList.remove(CLASSES.MENU_TOGGLED); } collapseTriggers.forEach(trigger => { if (Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["isLG"])() || !hasSubMenus(trigger)) { trigger.setAttribute(ATTRIBUTES.DISABLED_TOGGLE, 'collapse'); trigger.removeAttribute(ATTRIBUTES.TOGGLE); } else { trigger.setAttribute(ATTRIBUTES.TOGGLE, 'collapse'); trigger.removeAttribute(ATTRIBUTES.DISABLED_TOGGLE); } }); }); }); }; const initSlideBehavior = menu => { if (slideMenu(menu)) { document.querySelectorAll(SELECTORS.TOP_LEVEL_LINK).forEach(link => { link.addEventListener('click', () => { if (!Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["isLG"])() && hasSubMenus(link)) { menu.classList.add(CLASSES.MENU_TOGGLED); } }); }); document.querySelectorAll(SELECTORS.BACK_LINK).forEach(link => { link.addEventListener('click', () => { menu.classList.remove(CLASSES.MENU_TOGGLED); }); }); } }; const getMenuToggledBodyClass = menu => { switch (true) { case menu.classList.contains(CLASSES.MENU_LEFT): return CLASSES.BODY_MENU_TOGGLED_LEFT; case menu.classList.contains(CLASSES.MENU_RIGHT): return CLASSES.BODY_MENU_TOGGLED_RIGHT; default: return null; } }; const restoreMobileMenuInitialState = menu => { setTimeout(() => { if (slideMenu(menu)) { menu.classList.remove(CLASSES.MENU_TOGGLED); jquery__WEBPACK_IMPORTED_MODULE_0___default()(SELECTORS.BACK_LINK_CONTAINER).collapse('hide'); jquery__WEBPACK_IMPORTED_MODULE_0___default()(SELECTORS.SECOND_LEVEL_CATEGORIES).collapse('hide'); jquery__WEBPACK_IMPORTED_MODULE_0___default()(SELECTORS.THIRD_LEVEL_CATEGORIES).collapse('show'); } else { jquery__WEBPACK_IMPORTED_MODULE_0___default()(SELECTORS.COLLAPSE_NAV_MENU_LINKS).collapse('hide'); } }, 500); // Ensures the reset is executed after the menu has closed, so it's not visible to the customer }; const toggleMenuElements = (menu, background, menuToggles, state) => { const menuBody = document.querySelector(SELECTORS.MENU_BODY); if (typeof state !== 'undefined') { menu.classList.toggle(CLASSES.MENU_VISIBLE, state); background.classList.toggle(CLASSES.BACKGROUND_VISIBLE, state); menuToggles.forEach(el => { el.classList.toggle(CLASSES.MENU_TOGGLER_ACTIVE, state); }); if (Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["isLG"])()) { document.body.classList.remove(getMenuToggledBodyClass(menu)); } else { document.body.classList.toggle(getMenuToggledBodyClass(menu), state); } } else { menu.classList.toggle(CLASSES.MENU_VISIBLE); background.classList.toggle(CLASSES.BACKGROUND_VISIBLE); menuToggles.forEach(el => { el.classList.toggle(CLASSES.MENU_TOGGLER_ACTIVE); }); if (Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["isLG"])()) { document.body.classList.remove(getMenuToggledBodyClass(menu)); } else { document.body.classList.toggle(getMenuToggledBodyClass(menu)); } } if (menu.classList.contains(CLASSES.MENU_VISIBLE)) { document.dispatchEvent(new CustomEvent(_flyoutUnderHeader__WEBPACK_IMPORTED_MODULE_2__["EVENTS"].FLYOUT_OPEN, { detail: { content: menuBody } })); } else { document.dispatchEvent(new CustomEvent(_flyoutUnderHeader__WEBPACK_IMPORTED_MODULE_2__["EVENTS"].FLYOUT_CLOSE, { detail: { content: menuBody } })); restoreMobileMenuInitialState(menu); } }; const initMobileMenu = (menu, menuToggles, background) => { initSlideBehavior(menu); Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["onEvent"])(document, 'click', SELECTORS.MENU_TOGGLES, () => { toggleMenuElements(menu, background, menuToggles); }); document.addEventListener(_flyoutUnderHeader__WEBPACK_IMPORTED_MODULE_2__["EVENTS"].FLYOUT_OPEN, e => { const menuBody = document.querySelector(SELECTORS.MENU_BODY); if (menu.classList.contains(CLASSES.MENU_VISIBLE) && e.detail.content !== menuBody) { toggleMenuElements(menu, background, menuToggles, false); } }); }; const initTouchNavigation = () => { const links = Array.from(document.querySelectorAll(SELECTORS.TOP_LEVEL_LINK)); links.forEach(link => { if (!hasSubMenus(link)) { return; } link.addEventListener('touchstart', e => { if (!link.getAttribute(ATTRIBUTES.TOGGLE) && !link.classList.contains(CLASSES.TOUCH_FOCUS)) { e.preventDefault(); links.forEach(currentLink => { currentLink.classList.toggle(CLASSES.TOUCH_FOCUS, currentLink === link); }); } }); link.addEventListener('click', e => { setTimeout(() => { // Move to the next tick to give time to the touchstart handler to add the class if (link.classList.contains(CLASSES.TOUCH_FOCUS)) { e.preventDefault(); link.classList.remove(CLASSES.TOUCH_FOCUS); } }); }); }); }; /* harmony default export */ __webpack_exports__["default"] = (() => { const menu = document.querySelector(SELECTORS.MENU); const background = document.querySelector(SELECTORS.BACKGROUND); const menuToggles = document.querySelectorAll(SELECTORS.MENU_TOGGLES); if (menu && background && menuToggles) { initMobileMenu(menu, menuToggles, background); hideMenuOnTypeChange(menu, menuToggles); toggleCollapsesBehavior(menu); initTouchNavigation(); } }); /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/miniCart.js": /*!*******************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/miniCart.js ***! \*******************************************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./cartridges/app_storefront_base/cartridge/client/default/js/main.js (referenced with cjs require) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _util_fetchutils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/fetchutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/fetchutils.js"); /* harmony import */ var _util_domutils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/domutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); /* harmony import */ var _flyoutUnderHeader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./flyoutUnderHeader */ "./cartridges/app_tfg/cartridge/client/default/js/components/flyoutUnderHeader.js"); /* harmony import */ var _header__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./header */ "./cartridges/app_tfg/cartridge/client/default/js/components/header.js"); // eslint-disable-line import/named // eslint-disable-line import/named const CONSTANTS = { TOGGLE_CLASS: 'show', MIN_BODY_HEIGHT: 75, HOVER_TIMEOUT: 400, COUNT_UPDATE_DISPLAY_TIME: 3000 }; const CLASSES = { LINK_HIGHLIGHTED: 'minicart-link--active' }; const SELECTORS = { PARENT: '.minicart', LINK: '.minicart-link', CONTAINER: '.minicart__pane', CONTAINER_INNER: '.minicart__container', CONTENT: '.minicart__content', HEADER: '.minicart__header', BODY: '.minicart__body', FOOTER: '.minicart__footer', CART_BTN: '.checkout-btn', CLOSE_BUTTON: '.minicart__close-btn', OPEN_BUTTON: '.header-element.minicart', TOTAL_QUANTITY: '.minicart .minicart-quantity', TOTAL_VALUE: '.minicart .minicart-grand-total' }; const NEWPDP = document.querySelector('.new-pdp'); const headerEle = document.querySelector('.compact-header'); /** * After setting the total height of the minicart in regards to the page header, * calculates and sets the height of the minicart body's section * so that its footer gets stuck to the bottom of the content container * * @param {Element} container The minicart container * @param {Number} [pageHeaderHeight=] The height of the header to align against * @return {Number} The calculated max height for the body */ const setMiniCartBodyHeights = container => { const content = container.querySelector(SELECTORS.CONTENT); const header = container.querySelector(SELECTORS.HEADER); const body = container.querySelector(SELECTORS.BODY); const footer = container.querySelector(SELECTORS.FOOTER); if (header && body && footer) { const totalHeight = Object(_util_domutils__WEBPACK_IMPORTED_MODULE_2__["outerHeightWithMargin"])(content); const headerHeight = Object(_util_domutils__WEBPACK_IMPORTED_MODULE_2__["outerHeightWithMargin"])(header); const footerHeight = Object(_util_domutils__WEBPACK_IMPORTED_MODULE_2__["outerHeightWithMargin"])(footer); const bodyMaxHeight = totalHeight - headerHeight - footerHeight; body.style.maxHeight = `${bodyMaxHeight}px`; return bodyMaxHeight; } return null; }; /** * Checks if the target of the passed in event is one of the elements * which should cause the minicart to be closed when clicked on * * @param {Event} e The event to check * @return {Boolean} True if the event represents a minicart close click */ const isClickOnCloseTrigger = e => { const closeBtn = document.querySelector(SELECTORS.CLOSE_BUTTON); return !e.target.closest(SELECTORS.CONTAINER) && !e.target.closest(SELECTORS.PARENT) || e.target.closest(SELECTORS.CLOSE_BUTTON) || e.target === closeBtn; }; const showFlyout = container => { // Trigger global events to close any other open flyouts and position the minicart correctly document.dispatchEvent(new CustomEvent(_header__WEBPACK_IMPORTED_MODULE_4__["EVENTS"].UPDATE_HEADER)); document.dispatchEvent(new CustomEvent(_flyoutUnderHeader__WEBPACK_IMPORTED_MODULE_3__["EVENTS"].FLYOUT_OPEN, { detail: { flyout: container } })); // Display the flyout container.classList.add(CONSTANTS.TOGGLE_CLASS); }; const displayFlyout = async function displayFlyout(container) { let showFlyoutImmediately = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; const toggle = document.querySelector(SELECTORS.PARENT); const actionUrl = toggle.dataset.actionUrl; const innerContainer = container.querySelector(SELECTORS.CONTAINER_INNER); const body = document.querySelector('body'); body.style.borderRightWidth = '17px'; if (showFlyoutImmediately) { // Clear the stale minicart content before showing the flyout, so only the spinner is visible innerContainer.innerHTML = ''; // Start the loading indicator in the flyout jquery__WEBPACK_IMPORTED_MODULE_0___default()(innerContainer).spinner().start(); showFlyout(container); } // Load the minicart content const response = await fetch(actionUrl, Object(_util_fetchutils__WEBPACK_IMPORTED_MODULE_1__["fetchOptionsGet"])()); const data = await response.text(); // Populate the fresh minicart content in the flyout innerContainer.innerHTML = data; if (NEWPDP && headerEle && !Object(_util_domutils__WEBPACK_IMPORTED_MODULE_2__["isLG"])()) { headerEle.classList.add('active-flyout'); } // Calculate the heights of the minicart elements so the footer is fixed at the bottom const bodyHeight = setMiniCartBodyHeights(container); if (!showFlyoutImmediately && bodyHeight && bodyHeight >= CONSTANTS.MIN_BODY_HEIGHT) { showFlyout(container); } // Remove the loading indicator jquery__WEBPACK_IMPORTED_MODULE_0___default()(innerContainer).spinner().stop(); }; const closeFlyout = container => { const body = document.querySelector('body'); body.style.borderRightWidth = ''; container.classList.remove(CONSTANTS.TOGGLE_CLASS); if (NEWPDP && headerEle && !Object(_util_domutils__WEBPACK_IMPORTED_MODULE_2__["isLG"])()) { headerEle.classList.remove('active-flyout'); } document.dispatchEvent(new CustomEvent(_flyoutUnderHeader__WEBPACK_IMPORTED_MODULE_3__["EVENTS"].FLYOUT_CLOSE, { detail: { flyout: container } })); }; /** * Initializes the logic which controls the displaying and closing of the minicart * * @param {Element} container The minicart container */ const initMiniCartToggle = container => { let miniCartDisplayTimeout; document.addEventListener('click', e => { if (container.classList.contains(CONSTANTS.TOGGLE_CLASS)) { // hide the minicart on click event outside the container or cross-icon click if (isClickOnCloseTrigger(e)) { closeFlyout(container); } } }); Object(_util_domutils__WEBPACK_IMPORTED_MODULE_2__["onEvent"])(document, 'touchstart', SELECTORS.PARENT, e => { e.target.dataset.touch = true; }); Object(_util_domutils__WEBPACK_IMPORTED_MODULE_2__["onEvent"])(document, 'mouseover', SELECTORS.PARENT, e => { const qtyContainer = document.querySelector(SELECTORS.TOTAL_QUANTITY); const touchEnabled = e.target.dataset.touch === 'true'; const inMiniCart = e.target.closest(SELECTORS.CONTAINER); const miniCartShown = container.classList.contains(CONSTANTS.TOGGLE_CLASS); const hasItems = parseInt(qtyContainer.dataset.qt, 10) > 0; if (!touchEnabled && !inMiniCart && !miniCartShown && hasItems) { miniCartDisplayTimeout = setTimeout(() => { // show the minicart displayFlyout(container); }, window.miniCartHoverTimeout || CONSTANTS.HOVER_TIMEOUT); } // Prevent touches from stopping later hovers from working, e.g. on touch-screen laptops e.target.dataset.touch = false; }); Object(_util_domutils__WEBPACK_IMPORTED_MODULE_2__["onEvent"])(document, 'mouseout', SELECTORS.PARENT, () => { clearTimeout(miniCartDisplayTimeout); }); }; /** * Handles changes to the total number of items in the cart */ const updateMiniCartTotal = container => { let closeAfterChangeTimeout; jquery__WEBPACK_IMPORTED_MODULE_0___default()(SELECTORS.PARENT).on('count:update', async (event, data) => { // update minicart link quantity and total in the header menu const cart = data.cart || data.basket || data; const countValue = cart.numItems; const totalValue = cart.totals.grandTotal; const totalAvailable = totalValue && totalValue !== '-' && totalValue !== 'N/A'; const link = document.querySelector(SELECTORS.LINK); const qtyContainer = document.querySelector(SELECTORS.TOTAL_QUANTITY); const totalContainer = document.querySelector(SELECTORS.TOTAL_VALUE); const pageAction = document.querySelector('.page').dataset.action; const isFromCart = pageAction === 'Cart-Show'; qtyContainer.innerHTML = countValue; qtyContainer.dataset.qt = countValue; totalContainer.innerHTML = totalAvailable ? totalValue : ''; totalContainer.dataset.total = totalValue; if (countValue > 0 && !isFromCart && jquery__WEBPACK_IMPORTED_MODULE_0___default()('.ATBOverlayEnable').length < 1) { await displayFlyout(container, false); closeAfterChangeTimeout = setTimeout(() => { closeFlyout(container); }, CONSTANTS.COUNT_UPDATE_DISPLAY_TIME); } link.classList.toggle(CLASSES.LINK_HIGHLIGHTED, countValue > 0); }); Object(_util_domutils__WEBPACK_IMPORTED_MODULE_2__["onEvent"])(document, 'mouseover', SELECTORS.CONTAINER_INNER, () => { clearTimeout(closeAfterChangeTimeout); }); }; const updateMiniCart = async () => { const minicart = document.querySelector(SELECTORS.PARENT); if (minicart) { const _ref = await Object(_util_fetchutils__WEBPACK_IMPORTED_MODULE_1__["loadContent"])(minicart, null, null, false), content = _ref.content; minicart.innerHTML = content; const container = document.querySelector(SELECTORS.CONTAINER); if (container) { updateMiniCartTotal(container); if (container.dataset.initFlyoutUnderHeader) { Object(_flyoutUnderHeader__WEBPACK_IMPORTED_MODULE_3__["initFlyout"])(container, setMiniCartBodyHeights, CONSTANTS.TOGGLE_CLASS); } initMiniCartToggle(container); } } }; /* harmony default export */ __webpack_exports__["default"] = (async () => { updateMiniCart(); }); /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/search.js": /*!*****************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/search.js ***! \*****************************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~base */ "./cartridges/app_storefront_base/cartridge/client/default/js/components/search.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _util_debounce__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/debounce */ "./cartridges/app_bee_base/cartridge/client/default/js/util/debounce.js"); /* harmony import */ var _util_domutils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/domutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); /* harmony import */ var _header__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./header */ "./cartridges/app_tfg/cartridge/client/default/js/components/header.js"); /* harmony import */ var body_scroll_lock__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! body-scroll-lock */ "./node_modules/body-scroll-lock/lib/bodyScrollLock.min.js"); /* harmony import */ var body_scroll_lock__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(body_scroll_lock__WEBPACK_IMPORTED_MODULE_5__); /* harmony import */ var _util_fetchutils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../util/fetchutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/fetchutils.js"); // eslint-disable-line import/named // eslint-disable-line import/named const CLASSES = { SEARCH_FIELD: 'search-field', CLOSE_SEARCH: 'close-search', TRENDING_PANE: 'trending-suggestions', get TRENDING_PANE_ACTIVE() { return `${this.TRENDING_PANE}--active`; } }; const SELECTORS = { WRAPPER: '.suggestions-wrapper', SEARCH_FIELD: `.${CLASSES.SEARCH_FIELD}`, CLEAR_SEARCH: '.clear-search', TRENDING_PANE: `.${CLASSES.TRENDING_PANE}`, SEARCHESUGGESTIONS_PANE: '.suggestions', SUGGESTIONS_CLOSE: '.suggestions .close-search', LOAD_RECENT_SEARCH: '.trending-suggestions .js-load-recent-search', LOAD_POP_SEARCH: '.js-load-pop-search' }; const handleSuggestionsDisplay = () => { const headerHeight = _header__WEBPACK_IMPORTED_MODULE_4__["functions"].getHeaderHeight(); const panes = document.querySelectorAll(SELECTORS.SEARCHESUGGESTIONS_PANE); panes.forEach(pane => { const isVisible = Object(_util_domutils__WEBPACK_IMPORTED_MODULE_3__["visible"])(pane); const maxHeight = window.innerHeight - headerHeight; const isTallerThanWindow = pane.scrollHeight >= maxHeight; if (isVisible) { pane.style.maxHeight = `${maxHeight}px`; } if (isVisible && isTallerThanWindow) { Object(body_scroll_lock__WEBPACK_IMPORTED_MODULE_5__["disableBodyScroll"])(pane); } else { Object(body_scroll_lock__WEBPACK_IMPORTED_MODULE_5__["enableBodyScroll"])(pane); } }); }; const loadRecentSearches = async () => { const recentSearch = document.querySelector(SELECTORS.LOAD_RECENT_SEARCH); if (recentSearch && recentSearch.children.length <= 0) { const _ref = await Object(_util_fetchutils__WEBPACK_IMPORTED_MODULE_6__["loadContent"])(recentSearch, null, null, false), content = _ref.content; recentSearch.innerHTML = content; } }; const toggleTrendingSuggestions = (field, trendingPane) => { loadRecentSearches(); if (!field.value || field.value.length < 3) { trendingPane.classList.add(CLASSES.TRENDING_PANE_ACTIVE); } else { trendingPane.classList.remove(CLASSES.TRENDING_PANE_ACTIVE); } handleSuggestionsDisplay(); }; const clearSearchField = () => { const clearSearchToggles = document.querySelectorAll(SELECTORS.CLEAR_SEARCH); clearSearchToggles.forEach(clearSearch => { clearSearch.addEventListener('click', () => { const searchField = clearSearch.parentElement.parentElement.querySelector(SELECTORS.SEARCH_FIELD); if (searchField) { searchField.value = ''; searchField.focus(); searchField.click(); } }); }); }; const trendingSuggestions = () => { const trendingPane = document.querySelector(SELECTORS.TRENDING_PANE); if (trendingPane) { const searchField = trendingPane.parentElement.querySelector(SELECTORS.SEARCH_FIELD); if (searchField) { const debounceTrending = Object(_util_debounce__WEBPACK_IMPORTED_MODULE_2__["default"])(toggleTrendingSuggestions, 300); ['keyup', 'click'].forEach(evt => { searchField.addEventListener(evt, () => { debounceTrending(searchField, trendingPane); }); }); document.body.addEventListener('click', e => { if (e.target !== trendingPane && !trendingPane.contains(e.target) && !e.target.classList.contains(CLASSES.SEARCH_FIELD)) { trendingPane.classList.remove(CLASSES.TRENDING_PANE_ACTIVE); } setTimeout(handleSuggestionsDisplay); }); } } }; const closeSuggestions = () => { Object(_util_domutils__WEBPACK_IMPORTED_MODULE_3__["onEvent"])(document, 'click', SELECTORS.SUGGESTIONS_CLOSE, () => { const searchField = document.querySelector(SELECTORS.SEARCH_FIELD); if (searchField) { searchField.blur(); searchField.parentElement.click(); } }); }; const handleSuggestionsVisibility = () => { const wrapper = document.querySelector(SELECTORS.WRAPPER); const url = wrapper && wrapper.dataset.url; jquery__WEBPACK_IMPORTED_MODULE_1___default()(document).ajaxComplete((e, xhr, options) => { if (url && options.url && options.url.indexOf(url) >= 0) { handleSuggestionsDisplay(); } }); window.addEventListener('resize', Object(_util_debounce__WEBPACK_IMPORTED_MODULE_2__["default"])(handleSuggestionsDisplay)); }; const loadPopularSearches = async () => { const loadPopSearch = document.querySelector(SELECTORS.LOAD_POP_SEARCH); if (loadPopSearch) { const _ref2 = await Object(_util_fetchutils__WEBPACK_IMPORTED_MODULE_6__["loadContent"])(loadPopSearch, null, null, false), content = _ref2.content; loadPopSearch.innerHTML = content; } }; /* harmony default export */ __webpack_exports__["default"] = (() => { Object(_base__WEBPACK_IMPORTED_MODULE_0__["default"])(); loadPopularSearches(); clearSearchField(); trendingSuggestions(); closeSuggestions(); handleSuggestionsVisibility(); }); /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/sizeConversions.js": /*!**************************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/sizeConversions.js ***! \**************************************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _util_domutils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util/domutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); /* harmony import */ var _scripts_helpers_sizeHelpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../../scripts/helpers/sizeHelpers */ "./cartridges/app_tfg/cartridge/scripts/helpers/sizeHelpers.js"); /* harmony import */ var _scripts_helpers_sizeHelpers__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_scripts_helpers_sizeHelpers__WEBPACK_IMPORTED_MODULE_1__); // eslint-disable-line import/named const SELECTORS = { CONVERSION_DETAILS_SOURCE: '[data-size-conversions]', LABEL_CONVERSIONS: '[data-convert-label]', VALUE_CONVERSIONS: '[data-convert-value]' }; /* harmony default export */ __webpack_exports__["default"] = (() => { const conversionDetailsSource = document.querySelector(SELECTORS.CONVERSION_DETAILS_SOURCE); const isShoe = document.getElementsByName('isShoeProduct').length > 0 ? document.getElementsByName('isShoeProduct')[0] : null; if (conversionDetailsSource) { let conversionDetails = Object(_util_domutils__WEBPACK_IMPORTED_MODULE_0__["getJSONData"])(conversionDetailsSource, 'sizeConversions', null); if (isShoe && isShoe.value === 'true') { // this logic added for shoe size conversion. conversionDetails = Object(_util_domutils__WEBPACK_IMPORTED_MODULE_0__["getJSONData"])(conversionDetailsSource, 'shoeSizeConversions', null); } if (conversionDetails) { const labelConversions = document.querySelectorAll(SELECTORS.LABEL_CONVERSIONS); const valueConversions = document.querySelectorAll(SELECTORS.VALUE_CONVERSIONS); labelConversions.forEach(conversionEl => { const isRemoveSizePrefix = conversionEl && conversionEl.classList.contains('remove-size-prefix'); // eslint-disable-next-line max-len let targetText = isRemoveSizePrefix ? `${conversionEl.dataset.convertLabel}` : `${conversionDetails.prefix} ${conversionEl.dataset.convertLabel}`; if (conversionEl.dataset.convertLabel.indexOf('{0}') >= 0) { targetText = conversionEl.dataset.convertLabel.replace('{0}', conversionDetails.prefix); } conversionEl.innerText = targetText; }); valueConversions.forEach(conversionEl => { const baseValue = conversionEl.dataset.convertValue; // add some logic for shoe size conversion for PLP. const sibling = conversionEl.nextElementSibling; if (sibling && sibling.getAttribute('name') === 'isShoeProduct' && sibling.value === 'true') { conversionDetails = Object(_util_domutils__WEBPACK_IMPORTED_MODULE_0__["getJSONData"])(conversionDetailsSource, 'shoeSizeConversions', null); } conversionEl.innerText = Object(_scripts_helpers_sizeHelpers__WEBPACK_IMPORTED_MODULE_1__["handleSizeConversion"])(baseValue, conversionDetails.sizes.default, conversionDetails.sizes.current, window.beesfra && window.beesfra.config && window.beesfra.config.sizeConversionZeroPad); }); } } }); /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/spinner.js": /*!******************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/spinner.js ***! \******************************************************************************/ /*! no exports provided */ /*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./cartridges/app_storefront_base/cartridge/client/default/js/main.js (referenced with cjs require) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~base */ "./cartridges/app_storefront_base/cartridge/client/default/js/components/spinner.js"); /* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_base__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_1__); const baseSpinner = jquery__WEBPACK_IMPORTED_MODULE_1___default.a.fn.spinner; if (baseSpinner) { jquery__WEBPACK_IMPORTED_MODULE_1___default.a.fn.spinner = function () { const $element = jquery__WEBPACK_IMPORTED_MODULE_1___default()(this); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } const fn = baseSpinner.call(this, ...args); const fnStop = fn && fn.stop; if (fnStop) { /** * The base spinner plugin attaches a 'veiled' class on the parent element * when starting but checks the element itself for the class when stopping */ fn.stop = function () { const $veil = jquery__WEBPACK_IMPORTED_MODULE_1___default()('.veil'); /* eslint-disable jquery/no-class, jquery/no-parent, jquery/no-css */ if ($element.length && $veil.parent().parent().hasClass('veiled')) { $veil.parent().parent().css('position', ''); $veil.parent().parent().removeClass('veiled'); } /* eslint-enable */ fnStop.call(this); }; } return fn; }; } /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/stickyHeaderScroll.js": /*!*****************************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/stickyHeaderScroll.js ***! \*****************************************************************************************/ /*! exports provided: stickyHeaderScrollHandle, stickyHeaderScrollHandlePDP, default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stickyHeaderScrollHandle", function() { return stickyHeaderScrollHandle; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stickyHeaderScrollHandlePDP", function() { return stickyHeaderScrollHandlePDP; }); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _util_domutils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/domutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); /* harmony import */ var _throttle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./throttle */ "./cartridges/app_tfg/cartridge/client/default/js/components/throttle.js"); const SELECTORS = { HEADER: '.header-sticky', PDP: '.rd_PDP', PRDDETAIL: 'product-detail', PRDSETDETAIL: 'product-set-detail', NEWPDP: '.new-pdp', BREADCRUMB: '.product-detail__top-row-container', PRODUCTDETAIL: '.product-detail__details-section' }; const CONSTANTS = { SCROLL_INTERVAL: 150 }; let PRD_DETAIL = document.getElementsByClassName(SELECTORS.PRDDETAIL); if (document.getElementsByClassName(SELECTORS.PRDSETDETAIL).length > 0) { PRD_DETAIL = document.getElementsByClassName(SELECTORS.PRDSETDETAIL); } const PDP = document.querySelector(SELECTORS.PDP); const NEWPDP = document.querySelector(SELECTORS.NEWPDP); const header = document.querySelector(SELECTORS.HEADER); const headerBanner = document.querySelector('.header-banner'); const stickyHeaderScrollHandle = () => { let previousScrollPosition = 0; const isScrollingDown = () => { let goingDown = false; const scrollPosition = window.pageYOffset; if (scrollPosition >= header.offsetHeight && scrollPosition > previousScrollPosition) { goingDown = true; } previousScrollPosition = scrollPosition; return goingDown; }; const handleScroll = () => { if (isScrollingDown()) { header.classList.add('scroll-down'); header.classList.remove('scroll-up'); } else { header.classList.add('scroll-up'); header.classList.remove('scroll-down'); } }; const scrollThrottle = Object(_throttle__WEBPACK_IMPORTED_MODULE_2__["default"])(handleScroll, CONSTANTS.SCROLL_INTERVAL); if (header) { window.addEventListener('scroll', scrollThrottle); } }; const stickyHeaderScrollHandlePDP = () => { const banner = document.querySelector('.header-banner'); const PDPgallary = document.querySelector('#cld-gallery'); let previousScrollPosition = 0; const isScrollingDown = () => { let goingDown = false; const scrollPosition = window.pageYOffset; if (scrollPosition >= banner.offsetHeight) { header.classList.add('scroll-up-top-bar'); } const scrollDownFadeEffect = scrollPosition >= PDPgallary.offsetHeight - PRD_DETAIL[0].dataset.scrolldown; if (scrollPosition > previousScrollPosition && scrollDownFadeEffect) { goingDown = true; } const ScrollUpTransparentEffect = PDPgallary.offsetHeight - scrollPosition >= PRD_DETAIL[0].dataset.scrollup; if (PDPgallary.offsetHeight > scrollPosition && ScrollUpTransparentEffect && jquery__WEBPACK_IMPORTED_MODULE_0___default()('.rd_PDP').length === 0) { PDP.classList.add('rd_PDP'); } previousScrollPosition = scrollPosition; return goingDown; }; const handleHeader = () => { const scrollPosition = window.pageYOffset; const headerEle = document.querySelector('.compact-header'); const globalebanner = document.querySelector('.fsbloaded') || document.querySelector('#FreeShippingBanner'); let headerBannerHeight = headerBanner && headerBanner.getBoundingClientRect().height; const globalBannerHeight = globalebanner && globalebanner.getBoundingClientRect().height; const isGLobaleBanner = jquery__WEBPACK_IMPORTED_MODULE_0___default()('#FreeShippingBanner').length > 0 || jquery__WEBPACK_IMPORTED_MODULE_0___default()('.fsbloaded').lengh > 0; if (Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["isLG"])()) { headerEle.style.top = 0; } else if (isGLobaleBanner || jquery__WEBPACK_IMPORTED_MODULE_0___default()('.new-promo-banner').length > 0) { if (isGLobaleBanner) { // eslint-disable-next-line no-const-assign const geBanPos = headerBanner.querySelector('.fsbloaded') || headerBanner.querySelector('#FreeShippingBanner'); if (!(headerBanner && geBanPos)) { headerBannerHeight += globalBannerHeight; } } if (scrollPosition > headerBannerHeight) { // eslint-disable-next-line jquery/no-css jquery__WEBPACK_IMPORTED_MODULE_0___default()('.compact-header').css('top', 0); } else { headerEle.style.top = `${headerBannerHeight - jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).scrollTop()}px`; } } }; const handleScroll = () => { if (NEWPDP && !Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["isLG"])()) { handleHeader(); } if (isScrollingDown()) { header.classList.add('scroll-down'); header.classList.remove('scroll-up'); // eslint-disable-next-line jquery/no-class jquery__WEBPACK_IMPORTED_MODULE_0___default()('body').removeClass('rd_PDP'); } else { if (window.pageYOffset >= PDPgallary.offsetHeight) { PDP.classList.remove('rd_PDP'); } header.classList.add('scroll-up'); header.classList.remove('scroll-down'); } }; if (header) { window.addEventListener('scroll', handleScroll); if (NEWPDP) { window.addEventListener('resize', handleHeader); } if ('.header-banner-bottom'.length > 0) { jquery__WEBPACK_IMPORTED_MODULE_0___default()('.header-banner-bottom').remove(); } } const checkPositionOfbanner = headerBanner && window.pageYOffset <= headerBanner.getBoundingClientRect().height; if ('.new-promo-banner'.length > 0 && !Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["isLG"])() && checkPositionOfbanner) { // eslint-disable-next-line jquery/no-css jquery__WEBPACK_IMPORTED_MODULE_0___default()('.compact-header').css('top', headerBanner.getBoundingClientRect().height); } }; function headerInit() { const globalebanner = document.querySelector('#FreeShippingBanner'); const globaleBannerClass = document.querySelector('.fsbloaded'); const headerBannerHeight = headerBanner && headerBanner.getBoundingClientRect().height; const isGLobaleBanner = jquery__WEBPACK_IMPORTED_MODULE_0___default()('#FreeShippingBanner').length > 0 || jquery__WEBPACK_IMPORTED_MODULE_0___default()('.fsbloaded').lengh > 0; let globalbanner; const geBanPos = headerBanner.querySelector('.fsbloaded') || headerBanner.querySelector('#FreeShippingBanner'); if (globalebanner) { globalbanner = globalebanner && globalebanner.getBoundingClientRect().height; if (headerBanner && geBanPos) { globalbanner = 0; } } if (globaleBannerClass) { globalbanner = globaleBannerClass && globaleBannerClass.getBoundingClientRect().height; if (headerBanner && geBanPos) { globalbanner = 0; } } const totalBannerHeight = headerBannerHeight + globalbanner; if (isGLobaleBanner > 0) { // eslint-disable-next-line jquery/no-css if ('.new-promo-banner'.length > 0) { // eslint-disable-next-line jquery/no-css jquery__WEBPACK_IMPORTED_MODULE_0___default()('.compact-header').css('top', totalBannerHeight); } else { // eslint-disable-next-line jquery/no-css jquery__WEBPACK_IMPORTED_MODULE_0___default()('.compact-header').css('top', globalbanner); } } else { // eslint-disable-next-line jquery/no-css jquery__WEBPACK_IMPORTED_MODULE_0___default()('.compact-header').css('top', headerBannerHeight); } } function dockImageCarouselToTop() { const headerHeight = header ? header.offsetHeight : 0; const productImages = document.querySelector('.product-detail__product-images'); const productSetitem = document.querySelector('.set-items .product-detail__product-images'); if (productSetitem && productSetitem.lengh === 0) { if (productImages && Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["isLG"])()) { productImages.style.top = `${headerHeight + 15}px`; productImages.style.position = 'sticky'; productImages.style.height = 'fit-content'; } else { productImages.style.position = 'static'; } } } // eslint-disable-next-line no-unused-vars function checkForGEBanner(mutations, observer) { // eslint-disable-next-line arrow-parens mutations.forEach(mutation => { mutation.addedNodes.forEach(node => { if (node.nodeType === Node.ELEMENT_NODE) { // Check if the node has the desired ID or class if ((node.id === 'FreeShippingBanner' || node.classList.contains('fsbloaded')) && !Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["isLG"])()) { headerInit(); } } }); }); } // Create a MutationObserver instance if (NEWPDP) { const observer = new MutationObserver(checkForGEBanner); // Start observing the document's body for child list changes observer.observe(document.body, { childList: true, subtree: true }); } /* harmony default export */ __webpack_exports__["default"] = (() => { if (PRD_DETAIL.length && PDP) { stickyHeaderScrollHandlePDP(); } else { stickyHeaderScrollHandle(); } if (PRD_DETAIL.length > 0 && PRD_DETAIL[0].dataset.imagecarouselsticky === 'true' && NEWPDP) { dockImageCarouselToTop(); window.addEventListener('resize', dockImageCarouselToTop); } }); /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/components/throttle.js": /*!*******************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/components/throttle.js ***! \*******************************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* eslint-disable no-multi-assign */ /* eslint-disable no-param-reassign */ /* eslint-disable vars-on-top */ /* harmony default export */ __webpack_exports__["default"] = (function (func, wait, options) { let timeout; let context; let args; let result; let previous = 0; if (!options) options = {}; const later = function later() { previous = options.leading === false ? 0 : Date.now(); timeout = null; result = func.apply(context, args); if (!timeout) context = args = null; }; const throttled = function throttled() { const nowTime = Date.now(); if (!previous && options.leading === false) previous = nowTime; const remaining = wait - (nowTime - previous); context = this; // eslint-disable-next-line prefer-rest-params args = arguments; if (remaining <= 0 || remaining > wait) { if (timeout) { clearTimeout(timeout); timeout = null; } previous = nowTime; result = func.apply(context, args); if (!timeout) context = args = null; } else if (!timeout && options.trailing !== false) { timeout = setTimeout(later, remaining); } return result; }; throttled.cancel = function () { clearTimeout(timeout); previous = 0; timeout = context = args = null; }; return throttled; }); /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/search/productTile.js": /*!******************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/search/productTile.js ***! \******************************************************************************/ /*! exports provided: EVENTS, colorSwatches, quickAddToBag, addSearchSuggestionPhraseParam, preOrderVarient, enableSlideonPLPAltImg */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EVENTS", function() { return EVENTS; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorSwatches", function() { return colorSwatches; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "quickAddToBag", function() { return quickAddToBag; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addSearchSuggestionPhraseParam", function() { return addSearchSuggestionPhraseParam; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "preOrderVarient", function() { return preOrderVarient; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "enableSlideonPLPAltImg", function() { return enableSlideonPLPAltImg; }); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _components_sizeConversions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../components/sizeConversions */ "./cartridges/app_tfg/cartridge/client/default/js/components/sizeConversions.js"); /* harmony import */ var _util_domutils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/domutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); /* harmony import */ var _util_urlutils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/urlutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/urlutils.js"); /* harmony import */ var _util_fetchutils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../util/fetchutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/fetchutils.js"); /* eslint-disable jquery/no-class */ /* eslint-disable max-len */ // eslint-disable-line import/named // eslint-disable-line import/named // eslint-disable-line import/named const CLASSES = { SWATCH: 'product-tile__swatch', TILE_IMAGE_CONTAINER: 'product-tile__image', TILE_IMAGE_CONTAINER_OVERLAY_SHOWN: 'product-tile__image--add-overlay', SWATCH_CURRENT: 'product-tile__swatch--current', OUT_OF_STOCK: 'outofstock' }; const SELECTORS = { TILE: '.product-tile', SWATCH: `.${CLASSES.SWATCH}`, TILE_IMAGE_CONTAINER: `.${CLASSES.TILE_IMAGE_CONTAINER}`, TILE_IMAGE: `.${CLASSES.TILE_IMAGE_CONTAINER} .tile-image`, PRIMARY_IMAGE: `.${CLASSES.TILE_IMAGE_CONTAINER} .primary-image`, ALTERNATE_IMAGE: `.${CLASSES.TILE_IMAGE_CONTAINER} .alternate-image`, ALTERNATE_TILE_IMAGE: `.${CLASSES.TILE_IMAGE_CONTAINER} img.alternate-image`, PDP_LINK: '.pdp-link .primary-image.link', ALTERNATE_PDP_LINK: '.pdp-link .alternate-image.link', ADD_TO_BAG_LINK: '.product-tile__action-add', ADD_TO_BAG_OVERLAY: '.product-tile__add-overlay', ADD_TO_BAG_OVERLAY_CLOSE: '.product-tile__add-overlay-close', PRICE_CONTAINER: '.product-tile__price .link', PROMO_CONTAINER: '.product-tile__promotions .link', SUGGESTIONS_LINK: '.suggestions-categories .product .link' }; const EVENTS = { SWATCH_CHANGE: 'tile:swatch-changed', ADD_TO_BAG_OVERLAY_TOGGLE: 'tile:overlay-toggle' }; /** * Retrieves all sibling color swatches of the parameter * * @param {Element} swatch The swatch whose siblings to retrieve * @return {Element[]} The sibling swatches */ const getSwatchSiblings = swatch => { const otherSwatches = Object(_util_domutils__WEBPACK_IMPORTED_MODULE_2__["getSiblings"])(swatch, el => { const isNode = !!el.classList; const isSwatch = isNode && el.classList.contains(CLASSES.SWATCH); const isOtherSwatch = isSwatch && el !== swatch; return isOtherSwatch; }); return otherSwatches; }; /** * Handles the necessary changes to a product tile whose color swatch has been clicked * * @param {Element} tile The tile to update * @param {Element} clickedSwatch The color swatch whose click needs to be handled */ const updateTileElements = (tile, clickedSwatch) => { const image = tile.querySelector(SELECTORS.TILE_IMAGE); const links = tile.querySelectorAll(SELECTORS.PDP_LINK); const addToBag = tile.querySelector(SELECTORS.ADD_TO_BAG_LINK); const priceContainer = tile.querySelector(SELECTORS.PRICE_CONTAINER); const promoContainer = tile.querySelector(SELECTORS.PROMO_CONTAINER); image.src = clickedSwatch.dataset.image; image.dataset.src = clickedSwatch.dataset.image; links.forEach(link => { const hash = link.href.split('#')[1]; link.href = clickedSwatch.href; if (hash) { link.href += `#${hash}`; } }); if (addToBag) { addToBag.dataset.action = clickedSwatch.dataset.addToBagUrl; } if (priceContainer) { priceContainer.innerHTML = clickedSwatch.dataset.priceHtml; } if (promoContainer) { promoContainer.innerHTML = clickedSwatch.dataset.promoCalloutsHtml; } }; const updateTileElementsforAlternateImage = (tile, clickedSwatch) => { const alternateImage = tile.querySelector(SELECTORS.ALTERNATE_TILE_IMAGE); const links = tile.querySelectorAll(SELECTORS.ALTERNATE_PDP_LINK); const primaryImageCarouselItem = tile.querySelector(SELECTORS.PRIMARY_IMAGE); const AlternateImageCarouselItem = tile.querySelector(SELECTORS.ALTERNATE_IMAGE); if (alternateImage) { alternateImage.src = clickedSwatch.dataset.alternateImageUrl; alternateImage.dataset.src = clickedSwatch.dataset.alternateImageUrl; alternateImage.srcset = clickedSwatch.dataset.alternateImageSrcset; primaryImageCarouselItem.classList.add('active'); AlternateImageCarouselItem.classList.remove('active'); } if (links) { links.forEach(link => { const hash = link.href.split('#')[1]; link.href = clickedSwatch.href; if (hash) { link.href += `#${hash}`; } }); } }; /** * Ensures that the provided swatch gets marked as selected, * and all other swatches get marked as unselected * * @param {Element} clickedSwatch The swatch to select */ const handleSwatchSelection = clickedSwatch => { const otherSwatches = getSwatchSiblings(clickedSwatch); otherSwatches.forEach(otherSwatch => { otherSwatch.classList.remove(CLASSES.SWATCH_CURRENT); }); clickedSwatch.classList.add(CLASSES.SWATCH_CURRENT); }; const dispatchColorChangeEvent = (tile, selectedSwatch) => { const evt = new CustomEvent(EVENTS.SWATCH_CHANGE, { detail: { tile, selectedSwatch } }); document.dispatchEvent(evt); }; const dispatchAddToBagOverlayEvent = (tile, shown) => { const evt = new CustomEvent(EVENTS.ADD_TO_BAG_OVERLAY_TOGGLE, { detail: { tile, shown } }); document.dispatchEvent(evt); }; const displayAddToBagOverlay = async addToBagLink => { const _ref = await Object(_util_fetchutils__WEBPACK_IMPORTED_MODULE_4__["loadContent"])(addToBagLink), contentType = _ref.type, content = _ref.content; if (contentType === _util_fetchutils__WEBPACK_IMPORTED_MODULE_4__["CONTENT_TYPES"].TEXT) { const imageContainer = addToBagLink.closest(SELECTORS.TILE_IMAGE_CONTAINER); const existingOverlay = imageContainer.querySelector(SELECTORS.ADD_TO_BAG_OVERLAY); if (!existingOverlay) { imageContainer.innerHTML += content; imageContainer.classList.add(CLASSES.TILE_IMAGE_CONTAINER_OVERLAY_SHOWN); Object(_components_sizeConversions__WEBPACK_IMPORTED_MODULE_1__["default"])(); dispatchAddToBagOverlayEvent(imageContainer.closest(SELECTORS.TILE), true); } } else if (contentType === _util_fetchutils__WEBPACK_IMPORTED_MODULE_4__["CONTENT_TYPES"].JSON) { if (!content.error) { // eslint-disable-next-line jquery/no-trigger jquery__WEBPACK_IMPORTED_MODULE_0___default()('.minicart').trigger('count:update', content); if (jquery__WEBPACK_IMPORTED_MODULE_0___default()('.cart-page').length > 0 || jquery__WEBPACK_IMPORTED_MODULE_0___default()('#ATBRecommendationsModal').length > 0) { // eslint-disable-next-line jquery/no-trigger jquery__WEBPACK_IMPORTED_MODULE_0___default.a.when(jquery__WEBPACK_IMPORTED_MODULE_0___default()(addToBagLink).trigger('updateAddToCartFormData', content)).done(() => { // eslint-disable-next-line jquery/no-trigger jquery__WEBPACK_IMPORTED_MODULE_0___default()('body').trigger('product:afterAddToCart', content); }); } } } }; const closeAddToBagOverlay = async overlay => { if (overlay) { const tile = overlay.closest(SELECTORS.TILE); const imageVeiled = overlay.closest(SELECTORS.TILE_IMAGE_CONTAINER); overlay.remove(); imageVeiled.classList.remove('veiled'); imageVeiled.style.position = null; imageVeiled.classList.remove(CLASSES.TILE_IMAGE_CONTAINER_OVERLAY_SHOWN); dispatchAddToBagOverlayEvent(tile, false); } }; const handleAddToBagActions = () => { let lastClickedButton = null; jquery__WEBPACK_IMPORTED_MODULE_0___default()(document).on('updateAddToCartFormData', (e, data) => { const button = e.target; data.pid = button.dataset.pid; data.quantity = button.dataset.minQuantity || data.quantity; lastClickedButton = button; }).on('product:afterAddToCart', () => { if (lastClickedButton) { const overlay = lastClickedButton.closest(SELECTORS.ADD_TO_BAG_OVERLAY); closeAddToBagOverlay(overlay); lastClickedButton = null; } }); document.addEventListener(EVENTS.SWATCH_CHANGE, e => { const overlay = e.detail.tile.querySelector(SELECTORS.ADD_TO_BAG_OVERLAY); closeAddToBagOverlay(overlay); }); }; const handleStickers = (tile, swatch) => { const selectable = swatch.dataset.selectable; tile.classList.remove(CLASSES.OUT_OF_STOCK); if (selectable !== 'true') { tile.classList.add(CLASSES.OUT_OF_STOCK); } }; const colorSwatches = () => { jquery__WEBPACK_IMPORTED_MODULE_0___default()(document).on('click', SELECTORS.SWATCH, e => { e.preventDefault(); const swatch = e.currentTarget; const tile = swatch.closest(SELECTORS.TILE); const showAltImgonPLP = tile.getAttribute('data-showaltimg'); updateTileElements(tile, swatch); if (showAltImgonPLP !== null) { updateTileElementsforAlternateImage(tile, swatch); } handleSwatchSelection(swatch); handleStickers(tile, swatch); dispatchColorChangeEvent(tile, swatch); }); }; const quickAddToBag = () => { Object(_util_domutils__WEBPACK_IMPORTED_MODULE_2__["onEvent"])(document, 'click', SELECTORS.ADD_TO_BAG_LINK, async e => { e.preventDefault(); if (!e.delegateTarget.classList.contains('disabled')) { displayAddToBagOverlay(e.delegateTarget); } }); Object(_util_domutils__WEBPACK_IMPORTED_MODULE_2__["onEvent"])(document, 'click', SELECTORS.ADD_TO_BAG_OVERLAY_CLOSE, async e => { e.preventDefault(); const overlay = e.delegateTarget.closest(SELECTORS.ADD_TO_BAG_OVERLAY); closeAddToBagOverlay(overlay); }); handleAddToBagActions(); }; const addSearchSuggestionPhraseParam = () => { Object(_util_domutils__WEBPACK_IMPORTED_MODULE_2__["onEvent"])(document, 'click', SELECTORS.SUGGESTIONS_LINK, e => { let searchPhrase; const linkToPdp = e.delegateTarget; const searchInputs = document.querySelectorAll('.search-field'); searchInputs.forEach(searchField => { if (searchField.value !== '') { searchPhrase = searchField.value; } }); if (searchPhrase) { e.preventDefault(); window.location.href = Object(_util_urlutils__WEBPACK_IMPORTED_MODULE_3__["appendToUrl"])(linkToPdp.href, { q: searchPhrase }); } }); }; const preOrderVarient = () => { Object(_util_domutils__WEBPACK_IMPORTED_MODULE_2__["onEvent"])(document, 'click', '.product-tile__add-overlay-size', e => { const preOrderData = JSON.parse(e.srcElement.getAttribute('data-preOrderData')); const preOrderMessageContainer = e.srcElement.closest('.product-tile__add-overlay-sizes-container').querySelector('.product-tile__add-overlay-pre-order'); const preOrderMessage = e.srcElement.closest('.product-tile__add-overlay-sizes-container').querySelector('.product-tile__add-overlay-pre-order-availability-message'); if (preOrderData) { preOrderMessage.innerText = preOrderData.preorderAvailabilityMessage; if (preOrderMessageContainer.classList.contains('d-none')) { preOrderMessageContainer.classList.remove('d-none'); } } else if (!preOrderMessageContainer.classList.contains('d-none')) { preOrderMessageContainer.classList.add('d-none'); } }); }; const enableSlideonPLPAltImg = () => { if (jquery__WEBPACK_IMPORTED_MODULE_0___default()('.carousel').length > 0) { jquery__WEBPACK_IMPORTED_MODULE_0___default()('.carousel').on('touchstart', function (event) { const xClick = event.originalEvent.touches[0].pageX; jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).one('touchmove', function (e) { const xMove = e.originalEvent.touches[0].pageX; const sensitivityInPx = 5; if (Math.floor(xClick - xMove) > sensitivityInPx) { jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).carousel('next'); } else if (Math.floor(xClick - xMove) < -sensitivityInPx) { jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).carousel('prev'); } }); jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).on('touchend', function () { jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).off('touchmove'); }); }); } }; document.addEventListener('tile:overlay-toggle', () => { enableSlideonPLPAltImg(); }); jquery__WEBPACK_IMPORTED_MODULE_0___default()(document).on('click', '.bestprice .price-label, .bestprice-close-btn', e => { e.preventDefault(); if (jquery__WEBPACK_IMPORTED_MODULE_0___default()('#bestprice').hasClass('d-none')) { jquery__WEBPACK_IMPORTED_MODULE_0___default()('.price-label').addClass('active'); jquery__WEBPACK_IMPORTED_MODULE_0___default()('#bestprice').removeClass('d-none'); // eslint-disable-next-line jquery/no-css jquery__WEBPACK_IMPORTED_MODULE_0___default()('.price-label').css('textDecoration', 'none'); } else { jquery__WEBPACK_IMPORTED_MODULE_0___default()('#bestprice').addClass('d-none'); jquery__WEBPACK_IMPORTED_MODULE_0___default()('.price-label').removeClass('active'); // eslint-disable-next-line jquery/no-css jquery__WEBPACK_IMPORTED_MODULE_0___default()('.price-label').css('textDecoration', 'underline'); } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()('.bestprice-close-btn').hasClass('d-none')) { jquery__WEBPACK_IMPORTED_MODULE_0___default()('.bestprice-close-btn').removeClass('d-none'); } else { jquery__WEBPACK_IMPORTED_MODULE_0___default()('.bestprice-close-btn').addClass('d-none'); } }); /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/thirdParty/bootstrap/toggleFormElementsStates.js": /*!*********************************************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/thirdParty/bootstrap/toggleFormElementsStates.js ***! \*********************************************************************************************************/ /*! exports provided: COLLAPSE_EVENTS, toggleFormElementStates */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "COLLAPSE_EVENTS", function() { return COLLAPSE_EVENTS; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toggleFormElementStates", function() { return toggleFormElementStates; }); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _util_domutils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../util/domutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); const COLLAPSE_EVENTS = { FORMS_STATE_CHANGED: 'collapse:forms:change' }; const SELECTORS = { COLLAPSE: '.collapse', TABS: '[data-toggle="tab"]' }; /** * Sets the enabled/disabled state of all form elements found inside the element(s) * represented by the selector * * @param {Element[]} rootEls The elements to toggle the fields in * @param {boolean} enabled Whether to enable or disable the form fields */ function toggleFormElementsState(rootEls, enabled) { rootEls.forEach(root => { Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["findFormFields"])(root).forEach(el => { const parent = el.closest('div'); const hiddenInput = el.type === 'hidden'; const label = document.querySelector(`[for="${el.id}"]`); const activeHiddenInput = hiddenInput && Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["visible"])(parent); const activeToggle = label && Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["visible"])(label); const elVisible = Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["visible"])(el) || el.dataset.choice || activeHiddenInput || activeToggle; el.disabled = !el.dataset.forceEnabled && (!elVisible || !enabled); }); if (enabled) { // Handle nested collapse and tab elements Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["find"])(SELECTORS.TABS, root).forEach(el => toggleTabPanelFormElementsState.call(el)); Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["find"])(SELECTORS.COLLAPSE, root).forEach(el => toggleCollapseFormElementsState.call(el)); } }); } /** * Sets the enabled/disabled state of all form elements found inside the * tabpanel of the Bootstrap tab element passed in as a calling context * * @this {Element} el The element in whose tabpanel to toggle the fields in */ function toggleTabPanelFormElementsState() { const targets = document.querySelectorAll(this.hash); const targetsArr = Array.prototype.slice.call(targets); toggleFormElementsState(targetsArr, this.classList.contains('active')); } /** * Sets the enabled/disabled state of all form elements found inside the * Bootstrap collapse element passed in as a calling context * * @this {Element} The element to toggle the fields in */ function toggleCollapseFormElementsState() { toggleFormElementsState([this], this.classList.contains('show')); } /** * Finds all elements that correspond to the passed in selector * and calls the provided callback for each of them * * @param {string} selector The selector to use * @param {Function} callback The callback to execute */ function handleExistingElements(selector, callback) { // Reversing the selected elements is the cheapest way to ensure that nested // tabs and collapses are handled depth-first Array.from(document.querySelectorAll(selector)).reverse().forEach(el => callback.call(el)); document.dispatchEvent(new CustomEvent(COLLAPSE_EVENTS.FORMS_STATE_CHANGED)); } /** * Initializes listeners that handle the state of form elements inside * Bootstrap collapse elements or tab panels * * @param {string} type The type of Bootstrap element to handle */ function initElements(type) { let selector; let callback; switch (type) { case 'tab': selector = SELECTORS.TABS; callback = toggleTabPanelFormElementsState; break; case 'collapse': selector = SELECTORS.COLLAPSE; callback = toggleCollapseFormElementsState; break; default: } if (selector && callback) { // Handle elements currently on the page handleExistingElements(selector, callback); // Listen for the type's toggle events from user interaction jquery__WEBPACK_IMPORTED_MODULE_0___default()(document).on(`shown.bs.${type} hidden.bs.${type}`, selector, function () { callback.call(this); document.dispatchEvent(new CustomEvent(COLLAPSE_EVENTS.FORMS_STATE_CHANGED)); }); // Handle elements that get added as a result of AJAX calls const observer = new MutationObserver(handleExistingElements.bind(null, selector, callback)); observer.observe(document, { childList: true, subtree: true }); } } /** * Initializes listeners that handle the state of form elements inside Bootstrap tab panel elements */ function initTabs() { initElements('tab', SELECTORS.TABS, toggleTabPanelFormElementsState); } /** * Initializes listeners that handle the state of form elements inside Bootstrap collapse elements */ function initCollapse() { initElements('collapse', SELECTORS.COLLAPSE, toggleCollapseFormElementsState); } /** * Ensure that any form elements inside collapse or tabpanel containers * get disabled when their parents get hidden and vice-versa */ const toggleFormElementStates = () => { initTabs(); initCollapse(); }; /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/util.js": /*!****************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/util.js + 1 modules ***! \****************************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // CONCATENATED MODULE: ./cartridges/app_storefront_base/cartridge/client/default/js/util.js /* harmony default export */ var util = (function (include) { if (typeof include === 'function') { include(); } else if (typeof include === 'object') { Object.keys(include).forEach(function (key) { if (typeof include[key] === 'function') { include[key](); } }); } }); // CONCATENATED MODULE: ./cartridges/app_tfg/cartridge/client/default/js/util.js /** * This module represents a compatibility layer between the project and base code. * * The project code must be written using ES6 modules to meet the coding guidelines, * however, since its version 6, Babel has removed the compatibility for * require-ing ES6 modules, even if they only have a default export: * https://github.com/babel/babel/issues/2212 * * This results in all calls to require that resolve to ES6 modules * (due to the dependency chain injection) returning an object with a 'default' field, * which contains the actual public export of the module. * * Normally this would be resolved with a Babel plugin: * https://www.npmjs.com/package/babel-plugin-add-module-exports * * However, the plugin requires that the used Babel preset be confiugured to use CommonJS modules. * Changing that setting would break the Webpack chunks, so what is done instead is that * the base cartridge's modules are transpiled to ES6 before the project code is introduced. * This leaves the only remaining hurdle to full compatibility being the processInclude function, * since the __webpack_exports__ function returns a Module instance in some cases, which has * a default field, containing the module's default export. Attempts to treat it as an * iterable object resolve in that 'default' field, which is not usable for this method. */ /** * Intercepts processInclude calls to the base module, * and if the passed-in module is an ES6 module with a default export, * processes that default export instead of the exported module itself * * @param {Object} include The module to process */ /* harmony default export */ var js_util = __webpack_exports__["default"] = (function (include) { if (typeof include === 'object' && include.default) { util(include.default); } else { util(include); } }); /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js": /*!*************************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js + 1 modules ***! \*************************************************************************************/ /*! exports provided: find, findFormFields, getFormValuesObject, refreshAttributes, populateRemoteIncludes, visible, updateComponent, addUniqueEventListener, isMD, isLG, isXL, isIOS, innerHeight, isBackForwardNavigation, getElementOffset, getJSONData, parseHTMLString, createElementFromString, setElementHTML, onEvent, getFinalStyle, getScrollTop, outerWidthWithMargin, outerHeightWithMargin, getSiblings, addClassIfNeeded, removeClassIfNeeded, addOrRemoveClassIfNeeded */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/util/fetchutils.js because of ./cartridges/app_tfg/cartridge/client/default/js/customerService/contactUs.js */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, "find", function() { return /* binding */ find; }); __webpack_require__.d(__webpack_exports__, "findFormFields", function() { return /* binding */ findFormFields; }); __webpack_require__.d(__webpack_exports__, "getFormValuesObject", function() { return /* binding */ getFormValuesObject; }); __webpack_require__.d(__webpack_exports__, "refreshAttributes", function() { return /* binding */ refreshAttributes; }); __webpack_require__.d(__webpack_exports__, "populateRemoteIncludes", function() { return /* binding */ populateRemoteIncludes; }); __webpack_require__.d(__webpack_exports__, "visible", function() { return /* binding */ visible; }); __webpack_require__.d(__webpack_exports__, "updateComponent", function() { return /* binding */ updateComponent; }); __webpack_require__.d(__webpack_exports__, "addUniqueEventListener", function() { return /* binding */ addUniqueEventListener; }); __webpack_require__.d(__webpack_exports__, "isMD", function() { return /* binding */ isMD; }); __webpack_require__.d(__webpack_exports__, "isLG", function() { return /* binding */ isLG; }); __webpack_require__.d(__webpack_exports__, "isXL", function() { return /* binding */ isXL; }); __webpack_require__.d(__webpack_exports__, "isIOS", function() { return /* binding */ isIOS; }); __webpack_require__.d(__webpack_exports__, "innerHeight", function() { return /* binding */ domutils_innerHeight; }); __webpack_require__.d(__webpack_exports__, "isBackForwardNavigation", function() { return /* binding */ isBackForwardNavigation; }); __webpack_require__.d(__webpack_exports__, "getElementOffset", function() { return /* binding */ getElementOffset; }); __webpack_require__.d(__webpack_exports__, "getJSONData", function() { return /* reexport */ getJSONData; }); __webpack_require__.d(__webpack_exports__, "parseHTMLString", function() { return /* reexport */ parseHTMLString; }); __webpack_require__.d(__webpack_exports__, "createElementFromString", function() { return /* reexport */ createElementFromString; }); __webpack_require__.d(__webpack_exports__, "setElementHTML", function() { return /* reexport */ setElementHTML; }); __webpack_require__.d(__webpack_exports__, "onEvent", function() { return /* reexport */ onEvent; }); __webpack_require__.d(__webpack_exports__, "getFinalStyle", function() { return /* reexport */ getFinalStyle; }); __webpack_require__.d(__webpack_exports__, "getScrollTop", function() { return /* reexport */ getScrollTop; }); __webpack_require__.d(__webpack_exports__, "outerWidthWithMargin", function() { return /* reexport */ outerWidthWithMargin; }); __webpack_require__.d(__webpack_exports__, "outerHeightWithMargin", function() { return /* reexport */ outerHeightWithMargin; }); __webpack_require__.d(__webpack_exports__, "getSiblings", function() { return /* reexport */ getSiblings; }); __webpack_require__.d(__webpack_exports__, "addClassIfNeeded", function() { return /* reexport */ addClassIfNeeded; }); __webpack_require__.d(__webpack_exports__, "removeClassIfNeeded", function() { return /* reexport */ removeClassIfNeeded; }); __webpack_require__.d(__webpack_exports__, "addOrRemoveClassIfNeeded", function() { return /* reexport */ addOrRemoveClassIfNeeded; }); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/util/fetchutils.js + 1 modules var fetchutils = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/util/fetchutils.js"); // CONCATENATED MODULE: ./cartridges/app_bee_base/cartridge/client/default/js/util/domutils.js function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } const domParser = new DOMParser(); /** * Get JSON data from a data-attribute * * @param el the DOM element that contains the data attribute * @param name the name of the data-attriute (without data- prefix) * @param defaultValue the default value * * @returns the parsed data */ const getJSONData = (el, name, defaultValue) => { let result = defaultValue; const strData = el.dataset[name]; if (strData) { try { const data = JSON.parse(strData); if (Array.isArray(data)) { result = data; } else { result = _objectSpread({}, defaultValue, data); } } catch (ignore) {// ignore } } return result; }; /** * Parses a string containing HTML and returns an array of the created elements. * * @param str the markup text * * @return the created elements as array */ const parseHTMLString = str => Array.from(domParser.parseFromString(str, 'text/html').body.children); /** * Creates an element from the given string. * * @param str the markup text * * @returns the created element */ const createElementFromString = str => { const parsed = parseHTMLString(str); let res; if (parsed.length) { res = parsed[0]; // eslint-disable-line prefer-destructuring } return res; }; /** * Appends elements parsed from a string to an element. * * @param el the element to append * @param str the markup text * @param clear clear child elements before (default false) */ const setElementHTML = function setElementHTML(el, str) { let clear = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; if (clear) { el.innerHTML = ''; } parseHTMLString(str).forEach(newEl => { el.appendChild(newEl); }); }; /** * Event delegation. * * @param element the DOM element * @param eventName the event * @param selector selector for sub elements * @param fn the event handler function */ const onEvent = (element, eventName, selector, fn) => { element.addEventListener(eventName, e => { let node = e.target || e.srcElement; for (; node && node !== element; node = node.parentNode) { if (node.matches(selector)) { e.delegateTarget = node; fn(e); } } }); }; /** * Gets the style property as rendered via any means (style sheets, inline, etc) but does *not* compute values * @param domNode - the node to get properties for * @param properties - Can be a single property to fetch or an array of properties to fetch */ const getFinalStyle = (domNode, properties) => { if (!(properties instanceof Array)) { properties = [properties]; // eslint-disable-line no-param-reassign } const parent = domNode.parentNode; let originalDisplay; if (parent) { originalDisplay = parent.style.display; parent.style.display = 'none'; } const computedStyles = getComputedStyle(domNode); const result = {}; properties.forEach(prop => { result[prop] = computedStyles[prop]; }); if (parent) { parent.style.display = originalDisplay; } return result; }; /** * Get scroll top of document. */ const getScrollTop = () => (document.documentElement ? document.documentElement.scrollTop : 0) || document.body.scrollTop; /** * Get the outer width with margin of an element. * * @param el the DOM element */ const outerWidthWithMargin = el => { let width = el.offsetWidth; const style = getComputedStyle(el); width += parseInt(style.marginLeft, 10) + parseInt(style.marginRight, 10); return width; }; /** * Get the outer height with margin of an element. * * @param el the DOM element */ const outerHeightWithMargin = el => { let height = el.offsetHeight; const style = getComputedStyle(el); height += parseInt(style.marginTop, 10) + parseInt(style.marginBottom, 10); return height; }; /** * Get sibling elements of the given element. * * @param el the DOM element * @param filter a filter function */ const getSiblings = (el, filter) => { const siblings = []; el = el.parentNode.firstChild; // eslint-disable-line no-param-reassign do { // eslint-disable-line no-cond-assign if (!filter || filter(el)) siblings.push(el); } while (el = el.nextSibling); // eslint-disable-line no-param-reassign return siblings; }; /** * Adds a class if not set. * @param element the element * @param className the class to add */ const addClassIfNeeded = (element, className) => { const addNeeded = element && !element.classList.contains(className); if (addNeeded) { element.classList.add(className); } return addNeeded; }; /** * Removes a class if set. * @param element the element * @param className the class to remove */ const removeClassIfNeeded = (element, className) => { const removeNeeded = element && element.classList.contains(className); if (removeNeeded) { element.classList.remove(className); } return removeNeeded; }; /** * Adds or removes a class if needed. * @param element the element * @param className the class to add or remove * @param add add or remove the class? */ const addOrRemoveClassIfNeeded = (element, className, add) => (add ? addClassIfNeeded : removeClassIfNeeded)(element, className); // CONCATENATED MODULE: ./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js /** * Utility function to execute a selector lookup on the document, * an element or an array of elements * * @param {string} selector The selector to find * @param {Element|Element[]} [el=document] The element(s) relative to which to execute the lookup. * -If no parameter is provided, the page document is used. * If an array is provided, the query is executed on each of them, * and the results are flattened. * @return {Node[]} The nodes found by the query */ const find = (selector, el) => { let safeEl = el; let childrenArr = []; if (!safeEl) { safeEl = document; } else if (typeof safeEl === 'string') { safeEl = Array.prototype.slice.call(document.querySelectorAll(safeEl)); } if (Array.isArray(safeEl)) { childrenArr = safeEl.map(parentEl => parentEl.querySelectorAll(selector)).reduce((acc, children) => acc.concat(Array.prototype.slice.call(children)), []); } else { childrenArr = Array.prototype.slice.call(safeEl.querySelectorAll(selector)); } return childrenArr; }; /** * Convenience function to find all form fields in an element. * * @see find * @param {Element|Element[]} [el] The element(s) relative to which to execute the lookup. * @return {Node[]} The form field nodes found by the query */ const findFormFields = el => find('input, select, textarea, output', el); /** * Determines whether a form element should ne included in its values hash * * @param {Element} element The element to check * @return {boolean} True if it should be included */ const useElement = element => { const disabled = element.disabled, checked = element.checked; const selection = element.type === 'radio' || element.type === 'checkbox'; return !disabled && (!selection || checked); }; /** * Retrieves input data from a form and returns it as a JSON object. * @param {HTMLFormControlsCollection} elements the form elements * @return {Object} form data as an object literal */ const getFormValuesObject = parent => findFormFields(parent).reduce((data, element) => { if (useElement(element)) { data[element.name] = element.value; } return data; }, {}); /** * Populates the input attribute values of the form fields in the provided parent * so that they match their respective property values * * @param {HTMLFormControlsCollection} parent The parent of the elements to refresh */ const refreshAttributes = parent => { findFormFields(parent).forEach(field => { if (field.tagName.toLowerCase() === 'select') { const value = field.value; const selectedOption = Array.from(field.options).find(option => option.getAttribute('selected')); const valueOption = Array.from(field.options).find(option => option.value === value); if (selectedOption) { selectedOption.removeAttribute('selected'); } if (valueOption) { valueOption.setAttribute('selected', 'selected'); } } else { field.setAttribute('value', field.value); } if (field.checked) { field.setAttribute('checked', 'checked'); } else { field.removeAttribute('checked'); } if (field.disabled) { field.setAttribute('disabled', 'disabled'); } else { field.removeAttribute('disabled'); } }); }; /** * Loads in any remote includes that were returned in content in JSON responses as 'wainclude' */ const populateRemoteIncludes = async () => { const remoteIncludes = Array.from(document.querySelectorAll('wainclude')); const operations = remoteIncludes.map(remoteInclude => Object(fetchutils["loadContent"])(remoteInclude)); const results = await Promise.all(operations); results.forEach((result, i) => { const content = result.content, type = result.type; if (type === fetchutils["CONTENT_TYPES"].TEXT) { remoteIncludes[i].outerHTML = content; } }); }; const visible = el => el && !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length); /** * Replaces the passed in component with the updated content * * @param {string} selector Selector for the element to replace * @param {string} content The HTML content to update the element with */ const updateComponent = async (selector, content) => { const components = Array.from(document.querySelectorAll(selector)); const operations = components.map(component => { if (component && visible(component)) { if (content && content.length) { component.outerHTML = content; return populateRemoteIncludes(); } component.remove(); } return Promise.resolve(); }); await Promise.all(operations); }; /** * Creates an event listener using the provided values, removing and potential duplicates beforehan * * @param {EventTarget} el The target to add a listener to * @param {string} evt The event to listen for * @param {Function} handler The event handler to attach */ const addUniqueEventListener = (el, evt, handler) => { el.removeEventListener(evt, handler); el.addEventListener(evt, handler); }; /** * Checks whether the current window width puts the user in the MD style breakpoint * * @return {boolean} True if MD */ const isMD = () => window.matchMedia('(min-width: 769px)').matches; /** * Checks whether the current window width puts the user in the LG style breakpoint * * @return {boolean} True if LG */ const isLG = () => window.matchMedia('(min-width: 992px)').matches; /** * Checks whether the current window width puts the user in the XL style breakpoint * * @return {boolean} True if XL */ const isXL = () => window.matchMedia('(min-width: 1200px)').matches; const isIOS = () => navigator.userAgent.match(/(iPhone|iPod|iPad)/i); const domutils_innerHeight = el => { const style = window.getComputedStyle(el); const height = parseInt(style.height, 10) || 0; const paddingTop = parseInt(style.paddingTop, 10) || 0; const paddingBottom = parseInt(style.paddingBottom, 10) || 0; const borderTopWidth = parseInt(style.borderTopWidth, 10) || 0; const borderBottomWidth = parseInt(style.borderBottomWidth, 10) || 0; return height - paddingTop - paddingBottom - borderTopWidth - borderBottomWidth; }; /** * Determines if the current page was navigated to via back or forward navigation * * @return {boolean} True if back/forward was used */ const isBackForwardNavigation = () => { const LEGACY_BACKFW_TYPE = window.PerformanceNavigation && window.PerformanceNavigation.TYPE_BACK_FORWARD; const perf = window.performance; const legacyNavType = perf && perf.navigation && perf.navigation.type; const navEntry = perf && perf.getEntriesByType && perf.getEntriesByType('navigation')[0]; const navEntryBackFw = navEntry && navEntry.type === 'back_forward'; const legacyNavBackFw = legacyNavType && legacyNavType === LEGACY_BACKFW_TYPE; return !!(navEntryBackFw || legacyNavBackFw); }; /** * @typedef {Object} ElementOffsets * @property {number} top The top offset * @property {number} left The left offset */ /** * Calculates the offsets of the provided element from the document edges * * @param {Element} el The element to calculate for * @return {ElementOffsets} */ const getElementOffset = el => { let top = 0; let left = 0; let element = el; do { top += element.offsetTop || 0; left += element.offsetLeft || 0; element = element.offsetParent; } while (element); return { top, left }; }; /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/util/fetchutils.js": /*!***************************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/util/fetchutils.js + 1 modules ***! \***************************************************************************************/ /*! exports provided: CONTENT_TYPES, CONTENT_TYPES_MAPS, loadContent, attachDataToURL, removeParamsFromURL, getFormData, getURLSearchParams, fetchOptionsGeneral, fetchOptionsGet, fetchOptionsPost */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js because of ./cartridges/app_tfg/cartridge/client/default/js/sfra/productDetail.js */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/jquery/dist/jquery.js (<- Module is not an ECMAScript module) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, "CONTENT_TYPES", function() { return /* binding */ CONTENT_TYPES; }); __webpack_require__.d(__webpack_exports__, "CONTENT_TYPES_MAPS", function() { return /* binding */ CONTENT_TYPES_MAPS; }); __webpack_require__.d(__webpack_exports__, "loadContent", function() { return /* binding */ fetchutils_loadContent; }); __webpack_require__.d(__webpack_exports__, "attachDataToURL", function() { return /* reexport */ attachDataToURL; }); __webpack_require__.d(__webpack_exports__, "removeParamsFromURL", function() { return /* reexport */ removeParamsFromURL; }); __webpack_require__.d(__webpack_exports__, "getFormData", function() { return /* reexport */ getFormData; }); __webpack_require__.d(__webpack_exports__, "getURLSearchParams", function() { return /* reexport */ getURLSearchParams; }); __webpack_require__.d(__webpack_exports__, "fetchOptionsGeneral", function() { return /* reexport */ fetchOptionsGeneral; }); __webpack_require__.d(__webpack_exports__, "fetchOptionsGet", function() { return /* reexport */ fetchOptionsGet; }); __webpack_require__.d(__webpack_exports__, "fetchOptionsPost", function() { return /* reexport */ fetchOptionsPost; }); // EXTERNAL MODULE: ./node_modules/jquery/dist/jquery.js var jquery = __webpack_require__("./node_modules/jquery/dist/jquery.js"); var jquery_default = /*#__PURE__*/__webpack_require__.n(jquery); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js + 1 modules var domutils = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); // CONCATENATED MODULE: ./cartridges/app_bee_base/cartridge/client/default/js/util/fetchutils.js function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } // URL manipulation // ================ const DUMMY_HOST_PROTOCOL = 'http://dummy'; const prepareURL = url => { let theURL; try { theURL = new URL(url); } catch (e) { if (url.indexOf('/') === 0) { theURL = new URL(url, DUMMY_HOST_PROTOCOL); } else { throw e; } } return theURL; }; const prepareURLString = url => { let urlString = url.toString(); if (urlString.indexOf(`${DUMMY_HOST_PROTOCOL}/`) === 0) { urlString = urlString.substring(DUMMY_HOST_PROTOCOL.length); } return urlString; }; /** * Attach object data to an existing URL. * * @param url the URL * @param data the data to attach */ const attachDataToURL = (url, data) => { const theURL = prepareURL(url); const searchParams = new URLSearchParams(theURL.search); Object.keys(data).forEach(key => { let value = data[key]; if (value === null || value === undefined) { value = ''; } searchParams.set(key, value); }); theURL.search = searchParams.toString(); return prepareURLString(theURL); }; /** * Remove parameters from the given URL. * * @param url the URL * @param paramsToRemove the params to remove */ const removeParamsFromURL = (url, paramsToRemove) => { const theURL = prepareURL(url); const searchParams = new URLSearchParams(theURL.search); paramsToRemove.forEach(param => { searchParams.delete(param); }); theURL.search = searchParams.toString(); return prepareURLString(theURL); }; // Preparation of form data // ======================== /** * Create a new container for form data (can be FormData or URLSearchParams) and add an object to it. * @param object the object containing ghe data to add * @param FormDataContainer the form data container type */ const objToFormDataContainer = (object, FormDataContainer) => Object.keys(object).reduce((formData, key) => { formData.append(key, object[key]); return formData; }, new FormDataContainer()); /** * Create a FormData object using an object. * @param object the object containing ghe data to add */ const getFormData = object => objToFormDataContainer(object, FormData); /** * Create a URLSearchParams object using an object. * @param object the object containing ghe data to add */ const getURLSearchParams = object => objToFormDataContainer(object, URLSearchParams); // Request preparation // =================== /** * General options for all types of fetch requests. */ const fetchGeneral = { credentials: 'same-origin' }; /** * General headers for all types of fetch requests. */ const fetchHeadersGeneral = { 'X-Requested-With': 'XMLHttpRequest' }; /** * Generate options for fetch requests. * This contains general options and headers. * @param options (optional) options for the request merged with the general options * @param additionalHeaders (optional) additional headers for the request merged with the general headers */ const fetchOptionsGeneral = function fetchOptionsGeneral() { let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; let additionalHeaders = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; return _objectSpread({}, fetchGeneral, { headers: _objectSpread({}, fetchHeadersGeneral, additionalHeaders) }, options); }; /** * Generate options for GET requests. * This contains general options and headers. * @param options (optional) options for the request merged with the general options * @param additionalHeaders (optional) additional headers for the request merged with the general headers */ const fetchOptionsGet = function fetchOptionsGet() { let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; let additionalHeaders = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; return fetchOptionsGeneral(_objectSpread({ method: 'GET' }, options), additionalHeaders); }; /** * Generate options for general POST requests. * This contains general options and headers. * @param body the body for the POST request * @param options (optional) options for the request merged with the general options * @param additionalHeaders (optional) additional headers for the request merged with the general headers */ const fetchOptionsPost = function fetchOptionsPost(body) { let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; let additionalHeaders = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; return fetchOptionsGeneral(_objectSpread({ method: 'POST', body }, options), additionalHeaders); }; // Exports // ======= // CONCATENATED MODULE: ./cartridges/app_tfg/cartridge/client/default/js/util/fetchutils.js // eslint-disable-line import/named // eslint-disable-line import/named const CONTENT_TYPES = { TEXT: 'TEXT', JSON: 'JSON' }; const CONTENT_TYPES_MAPS = { [CONTENT_TYPES.TEXT]: ['text/html', 'text/plain'], [CONTENT_TYPES.JSON]: ['text/json', 'application/json'] }; const isType = (typeParts, contentType) => typeParts.some(part => contentType.indexOf(part) >= 0); const getResponseType = response => { let type = null; if (response) { const contentTypeHeader = response.headers.get('content-type') || ''; const contentType = contentTypeHeader.toLowerCase(); if (isType(CONTENT_TYPES_MAPS[CONTENT_TYPES.JSON], contentType)) { type = CONTENT_TYPES.JSON; } else if (isType(CONTENT_TYPES_MAPS[CONTENT_TYPES.TEXT], contentType)) { type = CONTENT_TYPES.TEXT; } } return type; }; const getResponseContent = async (response, type) => { let content; switch (type) { case CONTENT_TYPES.JSON: content = await response.json(); break; case CONTENT_TYPES.TEXT: content = await response.text(); break; default: content = null; } return content; }; const getUrl = item => { let url = item.href || item.action || item.dataset.action || item.getAttribute('url'); if (url && url.indexOf('http') !== 0) { url = `${window.location.protocol}//${window.location.host}${url}`; } return url; }; const startSpinner = urlSource => { let spinnerContainer; const supportedTags = ['form', 'div', 'span', 'ul']; if (urlSource) { spinnerContainer = urlSource.closest('[data-spinner-target]'); if (!spinnerContainer && supportedTags.indexOf(urlSource.tagName.toLowerCase()) >= 0) { spinnerContainer = urlSource; } } if (!spinnerContainer) { spinnerContainer = document.body; } jquery_default()(spinnerContainer).spinner().start(); return spinnerContainer; }; const fetchutils_loadContent = async function loadContent(trigger) { let loadUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; let additionalData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; let showSpinner = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; const urlSource = getUrl(trigger) ? trigger : trigger.form; let url = loadUrl || getUrl(urlSource); const method = urlSource && (urlSource.method || urlSource.dataset.method) || 'get'; let options; let formValues = Object(domutils["getFormValuesObject"])(urlSource); if (urlSource && urlSource.name && urlSource.tagName && urlSource.tagName.toLowerCase() === 'input') { let value = urlSource.value; if (urlSource.type === 'radio' || urlSource.type === 'checkbox') { value = urlSource.checked; } formValues = Object.assign({}, { [urlSource.name]: value }, formValues); } if (typeof additionalData === 'object') { formValues = Object.assign({}, additionalData, formValues); } if (method === 'post') { const formData = getFormData(formValues); options = fetchOptionsPost(formData); } else { const urlObject = new URL(url); const urlParams = new URLSearchParams(urlObject.search); const formUrlParams = getURLSearchParams(formValues); // eslint-disable-next-line no-restricted-syntax for (const formUrlParamName of formUrlParams.keys()) { urlParams.set(formUrlParamName, formUrlParams.get(formUrlParamName)); } urlObject.search = urlParams.toString(); url = urlObject.toString(); options = fetchOptionsGet(); } let spinner = null; if (showSpinner) { spinner = startSpinner(urlSource); } const response = await fetch(url, options); const type = getResponseType(response); const content = await getResponseContent(response, type); if (showSpinner) { jquery_default()(spinner).spinner().stop(); } return { url, type, content }; }; /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/util/scrollTo.js": /*!*************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/util/scrollTo.js ***! \*************************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _domutils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); /** * Allows for consistently scrolling the viewport to a specified element * * @param {string|Element|number} targetSelector Selector for the element or Y offset to scroll to */ /* harmony default export */ __webpack_exports__["default"] = (function (targetSelector) { let smooth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; let scrollTarget = targetSelector; if (typeof targetSelector === 'string') { scrollTarget = document.querySelector(targetSelector); } if (scrollTarget && scrollTarget instanceof Element) { let top = Object(_domutils__WEBPACK_IMPORTED_MODULE_0__["getElementOffset"])(scrollTarget).top - 100; if (Object(_domutils__WEBPACK_IMPORTED_MODULE_0__["isLG"])()) { top = Object(_domutils__WEBPACK_IMPORTED_MODULE_0__["getElementOffset"])(scrollTarget).top - 175; } window.scroll({ top, behavior: smooth ? 'smooth' : 'auto' }); } if (typeof scrollTarget === 'number' && !Number.isNaN(scrollTarget)) { window.scroll({ top: scrollTarget, behavior: smooth ? 'smooth' : 'auto' }); } }); /***/ }), /***/ "./cartridges/app_tfg/cartridge/client/default/js/util/urlutils.js": /*!*************************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/client/default/js/util/urlutils.js ***! \*************************************************************************/ /*! exports provided: appendToUrl, parseQueryString, removeParamsFromUrl */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "appendToUrl", function() { return appendToUrl; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseQueryString", function() { return parseQueryString; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeParamsFromUrl", function() { return removeParamsFromUrl; }); function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } const safeDecodeURIComponent = value => { let decodedValue = value; try { decodedValue = decodeURIComponent(value); } catch (e) {// Contains a non-decodable symbol, which means it's already decoded } return decodedValue; }; const appendToUrl = (url, params) => { let newUrl = url; newUrl += (newUrl.indexOf('?') !== -1 ? '&' : '?') + Object.keys(params).map(key => `${key}=${encodeURIComponent(params[key])}`).join('&'); return newUrl; }; const parseQueryString = queryStringUrl => { const queryString = queryStringUrl.split(/[#?]/)[1] || queryStringUrl; const params = queryString.split('&').reduce((acc, pair) => { const pairParts = pair.split('='); const _pairParts = _slicedToArray(pairParts, 2), paramName = _pairParts[0], paramValue = _pairParts[1]; if (paramName && paramValue) { const decodeSafeValue = paramValue.replace(/\+/g, '%20'); return Object.assign(acc, { [paramName]: safeDecodeURIComponent(decodeSafeValue) }); } return acc; }, {}); return params; }; const removeParamsFromUrl = (url, params) => { const _url$split = url.split('?'), _url$split2 = _slicedToArray(_url$split, 2), baseUrl = _url$split2[0], qs = _url$split2[1]; const modifiedQs = (qs || '').split('&').filter(qsPair => params.indexOf(qsPair.split('=')[0]) < 0).join('&'); return baseUrl + (modifiedQs ? `?${modifiedQs}` : ''); }; /***/ }), /***/ "./cartridges/app_tfg/cartridge/scripts/helpers/sizeHelpers.js": /*!*********************************************************************!*\ !*** ./cartridges/app_tfg/cartridge/scripts/helpers/sizeHelpers.js ***! \*********************************************************************/ /*! no static exports found */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { "use strict"; function handleSizeConversion(baseSize, defaultSizes, countrySizes, zeroPrefix, countryPrefix) { let convertedSize = baseSize; let numericSize; if (baseSize.indexOf('.') > -1) { numericSize = parseFloat(baseSize, 10); } else { numericSize = parseInt(baseSize, 10); } const sizeIndex = defaultSizes.indexOf(numericSize); if (sizeIndex >= 0) { const currentCountrySize = countrySizes[sizeIndex]; if (typeof currentCountrySize !== 'undefined') { convertedSize = currentCountrySize; if (zeroPrefix && convertedSize.toString().length === 1 && convertedSize.toString().length !== '0') { convertedSize = '0' + convertedSize; } } } if (countryPrefix) { convertedSize = countryPrefix + ' ' + convertedSize; } return convertedSize; } module.exports = { handleSizeConversion: handleSizeConversion }; /***/ }), /***/ "./cartridges/int_cloudinary_sfra/cartridge/client/default/js/components/cloudinaryMiniCart.js": /*!*****************************************************************************************************!*\ !*** ./cartridges/int_cloudinary_sfra/cartridge/client/default/js/components/cloudinaryMiniCart.js ***! \*****************************************************************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module uses injected variables ($) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* WEBPACK VAR INJECTION */(function($) { /* harmony default export */ __webpack_exports__["default"] = (function () { // Custom Start: Make cart product images responsive // $('.minicart').bind('DOMSubtreeModified', function (e) { if (e.target.innerHTML.length > 0) { if (typeof window.makeCloudinaryImagesResponsive !== 'undefined') { window.makeCloudinaryImagesResponsive(); } } }); // Custom End: Make cart product images responsive // }); /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"))) /***/ }), /***/ "./cartridges/int_cloudinary_sfra/cartridge/client/default/js/components/search.js": /*!*****************************************************************************************!*\ !*** ./cartridges/int_cloudinary_sfra/cartridge/client/default/js/components/search.js ***! \*****************************************************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module uses injected variables ($) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* WEBPACK VAR INJECTION */(function($) {/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~base */ "./cartridges/app_tfg/cartridge/client/default/js/components/search.js"); /* harmony default export */ __webpack_exports__["default"] = (function () { Object(_base__WEBPACK_IMPORTED_MODULE_0__["default"])(); // Custom Start: Make suggested product images responsive // $('.suggestions-wrapper').bind('DOMSubtreeModified', function (e) { if (e.target.innerHTML.length > 0) { if (typeof window.makeCloudinaryImagesResponsive !== 'undefined') { window.makeCloudinaryImagesResponsive(); } } }); // Custom End: Make suggested product images responsive // }); /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"))) /***/ }), /***/ "./cartridges/int_cloudinary_sfra/cartridge/client/default/js/main.js": /*!****************************************************************************!*\ !*** ./cartridges/int_cloudinary_sfra/cartridge/client/default/js/main.js ***! \****************************************************************************/ /*! no exports provided */ /*! ModuleConcatenation bailout: Module uses injected variables ($) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* WEBPACK VAR INJECTION */(function($) {/* harmony import */ var base_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! base/util */ "./cartridges/app_tfg/cartridge/client/default/js/util.js"); /* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ~base */ "./cartridges/int_gtm/cartridge/client/default/js/main.js"); // eslint-disable-next-line // window.jQuery = window.$ = require('jquery'); var processInclude = base_util__WEBPACK_IMPORTED_MODULE_0__["default"]; $(document).ready(function () { processInclude(__webpack_require__(/*! ./components/search */ "./cartridges/int_cloudinary_sfra/cartridge/client/default/js/components/search.js")); processInclude(__webpack_require__(/*! ./components/cloudinaryMiniCart */ "./cartridges/int_cloudinary_sfra/cartridge/client/default/js/components/cloudinaryMiniCart.js")); }); /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"))) /***/ }), /***/ "./cartridges/int_cybersource_sfra/cartridge/client/default/js/components/CSminiCart.js": /*!**********************************************************************************************!*\ !*** ./cartridges/int_cybersource_sfra/cartridge/client/default/js/components/CSminiCart.js ***! \**********************************************************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module uses injected variables ($) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* WEBPACK VAR INJECTION */(function($) { // var cart = require('base/cart/cart'); /* eslint-disable no-undef */ /* harmony default export */ __webpack_exports__["default"] = (function () { // cart(); $('.minicart').on('count:update', function (event, count) { if (count && $.isNumeric(count.quantityTotal)) { $('.minicart .minicart-quantity').text(count.quantityTotal); } }); $('.minicart').off('mouseenter focusin touchstart').on('mouseenter focusin touchstart', function (event) { if ($('.search:visible').length === 0) { return; } var url = $('.minicart').data('action-url'); var count = parseInt($('.minicart .minicart-quantity').text(), 10); if (count !== 0 && $('.minicart .popover.show').length === 0) { $('.minicart .popover').addClass('show'); $('.minicart .popover').spinner().start(); $.get(url, function (data) { $('.minicart .popover').empty(); $('.minicart .popover').append(data); var isPaypalEnabled = !!($('#paypal_enabled').length > 0 && document.getElementById('paypal_enabled').value === 'true'); var isGooglePayEnabled = !!($('#isGooglePayEnabled').length > 0 && $('#isGooglePayEnabled').val() === 'true'); if (isPaypalEnabled) { paypalhelper.paypalMini(); } if (isGooglePayEnabled) { onGooglePayLoaded(); } $.spinner().stop(); }); } event.stopImmediatePropagation(); }); $('body').on('touchstart click', function (e) { if ($('.minicart').has(e.target).length <= 0) { $('.minicart .popover').empty(); $('.minicart .popover').removeClass('show'); } }); $('.minicart').on('mouseleave focusout', function (event) { if (event.type === 'focusout' && $('.minicart').has(event.target).length > 0 || event.type === 'mouseleave' && $(event.target).is('.minicart .quantity') || $('body').hasClass('modal-open')) { event.stopPropagation(); return; } if (!($(document).find('.paypal-checkout-sandbox').length > 0)) { $('.minicart .popover').empty(); $('.minicart .popover').removeClass('show'); } event.stopImmediatePropagation(); }); $('body').on('change', '.minicart .quantity', function () { if ($(this).parents('.bonus-product-line-item').length && $('.cart-page').length) { // eslint-disable-next-line location.reload(); } }); }); /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"))) /***/ }), /***/ "./cartridges/int_cybersource_sfra/cartridge/client/default/js/main.js": /*!*****************************************************************************!*\ !*** ./cartridges/int_cybersource_sfra/cartridge/client/default/js/main.js ***! \*****************************************************************************/ /*! no exports provided */ /*! ModuleConcatenation bailout: Module uses injected variables ($) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* WEBPACK VAR INJECTION */(function($) {/* harmony import */ var base_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! base/util */ "./cartridges/app_tfg/cartridge/client/default/js/util.js"); // eslint-disable-next-line // window.jQuery = window.$ = require('jquery'); var processInclude = base_util__WEBPACK_IMPORTED_MODULE_0__["default"]; $(document).ready(function () { processInclude(__webpack_require__(/*! base/main */ "./cartridges/plugin_wishlists_tfg/cartridge/client/default/js/main.js")); processInclude(__webpack_require__(/*! ./components/CSminiCart */ "./cartridges/int_cybersource_sfra/cartridge/client/default/js/components/CSminiCart.js")); }); /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"))) /***/ }), /***/ "./cartridges/int_gtm/cartridge/client/default/js/components/clientSideValidation.js": /*!*******************************************************************************************!*\ !*** ./cartridges/int_gtm/cartridge/client/default/js/components/clientSideValidation.js ***! \*******************************************************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./cartridges/app_storefront_base/cartridge/client/default/js/main.js (referenced with cjs require) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~base */ "./cartridges/app_tfg/cartridge/client/default/js/components/clientSideValidation.js"); const baseInvalid = _base__WEBPACK_IMPORTED_MODULE_0__["default"].invalid; _base__WEBPACK_IMPORTED_MODULE_0__["default"].invalid = () => { baseInvalid.call(undefined); document.querySelectorAll('form input, form select').forEach(field => { field.addEventListener('invalid', function (e) { e.preventDefault(); if (!this.validity.valid) { const dataLayer = window[window.googleAnalytics.DATA_LAYER_NAME]; if (dataLayer) { const event = { message: this.closest('.form-group').querySelector('.invalid-feedback').innerText }; dataLayer.push(event); } } }); }); }; /* harmony default export */ __webpack_exports__["default"] = (_base__WEBPACK_IMPORTED_MODULE_0__["default"]); /***/ }), /***/ "./cartridges/int_gtm/cartridge/client/default/js/main.js": /*!****************************************************************************!*\ !*** ./cartridges/int_gtm/cartridge/client/default/js/main.js + 8 modules ***! \****************************************************************************/ /*! no exports provided */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@glidejs/glide/dist/glide.esm.js because of ./cartridges/app_tfg/cartridge/client/default/js/sfra/productDetail.js */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/int_cybersource_sfra/cartridge/client/default/js/main.js (<- Module uses injected variables ($)) */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/components/ajax.js because of ./cartridges/int_adyen_tfg/cartridge/client/default/js/checkout/billing.js */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/components/backToTop.js because of ./cartridges/app_tfg/cartridge/client/default/js/product/components/stockCheck.js */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/components/flyoutUnderHeader.js because of ./cartridges/app_tfg/cartridge/client/default/js/appointments/appointments.js */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/components/forms.js because of ./cartridges/app_tfg/cartridge/client/default/js/checkout/shipping.js */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/components/header.js because of ./cartridges/int_hubbox_sfra_tfg/cartridge/client/default/js/chunks/hubbox.val.js */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/components/stickyHeaderScroll.js because of ./cartridges/app_tfg/cartridge/client/default/js/product/base.js */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/search/productTile.js because of ./cartridges/app_tfg/cartridge/client/default/js/search/search.js */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/util.js because of ./cartridges/app_hobbs/cartridge/client/default/js/index.js */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js because of ./cartridges/app_tfg/cartridge/client/default/js/sfra/productDetail.js */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/int_loqate_tfg/cartridge/client/default/js/components/addressForm.js because of ./cartridges/app_tfg/cartridge/client/default/js/checkout/shipping.js */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/body-scroll-lock/lib/bodyScrollLock.min.js (<- Module is not an ECMAScript module) */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/jquery/dist/jquery.js (<- Module is not an ECMAScript module) */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/smoothscroll-polyfill/dist/smoothscroll.js (<- Module is not an ECMAScript module) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // NAMESPACE OBJECT: ./cartridges/int_gtm/cartridge/client/default/js/googleAnalytics/googleAnalytics.js var googleAnalytics_namespaceObject = {}; __webpack_require__.r(googleAnalytics_namespaceObject); __webpack_require__.d(googleAnalytics_namespaceObject, "polyfillBeaconAPI", function() { return polyfillBeaconAPI; }); __webpack_require__.d(googleAnalytics_namespaceObject, "installAjaxHandlers", function() { return installAjaxHandlers; }); __webpack_require__.d(googleAnalytics_namespaceObject, "pushRemoteIncludeEvents", function() { return pushRemoteIncludeEvents; }); // NAMESPACE OBJECT: ./cartridges/int_gtm/cartridge/client/default/js/googleAnalytics/clientSideEvents.js var clientSideEvents_namespaceObject = {}; __webpack_require__.r(clientSideEvents_namespaceObject); __webpack_require__.d(clientSideEvents_namespaceObject, "productClick", function() { return productClick; }); // NAMESPACE OBJECT: ./cartridges/app_tfg/cartridge/client/default/js/search/intelligentReach.js var intelligentReach_namespaceObject = {}; __webpack_require__.r(intelligentReach_namespaceObject); __webpack_require__.d(intelligentReach_namespaceObject, "alpProductLoad", function() { return alpProductLoad; }); __webpack_require__.d(intelligentReach_namespaceObject, "default", function() { return intelligentReach; }); // EXTERNAL MODULE: ./node_modules/jquery/dist/jquery.js var jquery = __webpack_require__("./node_modules/jquery/dist/jquery.js"); var jquery_default = /*#__PURE__*/__webpack_require__.n(jquery); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/util.js + 1 modules var util = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/util.js"); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/ajax.js var ajax = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/components/ajax.js"); // CONCATENATED MODULE: ./cartridges/int_gtm/cartridge/client/default/js/googleAnalytics/googleAnalytics.js /** * When the GTM events are pushed with the value 'beacon' in the field 'transport', * the dataLayer library will attempt to use the Beacon API, * so events can be tracked despite of the user navigating away form the page; * * However, it is not supported by all browsers that are still in use: * https://caniuse.com/#feat=beacon * * This function polyfills the sendBeacon method of the window's navigator * with a synchrnouse XMLHttpRequest, to guarantee correct tracking * * Source: Polyfill Service (https://github.com/Financial-Times/polyfill-service) */ const polyfillBeaconAPI = () => { window.navigator.sendBeacon = window.navigator.sendBeacon || function (url, data) { const xhr = 'XMLHttpRequest' in window ? new XMLHttpRequest() : new window.ActiveXObject('Microsoft.XMLHTTP'); xhr.open('POST', url, false); xhr.setRequestHeader('Accept', '*/*'); if (typeof data === 'string') { xhr.setRequestHeader('Content-Type', 'text/plain;charset=UTF-8'); xhr.responseType = 'text/plain'; } else if (Object.prototype.toString.call(data) === '[object Blob]') { if (data.type) { xhr.setRequestHeader('Content-Type', data.type); } } xhr.send(data); return true; }; }; /** * Removes old data from the DataLayer when it needs to be replaced */ const replaceDataLayerProperty = event => { const gtm = window.google_tag_manager[window.googleAnalytics.CONTAINER_ID]; if (gtm) { Object.keys(event.replace).forEach(propKey => { gtm.dataLayer.set(propKey, undefined); event[propKey] = event.replace[propKey]; }); } delete event.replace; return event; }; /** * Checks the results of all AJAX requests for JSON, * containing analytics events, and pushes them to the data layer, if any */ const handleAjaxEvents = (dataLayer, responseText) => { let events = []; try { // Handle JSON repsponses const response = JSON.parse(responseText); events = response[window.googleAnalytics.ANALYTICS_EVENTS_KEY]; } catch (ex) { if (typeof responseText === 'object') { events = responseText[window.googleAnalytics.ANALYTICS_EVENTS_KEY]; } else if (typeof responseText === 'string') { // Handle HTML responses using the GTM events decorator template const contentEl = document.createElement('div'); contentEl.innerHTML = responseText; contentEl.querySelectorAll('[name="analytics-events"]').forEach(input => { events = events.concat(JSON.parse(input.value)); }); } } if (events && events.length) { for (let i = 0; i < events.length; i++) { if (events[i].replace) { events[i] = replaceDataLayerProperty(events[i]); } dataLayer.push(events[i]); } } return responseText; }; /** * Extend the AJAX mechanisms that get used to allow for tracking any events in their responses */ const installAjaxHandlers = () => { const dataLayer = window[window.googleAnalytics.DATA_LAYER_NAME]; // Don't attach the listener if GTM or GA are not enabled if (!dataLayer) { return; } ajax["functions"].onComplete(handleAjaxEvents.bind(null, dataLayer)); }; /** * Checks the page for partial remote include templates, * containing analytics events, and pushes them to the data layer, if any */ const pushRemoteIncludeEvents = () => { let events = []; const dataLayer = window[window.googleAnalytics.DATA_LAYER_NAME]; // Don't query the DOM if GTM or GA are not enabled if (!dataLayer) { return; } document.querySelectorAll('[name="analytics-events"]').forEach(input => { events = events.concat(JSON.parse(input.value)); }); if (events && events.length) { for (let i = 0; i < events.length; i++) { dataLayer.push(events[i]); } } }; // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js + 1 modules var domutils = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); // CONCATENATED MODULE: ./cartridges/int_gtm/cartridge/client/default/js/googleAnalytics/clientSideEvents.js const getDataLayer = () => { let dataLayer = []; if (window.googleAnalytics && window[window.googleAnalytics.DATA_LAYER_NAME]) { dataLayer = window[window.googleAnalytics.DATA_LAYER_NAME]; } return dataLayer; }; const getCurrency = dataLayer => { const currencyEvt = dataLayer.find(evt => evt.currency); if (currencyEvt) { return currencyEvt.currency; } return null; }; const getProductList = trigger => { const listContainers = { 'recommendation - CTL': '#looksGreatWith', 'recommendation - YMAL': '#recommendations', PDP: '[data-action="Product-Show"]', 'PLP - category': '[data-action="Search-Show"][data-querystring*="cgid="]', 'PLP - search results': '[data-action="Search-Show"][data-querystring*="q="]', 'PLP - other': '[data-action="Search-Show"]', 'Recently viewed': '.product-detail__recently-viewed', 'cart - wishlist': '.cart-wishlist-section', wishlist: '[data-action="Wishlist-Show"]' }; return Object.keys(listContainers).find(listName => trigger.closest(listContainers[listName])) || 'other'; }; const getProductObject = trigger => { const trackingEl = trigger.closest('[data-tracking]'); if (trackingEl) { return Object(domutils["getJSONData"])(trackingEl, 'tracking', null); } return null; }; // eslint-disable-next-line import/prefer-default-export const productClick = () => { ['click', 'auxclick'].forEach(evt => { Object(domutils["onEvent"])(document, evt, '.product-tile .link', e => { const dataLayer = getDataLayer(); const productObj = getProductObject(e.delegateTarget); // Only a standard left click needs to be aborted and handled with a callback; // Scroll/Middle button clicks open a new tab, so they will be tracked by the current tab; same for Ctrl + Click // Right clicks must open a context menu, so no way to track those const standardClick = evt === 'click' && e.button === 0 && !e.ctrlClick; const auxilliaryClick = evt === 'auxclick' && e.button >= 2; if (auxilliaryClick) { // Auxilliary buttons usually don't interact with links, so no need to track them return; } if (productObj) { try { const payload = { event: 'eec.productClick', ecommerce: { currencyCode: getCurrency(dataLayer), click: { actionField: { list: getProductList(e.delegateTarget) }, products: [productObj] } } }; if (standardClick) { payload.eventCallback = () => { window.location.href = e.delegateTarget.href; }; payload.eventTimeout = 300; } dataLayer.push(payload); } catch (_unused) { return; } if (standardClick) { e.preventDefault(); setTimeout(() => { window.location.href = e.delegateTarget.href; }, 1000); } } }); }); }; // EXTERNAL MODULE: ./node_modules/jspolyfill-array.prototype.find/find.js var find = __webpack_require__("./node_modules/jspolyfill-array.prototype.find/find.js"); // EXTERNAL MODULE: ./node_modules/smoothscroll-polyfill/dist/smoothscroll.js var smoothscroll = __webpack_require__("./node_modules/smoothscroll-polyfill/dist/smoothscroll.js"); var smoothscroll_default = /*#__PURE__*/__webpack_require__.n(smoothscroll); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/header.js + 1 modules var header = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/components/header.js"); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/search/productTile.js var productTile = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/search/productTile.js"); // EXTERNAL MODULE: ./cartridges/int_loqate_tfg/cartridge/client/default/js/components/addressForm.js + 1 modules var addressForm = __webpack_require__("./cartridges/int_loqate_tfg/cartridge/client/default/js/components/addressForm.js"); // EXTERNAL MODULE: ./node_modules/body-scroll-lock/lib/bodyScrollLock.min.js var bodyScrollLock_min = __webpack_require__("./node_modules/body-scroll-lock/lib/bodyScrollLock.min.js"); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/flyoutUnderHeader.js var flyoutUnderHeader = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/components/flyoutUnderHeader.js"); // CONCATENATED MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/bodyScroll.js const disableBodyScrollModalWrapper = e => { Object(bodyScrollLock_min["disableBodyScroll"])(e.target); }; const disableBodyScrollFlyoutWrapper = e => { let target = null; if (e.detail) { if (e.detail.noScrollLock) { return; } if (e.detail.content) { target = e.detail.content; // Generic flyouts } else if (e.detail.flyout) { target = e.detail.flyout; // Menu flyout } } if (target) { Object(bodyScrollLock_min["disableBodyScroll"])(target, { allowTouchMove: el => { if (target.contains(el)) { let currentEl = el; while (currentEl && currentEl !== target) { if (currentEl.scrollHeight > currentEl.clientHeight) { return true; } currentEl = currentEl.parentNode; } } return false; } }); } }; /* harmony default export */ var bodyScroll = (() => { jquery_default()(document).on('show.bs.modal', disableBodyScrollModalWrapper).on('hidden.bs.modal', bodyScrollLock_min["clearAllBodyScrollLocks"]); document.addEventListener(flyoutUnderHeader["EVENTS"].FLYOUT_OPEN, disableBodyScrollFlyoutWrapper); document.addEventListener(flyoutUnderHeader["EVENTS"].FLYOUT_CLOSE, bodyScrollLock_min["clearAllBodyScrollLocks"]); }); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/backToTop.js var backToTop = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/components/backToTop.js"); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/forms.js var components_forms = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/components/forms.js"); // CONCATENATED MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/recaptcha.js /* global grecaptcha */ const SELECTORS = { RECAPTCHA_ELEMENT: '.g-recaptcha-key' }; /* harmony default export */ var recaptcha = (() => { const placeholder = document.querySelector(SELECTORS.RECAPTCHA_ELEMENT); if (placeholder) { const form = placeholder.closest('form'); if (form) { const btn = form.querySelector('[data-action=submit_captcha]'); btn.disabled = true; const sitekey = placeholder.dataset.sitekey; grecaptcha.ready(() => { grecaptcha.execute(sitekey, { action: 'submit_captcha' }).then(token => { btn.disabled = false; form.querySelector('.g-recaptcha-response').value = token; }); }); } } }); // CONCATENATED MODULE: ./cartridges/app_tfg/cartridge/client/default/js/search/intelligentReach.js /* eslint-disable jquery/no-ajax */ /* eslint-disable jquery/no-trigger */ /* eslint-disable jquery/no-html */ /* eslint-disable jquery/no-class */ /* eslint-disable no-console */ /* eslint-disable no-alert */ const intelligentReach_SELECTORS = { ALP_SIZE_LINK: '.intelligent-reach-section .size-link', ALP_SIZE_LINK_SPAN: '.intelligent-reach-section .size_inner_space_new', ALP_ADD_TO_CART: '.intelligent-reach-section .basket_btn' }; // ALP Events const removeSelectedClass = () => { const searchInputs = document.querySelectorAll('.intelligent-reach-section .size-link'); searchInputs.forEach(searchField => { searchField.classList.remove('sizeSelected'); searchField.classList.remove('product-detail__attribute__value--current'); }); }; const alpProductLoad = () => { jquery_default()(document).on('click', intelligentReach_SELECTORS.ALP_SIZE_LINK, e => { const sizelink = e.target; const basketButton = document.querySelector(intelligentReach_SELECTORS.ALP_ADD_TO_CART); const sizelinkObj = sizelink.classList.contains('size_inner_space_new') ? sizelink.parentElement : sizelink; if (!sizelinkObj.classList.contains('out_of_stock')) { removeSelectedClass(); sizelinkObj.classList.add('sizeSelected'); sizelinkObj.classList.add('product-detail__attribute__value--current'); basketButton.dataset.pid = sizelinkObj.dataset.id; if (jquery_default()('.intelligent-reach-section .size_new').hasClass('product-detail__attribute--error')) { jquery_default()('.intelligent-reach-section .size_new').removeClass('product-detail__attribute--error'); jquery_default()('.product-detail__attribute__error').html(''); } // basketButton.disabled = false; } else {// basketButton.disabled = true; } }); jquery_default()(document).on('click', intelligentReach_SELECTORS.ALP_ADD_TO_CART, e => { let execute = true; const buttonObj = e.target; const searchInputs = document.querySelectorAll('.intelligent-reach-section .size-link.sizeSelected'); if (searchInputs.length === 0) { jquery_default()('.intelligent-reach-section .size_new').addClass('product-detail__attribute--error'); jquery_default()('.product-detail__attribute__error').html('Please select your size'); execute = false; } if (execute) { const productId = buttonObj.dataset.pid; const qty = buttonObj.dataset.minQuantity; const addToCartAjexUrl = buttonObj.dataset.addToCartUrl; const dataObj = { pid: productId, quantity: qty }; if (addToCartAjexUrl) { jquery_default.a.ajax({ url: addToCartAjexUrl, method: 'POST', data: dataObj, success: function success(data) { jquery_default()('.minicart').trigger('count:update', data); jquery_default()('body').trigger('product:afterAddToCart', data); jquery_default.a.spinner().stop(); }, error: function error() { jquery_default.a.spinner().stop(); } }); } } }); }; /* harmony default export */ var intelligentReach = (() => { if (jquery_default()('.intelligent-reach-section').length > 0) { alpProductLoad(); } }); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/stickyHeaderScroll.js var stickyHeaderScroll = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/components/stickyHeaderScroll.js"); // CONCATENATED MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/validateInput.js /* harmony default export */ var validateInput = (() => { jquery_default()(document).on('change keyup', '.inputValidate', function () { // eslint-disable-next-line no-useless-escape const regex = /[^\w\s`!@#$£%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/g; jquery_default()(this).val(jquery_default()(this).val().replace(regex, '')); // eslint-disable-line jquery/no-val }); function isValidURL(url) { try { // eslint-disable-next-line no-new new URL(url); // URL constructor will throw an error if invalid return true; } catch (_unused) { return false; } } jquery_default()(document).on('change', '.validateName', function () { const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; // eslint-disable-next-line jquery/no-val if (emailRegex.test(jquery_default()(this).val()) || isValidURL(jquery_default()(this).val())) { // eslint-disable-next-line jquery/no-val jquery_default()(this).val(''); } const urlPattern = /(www|=|:|\.|https|https:\/\/|\/|#|\?)/g; jquery_default()(this).val(jquery_default()(this).val().replace(urlPattern, '')); // eslint-disable-line jquery/no-val }); }); jquery_default()(document).on('invalid', '#phoneNumber, #phone', function () { let newText = this.validationMessage; if (this.validity.tooShort && !this.validity.patternMismatch) { // eslint-disable-next-line jquery/no-data const oldText = jquery_default()('#phoneNumber, #phone').data('range-error'); // eslint-disable-next-line jquery/no-val const charLen = jquery_default()(this).val().length; newText = oldText.replace('X', charLen); // eslint-disable-next-line jquery/no-attr jquery_default()('#phoneNumber, #phone').attr('data-range-error', newText); } // eslint-disable-next-line jquery/no-text jquery_default()('#phoneNumber, #phone').siblings('.invalid-feedback').text(newText); }); // EXTERNAL MODULE: ./node_modules/@glidejs/glide/dist/glide.esm.js var glide_esm = __webpack_require__("./node_modules/@glidejs/glide/dist/glide.esm.js"); // CONCATENATED MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/addToBagRecommendation.js /* eslint-disable jquery/no-val */ /* eslint-disable jquery/no-parent */ /* eslint-disable jquery/no-find */ /* eslint-disable jquery/no-closest */ /* eslint-disable jquery/no-class */ /* eslint-disable jquery/no-data */ const addToBagRecommendation_SELECTORS = { MODAL: '#ATBRecommendationsModal', CONTAINER: '.ATBRecommendations-content', CAROUSEL_ANCHOR: '.addToBagOverlay-product-recommendations', CAROUSEL_ANCHOR_LOW_ASP: '.addToBagOverlay-product-recommendations-lowASP', NAVIGATORS: { ARROWS: '.glide__arrows' } }; const CustomLength = function CustomLength(glide, Components, Events) { const addToBagCarouselEvents = { handleSlider() { if (Components.Sizes.length <= glide.settings.perView) { glide.disable(); Components.Html.root.querySelector(addToBagRecommendation_SELECTORS.NAVIGATORS.ARROWS).classList.add('d-none'); } else { glide.enable(); Components.Html.root.querySelector(addToBagRecommendation_SELECTORS.NAVIGATORS.ARROWS).classList.remove('d-none'); } }, mount() { this.handleSlider(); } }; Events.on('resize', () => { addToBagCarouselEvents.handleSlider(); }); return addToBagCarouselEvents; }; const addToBagRecommendation_addToBagCarouselInit = function addToBagCarouselInit() { let slidesCount = 5; if (jquery_default()('.ATBOverlayEnable').length > 0 && parseInt(jquery_default()('.ATBOverlayEnable').data('slides-perview'), 10) > 0) { slidesCount = parseInt(jquery_default()('.ATBOverlayEnable').data('slides-perview'), 10); } if (jquery_default()(addToBagRecommendation_SELECTORS.CAROUSEL_ANCHOR).length > 0) { new glide_esm["default"](addToBagRecommendation_SELECTORS.CAROUSEL_ANCHOR, { type: 'slider', perView: slidesCount, gap: 10, rewind: false, bound: true, peek: { before: 0, after: 0 }, breakpoints: { 1400: { perView: slidesCount, peek: { before: 0, after: 0 } }, 1200: { perView: 4, peek: { before: 0, after: 0 } }, 992: { perView: 3, peek: { before: 0, after: 0 } }, 768: { perView: 3, peek: { before: 0, after: 0 } }, 576: { perView: 1, peek: { before: 0, after: 150 } }, 375: { perView: 1, peek: { before: 0, after: 150 } } } }).mount({ CustomLength }); } }; const addToBagRecommendation_addToBagCarouselLowASPInit = function addToBagCarouselLowASPInit() { const slidesCount = 1; if (jquery_default()(addToBagRecommendation_SELECTORS.CAROUSEL_ANCHOR_LOW_ASP).length > 0) { const lowASPRecommendations = document.querySelectorAll(addToBagRecommendation_SELECTORS.CAROUSEL_ANCHOR_LOW_ASP); for (let i = 0; i < lowASPRecommendations.length; i++) { new glide_esm["default"](lowASPRecommendations[i], { type: 'slider', perView: slidesCount, gap: 16, rewind: false, bound: true, peek: { before: 0, after: 0 }, breakpoints: { 1400: { perView: slidesCount, peek: { before: 0, after: 0 } }, 1200: { perView: 1, peek: { before: 0, after: 0 } }, 992: { perView: 1, peek: { before: 0, after: 0 } }, 768: { perView: 1, peek: { before: 0, after: 0 } }, 576: { perView: 1, peek: { before: 0, after: 0 } }, 375: { perView: 1, peek: { before: 0, after: 0 } } } }).mount({ CustomLength }); } } }; /* harmony default export */ var addToBagRecommendation = (() => { let lastClickedButton = null; let lastAddedProductID = null; let isATBRecommendationsModalShown = null; if (jquery_default()(addToBagRecommendation_SELECTORS.MODAL).length > 0) { const showATBOverlayModal = (pid, isModalShown) => { // eslint-disable-next-line jquery/no-data const url = jquery_default()(addToBagRecommendation_SELECTORS.MODAL).data('action'); if (!url || !pid) { return; } jquery_default.a.spinner().start(); // eslint-disable-next-line jquery/no-ajax jquery_default.a.ajax({ url, type: 'get', data: { pid }, success: data => { jquery_default()(addToBagRecommendation_SELECTORS.CONTAINER).empty(); // eslint-disable-next-line jquery/no-html jquery_default()(addToBagRecommendation_SELECTORS.CONTAINER).html(data); document.querySelector(addToBagRecommendation_SELECTORS.MODAL).classList.remove('modalWithoutCarousel'); if (isModalShown) { // eslint-disable-next-line jquery/no-hide jquery_default()('.ATBRecommendationsContainer').hide(); document.querySelector(addToBagRecommendation_SELECTORS.MODAL).classList.add('modalWithoutCarousel'); } if (jquery_default()(addToBagRecommendation_SELECTORS.CAROUSEL_ANCHOR).length > 0) { addToBagRecommendation_addToBagCarouselInit(); } if (jquery_default()(addToBagRecommendation_SELECTORS.CAROUSEL_ANCHOR_LOW_ASP).length > 0) { addToBagRecommendation_addToBagCarouselLowASPInit(); } jquery_default.a.spinner().stop(); }, error() { jquery_default()(addToBagRecommendation_SELECTORS.MODAL).modal('hide'); jquery_default.a.spinner().stop(); } }); jquery_default()(addToBagRecommendation_SELECTORS.MODAL).modal('show'); }; jquery_default()(document).on('updateAddToCartFormData', (e, data) => { if (!data.error) { lastClickedButton = e.target; } }).on('product:afterAddToCart', async (e, data) => { if (data && !data.error && lastClickedButton && lastClickedButton.dataset.pid) { lastAddedProductID = lastClickedButton.dataset.pid; isATBRecommendationsModalShown = jquery_default()('#ATBRecommendationsModal').hasClass('in') || jquery_default()('#ATBRecommendationsModal').hasClass('show'); showATBOverlayModal(lastAddedProductID, isATBRecommendationsModalShown); lastClickedButton = null; lastAddedProductID = null; isATBRecommendationsModalShown = null; } }); } document.addEventListener('addToBag:carousel-init', addToBagRecommendation_addToBagCarouselInit); document.addEventListener('addToBagLowASP:carousel-init', addToBagRecommendation_addToBagCarouselLowASPInit); jquery_default()(document).on('click', '.product-tile__add-overlay-size', function () { if (jquery_default()('.wishlist.container .wishlist__products').length > 0 && jquery_default()(this).closest('.ATBRecommendationsContainer') && jquery_default()(this).parent().find('.add-to-cart') && !jquery_default()(this).parent().find('.add-to-cart').data('url') && jquery_default()(this).parent().find('.add-to-cart-url') && jquery_default()(this).parent().find('.add-to-cart-url').val()) { jquery_default()(this).parent().find('.add-to-cart').data('url', jquery_default()(this).parent().find('.add-to-cart-url').val()); } }); }); // EXTERNAL MODULE: ./cartridges/int_cybersource_sfra/cartridge/client/default/js/main.js var main = __webpack_require__("./cartridges/int_cybersource_sfra/cartridge/client/default/js/main.js"); // CONCATENATED MODULE: ./cartridges/app_tfg/cartridge/client/default/js/main.js Object(ajax["installAjaxHandlers"])(); jquery_default()(document).ready(() => { Object(util["default"])(header); Object(util["default"])(productTile); Object(util["default"])(addressForm); Object(util["default"])(backToTop["default"]); Object(util["default"])(bodyScroll); Object(util["default"])(components_forms["initForms"]); Object(util["default"])(recaptcha); Object(util["default"])(intelligentReach_namespaceObject); Object(util["default"])(stickyHeaderScroll["default"]); Object(util["default"])(validateInput); Object(util["default"])(addToBagRecommendation); smoothscroll_default.a.polyfill(); }); // CONCATENATED MODULE: ./cartridges/int_gtm/cartridge/client/default/js/main.js /** * @description Initializes the necessary interactions for Google Analytics tracking */ jquery_default()(document).ready(() => { Object(util["default"])(googleAnalytics_namespaceObject); Object(util["default"])(clientSideEvents_namespaceObject); }); /***/ }), /***/ "./cartridges/int_loqate_tfg/cartridge/client/default/js/components/addressForm.js": /*!*****************************************************************************************************!*\ !*** ./cartridges/int_loqate_tfg/cartridge/client/default/js/components/addressForm.js + 1 modules ***! \*****************************************************************************************************/ /*! exports provided: initLookup, ADDRESS_FORM_EVENTS, initAddressForms, handleUppercasedFields */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/checkout/checkoutDom.js because of ./cartridges/int_hubbox_sfra_tfg/cartridge/client/default/js/chunks/hubbox.val.js */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/components/clientSideNav.js because of ./cartridges/int_hubbox_sfra_tfg/cartridge/client/default/js/chunks/hubbox.val.js */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/thirdParty/bootstrap/toggleFormElementsStates.js because of ./cartridges/int_adyen_tfg/cartridge/client/default/js/checkout.js */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js because of ./cartridges/app_tfg/cartridge/client/default/js/sfra/productDetail.js */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/util/fetchutils.js because of ./cartridges/app_tfg/cartridge/client/default/js/sfra/productDetail.js */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, "initLookup", function() { return /* binding */ initLookup; }); __webpack_require__.d(__webpack_exports__, "ADDRESS_FORM_EVENTS", function() { return /* reexport */ ADDRESS_FORM_EVENTS; }); __webpack_require__.d(__webpack_exports__, "initAddressForms", function() { return /* reexport */ initAddressForms; }); __webpack_require__.d(__webpack_exports__, "handleUppercasedFields", function() { return /* reexport */ handleUppercasedFields; }); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js + 1 modules var domutils = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/util/fetchutils.js + 1 modules var fetchutils = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/util/fetchutils.js"); // CONCATENATED MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/addressForm.js // eslint-disable-line import/named const ADDRESS_FORM_EVENTS = { REFRESH: 'country-form:refresh', POPULATE: 'address-fields:populate', SUBMIT: 'country-form:submit', UPDATE: 'address-fields:update' }; const SELECTORS = { FIELDS: '.address-fields', ROW: '.address-fields__row', COUNTRY: '[name$="_country"]' }; const initAddressForms = () => { Object(domutils["onEvent"])(document, 'change', SELECTORS.COUNTRY, async e => { const field = e.delegateTarget; const fieldRow = field.closest(SELECTORS.ROW); if (fieldRow && fieldRow.dataset.action) { const _ref = await Object(fetchutils["loadContent"])(field.form, fieldRow.dataset.action), content = _ref.content, type = _ref.type; if (type === fetchutils["CONTENT_TYPES"].JSON && content.csrfError) { window.location.href = content.redirectUrl; } else if (type === fetchutils["CONTENT_TYPES"].TEXT) { await Object(domutils["updateComponent"])(SELECTORS.FIELDS, content); } document.dispatchEvent(new CustomEvent(ADDRESS_FORM_EVENTS.REFRESH)); } }); }; const handleUppercasedFields = () => { Object(domutils["onEvent"])(document, 'keyup', '[data-uppercase="true"]', e => { e.delegateTarget.value = e.delegateTarget.value.toUpperCase(); }); }; // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/components/clientSideNav.js var clientSideNav = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/components/clientSideNav.js"); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/checkout/checkoutDom.js var checkoutDom = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/checkout/checkoutDom.js"); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/thirdParty/bootstrap/toggleFormElementsStates.js var toggleFormElementsStates = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/thirdParty/bootstrap/toggleFormElementsStates.js"); // CONCATENATED MODULE: ./cartridges/int_loqate_tfg/cartridge/client/default/js/components/addressForm.js const IDS = { LOOKUP: 'addressLookup', CUSTOM_LOOKUP: 'customAddressLookup', COUNTRY: 'country', ADDRESS_FIELDS: { LINE1: 'addressOne', LINE2: 'addressTwo', LINE3: 'addressThree', POSTAL_CODE: 'postalCode', CITY: 'city', STATE: 'stateCode' } }; const CLASSES = { ERROR: 'is-invalid' }; const addressForm_SELECTORS = { LOOKUP: `#${IDS.LOOKUP}`, CUSTOM_LOOKUP: `.${IDS.CUSTOM_LOOKUP}`, COUNTRY: `#${IDS.COUNTRY}`, ADDRESS_FIELDS: `#${Object.keys(IDS.ADDRESS_FIELDS).map(key => IDS.ADDRESS_FIELDS[key]).join(', #')}`, TOGGLE: '.address-lookup__footer', SUBMIT_BUTTON: 'button[type="submit"]' }; const showAddressFields = () => { document.querySelectorAll(addressForm_SELECTORS.ADDRESS_FIELDS).forEach(el => { el.disabled = false; el.parentElement.parentElement.classList.remove('d-none'); }); }; const showAddressFieldsOnReinit = () => { setTimeout(() => { const fields = Array.from(document.querySelectorAll(addressForm_SELECTORS.ADDRESS_FIELDS)); const hasValues = fields.some(field => !!field.value); const hasErrors = fields.some(field => field.classList.contains(CLASSES.ERROR)); if (hasValues || hasErrors) { showAddressFields(); } }, 1); }; const createControl = (lookupField, fields) => { const control = new window.pca.Address(fields, { key: lookupField.dataset.key, suppressAutocomplete: false }); control.listen('populate', address => { lookupField.value = address.Label.replace(/\n/g, ' '); if (fields.length > 1) { showAddressFields(); } document.dispatchEvent(new CustomEvent(ADDRESS_FORM_EVENTS.POPULATE)); document.dispatchEvent(new CustomEvent(ADDRESS_FORM_EVENTS.UPDATE)); document.dispatchEvent(new CustomEvent(ADDRESS_FORM_EVENTS.REFRESH)); }); return control; }; const initAddressSearch = () => { const lookupField = document.querySelector(addressForm_SELECTORS.LOOKUP); const customLookupFields = document.querySelectorAll(addressForm_SELECTORS.CUSTOM_LOOKUP); if (lookupField) { const fields = [{ element: IDS.LOOKUP, field: '', mode: window.pca.fieldMode.SEARCH }, { element: IDS.COUNTRY, field: 'Country', mode: window.pca.fieldMode.PRESERVE }, { element: IDS.ADDRESS_FIELDS.LINE1, field: 'Line1', mode: window.pca.fieldMode.POPULATE }, { element: IDS.ADDRESS_FIELDS.LINE2, field: 'Line2', mode: window.pca.fieldMode.POPULATE }, { element: IDS.ADDRESS_FIELDS.LINE3, field: 'Line3', mode: window.pca.fieldMode.POPULATE }, { element: IDS.ADDRESS_FIELDS.POSTAL_CODE, field: 'PostalCode', mode: window.pca.fieldMode.POPULATE }, { element: IDS.ADDRESS_FIELDS.CITY, field: 'City', mode: window.pca.fieldMode.POPULATE }, { element: IDS.ADDRESS_FIELDS.STATE, field: 'ProvinceName', mode: window.pca.fieldMode.POPULATE }]; const control = createControl(lookupField, fields); control.listen('results', results => { let i; let isContainPostAddress; for (i = 0; i < results.length; i++) { isContainPostAddress = typeof results[i] !== 'undefined' && (results[i].Text.toUpperCase().indexOf('PO BOX') !== -1 || results[i].Text.toUpperCase().indexOf('BFPO') !== -1); if (isContainPostAddress) { results.splice(i); } } }); control.listen('load', () => { control.setCountry(document.querySelector(addressForm_SELECTORS.COUNTRY).value); }); control.load(); // Forces the 'load' event to be fired, it seems to be skipped on occasion } customLookupFields.forEach(customLookupField => { const customFields = [{ element: customLookupField, field: 'search', mode: window.pca.fieldMode.DEFAULT }]; createControl(customLookupField, customFields); }); }; const initLookup = () => { // Set an interval to make sure window.pca is defined const pcaInterval = setInterval(() => { if (window.pca) { clearInterval(pcaInterval); initAddressSearch(); Object(domutils["onEvent"])(document, 'click', addressForm_SELECTORS.TOGGLE, () => { showAddressFields(); }); [toggleFormElementsStates["COLLAPSE_EVENTS"].FORMS_STATE_CHANGED].forEach(evt => { document.addEventListener(evt, () => { document.querySelectorAll(addressForm_SELECTORS.ADDRESS_FIELDS).forEach(el => { const toggle = document.querySelector(addressForm_SELECTORS.TOGGLE); if (Object(domutils["visible"])(toggle)) { el.disabled = false; } }); }); }); [ADDRESS_FORM_EVENTS.REFRESH, checkoutDom["EVENTS"].SAVED_ADDRESS.ADDRESS_SELECTED, checkoutDom["EVENTS"].BILLING.USE_SHIPPING_AS_BILLING_TOGGLED, clientSideNav["NAV_EVENTS"].NAV_CONTENT, clientSideNav["NAV_EVENTS"].NAV_BACK].forEach(evt => { document.addEventListener(evt, e => { initAddressSearch(); if (e.detail && e.detail.error) { showAddressFields(); } }); }); document.addEventListener(ADDRESS_FORM_EVENTS.SUBMIT, showAddressFieldsOnReinit); showAddressFieldsOnReinit(); } }, 100); }; /***/ }), /***/ "./cartridges/plugin_wishlists_tfg/cartridge/client/default/js/main.js": /*!*****************************************************************************************!*\ !*** ./cartridges/plugin_wishlists_tfg/cartridge/client/default/js/main.js + 1 modules ***! \*****************************************************************************************/ /*! no exports provided */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_storefront_base/cartridge/client/default/js/main.js (<- Module uses injected variables ($)) */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/app_tfg/cartridge/client/default/js/util.js because of ./cartridges/app_hobbs/cartridge/client/default/js/index.js */ /*! ModuleConcatenation bailout: Cannot concat with ./cartridges/plugin_wishlists_tfg/cartridge/client/default/js/product/wishlist.js (<- Module is referenced from these modules with unsupported syntax: ./cartridges/plugin_wishlists/cartridge/client/default/js/productDetail.js (referenced with cjs require)) */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/jquery/dist/jquery.js (<- Module is not an ECMAScript module) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // NAMESPACE OBJECT: ./cartridges/plugin_wishlists_tfg/cartridge/client/default/js/header/wishlist.js var wishlist_namespaceObject = {}; __webpack_require__.r(wishlist_namespaceObject); __webpack_require__.d(wishlist_namespaceObject, "default", function() { return header_wishlist; }); // EXTERNAL MODULE: ./node_modules/jquery/dist/jquery.js var jquery = __webpack_require__("./node_modules/jquery/dist/jquery.js"); var jquery_default = /*#__PURE__*/__webpack_require__.n(jquery); // EXTERNAL MODULE: ./cartridges/app_tfg/cartridge/client/default/js/util.js + 1 modules var util = __webpack_require__("./cartridges/app_tfg/cartridge/client/default/js/util.js"); // EXTERNAL MODULE: ./cartridges/plugin_wishlists_tfg/cartridge/client/default/js/product/wishlist.js var wishlist = __webpack_require__("./cartridges/plugin_wishlists_tfg/cartridge/client/default/js/product/wishlist.js"); // CONCATENATED MODULE: ./cartridges/plugin_wishlists_tfg/cartridge/client/default/js/header/wishlist.js const SELECTORS = { HEADER_COUNTER: '.wishlist-quantity' }; /* harmony default export */ var header_wishlist = (() => { const wishlistEmpty = document.querySelector('.header-element__icon > .wishlist-empty'); const wishlistFilled = document.querySelector('.header-element__icon > .wishlist-filled'); const productCounter = document.querySelector(SELECTORS.HEADER_COUNTER); function unMarkWishlist() { if (wishlistFilled && parseInt(productCounter.innerHTML, 10) === 0) { if (wishlistFilled && !wishlistFilled.classList.contains('d-none')) { wishlistFilled.classList.add('d-none'); } if (wishlistEmpty.classList.contains('d-none')) { wishlistEmpty.classList.remove('d-none'); } } } function markWishlistFilled() { if (wishlistFilled) { if (wishlistFilled && wishlistFilled.classList.contains('d-none')) { wishlistFilled.classList.remove('d-none'); } if (!wishlistEmpty.classList.contains('d-none')) { wishlistEmpty.classList.add('d-none'); } } } jquery_default()(document).on(wishlist["EVENTS"].WISHLIST_ADD, () => { markWishlistFilled(); if (productCounter) { productCounter.innerHTML = parseInt(productCounter.innerHTML, 10) + 1; } }); jquery_default()(document).on(wishlist["EVENTS"].WISHLIST_REMOVE, () => { if (productCounter) { const newCount = parseInt(productCounter.innerHTML, 10) - 1; productCounter.innerHTML = newCount > 0 ? newCount : 0; } unMarkWishlist(); }); jquery_default()(window).on('load', () => { if (productCounter && parseInt(productCounter.innerHTML, 10) > 0) { markWishlistFilled(); } else { unMarkWishlist(); } }); }); // EXTERNAL MODULE: ./cartridges/app_storefront_base/cartridge/client/default/js/main.js var main = __webpack_require__("./cartridges/app_storefront_base/cartridge/client/default/js/main.js"); // CONCATENATED MODULE: ./cartridges/plugin_wishlists_tfg/cartridge/client/default/js/main.js jquery_default()(document).ready(() => { Object(util["default"])(wishlist_namespaceObject); }); /***/ }), /***/ "./cartridges/plugin_wishlists_tfg/cartridge/client/default/js/product/wishlist.js": /*!*****************************************************************************************!*\ !*** ./cartridges/plugin_wishlists_tfg/cartridge/client/default/js/product/wishlist.js ***! \*****************************************************************************************/ /*! exports provided: EVENTS, reinitWishlistOnVariantChange, addToWishlist, default */ /*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./cartridges/plugin_wishlists/cartridge/client/default/js/productDetail.js (referenced with cjs require) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EVENTS", function() { return EVENTS; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reinitWishlistOnVariantChange", function() { return reinitWishlistOnVariantChange; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addToWishlist", function() { return addToWishlist; }); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _util_domutils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/domutils */ "./cartridges/app_tfg/cartridge/client/default/js/util/domutils.js"); // eslint-disable-line import/named const CLASSES = { INDICATOR_ACTIVE: 'wishlist__indicator--active' }; const EVENTS = { WISHLIST_ADD: 'product:addedToWishlist', WISHLIST_REMOVE: 'product:removedFromWishlist' }; const SELECTORS = { WISHLIST_BUTTON: '.add-to-wish-list', INDICATORS: { ADDED: '.wishlist__indicator--added', REMOVED: '.wishlist__indicator--removed' } }; const addRemoveFromWishlist = async (delegateTarget, styleClass, toggleAttribute) => { const _delegateTarget$datas = delegateTarget.dataset, urlAdd = _delegateTarget$datas.urlAdd, urlRemove = _delegateTarget$datas.urlRemove; const toggableStyleClass = styleClass || 'active'; const pid = jquery__WEBPACK_IMPORTED_MODULE_0___default()(delegateTarget).closest('.product-detail').find('.product-id').html(); // eslint-disable-line let optionId = jquery__WEBPACK_IMPORTED_MODULE_0___default()(delegateTarget).closest('.product-detail').find('.product-option').attr('data-option-id'); // eslint-disable-line let optionVal = jquery__WEBPACK_IMPORTED_MODULE_0___default()(delegateTarget).closest('.product-detail').find('.options-select option:selected').attr('data-value-id'); // eslint-disable-line let url = urlAdd || delegateTarget.dataset.href; let indicator = document.querySelector(SELECTORS.INDICATORS.ADDED); let isAdd = true; optionId = optionId || null; optionVal = optionVal || null; if (!url || !pid) { return; } // init remove operation if (delegateTarget.classList.contains(toggableStyleClass)) { url = urlRemove; indicator = document.querySelector(SELECTORS.INDICATORS.REMOVED); isAdd = false; jquery__WEBPACK_IMPORTED_MODULE_0___default.a.ajax({ // eslint-disable-line jquery/no-ajax url, type: 'get', dataType: 'json', data: { pid, optionId, optionVal } }); } else { url = urlAdd || delegateTarget.dataset.href; indicator = document.querySelector(SELECTORS.INDICATORS.ADDED); isAdd = true; jquery__WEBPACK_IMPORTED_MODULE_0___default.a.ajax({ // eslint-disable-line jquery/no-ajax url, type: 'post', dataType: 'json', data: { pid, optionId, optionVal } }); } indicator.classList.add(CLASSES.INDICATOR_ACTIVE); delegateTarget.classList.toggle(toggableStyleClass); if (toggleAttribute) { delegateTarget.toggleAttribute(toggleAttribute, isAdd); } if (isAdd) { document.dispatchEvent(new CustomEvent(EVENTS.WISHLIST_ADD)); } else { document.dispatchEvent(new CustomEvent(EVENTS.WISHLIST_REMOVE)); } document.addEventListener('click', () => { indicator.classList.remove(CLASSES.INDICATOR_ACTIVE); }, { once: true }); setTimeout(function () { // eslint-disable-line prefer-arrow-callback indicator.classList.remove(CLASSES.INDICATOR_ACTIVE); delegateTarget.blur(); }, 5000); }; const reinitWishlistOnVariantChange = () => { document.addEventListener('product:afterAttributeSelect', function () { // eslint-disable-line prefer-arrow-callback Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["onEvent"])(document, 'click', SELECTORS.WISHLIST_BUTTON, async e => { addRemoveFromWishlist(e.delegateTarget, 'active'); }); }); }; const addToWishlist = () => true; /* harmony default export */ __webpack_exports__["default"] = (() => { Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["onEvent"])(document, 'click', SELECTORS.WISHLIST_BUTTON, async e => { addRemoveFromWishlist(e.delegateTarget, 'active'); }); Object(_util_domutils__WEBPACK_IMPORTED_MODULE_1__["onEvent"])(document, 'click', '.product-tile__wishlist--link', async e => { addRemoveFromWishlist(e.delegateTarget, 'active'); }); }); /***/ }), /***/ "./node_modules/@glidejs/glide/dist/glide.esm.js": /*!*******************************************************!*\ !*** ./node_modules/@glidejs/glide/dist/glide.esm.js ***! \*******************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Glide; }); /*! * Glide.js v3.6.0 * (c) 2013-2022 Jędrzej Chałubek (https://github.com/jedrzejchalubek/) * Released under the MIT License. */ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function (obj) { return typeof obj; }; } else { _typeof = function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; } function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); } var defaults = { /** * Type of the movement. * * Available types: * `slider` - Rewinds slider to the start/end when it reaches the first or last slide. * `carousel` - Changes slides without starting over when it reaches the first or last slide. * * @type {String} */ type: 'slider', /** * Start at specific slide number defined with zero-based index. * * @type {Number} */ startAt: 0, /** * A number of slides visible on the single viewport. * * @type {Number} */ perView: 1, /** * Focus currently active slide at a specified position in the track. * * Available inputs: * `center` - Current slide will be always focused at the center of a track. * `0,1,2,3...` - Current slide will be focused on the specified zero-based index. * * @type {String|Number} */ focusAt: 0, /** * A size of the gap added between slides. * * @type {Number} */ gap: 10, /** * Change slides after a specified interval. Use `false` for turning off autoplay. * * @type {Number|Boolean} */ autoplay: false, /** * Stop autoplay on mouseover event. * * @type {Boolean} */ hoverpause: true, /** * Allow for changing slides with left and right keyboard arrows. * * @type {Boolean} */ keyboard: true, /** * Stop running `perView` number of slides from the end. Use this * option if you don't want to have an empty space after * a slider. Works only with `slider` type and a * non-centered `focusAt` setting. * * @type {Boolean} */ bound: false, /** * Minimal swipe distance needed to change the slide. Use `false` for turning off a swiping. * * @type {Number|Boolean} */ swipeThreshold: 80, /** * Minimal mouse drag distance needed to change the slide. Use `false` for turning off a dragging. * * @type {Number|Boolean} */ dragThreshold: 120, /** * A number of slides moved on single swipe. * * Available types: * `` - Moves slider by one slide per swipe * `|` - Moves slider between views per swipe (number of slides defined in `perView` options) * * @type {String} */ perSwipe: '', /** * Moving distance ratio of the slides on a swiping and dragging. * * @type {Number} */ touchRatio: 0.5, /** * Angle required to activate slides moving on swiping or dragging. * * @type {Number} */ touchAngle: 45, /** * Duration of the animation in milliseconds. * * @type {Number} */ animationDuration: 400, /** * Allows looping the `slider` type. Slider will rewind to the first/last slide when it's at the start/end. * * @type {Boolean} */ rewind: true, /** * Duration of the rewinding animation of the `slider` type in milliseconds. * * @type {Number} */ rewindDuration: 800, /** * Easing function for the animation. * * @type {String} */ animationTimingFunc: 'cubic-bezier(.165, .840, .440, 1)', /** * Wait for the animation to finish until the next user input can be processed * * @type {boolean} */ waitForTransition: true, /** * Throttle costly events at most once per every wait milliseconds. * * @type {Number} */ throttle: 10, /** * Moving direction mode. * * Available inputs: * - 'ltr' - left to right movement, * - 'rtl' - right to left movement. * * @type {String} */ direction: 'ltr', /** * The distance value of the next and previous viewports which * have to peek in the current view. Accepts number and * pixels as a string. Left and right peeking can be * set up separately with a directions object. * * For example: * `100` - Peek 100px on the both sides. * { before: 100, after: 50 }` - Peek 100px on the left side and 50px on the right side. * * @type {Number|String|Object} */ peek: 0, /** * Defines how many clones of current viewport will be generated. * * @type {Number} */ cloningRatio: 1, /** * Collection of options applied at specified media breakpoints. * For example: display two slides per view under 800px. * `{ * '800px': { * perView: 2 * } * }` */ breakpoints: {}, /** * Collection of internally used HTML classes. * * @todo Refactor `slider` and `carousel` properties to single `type: { slider: '', carousel: '' }` object * @type {Object} */ classes: { swipeable: 'glide--swipeable', dragging: 'glide--dragging', direction: { ltr: 'glide--ltr', rtl: 'glide--rtl' }, type: { slider: 'glide--slider', carousel: 'glide--carousel' }, slide: { clone: 'glide__slide--clone', active: 'glide__slide--active' }, arrow: { disabled: 'glide__arrow--disabled' }, nav: { active: 'glide__bullet--active' } } }; /** * Outputs warning message to the bowser console. * * @param {String} msg * @return {Void} */ function warn(msg) { console.error("[Glide warn]: ".concat(msg)); } /** * Converts value entered as number * or string to integer value. * * @param {String} value * @returns {Number} */ function toInt(value) { return parseInt(value); } /** * Converts value entered as number * or string to flat value. * * @param {String} value * @returns {Number} */ function toFloat(value) { return parseFloat(value); } /** * Indicates whether the specified value is a string. * * @param {*} value * @return {Boolean} */ function isString(value) { return typeof value === 'string'; } /** * Indicates whether the specified value is an object. * * @param {*} value * @return {Boolean} * * @see https://github.com/jashkenas/underscore */ function isObject(value) { var type = _typeof(value); return type === 'function' || type === 'object' && !!value; // eslint-disable-line no-mixed-operators } /** * Indicates whether the specified value is a function. * * @param {*} value * @return {Boolean} */ function isFunction(value) { return typeof value === 'function'; } /** * Indicates whether the specified value is undefined. * * @param {*} value * @return {Boolean} */ function isUndefined(value) { return typeof value === 'undefined'; } /** * Indicates whether the specified value is an array. * * @param {*} value * @return {Boolean} */ function isArray(value) { return value.constructor === Array; } /** * Creates and initializes specified collection of extensions. * Each extension receives access to instance of glide and rest of components. * * @param {Object} glide * @param {Object} extensions * * @returns {Object} */ function mount(glide, extensions, events) { var components = {}; for (var name in extensions) { if (isFunction(extensions[name])) { components[name] = extensions[name](glide, components, events); } else { warn('Extension must be a function'); } } for (var _name in components) { if (isFunction(components[_name].mount)) { components[_name].mount(); } } return components; } /** * Defines getter and setter property on the specified object. * * @param {Object} obj Object where property has to be defined. * @param {String} prop Name of the defined property. * @param {Object} definition Get and set definitions for the property. * @return {Void} */ function define(obj, prop, definition) { Object.defineProperty(obj, prop, definition); } /** * Sorts aphabetically object keys. * * @param {Object} obj * @return {Object} */ function sortKeys(obj) { return Object.keys(obj).sort().reduce(function (r, k) { r[k] = obj[k]; return r[k], r; }, {}); } /** * Merges passed settings object with default options. * * @param {Object} defaults * @param {Object} settings * @return {Object} */ function mergeOptions(defaults, settings) { var options = Object.assign({}, defaults, settings); // `Object.assign` do not deeply merge objects, so we // have to do it manually for every nested object // in options. Although it does not look smart, // it's smaller and faster than some fancy // merging deep-merge algorithm script. if (settings.hasOwnProperty('classes')) { options.classes = Object.assign({}, defaults.classes, settings.classes); if (settings.classes.hasOwnProperty('direction')) { options.classes.direction = Object.assign({}, defaults.classes.direction, settings.classes.direction); } if (settings.classes.hasOwnProperty('type')) { options.classes.type = Object.assign({}, defaults.classes.type, settings.classes.type); } if (settings.classes.hasOwnProperty('slide')) { options.classes.slide = Object.assign({}, defaults.classes.slide, settings.classes.slide); } if (settings.classes.hasOwnProperty('arrow')) { options.classes.arrow = Object.assign({}, defaults.classes.arrow, settings.classes.arrow); } if (settings.classes.hasOwnProperty('nav')) { options.classes.nav = Object.assign({}, defaults.classes.nav, settings.classes.nav); } } if (settings.hasOwnProperty('breakpoints')) { options.breakpoints = Object.assign({}, defaults.breakpoints, settings.breakpoints); } return options; } var EventsBus = /*#__PURE__*/function () { /** * Construct a EventBus instance. * * @param {Object} events */ function EventsBus() { var events = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _classCallCheck(this, EventsBus); this.events = events; this.hop = events.hasOwnProperty; } /** * Adds listener to the specifed event. * * @param {String|Array} event * @param {Function} handler */ _createClass(EventsBus, [{ key: "on", value: function on(event, handler) { if (isArray(event)) { for (var i = 0; i < event.length; i++) { this.on(event[i], handler); } return; } // Create the event's object if not yet created if (!this.hop.call(this.events, event)) { this.events[event] = []; } // Add the handler to queue var index = this.events[event].push(handler) - 1; // Provide handle back for removal of event return { remove: function remove() { delete this.events[event][index]; } }; } /** * Runs registered handlers for specified event. * * @param {String|Array} event * @param {Object=} context */ }, { key: "emit", value: function emit(event, context) { if (isArray(event)) { for (var i = 0; i < event.length; i++) { this.emit(event[i], context); } return; } // If the event doesn't exist, or there's no handlers in queue, just leave if (!this.hop.call(this.events, event)) { return; } // Cycle through events queue, fire! this.events[event].forEach(function (item) { item(context || {}); }); } }]); return EventsBus; }(); var Glide$1 = /*#__PURE__*/function () { /** * Construct glide. * * @param {String} selector * @param {Object} options */ function Glide(selector) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; _classCallCheck(this, Glide); this._c = {}; this._t = []; this._e = new EventsBus(); this.disabled = false; this.selector = selector; this.settings = mergeOptions(defaults, options); this.index = this.settings.startAt; } /** * Initializes glide. * * @param {Object} extensions Collection of extensions to initialize. * @return {Glide} */ _createClass(Glide, [{ key: "mount", value: function mount$1() { var extensions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; this._e.emit('mount.before'); if (isObject(extensions)) { this._c = mount(this, extensions, this._e); } else { warn('You need to provide a object on `mount()`'); } this._e.emit('mount.after'); return this; } /** * Collects an instance `translate` transformers. * * @param {Array} transformers Collection of transformers. * @return {Void} */ }, { key: "mutate", value: function mutate() { var transformers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; if (isArray(transformers)) { this._t = transformers; } else { warn('You need to provide a array on `mutate()`'); } return this; } /** * Updates glide with specified settings. * * @param {Object} settings * @return {Glide} */ }, { key: "update", value: function update() { var settings = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; this.settings = mergeOptions(this.settings, settings); if (settings.hasOwnProperty('startAt')) { this.index = settings.startAt; } this._e.emit('update'); return this; } /** * Change slide with specified pattern. A pattern must be in the special format: * `>` - Move one forward * `<` - Move one backward * `={i}` - Go to {i} zero-based slide (eq. '=1', will go to second slide) * `>>` - Rewinds to end (last slide) * `<<` - Rewinds to start (first slide) * `|>` - Move one viewport forward * `|<` - Move one viewport backward * * @param {String} pattern * @return {Glide} */ }, { key: "go", value: function go(pattern) { this._c.Run.make(pattern); return this; } /** * Move track by specified distance. * * @param {String} distance * @return {Glide} */ }, { key: "move", value: function move(distance) { this._c.Transition.disable(); this._c.Move.make(distance); return this; } /** * Destroy instance and revert all changes done by this._c. * * @return {Glide} */ }, { key: "destroy", value: function destroy() { this._e.emit('destroy'); return this; } /** * Start instance autoplaying. * * @param {Boolean|Number} interval Run autoplaying with passed interval regardless of `autoplay` settings * @return {Glide} */ }, { key: "play", value: function play() { var interval = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; if (interval) { this.settings.autoplay = interval; } this._e.emit('play'); return this; } /** * Stop instance autoplaying. * * @return {Glide} */ }, { key: "pause", value: function pause() { this._e.emit('pause'); return this; } /** * Sets glide into a idle status. * * @return {Glide} */ }, { key: "disable", value: function disable() { this.disabled = true; return this; } /** * Sets glide into a active status. * * @return {Glide} */ }, { key: "enable", value: function enable() { this.disabled = false; return this; } /** * Adds cuutom event listener with handler. * * @param {String|Array} event * @param {Function} handler * @return {Glide} */ }, { key: "on", value: function on(event, handler) { this._e.on(event, handler); return this; } /** * Checks if glide is a precised type. * * @param {String} name * @return {Boolean} */ }, { key: "isType", value: function isType(name) { return this.settings.type === name; } /** * Gets value of the core options. * * @return {Object} */ }, { key: "settings", get: function get() { return this._o; } /** * Sets value of the core options. * * @param {Object} o * @return {Void} */ , set: function set(o) { if (isObject(o)) { this._o = o; } else { warn('Options must be an `object` instance.'); } } /** * Gets current index of the slider. * * @return {Object} */ }, { key: "index", get: function get() { return this._i; } /** * Sets current index a slider. * * @return {Object} */ , set: function set(i) { this._i = toInt(i); } /** * Gets type name of the slider. * * @return {String} */ }, { key: "type", get: function get() { return this.settings.type; } /** * Gets value of the idle status. * * @return {Boolean} */ }, { key: "disabled", get: function get() { return this._d; } /** * Sets value of the idle status. * * @return {Boolean} */ , set: function set(status) { this._d = !!status; } }]); return Glide; }(); function Run (Glide, Components, Events) { var Run = { /** * Initializes autorunning of the glide. * * @return {Void} */ mount: function mount() { this._o = false; }, /** * Makes glides running based on the passed moving schema. * * @param {String} move */ make: function make(move) { var _this = this; if (!Glide.disabled) { !Glide.settings.waitForTransition || Glide.disable(); this.move = move; Events.emit('run.before', this.move); this.calculate(); Events.emit('run', this.move); Components.Transition.after(function () { if (_this.isStart()) { Events.emit('run.start', _this.move); } if (_this.isEnd()) { Events.emit('run.end', _this.move); } if (_this.isOffset()) { _this._o = false; Events.emit('run.offset', _this.move); } Events.emit('run.after', _this.move); Glide.enable(); }); } }, /** * Calculates current index based on defined move. * * @return {Number|Undefined} */ calculate: function calculate() { var move = this.move, length = this.length; var steps = move.steps, direction = move.direction; // By default assume that size of view is equal to one slide var viewSize = 1; // While direction is `=` we want jump to // a specified index described in steps. if (direction === '=') { // Check if bound is true, // as we want to avoid whitespaces. if (Glide.settings.bound && toInt(steps) > length) { Glide.index = length; return; } Glide.index = steps; return; } // When pattern is equal to `>>` we want // fast forward to the last slide. if (direction === '>' && steps === '>') { Glide.index = length; return; } // When pattern is equal to `<<` we want // fast forward to the first slide. if (direction === '<' && steps === '<') { Glide.index = 0; return; } // pagination movement if (direction === '|') { viewSize = Glide.settings.perView || 1; } // we are moving forward if (direction === '>' || direction === '|' && steps === '>') { var index = calculateForwardIndex(viewSize); if (index > length) { this._o = true; } Glide.index = normalizeForwardIndex(index, viewSize); return; } // we are moving backward if (direction === '<' || direction === '|' && steps === '<') { var _index = calculateBackwardIndex(viewSize); if (_index < 0) { this._o = true; } Glide.index = normalizeBackwardIndex(_index, viewSize); return; } warn("Invalid direction pattern [".concat(direction).concat(steps, "] has been used")); }, /** * Checks if we are on the first slide. * * @return {Boolean} */ isStart: function isStart() { return Glide.index <= 0; }, /** * Checks if we are on the last slide. * * @return {Boolean} */ isEnd: function isEnd() { return Glide.index >= this.length; }, /** * Checks if we are making a offset run. * * @param {String} direction * @return {Boolean} */ isOffset: function isOffset() { var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined; if (!direction) { return this._o; } if (!this._o) { return false; } // did we view to the right? if (direction === '|>') { return this.move.direction === '|' && this.move.steps === '>'; } // did we view to the left? if (direction === '|<') { return this.move.direction === '|' && this.move.steps === '<'; } return this.move.direction === direction; }, /** * Checks if bound mode is active * * @return {Boolean} */ isBound: function isBound() { return Glide.isType('slider') && Glide.settings.focusAt !== 'center' && Glide.settings.bound; } }; /** * Returns index value to move forward/to the right * * @param viewSize * @returns {Number} */ function calculateForwardIndex(viewSize) { var index = Glide.index; if (Glide.isType('carousel')) { return index + viewSize; } return index + (viewSize - index % viewSize); } /** * Normalizes the given forward index based on glide settings, preventing it to exceed certain boundaries * * @param index * @param length * @param viewSize * @returns {Number} */ function normalizeForwardIndex(index, viewSize) { var length = Run.length; if (index <= length) { return index; } if (Glide.isType('carousel')) { return index - (length + 1); } if (Glide.settings.rewind) { // bound does funny things with the length, therefor we have to be certain // that we are on the last possible index value given by bound if (Run.isBound() && !Run.isEnd()) { return length; } return 0; } if (Run.isBound()) { return length; } return Math.floor(length / viewSize) * viewSize; } /** * Calculates index value to move backward/to the left * * @param viewSize * @returns {Number} */ function calculateBackwardIndex(viewSize) { var index = Glide.index; if (Glide.isType('carousel')) { return index - viewSize; } // ensure our back navigation results in the same index as a forward navigation // to experience a homogeneous paging var view = Math.ceil(index / viewSize); return (view - 1) * viewSize; } /** * Normalizes the given backward index based on glide settings, preventing it to exceed certain boundaries * * @param index * @param length * @param viewSize * @returns {*} */ function normalizeBackwardIndex(index, viewSize) { var length = Run.length; if (index >= 0) { return index; } if (Glide.isType('carousel')) { return index + (length + 1); } if (Glide.settings.rewind) { // bound does funny things with the length, therefor we have to be certain // that we are on first possible index value before we to rewind to the length given by bound if (Run.isBound() && Run.isStart()) { return length; } return Math.floor(length / viewSize) * viewSize; } return 0; } define(Run, 'move', { /** * Gets value of the move schema. * * @returns {Object} */ get: function get() { return this._m; }, /** * Sets value of the move schema. * * @returns {Object} */ set: function set(value) { var step = value.substr(1); this._m = { direction: value.substr(0, 1), steps: step ? toInt(step) ? toInt(step) : step : 0 }; } }); define(Run, 'length', { /** * Gets value of the running distance based * on zero-indexing number of slides. * * @return {Number} */ get: function get() { var settings = Glide.settings; var length = Components.Html.slides.length; // If the `bound` option is active, a maximum running distance should be // reduced by `perView` and `focusAt` settings. Running distance // should end before creating an empty space after instance. if (this.isBound()) { return length - 1 - (toInt(settings.perView) - 1) + toInt(settings.focusAt); } return length - 1; } }); define(Run, 'offset', { /** * Gets status of the offsetting flag. * * @return {Boolean} */ get: function get() { return this._o; } }); return Run; } /** * Returns a current time. * * @return {Number} */ function now() { return new Date().getTime(); } /** * Returns a function, that, when invoked, will only be triggered * at most once during a given window of time. * * @param {Function} func * @param {Number} wait * @param {Object=} options * @return {Function} * * @see https://github.com/jashkenas/underscore */ function throttle(func, wait, options) { var timeout, context, args, result; var previous = 0; if (!options) options = {}; var later = function later() { previous = options.leading === false ? 0 : now(); timeout = null; result = func.apply(context, args); if (!timeout) context = args = null; }; var throttled = function throttled() { var at = now(); if (!previous && options.leading === false) previous = at; var remaining = wait - (at - previous); context = this; args = arguments; if (remaining <= 0 || remaining > wait) { if (timeout) { clearTimeout(timeout); timeout = null; } previous = at; result = func.apply(context, args); if (!timeout) context = args = null; } else if (!timeout && options.trailing !== false) { timeout = setTimeout(later, remaining); } return result; }; throttled.cancel = function () { clearTimeout(timeout); previous = 0; timeout = context = args = null; }; return throttled; } var MARGIN_TYPE = { ltr: ['marginLeft', 'marginRight'], rtl: ['marginRight', 'marginLeft'] }; function Gaps (Glide, Components, Events) { var Gaps = { /** * Applies gaps between slides. First and last * slides do not receive it's edge margins. * * @param {HTMLCollection} slides * @return {Void} */ apply: function apply(slides) { for (var i = 0, len = slides.length; i < len; i++) { var style = slides[i].style; var direction = Components.Direction.value; if (i !== 0) { style[MARGIN_TYPE[direction][0]] = "".concat(this.value / 2, "px"); } else { style[MARGIN_TYPE[direction][0]] = ''; } if (i !== slides.length - 1) { style[MARGIN_TYPE[direction][1]] = "".concat(this.value / 2, "px"); } else { style[MARGIN_TYPE[direction][1]] = ''; } } }, /** * Removes gaps from the slides. * * @param {HTMLCollection} slides * @returns {Void} */ remove: function remove(slides) { for (var i = 0, len = slides.length; i < len; i++) { var style = slides[i].style; style.marginLeft = ''; style.marginRight = ''; } } }; define(Gaps, 'value', { /** * Gets value of the gap. * * @returns {Number} */ get: function get() { return toInt(Glide.settings.gap); } }); define(Gaps, 'grow', { /** * Gets additional dimensions value caused by gaps. * Used to increase width of the slides wrapper. * * @returns {Number} */ get: function get() { return Gaps.value * Components.Sizes.length; } }); define(Gaps, 'reductor', { /** * Gets reduction value caused by gaps. * Used to subtract width of the slides. * * @returns {Number} */ get: function get() { var perView = Glide.settings.perView; return Gaps.value * (perView - 1) / perView; } }); /** * Apply calculated gaps: * - after building, so slides (including clones) will receive proper margins * - on updating via API, to recalculate gaps with new options */ Events.on(['build.after', 'update'], throttle(function () { Gaps.apply(Components.Html.wrapper.children); }, 30)); /** * Remove gaps: * - on destroying to bring markup to its inital state */ Events.on('destroy', function () { Gaps.remove(Components.Html.wrapper.children); }); return Gaps; } /** * Finds siblings nodes of the passed node. * * @param {Element} node * @return {Array} */ function siblings(node) { if (node && node.parentNode) { var n = node.parentNode.firstChild; var matched = []; for (; n; n = n.nextSibling) { if (n.nodeType === 1 && n !== node) { matched.push(n); } } return matched; } return []; } /** * Checks if passed node exist and is a valid element. * * @param {Element} node * @return {Boolean} */ function exist(node) { if (node && node instanceof window.HTMLElement) { return true; } return false; } /** * Coerces a NodeList to an Array. * * @param {NodeList} nodeList * @return {Array} */ function toArray(nodeList) { return Array.prototype.slice.call(nodeList); } var TRACK_SELECTOR = '[data-glide-el="track"]'; function Html (Glide, Components, Events) { var Html = { /** * Setup slider HTML nodes. * * @param {Glide} glide */ mount: function mount() { this.root = Glide.selector; this.track = this.root.querySelector(TRACK_SELECTOR); this.collectSlides(); }, /** * Collect slides */ collectSlides: function collectSlides() { this.slides = toArray(this.wrapper.children).filter(function (slide) { return !slide.classList.contains(Glide.settings.classes.slide.clone); }); } }; define(Html, 'root', { /** * Gets node of the glide main element. * * @return {Object} */ get: function get() { return Html._r; }, /** * Sets node of the glide main element. * * @return {Object} */ set: function set(r) { if (isString(r)) { r = document.querySelector(r); } if (exist(r)) { Html._r = r; } else { warn('Root element must be a existing Html node'); } } }); define(Html, 'track', { /** * Gets node of the glide track with slides. * * @return {Object} */ get: function get() { return Html._t; }, /** * Sets node of the glide track with slides. * * @return {Object} */ set: function set(t) { if (exist(t)) { Html._t = t; } else { warn("Could not find track element. Please use ".concat(TRACK_SELECTOR, " attribute.")); } } }); define(Html, 'wrapper', { /** * Gets node of the slides wrapper. * * @return {Object} */ get: function get() { return Html.track.children[0]; } }); /** * Add/remove/reorder dynamic slides */ Events.on('update', function () { Html.collectSlides(); }); return Html; } function Peek (Glide, Components, Events) { var Peek = { /** * Setups how much to peek based on settings. * * @return {Void} */ mount: function mount() { this.value = Glide.settings.peek; } }; define(Peek, 'value', { /** * Gets value of the peek. * * @returns {Number|Object} */ get: function get() { return Peek._v; }, /** * Sets value of the peek. * * @param {Number|Object} value * @return {Void} */ set: function set(value) { if (isObject(value)) { value.before = toInt(value.before); value.after = toInt(value.after); } else { value = toInt(value); } Peek._v = value; } }); define(Peek, 'reductor', { /** * Gets reduction value caused by peek. * * @returns {Number} */ get: function get() { var value = Peek.value; var perView = Glide.settings.perView; if (isObject(value)) { return value.before / perView + value.after / perView; } return value * 2 / perView; } }); /** * Recalculate peeking sizes on: * - when resizing window to update to proper percents */ Events.on(['resize', 'update'], function () { Peek.mount(); }); return Peek; } function Move (Glide, Components, Events) { var Move = { /** * Constructs move component. * * @returns {Void} */ mount: function mount() { this._o = 0; }, /** * Calculates a movement value based on passed offset and currently active index. * * @param {Number} offset * @return {Void} */ make: function make() { var _this = this; var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; this.offset = offset; Events.emit('move', { movement: this.value }); Components.Transition.after(function () { Events.emit('move.after', { movement: _this.value }); }); } }; define(Move, 'offset', { /** * Gets an offset value used to modify current translate. * * @return {Object} */ get: function get() { return Move._o; }, /** * Sets an offset value used to modify current translate. * * @return {Object} */ set: function set(value) { Move._o = !isUndefined(value) ? toInt(value) : 0; } }); define(Move, 'translate', { /** * Gets a raw movement value. * * @return {Number} */ get: function get() { return Components.Sizes.slideWidth * Glide.index; } }); define(Move, 'value', { /** * Gets an actual movement value corrected by offset. * * @return {Number} */ get: function get() { var offset = this.offset; var translate = this.translate; if (Components.Direction.is('rtl')) { return translate + offset; } return translate - offset; } }); /** * Make movement to proper slide on: * - before build, so glide will start at `startAt` index * - on each standard run to move to newly calculated index */ Events.on(['build.before', 'run'], function () { Move.make(); }); return Move; } function Sizes (Glide, Components, Events) { var Sizes = { /** * Setups dimensions of slides. * * @return {Void} */ setupSlides: function setupSlides() { var width = "".concat(this.slideWidth, "px"); var slides = Components.Html.slides; for (var i = 0; i < slides.length; i++) { slides[i].style.width = width; } }, /** * Setups dimensions of slides wrapper. * * @return {Void} */ setupWrapper: function setupWrapper() { Components.Html.wrapper.style.width = "".concat(this.wrapperSize, "px"); }, /** * Removes applied styles from HTML elements. * * @returns {Void} */ remove: function remove() { var slides = Components.Html.slides; for (var i = 0; i < slides.length; i++) { slides[i].style.width = ''; } Components.Html.wrapper.style.width = ''; } }; define(Sizes, 'length', { /** * Gets count number of the slides. * * @return {Number} */ get: function get() { return Components.Html.slides.length; } }); define(Sizes, 'width', { /** * Gets width value of the slider (visible area). * * @return {Number} */ get: function get() { return Components.Html.track.offsetWidth; } }); define(Sizes, 'wrapperSize', { /** * Gets size of the slides wrapper. * * @return {Number} */ get: function get() { return Sizes.slideWidth * Sizes.length + Components.Gaps.grow + Components.Clones.grow; } }); define(Sizes, 'slideWidth', { /** * Gets width value of a single slide. * * @return {Number} */ get: function get() { return Sizes.width / Glide.settings.perView - Components.Peek.reductor - Components.Gaps.reductor; } }); /** * Apply calculated glide's dimensions: * - before building, so other dimensions (e.g. translate) will be calculated propertly * - when resizing window to recalculate sildes dimensions * - on updating via API, to calculate dimensions based on new options */ Events.on(['build.before', 'resize', 'update'], function () { Sizes.setupSlides(); Sizes.setupWrapper(); }); /** * Remove calculated glide's dimensions: * - on destoting to bring markup to its inital state */ Events.on('destroy', function () { Sizes.remove(); }); return Sizes; } function Build (Glide, Components, Events) { var Build = { /** * Init glide building. Adds classes, sets * dimensions and setups initial state. * * @return {Void} */ mount: function mount() { Events.emit('build.before'); this.typeClass(); this.activeClass(); Events.emit('build.after'); }, /** * Adds `type` class to the glide element. * * @return {Void} */ typeClass: function typeClass() { Components.Html.root.classList.add(Glide.settings.classes.type[Glide.settings.type]); }, /** * Sets active class to current slide. * * @return {Void} */ activeClass: function activeClass() { var classes = Glide.settings.classes; var slide = Components.Html.slides[Glide.index]; if (slide) { slide.classList.add(classes.slide.active); siblings(slide).forEach(function (sibling) { sibling.classList.remove(classes.slide.active); }); } }, /** * Removes HTML classes applied at building. * * @return {Void} */ removeClasses: function removeClasses() { var _Glide$settings$class = Glide.settings.classes, type = _Glide$settings$class.type, slide = _Glide$settings$class.slide; Components.Html.root.classList.remove(type[Glide.settings.type]); Components.Html.slides.forEach(function (sibling) { sibling.classList.remove(slide.active); }); } }; /** * Clear building classes: * - on destroying to bring HTML to its initial state * - on updating to remove classes before remounting component */ Events.on(['destroy', 'update'], function () { Build.removeClasses(); }); /** * Remount component: * - on resizing of the window to calculate new dimensions * - on updating settings via API */ Events.on(['resize', 'update'], function () { Build.mount(); }); /** * Swap active class of current slide: * - after each move to the new index */ Events.on('move.after', function () { Build.activeClass(); }); return Build; } function Clones (Glide, Components, Events) { var Clones = { /** * Create pattern map and collect slides to be cloned. */ mount: function mount() { this.items = []; if (Glide.isType('carousel')) { this.items = this.collect(); } }, /** * Collect clones with pattern. * * @return {[]} */ collect: function collect() { var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var slides = Components.Html.slides; var _Glide$settings = Glide.settings, perView = _Glide$settings.perView, classes = _Glide$settings.classes, cloningRatio = _Glide$settings.cloningRatio; if (slides.length !== 0) { var peekIncrementer = +!!Glide.settings.peek; var cloneCount = perView + peekIncrementer + Math.round(perView / 2); var append = slides.slice(0, cloneCount).reverse(); var prepend = slides.slice(cloneCount * -1); for (var r = 0; r < Math.max(cloningRatio, Math.floor(perView / slides.length)); r++) { for (var i = 0; i < append.length; i++) { var clone = append[i].cloneNode(true); clone.classList.add(classes.slide.clone); items.push(clone); } for (var _i = 0; _i < prepend.length; _i++) { var _clone = prepend[_i].cloneNode(true); _clone.classList.add(classes.slide.clone); items.unshift(_clone); } } } return items; }, /** * Append cloned slides with generated pattern. * * @return {Void} */ append: function append() { var items = this.items; var _Components$Html = Components.Html, wrapper = _Components$Html.wrapper, slides = _Components$Html.slides; var half = Math.floor(items.length / 2); var prepend = items.slice(0, half).reverse(); var append = items.slice(half * -1).reverse(); var width = "".concat(Components.Sizes.slideWidth, "px"); for (var i = 0; i < append.length; i++) { wrapper.appendChild(append[i]); } for (var _i2 = 0; _i2 < prepend.length; _i2++) { wrapper.insertBefore(prepend[_i2], slides[0]); } for (var _i3 = 0; _i3 < items.length; _i3++) { items[_i3].style.width = width; } }, /** * Remove all cloned slides. * * @return {Void} */ remove: function remove() { var items = this.items; for (var i = 0; i < items.length; i++) { Components.Html.wrapper.removeChild(items[i]); } } }; define(Clones, 'grow', { /** * Gets additional dimensions value caused by clones. * * @return {Number} */ get: function get() { return (Components.Sizes.slideWidth + Components.Gaps.value) * Clones.items.length; } }); /** * Append additional slide's clones: * - while glide's type is `carousel` */ Events.on('update', function () { Clones.remove(); Clones.mount(); Clones.append(); }); /** * Append additional slide's clones: * - while glide's type is `carousel` */ Events.on('build.before', function () { if (Glide.isType('carousel')) { Clones.append(); } }); /** * Remove clones HTMLElements: * - on destroying, to bring HTML to its initial state */ Events.on('destroy', function () { Clones.remove(); }); return Clones; } var EventsBinder = /*#__PURE__*/function () { /** * Construct a EventsBinder instance. */ function EventsBinder() { var listeners = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _classCallCheck(this, EventsBinder); this.listeners = listeners; } /** * Adds events listeners to arrows HTML elements. * * @param {String|Array} events * @param {Element|Window|Document} el * @param {Function} closure * @param {Boolean|Object} capture * @return {Void} */ _createClass(EventsBinder, [{ key: "on", value: function on(events, el, closure) { var capture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; if (isString(events)) { events = [events]; } for (var i = 0; i < events.length; i++) { this.listeners[events[i]] = closure; el.addEventListener(events[i], this.listeners[events[i]], capture); } } /** * Removes event listeners from arrows HTML elements. * * @param {String|Array} events * @param {Element|Window|Document} el * @param {Boolean|Object} capture * @return {Void} */ }, { key: "off", value: function off(events, el) { var capture = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; if (isString(events)) { events = [events]; } for (var i = 0; i < events.length; i++) { el.removeEventListener(events[i], this.listeners[events[i]], capture); } } /** * Destroy collected listeners. * * @returns {Void} */ }, { key: "destroy", value: function destroy() { delete this.listeners; } }]); return EventsBinder; }(); function Resize (Glide, Components, Events) { /** * Instance of the binder for DOM Events. * * @type {EventsBinder} */ var Binder = new EventsBinder(); var Resize = { /** * Initializes window bindings. */ mount: function mount() { this.bind(); }, /** * Binds `rezsize` listener to the window. * It's a costly event, so we are debouncing it. * * @return {Void} */ bind: function bind() { Binder.on('resize', window, throttle(function () { Events.emit('resize'); }, Glide.settings.throttle)); }, /** * Unbinds listeners from the window. * * @return {Void} */ unbind: function unbind() { Binder.off('resize', window); } }; /** * Remove bindings from window: * - on destroying, to remove added EventListener */ Events.on('destroy', function () { Resize.unbind(); Binder.destroy(); }); return Resize; } var VALID_DIRECTIONS = ['ltr', 'rtl']; var FLIPED_MOVEMENTS = { '>': '<', '<': '>', '=': '=' }; function Direction (Glide, Components, Events) { var Direction = { /** * Setups gap value based on settings. * * @return {Void} */ mount: function mount() { this.value = Glide.settings.direction; }, /** * Resolves pattern based on direction value * * @param {String} pattern * @returns {String} */ resolve: function resolve(pattern) { var token = pattern.slice(0, 1); if (this.is('rtl')) { return pattern.split(token).join(FLIPED_MOVEMENTS[token]); } return pattern; }, /** * Checks value of direction mode. * * @param {String} direction * @returns {Boolean} */ is: function is(direction) { return this.value === direction; }, /** * Applies direction class to the root HTML element. * * @return {Void} */ addClass: function addClass() { Components.Html.root.classList.add(Glide.settings.classes.direction[this.value]); }, /** * Removes direction class from the root HTML element. * * @return {Void} */ removeClass: function removeClass() { Components.Html.root.classList.remove(Glide.settings.classes.direction[this.value]); } }; define(Direction, 'value', { /** * Gets value of the direction. * * @returns {Number} */ get: function get() { return Direction._v; }, /** * Sets value of the direction. * * @param {String} value * @return {Void} */ set: function set(value) { if (VALID_DIRECTIONS.indexOf(value) > -1) { Direction._v = value; } else { warn('Direction value must be `ltr` or `rtl`'); } } }); /** * Clear direction class: * - on destroy to bring HTML to its initial state * - on update to remove class before reappling bellow */ Events.on(['destroy', 'update'], function () { Direction.removeClass(); }); /** * Remount component: * - on update to reflect changes in direction value */ Events.on('update', function () { Direction.mount(); }); /** * Apply direction class: * - before building to apply class for the first time * - on updating to reapply direction class that may changed */ Events.on(['build.before', 'update'], function () { Direction.addClass(); }); return Direction; } /** * Reflects value of glide movement. * * @param {Object} Glide * @param {Object} Components * @return {Object} */ function Rtl (Glide, Components) { return { /** * Negates the passed translate if glide is in RTL option. * * @param {Number} translate * @return {Number} */ modify: function modify(translate) { if (Components.Direction.is('rtl')) { return -translate; } return translate; } }; } /** * Updates glide movement with a `gap` settings. * * @param {Object} Glide * @param {Object} Components * @return {Object} */ function Gap (Glide, Components) { return { /** * Modifies passed translate value with number in the `gap` settings. * * @param {Number} translate * @return {Number} */ modify: function modify(translate) { var multiplier = Math.floor(translate / Components.Sizes.slideWidth); return translate + Components.Gaps.value * multiplier; } }; } /** * Updates glide movement with width of additional clones width. * * @param {Object} Glide * @param {Object} Components * @return {Object} */ function Grow (Glide, Components) { return { /** * Adds to the passed translate width of the half of clones. * * @param {Number} translate * @return {Number} */ modify: function modify(translate) { return translate + Components.Clones.grow / 2; } }; } /** * Updates glide movement with a `peek` settings. * * @param {Object} Glide * @param {Object} Components * @return {Object} */ function Peeking (Glide, Components) { return { /** * Modifies passed translate value with a `peek` setting. * * @param {Number} translate * @return {Number} */ modify: function modify(translate) { if (Glide.settings.focusAt >= 0) { var peek = Components.Peek.value; if (isObject(peek)) { return translate - peek.before; } return translate - peek; } return translate; } }; } /** * Updates glide movement with a `focusAt` settings. * * @param {Object} Glide * @param {Object} Components * @return {Object} */ function Focusing (Glide, Components) { return { /** * Modifies passed translate value with index in the `focusAt` setting. * * @param {Number} translate * @return {Number} */ modify: function modify(translate) { var gap = Components.Gaps.value; var width = Components.Sizes.width; var focusAt = Glide.settings.focusAt; var slideWidth = Components.Sizes.slideWidth; if (focusAt === 'center') { return translate - (width / 2 - slideWidth / 2); } return translate - slideWidth * focusAt - gap * focusAt; } }; } /** * Applies diffrent transformers on translate value. * * @param {Object} Glide * @param {Object} Components * @return {Object} */ function mutator (Glide, Components, Events) { /** * Merge instance transformers with collection of default transformers. * It's important that the Rtl component be last on the list, * so it reflects all previous transformations. * * @type {Array} */ var TRANSFORMERS = [Gap, Grow, Peeking, Focusing].concat(Glide._t, [Rtl]); return { /** * Piplines translate value with registered transformers. * * @param {Number} translate * @return {Number} */ mutate: function mutate(translate) { for (var i = 0; i < TRANSFORMERS.length; i++) { var transformer = TRANSFORMERS[i]; if (isFunction(transformer) && isFunction(transformer().modify)) { translate = transformer(Glide, Components, Events).modify(translate); } else { warn('Transformer should be a function that returns an object with `modify()` method'); } } return translate; } }; } function Translate (Glide, Components, Events) { var Translate = { /** * Sets value of translate on HTML element. * * @param {Number} value * @return {Void} */ set: function set(value) { var transform = mutator(Glide, Components).mutate(value); var translate3d = "translate3d(".concat(-1 * transform, "px, 0px, 0px)"); Components.Html.wrapper.style.mozTransform = translate3d; // needed for supported Firefox 10-15 Components.Html.wrapper.style.webkitTransform = translate3d; // needed for supported Chrome 10-35, Safari 5.1-8, and Opera 15-22 Components.Html.wrapper.style.transform = translate3d; }, /** * Removes value of translate from HTML element. * * @return {Void} */ remove: function remove() { Components.Html.wrapper.style.transform = ''; }, /** * @return {number} */ getStartIndex: function getStartIndex() { var length = Components.Sizes.length; var index = Glide.index; var perView = Glide.settings.perView; if (Components.Run.isOffset('>') || Components.Run.isOffset('|>')) { return length + (index - perView); } // "modulo length" converts an index that equals length to zero return (index + perView) % length; }, /** * @return {number} */ getTravelDistance: function getTravelDistance() { var travelDistance = Components.Sizes.slideWidth * Glide.settings.perView; if (Components.Run.isOffset('>') || Components.Run.isOffset('|>')) { // reverse travel distance so that we don't have to change subtract operations return travelDistance * -1; } return travelDistance; } }; /** * Set new translate value: * - on move to reflect index change * - on updating via API to reflect possible changes in options */ Events.on('move', function (context) { if (!Glide.isType('carousel') || !Components.Run.isOffset()) { return Translate.set(context.movement); } Components.Transition.after(function () { Events.emit('translate.jump'); Translate.set(Components.Sizes.slideWidth * Glide.index); }); var startWidth = Components.Sizes.slideWidth * Components.Translate.getStartIndex(); return Translate.set(startWidth - Components.Translate.getTravelDistance()); }); /** * Remove translate: * - on destroying to bring markup to its inital state */ Events.on('destroy', function () { Translate.remove(); }); return Translate; } function Transition (Glide, Components, Events) { /** * Holds inactivity status of transition. * When true transition is not applied. * * @type {Boolean} */ var disabled = false; var Transition = { /** * Composes string of the CSS transition. * * @param {String} property * @return {String} */ compose: function compose(property) { var settings = Glide.settings; if (!disabled) { return "".concat(property, " ").concat(this.duration, "ms ").concat(settings.animationTimingFunc); } return "".concat(property, " 0ms ").concat(settings.animationTimingFunc); }, /** * Sets value of transition on HTML element. * * @param {String=} property * @return {Void} */ set: function set() { var property = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'transform'; Components.Html.wrapper.style.transition = this.compose(property); }, /** * Removes value of transition from HTML element. * * @return {Void} */ remove: function remove() { Components.Html.wrapper.style.transition = ''; }, /** * Runs callback after animation. * * @param {Function} callback * @return {Void} */ after: function after(callback) { setTimeout(function () { callback(); }, this.duration); }, /** * Enable transition. * * @return {Void} */ enable: function enable() { disabled = false; this.set(); }, /** * Disable transition. * * @return {Void} */ disable: function disable() { disabled = true; this.set(); } }; define(Transition, 'duration', { /** * Gets duration of the transition based * on currently running animation type. * * @return {Number} */ get: function get() { var settings = Glide.settings; if (Glide.isType('slider') && Components.Run.offset) { return settings.rewindDuration; } return settings.animationDuration; } }); /** * Set transition `style` value: * - on each moving, because it may be cleared by offset move */ Events.on('move', function () { Transition.set(); }); /** * Disable transition: * - before initial build to avoid transitioning from `0` to `startAt` index * - while resizing window and recalculating dimensions * - on jumping from offset transition at start and end edges in `carousel` type */ Events.on(['build.before', 'resize', 'translate.jump'], function () { Transition.disable(); }); /** * Enable transition: * - on each running, because it may be disabled by offset move */ Events.on('run', function () { Transition.enable(); }); /** * Remove transition: * - on destroying to bring markup to its inital state */ Events.on('destroy', function () { Transition.remove(); }); return Transition; } /** * Test via a getter in the options object to see * if the passive property is accessed. * * @see https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md#feature-detection */ var supportsPassive = false; try { var opts = Object.defineProperty({}, 'passive', { get: function get() { supportsPassive = true; } }); window.addEventListener('testPassive', null, opts); window.removeEventListener('testPassive', null, opts); } catch (e) {} var supportsPassive$1 = supportsPassive; var START_EVENTS = ['touchstart', 'mousedown']; var MOVE_EVENTS = ['touchmove', 'mousemove']; var END_EVENTS = ['touchend', 'touchcancel', 'mouseup', 'mouseleave']; var MOUSE_EVENTS = ['mousedown', 'mousemove', 'mouseup', 'mouseleave']; function Swipe (Glide, Components, Events) { /** * Instance of the binder for DOM Events. * * @type {EventsBinder} */ var Binder = new EventsBinder(); var swipeSin = 0; var swipeStartX = 0; var swipeStartY = 0; var disabled = false; var capture = supportsPassive$1 ? { passive: true } : false; var Swipe = { /** * Initializes swipe bindings. * * @return {Void} */ mount: function mount() { this.bindSwipeStart(); }, /** * Handler for `swipestart` event. Calculates entry points of the user's tap. * * @param {Object} event * @return {Void} */ start: function start(event) { if (!disabled && !Glide.disabled) { this.disable(); var swipe = this.touches(event); swipeSin = null; swipeStartX = toInt(swipe.pageX); swipeStartY = toInt(swipe.pageY); this.bindSwipeMove(); this.bindSwipeEnd(); Events.emit('swipe.start'); } }, /** * Handler for `swipemove` event. Calculates user's tap angle and distance. * * @param {Object} event */ move: function move(event) { if (!Glide.disabled) { var _Glide$settings = Glide.settings, touchAngle = _Glide$settings.touchAngle, touchRatio = _Glide$settings.touchRatio, classes = _Glide$settings.classes; var swipe = this.touches(event); var subExSx = toInt(swipe.pageX) - swipeStartX; var subEySy = toInt(swipe.pageY) - swipeStartY; var powEX = Math.abs(subExSx << 2); var powEY = Math.abs(subEySy << 2); var swipeHypotenuse = Math.sqrt(powEX + powEY); var swipeCathetus = Math.sqrt(powEY); swipeSin = Math.asin(swipeCathetus / swipeHypotenuse); if (swipeSin * 180 / Math.PI < touchAngle) { event.stopPropagation(); Components.Move.make(subExSx * toFloat(touchRatio)); Components.Html.root.classList.add(classes.dragging); Events.emit('swipe.move'); } else { return false; } } }, /** * Handler for `swipeend` event. Finitializes user's tap and decides about glide move. * * @param {Object} event * @return {Void} */ end: function end(event) { if (!Glide.disabled) { var _Glide$settings2 = Glide.settings, perSwipe = _Glide$settings2.perSwipe, touchAngle = _Glide$settings2.touchAngle, classes = _Glide$settings2.classes; var swipe = this.touches(event); var threshold = this.threshold(event); var swipeDistance = swipe.pageX - swipeStartX; var swipeDeg = swipeSin * 180 / Math.PI; this.enable(); if (swipeDistance > threshold && swipeDeg < touchAngle) { Components.Run.make(Components.Direction.resolve("".concat(perSwipe, "<"))); } else if (swipeDistance < -threshold && swipeDeg < touchAngle) { Components.Run.make(Components.Direction.resolve("".concat(perSwipe, ">"))); } else { // While swipe don't reach distance apply previous transform. Components.Move.make(); } Components.Html.root.classList.remove(classes.dragging); this.unbindSwipeMove(); this.unbindSwipeEnd(); Events.emit('swipe.end'); } }, /** * Binds swipe's starting event. * * @return {Void} */ bindSwipeStart: function bindSwipeStart() { var _this = this; var _Glide$settings3 = Glide.settings, swipeThreshold = _Glide$settings3.swipeThreshold, dragThreshold = _Glide$settings3.dragThreshold; if (swipeThreshold) { Binder.on(START_EVENTS[0], Components.Html.wrapper, function (event) { _this.start(event); }, capture); } if (dragThreshold) { Binder.on(START_EVENTS[1], Components.Html.wrapper, function (event) { _this.start(event); }, capture); } }, /** * Unbinds swipe's starting event. * * @return {Void} */ unbindSwipeStart: function unbindSwipeStart() { Binder.off(START_EVENTS[0], Components.Html.wrapper, capture); Binder.off(START_EVENTS[1], Components.Html.wrapper, capture); }, /** * Binds swipe's moving event. * * @return {Void} */ bindSwipeMove: function bindSwipeMove() { var _this2 = this; Binder.on(MOVE_EVENTS, Components.Html.wrapper, throttle(function (event) { _this2.move(event); }, Glide.settings.throttle), capture); }, /** * Unbinds swipe's moving event. * * @return {Void} */ unbindSwipeMove: function unbindSwipeMove() { Binder.off(MOVE_EVENTS, Components.Html.wrapper, capture); }, /** * Binds swipe's ending event. * * @return {Void} */ bindSwipeEnd: function bindSwipeEnd() { var _this3 = this; Binder.on(END_EVENTS, Components.Html.wrapper, function (event) { _this3.end(event); }); }, /** * Unbinds swipe's ending event. * * @return {Void} */ unbindSwipeEnd: function unbindSwipeEnd() { Binder.off(END_EVENTS, Components.Html.wrapper); }, /** * Normalizes event touches points accorting to different types. * * @param {Object} event */ touches: function touches(event) { if (MOUSE_EVENTS.indexOf(event.type) > -1) { return event; } return event.touches[0] || event.changedTouches[0]; }, /** * Gets value of minimum swipe distance settings based on event type. * * @return {Number} */ threshold: function threshold(event) { var settings = Glide.settings; if (MOUSE_EVENTS.indexOf(event.type) > -1) { return settings.dragThreshold; } return settings.swipeThreshold; }, /** * Enables swipe event. * * @return {self} */ enable: function enable() { disabled = false; Components.Transition.enable(); return this; }, /** * Disables swipe event. * * @return {self} */ disable: function disable() { disabled = true; Components.Transition.disable(); return this; } }; /** * Add component class: * - after initial building */ Events.on('build.after', function () { Components.Html.root.classList.add(Glide.settings.classes.swipeable); }); /** * Remove swiping bindings: * - on destroying, to remove added EventListeners */ Events.on('destroy', function () { Swipe.unbindSwipeStart(); Swipe.unbindSwipeMove(); Swipe.unbindSwipeEnd(); Binder.destroy(); }); return Swipe; } function Images (Glide, Components, Events) { /** * Instance of the binder for DOM Events. * * @type {EventsBinder} */ var Binder = new EventsBinder(); var Images = { /** * Binds listener to glide wrapper. * * @return {Void} */ mount: function mount() { this.bind(); }, /** * Binds `dragstart` event on wrapper to prevent dragging images. * * @return {Void} */ bind: function bind() { Binder.on('dragstart', Components.Html.wrapper, this.dragstart); }, /** * Unbinds `dragstart` event on wrapper. * * @return {Void} */ unbind: function unbind() { Binder.off('dragstart', Components.Html.wrapper); }, /** * Event handler. Prevents dragging. * * @return {Void} */ dragstart: function dragstart(event) { event.preventDefault(); } }; /** * Remove bindings from images: * - on destroying, to remove added EventListeners */ Events.on('destroy', function () { Images.unbind(); Binder.destroy(); }); return Images; } function Anchors (Glide, Components, Events) { /** * Instance of the binder for DOM Events. * * @type {EventsBinder} */ var Binder = new EventsBinder(); /** * Holds detaching status of anchors. * Prevents detaching of already detached anchors. * * @private * @type {Boolean} */ var detached = false; /** * Holds preventing status of anchors. * If `true` redirection after click will be disabled. * * @private * @type {Boolean} */ var prevented = false; var Anchors = { /** * Setups a initial state of anchors component. * * @returns {Void} */ mount: function mount() { /** * Holds collection of anchors elements. * * @private * @type {HTMLCollection} */ this._a = Components.Html.wrapper.querySelectorAll('a'); this.bind(); }, /** * Binds events to anchors inside a track. * * @return {Void} */ bind: function bind() { Binder.on('click', Components.Html.wrapper, this.click); }, /** * Unbinds events attached to anchors inside a track. * * @return {Void} */ unbind: function unbind() { Binder.off('click', Components.Html.wrapper); }, /** * Handler for click event. Prevents clicks when glide is in `prevent` status. * * @param {Object} event * @return {Void} */ click: function click(event) { if (prevented) { event.stopPropagation(); event.preventDefault(); } }, /** * Detaches anchors click event inside glide. * * @return {self} */ detach: function detach() { prevented = true; if (!detached) { for (var i = 0; i < this.items.length; i++) { this.items[i].draggable = false; } detached = true; } return this; }, /** * Attaches anchors click events inside glide. * * @return {self} */ attach: function attach() { prevented = false; if (detached) { for (var i = 0; i < this.items.length; i++) { this.items[i].draggable = true; } detached = false; } return this; } }; define(Anchors, 'items', { /** * Gets collection of the arrows HTML elements. * * @return {HTMLElement[]} */ get: function get() { return Anchors._a; } }); /** * Detach anchors inside slides: * - on swiping, so they won't redirect to its `href` attributes */ Events.on('swipe.move', function () { Anchors.detach(); }); /** * Attach anchors inside slides: * - after swiping and transitions ends, so they can redirect after click again */ Events.on('swipe.end', function () { Components.Transition.after(function () { Anchors.attach(); }); }); /** * Unbind anchors inside slides: * - on destroying, to bring anchors to its initial state */ Events.on('destroy', function () { Anchors.attach(); Anchors.unbind(); Binder.destroy(); }); return Anchors; } var NAV_SELECTOR = '[data-glide-el="controls[nav]"]'; var CONTROLS_SELECTOR = '[data-glide-el^="controls"]'; var PREVIOUS_CONTROLS_SELECTOR = "".concat(CONTROLS_SELECTOR, " [data-glide-dir*=\"<\"]"); var NEXT_CONTROLS_SELECTOR = "".concat(CONTROLS_SELECTOR, " [data-glide-dir*=\">\"]"); function Controls (Glide, Components, Events) { /** * Instance of the binder for DOM Events. * * @type {EventsBinder} */ var Binder = new EventsBinder(); var capture = supportsPassive$1 ? { passive: true } : false; var Controls = { /** * Inits arrows. Binds events listeners * to the arrows HTML elements. * * @return {Void} */ mount: function mount() { /** * Collection of navigation HTML elements. * * @private * @type {HTMLCollection} */ this._n = Components.Html.root.querySelectorAll(NAV_SELECTOR); /** * Collection of controls HTML elements. * * @private * @type {HTMLCollection} */ this._c = Components.Html.root.querySelectorAll(CONTROLS_SELECTOR); /** * Collection of arrow control HTML elements. * * @private * @type {Object} */ this._arrowControls = { previous: Components.Html.root.querySelectorAll(PREVIOUS_CONTROLS_SELECTOR), next: Components.Html.root.querySelectorAll(NEXT_CONTROLS_SELECTOR) }; this.addBindings(); }, /** * Sets active class to current slide. * * @return {Void} */ setActive: function setActive() { for (var i = 0; i < this._n.length; i++) { this.addClass(this._n[i].children); } }, /** * Removes active class to current slide. * * @return {Void} */ removeActive: function removeActive() { for (var i = 0; i < this._n.length; i++) { this.removeClass(this._n[i].children); } }, /** * Toggles active class on items inside navigation. * * @param {HTMLElement} controls * @return {Void} */ addClass: function addClass(controls) { var settings = Glide.settings; var item = controls[Glide.index]; if (!item) { return; } if (item) { item.classList.add(settings.classes.nav.active); siblings(item).forEach(function (sibling) { sibling.classList.remove(settings.classes.nav.active); }); } }, /** * Removes active class from active control. * * @param {HTMLElement} controls * @return {Void} */ removeClass: function removeClass(controls) { var item = controls[Glide.index]; if (item) { item.classList.remove(Glide.settings.classes.nav.active); } }, /** * Calculates, removes or adds `Glide.settings.classes.disabledArrow` class on the control arrows */ setArrowState: function setArrowState() { if (Glide.settings.rewind) { return; } var next = Controls._arrowControls.next; var previous = Controls._arrowControls.previous; this.resetArrowState(next, previous); if (Glide.index === 0) { this.disableArrow(previous); } if (Glide.index === Components.Run.length) { this.disableArrow(next); } }, /** * Removes `Glide.settings.classes.disabledArrow` from given NodeList elements * * @param {NodeList[]} lists */ resetArrowState: function resetArrowState() { var settings = Glide.settings; for (var _len = arguments.length, lists = new Array(_len), _key = 0; _key < _len; _key++) { lists[_key] = arguments[_key]; } lists.forEach(function (list) { toArray(list).forEach(function (element) { element.classList.remove(settings.classes.arrow.disabled); }); }); }, /** * Adds `Glide.settings.classes.disabledArrow` to given NodeList elements * * @param {NodeList[]} lists */ disableArrow: function disableArrow() { var settings = Glide.settings; for (var _len2 = arguments.length, lists = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { lists[_key2] = arguments[_key2]; } lists.forEach(function (list) { toArray(list).forEach(function (element) { element.classList.add(settings.classes.arrow.disabled); }); }); }, /** * Adds handles to the each group of controls. * * @return {Void} */ addBindings: function addBindings() { for (var i = 0; i < this._c.length; i++) { this.bind(this._c[i].children); } }, /** * Removes handles from the each group of controls. * * @return {Void} */ removeBindings: function removeBindings() { for (var i = 0; i < this._c.length; i++) { this.unbind(this._c[i].children); } }, /** * Binds events to arrows HTML elements. * * @param {HTMLCollection} elements * @return {Void} */ bind: function bind(elements) { for (var i = 0; i < elements.length; i++) { Binder.on('click', elements[i], this.click); Binder.on('touchstart', elements[i], this.click, capture); } }, /** * Unbinds events binded to the arrows HTML elements. * * @param {HTMLCollection} elements * @return {Void} */ unbind: function unbind(elements) { for (var i = 0; i < elements.length; i++) { Binder.off(['click', 'touchstart'], elements[i]); } }, /** * Handles `click` event on the arrows HTML elements. * Moves slider in direction given via the * `data-glide-dir` attribute. * * @param {Object} event * @return {void} */ click: function click(event) { if (!supportsPassive$1 && event.type === 'touchstart') { event.preventDefault(); } var direction = event.currentTarget.getAttribute('data-glide-dir'); Components.Run.make(Components.Direction.resolve(direction)); } }; define(Controls, 'items', { /** * Gets collection of the controls HTML elements. * * @return {HTMLElement[]} */ get: function get() { return Controls._c; } }); /** * Swap active class of current navigation item: * - after mounting to set it to initial index * - after each move to the new index */ Events.on(['mount.after', 'move.after'], function () { Controls.setActive(); }); /** * Add or remove disabled class of arrow elements */ Events.on(['mount.after', 'run'], function () { Controls.setArrowState(); }); /** * Remove bindings and HTML Classes: * - on destroying, to bring markup to its initial state */ Events.on('destroy', function () { Controls.removeBindings(); Controls.removeActive(); Binder.destroy(); }); return Controls; } function Keyboard (Glide, Components, Events) { /** * Instance of the binder for DOM Events. * * @type {EventsBinder} */ var Binder = new EventsBinder(); var Keyboard = { /** * Binds keyboard events on component mount. * * @return {Void} */ mount: function mount() { if (Glide.settings.keyboard) { this.bind(); } }, /** * Adds keyboard press events. * * @return {Void} */ bind: function bind() { Binder.on('keyup', document, this.press); }, /** * Removes keyboard press events. * * @return {Void} */ unbind: function unbind() { Binder.off('keyup', document); }, /** * Handles keyboard's arrows press and moving glide foward and backward. * * @param {Object} event * @return {Void} */ press: function press(event) { var perSwipe = Glide.settings.perSwipe; if (event.code === 'ArrowRight') { Components.Run.make(Components.Direction.resolve("".concat(perSwipe, ">"))); } if (event.code === 'ArrowLeft') { Components.Run.make(Components.Direction.resolve("".concat(perSwipe, "<"))); } } }; /** * Remove bindings from keyboard: * - on destroying to remove added events * - on updating to remove events before remounting */ Events.on(['destroy', 'update'], function () { Keyboard.unbind(); }); /** * Remount component * - on updating to reflect potential changes in settings */ Events.on('update', function () { Keyboard.mount(); }); /** * Destroy binder: * - on destroying to remove listeners */ Events.on('destroy', function () { Binder.destroy(); }); return Keyboard; } function Autoplay (Glide, Components, Events) { /** * Instance of the binder for DOM Events. * * @type {EventsBinder} */ var Binder = new EventsBinder(); var Autoplay = { /** * Initializes autoplaying and events. * * @return {Void} */ mount: function mount() { this.enable(); this.start(); if (Glide.settings.hoverpause) { this.bind(); } }, /** * Enables autoplaying * * @returns {Void} */ enable: function enable() { this._e = true; }, /** * Disables autoplaying. * * @returns {Void} */ disable: function disable() { this._e = false; }, /** * Starts autoplaying in configured interval. * * @param {Boolean|Number} force Run autoplaying with passed interval regardless of `autoplay` settings * @return {Void} */ start: function start() { var _this = this; if (!this._e) { return; } this.enable(); if (Glide.settings.autoplay) { if (isUndefined(this._i)) { this._i = setInterval(function () { _this.stop(); Components.Run.make('>'); _this.start(); Events.emit('autoplay'); }, this.time); } } }, /** * Stops autorunning of the glide. * * @return {Void} */ stop: function stop() { this._i = clearInterval(this._i); }, /** * Stops autoplaying while mouse is over glide's area. * * @return {Void} */ bind: function bind() { var _this2 = this; Binder.on('mouseover', Components.Html.root, function () { if (_this2._e) { _this2.stop(); } }); Binder.on('mouseout', Components.Html.root, function () { if (_this2._e) { _this2.start(); } }); }, /** * Unbind mouseover events. * * @returns {Void} */ unbind: function unbind() { Binder.off(['mouseover', 'mouseout'], Components.Html.root); } }; define(Autoplay, 'time', { /** * Gets time period value for the autoplay interval. Prioritizes * times in `data-glide-autoplay` attrubutes over options. * * @return {Number} */ get: function get() { var autoplay = Components.Html.slides[Glide.index].getAttribute('data-glide-autoplay'); if (autoplay) { return toInt(autoplay); } return toInt(Glide.settings.autoplay); } }); /** * Stop autoplaying and unbind events: * - on destroying, to clear defined interval * - on updating via API to reset interval that may changed */ Events.on(['destroy', 'update'], function () { Autoplay.unbind(); }); /** * Stop autoplaying: * - before each run, to restart autoplaying * - on pausing via API * - on destroying, to clear defined interval * - while starting a swipe * - on updating via API to reset interval that may changed */ Events.on(['run.before', 'swipe.start', 'update'], function () { Autoplay.stop(); }); Events.on(['pause', 'destroy'], function () { Autoplay.disable(); Autoplay.stop(); }); /** * Start autoplaying: * - after each run, to restart autoplaying * - on playing via API * - while ending a swipe */ Events.on(['run.after', 'swipe.end'], function () { Autoplay.start(); }); /** * Start autoplaying: * - after each run, to restart autoplaying * - on playing via API * - while ending a swipe */ Events.on(['play'], function () { Autoplay.enable(); Autoplay.start(); }); /** * Remount autoplaying: * - on updating via API to reset interval that may changed */ Events.on('update', function () { Autoplay.mount(); }); /** * Destroy a binder: * - on destroying glide instance to clearup listeners */ Events.on('destroy', function () { Binder.destroy(); }); return Autoplay; } /** * Sorts keys of breakpoint object so they will be ordered from lower to bigger. * * @param {Object} points * @returns {Object} */ function sortBreakpoints(points) { if (isObject(points)) { return sortKeys(points); } else { warn("Breakpoints option must be an object"); } return {}; } function Breakpoints (Glide, Components, Events) { /** * Instance of the binder for DOM Events. * * @type {EventsBinder} */ var Binder = new EventsBinder(); /** * Holds reference to settings. * * @type {Object} */ var settings = Glide.settings; /** * Holds reference to breakpoints object in settings. Sorts breakpoints * from smaller to larger. It is required in order to proper * matching currently active breakpoint settings. * * @type {Object} */ var points = sortBreakpoints(settings.breakpoints); /** * Cache initial settings before overwritting. * * @type {Object} */ var defaults = Object.assign({}, settings); var Breakpoints = { /** * Matches settings for currectly matching media breakpoint. * * @param {Object} points * @returns {Object} */ match: function match(points) { if (typeof window.matchMedia !== 'undefined') { for (var point in points) { if (points.hasOwnProperty(point)) { if (window.matchMedia("(max-width: ".concat(point, "px)")).matches) { return points[point]; } } } } return defaults; } }; /** * Overwrite instance settings with currently matching breakpoint settings. * This happens right after component initialization. */ Object.assign(settings, Breakpoints.match(points)); /** * Update glide with settings of matched brekpoint: * - window resize to update slider */ Binder.on('resize', window, throttle(function () { Glide.settings = mergeOptions(settings, Breakpoints.match(points)); }, Glide.settings.throttle)); /** * Resort and update default settings: * - on reinit via API, so breakpoint matching will be performed with options */ Events.on('update', function () { points = sortBreakpoints(points); defaults = Object.assign({}, settings); }); /** * Unbind resize listener: * - on destroying, to bring markup to its initial state */ Events.on('destroy', function () { Binder.off('resize', window); }); return Breakpoints; } var COMPONENTS = { // Required Html: Html, Translate: Translate, Transition: Transition, Direction: Direction, Peek: Peek, Sizes: Sizes, Gaps: Gaps, Move: Move, Clones: Clones, Resize: Resize, Build: Build, Run: Run, // Optional Swipe: Swipe, Images: Images, Anchors: Anchors, Controls: Controls, Keyboard: Keyboard, Autoplay: Autoplay, Breakpoints: Breakpoints }; var Glide = /*#__PURE__*/function (_Core) { _inherits(Glide, _Core); var _super = _createSuper(Glide); function Glide() { _classCallCheck(this, Glide); return _super.apply(this, arguments); } _createClass(Glide, [{ key: "mount", value: function mount() { var extensions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return _get(_getPrototypeOf(Glide.prototype), "mount", this).call(this, Object.assign({}, COMPONENTS, extensions)); } }]); return Glide; }(Glide$1); /***/ }), /***/ "./node_modules/base64-js/index.js": /*!*****************************************!*\ !*** ./node_modules/base64-js/index.js ***! \*****************************************/ /*! no static exports found */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.byteLength = byteLength exports.toByteArray = toByteArray exports.fromByteArray = fromByteArray var lookup = [] var revLookup = [] var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' for (var i = 0, len = code.length; i < len; ++i) { lookup[i] = code[i] revLookup[code.charCodeAt(i)] = i } // Support decoding URL-safe base64 strings, as Node.js does. // See: https://en.wikipedia.org/wiki/Base64#URL_applications revLookup['-'.charCodeAt(0)] = 62 revLookup['_'.charCodeAt(0)] = 63 function getLens (b64) { var len = b64.length if (len % 4 > 0) { throw new Error('Invalid string. Length must be a multiple of 4') } // Trim off extra bytes after placeholder bytes are found // See: https://github.com/beatgammit/base64-js/issues/42 var validLen = b64.indexOf('=') if (validLen === -1) validLen = len var placeHoldersLen = validLen === len ? 0 : 4 - (validLen % 4) return [validLen, placeHoldersLen] } // base64 is 4/3 + up to two characters of the original data function byteLength (b64) { var lens = getLens(b64) var validLen = lens[0] var placeHoldersLen = lens[1] return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen } function _byteLength (b64, validLen, placeHoldersLen) { return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen } function toByteArray (b64) { var tmp var lens = getLens(b64) var validLen = lens[0] var placeHoldersLen = lens[1] var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) var curByte = 0 // if there are placeholders, only get up to the last complete 4 chars var len = placeHoldersLen > 0 ? validLen - 4 : validLen for (var i = 0; i < len; i += 4) { tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] arr[curByte++] = (tmp >> 16) & 0xFF arr[curByte++] = (tmp >> 8) & 0xFF arr[curByte++] = tmp & 0xFF } if (placeHoldersLen === 2) { tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) arr[curByte++] = tmp & 0xFF } if (placeHoldersLen === 1) { tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) arr[curByte++] = (tmp >> 8) & 0xFF arr[curByte++] = tmp & 0xFF } return arr } function tripletToBase64 (num) { return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] } function encodeChunk (uint8, start, end) { var tmp var output = [] for (var i = start; i < end; i += 3) { tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF) output.push(tripletToBase64(tmp)) } return output.join('') } function fromByteArray (uint8) { var tmp var len = uint8.length var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes var parts = [] var maxChunkLength = 16383 // must be multiple of 3 // go through the array every three bytes, we'll deal with trailing stuff later for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { parts.push(encodeChunk( uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) )) } // pad the end with zeros, but make sure to not forget the extra bytes if (extraBytes === 1) { tmp = uint8[len - 1] parts.push( lookup[tmp >> 2] + lookup[(tmp << 4) & 0x3F] + '==' ) } else if (extraBytes === 2) { tmp = (uint8[len - 2] << 8) + uint8[len - 1] parts.push( lookup[tmp >> 10] + lookup[(tmp >> 4) & 0x3F] + lookup[(tmp << 2) & 0x3F] + '=' ) } return parts.join('') } /***/ }), /***/ "./node_modules/body-scroll-lock/lib/bodyScrollLock.min.js": /*!*****************************************************************!*\ !*** ./node_modules/body-scroll-lock/lib/bodyScrollLock.min.js ***! \*****************************************************************/ /*! no static exports found */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!function(e,t){if(true)!(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (t), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));else { var o; }}(this,function(exports){"use strict";function r(e){if(Array.isArray(e)){for(var t=0,o=Array(e.length);t { /** * ------------------------------------------------------------------------ * Constants * ------------------------------------------------------------------------ */ const NAME = 'alert'; const VERSION = '4.1.3'; const DATA_KEY = 'bs.alert'; const EVENT_KEY = `.${DATA_KEY}`; const DATA_API_KEY = '.data-api'; const JQUERY_NO_CONFLICT = $.fn[NAME]; const Selector = { DISMISS: '[data-dismiss="alert"]' }; const Event = { CLOSE: `close${EVENT_KEY}`, CLOSED: `closed${EVENT_KEY}`, CLICK_DATA_API: `click${EVENT_KEY}${DATA_API_KEY}` }; const ClassName = { ALERT: 'alert', FADE: 'fade', SHOW: 'show' /** * ------------------------------------------------------------------------ * Class Definition * ------------------------------------------------------------------------ */ }; class Alert { constructor(element) { this._element = element; } // Getters static get VERSION() { return VERSION; } // Public close(element) { let rootElement = this._element; if (element) { rootElement = this._getRootElement(element); } const customEvent = this._triggerCloseEvent(rootElement); if (customEvent.isDefaultPrevented()) { return; } this._removeElement(rootElement); } dispose() { $.removeData(this._element, DATA_KEY); this._element = null; } // Private _getRootElement(element) { const selector = _util__WEBPACK_IMPORTED_MODULE_1__["default"].getSelectorFromElement(element); let parent = false; if (selector) { parent = document.querySelector(selector); } if (!parent) { parent = $(element).closest(`.${ClassName.ALERT}`)[0]; } return parent; } _triggerCloseEvent(element) { const closeEvent = $.Event(Event.CLOSE); $(element).trigger(closeEvent); return closeEvent; } _removeElement(element) { $(element).removeClass(ClassName.SHOW); if (!$(element).hasClass(ClassName.FADE)) { this._destroyElement(element); return; } const transitionDuration = _util__WEBPACK_IMPORTED_MODULE_1__["default"].getTransitionDurationFromElement(element); $(element).one(_util__WEBPACK_IMPORTED_MODULE_1__["default"].TRANSITION_END, event => this._destroyElement(element, event)).emulateTransitionEnd(transitionDuration); } _destroyElement(element) { $(element).detach().trigger(Event.CLOSED).remove(); } // Static static _jQueryInterface(config) { return this.each(function () { const $element = $(this); let data = $element.data(DATA_KEY); if (!data) { data = new Alert(this); $element.data(DATA_KEY, data); } if (config === 'close') { data[config](this); } }); } static _handleDismiss(alertInstance) { return function (event) { if (event) { event.preventDefault(); } alertInstance.close(this); }; } } /** * ------------------------------------------------------------------------ * Data Api implementation * ------------------------------------------------------------------------ */ $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert())); /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ */ $.fn[NAME] = Alert._jQueryInterface; $.fn[NAME].Constructor = Alert; $.fn[NAME].noConflict = function () { $.fn[NAME] = JQUERY_NO_CONFLICT; return Alert._jQueryInterface; }; return Alert; })(jquery__WEBPACK_IMPORTED_MODULE_0___default.a); /* harmony default export */ __webpack_exports__["default"] = (Alert); /***/ }), /***/ "./node_modules/bootstrap/js/src/carousel.js": /*!***************************************************!*\ !*** ./node_modules/bootstrap/js/src/carousel.js ***! \***************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./cartridges/app_storefront_base/cartridge/client/default/js/thirdParty/bootstrap.js (referenced with cjs require) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util */ "./node_modules/bootstrap/js/src/util.js"); function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /** * -------------------------------------------------------------------------- * Bootstrap (v4.1.3): carousel.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ const Carousel = ($ => { /** * ------------------------------------------------------------------------ * Constants * ------------------------------------------------------------------------ */ const NAME = 'carousel'; const VERSION = '4.1.3'; const DATA_KEY = 'bs.carousel'; const EVENT_KEY = `.${DATA_KEY}`; const DATA_API_KEY = '.data-api'; const JQUERY_NO_CONFLICT = $.fn[NAME]; const ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key const ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch const Default = { interval: 5000, keyboard: true, slide: false, pause: 'hover', wrap: true }; const DefaultType = { interval: '(number|boolean)', keyboard: 'boolean', slide: '(boolean|string)', pause: '(string|boolean)', wrap: 'boolean' }; const Direction = { NEXT: 'next', PREV: 'prev', LEFT: 'left', RIGHT: 'right' }; const Event = { SLIDE: `slide${EVENT_KEY}`, SLID: `slid${EVENT_KEY}`, KEYDOWN: `keydown${EVENT_KEY}`, MOUSEENTER: `mouseenter${EVENT_KEY}`, MOUSELEAVE: `mouseleave${EVENT_KEY}`, TOUCHEND: `touchend${EVENT_KEY}`, LOAD_DATA_API: `load${EVENT_KEY}${DATA_API_KEY}`, CLICK_DATA_API: `click${EVENT_KEY}${DATA_API_KEY}` }; const ClassName = { CAROUSEL: 'carousel', ACTIVE: 'active', SLIDE: 'slide', RIGHT: 'carousel-item-right', LEFT: 'carousel-item-left', NEXT: 'carousel-item-next', PREV: 'carousel-item-prev', ITEM: 'carousel-item' }; const Selector = { ACTIVE: '.active', ACTIVE_ITEM: '.active.carousel-item', ITEM: '.carousel-item', NEXT_PREV: '.carousel-item-next, .carousel-item-prev', INDICATORS: '.carousel-indicators', DATA_SLIDE: '[data-slide], [data-slide-to]', DATA_RIDE: '[data-ride="carousel"]' /** * ------------------------------------------------------------------------ * Class Definition * ------------------------------------------------------------------------ */ }; class Carousel { constructor(element, config) { this._items = null; this._interval = null; this._activeElement = null; this._isPaused = false; this._isSliding = false; this.touchTimeout = null; this._config = this._getConfig(config); this._element = $(element)[0]; this._indicatorsElement = this._element.querySelector(Selector.INDICATORS); this._addEventListeners(); } // Getters static get VERSION() { return VERSION; } static get Default() { return Default; } // Public next() { if (!this._isSliding) { this._slide(Direction.NEXT); } } nextWhenVisible() { // Don't call next when the page isn't visible // or the carousel or its parent isn't visible if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') { this.next(); } } prev() { if (!this._isSliding) { this._slide(Direction.PREV); } } pause(event) { if (!event) { this._isPaused = true; } if (this._element.querySelector(Selector.NEXT_PREV)) { _util__WEBPACK_IMPORTED_MODULE_1__["default"].triggerTransitionEnd(this._element); this.cycle(true); } clearInterval(this._interval); this._interval = null; } cycle(event) { if (!event) { this._isPaused = false; } if (this._interval) { clearInterval(this._interval); this._interval = null; } if (this._config.interval && !this._isPaused) { this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval); } } to(index) { this._activeElement = this._element.querySelector(Selector.ACTIVE_ITEM); const activeIndex = this._getItemIndex(this._activeElement); if (index > this._items.length - 1 || index < 0) { return; } if (this._isSliding) { $(this._element).one(Event.SLID, () => this.to(index)); return; } if (activeIndex === index) { this.pause(); this.cycle(); return; } const direction = index > activeIndex ? Direction.NEXT : Direction.PREV; this._slide(direction, this._items[index]); } dispose() { $(this._element).off(EVENT_KEY); $.removeData(this._element, DATA_KEY); this._items = null; this._config = null; this._element = null; this._interval = null; this._isPaused = null; this._isSliding = null; this._activeElement = null; this._indicatorsElement = null; } // Private _getConfig(config) { config = _objectSpread({}, Default, config); _util__WEBPACK_IMPORTED_MODULE_1__["default"].typeCheckConfig(NAME, config, DefaultType); return config; } _addEventListeners() { if (this._config.keyboard) { $(this._element).on(Event.KEYDOWN, event => this._keydown(event)); } if (this._config.pause === 'hover') { $(this._element).on(Event.MOUSEENTER, event => this.pause(event)).on(Event.MOUSELEAVE, event => this.cycle(event)); if ('ontouchstart' in document.documentElement) { // If it's a touch-enabled device, mouseenter/leave are fired as // part of the mouse compatibility events on first tap - the carousel // would stop cycling until user tapped out of it; // here, we listen for touchend, explicitly pause the carousel // (as if it's the second time we tap on it, mouseenter compat event // is NOT fired) and after a timeout (to allow for mouse compatibility // events to fire) we explicitly restart cycling $(this._element).on(Event.TOUCHEND, () => { this.pause(); if (this.touchTimeout) { clearTimeout(this.touchTimeout); } this.touchTimeout = setTimeout(event => this.cycle(event), TOUCHEVENT_COMPAT_WAIT + this._config.interval); }); } } } _keydown(event) { if (/input|textarea/i.test(event.target.tagName)) { return; } switch (event.which) { case ARROW_LEFT_KEYCODE: event.preventDefault(); this.prev(); break; case ARROW_RIGHT_KEYCODE: event.preventDefault(); this.next(); break; default: } } _getItemIndex(element) { this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector.ITEM)) : []; return this._items.indexOf(element); } _getItemByDirection(direction, activeElement) { const isNextDirection = direction === Direction.NEXT; const isPrevDirection = direction === Direction.PREV; const activeIndex = this._getItemIndex(activeElement); const lastItemIndex = this._items.length - 1; const isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex; if (isGoingToWrap && !this._config.wrap) { return activeElement; } const delta = direction === Direction.PREV ? -1 : 1; const itemIndex = (activeIndex + delta) % this._items.length; return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex]; } _triggerSlideEvent(relatedTarget, eventDirectionName) { const targetIndex = this._getItemIndex(relatedTarget); const fromIndex = this._getItemIndex(this._element.querySelector(Selector.ACTIVE_ITEM)); const slideEvent = $.Event(Event.SLIDE, { relatedTarget, direction: eventDirectionName, from: fromIndex, to: targetIndex }); $(this._element).trigger(slideEvent); return slideEvent; } _setActiveIndicatorElement(element) { if (this._indicatorsElement) { const indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector.ACTIVE)); $(indicators).removeClass(ClassName.ACTIVE); const nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)]; if (nextIndicator) { $(nextIndicator).addClass(ClassName.ACTIVE); } } } _slide(direction, element) { const activeElement = this._element.querySelector(Selector.ACTIVE_ITEM); const activeElementIndex = this._getItemIndex(activeElement); const nextElement = element || activeElement && this._getItemByDirection(direction, activeElement); const nextElementIndex = this._getItemIndex(nextElement); const isCycling = Boolean(this._interval); let directionalClassName; let orderClassName; let eventDirectionName; if (direction === Direction.NEXT) { directionalClassName = ClassName.LEFT; orderClassName = ClassName.NEXT; eventDirectionName = Direction.LEFT; } else { directionalClassName = ClassName.RIGHT; orderClassName = ClassName.PREV; eventDirectionName = Direction.RIGHT; } if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) { this._isSliding = false; return; } const slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName); if (slideEvent.isDefaultPrevented()) { return; } if (!activeElement || !nextElement) { // Some weirdness is happening, so we bail return; } this._isSliding = true; if (isCycling) { this.pause(); } this._setActiveIndicatorElement(nextElement); const slidEvent = $.Event(Event.SLID, { relatedTarget: nextElement, direction: eventDirectionName, from: activeElementIndex, to: nextElementIndex }); if ($(this._element).hasClass(ClassName.SLIDE)) { $(nextElement).addClass(orderClassName); _util__WEBPACK_IMPORTED_MODULE_1__["default"].reflow(nextElement); $(activeElement).addClass(directionalClassName); $(nextElement).addClass(directionalClassName); const transitionDuration = _util__WEBPACK_IMPORTED_MODULE_1__["default"].getTransitionDurationFromElement(activeElement); $(activeElement).one(_util__WEBPACK_IMPORTED_MODULE_1__["default"].TRANSITION_END, () => { $(nextElement).removeClass(`${directionalClassName} ${orderClassName}`).addClass(ClassName.ACTIVE); $(activeElement).removeClass(`${ClassName.ACTIVE} ${orderClassName} ${directionalClassName}`); this._isSliding = false; setTimeout(() => $(this._element).trigger(slidEvent), 0); }).emulateTransitionEnd(transitionDuration); } else { $(activeElement).removeClass(ClassName.ACTIVE); $(nextElement).addClass(ClassName.ACTIVE); this._isSliding = false; $(this._element).trigger(slidEvent); } if (isCycling) { this.cycle(); } } // Static static _jQueryInterface(config) { return this.each(function () { let data = $(this).data(DATA_KEY); let _config = _objectSpread({}, Default, $(this).data()); if (typeof config === 'object') { _config = _objectSpread({}, _config, config); } const action = typeof config === 'string' ? config : _config.slide; if (!data) { data = new Carousel(this, _config); $(this).data(DATA_KEY, data); } if (typeof config === 'number') { data.to(config); } else if (typeof action === 'string') { if (typeof data[action] === 'undefined') { throw new TypeError(`No method named "${action}"`); } data[action](); } else if (_config.interval) { data.pause(); data.cycle(); } }); } static _dataApiClickHandler(event) { const selector = _util__WEBPACK_IMPORTED_MODULE_1__["default"].getSelectorFromElement(this); if (!selector) { return; } const target = $(selector)[0]; if (!target || !$(target).hasClass(ClassName.CAROUSEL)) { return; } const config = _objectSpread({}, $(target).data(), $(this).data()); const slideIndex = this.getAttribute('data-slide-to'); if (slideIndex) { config.interval = false; } Carousel._jQueryInterface.call($(target), config); if (slideIndex) { $(target).data(DATA_KEY).to(slideIndex); } event.preventDefault(); } } /** * ------------------------------------------------------------------------ * Data Api implementation * ------------------------------------------------------------------------ */ $(document).on(Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel._dataApiClickHandler); $(window).on(Event.LOAD_DATA_API, () => { const carousels = [].slice.call(document.querySelectorAll(Selector.DATA_RIDE)); for (let i = 0, len = carousels.length; i < len; i++) { const $carousel = $(carousels[i]); Carousel._jQueryInterface.call($carousel, $carousel.data()); } }); /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ */ $.fn[NAME] = Carousel._jQueryInterface; $.fn[NAME].Constructor = Carousel; $.fn[NAME].noConflict = function () { $.fn[NAME] = JQUERY_NO_CONFLICT; return Carousel._jQueryInterface; }; return Carousel; })(jquery__WEBPACK_IMPORTED_MODULE_0___default.a); /* harmony default export */ __webpack_exports__["default"] = (Carousel); /***/ }), /***/ "./node_modules/bootstrap/js/src/collapse.js": /*!***************************************************!*\ !*** ./node_modules/bootstrap/js/src/collapse.js ***! \***************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./cartridges/app_storefront_base/cartridge/client/default/js/thirdParty/bootstrap.js (referenced with cjs require) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util */ "./node_modules/bootstrap/js/src/util.js"); function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /** * -------------------------------------------------------------------------- * Bootstrap (v4.1.3): collapse.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ const Collapse = ($ => { /** * ------------------------------------------------------------------------ * Constants * ------------------------------------------------------------------------ */ const NAME = 'collapse'; const VERSION = '4.1.3'; const DATA_KEY = 'bs.collapse'; const EVENT_KEY = `.${DATA_KEY}`; const DATA_API_KEY = '.data-api'; const JQUERY_NO_CONFLICT = $.fn[NAME]; const Default = { toggle: true, parent: '' }; const DefaultType = { toggle: 'boolean', parent: '(string|element)' }; const Event = { SHOW: `show${EVENT_KEY}`, SHOWN: `shown${EVENT_KEY}`, HIDE: `hide${EVENT_KEY}`, HIDDEN: `hidden${EVENT_KEY}`, CLICK_DATA_API: `click${EVENT_KEY}${DATA_API_KEY}` }; const ClassName = { SHOW: 'show', COLLAPSE: 'collapse', COLLAPSING: 'collapsing', COLLAPSED: 'collapsed' }; const Dimension = { WIDTH: 'width', HEIGHT: 'height' }; const Selector = { ACTIVES: '.show, .collapsing', DATA_TOGGLE: '[data-toggle="collapse"]' /** * ------------------------------------------------------------------------ * Class Definition * ------------------------------------------------------------------------ */ }; class Collapse { constructor(element, config) { this._isTransitioning = false; this._element = element; this._config = this._getConfig(config); this._triggerArray = $.makeArray(document.querySelectorAll(`[data-toggle="collapse"][href="#${element.id}"],` + `[data-toggle="collapse"][data-target="#${element.id}"]`)); const toggleList = [].slice.call(document.querySelectorAll(Selector.DATA_TOGGLE)); for (let i = 0, len = toggleList.length; i < len; i++) { const elem = toggleList[i]; const selector = _util__WEBPACK_IMPORTED_MODULE_1__["default"].getSelectorFromElement(elem); const filterElement = [].slice.call(document.querySelectorAll(selector)).filter(foundElem => foundElem === element); if (selector !== null && filterElement.length > 0) { this._selector = selector; this._triggerArray.push(elem); } } this._parent = this._config.parent ? this._getParent() : null; if (!this._config.parent) { this._addAriaAndCollapsedClass(this._element, this._triggerArray); } if (this._config.toggle) { this.toggle(); } } // Getters static get VERSION() { return VERSION; } static get Default() { return Default; } // Public toggle() { if ($(this._element).hasClass(ClassName.SHOW)) { this.hide(); } else { this.show(); } } show() { if (this._isTransitioning || $(this._element).hasClass(ClassName.SHOW)) { return; } let actives; let activesData; if (this._parent) { actives = [].slice.call(this._parent.querySelectorAll(Selector.ACTIVES)).filter(elem => elem.getAttribute('data-parent') === this._config.parent); if (actives.length === 0) { actives = null; } } if (actives) { activesData = $(actives).not(this._selector).data(DATA_KEY); if (activesData && activesData._isTransitioning) { return; } } const startEvent = $.Event(Event.SHOW); $(this._element).trigger(startEvent); if (startEvent.isDefaultPrevented()) { return; } if (actives) { Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide'); if (!activesData) { $(actives).data(DATA_KEY, null); } } const dimension = this._getDimension(); $(this._element).removeClass(ClassName.COLLAPSE).addClass(ClassName.COLLAPSING); this._element.style[dimension] = 0; if (this._triggerArray.length) { $(this._triggerArray).removeClass(ClassName.COLLAPSED).attr('aria-expanded', true); } this.setTransitioning(true); const complete = () => { $(this._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).addClass(ClassName.SHOW); this._element.style[dimension] = ''; this.setTransitioning(false); $(this._element).trigger(Event.SHOWN); }; const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1); const scrollSize = `scroll${capitalizedDimension}`; const transitionDuration = _util__WEBPACK_IMPORTED_MODULE_1__["default"].getTransitionDurationFromElement(this._element); $(this._element).one(_util__WEBPACK_IMPORTED_MODULE_1__["default"].TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); this._element.style[dimension] = `${this._element[scrollSize]}px`; } hide() { if (this._isTransitioning || !$(this._element).hasClass(ClassName.SHOW)) { return; } const startEvent = $.Event(Event.HIDE); $(this._element).trigger(startEvent); if (startEvent.isDefaultPrevented()) { return; } const dimension = this._getDimension(); this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`; _util__WEBPACK_IMPORTED_MODULE_1__["default"].reflow(this._element); $(this._element).addClass(ClassName.COLLAPSING).removeClass(ClassName.COLLAPSE).removeClass(ClassName.SHOW); const triggerArrayLength = this._triggerArray.length; if (triggerArrayLength > 0) { for (let i = 0; i < triggerArrayLength; i++) { const trigger = this._triggerArray[i]; const selector = _util__WEBPACK_IMPORTED_MODULE_1__["default"].getSelectorFromElement(trigger); if (selector !== null) { const $elem = $([].slice.call(document.querySelectorAll(selector))); if (!$elem.hasClass(ClassName.SHOW)) { $(trigger).addClass(ClassName.COLLAPSED).attr('aria-expanded', false); } } } } this.setTransitioning(true); const complete = () => { this.setTransitioning(false); $(this._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).trigger(Event.HIDDEN); }; this._element.style[dimension] = ''; const transitionDuration = _util__WEBPACK_IMPORTED_MODULE_1__["default"].getTransitionDurationFromElement(this._element); $(this._element).one(_util__WEBPACK_IMPORTED_MODULE_1__["default"].TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); } setTransitioning(isTransitioning) { this._isTransitioning = isTransitioning; } dispose() { $.removeData(this._element, DATA_KEY); this._config = null; this._parent = null; this._element = null; this._triggerArray = null; this._isTransitioning = null; } // Private _getConfig(config) { config = _objectSpread({}, Default, config); config.toggle = Boolean(config.toggle); // Coerce string values _util__WEBPACK_IMPORTED_MODULE_1__["default"].typeCheckConfig(NAME, config, DefaultType); return config; } _getDimension() { const hasWidth = $(this._element).hasClass(Dimension.WIDTH); return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT; } _getParent() { let parent = null; if (_util__WEBPACK_IMPORTED_MODULE_1__["default"].isElement(this._config.parent)) { parent = this._config.parent; // It's a jQuery object if (typeof this._config.parent.jquery !== 'undefined') { parent = this._config.parent[0]; } } else { parent = document.querySelector(this._config.parent); } const selector = `[data-toggle="collapse"][data-parent="${this._config.parent}"]`; const children = [].slice.call(parent.querySelectorAll(selector)); $(children).each((i, element) => { this._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]); }); return parent; } _addAriaAndCollapsedClass(element, triggerArray) { if (element) { const isOpen = $(element).hasClass(ClassName.SHOW); if (triggerArray.length) { $(triggerArray).toggleClass(ClassName.COLLAPSED, !isOpen).attr('aria-expanded', isOpen); } } } // Static static _getTargetFromElement(element) { const selector = _util__WEBPACK_IMPORTED_MODULE_1__["default"].getSelectorFromElement(element); return selector ? document.querySelector(selector) : null; } static _jQueryInterface(config) { return this.each(function () { const $this = $(this); let data = $this.data(DATA_KEY); const _config = _objectSpread({}, Default, $this.data(), typeof config === 'object' && config ? config : {}); if (!data && _config.toggle && /show|hide/.test(config)) { _config.toggle = false; } if (!data) { data = new Collapse(this, _config); $this.data(DATA_KEY, data); } if (typeof config === 'string') { if (typeof data[config] === 'undefined') { throw new TypeError(`No method named "${config}"`); } data[config](); } }); } } /** * ------------------------------------------------------------------------ * Data Api implementation * ------------------------------------------------------------------------ */ $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { // preventDefault only for elements (which change the URL) not inside the collapsible element if (event.currentTarget.tagName === 'A') { event.preventDefault(); } const $trigger = $(this); const selector = _util__WEBPACK_IMPORTED_MODULE_1__["default"].getSelectorFromElement(this); const selectors = [].slice.call(document.querySelectorAll(selector)); $(selectors).each(function () { const $target = $(this); const data = $target.data(DATA_KEY); const config = data ? 'toggle' : $trigger.data(); Collapse._jQueryInterface.call($target, config); }); }); /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ */ $.fn[NAME] = Collapse._jQueryInterface; $.fn[NAME].Constructor = Collapse; $.fn[NAME].noConflict = function () { $.fn[NAME] = JQUERY_NO_CONFLICT; return Collapse._jQueryInterface; }; return Collapse; })(jquery__WEBPACK_IMPORTED_MODULE_0___default.a); /* harmony default export */ __webpack_exports__["default"] = (Collapse); /***/ }), /***/ "./node_modules/bootstrap/js/src/modal.js": /*!************************************************!*\ !*** ./node_modules/bootstrap/js/src/modal.js ***! \************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./cartridges/app_storefront_base/cartridge/client/default/js/thirdParty/bootstrap.js (referenced with cjs require) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util */ "./node_modules/bootstrap/js/src/util.js"); function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /** * -------------------------------------------------------------------------- * Bootstrap (v4.1.3): modal.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ const Modal = ($ => { /** * ------------------------------------------------------------------------ * Constants * ------------------------------------------------------------------------ */ const NAME = 'modal'; const VERSION = '4.1.3'; const DATA_KEY = 'bs.modal'; const EVENT_KEY = `.${DATA_KEY}`; const DATA_API_KEY = '.data-api'; const JQUERY_NO_CONFLICT = $.fn[NAME]; const ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key const Default = { backdrop: true, keyboard: true, focus: true, show: true }; const DefaultType = { backdrop: '(boolean|string)', keyboard: 'boolean', focus: 'boolean', show: 'boolean' }; const Event = { HIDE: `hide${EVENT_KEY}`, HIDDEN: `hidden${EVENT_KEY}`, SHOW: `show${EVENT_KEY}`, SHOWN: `shown${EVENT_KEY}`, FOCUSIN: `focusin${EVENT_KEY}`, RESIZE: `resize${EVENT_KEY}`, CLICK_DISMISS: `click.dismiss${EVENT_KEY}`, KEYDOWN_DISMISS: `keydown.dismiss${EVENT_KEY}`, MOUSEUP_DISMISS: `mouseup.dismiss${EVENT_KEY}`, MOUSEDOWN_DISMISS: `mousedown.dismiss${EVENT_KEY}`, CLICK_DATA_API: `click${EVENT_KEY}${DATA_API_KEY}` }; const ClassName = { SCROLLBAR_MEASURER: 'modal-scrollbar-measure', BACKDROP: 'modal-backdrop', OPEN: 'modal-open', FADE: 'fade', SHOW: 'show' }; const Selector = { DIALOG: '.modal-dialog', DATA_TOGGLE: '[data-toggle="modal"]', DATA_DISMISS: '[data-dismiss="modal"]', FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top', STICKY_CONTENT: '.sticky-top' /** * ------------------------------------------------------------------------ * Class Definition * ------------------------------------------------------------------------ */ }; class Modal { constructor(element, config) { this._config = this._getConfig(config); this._element = element; this._dialog = element.querySelector(Selector.DIALOG); this._backdrop = null; this._isShown = false; this._isBodyOverflowing = false; this._ignoreBackdropClick = false; this._scrollbarWidth = 0; } // Getters static get VERSION() { return VERSION; } static get Default() { return Default; } // Public toggle(relatedTarget) { return this._isShown ? this.hide() : this.show(relatedTarget); } show(relatedTarget) { if (this._isTransitioning || this._isShown) { return; } if ($(this._element).hasClass(ClassName.FADE)) { this._isTransitioning = true; } const showEvent = $.Event(Event.SHOW, { relatedTarget }); $(this._element).trigger(showEvent); if (this._isShown || showEvent.isDefaultPrevented()) { return; } this._isShown = true; this._checkScrollbar(); this._setScrollbar(); this._adjustDialog(); $(document.body).addClass(ClassName.OPEN); this._setEscapeEvent(); this._setResizeEvent(); $(this._element).on(Event.CLICK_DISMISS, Selector.DATA_DISMISS, event => this.hide(event)); $(this._dialog).on(Event.MOUSEDOWN_DISMISS, () => { $(this._element).one(Event.MOUSEUP_DISMISS, event => { if ($(event.target).is(this._element)) { this._ignoreBackdropClick = true; } }); }); this._showBackdrop(() => this._showElement(relatedTarget)); } hide(event) { if (event) { event.preventDefault(); } if (this._isTransitioning || !this._isShown) { return; } const hideEvent = $.Event(Event.HIDE); $(this._element).trigger(hideEvent); if (!this._isShown || hideEvent.isDefaultPrevented()) { return; } this._isShown = false; const transition = $(this._element).hasClass(ClassName.FADE); if (transition) { this._isTransitioning = true; } this._setEscapeEvent(); this._setResizeEvent(); $(document).off(Event.FOCUSIN); $(this._element).removeClass(ClassName.SHOW); $(this._element).off(Event.CLICK_DISMISS); $(this._dialog).off(Event.MOUSEDOWN_DISMISS); if (transition) { const transitionDuration = _util__WEBPACK_IMPORTED_MODULE_1__["default"].getTransitionDurationFromElement(this._element); $(this._element).one(_util__WEBPACK_IMPORTED_MODULE_1__["default"].TRANSITION_END, event => this._hideModal(event)).emulateTransitionEnd(transitionDuration); } else { this._hideModal(); } } dispose() { $.removeData(this._element, DATA_KEY); $(window, document, this._element, this._backdrop).off(EVENT_KEY); this._config = null; this._element = null; this._dialog = null; this._backdrop = null; this._isShown = null; this._isBodyOverflowing = null; this._ignoreBackdropClick = null; this._scrollbarWidth = null; } handleUpdate() { this._adjustDialog(); } // Private _getConfig(config) { config = _objectSpread({}, Default, config); _util__WEBPACK_IMPORTED_MODULE_1__["default"].typeCheckConfig(NAME, config, DefaultType); return config; } _showElement(relatedTarget) { const transition = $(this._element).hasClass(ClassName.FADE); if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { // Don't move modal's DOM position document.body.appendChild(this._element); } this._element.style.display = 'block'; this._element.removeAttribute('aria-hidden'); this._element.scrollTop = 0; if (transition) { _util__WEBPACK_IMPORTED_MODULE_1__["default"].reflow(this._element); } $(this._element).addClass(ClassName.SHOW); if (this._config.focus) { this._enforceFocus(); } const shownEvent = $.Event(Event.SHOWN, { relatedTarget }); const transitionComplete = () => { if (this._config.focus) { this._element.focus(); } this._isTransitioning = false; $(this._element).trigger(shownEvent); }; if (transition) { const transitionDuration = _util__WEBPACK_IMPORTED_MODULE_1__["default"].getTransitionDurationFromElement(this._element); $(this._dialog).one(_util__WEBPACK_IMPORTED_MODULE_1__["default"].TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration); } else { transitionComplete(); } } _enforceFocus() { $(document).off(Event.FOCUSIN) // Guard against infinite focus loop .on(Event.FOCUSIN, event => { if (document !== event.target && this._element !== event.target && $(this._element).has(event.target).length === 0) { this._element.focus(); } }); } _setEscapeEvent() { if (this._isShown && this._config.keyboard) { $(this._element).on(Event.KEYDOWN_DISMISS, event => { if (event.which === ESCAPE_KEYCODE) { event.preventDefault(); this.hide(); } }); } else if (!this._isShown) { $(this._element).off(Event.KEYDOWN_DISMISS); } } _setResizeEvent() { if (this._isShown) { $(window).on(Event.RESIZE, event => this.handleUpdate(event)); } else { $(window).off(Event.RESIZE); } } _hideModal() { this._element.style.display = 'none'; this._element.setAttribute('aria-hidden', true); this._isTransitioning = false; this._showBackdrop(() => { $(document.body).removeClass(ClassName.OPEN); this._resetAdjustments(); this._resetScrollbar(); $(this._element).trigger(Event.HIDDEN); }); } _removeBackdrop() { if (this._backdrop) { $(this._backdrop).remove(); this._backdrop = null; } } _showBackdrop(callback) { const animate = $(this._element).hasClass(ClassName.FADE) ? ClassName.FADE : ''; if (this._isShown && this._config.backdrop) { this._backdrop = document.createElement('div'); this._backdrop.className = ClassName.BACKDROP; if (animate) { this._backdrop.classList.add(animate); } $(this._backdrop).appendTo(document.body); $(this._element).on(Event.CLICK_DISMISS, event => { if (this._ignoreBackdropClick) { this._ignoreBackdropClick = false; return; } if (event.target !== event.currentTarget) { return; } if (this._config.backdrop === 'static') { this._element.focus(); } else { this.hide(); } }); if (animate) { _util__WEBPACK_IMPORTED_MODULE_1__["default"].reflow(this._backdrop); } $(this._backdrop).addClass(ClassName.SHOW); if (!callback) { return; } if (!animate) { callback(); return; } const backdropTransitionDuration = _util__WEBPACK_IMPORTED_MODULE_1__["default"].getTransitionDurationFromElement(this._backdrop); $(this._backdrop).one(_util__WEBPACK_IMPORTED_MODULE_1__["default"].TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration); } else if (!this._isShown && this._backdrop) { $(this._backdrop).removeClass(ClassName.SHOW); const callbackRemove = () => { this._removeBackdrop(); if (callback) { callback(); } }; if ($(this._element).hasClass(ClassName.FADE)) { const backdropTransitionDuration = _util__WEBPACK_IMPORTED_MODULE_1__["default"].getTransitionDurationFromElement(this._backdrop); $(this._backdrop).one(_util__WEBPACK_IMPORTED_MODULE_1__["default"].TRANSITION_END, callbackRemove).emulateTransitionEnd(backdropTransitionDuration); } else { callbackRemove(); } } else if (callback) { callback(); } } // ---------------------------------------------------------------------- // the following methods are used to handle overflowing modals // todo (fat): these should probably be refactored out of modal.js // ---------------------------------------------------------------------- _adjustDialog() { const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight; if (!this._isBodyOverflowing && isModalOverflowing) { this._element.style.paddingLeft = `${this._scrollbarWidth}px`; } if (this._isBodyOverflowing && !isModalOverflowing) { this._element.style.paddingRight = `${this._scrollbarWidth}px`; } } _resetAdjustments() { this._element.style.paddingLeft = ''; this._element.style.paddingRight = ''; } _checkScrollbar() { const rect = document.body.getBoundingClientRect(); this._isBodyOverflowing = rect.left + rect.right < window.innerWidth; this._scrollbarWidth = this._getScrollbarWidth(); } _setScrollbar() { if (this._isBodyOverflowing) { // Note: DOMNode.style.paddingRight returns the actual value or '' if not set // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set const fixedContent = [].slice.call(document.querySelectorAll(Selector.FIXED_CONTENT)); const stickyContent = [].slice.call(document.querySelectorAll(Selector.STICKY_CONTENT)); // Adjust fixed content padding $(fixedContent).each((index, element) => { const actualPadding = element.style.paddingRight; const calculatedPadding = $(element).css('padding-right'); $(element).data('padding-right', actualPadding).css('padding-right', `${parseFloat(calculatedPadding) + this._scrollbarWidth}px`); }); // Adjust sticky content margin $(stickyContent).each((index, element) => { const actualMargin = element.style.marginRight; const calculatedMargin = $(element).css('margin-right'); $(element).data('margin-right', actualMargin).css('margin-right', `${parseFloat(calculatedMargin) - this._scrollbarWidth}px`); }); // Adjust body padding const actualPadding = document.body.style.paddingRight; const calculatedPadding = $(document.body).css('padding-right'); $(document.body).data('padding-right', actualPadding).css('padding-right', `${parseFloat(calculatedPadding) + this._scrollbarWidth}px`); } } _resetScrollbar() { // Restore fixed content padding const fixedContent = [].slice.call(document.querySelectorAll(Selector.FIXED_CONTENT)); $(fixedContent).each((index, element) => { const padding = $(element).data('padding-right'); $(element).removeData('padding-right'); element.style.paddingRight = padding ? padding : ''; }); // Restore sticky content const elements = [].slice.call(document.querySelectorAll(`${Selector.STICKY_CONTENT}`)); $(elements).each((index, element) => { const margin = $(element).data('margin-right'); if (typeof margin !== 'undefined') { $(element).css('margin-right', margin).removeData('margin-right'); } }); // Restore body padding const padding = $(document.body).data('padding-right'); $(document.body).removeData('padding-right'); document.body.style.paddingRight = padding ? padding : ''; } _getScrollbarWidth() { // thx d.walsh const scrollDiv = document.createElement('div'); scrollDiv.className = ClassName.SCROLLBAR_MEASURER; document.body.appendChild(scrollDiv); const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth; document.body.removeChild(scrollDiv); return scrollbarWidth; } // Static static _jQueryInterface(config, relatedTarget) { return this.each(function () { let data = $(this).data(DATA_KEY); const _config = _objectSpread({}, Default, $(this).data(), typeof config === 'object' && config ? config : {}); if (!data) { data = new Modal(this, _config); $(this).data(DATA_KEY, data); } if (typeof config === 'string') { if (typeof data[config] === 'undefined') { throw new TypeError(`No method named "${config}"`); } data[config](relatedTarget); } else if (_config.show) { data.show(relatedTarget); } }); } } /** * ------------------------------------------------------------------------ * Data Api implementation * ------------------------------------------------------------------------ */ $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { let target; const selector = _util__WEBPACK_IMPORTED_MODULE_1__["default"].getSelectorFromElement(this); if (selector) { target = document.querySelector(selector); } const config = $(target).data(DATA_KEY) ? 'toggle' : _objectSpread({}, $(target).data(), $(this).data()); if (this.tagName === 'A' || this.tagName === 'AREA') { event.preventDefault(); } const $target = $(target).one(Event.SHOW, showEvent => { if (showEvent.isDefaultPrevented()) { // Only register focus restorer if modal will actually get shown return; } $target.one(Event.HIDDEN, () => { if ($(this).is(':visible')) { this.focus(); } }); }); Modal._jQueryInterface.call($(target), config, this); }); /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ */ $.fn[NAME] = Modal._jQueryInterface; $.fn[NAME].Constructor = Modal; $.fn[NAME].noConflict = function () { $.fn[NAME] = JQUERY_NO_CONFLICT; return Modal._jQueryInterface; }; return Modal; })(jquery__WEBPACK_IMPORTED_MODULE_0___default.a); /* harmony default export */ __webpack_exports__["default"] = (Modal); /***/ }), /***/ "./node_modules/bootstrap/js/src/scrollspy.js": /*!****************************************************!*\ !*** ./node_modules/bootstrap/js/src/scrollspy.js ***! \****************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./cartridges/app_storefront_base/cartridge/client/default/js/thirdParty/bootstrap.js (referenced with cjs require) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util */ "./node_modules/bootstrap/js/src/util.js"); function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /** * -------------------------------------------------------------------------- * Bootstrap (v4.1.3): scrollspy.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ const ScrollSpy = ($ => { /** * ------------------------------------------------------------------------ * Constants * ------------------------------------------------------------------------ */ const NAME = 'scrollspy'; const VERSION = '4.1.3'; const DATA_KEY = 'bs.scrollspy'; const EVENT_KEY = `.${DATA_KEY}`; const DATA_API_KEY = '.data-api'; const JQUERY_NO_CONFLICT = $.fn[NAME]; const Default = { offset: 10, method: 'auto', target: '' }; const DefaultType = { offset: 'number', method: 'string', target: '(string|element)' }; const Event = { ACTIVATE: `activate${EVENT_KEY}`, SCROLL: `scroll${EVENT_KEY}`, LOAD_DATA_API: `load${EVENT_KEY}${DATA_API_KEY}` }; const ClassName = { DROPDOWN_ITEM: 'dropdown-item', DROPDOWN_MENU: 'dropdown-menu', ACTIVE: 'active' }; const Selector = { DATA_SPY: '[data-spy="scroll"]', ACTIVE: '.active', NAV_LIST_GROUP: '.nav, .list-group', NAV_LINKS: '.nav-link', NAV_ITEMS: '.nav-item', LIST_ITEMS: '.list-group-item', DROPDOWN: '.dropdown', DROPDOWN_ITEMS: '.dropdown-item', DROPDOWN_TOGGLE: '.dropdown-toggle' }; const OffsetMethod = { OFFSET: 'offset', POSITION: 'position' /** * ------------------------------------------------------------------------ * Class Definition * ------------------------------------------------------------------------ */ }; class ScrollSpy { constructor(element, config) { this._element = element; this._scrollElement = element.tagName === 'BODY' ? window : element; this._config = this._getConfig(config); this._selector = `${this._config.target} ${Selector.NAV_LINKS},` + `${this._config.target} ${Selector.LIST_ITEMS},` + `${this._config.target} ${Selector.DROPDOWN_ITEMS}`; this._offsets = []; this._targets = []; this._activeTarget = null; this._scrollHeight = 0; $(this._scrollElement).on(Event.SCROLL, event => this._process(event)); this.refresh(); this._process(); } // Getters static get VERSION() { return VERSION; } static get Default() { return Default; } // Public refresh() { const autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION; const offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method; const offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0; this._offsets = []; this._targets = []; this._scrollHeight = this._getScrollHeight(); const targets = [].slice.call(document.querySelectorAll(this._selector)); targets.map(element => { let target; const targetSelector = _util__WEBPACK_IMPORTED_MODULE_1__["default"].getSelectorFromElement(element); if (targetSelector) { target = document.querySelector(targetSelector); } if (target) { const targetBCR = target.getBoundingClientRect(); if (targetBCR.width || targetBCR.height) { // TODO (fat): remove sketch reliance on jQuery position/offset return [$(target)[offsetMethod]().top + offsetBase, targetSelector]; } } return null; }).filter(item => item).sort((a, b) => a[0] - b[0]).forEach(item => { this._offsets.push(item[0]); this._targets.push(item[1]); }); } dispose() { $.removeData(this._element, DATA_KEY); $(this._scrollElement).off(EVENT_KEY); this._element = null; this._scrollElement = null; this._config = null; this._selector = null; this._offsets = null; this._targets = null; this._activeTarget = null; this._scrollHeight = null; } // Private _getConfig(config) { config = _objectSpread({}, Default, typeof config === 'object' && config ? config : {}); if (typeof config.target !== 'string') { let id = $(config.target).attr('id'); if (!id) { id = _util__WEBPACK_IMPORTED_MODULE_1__["default"].getUID(NAME); $(config.target).attr('id', id); } config.target = `#${id}`; } _util__WEBPACK_IMPORTED_MODULE_1__["default"].typeCheckConfig(NAME, config, DefaultType); return config; } _getScrollTop() { return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop; } _getScrollHeight() { return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); } _getOffsetHeight() { return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height; } _process() { const scrollTop = this._getScrollTop() + this._config.offset; const scrollHeight = this._getScrollHeight(); const maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight(); if (this._scrollHeight !== scrollHeight) { this.refresh(); } if (scrollTop >= maxScroll) { const target = this._targets[this._targets.length - 1]; if (this._activeTarget !== target) { this._activate(target); } return; } if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) { this._activeTarget = null; this._clear(); return; } const offsetLength = this._offsets.length; for (let i = offsetLength; i--;) { const isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]); if (isActiveTarget) { this._activate(this._targets[i]); } } } _activate(target) { this._activeTarget = target; this._clear(); let queries = this._selector.split(','); // eslint-disable-next-line arrow-body-style queries = queries.map(selector => { return `${selector}[data-target="${target}"],` + `${selector}[href="${target}"]`; }); const $link = $([].slice.call(document.querySelectorAll(queries.join(',')))); if ($link.hasClass(ClassName.DROPDOWN_ITEM)) { $link.closest(Selector.DROPDOWN).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE); $link.addClass(ClassName.ACTIVE); } else { // Set triggered link as active $link.addClass(ClassName.ACTIVE); // Set triggered links parents as active // With both
        and
\n ')},containerInner:function(e){return O('\n
\n ')},itemList:function(e,t){var i,n=ye()(e.list,((i={})[e.listSingle]=t,i[e.listItems]=!t,i));return O('\n
\n ')},placeholder:function(e,t){return O('\n
\n '+t+"\n
\n ")},item:function(e,t,i){var n,s,r=t.active?'aria-selected="true"':"",o=t.disabled?'aria-disabled="true"':"",a=ye()(e.item,((n={})[e.highlightedState]=t.highlighted,n[e.itemSelectable]=!t.highlighted,n[e.placeholder]=t.placeholder,n));return i?(a=ye()(e.item,((s={})[e.highlightedState]=t.highlighted,s[e.itemSelectable]=!t.disabled,s[e.placeholder]=t.placeholder,s)),O('\n \n "+t.label+'\x3c!--\n --\x3e\n Remove item\n \n
\n ")):O('\n \n "+t.label+"\n
\n ")},choiceList:function(e,t){var i=t?"":'aria-multiselectable="true"';return O('\n \n
\n ")},choiceGroup:function(e,t){var i,n=t.disabled?'aria-disabled="true"':"",s=ye()(e.group,((i={})[e.itemDisabled]=t.disabled,i));return O('\n \n
'+t.value+"
\n
\n ")},choice:function(e,t,i){var n,s=t.groupId>0?'role="treeitem"':'role="option"',r=ye()(e.item,e.itemChoice,((n={})[e.itemDisabled]=t.disabled,n[e.itemSelectable]=!t.disabled,n[e.placeholder]=t.placeholder,n));return O('\n \n "+t.label+"\n
\n ")},input:function(e,t){var i=ye()(e.input,e.inputCloned);return O('\n \n ')},dropdown:function(e){var t=ye()(e.list,e.listDropdown);return O('\n