{"version":3,"file":"default/js/subscribeModal.js","sources":["webpack:///webpack/bootstrap","webpack:///./cartridges/org_arlo/cartridge/client/default/js/components/EmailInputModal.js","webpack:///./cartridges/org_arlo/cartridge/client/default/js/components/Modal.js","webpack:///./cartridges/org_arlo/cartridge/client/default/js/subscribeModal.js"],"sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./cartridges/org_arlo/cartridge/client/default/js/subscribeModal.js\");\n","/**\n * Component: EmailInputModal\n */\nimport Modal from './Modal';\n\nexport default class EmailInputModal {\n constructor(id) {\n this.$self = jQuery('#' + id);\n this.modalId = this.$self.data('modal-id');\n this.enableAjax = this.$self.data('modal-ajax');\n this.$initialView = this.$self.find('.view--initial');\n this.$secondaryView = this.$self.find('.view--secondary');\n this.$modalTitle = this.$self.find('.modal__title');\n this.$emailInput = this.$self.find('input[type=\"email\"]');\n this.$placeholder = this.$self.find('span[data-placeholder]');\n this.$form = this.$self.find('form');\n this.$submitBtn = this.$self.find('button[type=\"submit\"]');\n\n // Setting this here because the Modal heading is part of the Modal component\n // and not included in the markup of this EmailInputModal instance.\n this.tyMessage = 'Thanks for connecting.';\n\n this.setInputHandlers = this.setInputHandlers.bind(this);\n this.setSubmitHandlers = this.setSubmitHandlers.bind(this);\n this.setSecondaryView = this.setSecondaryView.bind(this);\n\n if (this.$self) {\n this.init();\n }\n }\n\n init() {\n var config = {\n showCloseButton: true,\n cookieOnSubmit: true\n };\n\n this.setInputHandlers();\n\n if (this.enableAjax === true) {\n this.setSubmitHandlers();\n }\n\n this.modal = new Modal(this.modalId, config); // eslint-disable-line no-new\n }\n\n setInputHandlers() {\n if (this.$emailInput && this.$submitBtn) {\n this.$emailInput.on('input', () => {\n this.updateInputPlaceholder(this.$emailInput.val());\n\n if (this.verifyEmailFormat(this.$emailInput.val())) {\n this.$submitBtn.prop('disabled', false);\n } else {\n this.$submitBtn.prop('disabled', true);\n }\n });\n }\n }\n\n setSubmitHandlers() {\n if (this.$form) {\n this.$form.on('submit', () => {\n // This will need to be set up conditionally for working with the promo-overlay and the notify on the pdp.\n // The logic below was set to work with promo overlay.\n // e.preventDefault();\n // DEV NOTE: To be called upon success call to form endpoint.\n /* $.ajax({\n url: $(this).closest('form').attr('action'),\n type: $(this).closest('form').attr('method'),\n data: $(this).closest('form').serialize(),\n dataType: 'json',\n success: function (data) {\n // success here\n },\n error: function (err) {\n // error here\n }\n }); */\n // this.setSecondaryView();\n });\n }\n }\n\n verifyEmailFormat(email) {\n var regex = /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n\n return regex.test(String(email).toLowerCase());\n }\n\n updateInputPlaceholder(hasInput) {\n if (hasInput) {\n this.$placeholder.hide();\n } else {\n this.$placeholder.show();\n }\n }\n\n setSecondaryView() {\n // Update if initial and secondary view exist in markup.\n if (this.$initialView.length && this.$secondaryView.length) {\n // Hide initial view\n this.$initialView.hide();\n // Show success\n this.$secondaryView.show();\n\n // Update modal title\n this.$modalTitle.text(this.tyMessage);\n }\n }\n}\n","/**\n * Component: Modal\n */\n\nexport default class Modal {\n constructor(id, config) {\n this.ns = 'modal';\n this.$self = jQuery('#' + id + '.' + this.ns);\n this.options = this.$self.data('options');\n this.$overlay = this.$self.find('.' + this.ns + '__overlay');\n this.$closeBtn = this.$self.find('.' + this.ns + '__close');\n\n this.closeElements = [];\n this.closeElements.push(this.$overlay); // Close the modal if overlay is clicked\n this.closeElements.push(this.$closeBtn);\n\n this.openModal = this.openModal.bind(this);\n this.closeModal = this.closeModal.bind(this);\n\n if (this.options) {\n // Bind click event to trigger modal selector\n this.$modalOpenElement = jQuery(this.options.triggerModalOpenSelector);\n // Set autoOpen if exists in options object\n this.autoOpen = this.options.autoOpen;\n this.autoOpenFlag = this.options.autoOpenFlag;\n }\n\n if (this.$self) {\n this.init(config);\n }\n }\n\n init(config) {\n this.setOpenHandlers();\n this.setCloseHandlers();\n this.setCloseButtonState(this.$closeBtn, config);\n this.setOptionalCallbacks(config);\n\n if (this.autoOpen && this.autoOpenFlag) {\n this.openOnInit();\n }\n\n $('body').on('click', '#headache-subscribe', function (e) {\n e.preventDefault();\n this.openModal();\n });\n }\n\n openOnInit() {\n // If localStorage key has NOT been set yet, open modal.\n if (!window.localStorage.getItem(this.autoOpenFlag)) {\n this.openModal();\n }\n }\n\n setOpenHandlers() {\n if (this.$modalOpenElement) {\n this.$modalOpenElement.on('click', () => {\n this.openModal();\n });\n }\n }\n\n openModal() {\n $('body').addClass('no-scroll');\n this.$self.addClass(this.ns + '--opened');\n\n if (this.openCallback) {\n this.openCallback();\n }\n }\n\n setCloseHandlers() {\n for (var i = 0; i < this.closeElements.length; i++) {\n var el = this.closeElements[i];\n if (el) {\n $(el).on('click', () => {\n this.closeModal();\n });\n }\n }\n\n $(document).on('keydown', (e) => {\n var key = e.key || e.keyCode;\n if (\n key === 'Escape'\n || key === 'Esc'\n || key === 27\n ) {\n this.closeModal();\n }\n });\n }\n\n closeModal() {\n $('body').removeClass('no-scroll');\n this.$self.removeClass(this.ns + '--opened');\n\n if (this.closeCallback) {\n this.closeCallback();\n }\n\n if (this.autoOpen && this.autoOpenFlag) {\n window.localStorage.setItem(this.autoOpenFlag, true);\n }\n }\n\n setCloseButtonState($closeBtn, config) {\n if (config) {\n this.showCloseButton = config.showCloseButton;\n\n if (this.showCloseButton === true) {\n $closeBtn.show();\n } else {\n $closeBtn.hide();\n }\n }\n }\n\n setOptionalCallbacks(config) {\n if (config) {\n var openCb = config.openCallback;\n var closeCb = config.closeCallback;\n if (typeof openCb === 'function') {\n this.openCallback = openCb;\n }\n\n if (typeof closeCb === 'function') {\n this.closeCallback = closeCb;\n }\n }\n }\n}\n","/**\n * Arlo SFCC Static\n * Newsletter Modal init file\n*/\nimport EmailInputModal from './components/EmailInputModal';\n\n/**\n * Define the scroll event handler function\n */\nfunction scrollHandler() {\n var scrollPosition = window.scrollY;\n var scrollCoordinates = window.promoOverlayPosition;\n if (scrollPosition >= scrollCoordinates) {\n // Trigger the email signup pop-up here\n new EmailInputModal('promo-overlay'); // eslint-disable-line no-new\n // Remove the scroll event listener after the modal is triggered\n window.removeEventListener('scroll', scrollHandler);\n }\n}\n\n// Attach the scroll event listener\nwindow.addEventListener('scroll', scrollHandler);\n\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;AClFA;AACA;AACA;AACA;AAAA;AAGA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AAAA;AAAA;AAAA;AAGA;AAEA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;;;;;;;;;;;;;;;;;;;;;AC7GA;AACA;AACA;AAFA;AAKA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAKA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;;;;;;;;;;;;;ACnIA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;A","sourceRoot":""}