Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. console.log('1st');
  2. function DisplayLargeMultiRowCartPreviewOnHover(){
  3.   window.OPT_TEST_VERSION = 3;
  4.   var clearTimer, fadeOutWhenTimerEnds;
  5.  
  6.   clearTimer = function() {
  7.     return window.clearTimeout(window.opt_cartPopupTimer);
  8.   };
  9.  
  10.   fadeOutWhenTimerEnds = function(x) {
  11.     return window.opt_cartPopupTimer = window.setTimeout(function() {
  12.       return $('.opt_cartPopup').fadeOut();
  13.     }, x);
  14.   };
  15.  
  16.   (function($) {
  17.     var basket, createProductRowHtml, originalFunction;
  18.     basket = window.basket;
  19.     createProductRowHtml = function(x) {
  20.       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>";
  21.     };
  22.     originalFunction = basket.UpdateCartInfo;
  23.     return basket.UpdateCartInfo = function(data) {
  24.       originalFunction(data);
  25.       return window.aj({
  26.         url: '/Common/BasketSVC.asmx/GetChkBasket',
  27.         successFunc: function(x) {
  28.           return $(function() {
  29.             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;
  30.             stats = x.d.Obj;
  31.             $('.opt_itemAmtNumb').text(stats.TotalItems.ProductCount);
  32.             $('.opt_cartCount').text(stats.TotalItems.ProductCount);
  33.             $('.opt_totalNumber').text(stats.SubTotal.toCurrency());
  34.             showOnlyLastProductAdded = false;
  35.             showProductPrice = false;
  36.             showHeader = false;
  37.             showCheckoutButton = false;
  38.             showViewCartButton = false;
  39.             showWhiteBackgroundForProducts = false;
  40.             showFooterItemsCount = false;
  41.             showFooterSubTotal = false;
  42.             showDeleteButton = false;
  43.             showLargeProductImage = false;
  44.             switch (window.OPT_TEST_VERSION) {
  45.               case 1:
  46.                 showOnlyLastProductAdded = true;
  47.                 showViewCartButton = true;
  48.                 showFooterItemsCount = true;
  49.                 break;
  50.               case 2:
  51.                 showOnlyLastProductAdded = true;
  52.                 showHeader = true;
  53.                 showProductPrice = true;
  54.                 showCheckoutButton = true;
  55.                 showWhiteBackgroundForProducts = true;
  56.                 showFooterSubTotal = true;
  57.                 showDeleteButton = true;
  58.                 showLargeProductImage = true;
  59.                 break;
  60.               case 3:
  61.                 showHeader = true;
  62.                 showProductPrice = true;
  63.                 showCheckoutButton = true;
  64.                 showWhiteBackgroundForProducts = true;
  65.                 showFooterSubTotal = true;
  66.                 showDeleteButton = true;
  67.                 showLargeProductImage = true;
  68.                 break;
  69.               default:
  70.                 console.log('OPT_TEST_VERSION not set');
  71.             }
  72.             html = '';
  73.             if (showOnlyLastProductAdded) {
  74.               if (window.LastAddedProductId) {
  75.                 _ref = stats.Items;
  76.                 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  77.                   x = _ref[_i];
  78.                   if (x.ProductId === Number(window.LastAddedProductId)) {
  79.                     html += createProductRowHtml(x);
  80.                   }
  81.                 }
  82.               } else {
  83.                 basketItemIds = [];
  84.                 _ref1 = stats.Items;
  85.                 for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
  86.                   x = _ref1[_j];
  87.                   if (x.ProductId !== 0) {
  88.                     basketItemIds.push(x.BasketItemId);
  89.                   }
  90.                 }
  91.                 lastAddedBasketItemId = Math.max.apply(null, basketItemIds);
  92.                 _ref2 = stats.Items;
  93.                 for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
  94.                   x = _ref2[_k];
  95.                   if (x.BasketItemId === lastAddedBasketItemId) {
  96.                     html += createProductRowHtml(x);
  97.                   }
  98.                 }
  99.               }
  100.             } else {
  101.               $('.opt_cart').addClass('opt_cartScroll');
  102.               _ref3 = stats.Items;
  103.               for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
  104.                 x = _ref3[_l];
  105.                 if (x.ProductId !== 0) {
  106.                   html += createProductRowHtml(x);
  107.                 }
  108.               }
  109.             }
  110.             $('.opt_cart').html(html);
  111.             if (showWhiteBackgroundForProducts) {
  112.               $('.opt_productAdd').addClass('opt_whiteBg');
  113.             }
  114.             if (stats.SubTotal > 50) {
  115.               $('.opt_noFreeShipping').hide();
  116.               $('.opt_freeShipping').show();
  117.             } else {
  118.               $('.opt_freeShipping').hide();
  119.               $('.opt_noFreeShipping').show();
  120.             }
  121.             if (showViewCartButton) {
  122.               $('.opt_viewCartButton').show();
  123.             }
  124.             if (showCheckoutButton) {
  125.               $('.opt_checkoutButton').show();
  126.             }
  127.             if (showHeader) {
  128.               $('.opt_itemAmt').show();
  129.             }
  130.             if (showFooterSubTotal) {
  131.               $('.opt_total').show();
  132.             }
  133.             if (showProductPrice) {
  134.               $('.opt_productPrice').show();
  135.             }
  136.             if (showFooterItemsCount) {
  137.               $('.opt_itmCart').show();
  138.             }
  139.             if (showDeleteButton) {
  140.               $('.opt_removeProductIcon').show();
  141.             }
  142.             if (showLargeProductImage) {
  143.               $('.opt_productImageSmall').removeClass('.opt_productImageSmall').addClass('opt_productImageLarge');
  144.               $('.opt_contentR').removeClass('opt_contentRWide').addClass('opt_contentRShort');
  145.             }
  146.             if (window.LastAddedProductId && window.OPT_TEST_VERSION) {
  147.               // $('.opt_cartPopup').show();
  148.               // The above line activates popup after each AddToCart click
  149.               clearTimer();
  150.               return fadeOutWhenTimerEnds(5000);
  151.             }
  152.           });
  153.         }
  154.       });
  155.     };
  156.   })(jQuery);
  157.  
  158.   jQuery(function($) {
  159.     var cartPopup, popup, styles;
  160.     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>';
  161.     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>';
  162.     $('head').append(styles);
  163.     $('#srhBarDiv').append(cartPopup);
  164.     $(document).on('click', '.opt_removeProductIcon', function() {
  165.       var icon;
  166.       icon = this;
  167.       return window.aj({
  168.         url: '/Common/BasketSVC.asmx/RemoveItem',
  169.         parms: JSON.stringify({
  170.           basketItemId: $(icon).data('basket-item-id'),
  171.           elementAction: 1
  172.         }),
  173.         successFunc: function(m) {
  174.           basket.GetBasketData();
  175.           return $(icon).parents('.opt_productAdd').fadeOut();
  176.         }
  177.       });
  178.     });
  179.     popup = $('.opt_cartPopup');
  180.     return $('.opt_cartPopup,#srhBarData').hover(function() {
  181.       if (!window.OPT_TEST_VERSION) {
  182.         return;
  183.       }
  184.       clearTimer();
  185.       return popup.stop(true, true).show();
  186.     }, function() {
  187.       if (!window.OPT_TEST_VERSION) {
  188.         return;
  189.       }
  190.       clearTimer();
  191.       return fadeOutWhenTimerEnds(300);
  192.     });
  193.   });
  194. }
  195. 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)}})}
  196.  
  197.  
  198. TestPlan.global.add(1, DisplayLargeMultiRowCartPreviewOnHover);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement