(function() { function bxBootstrap() { var re = /bot|crawl|slurp|spider|mediapartners|headlesschrome|snap-prefetch|remotasks|woorank|uptime\.com|facebookexternalhit|facebookcatalog/i; if (re.test(navigator.userAgent) || navigator.userAgent == '') { return; } if (!(window.bouncex&&bouncex.website)) { var pushedData = []; if(window.bouncex && bouncex.push && bouncex.length){ pushedData = bouncex; } window.bouncex = {}; bouncex.pushedData = pushedData; bouncex.website = {"id":2510,"name":"Ray-Ban UK","cookie_name":"bounceClientVisit2510","domain":"ray-ban.comuk","ct":"fp_local_storage","ally":0,"ei":0,"tcjs":"","cjs":"window.top.bouncex.tealiumTracker = function(campaignName, parentName, eventType) {\n\tvar tealium_data2track = window.top.tealium_data2track || [];\n\tvar speakingString = 'X-X-X-BounceX-'+ eventType;\n\ttealium_data2track.push({\n\t\t'id': speakingString,\n\t\t'Content_TestCampaign': parentName,\n\t\t'Content_TestVariation': campaignName\n\t});\n};\n\n/* https://www.wrike.com/open.htm?id=439784749 */\nwindow.top.bouncex.tealiumTrackerV2 = function(ca_id, eventType) {\n var campaign = bouncex.campaigns[ca_id];\n\tvar campaignLabel = campaign.ga_i.label.toLowerCase();\n\tvar childString = '';\n\tvar parentString = '';\n\n\tif (campaignLabel.indexOf('email capture') > -1 || campaignLabel.indexOf('capture email') > -1) {\n\t parentString += 'emailCapture ';\n\t} else if (campaignLabel.indexOf('cart') > -1) {\n\t parentString += 'cartRecovery ';\n\t} else if (campaignLabel.indexOf('checkout') > -1) {\n\t parentString += 'checkoutShaping ';\n\t} else {\n\t parentString += 'Campaign ';\n\t}\n\n\tparentString += campaignLabel.indexOf('mobile') > -1 ? 'M ' : 'D ';\n\tparentString += '('+campaign.pid+')';\n\n\tchildString += campaign.ttype === 'variation' ? 'variation ' : 'control ';\n\tchildString += '('+ca_id+')';\n\t\n\tvar tealium_data2track = window.top.tealium_data2track || [];\n\tvar speakingString = 'Bounce-'+ eventType;\n\t\n\ttealium_data2track.push({\n\t\t'id': speakingString,\n\t\t'Tool_Name_Abbreviation': 'BO',\n\t\t'Content_TestCampaign': parentString,\n\t\t'Content_TestVariation': childString\n\t});\n};\n\njQuery('body').on('click.bx-cart_total', '#M_PDP_Prod_BuyNow, #addCartButton', function() {\n try {\n var new_total = Number(bouncex.vars.cart_total) + (Number(jQuery('.previewPrice').text().replace(/[^0-9\\\\.]/g,'')) || Number(jQuery('#priceField').text().replace(/[^0-9\\\\.]/g,'')));\n bouncex.setv('cart_total', new_total);\n bouncex.setBounceCookie();\n } catch(e) {\n\t\tbouncex.err(e);\n\t}\n});\n\n\n// if ( bouncex.vars.ibx_test ) {\n// DAF copied from ray-ban usa, has a mobile identifier for different tracking\n(function () {\n\twindow.bouncex = window.bouncex || {};\n\n\twindow.bouncex.bxISR = {\n\t\t/* --- INITIALIZATION --- */\n\t\tversion: 'Version 8.1 | 1/4/17',\n\t\tstartTime: Date.now(),\n\t\tsettings: {\n\t\t\tcurrentProduct: {},\n\t\t\tgeneral: {\n\t\t\t\tproductPageIdentifier: window.location.href.indexOf('customize') === -1 && jQuery('meta[property=\"og:type\"]').length > 0 && jQuery('meta[property=\"og:type\"]').attr('content') === 'product',\n\t\t\t\tmobilePageIdentifier: window.location.href.indexOf('/mobile') > -1 && window.location.href.indexOf('customize') === -1 && window.location.href.indexOf('virtual-try-on') === -1 && (jQuery('#pdp').length > 0 || jQuery('#producttype').length > 0 && jQuery('#producttype').val() !== 'Home'),\n\t\t\t\tmaxProducts: 20,\n\t\t\t\tcategoryHistory: JSON.parse(window.localStorage.getItem('bxCatHist')) || [],\n\t\t\t\tproductHistory: JSON.parse(window.localStorage.getItem('bxProdHist')) || [],\n\t\t\t\tcategoryHistoryLength: 0,\n\t\t\t\tproductHistoryLength: 0\n\t\t\t}\n\t\t},\n\n\t\tinit: function () {\n\t\t\tthis.productMap();\n\t\t\tthis.setItemHistoryLengths();\n\t\t\tthis.trackProductHistory();\n\t\t\tthis.trackCategoryHistory();\n\t\t\tthis.maxProducts();\n\t\t// \tconsole.log(Date.now() - window.bouncex.bxISR.startTime, 'bxISR start');\n\t\t},\n\n\t\tproductMap: function () {\n\t\t\tvar productValues;\n\t\t\tif ( this.settings.general.mobilePageIdentifier) {\n\t\t\t\tvar imgUrl = jQuery('#main-image-container .wcs-main-image:visible').length > 0? jQuery('#main-image-container .wcs-main-image:visible').attr('src').split('?')[0].replace(/fr$/, 'qt') : '',\n\t\t\t\t\tcategory = window.location.href.match(/mobile\\/(.+?)\\//);\n\t\t\t\tproductValues = {\n\t\t\t\t\turl: jQuery('link[rel=canonical]').length > 0 ? jQuery('link[rel=canonical]').attr('href') : window.location.href.split('?')[0],\n\t\t\t\t\tname: jQuery('#productName').val().toUpperCase(),\n\t\t\t\t\tsku: jQuery('#parentPartNumber').val() || window.location.href.split('?')[0].match(/\\d+$/)[0],\n\t\t\t\t\tcategory: [{ categoryName: category, categoryUrl: 'http://www.ray-ban.com/usa/mobile/' + category + '/clp'}],\n\t\t\t\t\tdescription: jQuery('#wcs-product-details-overlay .wcs-half-top').text().trim(),\n\t\t\t\t\tprice: jQuery('.previewPrice').text().replace(/[^0-9.]/g, ''),\n\t\t\t\t\tmainImgUrl: imgUrl.indexOf('http') > -1 ? imgUrl : 'http:' + imgUrl,\n\t\t\t\t\ttimeStamp: Date.now(),\n\t\t\t\t\tviewCount: 1,\n\t\t\t\t\tsessionId: window.bouncex.cookie.vid\n\t\t\t\t};\n\t\t\t} else if (this.settings.general.productPageIdentifier){\n\t\t\t \n\t\t\tvar imgUrlProd = jQuery('#main-image-container .wcs-main-image:visible').length > 0? jQuery('#main-image-container .wcs-main-image:visible').attr('src').split('?')[0].replace(/fr$/, 'qt') : '';\n\t\t\t\tvar $category = jQuery('.breadCrumbLabel:eq(-1)');\n\t\t\t\tproductValues = {\n\t\t\t\t\turl: jQuery('link[rel=canonical]').attr('href'),\n\t\t\t\t\tname: jQuery('#productName').val().toUpperCase(),\n\t\t\t\t\tsku: jQuery('[itemprop=productID]').text() || window.location.href.split('?')[0].match(/\\d+$/)[0],\n\t\t\t\t\tcategory: [{ categoryName: $category.text().trim().toLowerCase(), categoryUrl: $category.parent().attr('href') }],\n\t\t\t\t\tdescription: jQuery('.more-block .wcs-half-top').text().trim(),\n\t\t\t\t\tprice: jQuery('#wcs-productprice').text().replace(/[^0-9.]/g, ''),\n\t\t\t\t\tmainImgUrl: window.location.protocol+ imgUrlProd,\n\t\t\t\t\ttimeStamp: Date.now(),\n\t\t\t\t\tviewCount: 1,\n\t\t\t\t\tsessionId: window.bouncex.cookie.vid\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.settings.currentProduct = productValues;\n\t\t},\n\n\t\t/* --- END OF INITIALIZATION --- */\n\t\t/* --- HELPER FUNCTIONS --- */\n\n\t\taddProductToHistory: function (product) {\n // updated so that it does not track items without needed info \n\t\t if(product.url !== undefined && product.mainImgUrl !== \"http:\"){\n\t\t \tvar productHistory = this.settings.general.productHistory;\n\t\t \tproductHistory.unshift(product);\n\t\t \tthis.setProductHistory(productHistory);\n\t\t }\n\t\t},\n\n\t\taddCategoryToHistory: function (currentCategory) {\n\t\t\tvar categoryHistory = this.settings.general.categoryHistory;\n\t\t\tvar newCategory = {\n\t\t\t\tcategory: currentCategory,\n\t\t\t\tviewCount: 1,\n\t\t\t\ttimeStamp: Date.now()\n\t\t\t};\n\n\t\t\tcategoryHistory.unshift(newCategory);\n\t\t\twindow.bouncex.bxISR.setCategoryHistory(categoryHistory);\n\t\t},\n\n\t\tcompareProducts: function (productA, productB) {\n\t\t\tif (productA.mainImgUrl === productB.mainImgUrl) { return true; }\n\t\t\tif (productA.sku === productB.sku) { return true; }\n\t\t\tif (productA.name === productB.name) { return true; }\n\t\t\tif (productA.url === productB.url) { return true; }\n\t\t\treturn false;\n\t\t},\n\n\t\ttrackProductHistory: function () {\n\t\t\tvar productHistory = this.settings.general.productHistory;\n\t\t\tif (!this.settings.general.productPageIdentifier && !this.settings.general.mobilePageIdentifier) { return; }\n\n\t\t\tif (this.settings.general.productHistoryLength > 0) {\n\t\t\t\tvar historyUpdated = false;\n\n\t\t\t\tfor (var i = 0; i < this.settings.general.productHistoryLength; i++) {\n\t\t\t\t\tif (this.compareProducts(productHistory[i], this.settings.currentProduct)) {\n\t\t\t\t\t\tproductHistory[i].viewCount++;\n\t\t\t\t\t\tproductHistory[i].timeStamp = Date.now();\n\t\t\t\t\t\tproductHistory.unshift(productHistory[i]);\n\n\t\t\t\t\t\tproductHistory.splice(i + 1, 1);\n\t\t\t\t\t\thistoryUpdated = true;\n\t\t\t\t\t\tthis.setProductHistory(productHistory);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!historyUpdated) {\n\t\t\t\t\tthis.addProductToHistory(this.settings.currentProduct);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.addProductToHistory(this.settings.currentProduct);\n\t\t\t}\n\t\t},\n\n\t\ttrackCategoryHistory: function () {\n\t\t\tvar categoryHistory = this.settings.general.categoryHistory;\n\t\t\tif (!this.settings.general.productPageIdentifier && !this.settings.general.mobilePageIdentifier) { return; }\n\n\t\t\tvar currentCategoriesLength = this.settings.currentProduct.category.length;\n\t\t\tfor (var i = 0; i < currentCategoriesLength; i++) {\n\t\t\t\tvar currentCategory = this.settings.currentProduct.category[i];\n\n\t\t\t\tif (this.settings.general.categoryHistoryLength > 0) {\n\t\t\t\t\tvar historyUpdated = false;\n\t\t\t\t\tfor (var j = 0; j < this.settings.general.categoryHistoryLength; j++) {\n\t\t\t\t\t\tif (categoryHistory[j].category.categoryName === currentCategory.categoryName) {\n\t\t\t\t\t\t\tcategoryHistory[j].viewCount++;\n\t\t\t\t\t\t\tcategoryHistory[j].timeStamp = Date.now();\n\t\t\t\t\t\t\thistoryUpdated = true;\n\t\t\t\t\t\t\tthis.setCategoryHistory(categoryHistory);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!historyUpdated) {\n\t\t\t\t\t\tthis.addCategoryToHistory(currentCategory);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.addCategoryToHistory(currentCategory);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t/* --- END OF HELPER FUNCTIONS --- */\n\t\t/* --- GETTER FUNCTIONS --- */\n\n\t\tgetTopCategories: function (criteria, number) {\n\t\t\tvar categories = this.settings.general.categoryHistory;\n\t\t\tif (!number) { number = categories.length; }\n\n\t\t\tif (criteria === 'views') {\n\t\t\t\treturn categories.sort(function (a, b) { return b.viewCount - a.viewCount; }).slice(0, number);\n\t\t\t} else if (criteria === 'time') {\n\t\t\t\treturn categories.sort(function (a, b) { return b.timeStamp - a.timeStamp; }).slice(0, number);\n\t\t\t} else if (criteria === 'recency') {\n\t\t\t\treturn categories.sort(function (a, b) { return b.viewCount - a.viewCount; }).slice(0, number).sort(function (c, d) { return d.timeStamp - c.timeStamp; });\n\t\t\t}\n\t\t},\n\n\t\tgetTopProducts: function (criteria, number) {\n\t\t\tvar products = this.settings.general.productHistory;\n\t\t\tif (!number) { number = products.length; }\n\t\t\tif (criteria === 'views') {\n\t\t\t\treturn products.sort(function (a, b) { return b.viewCount - a.viewCount; }).slice(0, number);\n\t\t\t} else if (criteria === 'time') {\n\t\t\t\treturn products.sort(function (a, b) { return b.timeStamp - a.timeStamp; }).slice(0, number);\n\t\t\t} else if (criteria === 'recency') {\n\t\t\t\treturn products.sort(function (a, b) { return b.viewCount - a.viewCount; }).slice(0, number).sort(function (c, d) { return d.timeStamp - c.timeStamp; });\n\t\t\t}\n\t\t},\n\n\t\tmaxProducts: function () {\n\t\t\tvar maxProducts = this.settings.general.maxProducts;\n\t\t\tif (this.settings.general.productHistoryLength > maxProducts) {\n\t\t\t\tvar topProducts = this.getTopProducts('time', maxProducts);\n\t\t\t\tthis.setProductHistory(topProducts);\n\t\t\t}\n\t\t},\n\n\t\t/* --- END GETTER FUNCTIONS --- */\n\t\t/* --- SETTER FUNCTIONS --- */\n\n\t\tsetItemHistoryLengths: function () {\n\t\t\tthis.settings.general.categoryHistoryLength = this.settings.general.categoryHistory.length;\n\t\t\tthis.settings.general.productHistoryLength = this.settings.general.productHistory.length;\n\t\t},\n\n\t\tsetProductHistory: function (productHistory) {\n\t\t\twindow.localStorage.setItem('bxProdHist', JSON.stringify(productHistory));\n\t\t\tthis.settings.general.productHistory = productHistory;\n\t\t\tthis.settings.general.productHistoryLength = productHistory.length;\n\t\t},\n\n\t\tsetCategoryHistory: function (categoryHistory) {\n\t\t\twindow.localStorage.setItem('bxCatHist', JSON.stringify(categoryHistory));\n\t\t\tthis.settings.general.categoryHistory = categoryHistory;\n\t\t\tthis.settings.general.categoryHistoryLength = categoryHistory.length;\n\t\t},\n\n\t\t/* --- END SETTER FUNCTIONS --- */\n\t\t/* --- CAMPAIGN TEMPLATING --- */\n\n\t\tpopulateCampaignProductsV2: function (params) {\n\t\t\tif (!params || !params.campaignId || !params.numberProducts) { return false; }\n\t\t\tif (!params.sortBy) { params.sortBy = 'time'; }\n\t\t\tif (!params.productAction) { params.productAction = 'link'; }\n\t\t\tif (!params.linkAction) { params.linkAction = 'new'; }\n\n\t\t\tvar campaign = jQuery('#bx-campaign-' + params.campaignId);\n\t\t\tvar campaignProductArray = [];\n\n\t\t\tcampaignProductElements = {};\n\t\t\tjQuery.each(params.campaignSteps, function (x, y) {\n\n\t\t\t\tcampaignStepProductElements = [];\n\t\t\t\tfor ( var i = 0; i < params.numberProducts; i++ ) {\n\t\t\t\t\tvar campaignStepProductObject = {};\n\t\t\t\t\tif (y.productImages) {\n\t\t\t\t\t\tcampaignStepProductObject.img = campaign.find('#bx-form-' + params.campaignId + '-step-' + y.stepNumber + ' .bx-row-line-custom .bx-lineshape:eq(' + i +')');\n\t\t\t\t\t}\n\t\t\t\t\tif (y.productLinkElems) {\n\t\t\t\t\t\t// campaignStepProductObject.link = campaign.find('#bx-form-' + params.campaignId + '-step-' + y.stepNumber + ' .bx-group .bx-row-submit:eq('+i+')').find('button');\n\t\t\t\t\t\tcampaignStepProductObject.link = campaign.find('#bx-form-' + params.campaignId + '-step-' + y.stepNumber + ' .bx-group-custom:eq('+i+')');\n\t\t\t\t\t}\n\t\t\t\t\tif (y.productHoverStates) {\n\t\t\t\t\t\tcampaignStepProductObject.hoverTitle = campaign.find('#bx-form-' + params.campaignId + '-step-' + y.stepNumber + ' .bx-group .bx-row-line-custom:eq(' + i +')').siblings('.bx-row-text').find('div');\n\t\t\t\t\t}\n\t\t\t\t\tcampaignStepProductElements.push(campaignStepProductObject);\n\t\t\t\t}\n\n\t\t\t\tcampaignProductElements['step-' +x] = campaignStepProductElements;\n\t\t\t});\n\n\t\t\tvar productArray = window.bouncex.bxISR.getTopProducts(params.sortBy, params.numberProducts);\n\n\t\t\tvar self = this;\n\t\t\tjQuery.each(campaignProductElements, function (x, y) {\n\t\t\t\tvar productAction = function () {};\n\n\t\t\t\tfor ( var i = 0; i < y.length; i++ ) {\n\t\t\t\t\tif (params.campaignSteps[(x.split('-')[1])].productsLink) {\n\t\t\t\t\t\tvar productLink = (productArray[i].url.indexOf('http') > -1) ? productArray[i].url : window.top.location.origin + productArray[i].url;\n\t\t\t\t\t\tproductAction = self.makeProductAction(productLink, params);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (y[i].img) {\n\t\t\t\t\t\tvar imgSrc = productArray[i].mainImgUrl,\n\t\t\t\t\t\t\tproductImageElem = jQuery(y[i].img);\n\n\t\t\t\t\t\tproductImageElem.css('background-image', 'url(' + imgSrc + ')').addClass('isr-image isr' + x + '').bind('click.bx_' + params.campaignId + '_isr_' + i, productAction);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (y[i].link) {\n\t\t\t\t\t\tvar productLink = (productArray[i].url.indexOf('http') > -1) ? productArray[i].url : window.top.location.origin + productArray[i].url,\n\t\t\t\t\t\t\tproductLinkElem = jQuery(y[i].link);\n\n\t\t\t\t\t\tproductLinkElem.attr('bx-href', productLink).bind('click.bx_' + params.campaignId + '_isr_' + i, productAction);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (y[i].hoverTitle) {\n\t\t\t\t\t\tvar productTitle = productArray[i].name,\n\t\t\t\t\t\t\tproductHoverTitleElem = jQuery(y[i].hoverTitle);\n\n\t\t\t\t\t\tproductHoverTitleElem.text(productTitle).bind('click.bx_' + params.campaignId + '_isr_' + i, productAction);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t});\n\t\t},\n\n\t\tmakeProductAction: function (productLink, campaignParams) {\n\t\t\tvar productAction = function () {};\n\n\t\t\t\tif (campaignParams.productAction === 'link') {\n\t\t\t\t\tif (campaignParams.linkAction === 'new') {\n\t\t\t\t\t\tif (campaignParams.reportClicks) {\n\t\t\t\t\t\t\tproductAction = function () {\n\t\t\t\t\t\t\t\twindow.bouncex.report(campaignParams.campaignId, 'click');\n\t\t\t\t\t\t\t\twindow.top.open(productLink);\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tproductAction = function () {\n\t\t\t\t\t\t\t\twindow.top.open(productLink);\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (campaignParams.linkAction === 'current') {\n\t\t\t\t\t\tif (campaignParams.reportClicks) {\n\t\t\t\t\t\t\tproductAction = function () {\n\t\t\t\t\t\t\t\twindow.bouncex.report(campaignParams.campaignId, 'click');\n\t\t\t\t\t\t\t\tsetTimeout(function() {\n\t\t\t\t\t\t\t\t\twindow.top.location.replace(productLink);\n\t\t\t\t\t\t\t\t}, 100);\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tproductAction = function () {\n\t\t\t\t\t\t\t\twindow.top.location.replace(productLink);\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\treturn productAction;\n\t\t}\n\t};\n\t\n setTimeout(function(){\n \twindow.bouncex.bxISR.init();\n },3000);\n})();\n// }\n\nwindow.top.bouncex.md5 = function(inputString) {\n var hc=\"0123456789abcdef\";\n function rh(n) {var j,s=\"\";for(j=0;j<=3;j++) s+=hc.charAt((n>>(j*8+4))&0x0F)+hc.charAt((n>>(j*8))&0x0F);return s;}\n function ad(x,y) {var l=(x&0xFFFF)+(y&0xFFFF);var m=(x>>16)+(y>>16)+(l>>16);return (m<<16)|(l&0xFFFF);}\n function rl(n,c) {return (n<>>(32-c));}\n function cm(q,a,b,x,s,t) {return ad(rl(ad(ad(a,q),ad(x,t)),s),b);}\n function ff(a,b,c,d,x,s,t) {return cm((b&c)|((~b)&d),a,b,x,s,t);}\n function gg(a,b,c,d,x,s,t) {return cm((b&d)|(c&(~d)),a,b,x,s,t);}\n function hh(a,b,c,d,x,s,t) {return cm(b^c^d,a,b,x,s,t);}\n function ii(a,b,c,d,x,s,t) {return cm(c^(b|(~d)),a,b,x,s,t);}\n function sb(x) {\n var i;var nblk=((x.length+8)>>6)+1;var blks=new Array(nblk*16);for(i=0;i>2]|=x.charCodeAt(i)<<((i%4)*8);\n blks[i>>2]|=0x80<<((i%4)*8);blks[nblk*16-2]=x.length*8;return blks;\n }\n var i,x=sb(\"\"+inputString),a=1732584193,b=-271733879,c=-1732584194,d=271733878,olda,oldb,oldc,oldd;\n for(i=0;i -1 &&\r\n jQuery('html').attr('lang').indexOf(config.lang) > -1\r\n );\r\n}\r\n\r\nfunction isValidForTracking() {\r\n return (\r\n currentUrl.indexOf('/gift-cards') < 0 &&\r\n currentUrl.indexOf(config.tracking_country_path) > -1\r\n );\r\n}\r\n\r\nfunction getToken() {\r\n return bouncex.getBounceCookie(config.cookie);\r\n}\r\n\r\nfunction setVarAndCookie(varName, value) {\r\n bouncex.setVar(varName, value);\r\n bouncex.setBounceCookie();\r\n return;\r\n}\r\n\r\nfunction getIdFromUrl(url) {\r\n return url.split('/').pop();\r\n}\r\n\r\nfunction getGroupId() {\r\n var dataPdpObj = bouncex.parseJSON(jQuery('#data_pdp').first().text()) || {};\r\n return bouncex.utils.getNestedProp('resolvedSkuGridLensBridgeVal', '', dataPdpObj);\r\n}\r\n\r\n// ---- ITEM META DATA ---- //\r\n\r\nfunction getItemCopy() {\r\n return (\r\n jQuery('.rb-pdp-title').text().trim() ||\r\n jQuery('.fc-product-name').text().trim() ||\r\n jQuery('.fc-mobile-model-name').text().trim() ||\r\n jQuery('h1.rb-product-name').text().trim()\r\n );\r\n}\r\n\r\nfunction getItemCategory() {\r\n if (isCustomItem()) {\r\n return 'custom';\r\n }\r\n return (\r\n jQuery('.rb-breadcrumb.rb-child').eq(-2).text().trim() ||\r\n jQuery('#productTypeKeywordVal').val() ||\r\n jQuery('.category-name').text() ||\r\n 'Global'\r\n );\r\n}\r\n\r\nfunction getItemImage() {\r\n var imageUrl =\r\n jQuery('.images-slide.current img').attr('data-src') ||\r\n jQuery('.swiper-slide.image-gallery.swiper-slide-active img, .rb-images-grid__image:visible img').attr('src') ||\r\n jQuery('[property=\"og:image\"]').attr('content') ||\r\n jQuery('.rb-pdp-page .rb-product-images picture source,.rb-pdp-page .rb-product-images picture img').attr('src') || \r\n jQuery('[property=\"og:image\"]').attr('content') ||\r\n '';\r\n \r\n // imageUrl = imageUrl.split('__')[0] + '__001.png';\r\n\r\n if (isCustomItem()) {\r\n imageUrl = jQuery('.fc-focused-image-preloader').attr('src') || '';\r\n }\r\n\r\n if (!imageUrl) {\r\n return;\r\n }\r\n\r\n imageUrl =\r\n imageUrl.indexOf(window.location.protocol) > -1\r\n ? imageUrl\r\n : window.location.protocol + imageUrl;\r\n\r\n return bouncex.utils.url.allowParams('', imageUrl);\r\n}\r\n\r\nfunction itemInStock() {\r\n return (\r\n !jQuery('.rb-pdp-sticky-bar-mobile__not-available').length ||\r\n jQuery('button[data-element-id=\"X_Pdp_Stickybar_AddCart\"]')\r\n .text()\r\n .indexOf('ADD TO BAG') > -1\r\n );\r\n}\r\n\r\nfunction getItem() {\r\n var url = bouncex.utils.url.allowParams();\r\n return {\r\n id: getIdFromUrl(url),\r\n copy: getItemCopy(),\r\n category: getItemCategory(),\r\n url: url,\r\n imageurl: getItemImage(),\r\n instock: itemInStock(),\r\n };\r\n}\r\n\r\nfunction viewItem(itemId) {\r\n bouncex.push([\r\n 'view item',\r\n {\r\n 'item:id': itemId,\r\n 'item:itemgroupid': getGroupId()\r\n },\r\n ]);\r\n}\r\n\r\nfunction fireItemEvents(item) {\r\n viewItem(item.id);\r\n\r\n if (\r\n !isCustomItem() ||\r\n (isCustomItem() && isValidCustomImageFromMap(item.id, item.imageurl))\r\n ) {\r\n bouncex.push(['item', item]);\r\n }\r\n}\r\n\r\nfunction isCustomItem() {\r\n return currentUrl.indexOf('/customize') > -1;\r\n}\r\n\r\nfunction isValidCustomImageFromMap(itemId, imageUrl) {\r\n var recipe = customItemImageMap[itemId],\r\n recipeParam = bouncex.utils.url.getParam('recipe', imageUrl),\r\n decodedParam = recipeParam.replace(/[^\\d.-]|-/g, '');\r\n\r\n return decodedParam.indexOf(recipe) > -1;\r\n}\r\n\r\n/* ------------------------------ SKU TRACKING ------------------------------ */\r\nfunction initializeSkuEvents(itemId) {\r\n bouncex.push([\r\n 'select_sku',\r\n {\r\n 'item:id': itemId,\r\n 'item:itemgroupid': getGroupId(),\r\n 'item:feedid': itemId\r\n }\r\n ]);\r\n}\r\n\r\n// ---- CATEGORY META DATA ---- //\r\n\r\nfunction getCategoryPageTitle() {\r\n return (\r\n jQuery('.rb-page-title').text() ||\r\n bouncex.utils.getNestedProp('boxes_config.pageName')\r\n );\r\n}\r\n\r\nfunction getCategoryIds() {\r\n var selectors = '.rb-plp-product-tile__container, .rbBox.striked a';\r\n\r\n return jQuery(selectors)\r\n .map(function () {\r\n var url = jQuery(this).attr('href') || '',\r\n itemId = getIdFromUrl(url);\r\n\r\n if (itemId) {\r\n return itemId;\r\n }\r\n })\r\n .toArray()\r\n .join(',');\r\n}\r\n\r\nfunction getCategoryObj() {\r\n return {\r\n 'page:title': getCategoryPageTitle(),\r\n 'page:url': currentUrl,\r\n 'items:ids': getCategoryIds(),\r\n };\r\n}\r\n\r\nfunction fireViewCategory(catObj) {\r\n bouncex.push([\r\n 'view category',\r\n {\r\n 'items:ids': catObj.ids,\r\n 'page:url': catObj.url,\r\n 'page:title': catObj.title,\r\n },\r\n ]);\r\n return;\r\n}\r\n\r\n// ---- CART TRACKING ---- //\r\nfunction trackCustomCart() {\r\n bouncex.on(jQuery(document), 'ajaxComplete', function (e, x, settings) {\r\n if (\r\n settings.url.indexOf('/remix/add-to-cart') > -1 &&\r\n settings.type === 'POST'\r\n ) {\r\n var recipeId = JSON.parse(settings.data).recipeId,\r\n url;\r\n\r\n if (recipeId) {\r\n url = currentUrl + '?recipeId=' + recipeId;\r\n\r\n bouncex.push([\r\n 'custom add',\r\n {\r\n 'item:id': bouncex.vars.item_id,\r\n 'item:customurl': url,\r\n },\r\n ]);\r\n }\r\n\r\n bouncex.push(['add to cart', { 'item:id': bouncex.vars.item_id }]);\r\n setVarAndCookie('cart_set', true);\r\n }\r\n });\r\n}\r\n\r\nfunction getItemDetails() {\r\n var len = bouncex.utils.getNestedProp('dataLayer',[]).length,\r\n details;\r\n\r\n for (let i = len - 1; i > -1; i--) {\r\n let data = dataLayer[i];\r\n\r\n if (data.length > 2 && data[1] === 'add_to_cart' && data[2].items) {\r\n details = data[2].items[0];\r\n break;\r\n }\r\n }\r\n\r\n return details;\r\n}\r\n\r\nfunction addToCart() {\r\n if (isCustomItem()) {\r\n trackCustomCart();\r\n return;\r\n }\r\n\r\n bouncex.et.onVisible('.rb-sidebar-content__top-section:contains(\"ADDED TO BAG\"), .rb-minicart-container:contains(\"ADDED TO BAG\"), .rb-minicart-content__title .common__icon--circle-check', function () {\r\n var details = getItemDetails() || {};\r\n \t\tvar itemId = bouncex.vars.item_id,\r\n replenItem = {\r\n catalogId: jQuery('#catalogId').val(),\r\n storeId: jQuery('#storeId').val(),\r\n langId: jQuery('#langId').val(),\r\n catEntryId: details.products_moco || jQuery('#catEntryId').val(),\r\n quantity: 1,\r\n };\r\n \r\n bouncex.push([\r\n 'add to cart',\r\n {\r\n 'item:id': itemId,\r\n 'cart:item': JSON.stringify(replenItem),\r\n },\r\n ]);\r\n setVarAndCookie('cart_set', true);\r\n \t});\r\n \r\n}\r\n\r\nfunction emptyCart() {\r\n if (bouncex.vars.cart_set && bouncex.vars.items_in_cart === 0) {\r\n bouncex.push(['empty_cart']);\r\n setVarAndCookie('cart_set', false);\r\n }\r\n}\r\n\r\nfunction replenish(cart) {\r\n var replenishmentUrl = 'https://www.ray-ban.com/AjaxOrderItemAdd',\r\n $deferreds = [];\r\n\r\n cart.items.forEach(function (item) {\r\n $deferreds.push(makeReplenItem(item, replenishmentUrl));\r\n });\r\n\r\n $deferreds\r\n .reduce(function (promise, func) {\r\n return promise.then(function () {\r\n return func();\r\n });\r\n }, jQuery.Deferred().resolve([]))\r\n .then(replenComplete);\r\n}\r\n\r\nfunction makeReplenItem(data, replenishmentUrl) {\r\n return function () {\r\n return jQuery.ajax({\r\n type: 'GET',\r\n url: replenishmentUrl,\r\n data: bouncex.utils.url.generateQuerystring(data),\r\n });\r\n };\r\n}\r\n\r\nfunction replenComplete() {\r\n window.location.href =\r\n window.location.origin + window.location.pathname + '?bx_replen=true';\r\n}\r\n\r\nfunction cartOnReplen() {\r\n return (\r\n window.location.href.indexOf('bx_replen') > -1 ||\r\n window.location.href.indexOf('bx_cart') > -1 ||\r\n window.location.href.indexOf('account') > -1\r\n );\r\n}\r\n\r\n/******************************* LoggedIn User ********************************/\r\n\r\nfunction trackLoggedInUser() {\r\n var userEmail;\r\n\r\n if (!bouncex.vars.logged_in || !!bouncex.vars.logged_in_identified) {\r\n return;\r\n }\r\n\r\n bouncex.et.onTrue(\r\n function() {\r\n userEmail = bouncex.utils.url.getParam('email1', jQuery('form[action*=\"AddressAdd\"]').attr('action')) || jQuery('#user-email').val();\r\n return bouncex.utils.validate.email(userEmail);\r\n },\r\n function() {\r\n bouncex.push([\r\n 'user',\r\n {\r\n 'email': userEmail,\r\n 'source': 'LoggedIn'\r\n }\r\n ]);\r\n\r\n bouncex.setVar('logged_in_identified', true);\r\n }, \r\n 10\r\n );\r\n}\r\n\r\n\r\n/****************************** INITIALIZE EVENTS *****************************/\r\nfunction isValidItem(item) {\r\n var isValid = !!(item.id && item.copy && item.category && item.imageurl);\r\n return isValid;\r\n}\r\n\r\nfunction isValidCatObj(catObj) {\r\n return catObj['items:ids'] && catObj['page:url'] && catObj['page:title'];\r\n}\r\n\r\nfunction initializeItemEvents() {\r\n if (bouncex.website.pts === 'product') {\r\n var item;\r\n\r\n bouncex.et.onVarChange('item_id', function (oldId, newId) {\r\n if (oldId !== newId) {\r\n bouncex.et.onTrue(\r\n function () {\r\n item = getItem();\r\n return isValidItem(item);\r\n },\r\n function () {\r\n initializeSkuEvents(item.id);\r\n fireItemEvents(item);\r\n },\r\n 10\r\n );\r\n }\r\n });\r\n }\r\n return;\r\n}\r\n\r\nfunction initializeCategoryEvents() {\r\n var categoryObj;\r\n if (bouncex.website.pts === 'category') {\r\n bouncex.et.onTrue(\r\n function () {\r\n categoryObj = getCategoryObj();\r\n return isValidCatObj(categoryObj);\r\n },\r\n function () {\r\n bouncex.push(['view category', categoryObj]);\r\n return;\r\n }\r\n );\r\n }\r\n}\r\n\r\nfunction initializeCartEvents() {\r\n bouncex.et.cart.init({\r\n cartCountVariable: 'items_in_cart',\r\n storeValues: [],\r\n replenish: replenish,\r\n replenishmentType: 'ajax',\r\n });\r\n\r\n addToCart();\r\n bouncex.et.onVarChange('items_in_cart', emptyCart);\r\n}\r\n\r\nfunction init() {\r\n if (isValidDomain()) {\r\n trackLoggedInUser();\r\n initializeCartEvents();\r\n\r\n if (!isValidForTracking) {\r\n return;\r\n }\r\n\r\n switch (bouncex.website.pts) {\r\n case 'product':\r\n initializeItemEvents();\r\n break;\r\n case 'category':\r\n initializeCategoryEvents();\r\n break;\r\n default:\r\n break;\r\n }\r\n }\r\n}\r\n\r\ninit();\r\n","dge":false,"bxidLoadFirst":false,"pie":false,"cme":false,"gbi_enabled":0,"bpush":false,"pt":{"cart":{"testmode":false,"val":[[{"activation":"js","prop":"","prop2":"","prop3":"","val":"utag.data.Page_Type === 'CartPage';"}],[{"activation":"current_page_url","prop":"not_contains","prop2":"","prop3":"","val":"stage.ray-ban"}]]},"category":{"testmode":false,"val":[[{"activation":"js","prop":"","prop2":"","prop3":"","val":"document.querySelectorAll('.rb-plp').length > 0;"},{"activation":"current_page_url","prop":"contains","prop2":"","prop3":"","val":"-collection"}]]},"checkout":{"testmode":false,"val":[[{"activation":"js","prop":"","prop2":"","prop3":"","val":"utag.data.Page_Type === 'Delivery';"},{"activation":"js","prop":"","prop2":"","prop3":"","val":"utag_data.Page_Type === 'Payment';"}],[{"activation":"current_page_url","prop":"not_contains","prop2":"","prop3":"","val":"stage.ray-ban"}]]},"home":{"testmode":false,"val":[[{"activation":"js","prop":"","prop2":"","prop3":"","val":"utag.data.Page_Type === 'Home';"},{"activation":"current_page_url","prop":"exactly","prop2":"","prop3":"","val":"https://www.ray-ban.com/uk"}],[{"activation":"current_page_url","prop":"not_contains","prop2":"","prop3":"","val":"stage.ray-ban"}]]},"product":{"testmode":false,"val":[[{"activation":"js","prop":"","prop2":"","prop3":"","val":"document.querySelectorAll('.rb-pdp-page').length > 0;"},{"activation":"js","prop":"","prop2":"","prop3":"","val":"utag.data.Page_Type === 'Pcp';"}]]},"search":{"testmode":false,"val":[[{"activation":"js","prop":"","prop2":"","prop3":"","val":"utag.data.Page_Type === 'Search';"}]]}},"els":null,"vars":[{"name":"logged_in","polling":"all","persist":"no","page_types":[],"testmode":false,"default":"false","code":"utag_data.User_LoginStatus === 'Logged';","trigger":""},{"name":"ever_logged_in","polling":"all","persist":"permanent","page_types":[],"testmode":false,"default":"false","code":"bouncex.vars.logged_in || null;","trigger":""},{"name":"cart_qty","polling":"all","persist":"visit","page_types":[],"testmode":false,"default":"0","code":"bouncex.website.pts !== 'checkout' ? Number(jQuery('.number-of-products').eq(0).text().trim()) : null;","trigger":""},{"name":"cart_total","polling":"all","persist":"no","page_types":[],"testmode":true,"default":"0","code":"","trigger":""},{"name":"prod_price","polling":"all","persist":"no","page_types":["product"],"testmode":false,"default":"false","code":"Number(jQuery('.rb-pdp-sticky-bar__price__original, .fc-price').eq(0).text().replace(/[^0-9.]/g,''));","trigger":""},{"name":"product_name","polling":"all","persist":"no","page_types":["product"],"testmode":false,"default":"false","code":"jQuery('.rb-pdp-title').text().trim() || jQuery('.fc-product-name').text().trim() || jQuery('.fc-mobile-model-name').text().trim() || jQuery('h1.rb-product-name').text().trim();","trigger":""},{"name":"in_stock","polling":"all","persist":"no","page_types":["product"],"testmode":false,"default":"false","code":"true;","trigger":""},{"name":"cart","polling":"none","persist":"permanent","page_types":[],"testmode":false,"default":"false","code":"null;","trigger":""},{"name":"ibx_test","polling":"none","persist":"permanent","page_types":[],"testmode":false,"default":"false","code":"window.location.href.indexOf('ibx_test') > -1 || null;","trigger":""},{"name":"items_in_cart","polling":"all","persist":"visit","page_types":[],"testmode":false,"default":"0","code":"window.location.href.indexOf('/customize/') > -1 ? null : Number(jQuery('.rb-badge').eq(1).text().replace(/[^0-9.]/g, '')) || Number(jQuery('.odr-title').eq(1).text().replace(/[^0-9.]/g, '')) || Number(jQuery('.cart-qty').text().replace(/[^0-9.]/g, '')) || Number(jQuery('.all-items-counter').text().replace('(', '').replace(')', ''));","trigger":""},{"name":"has_replenished","polling":"none","persist":"permanent","page_types":[],"testmode":false,"default":"false","code":"null;","trigger":""},{"name":"product_page","polling":"none","persist":"no","page_types":[],"testmode":false,"default":"false","code":"bouncex.website.pts === 'product';","trigger":""},{"name":"remix_page","polling":"all","persist":"no","page_types":[],"testmode":false,"default":"false","code":"(typeof window.utag_data !== 'undefined') ? utag_data.Page_Name === \"Remix:Configurator\" : null;","trigger":""},{"name":"submitted_onsite","polling":"all","persist":"permanent","page_types":[],"testmode":false,"default":"false","code":"jQuery('.rb-footer__mail__succes, .rb-footer__mail__title__ok').text().toUpperCase().indexOf('NOW YOU ARE A MEMBER OF RAY-BAN THE ONES COMMUNITY') > -1 || null;","trigger":""},{"name":"products_tracked","polling":"all","persist":"no","page_types":[],"testmode":false,"default":"0","code":"bouncex.parseJSON(localStorage.getItem('bxProdHist'),[]).length;","trigger":""},{"name":"bxhem","polling":"none","persist":"visit","page_types":[],"testmode":true,"default":"false","code":"null;","trigger":""},{"name":"remix_product_name","polling":"all","persist":"no","page_types":[],"testmode":false,"default":"false","code":"window.location.href.indexOf('/customise/') > -1 ? jQuery('#modelTitle').text().replace(/[^a-zA-Z0-9\\s]/g, '') : false;","trigger":"pageload"},{"name":"page_type","polling":"none","persist":"no","page_types":[],"testmode":false,"default":"false","code":"bouncex.website.pts;","trigger":"pageload"},{"name":"item_id","polling":"vars","persist":"no","page_types":[],"testmode":false,"default":"false","code":"window.location.href.indexOf('#') > -1 ? window.location.href.split('#').shift().split('/').pop() : window.location.href.split('?').shift().split('/').pop();","trigger":"pageload"},{"name":"cart_set","polling":"none","persist":"visit","page_types":[],"testmode":false,"default":"false","code":"null;","trigger":"pageload"},{"name":"logged_in_identified","polling":"none","persist":"visit","page_types":[],"testmode":false,"default":"false","code":"null;","trigger":"pageload"}],"dgu":"pixel.cdnwidget.com","dgp":false,"ba":{"enabled":0,"fbte":0},"biu":"assets.bounceexchange.com","bau":"api.bounceexchange.com","beu":"events.bouncex.net","ibx":{"tjs":"","cjs":"","miw":0,"mibcx":1,"te":1,"cart_rep":{"get":"","set":""},"ulpj":{"bxid":"espemailid"},"cus":"","miw_exclude":"","enabled":1},"etjson":null,"osre":true,"osru":"osr.bounceexchange.com/v1/osr/items","checkDfp":false,"gamNetwork":"","spa":1,"spatm":0,"preinit_cjs":"","crs":{"integrations":null,"pageCount":null},"mat":0,"math":0,"cpnu":"coupons.bounceexchange.com","dfpcms":0,"sms":{"optm":"","eventSharing":false,"shqId":"","enabled":0},"pde":false,"fme":false,"fmx":"","sdk":{"android":{"enabled":false,"enabledVersions":[],"eventModifications":null},"ios":{"enabled":false,"enabledVersions":[],"eventModifications":null}},"onsite":{"enabled":1},"ads":{"enabled":0},"pubs":{"enabled":0},"websdk":{"enabled":0},"ga4_property_id":"","ga4_measurement_id":"","tag_state_domain":"api.bounceexchange.com"} ; bouncex.tag = 'tag3'; bouncex.$ = window.jQuery; bouncex.env = 'production'; bouncex.restrictedTlds = {"casl":{"ca":1},"gdpr":{"ad":1,"al":1,"at":1,"ax":1,"ba":1,"be":1,"bg":1,"by":1,"xn--90ais":1,"ch":1,"cy":1,"cz":1,"de":1,"dk":1,"ee":1,"es":1,"eu":1,"fi":1,"fo":1,"fr":1,"uk":1,"gb":1,"gg":1,"gi":1,"gr":1,"hr":1,"hu":1,"ie":1,"im":1,"is":1,"it":1,"je":1,"li":1,"lt":1,"lu":1,"lv":1,"mc":1,"md":1,"me":1,"mk":1,"xn--d1al":1,"mt":1,"nl":1,"no":1,"pl":1,"pt":1,"ro":1,"rs":1,"xn--90a3ac":1,"ru":1,"su":1,"xn--p1ai":1,"se":1,"si":1,"sj":1,"sk":1,"sm":1,"ua":1,"xn--j1amh":1,"va":1,"tr":1}}; bouncex.client = { supportsBrotli: 1 }; bouncex.assets = {"ads":"005ab6b05ecd8ae76686b26c919990d4","creativesBaseStyles":"a53944a2","gpsAuction":"bbb80866120d17013073bb6d284cbd6b","inbox":"75060a85c1a4aebcc6f779b9e84db722","onsite":"abbdf7a49be9b52b097917b7b527b262","sms":"e39203556bab2366e56296ce42e974a7","websdk":"3cdb3cd0b71927a211b8afdc85918cfd"}; bouncex.push = function(pushData) { bouncex.pushedData.push(pushData); } var runtime = document.createElement('script'); runtime.setAttribute('src', '//assets.bounceexchange.com/assets/smart-tag/versioned/runtime_6459738026535cda4232dc813c61447d.br.js'); runtime.setAttribute('async', 'async'); runtime.setAttribute('onload', 'bouncex.initializeTag()'); bouncex.initializeTag = function() { var script = document.createElement('script'); script.setAttribute('src', '//assets.bounceexchange.com/assets/smart-tag/versioned/main-v2_3992efcea79e7aafb3faf668d6e3838c.br.js'); script.setAttribute('async', 'async'); document.body.appendChild(script); bouncex.initializeTag = function() {}; }; document.body.appendChild(runtime); } } if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", bxBootstrap); } else { bxBootstrap(); }})();