{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./cartridges/app_livingproof_sfra/cartridge/client/default/js/search.js","webpack:///./cartridges/app_livingproof_sfra/cartridge/client/default/js/search/search.js","webpack:///./sfra/cartridges/app_storefront_base/cartridge/client/default/js/util.js","webpack:///./vendor/app_storefront_core/cartridge/client/default/js/product/compare.js","webpack:///./vendor/app_storefront_core/cartridge/client/default/js/product/wishlistHeart.js"],"names":[],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;AClFa;;AAEb,qBAAqB,mBAAO,CAAC,4FAAW;;AAExC;AACA,mBAAmB,mBAAO,CAAC,uGAAiB;AAC5C,mBAAmB,mBAAO,CAAC,qHAA4B;AACvD,mBAAmB,mBAAO,CAAC,yGAAsB;AACjD,CAAC;;;;;;;;;;;;;ACRY;;AAEb;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uBAAuB,oCAAoC;AAC3D;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA,aAAa;AACb,SAAS;;AAET;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,uBAAuB,0BAA0B;AACjD;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,uBAAuB,2BAA2B;AAClD;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA,iBAAiB;AACjB,aAAa;AACb,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;;;;;;;;;;;;ACxPa;;AAEb;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;;;;;;;;;;;;ACZa;;AAEb;AACA;AACA;AACA;;AAEA;;;AAGA;AACA;AACA;AACA,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB;;AAEA;AACA;AACA;AACA,WAAW,sBAAsB;AACjC,WAAW,OAAO;AAClB,YAAY,OAAO;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,yBAAyB;AACpC;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA,uBAAuB,uBAAuB;AAC9C;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,yBAAyB;AACpC,YAAY,yBAAyB;AACrC;AACA;AACA;AACA;;AAEA;AACA;AACA,SAAS;;AAET;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA,WAAW,yBAAyB;AACpC,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,YAAY,yBAAyB;AACrC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,yBAAyB;AACpC,WAAW,OAAO;AAClB,YAAY,yBAAyB;AACrC;AACA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA,+CAA+C,mBAAmB;AAClE,KAAK;;AAEL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,qDAAqD,WAAW;AAChE,aAAa;AACb;AACA,uDAAuD,WAAW;AAClE;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mDAAmD,WAAW;AAC9D,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qDAAqD,WAAW;AAChE,aAAa;AACb,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gFAAgF,gBAAgB,EAAE;AAClG,gCAAgC;AAChC;;AAEA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA,SAAS;AACT;AACA;;;;;;;;;;;;;ACpTa;;AAEb;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT;AACA","file":"default/js/search.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/app_livingproof_sfra/cartridge/client/default/js/search.js\");\n","'use strict';\n\nvar processInclude = require('base/util');\n\n$(document).ready(function () {\n processInclude(require('./search/search'));\n processInclude(require('core/product/wishlistHeart'));\n processInclude(require('core/product/compare'));\n});\n","'use strict';\n\n/**\n * Update DOM elements with Ajax results\n *\n * @param {Object} $results - jQuery DOM element\n * @param {string} selector - DOM element to look up in the $results\n * @return {undefined}\n */\nfunction updateDom($results, selector) {\n var $updates = $results.find(selector);\n $(selector).empty().html($updates.html());\n}\n\n/**\n * Keep refinement panes expanded/collapsed after Ajax refresh\n *\n * @param {Object} $results - jQuery DOM element\n * @return {undefined}\n */\nfunction handleRefinements($results) {\n $('.refinement.active').each(function () {\n $(this).removeClass('active');\n var activeDiv = $results.find('.' + $(this)[0].className.replace(/ /g, '.'));\n activeDiv.addClass('active');\n activeDiv.find('button.title').attr('aria-expanded', 'true');\n });\n\n updateDom($results, '.refinements');\n}\n\n/**\n * Parse Ajax results and updated select DOM elements\n *\n * @param {string} response - Ajax response HTML code\n * @return {undefined}\n */\nfunction parseResults(response) {\n var $results = $(response);\n var specialHandlers = {\n '.refinements': handleRefinements\n };\n\n // Update DOM elements that do not require special handling\n [\n '.grid-header',\n '.header-bar',\n '.header.page-title',\n '.product-grid',\n '.show-more',\n '.filter-bar'\n ].forEach(function (selector) {\n updateDom($results, selector);\n });\n\n Object.keys(specialHandlers).forEach(function (selector) {\n specialHandlers[selector]($results);\n });\n}\n\n/**\n * This function retrieves another page of content to display in the content search grid\n * @param {JQuery} $element - the jquery element that has the click event attached\n * @param {JQuery} $target - the jquery element that will receive the response\n * @return {undefined}\n */\nfunction getContent($element, $target) {\n var showMoreUrl = $element.data('url');\n $.spinner().start();\n $.ajax({\n url: showMoreUrl,\n method: 'GET',\n success: function (response) {\n $target.append(response);\n $.spinner().stop();\n },\n error: function () {\n $.spinner().stop();\n }\n });\n}\n\n/**\n * Update sort option URLs from Ajax response\n *\n * @param {string} response - Ajax response HTML code\n * @return {undefined}\n */\nfunction updateSortOptions(response) {\n var $tempDom = $('
').append($(response));\n var sortOptions = $tempDom.find('.grid-footer').data('sort-options').options;\n sortOptions.forEach(function (option) {\n $('option.' + option.id).val(option.url);\n });\n}\n\nmodule.exports = {\n filter: function () {\n // Display refinements bar when Menu icon clicked\n $('.container').on('click', 'button.filter-results', function () {\n $('.refinement-bar, .modal-background').show();\n $('.refinement-bar').siblings().attr('aria-hidden', true);\n $('.refinement-bar').closest('.row').siblings().attr('aria-hidden', true);\n $('.refinement-bar').closest('.tab-pane.active').siblings().attr('aria-hidden', true);\n $('.refinement-bar').closest('.container.search-results').siblings().attr('aria-hidden', true);\n $('.refinement-bar .close').focus();\n $('body').addClass('flyout-active filter-active');\n });\n },\n\n closeRefinements: function () {\n // Refinements close button\n $('.container').on('click', '.refinement-bar button.close, .modal-background', function () {\n $('.refinement-bar, .modal-background').hide();\n $('.refinement-bar').siblings().attr('aria-hidden', false);\n $('.refinement-bar').closest('.row').siblings().attr('aria-hidden', false);\n $('.refinement-bar').closest('.tab-pane.active').siblings().attr('aria-hidden', false);\n $('.refinement-bar').closest('.container.search-results').siblings().attr('aria-hidden', false);\n $('.btn.filter-results').focus();\n });\n },\n\n resize: function () {\n // Close refinement bar and hide modal background if user resizes browser\n $(window).resize(function () {\n $('.refinement-bar, .modal-background').hide();\n $('.refinement-bar').siblings().attr('aria-hidden', false);\n $('.refinement-bar').closest('.row').siblings().attr('aria-hidden', false);\n $('.refinement-bar').closest('.tab-pane.active').siblings().attr('aria-hidden', false);\n $('.refinement-bar').closest('.container.search-results').siblings().attr('aria-hidden', false);\n });\n },\n\n sort: function () {\n\n $('.container').on('click', '.sort-options a', function (e) {\n e.preventDefault();\n $.spinner().start();\n $(this).trigger('search:sort', $(this).attr('href'));\n $('.sort-options-container').find('.active').removeClass('active');\n $(this).addClass('active').parents('.sort-options-container').removeClass('active');\n $('body').removeClass('flyout-active sort-active');\n\n $.ajax({\n url: $(this).attr('href'),\n data: { selectedUrl: $(this).attr('href') },\n method: 'GET',\n success: function (response) {\n $('.product-grid').empty().html(response);\n $.spinner().stop();\n },\n error: function () {\n $.spinner().stop();\n }\n });\n });\n\n // Handle sort order menu selection\n $('.container').on('change', '[name=sort-order]', function (e) {\n e.preventDefault();\n\n $.spinner().start();\n $(this).trigger('search:sort', this.value);\n $.ajax({\n url: this.value,\n data: { selectedUrl: this.value },\n method: 'GET',\n success: function (response) {\n $('.product-grid').empty().html(response);\n $.spinner().stop();\n $('.sort-options-container').find('li.active').removeClass('active');\n $('.sort-options-container').find('li[data-value=' + this.value + ']').addClass('active');\n },\n error: function () {\n $.spinner().stop();\n }\n });\n });\n },\n\n showMore: function () {\n // Show more products\n $('.container').on('click', '.show-more button', function (e) {\n e.stopPropagation();\n var showMoreUrl = $(this).data('url');\n e.preventDefault();\n\n $.spinner().start();\n $(this).trigger('search:showMore', e);\n $.ajax({\n url: showMoreUrl,\n data: { selectedUrl: showMoreUrl },\n method: 'GET',\n success: function (response) {\n $('.grid-footer').replaceWith(response);\n updateSortOptions(response);\n $.spinner().stop();\n },\n error: function () {\n $.spinner().stop();\n }\n });\n });\n },\n\n applyFilter: function () {\n // Handle refinement value selection and reset click\n $('.container').on(\n 'click',\n '.refinements li button, .refinement-bar button.reset, .filter-value button, .swatch-filter button',\n function (e) {\n e.preventDefault();\n e.stopPropagation();\n\n $.spinner().start();\n $(this).trigger('search:filter', e);\n $.ajax({\n url: $(this).data('href'),\n data: {\n page: $('.grid-footer').data('page-number'),\n selectedUrl: $(this).data('href')\n },\n method: 'GET',\n success: function (response) {\n parseResults(response);\n $.spinner().stop();\n },\n error: function () {\n $.spinner().stop();\n }\n });\n });\n },\n\n showContentTab: function () {\n // Display content results from the search\n $('.container').on('click', '.content-search', function () {\n if ($('#content-search-results').html() === '') {\n getContent($(this), $('#content-search-results'));\n }\n });\n\n // Display the next page of content results from the search\n $('.container').on('click', '.show-more-content button', function () {\n getContent($(this), $('#content-search-results'));\n $('.show-more-content').remove();\n });\n }\n};\n","'use strict';\n\nmodule.exports = function (include) {\n if (typeof include === 'function') {\n include();\n } else if (typeof include === 'object') {\n Object.keys(include).forEach(function (key) {\n if (typeof include[key] === 'function') {\n include[key]();\n }\n });\n }\n};\n","'use strict';\n\nvar $compareBar = $('.compare-bar-wrapper');\nvar maxSlots = parseInt($('.compare-bar').data('max-slots'), 10);\nvar productsForComparison = [];\nvar compareButtonText = $('button.compare').text();\n\nvar lastKnownUrl = location.href;\n\n\n/**\n * @typedef ProductComparisonList\n * @type Object\n * @property {string} pid - ID for product to compare\n * @property {string} imgSrc - Image URL for selected product\n */\n\n/**\n * Compiles the HTML for a single slot\n *\n * @param {ProductComparisonList} product - Selected product to compare\n * @param {number} idx - Slot number (zero-based)\n * @return {string} - HTML for a single slot\n */\nfunction compileSlot(product, idx) {\n var pid = product.pid;\n var name = 'pid' + idx;\n\n return '' +\n '
' +\n '
' +\n '' +\n '
' +\n '' +\n '
' +\n '
' +\n '' +\n '
\\n';\n}\n\n/**\n * Draw and render the Compare Bar product slots\n *\n * @param {ProductComparisonList []} productsToCompare - List of ID's of the products to compare\n */\nfunction redrawCompareSlots(productsToCompare) {\n var html = productsToCompare.map(function (product, idx) {\n return compileSlot(product, idx);\n }).join('');\n\n // Render empty slots\n if (productsToCompare.length < maxSlots) {\n var numAvailableSlots = maxSlots - productsToCompare.length;\n\n for (var i = 0; i < numAvailableSlots; i++) {\n if (i === 0 && productsToCompare.length < 2) {\n html += '
' +\n '
' + $('.compare-bar').data('min-products-msg') +\n '
';\n } else {\n html += '
';\n }\n }\n }\n\n $('.compare-bar .product-slots').empty().append(html);\n}\n\n/**\n * Enables/disables the Compare button, depending on whether at least two products have been\n * selected for comparison\n *\n * @param {number} numProducts - Number of products selected for comparison\n */\nfunction setCompareButton(numProducts) {\n if (numProducts > 0) {\n $('button.compare').text(compareButtonText + '(' + numProducts + ')');\n } else {\n $('button.compare').text(compareButtonText);\n }\n if (numProducts < 2) {\n $('button.compare').attr('disabled', true);\n } else {\n $('button.compare').removeAttr('disabled');\n }\n}\n\n/**\n * Returns a copy of a list of products to compare\n *\n * @param {ProductComparisonList []} productsToCompare - List of ID's of the products to compare\n * @return {ProductComparisonList []} List of ID's of the products to compare\n */\nfunction copyProducts(productsToCompare) {\n return productsToCompare.map(function (product) {\n var proxy = {};\n\n Object.keys(product).forEach(function (key) {\n proxy[key] = product[key];\n });\n\n return proxy;\n });\n}\n\n/**\n * Handles the selection of a product for comparison\n *\n * @param {ProductComparisonList []} products - List of ID's of the products to compare\n * @param {string} pid - ID for product to compare\n * @param {string} imgSrc - Image URL for selected product\n * @return {ProductComparisonList []} List of ID's of the products to compare\n */\nfunction selectProduct(products, pid, imgSrc) {\n var productsToCompare = copyProducts(products) || [];\n\n if (productsToCompare.length < maxSlots) {\n productsToCompare.push({\n pid: pid,\n imgSrc: imgSrc\n });\n\n if (productsToCompare.length === maxSlots) {\n $('input[type=checkbox]:not(:checked)').attr('disabled', true);\n }\n\n redrawCompareSlots(productsToCompare);\n setCompareButton(productsToCompare.length);\n $compareBar.show();\n }\n\n return productsToCompare;\n}\n\n/**\n * Handles the deselection of a product\n *\n * @param {ProductComparisonList []} products - List of ID's of the products to compare\n * @param {string} pid - ID for product to compare\n * @return {ProductComparisonList []} List of ID's of the products to compare\n */\nfunction deselectProduct(products, pid) {\n var productsToCompare = copyProducts(products) || [];\n\n productsToCompare = productsToCompare.filter(function (product) {\n return product.pid !== pid;\n });\n\n if (productsToCompare.length === 0) {\n $compareBar.hide();\n }\n\n $('input#' + pid).prop('checked', false);\n $('input[type=checkbox]:not(:checked)').removeAttr('disabled');\n\n redrawCompareSlots(productsToCompare);\n setCompareButton(productsToCompare.length);\n return productsToCompare;\n}\n\n/**\n * Clears the Compare Bar and hides it\n * @return {undefined}\n */\nfunction clearCompareBar() {\n productsForComparison.forEach(function (product) {\n $(this).trigger('compare:deselected', { pid: product.pid });\n });\n\n productsForComparison = [];\n $('.compare input').prop('checked', false);\n $('.compare input[type=checkbox]:not(:checked)').removeAttr('disabled');\n $compareBar.hide();\n}\n\n/**\n * Update form action url to not have query string\n * @returns {undefined}\n */\nfunction updateSubmitUrl() {\n var form = $('.compare-products-form');\n var targetUrl = form.attr('action');\n var urlParts = targetUrl.split('?');\n if (urlParts[1]) {\n urlParts[1].split('&').forEach(function (keyValue) {\n var splittedValues = keyValue.split('=');\n var key = decodeURIComponent(splittedValues[0]);\n var value = decodeURIComponent(splittedValues[1]);\n if (key && value) {\n if (form.find('[name=\"' + key + '\"]').length === 0) {\n form.append('');\n }\n }\n });\n form.attr('action', urlParts[0]);\n }\n}\n\nmodule.exports = {\n /**\n * Handles Compare checkbox click\n */\n handleCompareClick: function () {\n $('div.page').on('click', '.compare input[type=checkbox]', function () {\n var pid = $(this).attr('id');\n var checked = $(this).is(':checked');\n var imgSrc = $(this).closest('.product-tile')\n .find('.tile-image')\n .prop('src');\n\n if (checked) {\n productsForComparison = selectProduct(productsForComparison, pid, imgSrc);\n $(this).trigger('compare:selected', { pid: pid });\n } else {\n productsForComparison = deselectProduct(productsForComparison, pid);\n $(this).trigger('compare:deselected', { pid: pid });\n }\n });\n },\n\n /**\n * Handles the Clear All link\n */\n handleClearAll: function () {\n $('.compare-bar a.clear-all').on('click', function (e) {\n e.preventDefault();\n clearCompareBar();\n });\n },\n\n /**\n * Show/Hide Compare bar on PLP\n */\n toggleCompareBar: function () {\n $('.compare-bar-wrapper').on('click', '.toggle-compare', function () {\n $(this).parent('.compare-bar-wrapper').toggleClass('hidden');\n $(this).find('.fa').toggleClass('fa-angle-down fa-angle-up');\n });\n },\n\n /**\n * Handles deselection of a product on the Compare Bar\n */\n deselectProductOnCompareBar: function () {\n $('.compare-bar').on('click', '.close', function () {\n var pid = $(this).closest('.slot').data('pid').toString();\n productsForComparison = deselectProduct(productsForComparison, pid);\n $(this).trigger('compare:deselected', { pid: pid });\n });\n },\n\n /**\n * Selects products for comparison based on the checked status of the Compare checkboxes in\n * each product tile. Used when user goes back from the Compare Products page.\n */\n selectCheckedProducts: function () {\n $('.product-grid').ready(function () {\n if (location.hash) {\n location.hash.replace('#', '').split(',').forEach(function (id) {\n $('input#' + id).prop('checked', 'checked');\n });\n }\n $('.compare input:checked').each(function () {\n var pid = $(this).prop('id');\n var imgSrc = $(this).closest('.product-tile')\n .find('img.tile-image')\n .prop('src');\n productsForComparison = selectProduct(productsForComparison, pid, imgSrc);\n $(this).trigger('compare:selected', { pid: pid });\n });\n });\n },\n\n /**\n * Sets the \"backUrl\" property to the last attribute selected URL to ensure that when the user\n * goes back from the Compare Products page, the previously selected attributes are still\n * selected and applied to the previous search.\n */\n setBackUrl: function () {\n $('.search-results').on('click', '.refinements a', function () {\n $('input[name=\"backUrl\"]').val($(this).prop('href'));\n });\n },\n\n /**\n * Sets the history.pushState for history.back() to work from the Compare Products page.\n */\n setPushState: function () {\n $('.compare-products-form').on('submit', function () {\n updateSubmitUrl();\n var selectedProducts = $('.compare input:checked').map(function () { return this.id; }).get().join(',');\n history.pushState({}, document.title, lastKnownUrl + '#' + selectedProducts);\n location.hash = selectedProducts;\n\n $(this).find('input[name=\"cgid\"]').attr('value', $('input.category-id').val());\n });\n },\n catchFilterChange: function () {\n $('.container').on('click', '.refinements li a, .refinement-bar a.reset', function (e) {\n e.preventDefault();\n clearCompareBar();\n });\n },\n listenToFilterChange: function () {\n $('body').on('search:filter', function (e, data) {\n lastKnownUrl = data.currentTarget.href;\n });\n }\n};\n","'use strict';\n\n/**\n * appends params to a url\n * @param {string} data - data returned from the server's ajax call\n * @param {Object} icon - icon that was clicked to add a product to the wishlist\n */\nfunction displayMessageAndChangeIcon(data, icon) {\n $.spinner().stop();\n var status;\n if (data.success) {\n status = 'alert-success';\n if (icon.hasClass('fa-heart-o')) {\n icon.removeClass('fa-heart-o').addClass('fa-heart');\n }\n } else {\n status = 'alert-danger';\n }\n\n if ($('.add-to-wishlist-messages').length === 0) {\n $('body').append(\n '
'\n );\n }\n $('.add-to-wishlist-messages')\n .append('
' + data.msg + '
');\n\n setTimeout(function () {\n $('.add-to-wishlist-messages').remove();\n }, 5000);\n}\n\nmodule.exports = {\n addToWishlist: function () {\n $('body').on('click', '.wishlistTile', function (e) {\n e.preventDefault();\n var icon = $(this).find($('i'));\n var url = $(this).attr('href');\n var pid = $(this).closest('.product').data('pid');\n var optionId = $(this).closest('.product-detail').find('.product-option').attr('data-option-id');\n var optionVal = $(this).closest('.product-detail').find('.options-select option:selected').attr('data-value-id');\n optionId = optionId || null;\n optionVal = optionVal || null;\n if (!url || !pid) {\n return;\n }\n\n $.spinner().start();\n $.ajax({\n url: url,\n type: 'post',\n dataType: 'json',\n data: {\n pid: pid,\n optionId: optionId,\n optionVal: optionVal\n },\n success: function (data) {\n displayMessageAndChangeIcon(data, icon);\n },\n error: function (err) {\n displayMessageAndChangeIcon(err, icon);\n }\n });\n });\n }\n};\n"],"sourceRoot":""}