Sei sulla pagina 1di 17

function setupSlider() { //size the slider sliderW = $(".glo-ucart-slider-item").size() * $(".glo-ucart-slider-item ").eq(0).width(); $("#glo-ucart-slider-content").width( sliderW ); $.

widgetSlider({ viewport: "#glo-ucart-slider-viewport", content: "#glo-ucart-slider-content", next: "#widget-slider-next", prev: "#widget-slider-prev", item: ".glo-ucart-slider-item", direction: "horizontal", showAmount: 3 }); }; //Need to load jsp with ajax to avoid Akamai caching function loadRecentlyViewed() { $("#recentlyViewedContainer").load("/catalog/gadgets/recently_viewed_ite ms.jsp"); } function getParam(name) { return decodeURI( (RegExp(name + '=' + '(.+?)(&|$)').exec(location .search)||[,null])[1] ); } function fireHPSubscribe() { var visited = $.cookie('visited'); if (visited == 'yes') { return false; } else { $.fancybox({ overlayColor:"#000", padding:1,// border width margin:0, autoDimensions:true, hideOnOverlayClick:true, showCloseButton:false, href:"/common/hp_subscribe.jsp" }); } $.cookie('visited', 'yes', { expires: 7 }); } function fireloginPage() { $.fancybox({ overlayColor:"#000", padding:1,// border width margin:0, autoDimensions:true, hideOnOverlayClick:true, showCloseButton:false, href:"/custserv/login_popup.jsp" }); }

function checkSession() { var isSessionExpired = getParam("showLoginModalPage"); var isSessionExpiredJ = getParam("isSessionExpired"); if (isSessionExpired === "true" && isSessionExpiredJ != "true") { $("#glo-body-border").empty(); fireloginPage(); } else { return; } } function fireSocial() { $.fancybox({ overlayColor:"#000", padding:1,// border width margin:0, autoDimensions:true, hideOnOverlayClick:true, showCloseButton:false, href:('/custserv/confirmation_social.jsp') }); } function checkErrorFields() { $(".glo-tex-error:empty").remove(); } function openMiniCart() { ucartActive = 1; var minicartNoHover =$('#minicartNoHover').val(); $('.jcarousel-list,' + '.jcarousel-clip,' + '.jcarousel-prev,' + '.jcarousel-next,' + '.refine-li,' + '#cat-pro-nav').css({'z-index':0}); if (!minicartNoHover){ $('#widget-ucart').slideDown(800); } } function hideMiniCart() { ucartActive = 0; clearTimeout(ucartTimer); $('#widget-ucart').slideUp(800, function() { $('.ucart-success-err-msg').text(''); }); $(".miniCartHover").die("mousemove"); $('.jcarousel-list').css({'z-index':1}); $('.jcarousel-clip').css({'z-index':2}); $('.jcarousel-prev, .jcarousel-next').css({'z-index':3}); $('.refine-li').css({'z-index':1});

$('#cat-pro-nav').css({'z-index':10}); } function random_string() { var time = String((new Date()).getTime()).replace(/\D/gi, ''); return time; } function changeState(country, whichAddressForm) { var isCan = $('#canstates_' + whichAddressForm).is(':visible'); if (isCan && (country != 'US' && country != 'CA')) { $('#state_billing3_' + whichAddressForm).val( $('#state_billing2 _' + whichAddressForm + ' option:selected').text() ); $('#stateValue_' + whichAddressForm).val( $('#state_billing2_' + whichAddressForm + ' option:selected').text() ); } if (country == 'US' || country == 'USA') { $('#usstates_' + whichAddressForm).show(); $('#intstates_' + whichAddressForm).hide(); $('#canstates_' + whichAddressForm).hide(); $('#'+ whichAddressForm +' .zipLabel label').text('ZIP*'); } else if (country == 'CA') { $('#canstates_' + whichAddressForm).show(); $('#usstates_' + whichAddressForm).hide(); $('#intstates_' + whichAddressForm).hide(); $('#'+ whichAddressForm +' .zipLabel label').text('ZIP*'); } else if (country == "MX") { $('#'+ whichAddressForm +' .zipLabel label').text('ZIP*'); } else { $('#canstates_' + whichAddressForm).hide(); $('#intstates_' + whichAddressForm).show(); $('#usstates_' + whichAddressForm).hide(); $('#'+ whichAddressForm +' .zipLabel label').text('POSTAL CODE*' ); } } (function($) { $.fn.formCallback = function(formName) { return this.each(function() { var $this = $(this), activeBlock = $this.parents('.activeBlock'), inactiveBlock = $this.parents('.inactiveBlock'); activeBlock.find('input[type!="hidden"], textarea').val( ''); if (formName && formName == "changePasswordForm") { activeBlock.find('.cancel').trigger('click'); } else if (formName && formName == "editEmailForm") { $('#emailLabel').load('/user/gadgets/user_email. jsp', function() { activeBlock.find('.cancel').trigger('cli ck'); }); } else if (formName && formName == "forgotPasswordForm") {

//$('#modal-inner .close').trigger('click'); $('#forgot-password-wrapper').html('<div class=" widget-ima-loader"><img alt="Loading..." src="//www.express.com/cdn/legacy/web/i mg/backgrounds/ima-glo-loading.gif"></div>').load("/common/forgot_password_succe ss.jsp"); } else if (formName && formName == "shippingAddressChangeF orm") { activeBlock.find('.cancel').trigger('click'); } else if (formName && formName == "shippingForm") { $('#shippingAddresses').find('.inactiveBlock').l oad('/user/gadgets/shipping_address_display.jsp', function() { activeBlock.find('.cancel').trigger('cli ck'); }); } else if (formName && formName == "loyaltyForm") { $('#expressNextInfo').find('.inactiveBlock').loa d('/user/gadgets/profile_next.jsp', function() { activeBlock.find('.cancel').trigger('cli ck'); }); } else if (formName && formName == "creditCardForm") { $('#billingAddresses').find('.inactiveBlock').lo ad('/user/gadgets/billing_info_display.jsp', function() { if ($("#billing #index-6").length != 0) { $("#maxBillingOptions").text("5" ); } activeBlock.find('.cancel').trigger('cli ck'); }); } else if (formName && formName == "emailAFrndForm") { var product = $('#productName').val(); $("#cat-ema-con").html('<div class="widget-ima-l oader"><img alt="Loading..." src="//www.express.com/cdn/legacy/web/img/backgroun ds/ima-glo-loading.gif"></div>').load("/catalog/gadgets/email_friend_success.jsp ?productName="+encodeURIComponent(product)); } else if (formName && formName == "subscribeForm") { $("#SubscribePopupFormInner").html('<div id="Sub scribeSuccessful"><span class="glo-bold">THANKS!</span><br/>You are now signed u p for Express e-mail.<br/><br/><br/><a class="js-CloseSubscribeLayer close" href ="#ShopNow"><img class="js-ButtonImage glo-but-css-off" src="//www.express.com/c dn/legacy/web/img/buttons/but-use-shop-now.gif" alt="Shop Now" env="images"/></a ></div>'); fireHomePageEmailPopUpCompleteEvent(); } else { activeBlock.find('.cancel').trigger('click'); } }); }; })($);

(function($) { $.fn.errorCallback = function(formName, errorMap, formError) { this.each(function() { var $this = $(this), fieldId; var formErrorMsg = $('<div class="glo-tex-error" sty le="display:none;" />').html(formError); if(formName == 'giftCardForm') { $('#che-ord-rev-top').prepend(formErrorMsg); } else { $this.parents('.toggleBlock').prepend(formErrorM sg); } if (errorMap) { for (fieldId in errorMap[0]) { var errorMsg = $('<dd class="glo-tex -error" style="display:none;" />').html(errorMap[0][fieldId]); if (formName == 'creditCardForm' && fiel dId.indexOf('card')<=0) { fieldId = fieldId + '_billing'; if(fieldId == 'state_billing'){ fieldId = fieldId + '1_b illing'; } } if (formName == 'shippingForm') { if(fieldId == 'state'){ fieldId = fieldId + '_bi lling1_shipping'; }else{ fieldId = 'ship' + field Id.substr(0,1).toUpperCase() + fieldId.substr(1,fieldId.length); } } // form should be: shipAddressForm if (formName == 'editEmailForm') { field Id = fieldId + '_email'; } if (formName == 'editPasswordForm') { fi eldId = fieldId + '_pwd'; } if(formName == 'creditCardForm' && field Id == 'country_billing'){ errorMsg.insertAfter($('#' + fie ldId)); }else{ errorMsg.insertAfter($('#' + fie ldId).parents('.ec')); } if((formName == 'giftCardForm') && (fiel dId != null)) { errorMsg.insertAfter($('#'+field Id)); } } } $this.parents('.toggleBlock').find('.glo-tex-error').fad eIn('fast');

if(formName == 'giftCardForm') { $('#che-ord-rev-top').find('.glo-tex-error').fad eIn('fast'); } }); }; })($); $(document).ready(function() { var url = window.location.pathname; var url_parts = url.replace(/\/\s*$/,'').split('/'); url_parts.shift(); var section = url_parts[1]; if (section) { switch (section) { case ("Women"): $('#main-header .main-nav ul li a[title="Women"]').css('color ','white'); break; case ("Men"): $('#main-header .main-nav ul li a[title="Men"]').css('color', 'white'); break; case ("GiftCards"): $('#main-header .main-nav ul li a[title="GiftCards"]').css(' color','white'); break; default: } } $.ajaxSetup({ cache: false }); checkSession(); var mTWSValue = $('#mTWS').val(), options = { mTWS:mTWSValue }; $.ajax({ async:false, type:"post", url:"/checkout/gadgets/minicartcontents.jsp", data:options, dataType:"html", success: function(responseData) { $('#widget-ucart').html(responseData); } }); // remove empty error fields checkErrorFields(); if ($('.expressHomepage').length != 0) { fireHPSubscribe(); } if($('.mm-receipt').length != 0) { fireSocial();

} /* address_form.jsp LISTENERS - START */ $('.country').live('change', function() { var context = $(this), fragment = context.attr('fragment'), mode = context.attr('mode'), locale = context.val(), parentBlock = context.parents('.toggleBlock'); parentBlock.load(fragment, { locale:locale, addEditMode:mode }, function() { parentBlock.find('.country option[value="' + locale + '" ]').attr('selected', "selected"); }); }); $("#addressFormCountry").live("change", function(e) { e.preventDefault(); var country = $(this).val(); var whichAddressForm = 'shipping'; changeState(country, whichAddressForm); }); $("#country_billing").live("change", function(e) { e.preventDefault(); var country = $(this).val(); var whichAddressForm = 'billing'; changeState(country, whichAddressForm); }); $('.state_billing_select').live('change', function() { var stateIdSplit = $(this).attr('id').split('_')[2]; $('#stateValue_' + stateIdSplit).val( $(this).val() ); }); $('.state_billing_text').live('blur', function() { var stateIdSplit = $(this).attr('id').split('_')[2]; $('#stateValue_' + stateIdSplit).val( $(this).val() ); }); /* address_form.jsp LISTENERS - END */ // clear input field values $('.input-text').focus(function() { if ( this.value === this.defaultValue) { this.value = ''; } }) .blur(function() { if ( this.value === '') { this.value = this.defaultValue; } }); exp.utils.popupLink(".more", { width: 990,

height: 700, scrollbars: 1 }); // fancybox pop-up links for generic modals $('html').on('click','.popup', function(e) { if (tw = $(this).attr('data-width')) { $.fancybox({ overlayColor:"#000", padding:1,// border width margin:0, autoDimensions:false, width:tw, hideOnOverlayClick:true, showCloseButton:false, href:$(this).attr("href"), onStart: function() { $('head').first().append('<style id="fan cyfix">#fancybox-content, #fancybox-content>div {height:auto !important;}</style >') }, onClosed: function() { $('#fancyfix').remove(); } }); } else { $.fancybox({ overlayColor:"#000", padding:1,// border width margin:0, autoDimensions:true, hideOnOverlayClick:true, showCloseButton:false, href:$(this).attr("href") }); } e.preventDefault(); }); // fancybox pop-up for email signup privacy policy link $(".privacyPop").die("click").live("click", function(e) { $.fancybox({ overlayColor:"#000", padding:1,// border width margin:0, autoDimensions:true, hideOnOverlayClick:true, showCloseButton:false, href:$(this).attr("href"), onClosed: function() { setTimeout(fireHPSubscribe, 500); } }); e.preventDefault(); $.removeCookie("visited", -5); //This will set IE7 to -5 and th e new browsers seem to get it set to null. }); // fancyboxy pop-up for category listing swatch $(".swatch-popup").die("click").live("click", function(e) { $.fancybox({

overlayColor:"#000", padding:1,// border width margin:0, autoDimensions:true, hideOnOverlayClick:true, showCloseButton:false, href:$(this).attr("href"), onComplete: function(){ flyoutmodal.init(); } }); e.preventDefault(); }); // fancybox pop-up for edit on basket $(".popup-quickview-basket").die("click").live("click", function(e) { $.fancybox({ overlayColor:"#000", padding:1,// border width margin:0, autoDimensions:true, hideOnOverlayClick:true, showCloseButton:false, href:$(this).attr("href"), onComplete: function(){ flyoutmodal.init(); } }); e.preventDefault(); }); $(".popup-wide").die("click").live("click", function(e) { $.fancybox({ overlayColor:"#000", padding:1,// border width margin:0, width:860, autoDimensions:true, hideOnOverlayClick:true, showCloseButton:false, href:$(this).attr("href") }); e.preventDefault(); }); $(".popout").live("click", function(e) { $.fancybox({ overlayColor:"#000", padding:1,// border width margin:0, autoDimensions:true, hideOnOverlayClick:true, showCloseButton:true, href:$(this).attr("href") }); e.preventDefault(); }); $(".popoutOutfits").live("click", function(e) { var context = $(this); var csdIndex = context.attr('res');

var productId = $('#productId_' + csdIndex).val(); var expressView = $('.expressView:first').text(); var selectedColor = ($('#selectedColor_' + csdIndex).length ? $( '#selectedColor_' + csdIndex).val() : ""); var selectedSize = ($('#selectedSize_' + csdIndex).length ? $('# selectedSize_' + csdIndex).val() : ""); var thisHref = $(this).attr("href").split('?')[0] + '?productId=' + productId + '&csdIndex=' + csdIndex + '&expressView=' + expressView + '&selectedColor=' + selectedColor + '&selectedSize=' + selectedSize + '&rnd=' + random_string(); $.fancybox({ overlayColor:"#000", padding:1,// border width margin:0, autoDimensions:true, hideOnOverlayClick:false, showCloseButton:true, href:thisHref }); e.preventDefault(); }); /*larger image iframe */ $(".iframe").live("click", function(e) { $.fancybox({ overlayColor:"#000", padding:1,// border width margin:0, autoDimensions:true, hideOnOverlayClick:true, showCloseButton:true, href:$(this).attr("href"), type:'iframe', width:1030, height:652, autoScale:'true', scrolling: 'no' }); e.preventDefault(); }); $("a.close").live("click",function(e){ e.preventDefault(); $.fancybox.close(); }); $("a.login-close").live("click",function(e){ e.preventDefault(); window.location = "/index.jsp"; }); $('.activeBlock .cancel, .toggleBlocks').live('click', function() { var context = $(this); var target = context.attr('href').split('#')[1]; target = $('#' + target);

contextText = context.text(); e header (loaded)

// Text within the <a> tag in th

targetText = target.attr('id'); // ID of the DIV to be populated activeBlock = target.find('.activeBlock'); inactiveBlock = target.find('.inactiveBlock'); activeBlock.find('.glo-tex-error').fadeOut('fast').remove().end( ); activeBlock.find('input[type!="hidden"], textarea').val(''); titleLink = context.parents('.box').find('.toggleBlocks'); currentLinkText = titleLink.text(); initialLinkText = titleLink.attr('data-func-text'); if (target.length) { activeBlock.switchClass('activeBlock', 'inactiveBlock', 0); inactiveBlock.switchClass('inactiveBlock', 'activeBlock' , 0); if (targetText == "billingAddresses") { $(".billingForm:visible").load("/user/gadgets/bi lling_info_create.jsp"); } if (targetText == "shippingAddresses") { $(".shippingForm:visible").load("/user/gadgets/s hipping_address_create.jsp"); } if (currentLinkText == initialLinkText) { titleLink.text('Cancel'); $('#cardType').val(""); $('#state_billing1_billing').val(""); $('#cardExpMonth_billing').val(""); $('#atg_store_useCreditCardAsDefault').attr('che cked',false); //$('#country_billing').val(""); $('#cardExpYear_billing').val(""); } else { if (targetText.toLowerCase().indexOf('bill') >= 0) { var maxBillingOptionsCount = +($('#maxBi llingOptions').text()); if (maxBillingOptionsCount >= 5) { titleLink.text(initialLinkText). addClass('hiddenBlock'); } else { titleLink.text(initialLinkText); } } else { titleLink.text(initialLinkText); } } } return false; });

$('.editForm').live('click', function() { var context = $(this), targetHref = context.parents('.box').find('.toggleBlocks').attr( 'href'), target = $(targetHref), activeBlock = target.find('.activeBlock'), inactiveBlock = target.find('.inactiveBlock'); activeBlock.find('.glo-tex-error').fadeOut('fast').remove().end( ); if (targetHref.indexOf('billingAddresses') >= 0) { $("#billing .add-cancel").text('Cancel'); } else { // shippingAddresses $("#shipping .add-cancel").text('Cancel'); } if (target.length) { activeBlock.switchClass('activeBlock', 'inactiveBlock', 0); inactiveBlock.switchClass('inactiveBlock', 'activeBlock' , 0, function() { var $.ajax({ async: false, url: context.attr('href'), type: "post", dataType: "html", success: function(responseData) { contentBlock.html(responseData); }, complete: function() { //$('.country').trigger('change' ); }, statusCode: { 409: function() { fireloginPage(); } } }); }); } return false; }); $('.edit-next-info').on({ click: function() { $('#nextEdit').load('/user/gadgets/profile_next_edit.jsp '); } }); $('.formRedirectSubmit').live('click', function(event) { event.preventDefault(); event.stopPropagation(); var context = $(this); var formContext = context.attr('href').split('#')[1]; contentBlock = $(this);

var $.ajax({

formContext = $('#' + formContext); queryString = formContext.serialize(); url: context.attr('rel'), data: queryString, type: "post", dataType: "html", success: function(responseData) { $("#fancybox-content").empty().html(responseData

); } }); return false; }); $("#loyaltyLandingForm").submit(function(e) { e.preventDefault(); var loyaltyInfo = $(this).serializeArray(); var context = $(this); var activeBlock = context.parents('.activeBlock'); $.ajax({ url: "/loyalty/action/loyalty-pre-existing-submit.jsp", type: "post", data: loyaltyInfo, dataType: "json", async: true, cache: false, complete: function (responseData, status) { if (responseData.status =="200") { activeBlock.find('.glo-tex-error').fadeO ut('fast').remove().end(); var nseData.responseText); if (resultObject == null || resultObject == "") { return false; } if (resultObject.result == "success") { context.formCallback(resultObjec t.form); }else if (resultObject.result == "error" ) { context.errorCallback(resultObje ct.form, resultObject.errors, resultObject.formError); } } else if (responseData.status == "302") { $.fancybox({ overlayColor: "# 000", type:'iframe', padding: 1, margin: 0, width: 622, height: 273, resultObject = $.parseJSON(respo

autoDimensions: false, href: responseDa ta.responseText, hideOnOverlayCli ck: false, showCloseButton: false }); } else if (responseData.status == "202") { window.location.href = responseData.resp onseText; } } }); }); $('.formSubmit').live('click', function(event) { event.preventDefault(); event.stopPropagation(); var context = $(this); var activeBlock = context.parents('.activeBlock'); var formContext = context.attr('href').split('#')[1]; formContext = $('#' + formContext); var queryString = formContext.serialize(); $.ajax({ url: context.attr('rel'), data: queryString, type: "post", dataType: "json", success: function(responseData) { activeBlock.find('.glo-tex-error').fadeOut('fast ').remove().end(); var resultObject = responseData;

if (resultObject == null) { return false; } if (resultObject.result == "success") { context.formCallback(resultObject.form); //$('#kaptchaImage').attr('src', '/kaptc ha.jpg?' + Math.floor(Math.random()*100) ); }else if (resultObject.result == "error") { context.errorCallback(resultObject.form, resultObject.errors, resultObject.formError); //$('#kaptchaImage').attr('src', '/kaptc ha.jpg?' + Math.floor(Math.random()*100) ); }else if(resultObject.result !=null){ $("#succesMsg").html("Your card has a ba lance of $" + resultObject.result + "."); $('#kaptchaImage').attr('src', '/kaptcha .jpg?' + Math.floor(Math.random()*100) ); } }, statusCode: {

409: function() { fireloginPage(); } } }); return false; }); $("a.widget-quickview-but-close").live('click', function(e) { e.preventDefault(); $.fancybox.close(); }); /* MINI-CART - START */ $('.glo-header-link-span.bag').bind('click', function() { location.href = '/checkout/basket.jsp'; }); /* NEW MINI-CART CONTROLS */ /* setup the timer */ ucartActive = 0; ucartTimer = setTimeout(function() { hideMiniCart(); }, 500); $(".miniCartHover, .miniCartContents").die("mouseenter"); $(".miniCartHover, .miniCartContents").live("mouseenter", function() { clearTimeout(ucartTimer); if (ucartActive != 1) { ucartActive = 1; openMiniCart(); } return true; }); $(".miniCartContents, .miniCartHover").die("mouseleave"); $(".miniCartContents, .miniCartHover").live("mouseleave", function() { ucartTimer = setTimeout(function() { hideMiniCart(); }, 500); return true; }); $('.widget-ucart-close-but').live('click', function() { hideMiniCart(); }); /* NEW MINI-CART CONTROLS */ $('.widget-ucart-remove').live('click', function(event) { event.preventDefault(); event.stopPropagation(); var minicartForm = $(this).attr('id').replace('removeFromMiniCar tA', 'removeFromMiniCartForm'); var successMessageId = $(this).attr('id').split('_')[1]; // SKU ID var skuId = $(this).attr('skuid'); var actionUrl = '/checkout/gadgets/minicart.jsp?mTWS=' + success

MessageId; var commerceItemId= $(this).attr('id').split('_')[1]; var prdIdInputName = "productId_"+commerceItemId; var prodSelector = 'input[name=\"'+prdIdInputName+'\"]'; var productId = $(prodSelector).val(); $.ajax({ async: false, cache: false, type: "post", url: actionUrl, data: $('#' + minicartForm + ' input').serialize(), dataType:"html", success: function(responseData) { $('.widget-quickview-but-close').trigger('click' ); openMiniCart(); setupSlider(); var miniCartOffset = $('.bag').offset().top - 24 ; $('html, body').animate({ scrollTop: miniCartOffset }, '1000'); }, complete: function() { $.ajax({ async: false, cache: false, type: "get", url: '/includes/shoppingCartItemCount.js p?returnVar=yes', dataType: "html", success: function (itemCount) { fireCartRemove(productId, skuId) ; //$('#widget-ucart-item-count'). text('(' + $.trim(itemCount) + ')'); $('.bag-icon').text($.trim(itemC ount)); if($('.bag-icon').text() == "0"){ $('.bag-icon').addClass('empty') ; } var geId, options = { mTWS:mTWSValue }; $.ajax({ async:false, type:"post", url:"/checkout/gadgets/m inicartcontents.jsp?removedSkuId="+skuId, data:options, dataType:"html", success: function(respon seData) { $('#widget-ucart ').html(responseData); } mTWSValue = successMessa

}); } }); } }); return false; }); /* MINI-CART - END */ if ($('#addToCart').length == true) { openMiniCart(); } });

Potrebbero piacerti anche