{"version":3,"sources":["../../../../../Foundation/JavascriptCommon/code/scripts/common/urlUtils.js","ProductCategoryBanner/main.js"],"names":["define","parseQueryParamsFromUrl","url","window","location","search","query","decomposeUrl","indexOf","substring","match","urlParams","decode","s","decodeURI","decodeURIComponent","exec","path","hash","putParamIntoUrl","paramName","paramValue","urlComp","encodeURIComponent","getParamFromUrl","pushParamIntoLink","domElement","$","attr","href","params","p","toLowerCase","newSearchString","param","newHref","history","pushState","replaceState","popParamFromLink","retVal","require","urlUtils","displayVideo","event","preventDefault","toggleClass","videoElement","src","data","off","on"],"mappings":"AAAAA,OAAA,qBAEA,WAKA,QAAAC,GAAAC,GACAA,EAAAA,GAAAC,OAAAC,SAAAC,MAEA,IAAAC,GAAAC,EAAAL,GAAAG,MACAC,GAAAE,QAAA,MAAA,IAAAF,EAAAA,EAAAG,UAAAH,EAAAE,QAAA,KAAA,GAMA,KALA,GACAE,GADAC,KAEAN,EAAA,qBACAO,EAAA,SAAAC,GAAA,MAAAC,WAAAC,mBAAAF,KAEAH,EAAAL,EAAAW,KAAAV,IACAK,EAAAC,EAAAF,EAAA,KAAAE,EAAAF,EAAA,GAEA,OAAAC,GAOA,QAAAJ,GAAAL,GACA,GAAAe,GAAA,GACAZ,EAAA,GACAa,EAAA,EAkBA,OAjBAhB,GAAAM,QAAA,MAAA,GAEAS,EAAAf,EAAAO,UAAA,EAAAP,EAAAM,QAAA,MACAH,EAAAH,EAAAO,UAAAP,EAAAM,QAAA,MACAH,EAAAG,QAAA,MAAA,IAEAU,EAAAb,EAAAI,UAAAJ,EAAAG,QAAA,MACAH,EAAAA,EAAAI,UAAA,EAAAJ,EAAAG,QAAA,QAEAN,EAAAM,QAAA,MAAA,GAAAN,EAAAM,QAAA,MAAAN,EAAAM,QAAA,OAEAS,EAAAf,EAAAO,UAAA,EAAAP,EAAAM,QAAA,MACAU,EAAAhB,EAAAO,UAAAP,EAAAM,QAAA,OAGAS,EAAAf,GAAA,IAGAe,KAAAA,EACAZ,OAAAA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,EAAA,IAAAX,EAAAJ,IACAS,GAAAD,GAAAE,KAAA,OAAAO,OAEAC,UAAAA,QAAAC,WAEAD,QAAAE,aACA,KACA,KACAhB,EAAAL,MACAgB,EAAA,IAAAA,EAAA,IACAX,EAAAJ,MAKA,MAAAsB,GAIA,OACAvC,wBAAAA,EACAM,aAAAA,EACAY,gBAAAA,EACAK,gBAAAA,EACAC,kBAAAA,EACAc,iBAAAA,KAIAE,SCzKA,mBAEA,SAAAC,GAMA,QAAAC,GAAAC,GAEAA,EAAAC,iBAEAlB,EAAA,oEAAAmB,YAAA,SAEA,IAAAC,GAAApB,EAAA,yCACAoB,GAAA,GAAAC,IAAAN,EAAAvB,gBAAA,WAAA,IAAA4B,EAAAE,KAAA,SAXA,WACAtB,EAAA,+CAAAuB,IAAA,SAAAC,GAAA,QAAAR,QAiBA3C,OAAA,6BAAA","file":"ProductCategoryBanner.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","require([\r\n \"common/urlUtils\"\r\n],\r\n function (urlUtils) {\r\n\r\n function initClickHandlers() {\r\n $(\".product-category-banner .banner-video-text\").off(\"click\").on(\"click\", displayVideo);\r\n }\r\n\r\n function displayVideo(event) {\r\n\r\n event.preventDefault();\r\n\r\n $(\".product-category-banner .banner-image,.banner-video-text,.video\").toggleClass(\"d-none\");\r\n\r\n var videoElement = $(\".product-category-banner .video iframe\");\r\n videoElement[0].src = urlUtils.putParamIntoUrl(\"autoplay\", \"1\", videoElement.data(\"src\"));\r\n\r\n }\r\n\r\n initClickHandlers();\r\n });\r\n\ndefine(\"ProductCategoryBanner/main\", function(){});\n\n"]}