/* * Merch block Javascript * version 1 */ jQuery.fn.makeLinksExternal=function(){return this.each(function(){var a=jQuery(this).attr("href");if(a.indexOf(location.host)==-1&&a.indexOf("/")!=0){jQuery(this).attr("target","_blank")}})}; /* Functions for Merch Hover Card */ function bringMerchHCOn(merchImg){ merchImg.showTimer = window.setTimeout(function(){ jQuery(merchImg).siblings(".merchHC").fadeIn(350); },300); } function killMerchHC(merchImg){ if (merchImg.showTimer){ window.clearTimeout(merchImg.showTimer); } } function testOmnitureStringPresence(omnitureString){ var omnitureStrRegex = /intcmp=(.*)(&.*|\/)$/; var regExCapture = omnitureString.match(omnitureStrRegex); return regExCapture; } function getMerchToasterOmnitureArray(omnitureString){ var omnitureArrayLinks = new Array(); omnitureString = jQuery.trim(omnitureString); if (omnitureString.charAt(omnitureString.length-1) != "/" ){omnitureString += "/";} var regExCapture = testOmnitureStringPresence(omnitureString); if (regExCapture!= null && regExCapture != ""){ var regularExpCapture = regExCapture[1]; omnitureString = omnitureString.replace(/\/$/,''); omnitureArrayLinks["alert-title"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-alert-title'); omnitureArrayLinks["alert-thumb"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-alert-thumb'); omnitureArrayLinks["alert-button"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-alert-button'); }else { omnitureArrayLinks["alert-title"] = omnitureString.replace(/\/$/,'?intcmp=-alert-title'); omnitureArrayLinks["alert-thumb"] = omnitureString.replace(/\/$/,'?intcmp=-alert-thumb'); omnitureArrayLinks["alert-button"] = omnitureString.replace(/\/$/,'?intcmp=-alert-button'); } return omnitureArrayLinks; } /* * This function is used to tag store links with different omniture tags, * to track them. This will enable us to track which links the user clicked. * */ function getMerchOmnitureArray(omnitureString){ var omnitureArrayLinks = new Array(); omnitureString = jQuery.trim(omnitureString); if (omnitureString.charAt(omnitureString.length-1) != "/" ){omnitureString += "/";} regExCapture = testOmnitureStringPresence(omnitureString); if (regExCapture != null && regExCapture != ""){ var regularExpCapture = regExCapture[1]; omnitureString = omnitureString.replace(/\/$/,''); omnitureArrayLinks["page-title"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-page-title'); omnitureArrayLinks["page-button"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-page-button'); omnitureArrayLinks["page-thumb"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-page-thumb'); omnitureArrayLinks["hovercard-title"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-hovercard-title'); omnitureArrayLinks["hovercard-thumb"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-hovercard-thumb'); omnitureArrayLinks["hovercard-button"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-hovercard-button'); }else{ omnitureArrayLinks["page-title"] = omnitureString.replace(/\/$/,'?intcmp=page-title'); omnitureArrayLinks["page-button"] = omnitureString.replace(/\/$/,'?intcmp=page-button'); omnitureArrayLinks["page-thumb"] = omnitureString.replace(/\/$/,'?intcmp=page-thumb'); omnitureArrayLinks["hovercard-title"] = omnitureString.replace(/\/$/,'?intcmp=hovercard-title'); omnitureArrayLinks["hovercard-thumb"] = omnitureString.replace(/\/$/,'?intcmp=hovercard-thumb'); omnitureArrayLinks["hovercard-button"] = omnitureString.replace(/\/$/,'?intcmp=hovercard-button'); } return omnitureArrayLinks; } /* * * This function generates the structure of the merch module. * The structure is just a javascript variables interspersed with html. */ function generateMerchStructure (){ var $merchData = jQuery("#merchData"); var $merchItem = $merchData.children(".merchItems") var merchViewAllLink = $merchData.children(".merchViewAll").html(); var merchHoverCardPresenHtml = $merchData.children(".merchHoverCardPresent").html(); var merchHoverCardPresent = jQuery.trim(merchHoverCardPresenHtml); merchHoverCardPresent = !!merchHoverCardPresent; /* Code for the Merch Head */ var merchHead = '
' var visitStorehead = jQuery('#merchContainer').parent(".description").parent(".body").siblings(".head"); jQuery(merchHead).appendTo(visitStorehead); jQuery(visitStorehead).find("a").makeLinksExternal(); /* End of Code for Merch Module */ var merchBody='