1var Wick = Wick || {}; 2Wick.MiniBasket = { 3 4 initialize: function() { 5 var $el = $('.header-minicart-wrap .header-minicart__switcher'); 6 7 if (Wick.Responsive.getCurrentBreakpoint() === 'up-lg') { 8 $el = $('.header-right__item .header-minicart__switcher'); 9 } 10 11 var $rollover = $('#mini-basket-rollover'), 12 $popup = $('#mini-basket-popup'), 13 $body = $('body'), 14 fixContent = 'fixed-content', 15 $switcherBtn = $('.header-minicart__btn_switcher'), 16 $linkBtn = $('.header-minicart__btn_link'); 17 18 if (Wick.Responsive.isTouchDevice()) { 19 $linkBtn.on('touchstart', function () { 20 document.location.href = $linkBtn[0].href; 21 }); 22 } 23 24 var showMiniBasketLink = function () { 25 $switcherBtn.hide(); 26 $linkBtn.show(); 27 $body.addClass(fixContent); 28 }; 29 30 var hideMiniBasketLink = function () { 31 $switcherBtn.show(); 32 $linkBtn.hide(); 33 $body.removeClass(fixContent); 34 }; 35 36 var removeSwitcherButton = function () { 37 $switcherBtn.remove(); 38 $linkBtn.show(); 39 $body.removeClass(fixContent); 40 }; 41 42 var popup = { 43 isExist: false, 44 self: '.popover-mini-basket_just-added', 45 timeout: undefined, 46 productTitle: '.popover-mini-basket_just-added .product-card__title', 47 btnClose: '.popover-mini-basket_just-added .notification__close', 48 create: function (data) { 49 var $justAddedPopover = $el 50 .popover({ 51 trigger: 'manual', 52 html: true, 53 placement: 'bottom', 54 fallbackPlacement: 'clockwise', 55 offset: '-65%', 56 content: $popup.html(data).html(), 57 sanitize: false 58 }) 59 .popover('show'); 60 61 if (Wick.Responsive.isTouchDevice()) { 62 $justAddedPopover.on('shown.bs.popover', hideMiniBasketLink); 63 } 64 65 popup.timeout = setTimeout(function () { 66 popup.destroy(); 67 }, 6000); 68 69 $(popup.productTitle).each(function (index, value) { 70 $clamp(value, {clamp: 3}); 71 }); 72 73 if ($('.header-wrapper').length || $('.sticky-header-wrapper').length) { 74 $('html, body').animate({scrollTop: 0}, 300); 75 } 76 77 popup.isExist = true; 78 }, 79 bindEvents: function () { 80 $(document).on('click', popup.btnClose, function () { 81 popup.destroy(); 82 }); 83 }, 84 destroy: function () { 85 if (!popup.isExist){ 86 return; 87 } 88 89 $el.popover('dispose'); 90 popup.isExist = false; 91 clearTimeout(popup.timeout); 92 } 93 }; 94 95 var rollover = { 96 isExist: false, 97 self: '.popover-mini-basket_permanent', 98 productTitle: '.popover-mini-basket_permanent .product-card__title', 99 btnClose: '.popover-mini-basket_permanent .notification__close', 100 create: function(){ 101 popup.destroy(); 102 103 $.ajax({ 104 url: rolloverPopupUrl, 105 cache: false, 106 type: 'GET', 107 async: false, 108 success: function (data) { 109 $rollover.html(data); 110 } 111 }); 112 113 var $popover = $el.popover({ 114 trigger: 'manual', 115 html: true, 116 placement: 'bottom', 117 fallbackPlacement: 'clockwise', 118 offset: '-65%', 119 content: $rollover.html(), 120 sanitize: false 121 }); 122 123 $popover.on('inserted.bs.popover', function(){ 124 $(rollover.productTitle).each(function (index, value) { 125 $clamp(value, {clamp: 3}); 126 }); 127 }); 128 129 if (Wick.Responsive.isTouchDevice()) { 130 $popover.on('hidden.bs.popover', hideMiniBasketLink) 131 .on('shown.bs.popover', showMiniBasketLink); 132 } 133 134 var $expandedEl = $("footer"); 135 $popover.on('hidden.bs.popover', function () { 136 $expandedEl.css("padding-top", "inherit"); 137 }) 138 .on('show.bs.popover', function () { 139 var popoverContent = $rollover.html(), 140 productIdentifier = '<div class="card product-card-preview product-card-preview_horizontal">', 141 productsCount = popoverContent.split(productIdentifier).length - 1, 142 productPageLimit = 4, 143 popoverMaxHeight = 868, 144 contentBodyHeight = $("main").innerHeight() + $("footer").innerHeight(); 145 146 if (productPageLimit < productsCount && contentBodyHeight <= popoverMaxHeight) { 147 var diff = popoverMaxHeight - contentBodyHeight; 148 $expandedEl.css("padding-top", diff+"px"); 149 } 150 }); 151 152 rollover.isExist = true; 153 }, 154 155 keepPopup: function(e) { 156 return !$('.popover').hasClass('show') 157 || $(e.target).parents(rollover.self).length 158 || $(e.target).parents(popup.self).length 159 || $(e.target).closest('.header-minicart__btn').length 160 || $('.sidebar_outer:visible').length; 161 }, 162 163 _bindTouchEvents: function(){ 164 $el.on('touchstart', function(){ 165 if (!rollover.isExist) { 166 rollover.create(); 167 } 168 $el.popover('show'); 169 }); 170 171 $(document).off("touchstart.leaveBasket").on("touchstart.leaveBasket", function (e) { 172 if (rollover.keepPopup(e)) { 173 return; 174 } 175 $el.popover('hide'); 176 }); 177 }, 178 _bindEvents: function(){ 179 $el.on('mouseenter', function() { 180 if (!rollover.isExist) { 181 rollover.create(); 182 } 183 $el.popover('show'); 184 }) 185 .on('mouseleave', function() { 186 setTimeout(function() { 187 if (!$('.popover:hover').length) { 188 $el.popover('hide'); 189 } 190 }, 100); 191 }); 192 193 $(document).on('mouseleave', rollover.self, function(){ 194 $el.popover('hide'); 195 }); 196 }, 197 bindEvents: function(){ 198 $(document).on('click', rollover.btnClose, function () { 199 rollover.destroy(); 200 }); 201 if (!Wick.Responsive.isTouchDevice()) { 202 this._bindEvents(); 203 } else { 204 this._bindTouchEvents(); 205 } 206 }, 207 destroy: function () { 208 if (!rollover.isExist) { 209 return; 210 } 211 212 $el.popover('dispose'); 213 rollover.isExist = false;
214 } 215 }; 216 217 if (!Wick.Responsive.isTouchDevice()) { 218 removeSwitcherButton(); 219 } 220 221 $(document).on("cartUpdate", function() { 222 Wick.MiniBasket.refreshMiniCart(); 223 }); 224 225 return { 226 showJustAdded: function (data) { 227 Wick.MiniBasketSlider.showProductAddedToCartSlider(data); 228 }, 229 230 refreshMiniCart : function() { 231 var url = '/cart/enhancedMiniCart/SUBTOTAL/?'; 232 if (typeof refreshMiniCartUrl !== 'undefined') { 233 url = refreshMiniCartUrl; 234 } 235 $.ajax({ 236 dataType: "json", 237 type : 'GET', 238 url: url + Math.floor(Math.random() * 101) * (new Date().getTime()), 239 cache: false 240 }).done(function(result) { 241 $('.header-minicart__btn-label').html(result.miniCartTotal); 242 $('.header-minicart__counter').html(result.totalItems); 243 $('.basket-total-items').html(result.totalItems); 244 }); 245 } 246 }; 247 }, 248 249 disablePopupElement: function(context, checkForAsmCheckout) { 250 if (typeof isASMWithGuest !== 'undefined' && isASMWithGuest && checkForAsmCheckout) { 251 $(".asm-guest__error-container").html($("#asm-guest__error-message").html()); 252 event.preventDefault(); 253 } else { 254 setTimeout((function() { 255 $(context).attr("disabled", "disabled"); 256 }).bind(this), 100); 257 } 258 } 259}; 260 261Object.assign(Wick.MiniBasket, Wick.MiniBasket.initialize());
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.