1(function($) { 2 "use strict"; 3 4 var UNCODE_WC = window.UNCODE_WC || {}; 5 window.UNCODE_WC = UNCODE_WC; 6 7 function get_cart() { 8 var ajaxurl = ''; 9 10 if (window.wc_add_to_cart_params != undefined) { 11 ajaxurl = wc_add_to_cart_params.ajax_url 12 } 13 14 if (window.woocommerce_params != undefined) { 15 ajaxurl = woocommerce_params.ajax_url 16 } 17 18 if (ajaxurl) { 19 $.post({ 20 url: ajaxurl, 21 dataType: 'JSON', 22 data: { 23 action: 'woomenucart_ajax' 24 }, 25 success: function(data, textStatus, XMLHttpRequest) { 26 $('.uncode-cart-dropdown').html(data.cart); 27 if (data != '') { 28 if ( SiteParameters.uncode_wc_popup_cart_qty ) { 29 if ($('.uncode-cart .badge, .mobile-shopping-cart .badge').length) { 30 $('.uncode-cart .badge, .mobile-shopping-cart .badge').html(data.articles); 31 } else { 32 $('.uncode-cart .cart-icon-container').append('<span class="badge init-product-counter">' + data.articles + '</span>'); //$('.uncode-cart .badge').html(data.articles); 33 } 34 $(document.body).trigger('uncode_get_cart', [data.articles]); 35 } else { 36 if ($('.uncode-cart .badge, .mobile-shopping-cart .badge').length) { 37 if (data.articles > 0) { 38 $('.uncode-cart .badge, .mobile-shopping-cart .badge').html(data.articles); 39 $('.uncode-cart .badge, .mobile-shopping-cart .badge').show(); 40 } else { 41 $('.uncode-cart .badge, .mobile-shopping-cart .badge').hide(); 42 } 43 } else { 44 $('.uncode-cart .cart-icon-container').append('<span class="badge">' + data.articles + '</span>'); //$('.uncode-cart .badge').html(data.articles); 45 } 46 } 47 } 48 } 49 }); 50 } 51 52 } 53 54 function remove_from_cart() { 55 $(document).on('click', '.uncode-cart-dropdown a.remove', function(e){ 56 57 var $remove = $(this), 58 product_id = $remove.attr("data-product_id"), 59 item_key = $remove.attr("data-item_key"), 60 $li = $remove.parents('.cart-item-list').eq(0).addClass('removing-item').animate({ 61 opacity: .5 62 },150); 63 64 $.post({ 65 dataType: 'json', 66 url: wc_add_to_cart_params.ajax_url, 67 data: { 68 action: "woomenucart_remove_ajax", 69 item_key: item_key 70 }, 71 success: function(html){ 72 $li.slideUp(200, function(){ 73 get_cart(); 74 }); 75 } 76 }); 77 78 return false; 79 }); 80 } 81 82 function reset_product_image(event, variation) { 83 var $target = event.target, 84 $row = $target.closest('.row-parent', $row), 85 get_href = $('a.woocommerce-main-image', $row), 86 image_variable = $('> img', get_href), 87 getLightbox = typeof UNCODE.lightbox !== 'undefined' && !SiteParameters.lbox_enhanced ? UNCODE.lightboxArray[get_href.data('lbox')] : false; 88 89 if (SiteParameters.uncode_adaptive == true) { 90 image_variable.removeClass(['async-done', 'woocommerce-product-gallery__image-first__img']).addClass('adaptive-async'); 91 image_variable.wc_reset_variation_attr( 'src' ); 92 image_variable.wc_reset_variation_attr( 'data-path' ); 93 image_variable.wc_reset_variation_attr( 'data-guid' ); 94 UNCODE.adaptive(); 95 } 96 97 if (getLightbox != undefined && getLightbox !== false) { 98 getLightbox.refresh(); 99 } else if ( SiteParameters.lbox_enhanced ) { 100 get_href.closest('.woocommerce-product-gallery').trigger('more-items-loaded'); 101 } 102 } 103 104 function change_images(event, variation) { 105 if ($(this).closest('.tmb-woocommerce').length > 0) { 106 return; 107 } 108 109 UNCODE.single_product_variation_already_changed = true; 110 if (variation.image_src !== '') { 111 var $target = event.target, 112 $row = $target.closest('.row-parent', $row), 113 get_href = $('a.woocommerce-main-image', $row), 114 $col_bg = $('.uncol-featured-image .background-inner', $row), 115 image_variable = $('> img', get_href), 116 image_thumb = variation.image.thumb_src, 117 gallery_thumb = variation.image.gallery_thumbnail_src, 118 image_srcset = variation.image.thumb_srcset, 119 getLightbox = typeof UNCODE.lightbox !== 'undefined' && !SiteParameters.lbox_enhanced ? UNCODE.lightboxArray[get_href.data('lbox')] : false; 120 get_href.data('options', "thumbnail: '" + variation.image_src + "'"); 121 if (SiteParameters.uncode_adaptive == true) { 122 image_variable.wc_set_variation_attr( 'src', variation.image_src );
123 image_variable.wc_set_variation_attr( 'data-path', variation.uncode_image_path ); 124 image_variable.wc_set_variation_attr( 'data-guid', variation.uncode_image_guid ); 125 image_variable.removeClass(['async-done', 'woocommerce-product-gallery__image-first__img']).addClass('adaptive-async'); 126 UNCODE.adaptive(); 127 } 128 if (getLightbox != undefined && getLightbox !== false) { 129 getLightbox.refresh(); 130 } else if ( SiteParameters.lbox_enhanced ) { 131 get_href.closest('.woocommerce-product-gallery').trigger('more-items-loaded'); 132 } 133 if (!UNCODE.isFrontEndEditor) { 134 $(window).trigger('focus'); 135 } 136 137 var $woocommerce_product_gallery_nav = $('.woocommerce-product-gallery-nav'); 138 139 if ($woocommerce_product_gallery_nav.length) { 140 var $first_thumb = $woocommerce_product_gallery_nav.find('.woocommerce-product-gallery__wrapper-nav li.woocommerce-product-gallery__first-thumb img', $row); 141 if ( SiteParameters.uncode_adaptive == true ) { 142 var data_crop = $first_thumb.attr('data-crop'), 143 data_singlew = $first_thumb.attr('data-singlew'), 144 data_singleh = $first_thumb.attr('data-singleh'); 145 146 $first_thumb 147 .attr('src', gallery_thumb) 148 .attr('data-path', variation.uncode_image_path) 149 .attr('data-guid', variation.uncode_image_guid) 150 .attr('data-uniqueid', variation.data_uniqueid) 151 .attr('data-width', variation.data_width) 152 .attr('data-height', variation.data_height) 153 .attr('data-singlew', variation.data_singlew) 154 .attr('data-singleh', variation.data_singleh) 155 .attr('data-crop', variation.data_crop); 156 157 if (!$woocommerce_product_gallery_nav.hasClass('lateral-nav-wrapper')) { 158 $first_thumb.removeClass(['async-done', 'adaptive-fetching']).addClass('adaptive-async'); 159 UNCODE.adaptive(); 160 } 161 } else { 162 $first_thumb 163 .attr('src', gallery_thumb); 164 if ( image_srcset ) { 165 $first_thumb.attr('srcset', image_srcset); 166 } 167 $(window).trigger('woocommerce_variation_has_loaded'); 168 } 169 } 170 171 if ( $col_bg.length ) { 172 var objImg = new Image(), 173 bg_img_src; 174 if ( $col_bg.hasClass( 'async-done') ) { 175 bg_img_src = variation.image_link; 176 } else { 177 bg_img_src = variation.image_src; 178 } 179 objImg.src = bg_img_src; 180 objImg.onload = function() { 181 $col_bg.animate({ opacity: 0 }, 100, function(){ 182 $col_bg.css({'background-image':'url('+bg_img_src+')'}); 183 $col_bg.animate({ opacity: 1 }, 250); 184 }); 185 } 186 } 187 } 188 } 189 190 function reset_data(event) { 191 if ( UNCODE.single_product_variation_already_changed ) { 192 var $col_bg = $('.uncol-featured-image .background-inner'), 193 $first_thumb = $('.woocommerce-product-gallery__first-thumb img'), 194 bg_img_src, 195 bg_img_srcset, 196 objImg = new Image(); 197 198 if ( $col_bg.length ) { 199 bg_img_src = $col_bg.attr('data-o_src'); 200 objImg = new Image(); 201 objImg.src = bg_img_src; 202 objImg.onload = function() { 203 $col_bg.animate({ opacity: 0 }, 100, function(){ 204 $col_bg.css({'background-image':'url('+bg_img_src+')'}); 205 $col_bg.animate({ opacity: 1 }, 250); 206 }); 207 } 208 } else if ( $first_thumb.length ) { 209 bg_img_src = $first_thumb.attr('data-o_src'); 210 bg_img_srcset = $first_thumb.attr('data-o_srcset'); 211 objImg = new Image(); 212 objImg.src = bg_img_src; 213 objImg.onload = function() { 214 $first_thumb 215 .attr('src', bg_img_src) 216 .attr('srcset', bg_img_srcset); 217 $(window).trigger('woocommerce_variation_has_loaded'); 218 } 219 } 220 } 221 } 222 223 function check_variation_values(event) { 224 var $selects = $(event.currentTarget).find('select'), 225 checkSelectValues = false; 226 $selects.each(function(){ 227 var $select = $(this); 228 if ( $select.val() !== '' ) { 229 checkSelectValues = true; 230 } 231 }); 232 233 if ( checkSelectValues ) { 234 $(event.currentTarget).removeClass('hide-clear'); 235 } else { 236 $(event.currentTarget).addClass('hide-clear'); 237 } 238 239 setTimeout(function(){ 240 $(window).trigger('woocommerce_variation_has_loaded'); 241 }, 1250); 242 } 243 244 function reloadVariations() { 245 remove_from_cart(); 246 $('body').on("added_to_cart wc_fragments_refreshed removed_from_cart", get_cart); 247 if (!$('body').hasClass('uncode-default-product-gallery')) { 248 $('.variations_form') 249 .on("show_variation", change_images) 250 .on("reset_data", reset_data) 251 .on("check_variations", check_variation_values) 252 .on('reset_image', reset_product_image); 253 } 254 } 255
256 $(document).ready(reloadVariations); 257 258 function handleRatings() { 259 if ( $('#rating').length ) { 260 setTimeout(function(){ 261 $('.comment-form-rating').each(function(){ 262 var $wrap = $(this), 263 $stars = $('p.stars', $wrap).remove(); 264 $( '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>' ); 265 }); 266 }, 10); 267 } 268 } 269 270 $(document).ready(handleRatings); 271 $(document).on('vc-uncode_single_product_reviews', handleRatings); 272 273 $(document).on('vc-uncode_single_product_reviews', function(e, el) { 274 if ( el !== 'undefined' ) { 275 var $tabContainer = $(el).closest('.tab-container'); 276 $tabContainer.addClass('wootabs'); 277 } 278 } ); 279 280 var scrollToReviews = function(){ 281 if ( $('.wootabs, .wpb_accordion').length ) { 282 283 var hash = window.location.hash, 284 url = window.location.href, 285 $tabs = $( this ).find( 'ul.nav-tabs' ).first(), 286 $accordion = $( this ).find('.panel-group').first(), 287 scrollAction = false, 288 $tabs_wrapper = $tabs.closest('.wootabs'), 289 $both_wrapper, 290 $li, $panel, $click_trigger = false; 291 292 var scrollToReviewsInside = function( clicked ){ 293 294 if ( $tabs.length && $('#reviews', $tabs_wrapper).length ) { 295 var tab_reviews = $('#reviews', $tabs_wrapper).first().closest('.tab-pane').attr('id'); 296 $('[data-tab-id="' + tab_reviews + '"]', $tabs).addClass('reviews_tab'); 297 $li = $('.reviews_tab', $tabs); 298 $both_wrapper = $tabs_wrapper; 299 $click_trigger = true; 300 } else if ( $accordion.length && $('#reviews', $accordion).length ) { 301 var tab_reviews = $('#reviews', $accordion).first().closest('.tab-pane').attr('id'); 302 $panel = $('#reviews', $accordion).first().closest('.panel'); 303 $li = $('.panel-title', $panel); 304 $both_wrapper = $accordion; 305 $click_trigger = true; 306 } else if ( $('div#reviews').length && clicked ) { 307 $both_wrapper = $('div#reviews'); 308 scrollAction = true; 309 } else { 310 return false; 311 } 312 313 if ( $click_trigger && ( hash.toLowerCase().indexOf( 'comment-' ) >= 0 || hash === '#reviews' || hash === '#tab-reviews' ) ) { 314 $( 'a', $li ).click(); 315 scrollAction = true; 316 } else if ( $click_trigger && ( url.indexOf( 'comment-page-' ) > 0 || url.indexOf( 'cpage=' ) > 0 ) ) { 317 $( 'a', $li ).click(); 318 scrollAction = true; 319 } 320 321 if ( scrollAction ) { 322 var body = $("html, body"), 323 bodyTop = document.documentElement['scrollTop'] || document.body['scrollTop'], 324 delta = bodyTop - ($both_wrapper.length ? $both_wrapper.offset().top : 0), 325 getOffset = UNCODE.get_scroll_offset(); 326 if ( typeof $both_wrapper.offset() === 'undefined' ) 327 return; 328 scrollTo = $both_wrapper.offset().top - 27; 329 scrollTo -= getOffset; 330 331 var scrollSpeed = (SiteParameters.constant_scroll == 'on') ? Math.abs(delta) / parseFloat(SiteParameters.scroll_speed) : SiteParameters.scroll_speed; 332 if (scrollSpeed < 1000 && SiteParameters.constant_scroll == 'on') scrollSpeed = 1000; 333 334 if (scrollSpeed == 0) { 335 body.scrollTop((delta > 0) ? scrollTo - 0.1 : scrollTo); 336 } else { 337 body.animate({ 338 scrollTop: (delta > 0) ? scrollTo - 0.1 : scrollTo 339 }, scrollSpeed, 'easeInOutQuad'); 340 } 341 } else { 342 return false; 343 } 344 }; 345 346 scrollToReviewsInside( false ); 347 348 $('a.woocommerce-review-link').on('click', function(e) { 349 e.preventDefault(); 350 hash = '#reviews'; 351 scrollToReviewsInside( true ); 352 }); 353 354 } 355 } 356 $(document).ready(scrollToReviews); 357 358 var qtyPlusMinus = function(){ 359 $('.qty-inset:not(.qty-inset-active)').each(function(){ 360 var $qtyInsets = $(this).addClass('qty-inset-active'), 361 $input = $('input.qty', $qtyInsets), 362 $minus = $('.qty-minus', $qtyInsets), 363 $plus = $('.qty-plus', $qtyInsets), 364 step = parseFloat( $input.attr('step') ), 365 min = parseFloat( $input.attr('min') ), 366 max = parseFloat( $input.attr('max') ), 367 value = parseFloat($input.val()); 368 369 if ( isNaN(step) ) { 370 step = 1; 371 } 372 373 if ( isNaN(min) ) { 374 min = 1; 375 } 376 377 if ( isNaN(value) ) { 378 value = 0; 379 $input.val( value ); 380 } 381 382 $minus.on('click', function () { 383 if (UncodeWCParameters.activate_input_check_on_click) { 384 step = parseFloat( $input.attr('step') ); 385 min = parseFloat( $input.attr('min') ); 386 max = parseFloat( $input.attr('max') ); 387 if ( isNaN(step) ) { 388 step = 1; 389 } 390 if ( isNaN(min) ) { 391 min = 1; 392 } 393 } 394 395 value = parseFloat( $input.val() ) - step; 396 if ( value < min ) { 397 value = min; 398 } 399 $input.val( value ).trigger( 'change' ); 400 }); 401 402 $plus.on('click', function () { 403 if (UncodeWCParameters.activate_input_check_on_click) { 404 step = parseFloat( $input.attr('step') ); 405 min = parseFloat( $input.attr('min') ); 406 max = parseFloat( $input.attr('max') ); 407 if ( isNaN(step) ) { 408 step = 1; 409 } 410 if ( isNaN(min) ) { 411 min = 1; 412 } 413 } 414 415 value = parseFloat( $input.val() ) + step; 416 if ( !isNaN(max) && value > max ) { 417 value = max; 418 } 419 $input.val( value ).trigger( 'change' ); 420 }); 421 }); 422 }; 423 424 var resizeCartRow = function(){ 425 if ($('form.woocommerce-cart-form').length > 0) { 426 window.dispatchEvent(new CustomEvent('vc-resize')); 427 } 428 }; 429 430 $(document.body).on('updated_cart_totals', qtyPlusMinus); 431 $(document.body).on('updated_cart_totals', resizeCartRow); 432 $(document).ready(qtyPlusMinus); 433 $(document).on('vc-frontend:vc_button', qtyPlusMinus); 434 435 var woocommerce_product_gallery = function() { 436 $( 'body:not(.single-uncodeblock) .woocommerce-product-gallery' ).each( function() { 437 if ($('body').hasClass('uncode-default-product-gallery')) { 438 return; 439 } 440 441 var $slider = $(this); 442 443 UNCODE_WC.product_gallery($slider); 444 }); 445 } 446 447 UNCODE_WC.product_gallery = function($slider) { 448 var $parent = $slider.closest('.uncode-wrapper').length ? $slider.closest('.uncode-wrapper') : $slider.closest('.uncont'),
449 cols = parseFloat( $slider.attr('data-columns') ), 450 dots = $parent.attr('data-dots') == 'true', 451 gutter = $parent.length && typeof $parent.attr('data-gutter') !== 'undefined' ? parseFloat( $parent.attr('data-gutter') ) : 18, 452 $main = $('.woocommerce-product-gallery__wrapper.owl-carousel', $parent), 453 $stack = $('.woocommerce-layout-images-stack-lateral .woocommerce-product-gallery__wrapper', $parent), 454 mainL = $main.find('.woocommerce-product-gallery__image').length, 455 $thumbs = $('.woocommerce-product-gallery__wrapper-nav:not(.lateral-nav)', $parent), 456 $thumbs_nav = $('.woocommerce-product-gallery__wrapper-nav', $parent), 457 $navTh = $('.woocommerce-product-gallery__thumb', $thumbs_nav).attr('tabindex', 0), 458 thumbsL = $thumbs.find('li').length; 459 460 $navTh.each(function(key, val){ 461 $(val).attr('aria-label', SiteParameters.uncode_slide_label + ' ' + (key+1)); 462 }); 463 464 if ($.fn.owlCarousel) { 465 if ( mainL > 1 && $slider.hasClass('owl-carousel-wrapper') ) { 466 $main.owlCarousel({ 467 items: 1, 468 autoHeight: true, 469 rtl: $('body').hasClass('rtl') ? true : false, 470 responsiveRefreshRate: 200, 471 responsive: { 472 0: { 473 dots: $('.woocommerce-product-gallery__wrapper-nav.lateral-nav', $parent).length || dots === true 474 }, 475 960: { 476 dots: dots 477 } 478 } 479 }).on('changed.owl.carousel', function(event) { 480 if (event.namespace && event.property.name === 'position') { 481 var target = event.relatedTarget.relative(event.property.value, true); 482 var data = $thumbs.data('owl.carousel'); 483 if ( ! $('.owl-item', $thumbs).eq( target ).hasClass('active') ) { 484 $thumbs.owlCarousel( 'to', target, 300, true ); 485 } 486 } 487 }); 488 $main.on('translate.owl.carousel', function(event) { 489 $(event.currentTarget).addClass('owl-translating'); 490 }); 491 $main.on('translated.owl.carousel', function(event) { 492 $(event.currentTarget).removeClass('owl-translating'); 493 }); 494 $thumbs.on('initialized.owl.carousel', function(event) { 495 $thumbs.closest('.woocommerce-product-gallery-nav-wrapper').css({ 496 opacity: 1 497 }); 498 }).owlCarousel({ 499 items: cols, 500 margin: gutter, 501 autoHeight: true, 502 nav: true, 503 rtl: $('body').hasClass('rtl') ? true : false, 504 mouseDrag: cols < thumbsL, 505 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>'], 506 responsiveRefreshRate: 100, 507 }) 508 $(window).on('load uncode-quick-view-first-hover woocommerce_variation_has_loaded', function () { 509 setTimeout(function(){ 510 $main.trigger('refresh.owl.carousel'); 511 $thumbs.trigger('refresh.owl.carousel'); 512 513 var product_div = $main.closest('div.woocommerce-product-gallery--with-variation-gallery'); 514 515 if (!product_div.length > 0) { 516 if (!$('.owl-item', $main).eq(0).hasClass('active')) { 517 $main.owlCarousel( 'to', 0, 300, true ); 518 } 519 if (!$('.owl-item', $thumbs).eq(0).hasClass('active')) { 520 $thumbs.owlCarousel( 'to', 0, 300, true ); 521 } 522 } 523 524 $('.owl-dot', $main).each(function(key, val){ 525 $(val).attr('aria-label', SiteParameters.uncode_slide_label + ' ' + (key+1)); 526 }); 527 $('.owl-dot', $thumbs).each(function(key, val){ 528 $(val).attr('aria-label', SiteParameters.uncode_slide_label + ' ' + (key+1)); 529 }); 530 }, 300); 531 }); 532 } 533 } 534 535 var scrollBody = function(index) { 536 $('.woocommerce-product-gallery__thumb', $thumbs_nav).removeClass('is-selected'); 537 $('.woocommerce-product-gallery__thumb', $thumbs_nav).eq(index).addClass('is-selected'); 538 539 var top_gutter = parseInt($stack.closest('.row').css('padding-top')); 540 541 var getSection = $('.woocommerce-product-gallery__image', $stack).eq(index), 542 scrollTo; 543 544 if (getSection == undefined) return; 545 546 var body = $("html, body"), 547 bodyTop = document.documentElement['scrollTop'] || document.body['scrollTop'], 548 delta = bodyTop - ($('.woocommerce-product-gallery__image', $stack).eq(index).length ? $('.woocommerce-product-gallery__image', $stack).eq(index).offset().top : 0), 549 getOffset = UNCODE.get_scroll_offset(index); 550 if ( typeof getSection.offset() === 'undefined' ) { 551 return; 552 } 553 scrollTo = getSection.offset().top; 554
555 if ( !( $('.menu-desktop-transparent').length && UNCODE.wwidth > UNCODE.mediaQuery ) && !( $('.menu-mobile-transparent').length && UNCODE.wwidth <= UNCODE.mediaQueryMobile ) ) { 556 var shrink = typeof $('.navbar-brand').data('padding-shrink') !== 'undefined' ? $('.navbar-brand').data('padding-shrink')*2 : 36; 557 if ( $('.menu-sticky .menu-container:not(.menu-hide)').length && $('.menu-shrink').length ) { 558 scrollTo += UNCODE.menuHeight - ( $('.navbar-brand').data('minheight') + shrink ); 559 } 560 561 if ( $('.menu-sticky .menu-container:not(.menu-hide)').length && ! $('.menu-shrink').length && $('.body').hasClass('vmenu') ) { 562 if ( index === 0 ) { 563 scrollTo = 0; 564 } else { 565 scrollTo -= $('.menu-sticky .menu-container').outerHeight(); 566 } 567 } else { 568 scrollTo -= getOffset; 569 } 570 } 571 572 scrollTo -= top_gutter; 573 574 var scrollSpeed = (SiteParameters.constant_scroll == 'on') ? Math.abs(delta) / parseFloat(SiteParameters.scroll_speed) : SiteParameters.scroll_speed; 575 if (scrollSpeed < 1000 && SiteParameters.constant_scroll == 'on') scrollSpeed = 1000; 576 577 if (index != 0) { 578 UNCODE.scrolling = true; 579 } 580 581 if (scrollSpeed == 0) { 582 body.scrollTop((delta > 0) ? scrollTo - 0.1 : scrollTo); 583 UNCODE.scrolling = false; 584 } else { 585 body.on("scroll wheel DOMMouseScroll mousewheel touchmove", function(){ 586 $(this).stop(); 587 }).stop(true,false).animate({ 588 scrollTop: (delta > 0) ? scrollTo - 0.1 : scrollTo 589 }, scrollSpeed, 'easeInOutCubic', function(){ 590 UNCODE.scrolling = false; 591 }); 592 } 593 594 }; 595 596 var changeThumbActive = function(section, index) { 597 var newSection = $('.woocommerce-product-gallery__thumb', $thumbs_nav).eq(index); 598 if (newSection.length) { 599 $('.woocommerce-product-gallery__thumb', $thumbs_nav).removeClass('is-selected'); 600 newSection.addClass('is-selected'); 601 } 602 } 603 604 $('.woocommerce-product-gallery__image', $stack).each(function(index, val) { 605 new Waypoint({ 606 context: UNCODE.isUnmodalOpen ? document.getElementById('unmodal-content') : window, 607 element: val, 608 handler: function(direction) { 609 changeThumbActive(this.element, index); 610 }, 611 }); 612 }); 613 614 $thumbs_nav.on( 'click', '.woocommerce-product-gallery__thumb', function(e){ 615 e.preventDefault(); 616 var number = $(this).index(); 617 if ( $main.length ) { 618 number = $(this).closest('.owl-item').index(); 619 if ( number < 0 ) { 620 number = $(this).index(); 621 } 622 $main.owlCarousel( 'to', number, 300, true ); 623 } else if ( $stack.length ) { 624 scrollBody( number ); 625 } 626 }); 627 628 var uncodeZoom = function(){ 629 if ($.fn.zoom && $('body').hasClass('wc-zoom-enabled') ) { 630 var $zoomTrgt = $('.woocommerce-product-gallery__image', $slider); 631 632 if ( $('.thumbnails', $slider).length ) 633 $zoomTrgt = $zoomTrgt.first(); 634 635 $zoomTrgt.trigger( 'zoom.destroy' ); 636 $zoomTrgt.zoom(); 637 638 var checkForZoom = function(){ 639 640 if ( $parent.hasClass( 'no-zoom-mobile' ) && UNCODE.wwidth < 960 ) { 641 $zoomTrgt.trigger( 'zoom.destroy' ).addClass('mouse-moving'); 642 $('.zoom-overlay', $zoomTrgt).remove(); 643 return false; 644 } 645 $('.woocommerce-product-gallery__image').each(function(){ 646 var $wrap = $(this), 647 $zoomImg = $('.zoomImg', $wrap); 648 649 if (UNCODE.isMobile || !$zoomImg.length) { 650 $wrap.addClass('mouse-moving'); 651 } 652 }); 653 654 var galleryWidth = $zoomTrgt.width(), 655 zoom_options = { 656 touch: true, 657 callback: function(){ 658 $('.woocommerce-product-gallery__image').each(function(){ 659 var $wrap = $(this), 660 $zoomImg = $('.zoomImg', $wrap), 661 $overZoom = $('.zoom-overlay', $wrap), 662 $imageIL = $('a[data-lbox]', $wrap), 663 $carousel = $wrap.closest('.owl-carousel'); 664 665 $wrap.prepend($zoomImg); 666 if (UNCODE.isMobile || !$zoomImg.length) { 667 $wrap.addClass('mouse-moving'); 668 $zoomImg.css({ 669 'visibility':'hidden' 670 }); 671 } 672 673 /* Make work everything on touch events */ 674 var onlongtouch, 675 timer, 676 now, 677 touchduration = 500, 678 startX = 0, startY, newX, newY; 679 680 $wrap.parent().on('mousemove.zoom', function(){ 681 if ( ! $wrap.hasClass('mouse-moving') ) { 682 if ( startX == 0 ) { 683 startX = event.clientX; 684 startY = event.clientY; 685 } 686 newX = event.clientX; 687 newY = event.clientY; 688 if ( Math.abs( newX - startX ) > 50 && Math.abs( newY - startY ) > 50 ) { 689 $wrap.addClass('mouse-moving'); 690 } 691 } 692 }); 693 694 $overZoom.on('touchstart.zoom', function (e) { 695 now = new Date().getTime(); 696 }).on('touchmove.zoom', function (e) { 697 setTimeout(function(){ 698 $zoomImg.css({ 699 'visibility':'visible' 700 }); 701 }, 100); 702 }).on('touchend.zoom', function (e) { 703 var newTap = new Date().getTime(); 704 if ( newTap - now < 75 && ! $('body').hasClass('ilightbox-noscroll') ) { 705 $imageIL.trigger('itap.iL'); 706 } 707 if (UNCODE.isMobile) { 708 $zoomImg.css({ 709 'visibility':'hidden' 710 }); 711 } 712 }); 713 714 }); 715 } 716 }; 717 718 if ( 'ontouchstart' in window ) { 719 zoom_options.on = 'click'; 720 } 721 722 $zoomTrgt.trigger( 'zoom.destroy' ); 723 $zoomTrgt.each(function(){ 724 var $thisTrgt = $(this), 725 $img = $('img', $thisTrgt); 726 727 if ( $img.data( 'large_image_width' ) > galleryWidth ) { 728 $thisTrgt.zoom(zoom_options); 729 } else { 730 $thisTrgt.trigger( 'zoom.destroy' ); 731 } 732 733 }); 734 735 }; 736 checkForZoom(); 737 738 var setCheckForZoom; 739 $(window).on( 'resize', function(){ 740 clearTimeout(setCheckForZoom); 741 setCheckForZoom = setTimeout( checkForZoom, 500 ); 742 }); 743 } 744 }; 745 uncodeZoom(); 746 window.addEventListener('load', uncodeZoom); 747 } 748 749 woocommerce_product_gallery(); 750 751 $(window).on('unmodal-open', function(){ 752 $('#unmodal-content .woocommerce-product-gallery__image').removeClass('mouse-moving'); 753 }) 754 $(document).on('unmodal-close', function(){ 755 $('#unmodal-content .woocommerce-product-gallery__image').removeClass('mouse-moving'); 756 }) 757 758 /************************************************************ 759 * Redirect to custom empty cart page 760 ************************************************************/ 761 762 $(document.body).on('wc_cart_emptied', redirect_to_custom_empty_cart); 763 764 function redirect_to_custom_empty_cart() { 765 if (UncodeWCParameters.empty_cart_url !== '') { 766 window.location.replace(UncodeWCParameters.empty_cart_url); 767 } 768 } 769
770 /************************************************************ 771 * Make the variation price inherit the font family from main price 772 ************************************************************/ 773 774 function variation_price_font() { 775 776 var $forms = $('form.variations_form'); 777 778 $forms.each(function(){ 779 var $form = $(this); 780 781 $form.on('woocommerce_variation_has_changed wc_variation_form', function(){ 782 var $var_price = $('.woocommerce-variation-price .woocommerce-Price-amount'), 783 $row = $form.closest('.vc_row'), 784 $main_price = $('.heading-text .woocommerce-Price-amount', $row); 785 786 if ( $main_price.length ) { 787 var $price_wrap = $main_price.closest('.heading-text'), 788 $price_nest = $('> *:first-child', $price_wrap), 789 font_class = $price_nest.attr('class').split(' '), 790 i; 791 792 for ( i = 0; i < font_class.length; i++ ) { 793 if ( font_class[i].indexOf('font') !== -1 && font_class[i].indexOf('fontsize') === -1 ) { 794 $var_price.addClass( font_class[i] ); 795 } 796 } 797 } 798 }); 799 }); 800 } 801 802 $(document).ready(function() { 803 variation_price_font(); 804 }); 805 806 /************************************************************ 807 * Show minicart when adding something 808 ************************************************************/ 809 810 var cartShow, cartHover, 811 sideCart_scrollTop = $('html, body').scrollTop();; 812 813 var minicart_notify = function(){ 814 var $body = $('body'); 815 816 if ( ! $body.hasClass('minicart-notification') ) { 817 return false; 818 } 819 820 var $sidecart = $('#uncode_sidecart'), 821 $miniCart = $('.menu-smart .uncode-cart-dropdown'), 822 $smartMenu = $miniCart.closest('.menu-smart'); 823 824 $miniCart.on('hover', function(){ 825 clearTimeout(cartHover); 826 }); 827 828 var show_added_to_cart = function(e){ 829 830 clearTimeout(cartShow); 831 clearTimeout(cartHover); 832 833 if ( $sidecart.length && ( ! ( $body.hasClass('uncode-sidecart-mobile-disabled') && UNCODE.wwidth <= UNCODE.mediaQuery ) ) ) { 834 $sidecart.imagesLoaded().done( function( instance ) { 835 setTimeout(function(){ 836 sideCart_scrollTop = $('html, body').scrollTop(); 837 $body.addClass('uncode-sidecart-open'); 838 $(window).trigger('uncode-sidecart-open'); 839 $('html, body').scrollTop(sideCart_scrollTop); 840 }, 500); 841 }); 842 } 843 844 var show_added_to_cart_timeout = function(){ 845 cartShow = setTimeout(function(){ 846 $miniCart.imagesLoaded().done( function( instance ) { 847 $smartMenu.smartmenus('itemActivate', $('.uncode-cart > a')); 848 cartHover = setTimeout(function(){ 849 $smartMenu.smartmenus('menuHideAll'); 850 }, 4000); 851 }); 852 }, 500); 853 }; 854 855 if ( UNCODE.wwidth >= 960 ) { 856 if ( e == 'uncode-wc-added-to-cart' ) { 857 show_added_to_cart_timeout(); 858 } else { 859 $( document.body ).on( 'wc_fragments_loaded', function(){ 860 show_added_to_cart_timeout(); 861 }); 862 } 863 } 864 }; 865 866 if ( $('body').hasClass('uncode-wc-disable-added-to-cart-trigger')) { 867 $( document.body ).on( 'added_to_cart', function() { 868 setTimeout(function(){ 869 $(document.body).trigger('wc_fragment_refresh'); 870 }, 500); 871 } ); 872 } else { 873 $( document.body ).on( 'added_to_cart', show_added_to_cart ); 874 } 875 876 $(document).ready(function() { 877 if ( $('body').hasClass('uncode-wc-added-to-cart')) { 878 show_added_to_cart('uncode-wc-added-to-cart'); 879 } 880 }); 881 882 }; 883 884 minicart_notify(); 885 886 /************************************************************ 887 * View Cart Button 888 ************************************************************/ 889 $( document.body ).on( 'wc_cart_button_updated', function(e, $button){ 890 if ( $(document.body).hasClass('minicart-notification') || wc_add_to_cart_params == undefined ) { 891 return false; 892 } 893 894 $button 895 .addClass('added_and_noted') 896 .removeClass('ajax_add_to_cart') 897 .find('.added_to_cart') 898 .text( wc_add_to_cart_params.i18n_view_cart ) 899 .on('click', function(e){ 900 e.preventDefault(); 901 window.location.href = wc_add_to_cart_params.cart_url; 902 return false; 903 }); 904 }); 905 906 /************************************************************ 907 * Side Cart 908 ************************************************************/ 909 var init_sidecart = function(){ 910 var $body = $('body.uncode-sidecart-enabled'); 911 if ( ! $body.length ) { 912 return false;
913 } 914 915 var $cart_icon = $('.mobile-shopping-cart, .uncode-cart.menu-item-link > a'), 916 $sidecart = $('#uncode_sidecart'), 917 $view_cart = $('a.wc-forward:not(.checkout)', $sidecart).removeClass('btn-sm'), 918 $checkout = $('a.checkout', $sidecart).removeClass('btn-sm').addClass('btn-flat'), 919 $overlay = $('#uncode_sidecart_overlay'), 920 $close_cart = $('.close-mini-cart', $sidecart), 921 sidecart_hover = false; 922 923 $cart_icon.off('click').on('click', function( e ){ 924 if ( $sidecart.length && ! ( $(this).closest('.overlay').length && UNCODE.wwidth > UNCODE.mediaQuery ) && ( ! ( $body.hasClass('uncode-sidecart-mobile-disabled') && UNCODE.wwidth <= UNCODE.mediaQuery ) ) ) { 925 e.preventDefault(); 926 e.stopPropagation(); 927 sideCart_scrollTop = $('html, body').scrollTop(); 928 $body.addClass('uncode-sidecart-open'); 929 $(window).trigger('uncode-sidecart-open'); 930 $('html, body').scrollTop(sideCart_scrollTop); 931 } 932 }); 933 934 $sidecart.on('mouseover',function(){ 935 sidecart_hover = true; 936 }).on('mouseout', function(){ 937 sidecart_hover = false; 938 }); 939 940 $body.on('click', function( e ){ 941 if ( $body.hasClass('uncode-sidecart-open') && !sidecart_hover ) { 942 $body.removeClass('uncode-sidecart-open'); 943 $(window).trigger('uncode-sidecart-closed'); 944 $('html, body').scrollTop(sideCart_scrollTop); 945 } 946 }); 947 948 $close_cart.on('click', function( e ){ 949 e.preventDefault(); 950 $body.removeClass('uncode-sidecart-open'); 951 $(window).trigger('uncode-sidecart-closed'); 952 $('html, body').scrollTop(sideCart_scrollTop); 953 }); 954 }; 955 $(document).ready(function(){ 956 init_sidecart(); 957 }); 958 $( document.body ).on("wc_fragments_refreshed added_to_cart removed_from_cart", function(){ 959 init_sidecart(); 960 requestTimeout( init_sidecart, 1 ); 961 }); 962 963 var sidecart_size = function(){ 964 var $body = $('body.uncode-sidecart-enabled'), 965 $widget_cart = $('.widget_shopping_cart_content'), 966 $mini_cart_item = $('.mini_cart_item', $widget_cart); 967 968 if ( $widget_cart.length ) { 969 $mini_cart_item.each(function(){ 970 var $this = $(this), 971 $img_product = $('.attachment-woocommerce_thumbnail', $this), 972 imgH = $img_product.height(); 973 974 $this.css({ 975 'min-height': imgH+6 976 }) 977 978 }); 979 } 980 if ( $body.length ) { 981 982 var $sidecart = $('#uncode_sidecart'), 983 $cart_header = $('.woocommerce-mini-cart-header', $sidecart), 984 headerH = $cart_header.outerHeight(), 985 $cart_footer = $('.woocommerce-mini-cart-footer', $sidecart), 986 footerH = $cart_footer.outerHeight(), 987 $cart_body = $('.woocommerce-mini-cart-body', $sidecart); 988 989 $cart_body.css({ 990 'padding-top':headerH, 991 'padding-bottom':footerH 992 }); 993 994 } 995 }; 996 $(document).ready(function(){ 997 var setCTA; 998 sidecart_size(); 999 requestTimeout(function(){ 1000 $(window).on( 'resize', function(){ 1001 clearRequestTimeout(setCTA); 1002 setCTA = requestTimeout( sidecart_size, 100 ); 1003 }); 1004 }, 400); 1005 }); 1006 $( document.body ).on("wc_fragments_refreshed added_to_cart removed_from_cart", function(){ 1007 sidecart_size(); 1008 requestTimeout( sidecart_size, 1 ); 1009 }); 1010 1011 /************************************************************ 1012 * Quick view 1013 ************************************************************/ 1014 1015 var modal_quick_view_content = $('.quick-view-content'); 1016 var last_viewed_product_id; 1017 1018 $(document).off('click', '.quick-view-button').on('click', '.quick-view-button', function() { 1019 var _this = $(this); 1020 var product_id = _this.data('post-id'); 1021 var post_type = _this.data('post-type'); 1022 var post_url = _this.attr('data-post-url'); 1023 var single_variation_atts = _this.attr('data-single-variation'); 1024 1025 // Empty modal 1026 if (modal_quick_view_content.length > 0) { 1027 modal_quick_view_content.html(''); 1028 } 1029 1030 var data = { 1031 action: 'uncode_load_ajax_quick_view', 1032 post_id: product_id, 1033 post_type: post_type, 1034 post_url: post_url, 1035 }; 1036 1037 if (single_variation_atts) { 1038 var variation_atts_obj = JSON.parse(single_variation_atts) 1039 1040 for (var att_key in variation_atts_obj) { 1041 if (variation_atts_obj[att_key]) { 1042 data['attribute_' + att_key] = variation_atts_obj[att_key]; 1043 } 1044 } 1045 } 1046 1047 // Get quick view content via AJAX 1048 $.ajax({ 1049 url: woocommerce_params.ajax_url, 1050 data: data, 1051 type: 'post', 1052 error: function(data) { 1053 if (SiteParameters.enable_debug == true) { 1054 // This console log is disabled by default 1055 // So nothing is printed in a typical installation 1056 // 1057 // It can be enabled for debugging purposes setting 1058 // the 'uncode_enable_debug_on_js_scripts' filter to true 1059 console.log('AJAX error on quick view response'); 1060 } 1061 }, 1062 success: function(response) { 1063 if (response && response.success === false) { 1064 if (SiteParameters.enable_debug == true) { 1065 // This console log is disabled by default 1066 // So nothing is printed in a typical installation 1067 // 1068 // It can be enabled for debugging purposes setting 1069 // the 'uncode_enable_debug_on_js_scripts' filter to true 1070 if (response.data.error) { 1071 console.log(response.data.error); 1072 } else { 1073 console.log('Unknown error on quick view response'); 1074 } 1075 } 1076 } else { 1077 var html = response.data.html; 1078 1079 if (modal_quick_view_content.length > 0) { 1080 modal_quick_view_content.html(html); 1081 } 1082 1083 last_viewed_product_id = product_id; 1084 1085 modal_quick_view_content.imagesLoaded().done( function( instance ) { 1086 $(document).trigger('uncode-unmodal-show-content'); 1087 $(document).trigger('uncode-quick-view-loaded'); 1088 window.dispatchEvent(new CustomEvent('uncode-quick-view-loaded')); 1089 1090 setTimeout(function(){ 1091 modal_quick_view_content.one('mousemove', function(){ 1092 window.dispatchEvent(new CustomEvent('uncode-quick-view-first-hover')); 1093 }); 1094 }, 10); 1095 }); 1096 } 1097 } 1098 }); 1099 1100 return false;
1101 }); 1102 1103 $(document).on('uncode-quick-view-loaded', function() { 1104 var form_variation = modal_quick_view_content.find('.variations_form'); 1105 1106 form_variation.each(function() { 1107 $(this).wc_variation_form(); 1108 }); 1109 1110 form_variation.trigger('check_variations'); 1111 form_variation.trigger('reset_image'); 1112 1113 if( typeof $.fn.wc_product_gallery !== 'undefined' ) { 1114 modal_quick_view_content.find('.woocommerce-product-gallery').each(function(){ 1115 $(this).wc_product_gallery(); 1116 }); 1117 } 1118 1119 $( '#unmodal-content' ).on( 'change', '.quantity .qty', function() { 1120 jQuery( this ).closest('form.cart').find('.add_to_cart_button').attr( 'data-quantity', jQuery( this ).val() ); 1121 }); 1122 1123 woocommerce_product_gallery(); 1124 variation_price_font(); 1125 qtyPlusMinus(); 1126 1127 UNCODE.preventDoubleTransition(); 1128 UNCODE.utils(); 1129 if (typeof UNCODE.share !== 'undefined') { 1130 UNCODE.share(); 1131 } 1132 if (typeof UNCODE.tooltip !== 'undefined') { 1133 UNCODE.tooltip(); 1134 } 1135 if (typeof UNCODE.counters !== 'undefined') { 1136 UNCODE.counters(); 1137 } 1138 if (typeof UNCODE.countdowns !== 'undefined') { 1139 UNCODE.countdowns(); 1140 } 1141 if (typeof UNCODE.tabs !== 'undefined') { 1142 UNCODE.tabs(); 1143 } 1144 if (typeof UNCODE.collapse !== 'undefined') { 1145 UNCODE.collapse(); 1146 } 1147 if (typeof UNCODE.okvideo !== 'undefined') { 1148 UNCODE.okvideo(); 1149 } 1150 if (typeof UNCODE.backgroundSelfVideos !== 'undefined') { 1151 UNCODE.backgroundSelfVideos(); 1152 } 1153 UNCODE.tapHover(); 1154 if (typeof UNCODE.isotopeLayout !== 'undefined') { 1155 UNCODE.isotopeLayout(); 1156 } 1157 if (typeof UNCODE.justifiedGallery !== 'undefined') { 1158 UNCODE.justifiedGallery(); 1159 } 1160 if (typeof UNCODE.cssGrid !== 'undefined') { 1161 UNCODE.cssGrid(); 1162 } 1163 if (typeof UNCODE.lightbox !== 'undefined' && !SiteParameters.lbox_enhanced) { 1164 UNCODE.lightbox(); 1165 } 1166 if (typeof UNCODE.lightgallery !== 'undefined' && SiteParameters.lbox_enhanced) { 1167 UNCODE.lightgallery(); 1168 } 1169 if (typeof UNCODE.carousel !== 'undefined') { 1170 UNCODE.carousel($('body')); 1171 } 1172 UNCODE.lettering(); 1173 UNCODE.animations(); 1174 UNCODE.stickyElements(); 1175 if (typeof UNCODE.twentytwenty !== 'undefined') { 1176 UNCODE.twentytwenty(); 1177 } 1178 UNCODE.disableHoverScroll(); 1179 if (typeof uncode_progress_bar !== 'undefined') { 1180 uncode_progress_bar(); 1181 } 1182 if (typeof UNCODE.filters !== 'undefined') { 1183 UNCODE.filters(); 1184 } 1185 if (typeof UNCODE.ajax_filters !== 'undefined') { 1186 UNCODE.ajax_filters(); 1187 } 1188 if (typeof UNCODE.widgets !== 'undefined') { 1189 UNCODE.widgets(); 1190 } 1191 1192 $(document).trigger('yith_wcwl_init'); 1193 }); 1194 1195 /************************************************************ 1196 * Trigger fragments 1197 ************************************************************/ 1198 if ( SiteParameters.update_wc_fragments == true ) { 1199 $(document).ready(function() { 1200 $(document.body).trigger('wc_fragment_refresh'); 1201 }); 1202 } 1203 1204 /************************************************************ 1205 * Cart badge 1206 ************************************************************/ 1207 $(document).ready(function() { 1208 if ( SiteParameters.uncode_wc_popup_cart_qty ) { 1209 $(document.body).on('wc_fragments_loaded', function(){ 1210 $('.cart-icon-container .badge').removeClass('init-product-counter'); 1211 }) 1212 .on('uncode_get_cart', function(e, data){ 1213 if ( $('.cart-icon-container .badge').text() !== '' || ( data > 0 ) ) { 1214 $('.cart-icon-container .badge').addClass('init-product-counter'); 1215 } else { 1216 $('.cart-icon-container .badge').removeClass('init-product-counter'); 1217 } 1218 }); 1219 } 1220 }); 1221 1222 var clearZoomSet; 1223 $(window).on('load', function(){ 1224 clearTimeout(clearZoomSet); 1225 clearZoomSet = setTimeout(function(){ 1226 $('.zoomImg').each(function(){ 1227 $(this).removeAttr('role'); 1228 }); 1229 }, 1); 1230 }); 1231 1232})(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.