{ "version": 3, "sources": [ "../../../../../Foundation/JavascriptCommon/code/scripts/common/urlUtils.js", "../../../../Media/code/scripts/app/MediaGallery/mediaGallery.js", "ProductDetailsAndDimensions/productDetailsAndDimensions.js", "../../../../Order/code/scripts/app/ShoppingCartIcon/shoppingCartIcon.js", "../../../../../Foundation/JavascriptCommon/code/scripts/common/formUtils.js", "../../../../../Foundation/JavascriptCommon/code/scripts/common/alertMessage.js", "../../../../Order/code/scripts/app/ShoppingCartIcon/miniCart.js", "ProductDescriptionTabs/replacementParts.js", "../../../../../Foundation/JavascriptCommon/code/scripts/common/spinner.js", "../../../../../Foundation/JavascriptCommon/code/scripts/common/formatter.js", "ProductOptions/productOptions.js", "ProductOptions/main.js" ], "names": [], "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;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;AACA;AACA;AACA;AACA;AACA;AACA,AC1KA;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;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;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,ACzOA;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;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,AC/GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,AClBA;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;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,AC9GA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,ACvGA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,ACvGA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,AC1FA;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,AC7CA;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,AC3BA;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;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;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;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;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;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,ACjgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA", "file": "ProductOptions.js", "sourcesContent": [ "define('common/urlUtils',[\r\n],\r\n function () {\r\n\r\n // Takes the url and parses the query string parameters out of it.\r\n // Returns the parameters and their string values as object { paramName1: value1, paramName2: value2, ...},\r\n // or an empty object in case there are no parameters in url.\r\n function parseQueryParamsFromUrl(url) {\r\n url = url ? url : window.location.search; // default url parameter if not set\r\n // take just the query search part of url (lose the leading question mark)\r\n var query = decomposeUrl(url).search;\r\n if (query.indexOf(\"?\") >= 0) query = query.substring(query.indexOf(\"?\") + 1);\r\n var urlParams = {},\r\n match,\r\n search = /([^&=]+)=?([^&]*)/g,\r\n decode = function (s) { return decodeURI(decodeURIComponent(s)); };\r\n\r\n while (match = search.exec(query))\r\n urlParams[decode(match[1])] = decode(match[2]);\r\n\r\n return urlParams;\r\n }\r\n\r\n // Takes the url, decomposes it into three components: path, search, hash,\r\n // and returns those three components in an object.\r\n // When searching for hash string which is directly after path (without search parameters) we're ignoring '#/'.\r\n // That is not a hash, that is Angular routing and it's actually part of the path.\r\n function decomposeUrl(url) {\r\n var path = '';\r\n var search = '';\r\n var hash = '';\r\n if (url.indexOf('?') >= 0) {\r\n // there is search string already in the url\r\n path = url.substring(0, url.indexOf('?'));\r\n search = url.substring(url.indexOf('?'));\r\n if (search.indexOf('#') >= 0) {\r\n // there is also a hash string in the url\r\n hash = search.substring(search.indexOf('#'));\r\n search = search.substring(0, search.indexOf('#'));\r\n }\r\n } else if (url.indexOf('#') >= 0 && url.indexOf('#') != url.indexOf('#/')) {\r\n // no search string, but there is hash string\r\n path = url.substring(0, url.indexOf('#'));\r\n hash = url.substring(url.indexOf('#'));\r\n } else {\r\n // no search string, no hash string\r\n path = url ? url : '';\r\n }\r\n return {\r\n path: path, // path also includes the protocol and hostname (if they existed in the given url)\r\n search: search,\r\n hash: hash\r\n }\r\n }\r\n\r\n // Adds a new query string parameter into the given url.\r\n // Returns the newly constructed url.\r\n function putParamIntoUrl(paramName, paramValue, url) {\r\n // first we'll split the url into 3 components\r\n var urlComp = decomposeUrl(url);\r\n // add the new query string parameter into search string\r\n urlComp.search = (urlComp.search ? urlComp.search + '&' : '?') + paramName + '=' + encodeURIComponent(paramValue);\r\n // return the new url\r\n return urlComp.path + urlComp.search + urlComp.hash;\r\n }\r\n\r\n // Reads the specified query string parameter from a given url.\r\n // Returns the value of that parameter (a string value). \r\n function getParamFromUrl(paramName, url) {\r\n return parseQueryParamsFromUrl(url)[paramName];\r\n }\r\n\r\n // Modifies the given DOM element's href property, or the current page's URL (if\r\n // no domElement has been given) by adding new query string parameter with the\r\n // given value. \r\n function pushParamIntoLink(paramName, paramValue, domElement) {\r\n var url;\r\n if (domElement) url = $(domElement).attr('href'); // url from DOM element\r\n else url = window.location.href; // current page url\r\n\r\n var params = parseQueryParamsFromUrl(url);\r\n\r\n // making sure that we find the parameter no matter how it's written (case insensitive)\r\n for (var p in params) {\r\n if (p.toLowerCase() === paramName.toLowerCase()) {\r\n paramName = p;\r\n break;\r\n }\r\n }\r\n\r\n params[paramName] = paramValue; // update (or add) the parameter\r\n var newSearchString = $.param(params); // and construct a new search string.\r\n\r\n var urlComp = decomposeUrl(url);\r\n if (domElement) {\r\n // set new href property on DOM element\r\n var newHref = urlComp.path + (newSearchString ? ('?' + newSearchString) : '') + urlComp.hash;\r\n $(domElement).attr('href', newHref);\r\n } else {\r\n if (history && history.pushState) { // because some older browsers (IE 9 or older) don't support this\r\n // for other pages put new URL to browser's address bar using window.history\r\n history.replaceState(\r\n null,\r\n null,\r\n urlComp.path +\r\n (newSearchString ? ('?' + newSearchString) : '') +\r\n urlComp.hash\r\n );\r\n }\r\n }\r\n }\r\n\r\n // Reads the query string parameter from the domElement's href property, or from\r\n // the current page's URL (if no domElement has been given). Removes the parameter\r\n // from the URL and puts new URL into the domElement's href property, or into the\r\n // browser's address bar.\r\n // Returns the value of that parameter (a string value).\r\n function popParamFromLink(paramName, domElement) {\r\n var url;\r\n if (domElement) url = $(domElement).attr('href'); // url from DOM element\r\n else url = window.location.href; // current page url\r\n\r\n var params = parseQueryParamsFromUrl(url);\r\n var retVal;\r\n\r\n // making sure that we find the parameter no matter how it's written (case insensitive)\r\n for (var p in params) {\r\n if (p.toLowerCase() === paramName.toLowerCase()) {\r\n paramName = p;\r\n break;\r\n }\r\n }\r\n\r\n if (params[paramName]) {\r\n // the requested parameter exists in the url\r\n retVal = params[paramName]; // Its value will be returned from the function.\r\n delete params[paramName]; // Remove the parameter from the array,\r\n var newSearchString = $.param(params); // and construct a new search string.\r\n var urlComp = decomposeUrl(url);\r\n if (domElement) {\r\n // set new href property on DOM element\r\n var newHref = urlComp.path + (newSearchString ? ('?' + newSearchString) : '') + urlComp.hash;\r\n $(domElement).attr('href', newHref);\r\n } else {\r\n if (history && history.pushState) { // because some older browsers (IE 9 or older) don't support this\r\n // for other pages put new URL to browser's address bar using window.history\r\n history.replaceState(\r\n null,\r\n null,\r\n urlComp.path +\r\n (newSearchString ? ('?' + newSearchString) : '') +\r\n urlComp.hash\r\n );\r\n }\r\n }\r\n }\r\n return retVal;\r\n }\r\n\r\n\r\n return {\r\n parseQueryParamsFromUrl: parseQueryParamsFromUrl,\r\n decomposeUrl: decomposeUrl,\r\n putParamIntoUrl: putParamIntoUrl,\r\n getParamFromUrl: getParamFromUrl,\r\n pushParamIntoLink: pushParamIntoLink,\r\n popParamFromLink: popParamFromLink\r\n }\r\n });\r\n\n", "define('mediaGallery/mediaGallery',[\r\n],\r\n function () {\r\n\r\n const mediaGallerySelector = \".media-gallery\";\r\n const swiperSelector = \"div[id^='media_gallery_swiper_']\";\r\n const thumbsSelector = \"div[id^='media_gallery_thumbs_']\";\r\n\r\n // ZOOM & PINCH MEDIA GALLERY\r\n function initZoomAndPinch(slidesSelector) {\r\n slidesSelector = slidesSelector || '.media-gallery .main .swiper-slide';\r\n if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {\r\n setTimeout(function () {\r\n var divs = document.querySelectorAll(slidesSelector + ' .swiper-image-container img').forEach(function (el) {\r\n new PinchZoom(el, {\r\n tapZoomFactor: 3,\r\n minZoom: 1,\r\n maxZoom: 3\r\n });\r\n });\r\n }, 250);\r\n }\r\n else {\r\n // Thumbnail hovers\r\n $(\".thumb-slide\").off('click').on('click', function () {\r\n var parent = $(this).parent();\r\n var slideIndex = parent.children().index($(this)[0]);\r\n var swiperContainer = $(this).closest(mediaGallerySelector).find(swiperSelector);\r\n var swiper = swiperContainer[0].swiper;\r\n setTimeout(function () {\r\n swiper.slideTo(slideIndex);\r\n }, 250);\r\n });\r\n }\r\n }\r\n\r\n function monitorIframe() {\r\n // SET INTERVAL TO DETECT IFRAME CLICK\r\n var monitor = setInterval(function(){\r\n var elem = document.activeElement;\r\n if(elem && elem.tagName == 'IFRAME'){\r\n elem.blur();\r\n $('.media-gallery').addClass('video-playing');\r\n clearInterval(monitor);\r\n }\r\n }, 100);\r\n }\r\n\r\n (function loadDynamicIframe() {\r\n // ADD DEFAULT YOUTUBE IMAGE TO IFRAME\r\n $('.media-gallery .video-embed').each(function(){\r\n var y = $(this).attr('data-thumb');\r\n $(this).css('background-image','url('+ y + ')');\r\n });\r\n // REPLACE DEFAULT YOUTUBE IMAGE WITH YOUTUBE\r\n $('.media-gallery .video_wrapper .icon-play').on('click',function(){\r\n var b = $(this).next().attr('data-src');\r\n $(this).next().attr('src',b);\r\n $(this).remove();\r\n });\r\n $('.media-gallery .video_wrapper .play-icon').on('click', function () {\r\n var b = $(this).next().attr('data-src');\r\n $(this).next().attr('src', b);\r\n $(this).remove();\r\n });\r\n monitorIframe();\r\n }());\r\n\r\n function position(galleryNumber, slideId) {\r\n var swiperContainer = $(\"#media_gallery_swiper_\" + galleryNumber);\r\n if (swiperContainer.length) {\r\n var swiper = swiperContainer[0].swiper;\r\n if (swiper) {\r\n var slideIndex = $(swiperContainer).find(\".swiper-slide[data-slide-id=\" + slideId + \"]\").index(\".swiper-slide\");\r\n if (slideIndex >= 0) {\r\n swiper.slideTo(slideIndex, 0);\r\n displayCaptionForCurrentSlide(swiper);\r\n }\r\n }\r\n }\r\n }\r\n\r\n function displayVariantImages(galleryNumber, variantImageId, additionalVariantImages) {\r\n\r\n if (!window.mediaGalleryData || !window.mediaGalleryData.variantImages) return; // there's no mediaGalleryData to work with\r\n\r\n var swiperContainerSelector = \"#media_gallery_swiper_\" + galleryNumber;\r\n var variantImageSlideSelector = swiperContainerSelector + \" .swiper-slide[data-slide-type=VariantImage]\";\r\n\r\n var swiperContainer = $(swiperContainerSelector);\r\n if (!swiperContainer.length) return; // no swiper container - nothing to do\r\n var swiper = swiperContainer[0].swiper;\r\n if (!swiper) return; // no swiper initializaed - nothing to do\r\n\r\n var swiperChanged = false;\r\n // first, remove currently displayed variant images\r\n $(variantImageSlideSelector).each(function (index, slideElement) {\r\n var slideIndex = $(slideElement).index(\".swiper-slide\");\r\n swiper.removeSlide(slideIndex);\r\n swiper.thumbs.swiper.removeSlide(slideIndex);\r\n swiperChanged = true;\r\n });\r\n\r\n // then, add images given as parameters\r\n var imagesToAdd = variantImageId ? [variantImageId].concat(additionalVariantImages) : additionalVariantImages;\r\n if (imagesToAdd.length) {\r\n var slideCssClass = $(swiperContainer).data(\"slideCssClass\");\r\n var thumbnailSlideCssClass = $(swiperContainer).data(\"thumbnailSlideCssClass\");\r\n\r\n var slidesToAdd = [];\r\n var thumbnailsToAdd = [];\r\n imagesToAdd.forEach(function (imageId) {\r\n var variantImage = mediaGalleryData.variantImages[imageId];\r\n //checking if variant image exist (if image is unpublished it will be undefined and it will raise error in javascript)\r\n if (variantImage) {\r\n slidesToAdd.push(getSlideHtml(slideCssClass, imageId, variantImage.caption, variantImage.url, variantImage.alt));\r\n thumbnailsToAdd.push(getThumbnailSlideHtml(thumbnailSlideCssClass, variantImage.thumbnailUrl, variantImage.alt));\r\n }\r\n });\r\n\r\n swiper.prependSlide(slidesToAdd.reverse());\r\n swiper.thumbs.swiper.prependSlide(thumbnailsToAdd.reverse());\r\n\r\n swiperChanged = true;\r\n }\r\n\r\n if (swiperChanged) {\r\n swiper.slideTo(0, 0);\r\n // do the required initializations for newly added slides\r\n initZoomAndPinch(variantImageSlideSelector);\r\n $(variantImageSlideSelector).off('click').on('click', displayGalleryPopup);\r\n dispatchResizeEvent();\r\n displayCaptionForCurrentSlide(swiper);\r\n }\r\n }\r\n\r\n function getSlideHtml(cssClass, slideId, slideCaption, imageUrl, alt) {\r\n return '
' +\r\n '
' +\r\n '' +\r\n '\"'' +\r\n '' +\r\n '
' +\r\n '
' +\r\n '
';\r\n }\r\n\r\n function getThumbnailSlideHtml(cssClass, imageUrl, alt) {\r\n return '
' +\r\n '
' +\r\n '\"'' +\r\n '
' +\r\n '
';\r\n }\r\n\r\n function displayCaptionForCurrentSlide(swiper) {\r\n var slide = swiper.slides[swiper.realIndex];\r\n\r\n // Taking the caption for variant images from the Javascript object, and for other images from their data-slide-caption attribute.\r\n // (This is because double quote characters are causing problems in variant image slide, which are generated dynamically in runtime.)\r\n var imageId = $(slide).data(\"slideId\");\r\n var variantImage = mediaGalleryData.variantImages ? mediaGalleryData.variantImages[imageId] : null;\r\n var captionHtmlEncoded = variantImage ? variantImage.caption : $(slide).data(\"slideCaption\");\r\n // caption string is HTML encoded (so it doesn't mess up Javascript object or data attribute), now we have to decode it back\r\n var textArea = document.createElement('textarea');\r\n textArea.innerHTML = captionHtmlEncoded;\r\n var caption = textArea.value;\r\n\r\n $(slide).closest(mediaGallerySelector).find(\".caption\").empty().html(caption);\r\n if($('.media-gallery').hasClass('video-playing')) {\r\n $('.media-gallery').removeClass('video-playing'); \r\n $('.media-gallery .video-embed').each(function(){\r\n var el_src = $(this).attr(\"src\");\r\n $(this).attr(\"src\",el_src);\r\n });\r\n monitorIframe(); \r\n }\r\n }\r\n\r\n function displayGalleryPopup(event) {\r\n if (!(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))) {\r\n setTimeout(function () {\r\n $('.easyzoom').EasyZoomMagnifierReset();\r\n\r\n if (!$(\".modal-gallery\").hasClass(\"open-modal\")) {\r\n $('.modal-gallery').addClass('open-modal');\r\n }\r\n dispatchResizeEvent();\r\n }, 250);\r\n }\r\n }\r\n\r\n function closeGalleryPopup(event) {\r\n //e.preventDefault();\r\n var data = $(\".swiper-container.main\").data();\r\n\r\n $(\".swiper-lazy.swiper-lazy-loaded\").css(\"transform\", \"translate3d(0px, 0px, 0px) scale(1)\");\r\n $(\".swiper-zoom-container\").css(\"transform\", \"translate3d(0px, 0px, 0px)\");\r\n\r\n $('.modal-gallery').removeClass('open-modal');\r\n $('.easyzoom').EasyZoomMagnifier();\r\n\r\n dispatchResizeEvent();\r\n }\r\n\r\n function dispatchResizeEvent() {\r\n var event;\r\n if (typeof (Event) === 'function') {\r\n event = new Event('resize');\r\n } else {\r\n event = document.createEvent('Event');\r\n event.initEvent('resize', false, false);\r\n }\r\n\r\n window.dispatchEvent(event);\r\n }\r\n\r\n return {\r\n position: position,\r\n displayVariantImages: displayVariantImages,\r\n displayCaptionForCurrentSlide: displayCaptionForCurrentSlide,\r\n mediaGallerySelector: mediaGallerySelector,\r\n swiperSelector: swiperSelector,\r\n thumbsSelector: thumbsSelector,\r\n displayGalleryPopup: displayGalleryPopup,\r\n closeGalleryPopup: closeGalleryPopup,\r\n initZoomAndPinch: initZoomAndPinch\r\n };\r\n });\r\n\n", "define('productDetailsAndDimensions/productDetailsAndDimensions',[\r\n],\r\n function () {\r\n\r\n const componentSelector = \".product-details-and-dimensions\";\r\n const itersEcersSelector = \".rating-scale\";\r\n const componentTitleSelector = \"#details-and-dimensions\";\r\n const dimensionsWrapperSelector = \".dimensions-wrapper\";\r\n const dimensionsChangeList = [\r\n { selector: \".height\", wrapperSelector: \".height-wrapper\", data: \"height\" },\r\n { selector: \".depth\", wrapperSelector: \".depth-wrapper\", data: \"depth\" },\r\n { selector: \".width\", wrapperSelector: \".width-wrapper\", data: \"width\" },\r\n { selector: \".length\", wrapperSelector: \".length-wrapper\", data: \"length\" }\r\n ];\r\n const detailsChangeList = [\r\n { selector: \".details\", wrapperSelector: \".details-wrapper\", data: \"details\" }\r\n ];\r\n const ageRangeChangeList = [\r\n { selector: \".age-range\", wrapperSelector: \".age-range-wrapper\", data: \"ageRange\" }\r\n ];\r\n\r\n function displayVariantData(variantGuid) {\r\n var variant = productDetailsAndDimensions.variants[variantGuid];\r\n if (variant) {\r\n var componentElement = $(componentSelector);\r\n var displayed = {\r\n dimensions: false,\r\n details: false,\r\n image: false,\r\n itersEcers: false\r\n };\r\n // change text elements for dimensions\r\n dimensionsChangeList.forEach(function (change) {\r\n var value = variant[change.data];\r\n $(componentElement).find(change.selector).empty().html(value);\r\n if (value) {\r\n // this dimension has value - display its wrapper as well.\r\n $(componentElement).find(change.wrapperSelector).removeClass(\"d-none\");\r\n displayed.dimensions = true;\r\n } else {\r\n // this dimension doesn't have value - hide the wrapper.\r\n $(componentElement).find(change.wrapperSelector).addClass(\"d-none\");\r\n }\r\n });\r\n // If there's any dimension displayed - display the title as well. Otherwise hide it.\r\n if (displayed.dimensions) {\r\n $(componentElement).find(dimensionsWrapperSelector).removeClass(\"d-none\");\r\n } else {\r\n $(componentElement).find(dimensionsWrapperSelector).addClass(\"d-none\");\r\n }\r\n // change text for details\r\n detailsChangeList.forEach(function (change) {\r\n var value = variant[change.data];\r\n $(componentElement).find(change.selector).empty().html(value);\r\n if (value) {\r\n // has value - display the wrapper as well\r\n $(componentElement).find(change.wrapperSelector).removeClass(\"d-none\");\r\n displayed.details = true;\r\n } else {\r\n // doesn't have value - hide the wrapper\r\n $(componentElement).find(change.wrapperSelector).addClass(\"d-none\");\r\n }\r\n });\r\n // change text for age range\r\n ageRangeChangeList.forEach(function (change) {\r\n var value = variant[change.data];\r\n $(componentElement).find(change.selector).empty().html(value);\r\n if (value) {\r\n // has value - display the wrapper as well\r\n $(componentElement).find(change.wrapperSelector).removeClass(\"d-none\");\r\n displayed.details = true;\r\n } else {\r\n // doesn't have value - hide the wrapper\r\n $(componentElement).find(change.wrapperSelector).addClass(\"d-none\");\r\n }\r\n });\r\n // change image url\r\n if (variant.imageUrl) {\r\n var imageElement = $(componentElement).find(\".dimensions-image\");\r\n var currentImageUrl = $(imageElement).attr(\"src\");\r\n if (variant.imageUrl !== currentImageUrl) {\r\n $(imageElement)\r\n .addClass(\"opacity-05\")\r\n .attr(\"src\", variant.imageUrl)\r\n .attr(\"width\", variant.imageWidth)\r\n .attr(\"height\", variant.imageHeight)\r\n .one(\"load\", function () { $(this).removeClass(\"opacity-05\") });\r\n }\r\n $(componentElement).find(\".dimensions-image-wrapper\").removeClass(\"d-none\");\r\n displayed.image = true;\r\n } else {\r\n $(componentElement).find(\".dimensions-image-wrapper\").addClass(\"d-none\");\r\n }\r\n //do we have iters and ecers?\r\n if ($(componentElement).find(itersEcersSelector).length) {\r\n displayed.itersEcers = true;\r\n }\r\n // If there's something displayed - display the component title as well. Otherwise hide it.\r\n if (displayed.details || displayed.dimensions || displayed.image || displayed.itersEcers) {\r\n $(componentTitleSelector).removeClass(\"d-none\");\r\n } else {\r\n $(componentTitleSelector).addClass(\"d-none\");\r\n }\r\n }\r\n }\r\n\r\n return {\r\n displayVariantData: displayVariantData\r\n };\r\n });\r\n\n", "define('shoppingCartIcon/shoppingCartIcon',[\r\n],\r\n function () {\r\n\r\n const itemCountSelector = \".shopping-cart-icon .item-count\";\r\n\r\n function updateItemCount(count) {\r\n $(itemCountSelector).empty();\r\n if (count > 0) {\r\n $(itemCountSelector).text(count);\r\n }\r\n }\r\n\r\n return {\r\n updateItemCount: updateItemCount\r\n };\r\n });\r\n\n", "define('common/formUtils',[\r\n],\r\n function () {\r\n\r\n // Clears and deactivates all invalid feedback text on form fields\r\n function clearInvalidFeedback(formId) {\r\n if (!formId.startsWith(\"#\")) formId = \"#\" + formId;\r\n $(formId + \" .is-invalid\").removeClass(\"is-invalid\");\r\n $(formId + \" .invalid-feedback\").empty();\r\n }\r\n\r\n // Fills in and activates invalid feedback text on form fields\r\n function displayInvalidFeedback(invalidFields, formId) {\r\n if (!formId.startsWith(\"#\")) formId = \"#\" + formId;\r\n if (invalidFields) {\r\n invalidFields.forEach(function (fieldMessage) {\r\n var field = $(formId + \" [name='\" + fieldMessage.FieldName + \"']\");\r\n field.addClass(\"is-invalid\");\r\n field.siblings(\".invalid-feedback\").append(fieldMessage.MessageText);\r\n });\r\n }\r\n }\r\n\r\n // Collects the data from all form fields and returns them as object,\r\n // using \"name\" attribute values from form fields as object property names.\r\n function collectFormData(formId) {\r\n if (!formId.startsWith(\"#\")) formId = \"#\" + formId;\r\n // the serializeArray() jQuery method doesn't take the values from disabled fields, so first I'll\r\n // temporarily enable all disabled fields, and then disable them again\r\n var disabledFields = $(formId).find(\":input:disabled\").prop(\"disabled\", false);\r\n var serializedData = $(formId).serializeArray();\r\n disabledFields.prop(\"disabled\", true);\r\n var formData = {};\r\n serializedData.forEach(function (data) {\r\n formData[data.name] = data.value;\r\n });\r\n // serializeArray does not return anything for unchecked checkboxes, so we'll add them now with value false\r\n $(formId + \" input[type='checkbox']:not(:checked)\").each(function (index, element) {\r\n formData[element.name] = false;\r\n });\r\n // serializeArray returns \"on\" for checked checkboxes, so we'll set them to true now\r\n $(formId + \" input[type='checkbox']:checked\").each(function (index, element) {\r\n formData[element.name] = true;\r\n });\r\n return formData;\r\n }\r\n\r\n // Goes through all input elements on the form and fills them with data from the\r\n // given object, matching \"name\" attribute of the input element with object property name.\r\n function populateFormWithData(formId, data) {\r\n if (!formId.startsWith(\"#\")) formId = \"#\" + formId;\r\n $(formId + \" :input\").each(function (index, element) { \r\n if (element.type === \"radio\" ||\r\n element.type === \"checkbox\")\r\n {\r\n if (data[element.name] !== undefined)\r\n $(element).prop(\"checked\", $(element).val().toString() === data[element.name].toString());\r\n }\r\n else if (element.type === \"text\" ||\r\n element.type === \"email\" ||\r\n element.type === \"tel\" ||\r\n element.type === \"password\" ||\r\n element.type === \"textarea\" ||\r\n element.type === \"select-one\")\r\n {\r\n if (data[element.name] !== undefined)\r\n $(element).val(data[element.name]);\r\n else\r\n $(element).val(null);\r\n }\r\n });\r\n }\r\n\r\n function disableFields(formId) {\r\n if (!formId.startsWith(\"#\")) formId = \"#\" + formId;\r\n $(formId + \" :input\").prop(\"disabled\", true);\r\n }\r\n\r\n function enableFields(formId) {\r\n if (!formId.startsWith(\"#\")) formId = \"#\" + formId;\r\n $(formId + \" :input\").prop(\"disabled\", false);\r\n }\r\n\r\n function initializeFloatingLabels(formId) {\r\n if (!formId.startsWith(\"#\")) formId = \"#\" + formId;\r\n $(formId + \" .floating-label-container\").each(function (index, element) {\r\n var inputElement = $(element).find(\":input\")[0];\r\n if (inputElement.value) $(element).addClass(\"active\");\r\n else $(element).removeClass(\"active\");\r\n });\r\n }\r\n\r\n //adds the form token to the object for use with [ValidateAntiforgeryToken] attribute\r\n function useToken(data) { \r\n var token = $('input[name=\"__RequestVerificationToken\"]').val();\r\n data.__RequestVerificationToken = token;\r\n }\r\n\r\n return {\r\n clearInvalidFeedback: clearInvalidFeedback,\r\n displayInvalidFeedback: displayInvalidFeedback,\r\n collectFormData: collectFormData,\r\n populateFormWithData: populateFormWithData,\r\n disableFields: disableFields,\r\n enableFields: enableFields,\r\n initializeFloatingLabels: initializeFloatingLabels,\r\n useToken: useToken\r\n };\r\n });\r\n\n", "define('common/alertMessage',[\r\n],\r\n function () {\r\n\r\n const alertSelector = \"#alertMessage\";\r\n const allButtonsSelector = alertSelector + \" .modal-footer button\";\r\n const buttonSelector = {\r\n ok: allButtonsSelector + \".ok\",\r\n yes: allButtonsSelector + \".yes\",\r\n no: allButtonsSelector + \".no\"\r\n };\r\n\r\n function show(messageText, okCallback) {\r\n setIcon();\r\n setButtons(\"ok\", okCallback);\r\n displayAlert(messageText);\r\n }\r\n\r\n function info(messageText, okCallback) {\r\n setIcon(\"info\");\r\n setButtons(\"ok\", okCallback);\r\n displayAlert(messageText);\r\n }\r\n\r\n function warning(messageText, okCallback) {\r\n setIcon(\"warning\");\r\n setButtons(\"ok\", okCallback);\r\n displayAlert(messageText);\r\n }\r\n \r\n function error(messageText, okCallback, displayDefaultMessage) {\r\n setIcon(\"error\");\r\n setButtons(\"ok\", okCallback); \r\n if (typeof messageText === 'undefined' || messageText === null) messageText = \"\";\r\n if (typeof displayDefaultMessage === 'undefined') displayDefaultMessage = true;\r\n if (displayDefaultMessage || messageText === \"\") {\r\n messageText = CP.Messages[\"General/Default Error Message\"] + messageText;\r\n }\r\n displayAlert(messageText);\r\n }\r\n\r\n function yesNoQuestion(messageText, yesCallback, noCallback) {\r\n setIcon(\"question\");\r\n setButtons(\"yes-no\", yesCallback, noCallback);\r\n displayAlert(messageText);\r\n }\r\n\r\n function setIcon(iconName) {\r\n $(alertSelector + \" .icons\").addClass(\"d-none\");\r\n $(alertSelector + \" i\").addClass(\"d-none\");\r\n if (iconName) {\r\n $(alertSelector + \" .icons\").removeClass(\"d-none\");\r\n $(alertSelector + \" i.\" + iconName).removeClass(\"d-none\");\r\n }\r\n }\r\n\r\n function setButtons(buttons, callback1, callback2) {\r\n $(allButtonsSelector).addClass(\"d-none\");\r\n $(buttonSelector.ok).off(\"click\");\r\n $(buttonSelector.yes).off(\"click\");\r\n $(buttonSelector.no).off(\"click\");\r\n if (buttons === \"yes-no\") {\r\n $(buttonSelector.yes).removeClass(\"d-none\");\r\n $(buttonSelector.no).removeClass(\"d-none\");\r\n $(buttonSelector.yes).on(\"click\", function () { hideAndCallback(callback1); });\r\n $(buttonSelector.no).on(\"click\", function () { hideAndCallback(callback2); });\r\n }\r\n else {\r\n $(buttonSelector.ok).removeClass(\"d-none\");\r\n $(buttonSelector.ok).on(\"click\", function () { hideAndCallback(callback1); });\r\n }\r\n }\r\n\r\n var alertModal;\r\n\r\n function displayAlert(messageText) {\r\n $(alertSelector + \" .alert-text\").empty().html(messageText);\r\n if (!alertModal) {\r\n // initializing alertModal\r\n var alertElement = document.querySelector(alertSelector);\r\n if (alertElement) {\r\n alertModal = bootstrap.Modal.getOrCreateInstance(alertElement, { backdrop: \"static\", keyboard: false });\r\n if (!alertModal) console.log(\"Alert modal not initialized for \" + alertSelector);\r\n }\r\n else console.log(\"There's no alert modal with selector \" + alertSelector);\r\n }\r\n if (alertModal) alertModal.show();\r\n }\r\n\r\n function hideAndCallback(callback) {\r\n if (callback) $(alertSelector).one(\"hidden.bs.modal\", callback);\r\n if (alertModal) alertModal.hide();\r\n }\r\n\r\n return {\r\n show: show,\r\n info: info,\r\n warning: warning,\r\n error: error,\r\n yesNoQuestion: yesNoQuestion\r\n };\r\n });\r\n\n", "define('shoppingCartIcon/miniCart',[\r\n \"common/formUtils\",\r\n \"common/alertMessage\"\r\n],\r\nfunction (formUtils, alertMessage) {\r\n\r\n const miniCartSelector = \".mini-cart\";\r\n const cartIconSelector = \".shopping-cart-icon .the-icon\";\r\n var autoHideTimeout = 0;\r\n\r\n function init() {\r\n $(cartIconSelector).webuiPopover({\r\n trigger: \"click\",\r\n placement: \"bottom-left\",\r\n width: 400,\r\n type: \"html\",\r\n url: \".mini-cart\",\r\n animation: \"fade\",\r\n multi: true,\r\n arrow: false,\r\n closeable: true,\r\n onShow: populateMiniCart\r\n });\r\n }\r\n\r\n function flash() {\r\n // I've tried this by using some of the WebuiPopover methods (https://github.com/sandywalker/webui-popover),\r\n // but none of them worked for changing the options on the fly, so I'm accessing the popover options\r\n // directly from the data object on the cart icon element.\r\n var options = $(cartIconSelector).data(\"plugin_webuiPopover\").options;\r\n\r\n // setting the options for flashing the popover\r\n var pageTop = $(window).scrollTop();\r\n var cartIconPosition = $(cartIconSelector).offset().top + $(cartIconSelector)[0].offsetHeight;\r\n if (pageTop > cartIconPosition) {\r\n // cart icon is out of the view, offset the popover so it's visible\r\n options.offsetTop = pageTop - cartIconPosition;\r\n }\r\n autoHideTimeout = 3000; // auto hide the popup 3 seconds after its content has loaded\r\n\r\n // showing the popover\r\n $(cartIconSelector).webuiPopover(\"show\");\r\n\r\n // resetting the options back to default values\r\n options.offsetTop = 0;\r\n }\r\n\r\n function populateMiniCart() {\r\n spinner(\"show\");\r\n var postData = {};\r\n formUtils.useToken(postData);\r\n\r\n $.ajax({\r\n type: \"POST\",\r\n url: \"/customapi/Order/GetMiniCart\",\r\n dataType: \"json\",\r\n data: postData,\r\n success: function (data) {\r\n if (data.status === \"OK\") {\r\n $(miniCartSelector + \" .mini-cart-content\").empty().html(data.content);\r\n if (data.count > 0) {\r\n $(miniCartSelector + \" .mini-cart-button\").removeClass(\"d-none\");\r\n }\r\n if (autoHideTimeout > 0) {\r\n // hiding the minicart popup after a set timeout\r\n setTimeout(function () {\r\n $(cartIconSelector).webuiPopover(\"hide\");\r\n }, autoHideTimeout);\r\n autoHideTimeout = 0;\r\n }\r\n } else if (data.status === \"ERROR\") {\r\n alertMessage.error(data.message);\r\n }\r\n },\r\n error: function (jq, status, errorThrown) {\r\n alertMessage.error(status + \": \" + errorThrown);\r\n },\r\n complete: function () {\r\n spinner(\"hide\");\r\n }\r\n\r\n });\r\n\r\n }\r\n\r\n function spinner(what) {\r\n if (what === \"show\") {\r\n $(miniCartSelector + \" .mini-cart-content\").empty(); // remove previous content\r\n $(miniCartSelector + \" .mini-cart-button\").addClass(\"d-none\"); // hide button\r\n $(miniCartSelector + \" .spinner\").removeClass(\"d-none\"); // show spinner\r\n }\r\n else if (what === \"hide\") {\r\n $(miniCartSelector + \" .spinner\").addClass(\"d-none\");\r\n }\r\n\r\n }\r\n\r\n return {\r\n init: init,\r\n flash: flash\r\n };\r\n});\r\n\n", "define('productDescriptionTabs/replacementParts',[\r\n],\r\nfunction () {\r\n\r\n function init() {\r\n $(\".more-replacement-parts .link\").off(\"click\").on(\"click\", showMoreReplacementParts);\r\n if ($(\".replacement-parts .part-tile\").length > partsInitiallyDisplayedOnMobile) {\r\n $(window).off(\"resize.replacementParts\").on(\"resize.replacementParts\", adjustNumberofDisplayedParts);\r\n }\r\n showMoreLinkVisible = true;\r\n currentView = views.none;\r\n adjustNumberofDisplayedParts();\r\n }\r\n\r\n function showMoreReplacementParts(event) {\r\n $(\".replacement-parts .part-tile\").removeClass(\"d-none\");\r\n $(\".more-replacement-parts\").addClass(\"d-none\");\r\n showMoreLinkVisible = false;\r\n }\r\n\r\n var views = {\r\n desktop: 1,\r\n mobile: 2,\r\n none: 3\r\n };\r\n\r\n var partsInitiallyDisplayedOnMobile = 2;\r\n var partsInitiallyDisplayedOnDesktop = 3;\r\n var showMoreLinkVisible = true;\r\n\r\n var currentView = views.none;\r\n var mobileBreakpoint;\r\n\r\n function adjustNumberofDisplayedParts(event) {\r\n if (!showMoreLinkVisible) return;\r\n\r\n var width = $(window).width();\r\n if (!mobileBreakpoint) {\r\n mobileBreakpoint = $(\".dynamic-mobile-accordion\").data(\"mobileBreakpoint\");\r\n }\r\n\r\n if (width < mobileBreakpoint && currentView !== views.mobile) {\r\n // SWITCH TO MOBILE\r\n $(\".replacement-parts .part-tile.active\").addClass(\"d-none\");\r\n $(\".replacement-parts .part-tile.active:lt(\" + partsInitiallyDisplayedOnMobile + \")\").removeClass(\"d-none\");\r\n\r\n if ($(\".replacement-parts .part-tile.active\").length > partsInitiallyDisplayedOnMobile) {\r\n $(\".more-replacement-parts\").removeClass(\"d-none\");\r\n } else {\r\n $(\".more-replacement-parts\").addClass(\"d-none\");\r\n }\r\n\r\n currentView = views.mobile;\r\n } else if (width >= mobileBreakpoint && currentView !== views.desktop) {\r\n // SWITCH TO DESKTOP\r\n $(\".replacement-parts .part-tile.active\").addClass(\"d-none\");\r\n $(\".replacement-parts .part-tile.active:lt(\" + partsInitiallyDisplayedOnDesktop + \")\").removeClass(\"d-none\");\r\n\r\n if ($(\".replacement-parts .part-tile.active\").length > partsInitiallyDisplayedOnDesktop) {\r\n $(\".more-replacement-parts\").removeClass(\"d-none\");\r\n } else {\r\n $(\".more-replacement-parts\").addClass(\"d-none\");\r\n }\r\n\r\n currentView = views.desktop;\r\n }\r\n\r\n var activePartsCount = $(\".replacement-parts .part-tile.active\").length;\r\n if (activePartsCount > 0) {\r\n $(\".more-replacement-parts .count\").text(activePartsCount);\r\n $(\".replacement-parts\").removeClass(\"d-none\");\r\n }\r\n else {\r\n $(\".replacement-parts\").addClass(\"d-none\");\r\n }\r\n \r\n }\r\n\r\n function display(variantSku) {\r\n $(\".replacement-parts .part-tile[data-related-to-variant-sku!='']\").removeClass(\"active\");\r\n $(\".replacement-parts .part-tile[data-related-to-variant-sku='\" + variantSku + \"']\").addClass(\"active\");\r\n init();\r\n }\r\n\r\n return {\r\n display: display\r\n };\r\n \r\n});\r\n\n", "define('common/spinner',[\r\n],\r\n function () {\r\n\r\n var spinnerShownAt = {};\r\n\r\n function show(spinnerSelector) {\r\n $(spinnerSelector).removeClass(\"d-none\");\r\n var image = $(spinnerSelector).find(\"img\");\r\n if (image.length) {\r\n var alt = $(image).attr(\"alt\");\r\n if (!alt)\r\n $(image).attr(\"alt\", \"Spinner\");\r\n }\r\n // mark the time when this spinner was displayed\r\n spinnerShownAt[spinnerSelector] = Date.now();\r\n }\r\n\r\n function hide(spinnerSelector, callbackWhenHidden) {\r\n // This logic ensures that the spinner is displayed for at least 500ms.\r\n // Otherwise it just flickers and that doesn't look good for the user.\r\n var waitTime = 500 - (Date.now() - spinnerShownAt[spinnerSelector]);\r\n if (waitTime > 0) {\r\n setTimeout(function () {\r\n $(spinnerSelector).addClass(\"d-none\");\r\n if (callbackWhenHidden) callbackWhenHidden();\r\n }, waitTime);\r\n }\r\n else {\r\n $(spinnerSelector).addClass(\"d-none\");\r\n if (callbackWhenHidden) callbackWhenHidden();\r\n }\r\n }\r\n\r\n function getSpinnerHtml(spinnerId) {\r\n return '
';\r\n }\r\n\r\n return {\r\n show: show,\r\n hide: hide,\r\n getSpinnerHtml: getSpinnerHtml\r\n };\r\n });\r\n\n", "define('common/formatter',[\r\n],\r\n function () {\r\n\r\n var spinnerShownAt = {};\r\n\r\n function money(someNumber, hideZeroAmount) {\r\n try {\r\n if (hideZeroAmount && someNumber == 0) return \"\";\r\n if (CP.SessionContext.SiteName === \"cpus\") {\r\n var fmtUS = new Intl.NumberFormat('en-US', {\r\n style: 'currency',\r\n currency: 'USD'\r\n });\r\n return fmtUS.format(someNumber).replace(\".00\", \"\");\r\n }\r\n }\r\n catch (error) {\r\n return someNumber;\r\n }\r\n }\r\n\r\n return {\r\n money: money\r\n };\r\n });\r\n\n", "define('ProductOptions/productOptions',[\r\n \"common/urlUtils\",\r\n \"mediaGallery/mediaGallery\",\r\n \"productDetailsAndDimensions/productDetailsAndDimensions\",\r\n \"shoppingCartIcon/shoppingCartIcon\",\r\n \"shoppingCartIcon/miniCart\",\r\n \"common/alertMessage\",\r\n \"productDescriptionTabs/replacementParts\",\r\n \"common/spinner\",\r\n \"common/formUtils\",\r\n \"common/formatter\"\r\n],\r\nfunction (urlUtils, mediaGallery, productDetailsAndDimensions, shoppingCartIcon, miniCart,\r\n alertMessage, replacementParts, spinner, formUtils, formatter) {\r\n\r\n // There can be multiple product options components on the same page.\r\n // productOptions global array will contain data for all of them.\r\n // optionsIndex variable always needs to point to the one that we're currently doing something with, so\r\n // all functions in this module can use it to get the options for the correct options component instance.\r\n // Each event handler will set that variable to the correct value (because in the event we know inside\r\n // of which product options component instance the event was fired), and the rest of the functions called\r\n // as a result of that event will then use it.\r\n // On initializations we run through all the product options component instances that exist on the page and\r\n // initialize them one by one in the loop, setting the correct value for optionsIndex variable for each step\r\n // of the loop.\r\n var optionsIndex = 0;\r\n function optionsSelector() {\r\n // this functions gives us the current product options selector\r\n return \"#product_options_\" + optionsIndex;\r\n }\r\n const allProductOptionsSelector = \"[id^=product_options_]\";\r\n\r\n const quantityInputSelector = \" .quantity-selector input\";\r\n\r\n function productOptionsElement(childElement) {\r\n poElement = $(childElement).closest(allProductOptionsSelector);\r\n return poElement.length ? poElement : null;\r\n }\r\n\r\n function init() {\r\n initEventHandlers();\r\n\r\n $(allProductOptionsSelector).each(function (i, element) {\r\n optionsIndex = $(element).data(\"optionsIndex\");\r\n disableImpossibleCombinations();\r\n displayCurrentVariant(true);\r\n // To prevent flashing of some options that will initially be hidden, we keep\r\n // the options section hidden until we do initial setup of options.\r\n // Now we're ready to show it\r\n $(optionsSelector() + \" .options\").removeClass(\"d-none\");\r\n });\r\n }\r\n\r\n\r\n function initEventHandlers() {\r\n // there are 3 types of option selector elements:\r\n $(allProductOptionsSelector+\" button.option-value\").off(\"click\").on(\"click\", buttonOptionClicked); // a set of buttons\r\n $(allProductOptionsSelector+\" .selector.option-value\").off(\"click\").on(\"click\", buttonOptionClicked); // color selector (or any other type of custom selector)\r\n $(allProductOptionsSelector+\" select.option-value\").off(\"change\").on(\"change\", listOptionChanged); // a list\r\n // and there are also som buttons:\r\n $(allProductOptionsSelector + \" button.cart\").off(\"click\").on(\"click\", addToCartClicked);\r\n $(allProductOptionsSelector + \" button.update\").off(\"click\").on(\"click\", updateCartClicked);\r\n $(allProductOptionsSelector + quantityInputSelector).off(\"quantityChanged\").on(\"quantityChanged\", quantityChanged);\r\n $(allProductOptionsSelector + \" button.remove-item\").off(\"click\").on(\"click\", removeClicked);\r\n\r\n }\r\n\r\n function buttonOptionClicked(event) {\r\n if ($(this).hasClass(\"current\")) return; // already selected\r\n\r\n optionsIndex = $(this).closest(allProductOptionsSelector).data(\"optionsIndex\");\r\n var optionData = $(this).data();\r\n changeVariant(optionData.fieldName, optionData.valueId);\r\n }\r\n\r\n function listOptionChanged(event) {\r\n optionsIndex = $(this).closest(allProductOptionsSelector).data(\"optionsIndex\");\r\n var optionData = $(this.selectedOptions[0]).data();\r\n changeVariant(optionData.fieldName, optionData.valueId);\r\n }\r\n\r\n function updateCartClicked(event) {\r\n optionsIndex = $(this).closest(allProductOptionsSelector).data(\"optionsIndex\");\r\n dispatchEvent(\"updateCart\", {\r\n oldVariantGuid: productOptions[optionsIndex].initialVariantGuid,\r\n oldQuantity: productOptions[optionsIndex].initialQuantity,\r\n newVariantGuid: productOptions[optionsIndex].currentVariant.variantGuid,\r\n newProductSku: productOptions[optionsIndex].productSku,\r\n newVariantSku: productOptions[optionsIndex].currentVariant.variantSku,\r\n newQuantity: $(optionsSelector() + quantityInputSelector).val()\r\n });\r\n }\r\n\r\n function removeClicked(event) {\r\n optionsIndex = $(this).closest(allProductOptionsSelector).data(\"optionsIndex\");\r\n elementForEvent = $(optionsSelector()).parent();\r\n $(optionsSelector()).remove();\r\n dispatchEvent(\"itemRemoved\", {\r\n productSku: productOptions[optionsIndex].productSku,\r\n variantSku: productOptions[optionsIndex].currentVariant.variantSku\r\n },\r\n elementForEvent);\r\n }\r\n\r\n function changeVariant(fieldName, newValueId) {\r\n // change selected option value\r\n var optionToChange = productOptions[optionsIndex].currentVariant.options.find(function (option) {\r\n return option.fieldName === fieldName;\r\n });\r\n optionToChange.valueId = newValueId;\r\n\r\n identifyVariant(fieldName);\r\n\r\n disableImpossibleCombinations();\r\n\r\n displayCurrentVariant();\r\n }\r\n\r\n function disableImpossibleCombinations() {\r\n enableAllValues();\r\n // go through all possible combinations of option values and disable the values that lead to impossible combinations\r\n\r\n // outer loop goes through each option one by one\r\n productOptions[optionsIndex].options.forEach(function (option) {\r\n\r\n if (option.canBeDisabled) {\r\n\r\n // then this loop goes through all the values in that option one by one\r\n option.values.forEach(function (value) {\r\n\r\n // this value goes as first into the combination to be tested\r\n var combinationToTest = [{ fieldName: option.fieldName, valueId: value.valueId }];\r\n\r\n // add the values that are currently selected for other options into the combination to be tested\r\n productOptions[optionsIndex].currentVariant.options\r\n .filter(function (o) { return o.fieldName !== option.fieldName; })\r\n .forEach(function (otherOption) {\r\n combinationToTest.push({\r\n fieldName: otherOption.fieldName,\r\n valueId: otherOption.valueId\r\n });\r\n });\r\n\r\n // now we test if that combination makes up a valid variant\r\n var variant = findVariant(combinationToTest);\r\n if (!variant) {\r\n // This is an impossible combination. Disable this value.\r\n disableValue(value.valueId);\r\n }\r\n });\r\n\r\n }\r\n\r\n });\r\n\r\n // hide option names that are left empty (with no values displayed under them)\r\n $(optionsSelector() + \" .option .option-values\").siblings(\".option-name\").addClass(\"hidden\"); // hide all\r\n $(optionsSelector() + \" .option .option-values\").has(\".option-value:not(.disabled, .d-none)\").siblings(\".option-name\").removeClass(\"hidden\"); // bring back only those that have at least one value displayed\r\n }\r\n\r\n function enableAllValues() {\r\n $(optionsSelector()+\" button.option-value\").removeClass(\"disabled\");\r\n $(optionsSelector()+\" .selector.option-value\").removeClass(\"disabled\");\r\n $(optionsSelector() + \" select.option-value option\").attr(\"hidden\", null);\r\n $(optionsSelector() + \" select.option-value option\").attr(\"disabled\", null);\r\n }\r\n\r\n function disableValue(valueId) {\r\n $(optionsSelector()+\" button.option-value[data-value-id='\" + valueId + \"']\").addClass(\"disabled\");\r\n $(optionsSelector()+\" .selector.option-value[data-value-id='\" + valueId + \"']\").addClass(\"disabled\");\r\n $(optionsSelector()+\" select.option-value option[data-value-id='\" + valueId + \"']\").attr(\"hidden\", \"\"); // in the list we're hiding the option instead of disabling it\r\n $(optionsSelector()+\" select.option-value option[data-value-id='\" + valueId + \"']\").attr(\"disabled\", \"\"); // also disable for IE\r\n }\r\n\r\n function markCurrentOptions(variantOptions) {\r\n // first unmark all\r\n $(optionsSelector()+\" button.option-value\").removeClass(\"current\");\r\n $(optionsSelector() + \" .selector.option-value\").removeClass(\"current\");\r\n $(optionsSelector() + \" select.option-value option\").removeClass(\"current\");\r\n // print layout fields\r\n $(optionsSelector() + \" .option.print-only\").removeClass(\"d-print-block\"); // hide all by default\r\n $(optionsSelector() + \" .option.print-only .display-value\").text(\"\"); // and empty them\r\n // then mark those that need to be marked\r\n variantOptions.forEach(function (option) {\r\n $(optionsSelector()+\" button.option-value[data-value-id='\" + option.valueId + \"']\").addClass(\"current\");\r\n $(optionsSelector()+\" .selector.option-value[data-value-id='\" + option.valueId + \"']\").addClass(\"current\");\r\n $(optionsSelector() + \" select.option-value:has(option[data-value-id='\" + option.valueId + \"'])\").val(option.valueId);\r\n $(optionsSelector() + \" select.option-value option[data-value-id='\" + option.valueId + \"']\").addClass(\"current\");\r\n // and set display values for print layout (only those that have values)\r\n if (option.displayValue) {\r\n var printOnlyElement = $(optionsSelector() + \" .option.print-only[data-field-name='\" + option.fieldName + \"']\");\r\n if (printOnlyElement) {\r\n $(printOnlyElement).addClass(\"d-print-block\"); // display the element\r\n $(printOnlyElement).find(\".display-value\").text(option.displayValue); // set value\r\n }\r\n }\r\n });\r\n }\r\n\r\n function identifyVariant(clickedFieldName) {\r\n // first try to find a variant that exactly matches the current set of chosen options\r\n var variant = findVariant(productOptions[optionsIndex].currentVariant.options);\r\n if (variant) {\r\n // We've found it! Just set its variantGuid and sku (the changed option is already set in changeVariant function).\r\n productOptions[optionsIndex].currentVariant.variantGuid = variant.variantGuid;\r\n productOptions[optionsIndex].currentVariant.variantSku = variant.variantSku;\r\n }\r\n else {\r\n // Find a variant that most closely matches the current set of chosen options.\r\n var rankingList = [];\r\n productOptions[optionsIndex].variants.forEach(function (variant) {\r\n var matchCount = 0;\r\n var clickedMatchCount = 0;\r\n variant.options.forEach(function (variantOption) {\r\n var matches = productOptions[optionsIndex].currentVariant.options.forEach(function (currentOption) {\r\n if (currentOption.fieldName === variantOption.fieldName && currentOption.valueId === variantOption.valueId) {\r\n matchCount++;\r\n if (variantOption.fieldName === clickedFieldName) {\r\n clickedMatchCount++;\r\n }\r\n }\r\n });\r\n });\r\n rankingList.push({ variant: variant, matchCount: matchCount, clickedMatchCount: clickedMatchCount });\r\n });\r\n // Sort the ranking list. We're favoring the variants where a clicked field matches.\r\n rankingList.sort(function (a, b) {\r\n if (b.clickedMatchCount !== a.clickedMatchCount) return b.clickedMatchCount - a.clickedMatchCount;\r\n else return b.matchCount - a.matchCount;\r\n });\r\n\r\n // Take the first variant from that list and copy all values to our currentVariant object\r\n productOptions[optionsIndex].currentVariant = {\r\n variantGuid: rankingList[0].variant.variantGuid,\r\n variantSku: rankingList[0].variant.variantSku,\r\n options: []\r\n };\r\n rankingList[0].variant.options.forEach(function (option) {\r\n productOptions[optionsIndex].currentVariant.options.push({\r\n fieldName: option.fieldName,\r\n valueId: option.valueId,\r\n displayValue: option.displayValue\r\n });\r\n });\r\n }\r\n }\r\n\r\n function findVariant(givenOptions) {\r\n // find a variant whose options all match the given set of options\r\n return productOptions[optionsIndex].variants.find(function (variant) {\r\n return givenOptions.every(function (currentOption) {\r\n return variant.options.find(function (variantOption) {\r\n return variantOption.fieldName === currentOption.fieldName\r\n && variantOption.valueId === currentOption.valueId;\r\n });\r\n });\r\n });\r\n }\r\n\r\n function findCurrentVariant() {\r\n return productOptions[optionsIndex].variants.find(function (v) {\r\n return v.variantGuid === productOptions[optionsIndex].currentVariant.variantGuid;\r\n });\r\n }\r\n\r\n function displayCurrentVariant(calledFromInit) {\r\n var variant = findCurrentVariant();\r\n if (variant) {\r\n markCurrentOptions(variant.options);\r\n $(optionsSelector()+\" .variant-item-number-itemno\").text(variant.itemNumber);\r\n $(optionsSelector() + \" .variant-price\").html(variant.price);\r\n var productAlertBlack = $(optionsSelector() + \" .product-alert-black\");\r\n if (productAlertBlack.length) productAlertBlack.html(variant.productAlert);\r\n else $(optionsSelector() + \" .product-alert-red\").html(variant.productAlert); \r\n var smallImageElement = $(optionsSelector() + \" .small-variant-image\");\r\n var currentImageUrl = $(smallImageElement).attr(\"src\");\r\n if (variant.smallVariantImageUrl !== currentImageUrl) {\r\n $(smallImageElement)\r\n .addClass(\"opacity-05\")\r\n .one(\"load\", function () { $(this).removeClass(\"opacity-05\"); })\r\n .attr(\"src\", variant.smallVariantImageUrl)\r\n .attr(\"width\", variant.smallVariantImageWidth)\r\n .attr(\"height\", variant.smallVariantImageHeight)\r\n .each(function () {\r\n // Workaround for situations where the load event doesn't get triggerred because the image is taken from cache, or the\r\n // image changes so quickly that our \"onload\" event didn't have a chance to be set up yet.\r\n setTimeout(() => { $(smallImageElement).removeClass(\"opacity-05\"); }, 2000); // just in case \"onload\" didn't do it already, we'll clear the opacity class after 2 seconds\r\n });\r\n }\r\n //$(\"#cart-quick-edit-modal .quick-edit-variant-image\").attr(\"src\", variant.quickEditVariantImageUrl);\r\n //quickEditModal.displayImage(variant.quickEditVariantImageUrl);\r\n $(optionsSelector()).data(\"variantSku\", variant.variantSku);\r\n $(optionsSelector()+\" .variant-link\").attr(\"href\", variant.variantUrl);\r\n $(optionsSelector()+\" .variant-link\").data(\"variantSku\", variant.variantSku); // this will be used by the GTM click event\r\n\r\n if (!calledFromInit) {\r\n // Recalculate price total. We don't need to do it on initialization because\r\n // everything will already be calculated in back-end.\r\n calculatePriceTotal();\r\n }\r\n\r\n if (variant.isNew) {\r\n $(optionsSelector() + \" .new-marker\").removeClass(\"d-none\");\r\n } else {\r\n $(optionsSelector() + \" .new-marker\").addClass(\"d-none\");\r\n }\r\n\r\n if (productOptions[optionsIndex].refreshOtherComponentsWhenVariantChanges) {\r\n $(\".dynamic-product-description\").html(variant.variantDescription);\r\n urlUtils.pushParamIntoLink(\"v\", variant.variantSku);\r\n mediaGallery.displayVariantImages(1, variant.variantImageId, variant.additionalVariantImages);\r\n productDetailsAndDimensions.displayVariantData(variant.variantSku);\r\n displayAccessories(variant.variantSku);\r\n replacementParts.display(variant.variantSku);\r\n }\r\n\r\n dispatchEvent(\"variantChanged\", variant);\r\n }\r\n }\r\n\r\n function dispatchEvent(eventName, eventData, eventElement) {\r\n var event;\r\n var trueTypeOf = function (obj) {\r\n return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase();\r\n };\r\n if (trueTypeOf(window.CustomEvent) === 'function') {\r\n event = new CustomEvent(eventName, {\r\n bubbles: true,\r\n detail: eventData\r\n });\r\n } else {\r\n event = document.createEvent('CustomEvent');\r\n event.initCustomEvent(eventName, true, false, eventData);\r\n }\r\n if (!eventElement) eventElement = $(optionsSelector());\r\n eventElement[0].dispatchEvent(event);\r\n $('.swiper-lazy-preloader').hide();\r\n }\r\n\r\n function quantityChanged(event) {\r\n optionsIndex = $(this).closest(allProductOptionsSelector).data(\"optionsIndex\");\r\n calculatePriceTotal();\r\n }\r\n\r\n function calculatePriceTotal() {\r\n var variant = findCurrentVariant();\r\n var priceTotalSpinner = optionsSelector() + \" .price-total-wrapper .spinner-wrapper\";\r\n spinner.show(priceTotalSpinner);\r\n var priceTotal = $(optionsSelector() + quantityInputSelector).val() * variant.priceDecimal;\r\n $(optionsSelector() + \" .price-total\").data(\"priceTotal\", priceTotal);\r\n spinner.hide(priceTotalSpinner, function () {\r\n // Doing this in the callback, so the new price is displayed when the spinner is hidden, and not before.\r\n // That looks better than showing the new value while the spinner is still spinning (because it spins for minimum of 0.5 seconds).\r\n $(optionsSelector() + \" .price-total\").html(formatter.money(priceTotal, true));\r\n });\r\n dispatchEvent(\"priceTotalChanged\");\r\n }\r\n\r\n function displayAccessories(variantSku) {\r\n $(\".product-accessories .product-options[data-related-to-variant-sku!='']\").addClass(\"d-none\");\r\n $(\".product-accessories .product-options[data-related-to-variant-sku='\" + variantSku + \"']\").removeClass(\"d-none\");\r\n if ($(\".product-accessories .product-options:not(.d-none)\").length) {\r\n // there are some accessories displayed - display the title too\r\n $(\".product-accessories-title\").removeClass(\"d-none\");\r\n }\r\n else {\r\n // there aren't any accessories displayed - hide the title too\r\n $(\".product-accessories-title\").addClass(\"d-none\");\r\n }\r\n }\r\n\r\n var itemsWithoutPrice = [];\r\n function checkIfItemHasPrice(childElement) {\r\n var poElement = productOptionsElement(childElement);\r\n if (poElement) {\r\n if ($(poElement).find(\".variant-price\").text()) return; // it's okay, it has a price\r\n // no price, put the item into the array of bad items\r\n itemsWithoutPrice.push($(poElement).find(\".variant-link\").text());\r\n }\r\n }\r\n\r\n function getQuantity(childElement) {\r\n var poElement = productOptionsElement(childElement);\r\n if (poElement) {\r\n return +$(poElement).find(quantityInputSelector).val(); // unary operator \"+\" is here to convert the value from string to number\r\n }\r\n return null;\r\n }\r\n\r\n function setQuantity(childElement, quantity, triggerChange) {\r\n var poElement = productOptionsElement(childElement);\r\n if (poElement) {\r\n var quantityInputElement = $(poElement).find(quantityInputSelector);\r\n if (quantityInputElement) {\r\n Coria.setQuantity(quantityInputElement, quantity, triggerChange);\r\n }\r\n }\r\n }\r\n\r\n function getVariantSkus(childElement) {\r\n var poElement = productOptionsElement(childElement);\r\n if (poElement) {\r\n var poIndex = $(poElement).data(\"optionsIndex\");\r\n if (poIndex) {\r\n return {\r\n productSku: productOptions[poIndex].productSku,\r\n variantSku: productOptions[poIndex].currentVariant.variantSku\r\n };\r\n }\r\n }\r\n return { productSku: null, variantSku: null };\r\n }\r\n\r\n function addToCartClicked(event) {\r\n itemsWithoutPrice = [];\r\n optionsIndex = $(this).closest(allProductOptionsSelector).data(\"optionsIndex\");\r\n var spinnerSelector = optionsSelector() + \" .spinner-wrapper\";\r\n var quantity = getQuantity(this);\r\n if (quantity != 0) {\r\n checkIfItemHasPrice(this);\r\n if (itemsWithoutPrice.length) {\r\n alertMessage.error(CP.Messages[\"Add To Cart/No Price For Product\"], null, false);\r\n }\r\n else {\r\n var skus = getVariantSkus(this);\r\n addToCart(\r\n [{\r\n ProductSku: skus.productSku,\r\n VariantSku: skus.variantSku,\r\n Quantity: quantity\r\n }],\r\n spinnerSelector\r\n );\r\n }\r\n }\r\n }\r\n\r\n function addAllToCart(listSelector, spinnerSelector) {\r\n itemsWithoutPrice = [];\r\n var addToCartButtons = $(listSelector + \" button.cart\");\r\n if (addToCartButtons.length) {\r\n var itemList = [];\r\n addToCartButtons.each(function (index, element) {\r\n var quantity = getQuantity(element);\r\n if (quantity != 0) {\r\n checkIfItemHasPrice(element);\r\n var skus = getVariantSkus(element);\r\n itemList.push({\r\n ProductSku: skus.productSku,\r\n VariantSku: skus.variantSku,\r\n Quantity: quantity\r\n });\r\n }\r\n });\r\n\r\n if (itemsWithoutPrice.length) {\r\n alertMessage.error(CP.Messages[\"Add To Cart/No Price For Product Plural\"] + itemsWithoutPrice.join(\", \"), null, false);\r\n }\r\n else {\r\n addToCart(\r\n itemList,\r\n spinnerSelector\r\n );\r\n }\r\n }\r\n\r\n }\r\n\r\n\r\n function addToCart(itemList, spinnerSelector) {\r\n if (itemList.length === 0) return;\r\n\r\n var postData = {\r\n itemList: itemList\r\n };\r\n formUtils.useToken(postData);\r\n\r\n spinner.show(spinnerSelector);\r\n\r\n $.ajax({\r\n type: \"POST\",\r\n url: \"/customapi/Order/AddToCart\",\r\n dataType: \"json\",\r\n data: postData,\r\n success: function (data) {\r\n if (data.status === \"OK\") {\r\n shoppingCartIcon.updateItemCount(data.cartItems);\r\n miniCart.flash();\r\n //gtmHelper.processCartChanges(data.changedCartItems); Google Tag Manager is not used\r\n } else if (data.status === \"ERROR\") {\r\n alertMessage.error(data.message);\r\n }\r\n },\r\n error: function (jq, status, errorThrown) {\r\n alertMessage.error(status + \": \" + errorThrown);\r\n },\r\n complete: function () {\r\n spinner.hide(spinnerSelector);\r\n }\r\n\r\n });\r\n\r\n }\r\n\r\n return {\r\n init: init,\r\n addAllToCart: addAllToCart,\r\n getVariantSkus: getVariantSkus,\r\n getQuantity: getQuantity,\r\n setQuantity: setQuantity\r\n };\r\n});\r\n\n", "require([\r\n \"ProductOptions/productOptions\"\r\n],\r\nfunction (productOptions) {\r\n\r\n productOptions.init();\r\n window.Coria = window.Coria || {};\r\n window.Coria.reInitProductOptions = productOptions.init;\r\n});\r\n\ndefine(\"ProductOptions/main\", function(){});\n\n" ] }