1(function($) { 2 "use strict"; 3 4 function get_cart() { 5 if (window.wc_add_to_cart_params != undefined) { 6 $.post({ 7 url: wc_add_to_cart_params.ajax_url, 8 dataType: 'JSON', 9 data: { 10 action: 'woomenucart_ajax' 11 }, 12 success: function(data, textStatus, XMLHttpRequest) { 13 $('.uncode-cart-dropdown').html(data.cart); 14 if (data != '') { 15 if ($('.uncode-cart .badge, .mobile-shopping-cart .badge').length) { 16 if (data.articles > 0) { 17 $('.uncode-cart .badge, .mobile-shopping-cart .badge').html(data.articles); 18 $('.uncode-cart .badge, .mobile-shopping-cart .badge').show(); 19 } else { 20 $('.uncode-cart .badge, .mobile-shopping-cart .badge').hide(); 21 } 22 } else $('.uncode-cart .cart-icon-container').append('<span class="badge">' + data.articles + '</span>'); //$('.uncode-cart .badge').html(data.articles); 23 } 24 } 25 }); 26 } 27 28 } 29 30 function remove_from_cart() { 31 $(document).on('click', '.uncode-cart-dropdown a.remove', function(e){ 32 33 var $remove = $(this), 34 product_id = $remove.attr("data-product_id"), 35 item_key = $remove.attr("data-item_key"), 36 $li = $remove.parents('.cart-item-list').eq(0).addClass('removing-item').animate({ 37 opacity: .5 38 },150); 39 40 $.post({ 41 dataType: 'json', 42 url: wc_add_to_cart_params.ajax_url, 43 data: { 44 action: "woomenucart_remove_ajax", 45 item_key: item_key 46 }, 47 success: function(html){ 48 $li.slideUp(200, function(){ 49 get_cart(); 50 }); 51 } 52 }); 53 54 return false; 55 }); 56 } 57 58 function change_images(event, variation) { 59 UNCODE.single_product_variation_already_changed = true; 60 if (variation.image_src !== '') { 61 var $target = event.target, 62 $row = $target.closest('.row-parent', $row), 63 get_href = $('a.woocommerce-main-image', $row), 64 $col_bg = $('.uncol-featured-image .background-inner', $row), 65 image_variable = $('> img', get_href), 66 image_thumb = variation.image.thumb_src, 67 image_srcset = variation.thumb_srcset, 68 getLightbox = UNCODE.lightboxArray[get_href.data('lbox')]; 69 get_href.data('options', "thumbnail: '" + variation.image_src + "'"); 70 image_variable.attr('src', variation.image_src); 71 if ( image_variable.hasClass('async-done') ) { 72 image_variable.attr('data-path', variation.uncode_image_path); 73 image_variable.attr('data-guid', variation.uncode_image_guid); 74 image_variable.removeClass('async-done').addClass('adaptive-async'); 75 UNCODE.adaptive(); 76 } 77 if (getLightbox != undefined) getLightbox.refresh(); 78 $(window).trigger('focus'); 79 80 if ( $('.woocommerce-product-gallery-nav').length ) { 81 var $first_thumb = $('.woocommerce-product-gallery-nav .woocommerce-product-gallery__wrapper-nav li.woocommerce-product-gallery__first-thumb img', $row); 82 if ( SiteParameters.uncode_adaptive == true ) { 83 var data_crop = $first_thumb.attr('data-crop'), 84 data_singlew = $first_thumb.attr('data-singlew'), 85 data_singleh = $first_thumb.attr('data-singleh'); 86 87 $first_thumb 88 .attr('data-path', variation.uncode_image_path) 89 .attr('data-guid', variation.uncode_image_guid) 90 .attr('data-uniqueid', variation.data_uniqueid) 91 .attr('data-width', variation.data_width) 92 .attr('data-height', variation.data_height) 93 .attr('data-singlew', variation.data_singlew) 94 .attr('data-singleh', variation.data_singleh) 95 .attr('data-crop', variation.data_crop) 96 .removeClass('async-done').addClass('adaptive-async'); 97 UNCODE.adaptive(); 98 } else { 99 $first_thumb 100 .attr('src', image_thumb); 101 if ( image_srcset ) { 102 $first_thumb.attr('srcset', image_srcset); 103 } 104 $(window).trigger('woocommerce_variation_has_loaded'); 105 } 106 } 107 108 if ( $col_bg.length ) { 109 var objImg = new Image(), 110 bg_img_src; 111 if ( $col_bg.hasClass( 'async-done') ) { 112 bg_img_src = variation.image_link; 113 } else { 114 bg_img_src = variation.image_src; 115 } 116 objImg.src = bg_img_src; 117 objImg.onload = function() { 118 $col_bg.animate({ opacity: 0 }, 100, function(){ 119 $col_bg.css({'background-image':'url('+bg_img_src+')'}); 120 $col_bg.animate({ opacity: 1 }, 250); 121 }); 122 } 123 } 124 } 125 } 126 127 function reset_data(event) { 128 if ( UNCODE.single_product_variation_already_changed ) { 129 var $col_bg = $('.uncol-featured-image .background-inner'), 130 $first_thumb = $('.woocommerce-product-gallery__first-thumb img'), 131 bg_img_src, 132 bg_img_srcset, 133 objImg = new Image(); 134 135 if ( $col_bg.length ) { 136 bg_img_src = $col_bg.attr('data-o_src'); 137 objImg = new Image(); 138 objImg.src = bg_img_src; 139 objImg.onload = function() { 140 $col_bg.animate({ opacity: 0 }, 100, function(){ 141 $col_bg.css({'background-image':'url('+bg_img_src+')'}); 142 $col_bg.animate({ opacity: 1 }, 250); 143 }); 144 } 145 } else if ( $first_thumb.length ) { 146 bg_img_src = $first_thumb.attr('data-o_src'); 147 bg_img_srcset = $first_thumb.attr('data-o_srcset'); 148 objImg = new Image(); 149 objImg.src = bg_img_src; 150 objImg.onload = function() { 151 $first_thumb 152 .attr('src', bg_img_src) 153 .attr('srcset', bg_img_srcset); 154 $(window).trigger('woocommerce_variation_has_loaded'); 155 } 156 } 157 } 158 } 159 160 function check_variation_values(event) { 161 var $selects = $(event.currentTarget).find('select'), 162 checkSelectValues = false;
163 $selects.each(function(){ 164 var $select = $(this); 165 if ( $select.val() !== '' ) { 166 checkSelectValues = true; 167 } 168 }); 169 170 if ( checkSelectValues ) { 171 $(event.currentTarget).removeClass('hide-clear'); 172 } else { 173 $(event.currentTarget).addClass('hide-clear'); 174 } 175 176 setTimeout(function(){ 177 $(window).trigger('woocommerce_variation_has_loaded'); 178 }, 1250); 179 } 180 181 function reloadVariations() { 182 remove_from_cart(); 183 $('body').on("added_to_cart wc_fragments_refreshed removed_from_cart", get_cart); 184 $('.variations_form') 185 .on("show_variation", change_images) 186 .on("reset_data", reset_data) 187 .on("check_variations", check_variation_values); 188 } 189 190 $(document).ready(reloadVariations); 191 $(document).on('uncode-quick-view-loaded', reloadVariations); 192 193 function handleRatings() { 194 if ( $('#rating').length ) { 195 setTimeout(function(){ 196 $('.comment-form-rating').each(function(){ 197 var $wrap = $(this), 198 $stars = $('p.stars', $wrap).remove(); 199 $( 'select[name="rating"]', $wrap ).hide().before( '<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>' ); 200 }); 201 }, 10); 202 } 203 } 204 205 $(document).ready(handleRatings); 206 $(document).on('vc-uncode_single_product_reviews', handleRatings); 207 208 $(document).on('vc-uncode_single_product_reviews', function(e, el) { 209 if ( el !== 'undefined' ) { 210 var $tabContainer = $(el).closest('.tab-container'); 211 $tabContainer.addClass('wootabs'); 212 } 213 } ); 214 215 var scrollToReviews = function(){ 216 if ( $('.wootabs, .wpb_accordion').length ) { 217 218 var hash = window.location.hash, 219 url = window.location.href, 220 $tabs = $( this ).find( 'ul.nav-tabs' ).first(), 221 $accordion = $( this ).find('.panel-group').first(), 222 scrollAction = false, 223 $tabs_wrapper = $tabs.closest('.wootabs'), 224 $both_wrapper, 225 $li, $panel, $click_trigger = false; 226 227 var scrollToReviewsInside = function( clicked ){ 228 229 if ( $tabs.length && $('#reviews', $tabs_wrapper).length ) { 230 var tab_reviews = $('#reviews', $tabs_wrapper).first().closest('.tab-pane').attr('id'); 231 $('[data-tab-id="' + tab_reviews + '"]', $tabs).addClass('reviews_tab'); 232 $li = $('.reviews_tab', $tabs); 233 $both_wrapper = $tabs_wrapper; 234 $click_trigger = true; 235 } else if ( $accordion.length && $('#reviews', $accordion).length ) { 236 var tab_reviews = $('#reviews', $accordion).first().closest('.tab-pane').attr('id'); 237 $panel = $('#reviews', $accordion).first().closest('.panel'); 238 $li = $('.panel-title', $panel); 239 $both_wrapper = $accordion; 240 $click_trigger = true; 241 } else if ( $('div#reviews').length && clicked ) { 242 $both_wrapper = $('div#reviews'); 243 scrollAction = true; 244 } else { 245 return false; 246 } 247 248 if ( $click_trigger && ( hash.toLowerCase().indexOf( 'comment-' ) >= 0 || hash === '#reviews' || hash === '#tab-reviews' ) ) { 249 $( 'a', $li ).click(); 250 scrollAction = true; 251 } else if ( $click_trigger && ( url.indexOf( 'comment-page-' ) > 0 || url.indexOf( 'cpage=' ) > 0 ) ) { 252 $( 'a', $li ).click(); 253 scrollAction = true; 254 } 255 256 if ( scrollAction ) { 257 var body = $("html, body"), 258 bodyTop = document.documentElement['scrollTop'] || document.body['scrollTop'], 259 delta = bodyTop - ($both_wrapper.length ? $both_wrapper.offset().top : 0), 260 getOffset = UNCODE.get_scroll_offset(); 261 if ( typeof $both_wrapper.offset() === 'undefined' ) 262 return; 263 scrollTo = $both_wrapper.offset().top - 27; 264 scrollTo -= getOffset; 265 266 var scrollSpeed = (SiteParameters.constant_scroll == 'on') ? Math.abs(delta) / parseFloat(SiteParameters.scroll_speed) : SiteParameters.scroll_speed; 267 if (scrollSpeed < 1000 && SiteParameters.constant_scroll == 'on') scrollSpeed = 1000; 268 269 if (scrollSpeed == 0) { 270 body.scrollTop((delta > 0) ? scrollTo - 0.1 : scrollTo); 271 } else { 272 body.animate({ 273 scrollTop: (delta > 0) ? scrollTo - 0.1 : scrollTo 274 }, scrollSpeed, 'easeInOutQuad'); 275 } 276 } else { 277 return false;
278 } 279 }; 280 281 scrollToReviewsInside( false ); 282 283 $('a.woocommerce-review-link').on('click', function(e) { 284 e.preventDefault(); 285 hash = '#reviews'; 286 scrollToReviewsInside( true ); 287 }); 288 289 } 290 } 291 $(document).ready(scrollToReviews); 292 293 var qtyPlusMinus = function(){ 294 $('.qty-inset:not(.qty-inset-active)').each(function(){ 295 var $qtyInsets = $(this).addClass('qty-inset-active'), 296 $input = $('input.qty', $qtyInsets), 297 $minus = $('.qty-minus', $qtyInsets), 298 $plus = $('.qty-plus', $qtyInsets), 299 step = parseFloat( $input.attr('step') ), 300 min = parseFloat( $input.attr('min') ), 301 max = parseFloat( $input.attr('max') ), 302 value = parseFloat( $input.val() ); 303 304 if ( isNaN(step) ) { 305 step = 1; 306 } 307 308 if ( isNaN(min) ) { 309 min = 1; 310 } 311 312 if ( isNaN(value) ) { 313 value = 0; 314 $input.val( value ); 315 } 316 317 $minus.on('click', function(){ 318 value = parseFloat( $input.val() ) - step; 319 if ( value < min ) { 320 value = min; 321 } 322 $input.val( value ).trigger( 'change' ); 323 }); 324 325 $plus.on('click', function(){ 326 value = parseFloat( $input.val() ) + step; 327 if ( isNaN(max) && value > max ) { 328 value = max; 329 } 330 $input.val( value ).trigger( 'change' ); 331 }); 332 }); 333 }; 334 335 var resizeCartRow = function(){ 336 if ($('form.woocommerce-cart-form').length > 0) { 337 window.dispatchEvent(new CustomEvent('vc-resize')); 338 } 339 }; 340 341 $(document.body).on('updated_cart_totals', qtyPlusMinus); 342 $(document.body).on('updated_cart_totals', resizeCartRow); 343 $(document).ready(qtyPlusMinus); 344 $(document).on('vc-frontend:vc_button', qtyPlusMinus); 345 346 var woocommerce_product_gallery = function() { 347 $( 'body:not(.single-uncodeblock) .woocommerce-product-gallery' ).each( function() { 348 349 var $slider = $(this), 350 $parent = $slider.closest('.uncode-wrapper').length ? $slider.closest('.uncode-wrapper') : $slider.closest('.uncont'), 351 cols = parseFloat( $slider.attr('data-columns') ), 352 dots = $parent.attr('data-dots') == 'true', 353 gutter = $parent.length && typeof $parent.attr('data-gutter') !== 'undefined' ? parseFloat( $parent.attr('data-gutter') ) : 18, 354 $main = $('.woocommerce-product-gallery__wrapper', $parent), 355 mainL = $main.find('.woocommerce-product-gallery__image').length, 356 $thumbs = $('.woocommerce-product-gallery__wrapper-nav', $parent), 357 thumbsL = $thumbs.find('li').length; 358 359 if ($.fn.owlCarousel) { 360 if ( mainL > 1 && $slider.hasClass('owl-carousel-wrapper') ) { 361 $main.owlCarousel({ 362 items: 1, 363 autoHeight: true, 364 dots: dots, 365 responsiveRefreshRate: 200, 366 }).on('changed.owl.carousel', function(event) { 367 if (event.namespace && event.property.name === 'position') { 368 var target = event.relatedTarget.relative(event.property.value, true); 369 syncPosition(target); 370 } 371 }); 372 $main.on('translate.owl.carousel', function(event) { 373 $(event.currentTarget).addClass('owl-translating'); 374 }); 375 $main.on('translated.owl.carousel', function(event) { 376 $(event.currentTarget).removeClass('owl-translating'); 377 }); 378 $thumbs.on('initialized.owl.carousel', function(event) { 379 $thumbs.closest('.woocommerce-product-gallery-nav-wrapper').css({ 380 opacity: 1 381 }); 382 }).owlCarousel({ 383 items: cols, 384 margin: gutter, 385 autoHeight: true, 386 nav: true, 387 mouseDrag: cols < thumbsL, 388 navText: ['<div class="owl-nav-container btn-default btn-hover-nobg"><i class="fa fa-fw fa-angle-left"></i></div>', '<div class="owl-nav-container btn-default btn-hover-nobg"><i class="fa fa-fw fa-angle-right"></i></div>'], 389 responsiveRefreshRate: 100, 390 }); 391 $(window).on('load uncode-quick-view-first-hover woocommerce_variation_has_loaded', function(){ 392 $main.trigger('refresh.owl.carousel'); 393 $thumbs.trigger('refresh.owl.carousel'); 394 }); 395 } 396 } 397 398 function syncPosition(target){ 399 var data = $thumbs.data('owl.carousel'); 400 if ( ! $('.owl-item', $thumbs).eq( target ).hasClass('active') ) { 401 $thumbs.owlCarousel( 'to', target, 300, true ); 402 } 403 } 404 405 $thumbs.on( 'click', '.owl-item', function(e){ 406 e.preventDefault(); 407 var number = $(this).index(); 408 $main.owlCarousel( 'to', number, 300, true ); 409 }); 410 411 412 if ($.fn.zoom && $('body').hasClass('wc-zoom-enabled') ) { 413 var $zoomTrgt = $('.woocommerce-product-gallery__image', $slider); 414 415 if ( $('.thumbnails', $slider).length ) 416 $zoomTrgt = $zoomTrgt.first(); 417 418 $zoomTrgt.trigger( 'zoom.destroy' ); 419 $zoomTrgt.zoom(); 420 421 var checkForZoom = function(){ 422 $('.woocommerce-product-gallery__image').each(function(){ 423 var $wrap = $(this), 424 $zoomImg = $('.zoomImg', $wrap); 425 426 if (UNCODE.isMobile || !$zoomImg.length) { 427 $wrap.addClass('mouse-moving'); 428 } 429 }); 430 431 var galleryWidth = $zoomTrgt.width(), 432 zoom_options = { 433 touch: true, 434 callback: function(){ 435 $('.woocommerce-product-gallery__image').each(function(){ 436 var $wrap = $(this), 437 $zoomImg = $('.zoomImg', $wrap), 438 $overZoom = $('.zoom-overlay', $wrap), 439 $imageIL = $('a[data-lbox]', $wrap), 440 $carousel = $wrap.closest('.owl-carousel'); 441 442 $wrap.prepend($zoomImg); 443 if (UNCODE.isMobile || !$zoomImg.length) { 444 $wrap.addClass('mouse-moving'); 445 $zoomImg.css({ 446 'visibility':'hidden' 447 }); 448 } 449 450 /* Make work everything on touch events */ 451 var onlongtouch, 452 timer, 453 now, 454 touchduration = 500, 455 startX = 0, startY, newX, newY; 456 457 $wrap.parent().on('mousemove.zoom', function(){ 458 if ( ! $wrap.hasClass('mouse-moving') ) { 459 if ( startX == 0 ) { 460 startX = event.clientX; 461 startY = event.clientY; 462 } 463 newX = event.clientX; 464 newY = event.clientY; 465 if ( Math.abs( newX - startX ) > 50 && Math.abs( newY - startY ) > 50 ) { 466 $wrap.addClass('mouse-moving'); 467 } 468 } 469 }); 470 471 $overZoom.on('touchstart.zoom', function (e) { 472 now = new Date().getTime(); 473 }).on('touchmove.zoom', function (e) { 474 setTimeout(function(){ 475 $zoomImg.css({ 476 'visibility':'visible' 477 }); 478 }, 100); 479 }).on('touchend.zoom', function (e) { 480 var newTap = new Date().getTime(); 481 if ( newTap - now < 75 && ! $('body').hasClass('ilightbox-noscroll') ) { 482 $imageIL.trigger('itap.iL'); 483 } 484 if (UNCODE.isMobile) { 485 $zoomImg.css({ 486 'visibility':'hidden' 487 }); 488 } 489 }); 490 491 }); 492 } 493 }; 494 495 if ( 'ontouchstart' in window ) { 496 zoom_options.on = 'click'; 497 } 498 499 $zoomTrgt.trigger( 'zoom.destroy' ); 500 $zoomTrgt.each(function(){ 501 var $thisTrgt = $(this), 502 $img = $('img', $thisTrgt); 503 504 if ( $img.data( 'large_image_width' ) > galleryWidth ) { 505 $thisTrgt.zoom(zoom_options); 506 } else { 507 $thisTrgt.trigger( 'zoom.destroy' ); 508 } 509 510 }); 511 }; 512 checkForZoom(); 513 514 var setCheckForZoom; 515 $(window).on( 'resize', function(){ 516 clearTimeout(setCheckForZoom); 517 setCheckForZoom = setTimeout( checkForZoom, 500 ); 518 }); 519 } 520 521 } ); 522 523 $(window).on('unmodal-open', function(){ 524 $('#unmodal-content .woocommerce-product-gallery__image').removeClass('mouse-moving'); 525 }) 526 $(document).on('unmodal-close', function(){ 527 $('#unmodal-content .woocommerce-product-gallery__image').removeClass('mouse-moving'); 528 }) 529 } 530 531 woocommerce_product_gallery(); 532 533 /************************************************************ 534 * Redirect to custom empty cart page 535 ************************************************************/ 536 537 $(document.body).on('wc_cart_emptied', redirect_to_custom_empty_cart); 538 539 function redirect_to_custom_empty_cart() { 540 if (UncodeWCParameters.empty_cart_url !== '') { 541 window.location.replace(UncodeWCParameters.empty_cart_url); 542 } 543 } 544
545 /************************************************************ 546 * Make the variation price inherit the font family from main price 547 ************************************************************/ 548 549 function variation_price_font() { 550 551 var $forms = $('form.variations_form'); 552 553 $forms.each(function(){ 554 var $form = $(this); 555 556 $form.on('woocommerce_variation_has_changed wc_variation_form', function(){ 557 var $var_price = $('.woocommerce-variation-price .woocommerce-Price-amount'), 558 $row = $form.closest('.vc_row'), 559 $main_price = $('.heading-text .woocommerce-Price-amount', $row); 560 561 if ( $main_price.length ) { 562 var $price_wrap = $main_price.closest('.heading-text'), 563 $price_nest = $('> *:first-child', $price_wrap), 564 font_class = $price_nest.attr('class').split(' '), 565 i; 566 567 for ( i = 0; i < font_class.length; i++ ) { 568 if ( font_class[i].indexOf('font') !== -1 && font_class[i].indexOf('fontsize') === -1 ) { 569 $var_price.addClass( font_class[i] ); 570 } 571 } 572 } 573 }); 574 }); 575 } 576 577 $(document).ready(function() { 578 variation_price_font(); 579 }); 580 581 /************************************************************ 582 * Show minicart when adding something 583 ************************************************************/ 584 585 var cartShow, cartHover; 586 587 var minicart_notify = function(){ 588 var $body = $('body'); 589 590 if ( ! $body.hasClass('minicart-notification') ) { 591 return false; 592 } 593 594 var $sidecart = $('#uncode_sidecart'), 595 $miniCart = $('.menu-smart .uncode-cart-dropdown'), 596 $smartMenu = $miniCart.closest('.menu-smart'); 597 598 $miniCart.on('hover', function(){ 599 clearTimeout(cartHover); 600 }); 601 602 var show_added_to_cart = function(e){ 603 604 clearTimeout(cartShow); 605 clearTimeout(cartHover); 606 607 if ( $sidecart.length ) { 608 $sidecart.imagesLoaded().done( function( instance ) { 609 setTimeout(function(){ 610 $body.addClass('uncode-sidecart-open'); 611 $(window).trigger('uncode-sidecart-open'); 612 }, 500); 613 }); 614 } 615 616 var show_added_to_cart_timeout = function(){ 617 cartShow = setTimeout(function(){ 618 $miniCart.imagesLoaded().done( function( instance ) { 619 $smartMenu.smartmenus('itemActivate', $('.uncode-cart > a')); 620 cartHover = setTimeout(function(){ 621 $smartMenu.smartmenus('menuHideAll'); 622 }, 4000); 623 }); 624 }, 500); 625 }; 626 627 if ( UNCODE.wwidth >= 960 ) { 628 if ( e == 'uncode-wc-added-to-cart' ) { 629 show_added_to_cart_timeout(); 630 } else { 631 $( document.body ).on( 'wc_fragments_loaded', function(){ 632 show_added_to_cart_timeout(); 633 }); 634 } 635 } 636 }; 637 $( document.body ).on( 'added_to_cart', show_added_to_cart ); 638 639 $(document).ready(function() { 640 if ( $('body').hasClass('uncode-wc-added-to-cart')) { 641 show_added_to_cart('uncode-wc-added-to-cart'); 642 } 643 }); 644 645 }; 646 647 minicart_notify(); 648 649 /************************************************************ 650 * View Cart Button 651 ************************************************************/ 652 $( document.body ).on( 'wc_cart_button_updated', function(e, $button){ 653 if ( $(document.body).hasClass('minicart-notification') ) { 654 return false; 655 } 656 657 $button 658 .addClass('added_and_noted') 659 .removeClass('ajax_add_to_cart') 660 .find('.added_to_cart') 661 .text( wc_add_to_cart_params.i18n_view_cart ) 662 .on('click', function(e){ 663 e.preventDefault(); 664 window.location.href = wc_add_to_cart_params.cart_url; 665 return false; 666 }); 667 }); 668 669 /************************************************************ 670 * Side Cart 671 ************************************************************/ 672 var init_sidecart = function(){ 673 var $body = $('body.uncode-sidecart-enabled'); 674 if ( ! $body.length ) { 675 return false; 676 } 677 678 var $cart_icon = $('.mobile-shopping-cart, .uncode-cart.menu-item-link > a'), 679 $sidecart = $('#uncode_sidecart'), 680 $view_cart = $('a.wc-forward:not(.checkout)', $sidecart).removeClass('btn-sm'), 681 $checkout = $('a.checkout', $sidecart).removeClass('btn-sm').addClass('btn-flat'),
682 $overlay = $('#uncode_sidecart_overlay'), 683 $close_cart = $('.close-mini-cart', $sidecart), 684 sidecart_hover = false; 685 686 $cart_icon.on('click', function( e ){ 687 if ( $sidecart.length && ! ( $(this).closest('.overlay').length && UNCODE.wwidth > UNCODE.mediaQuery ) && ( ! ( $body.hasClass('uncode-sidecart-mobile-disabled') && UNCODE.wwidth <= UNCODE.mediaQuery ) ) ) { 688 e.preventDefault(); 689 e.stopPropagation(); 690 $body.addClass('uncode-sidecart-open'); 691 $(window).trigger('uncode-sidecart-open'); 692 } 693 }); 694 695 $sidecart.on('mouseover',function(){ 696 sidecart_hover = true; 697 }).on('mouseout', function(){ 698 sidecart_hover = false; 699 }); 700 701 $body.on('click', function( e ){ 702 if ( $body.hasClass('uncode-sidecart-open') && !sidecart_hover ) { 703 $body.removeClass('uncode-sidecart-open'); 704 $(window).trigger('uncode-sidecart-closed'); 705 } 706 }); 707 708 $close_cart.on('click', function( e ){ 709 e.preventDefault(); 710 $body.removeClass('uncode-sidecart-open'); 711 $(window).trigger('uncode-sidecart-closed'); 712 }); 713 }; 714 $(document).ready(function(){ 715 init_sidecart(); 716 }); 717 $( document.body ).on("wc_fragments_refreshed added_to_cart removed_from_cart", function(){ 718 init_sidecart(); 719 requestTimeout( init_sidecart, 1 ); 720 }); 721 722 var sidecart_size = function(){ 723 var $body = $('body.uncode-sidecart-enabled'), 724 $widget_cart = $('.widget_shopping_cart_content'), 725 $mini_cart_item = $('.mini_cart_item', $widget_cart); 726 727 if ( $widget_cart.length ) { 728 $mini_cart_item.each(function(){ 729 var $this = $(this), 730 $img_product = $('.attachment-woocommerce_thumbnail', $this), 731 imgH = $img_product.height(); 732 733 $this.css({ 734 'min-height': imgH+6 735 }) 736 737 }); 738 } 739 if ( $body.length ) { 740 741 var $sidecart = $('#uncode_sidecart'), 742 $cart_header = $('.woocommerce-mini-cart-header', $sidecart), 743 headerH = $cart_header.outerHeight(), 744 $cart_footer = $('.woocommerce-mini-cart-footer', $sidecart), 745 footerH = $cart_footer.outerHeight(), 746 $cart_body = $('.woocommerce-mini-cart-body', $sidecart); 747 748 $cart_body.css({ 749 'padding-top':headerH, 750 'padding-bottom':footerH 751 }); 752 753 } 754 }; 755 $(document).ready(function(){ 756 var setCTA; 757 sidecart_size(); 758 requestTimeout(function(){ 759 $(window).on( 'resize', function(){ 760 clearRequestTimeout(setCTA); 761 setCTA = requestTimeout( sidecart_size, 100 ); 762 }); 763 }, 400); 764 }); 765 $( document.body ).on("wc_fragments_refreshed added_to_cart removed_from_cart", function(){ 766 sidecart_size(); 767 requestTimeout( sidecart_size, 1 ); 768 }); 769 770 /************************************************************ 771 * Quick view 772 ************************************************************/ 773 774 var modal_quick_view_content = $('.quick-view-content'); 775 var last_viewed_product_id; 776 777 $(document).off('click', '.quick-view-button').on('click', '.quick-view-button', function() { 778 var _this = $(this); 779 var product_id = _this.data('post-id'); 780 var post_type = _this.data('post-type'); 781 782 if (last_viewed_product_id === product_id && modal_quick_view_content.find('#product-' + product_id).length > 0) { 783 $(document).trigger('uncode-unmodal-show-content'); 784 785 // Re-open the open the modal instead of regenerating it 786 return false; 787 } 788 789 // Empty modal 790 if (modal_quick_view_content.length > 0) { 791 modal_quick_view_content.html(''); 792 } 793 794 // Get quick view content via AJAX 795 $.ajax({ 796 url: woocommerce_params.ajax_url, 797 data: { 798 action: 'uncode_load_ajax_quick_view', 799 post_id: product_id, 800 post_type: post_type, 801 }, 802 type: 'post', 803 error: function(data) { 804 if (SiteParameters.enable_debug == true) { 805 // This console log is disabled by default 806 // So nothing is printed in a typical installation 807 // 808 // It can be enabled for debugging purposes setting 809 // the 'uncode_enable_debug_on_js_scripts' filter to true 810 console.log('AJAX error on quick view response'); 811 } 812 }, 813 success: function(response) { 814 if (response && response.success === false) { 815 if (SiteParameters.enable_debug == true) { 816 // This console log is disabled by default 817 // So nothing is printed in a typical installation 818 // 819 // It can be enabled for debugging purposes setting 820 // the 'uncode_enable_debug_on_js_scripts' filter to true 821 if (response.data.error) { 822 console.log(response.data.error); 823 } else { 824 console.log('Unknown error on quick view response'); 825 } 826 } 827 } else { 828 var html = response.data.html; 829 830 if (modal_quick_view_content.length > 0) { 831 modal_quick_view_content.html(html); 832 } 833 834 last_viewed_product_id = product_id; 835 836 modal_quick_view_content.imagesLoaded().done( function( instance ) { 837 $(document).trigger('uncode-unmodal-show-content'); 838 $(document).trigger('uncode-quick-view-loaded'); 839 window.dispatchEvent(new CustomEvent('uncode-quick-view-loaded')); 840 841 setTimeout(function(){ 842 modal_quick_view_content.one('mousemove', function(){ 843 window.dispatchEvent(new CustomEvent('uncode-quick-view-first-hover')); 844 }); 845 }, 10); 846 }); 847 } 848 } 849 }); 850 851 return false;
852 }); 853 854 $(document).on('uncode-quick-view-loaded', function() { 855 var form_variation = modal_quick_view_content.find('.variations_form'); 856 857 form_variation.each(function() { 858 $(this).wc_variation_form(); 859 }); 860 861 form_variation.trigger('check_variations'); 862 form_variation.trigger('reset_image'); 863 864 if( typeof $.fn.wc_product_gallery !== 'undefined' ) { 865 modal_quick_view_content.find('.woocommerce-product-gallery').each(function(){ 866 $(this).wc_product_gallery(); 867 }); 868 } 869 870 $( '#unmodal-content' ).on( 'change', '.quantity .qty', function() { 871 jQuery( this ).closest('form.cart').find('.add_to_cart_button').attr( 'data-quantity', jQuery( this ).val() ); 872 }); 873 874 woocommerce_product_gallery(); 875 variation_price_font(); 876 qtyPlusMinus(); 877 878 UNCODE.preventDoubleTransition(); 879 UNCODE.utils(); 880 if (typeof UNCODE.share !== 'undefined') { 881 UNCODE.share(); 882 } 883 if (typeof UNCODE.tooltip !== 'undefined') { 884 UNCODE.tooltip(); 885 } 886 if (typeof UNCODE.counters !== 'undefined') { 887 UNCODE.counters(); 888 } 889 if (typeof UNCODE.countdowns !== 'undefined') { 890 UNCODE.countdowns(); 891 } 892 if (typeof UNCODE.tabs !== 'undefined') { 893 UNCODE.tabs(); 894 } 895 if (typeof UNCODE.collapse !== 'undefined') { 896 UNCODE.collapse(); 897 } 898 if (typeof UNCODE.okvideo !== 'undefined') { 899 UNCODE.okvideo(); 900 } 901 if (typeof UNCODE.backgroundSelfVideos !== 'undefined') { 902 UNCODE.backgroundSelfVideos(); 903 } 904 UNCODE.tapHover(); 905 if (typeof UNCODE.isotopeLayout !== 'undefined') { 906 UNCODE.isotopeLayout(); 907 } 908 if (typeof UNCODE.justifiedGallery !== 'undefined') { 909 UNCODE.justifiedGallery(); 910 } 911 if (typeof UNCODE.lightbox !== 'undefined') { 912 UNCODE.lightbox(); 913 } 914 if (typeof UNCODE.carousel !== 'undefined') { 915 UNCODE.carousel($('body')); 916 } 917 UNCODE.lettering(); 918 UNCODE.animations(); 919 UNCODE.stickyElements(); 920 if (typeof UNCODE.twentytwenty !== 'undefined') { 921 UNCODE.twentytwenty(); 922 } 923 UNCODE.disableHoverScroll(); 924 if (typeof uncode_progress_bar !== 'undefined') { 925 uncode_progress_bar(); 926 } 927 if (typeof UNCODE.filters !== 'undefined') { 928 UNCODE.filters(); 929 } 930 if (typeof UNCODE.widgets !== 'undefined') { 931 UNCODE.widgets(); 932 } 933 934 }); 935 936 /************************************************************ 937 * Trigger fragments 938 ************************************************************/ 939 if ( SiteParameters.update_wc_fragments == true ) { 940 $(document).ready(function() { 941 $(document.body).trigger('wc_fragment_refresh'); 942 }); 943 } 944 945})(jQuery);
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.