1function resizeFancybox() { 2 var $fwrap = $('#fancybox-wrap') 3 var modal = $fwrap.find('.popup-content').first() 4 if (!modal.width()) { 5 return 6 } 7 8 var maxWidth = parseInt(modal.data('max-width')) || 450 9 var outerPadding = parseInt(modal.data('padding')) || 0 10 var outerMargin = parseInt(modal.data('margin')) || 20 11 var minDiff = outerPadding * 2 + outerMargin * 2 12 var width = modal.width() 13 var availableWidth = $(window).width() - minDiff 14 15 var newWidth = 0 16 //window collapse 17 if (availableWidth < width) { 18 newWidth = availableWidth 19 } 20 //window expand 21 else if (availableWidth > width && width != maxWidth) { 22 if (availableWidth > maxWidth) { 23 newWidth = maxWidth 24 } else { 25 newWidth = availableWidth 26 } 27 } 28 29 newWidth = newWidth || width 30 modal.width(newWidth) 31 $('#fancybox-content').width(newWidth) 32 $fwrap.width(newWidth + outerPadding * 2) 33 34 $fwrap.stop().animate( 35 { 36 left: ($(window).width() - $fwrap.outerWidth()) / 2, 37 }, 38 160 39 ) 40 //$fwrap.css('left', (($(window).width() - $fwrap.outerWidth()) / 2) + 'px'); 41 //$.fancybox.center(); 42} 43var wishlist = { 44 speed: 350, 45 maxMobileWidth: 767, 46 idLang: 1, 47 $container: null, 48 49 clicked: true, 50 51 toggleWish: function (productId, checked) { 52 if (checked) { 53 $('#wlAdd' + productId) 54 .find('.hackyBox') 55 .attr('checked', true) 56 $('#wlAdd' + productId) 57 .find('.heartSymbol') 58 .addClass('in-wishlist') 59 } else { 60 $('#wlAdd' + productId) 61 .find('.hackyBox') 62 .attr('checked', false) 63 $('#wlAdd' + productId) 64 .find('.heartSymbol') 65 .removeClass('in-wishlist') 66 } 67 }, 68 69 animWish: function () { 70 var heartSymbol = $('.heartSymbol') 71 var heart = $('.heart') 72 73 this.clicked = false 74 75 heartSymbol.hide() 76 heart.css('animation-duration', '0') 77 78 setTimeout( 79 function (heartSymbol, heart) { 80 heartSymbol.show() 81 heart.css('animation-duration', '.45s') 82 }, 83 100, 84 heartSymbol, 85 heart 86 ) 87 88 this.clicked = true 89 }, 90 91 init: function () { 92 var self = this 93 94 self.idLang = parseInt($('input#id_lang').val()) || 1 95 self.$container = $('#wishlist') 96 self.$miniWishlist = $('#mini_wishlist_link .dropdown-block') 97 98 self.moveWishlistButtonForMobile() 99 100 if ($('#idCombination')) { 101 attr = $('.heartSymbol').attr('data-wl-combinations') 102 var idProduct = $('.add-to-wishlist-container') 103 .find('.wl_id_product') 104 .val() 105 if ( 106 attr && 107 !$.inArray($('.product_page #idCombination').val(), attr.split(';')) >= 108 0 109 ) { 110 self.toggleWish(idProduct, true) 111 } 112 } 113 114 $('.add-to-wl').live('click', function (e) { 115 if (!self.clicked) return 116 117 var $container = $(this).closest('.add-to-wishlist-container') 118 var $wishlistWrapper = $container.closest('.add-to-wishlist') 119 120 if ($wishlistWrapper.length && $wishlistWrapper.data('wishlist-disabled') == 1) { 121 e.preventDefault(); 122 e.stopPropagation(); 123 return false 124 } 125 126 var idProduct = $container.find('.wl_id_product').val() 127 var idCombination 128 if ( 129 $container 130 .closest('.ajax-block-product-content') 131 .find('.atdevshowattribute .product-combination').length 132 ) { 133 idCombination = $container 134 .closest('.ajax-block-product-content') 135 .find('.atdevshowattribute .product-combination') 136 .attr('data-product-attribute') 137 } else { 138 idCombination = 139 $container.find('.wl_id_product_attribute').val() || 140 $('#idCombination').val() || 141 0 142 } 143 self.addToWL( 144 idProduct, 145 idCombination, 146 $container.find('.wl_current_uri').val() 147 ) 148 }) 149 150 $('.delete-product, .ajax_wishlist_block_remove_link').live( 151 'click', 152 function (e) { 153 e.preventDefault() 154 self.deleteProduct($(this).closest('.wl-product')) 155 return false 156 } 157 ) 158 159 $('.jsContinueShopping').live('click', function (e) { 160 e.preventDefault() 161 $('#fancybox-close').trigger('click') 162 }) 163 164 $('#idCombination').change(function () { 165 if ( 166 $.inArray( 167 $('#idCombination').val(), 168 $('.heartSymbol').attr('data-wl-combinations').split(';') 169 ) >= 0 170 ) { 171 self.toggleWish($(this).data('product-id'), true) 172 } else { 173 self.toggleWish($(this).data('product-id'), false) 174 } 175 }) 176 177 var wlItemHeight = 0 178 $('.wl-product h3.title').each(function (key, obj) { 179 if ($(obj).height() > wlItemHeight) { 180 wlItemHeight = $(obj).height() 181 } 182 }) 183 184 if (wlItemHeight) { 185 $('.wl-product h3.title').css('height', wlItemHeight + 'px') 186 } 187 }, 188 /*This function move all wishlist buttons from desktop price block to mobile price block 189 to display them on mobile version (https://redmine.3atdev.net/issues/32051#note-18)*/ 190 moveWishlistButtonForMobile: function () {
191 const addToWishlistContainers = $('.add-to-wishlist-container') 192 if ( 193 window.innerWidth <= this.maxMobileWidth && 194 addToWishlistContainers.length 195 ) { 196 addToWishlistContainers.each(function () { 197 const addToWishlistContainerCopy = $(this).clone(true) 198 const priceBlock = $(this) 199 .closest('.prices-block-wrap') 200 .find('.prices-block') 201 if (priceBlock.length) { 202 $(this).remove() 203 priceBlock.append(addToWishlistContainerCopy) 204 } 205 }) 206 } 207 }, 208 209 getPopupContainer: function () { 210 return $('#fancybox-content .wishlist-alert-wrapper.added-procuct') 211 }, 212 213 addToWL: function (idProduct, idProductAttribute) { 214 var self = this 215 216 $.ajax({ 217 type: 'POST', 218 url: '/modules/wishlist/ajax.php', 219 data: 220 'ajaxAddToWishlist=1&id_product=' + 221 idProduct + 222 '&id_product_attribute=' + 223 idProductAttribute + 224 '&id_lang=' + 225 self.idLang, 226 dataType: 'json', 227 success: function (data) { 228 if (typeof data == 'object') { 229 if (data.success) { 230 if (data.miniwishlist_html) { 231 self.$miniWishlist.html(data.miniwishlist_html) 232 } 233 if (data.confirm_popup_html) { 234 self.showPopup(data.confirm_popup_html) 235 } else if (data.auth_popup_html) { 236 self.showPopup(data.auth_popup_html) 237 } else if (data.id_product) { 238 if (typeof data.deleted === 'undefined') { 239 $('.search-item[data-id=' + idProduct + '] .add-icon').addClass( 240 'added' 241 ) 242 var wlAttributes = $('#wlAddBtn' + data.id_product) 243 .attr('data-wl-combinations') 244 .split(';') 245 if ($.inArray(data.id_product_attribute, wlAttributes) < 0) { 246 wlAttributes.push(data.id_product_attribute) 247 } 248 self.toggleWish(data.id_product, true) 249 $('#wlAddBtn' + data.id_product).attr( 250 'data-wl-combinations', 251 wlAttributes.join(';') 252 ) 253 } else { 254 $( 255 '.search-item[data-id=' + idProduct + '] .add-icon' 256 ).removeClass('added') 257 $('#wlAddBtn' + data.id_product).removeClass('in-wishlist') 258 var wlAttributes = $('#wlAddBtn' + data.id_product) 259 .attr('data-wl-combinations') 260 .split(';') 261 $.each(wlAttributes, function (index, el) { 262 if (el == data.id_product_attribute) { 263 wlAttributes.splice(index, 1) 264 } 265 }) 266 self.toggleWish(data.id_product, false) 267 $('#wlAddBtn' + data.id_product).attr( 268 'data-wl-combinations', 269 wlAttributes.join(';') 270 ) 271 } 272 } else { 273 alert('Technical error') 274 } 275 if (!data.deleted) { 276 document.dispatchEvent( 277 new CustomEvent('afterAddToWishlist', { 278 detail: { gaData: data.gaData }, 279 }) 280 ) 281 } 282 } else if (data.error) { 283 } 284 } else { 285 alert('Technical error') 286 } 287 }, 288 error: function (XMLHttpRequest, textStatus, errorThrown) { 289 alert('Technical error') 290 }, 291 }) 292 }, 293 294 showPopup: function (content) { 295 $.fancybox({ 296 content: $(content), 297 padding: 0, 298 margin: 20, 299 autoScale: true, 300 centerOnScroll: true, 301 autoDimensions: true, 302 transitionIn: 'none', 303 transitionOut: 'none', 304 onComplete: function () { 305 $('#fancybox-outer').addClass('wl') 306 $('#fancybox-wrap').addClass('wl') 307 resizeFancybox() 308 }, 309 }) 310 }, 311 312 deleteProduct: function ($product) { 313 var self = this 314 315 var idProduct = $product.data('id') 316 var idAttr = $product.data('id-attr') 317 318 $.ajax({ 319 type: 'POST', 320 url: '/modules/wishlist/ajax.php', 321 data: 322 'ajaxDeleteProduct=1&id_product=' + 323 idProduct + 324 '&id_attr=' + 325 idAttr + 326 '&id_lang=' + 327 self.idLang, 328 dataType: 'json', 329 success: function (data) { 330 if (typeof data == 'object') { 331 if (data.success) { 332 $('.search-item[data-id=' + idProduct + '] .add-icon').removeClass( 333 'added' 334 ) 335 336 self.$container 337 .find( 338 '.wl-product[data-id="' + 339 idProduct + 340 '"][data-id-attr="' + 341 idAttr + 342 '"]' 343 ) 344 .each(function () { 345 $(this) 346 .hide(600) 347 .remove() 348 .delay(600) 349 .queue(function () { 350 if (data.empty_list_html) { 351 self.$container.append(data.empty_list_html) 352 } 353 }) 354 }) 355 self.$miniWishlist 356 .find( 357 '.wl-product[data-id="' + 358 idProduct + 359 '"][data-id-attr="' + 360 idAttr + 361 '"]' 362 ) 363 .each(function () { 364 $(this).hide(600).remove() 365 if (data.empty_list_html) { 366 self.$miniWishlist.append( 367 '<div class="no-products-message">' + 368 data.empty_list_html + 369 '</div>' 370 ) 371 self.$miniWishlist.find('.block-with-button').hide() 372 } 373 }) 374 if ( 375 self.getPopupContainer().data('product-id') === 376 $product.data('id') 377 ) { 378 self 379 .getPopupContainer() 380 .find('.wishlist-result-product') 381 .hide(600) 382 .delay(600) 383 .remove() 384 if (data.removed_product_message) { 385 self 386 .getPopupContainer() 387 .find('.whishlist-result-title') 388 .html(data.removed_product_message) 389 .addClass('removed-product') 390 .after( 391 '<div class="remove-results-info">' + 392 data.products_count + 393 '</div>' 394 ) 395 } 396 } 397 398 var totalItms = parseInt($('.nProductsInWishlist span').text()) 399 if (!data.already_deleted) { 400 $('.nProductsInWishlist span').text(--totalItms) 401 } 402 403 if ($('.wl-product').length == 0 && totalItms != 0) { 404 window.location = window.location.pathname 405 } 406 407 if (totalItms == 0) { 408 $('.nProductsInWishlist').hide() 409 $('.nProductsEmpty').show() 410 } 411 } else if (data.error) { 412 console.log(data.error) 413 } 414 } else { 415 alert('Technical error') 416 } 417 }, 418 error: function (XMLHttpRequest, textStatus, errorThrown) { 419 alert('Technical error') 420 }, 421 }) 422 423 return false 424 }, 425} 426 427$(function () {
428 wishlist.init() 429})
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.