Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- console.log('1st');
- function DisplayLargeMultiRowCartPreviewOnHover(){
- window.OPT_TEST_VERSION = 3;
- var clearTimer, fadeOutWhenTimerEnds;
- clearTimer = function() {
- return window.clearTimeout(window.opt_cartPopupTimer);
- };
- fadeOutWhenTimerEnds = function(x) {
- return window.opt_cartPopupTimer = window.setTimeout(function() {
- return $('.opt_cartPopup').fadeOut();
- }, x);
- };
- (function($) {
- var basket, createProductRowHtml, originalFunction;
- basket = window.basket;
- createProductRowHtml = function(x) {
- return "<div class='opt_productAdd clearfix'> <div class='opt_contentL'> <img class='opt_productImageSmall' src='" + x.Product.ThumbnailUrl + "' alt='' /> </div> <div class='opt_contentR opt_contentRWide'> <div> <div class='opt_productTitle'> <a class='opt_productLink' href='" + x.Product.NavigateUrl + "'>" + x.Name + "</a> </div> <div class='opt_line'></div> </div> <div class='opt_bottomR'> <div class='opt_qty clearfix'> <span>Qty:</span> <span class='opt_qtyNumb'>" + x.Quantity + "</span> <span class='opt_productPrice hidden'> <span class='opt_vertLine'></span> <span class='opt_Price'>" + (x.Price.toCurrency()) + "</span> </span> <span class='opt_removeProductIcon hidden' data-basket-item-id='" + x.BasketItemId + "'>X</span> </div> </div> </div> </div>";
- };
- originalFunction = basket.UpdateCartInfo;
- return basket.UpdateCartInfo = function(data) {
- originalFunction(data);
- return window.aj({
- url: '/Common/BasketSVC.asmx/GetChkBasket',
- successFunc: function(x) {
- return $(function() {
- var basketItemIds, html, lastAddedBasketItemId, showCheckoutButton, showDeleteButton, showFooterItemsCount, showFooterSubTotal, showHeader, showLargeProductImage, showOnlyLastProductAdded, showProductPrice, showViewCartButton, showWhiteBackgroundForProducts, stats, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3;
- stats = x.d.Obj;
- $('.opt_itemAmtNumb').text(stats.TotalItems.ProductCount);
- $('.opt_cartCount').text(stats.TotalItems.ProductCount);
- $('.opt_totalNumber').text(stats.SubTotal.toCurrency());
- showOnlyLastProductAdded = false;
- showProductPrice = false;
- showHeader = false;
- showCheckoutButton = false;
- showViewCartButton = false;
- showWhiteBackgroundForProducts = false;
- showFooterItemsCount = false;
- showFooterSubTotal = false;
- showDeleteButton = false;
- showLargeProductImage = false;
- switch (window.OPT_TEST_VERSION) {
- case 1:
- showOnlyLastProductAdded = true;
- showViewCartButton = true;
- showFooterItemsCount = true;
- break;
- case 2:
- showOnlyLastProductAdded = true;
- showHeader = true;
- showProductPrice = true;
- showCheckoutButton = true;
- showWhiteBackgroundForProducts = true;
- showFooterSubTotal = true;
- showDeleteButton = true;
- showLargeProductImage = true;
- break;
- case 3:
- showHeader = true;
- showProductPrice = true;
- showCheckoutButton = true;
- showWhiteBackgroundForProducts = true;
- showFooterSubTotal = true;
- showDeleteButton = true;
- showLargeProductImage = true;
- break;
- default:
- console.log('OPT_TEST_VERSION not set');
- }
- html = '';
- if (showOnlyLastProductAdded) {
- if (window.LastAddedProductId) {
- _ref = stats.Items;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- x = _ref[_i];
- if (x.ProductId === Number(window.LastAddedProductId)) {
- html += createProductRowHtml(x);
- }
- }
- } else {
- basketItemIds = [];
- _ref1 = stats.Items;
- for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
- x = _ref1[_j];
- if (x.ProductId !== 0) {
- basketItemIds.push(x.BasketItemId);
- }
- }
- lastAddedBasketItemId = Math.max.apply(null, basketItemIds);
- _ref2 = stats.Items;
- for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
- x = _ref2[_k];
- if (x.BasketItemId === lastAddedBasketItemId) {
- html += createProductRowHtml(x);
- }
- }
- }
- } else {
- $('.opt_cart').addClass('opt_cartScroll');
- _ref3 = stats.Items;
- for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
- x = _ref3[_l];
- if (x.ProductId !== 0) {
- html += createProductRowHtml(x);
- }
- }
- }
- $('.opt_cart').html(html);
- if (showWhiteBackgroundForProducts) {
- $('.opt_productAdd').addClass('opt_whiteBg');
- }
- if (stats.SubTotal > 50) {
- $('.opt_noFreeShipping').hide();
- $('.opt_freeShipping').show();
- } else {
- $('.opt_freeShipping').hide();
- $('.opt_noFreeShipping').show();
- }
- if (showViewCartButton) {
- $('.opt_viewCartButton').show();
- }
- if (showCheckoutButton) {
- $('.opt_checkoutButton').show();
- }
- if (showHeader) {
- $('.opt_itemAmt').show();
- }
- if (showFooterSubTotal) {
- $('.opt_total').show();
- }
- if (showProductPrice) {
- $('.opt_productPrice').show();
- }
- if (showFooterItemsCount) {
- $('.opt_itmCart').show();
- }
- if (showDeleteButton) {
- $('.opt_removeProductIcon').show();
- }
- if (showLargeProductImage) {
- $('.opt_productImageSmall').removeClass('.opt_productImageSmall').addClass('opt_productImageLarge');
- $('.opt_contentR').removeClass('opt_contentRWide').addClass('opt_contentRShort');
- }
- if (window.LastAddedProductId && window.OPT_TEST_VERSION) {
- // $('.opt_cartPopup').show();
- // The above line activates popup after each AddToCart click
- clearTimer();
- return fadeOutWhenTimerEnds(5000);
- }
- });
- }
- });
- };
- })(jQuery);
- jQuery(function($) {
- var cartPopup, popup, styles;
- styles = '<style type="text/css"> #srhBarDiv { position: relative; } .opt_greyTriangle { width: 28px; height: 14px; position: absolute; top: 0; right: 17px; background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAOCAYAAAA8E3wEAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPhJREFUeNqslN0KgzAMhduyXVvF+73AfOu9n3o7GF3DOHIW0h/HCqU1mn45SaxPKbmzY9u25L13wzD4s77hV5gEuu/7699AUTAx7HjxgYYM1SlajHPmw6+R0jHPVTY4WL4XGAb8Y4w96Z1rCm+AiTIczDBWy+orY2opdJwySx3qibWlNPTAtDp55kA5CKOmfUDLkcEM7/HVwGstjVpJyyb7Uk2DFR2nrNQkJRvqWWqkL4WA6VqhIdjGdl1TBmsogEuGrRxprU4lhZgctKxcIgHes+Eh/y5Hq1Oq259VW03FGeFbyufNM68X3DpW9KXbxYJagbHfW4ABAOgFALy7+pV5AAAAAElFTkSuQmCC"); } .opt_removeProductIcon { display: inline-block; float: right; padding: 0 5px; margin: 3px 5px 0 0; cursor: pointer; background-color: #da2200; color: white; } .opt_cartPopup { width: 300px; height: 130px; position: absolute; right: 100px; top: 100%; z-index: 99; } .opt_cartTop { height: 14px; position: relative; } .opt_cartBody { background-color: #EBEBEB; border-radius: 10px; border: 1px solid #CDCDCD; } .opt_cart { max-height: 400px; } .opt_cartScroll { overflow-x: hidden; overflow-y: scroll } .opt_itemAmt { color: #515c62; font-family: Rockwell, serif; font-size: 22px; font-weight: 300; text-align: center; } .opt_itemAmtNumb { color: #da2200; font-size: 35px; font-weight: 800; } .opt_productAdd { margin: 0 10px; padding-top: 10px; padding-bottom: 5px; display: table; } .opt_whiteBg { background-color: white !important; } .opt_contentL { display: table-cell; vertical-align: middle; } .opt_contentR { padding-right: 10px; display: table-cell; vertical-align: middle; } .opt_contentRWide { width: 190px; } .opt_contentRShort { width: 165px; } .opt_productImageSmall { width: 50px; height: 50px; margin: 0 5px 5px 5px; } .opt_productImageLarge { width: 75px; height: 75px; margin: 0 5px 5px 5px; } .opt_productLink { color: red !important; font-weight: bold; } .opt_productTitle { color: #da2200 !important; font-family: Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 12px; font-weight: 500; } .opt_line { border-bottom: thin solid #da2200; } .opt_bottomR { margin-top: 5px; } .opt_qty { font-family: Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 12px; color: #a1a1a1; } .opt_qtyNumb { font-family: Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 12px; color: #515c62; font-weight: 600; margin-left: 5px; } .opt_vertLine { border-left: thin solid #da2200; display: inline-block; height: 15px; margin-left: 5px; } .opt_Price { margin-left: 10px; font-family: Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 12px; color: #515c62; font-weight: 600; } .opt_total { margin: 10px 0px 10px 0; background-color: #ffffff; color: #515c62; font-family: Rockwell, serif; font-size: 16px; font-weight: 300; text-align: right; } .opt_totalNumber { color: red; padding-right: 10px; } .opt_viewCartBtn { margin: 5px 0 0 10px; width: 240px; display: inline-block; height: 22px !important; } .opt_checkoutButton { text-align: right; padding-bottom: 5px; padding-right: 5px; } .opt_freeShipping { float: left; font-size: 15px; margin-top: 5px; margin-left: 10px; font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; font-weight: normal; color: #79B524; } .opt_noFreeShipping { float: left; font-size: 12px; margin-top: 5px; margin-left: 10px; font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; font-weight: bold; color: #da2200; } .opt_itmCart { color: #515c62; font-family: Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 12px; font-weight: 200; text-align: center; margin: 3px 0px 3px 0px; } .opt_crt { margin-left: 5px; } </style>';
- cartPopup = '<div class="opt_cartPopup hidden"> <div class="opt_cartTop"> <div class="opt_greyTriangle"></div> </div> <div class="opt_cartBody"> <div class="opt_itemAmt hidden"> <span class="opt_itemAmtNumb"></span> <span>Items in cart</span> </div> <div class="opt_cart"></div> <div class="opt_viewCartButton hidden"> <a href="/basket.aspx" class="defBtn defbtnLnk opt_viewCartBtn">View Cart</a> </div> <div class="opt_itmCart hidden"> <span class="opt_cartCount"></span> <span class="opt_crt">Items in cart</span> </div> <div class="opt_total hidden"> <span>Subtotal:</span> <span class="opt_totalNumber"></span> </div> <div class="opt_checkoutButton hidden"> <span class="opt_freeShipping hidden">Your cart qualifies for FREE Shipping!</span><span class="opt_noFreeShipping hidden">*Add $50 or more to receive FREE Shipping!</span> <a href="/basket.aspx" class="defBtn defbtnLnk opt_viewCartBtn">Checkout</a> </div> </div>';
- $('head').append(styles);
- $('#srhBarDiv').append(cartPopup);
- $(document).on('click', '.opt_removeProductIcon', function() {
- var icon;
- icon = this;
- return window.aj({
- url: '/Common/BasketSVC.asmx/RemoveItem',
- parms: JSON.stringify({
- basketItemId: $(icon).data('basket-item-id'),
- elementAction: 1
- }),
- successFunc: function(m) {
- basket.GetBasketData();
- return $(icon).parents('.opt_productAdd').fadeOut();
- }
- });
- });
- popup = $('.opt_cartPopup');
- return $('.opt_cartPopup,#srhBarData').hover(function() {
- if (!window.OPT_TEST_VERSION) {
- return;
- }
- clearTimer();
- return popup.stop(true, true).show();
- }, function() {
- if (!window.OPT_TEST_VERSION) {
- return;
- }
- clearTimer();
- return fadeOutWhenTimerEnds(300);
- });
- });
- }
- function logNotLoaded(){console.log("not loaded")}if(typeof TestPlan==="undefined"||!(TestPlan.global instanceof TestPlan)){function TestPlan(){var e={};this.add=function(t,n){if(typeof t!=="number"){throw new Error("The order must be a number.")}if(typeof n!=="function"){throw new Error("The action must be a function.")}var r=e[t];if(r){r.push(n)}else{e[t]=r=[n]}};this.executeStep=function(t){var n=e[t];if(n instanceof Array){for(var r in n){var i=n[r];if(typeof i==="function"){i()}}}};this.executePlan=logNotLoaded}TestPlan.global=new TestPlan}if(typeof _==="undefined"||TestPlan.executePlan===logNotLoaded){$.getScript("//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore.js",function(){TestPlan.global.executePlan=function(){var t=e;t=_.keys(t);t=t.map(parseInt);t=t.filter(_.isNumber);t=_.sortBy(t,_.identity);_.each(t,TestPlan.global.executeStep)}})}
- TestPlan.global.add(1, DisplayLargeMultiRowCartPreviewOnHover);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement