1( function() { 2 'use strict'; 3 // Compatibility with YITH WISHLIST PRO 4 if ( typeof yith_wcwl_l10n != 'undefined' ) { 5 yith_wcwl_l10n.enable_tooltip = false; 6 } 7 // Hide Tooltip before adding to wishlist 8 jQuery( document ).on( 'yith_wcwl_add_to_wishlist_data yith_woocompare_product_added', function( e, $el ) { 9 if ( $el.length ) { 10 $el.tooltip( 'dispose' ); 11 } 12 if ( $el.$initiator ) { 13 $el.$initiator.tooltip( 'dispose' ); 14 } 15 } ); 16 jQuery( document ).on( 'click', 'a.compare.added', function( e ) { 17 jQuery( this ).tooltip( 'dispose' ); 18 }); 19 // Theme Functions 20 function portoCalcSliderButtonsPosition( $parent, padding ) { 21 var $buttons = $parent.find( '.show-nav-title .owl-nav' ); 22 if ( $buttons.length ) { 23 if ( window.theme.rtl ) { 24 $buttons.css( 'left', padding ); 25 } else { 26 $buttons.css( 'right', padding ); 27 } 28 if ( $buttons.closest( '.porto-products' ).length && $buttons.closest( '.porto-products' ).parent().children( '.products-slider-title' ).length ) { 29 var $title = $buttons.closest( '.porto-products' ).parent().children( '.products-slider-title' ), newMT = $title.offset().top - $parent.offset().top - parseInt( $title.css( 'padding-top' ), 10 ) - parseInt( $title.css( 'line-height' ), 10 ) / 2 + $buttons.children().outerHeight() - parseInt( $buttons.children().css( 'margin-top' ), 10 ); 30 $buttons.css( 'margin-top', newMT ); 31 } 32 } 33 } 34 35 // Woocommerce Products Slider 36 if ( typeof jQuery.fn.owlCarousel == 'function' ) { 37 ( function( theme, $ ) { 38 39 theme = theme || {}; 40 41 var instanceName = '__wooProductsSlider'; 42 43 var WooProductsSlider = function( $el, opts ) { 44 return this.initialize( $el, opts ); 45 }; 46 47 WooProductsSlider.defaults = { 48 rtl: theme.rtl, 49 autoplay: theme.slider_autoplay == '1' ? true : false, 50 autoplayTimeout: theme.slider_speed ? theme.slider_speed : 5000, 51 loop: theme.slider_loop, 52 nav: false, 53 navText: ["", ""], 54 dots: false, 55 autoplayHoverPause: true, 56 items: 1, 57 responsive: {}, 58 autoHeight: true, 59 lazyLoad: true 60 }; 61 62 WooProductsSlider.prototype = { 63 initialize: function( $el, opts ) { 64 if ( $el.data( instanceName ) ) { 65 return this; 66 } 67 68 this.$el = $el; 69 70 this 71 .setData() 72 .setOptions( opts ) 73 .build(); 74 75 return this; 76 }, 77 78 setData: function() { 79 this.$el.data( instanceName, true ); 80 81 return this; 82 }, 83 84 setOptions: function( opts ) { 85 this.options = $.extend( true, {}, WooProductsSlider.defaults, opts, { 86 wrapper: this.$el 87 } ); 88 89 return this; 90 }, 91 92 calcOwlHeight: function( $el ) { 93 var h = 0; 94 $el.find( '.owl-item.active' ).each( function() { 95 if ( h < $( this ).height() ) 96 h = $( this ).height(); 97 } ); 98 $el.find( '.owl-stage-outer' ).height( h ); 99 }, 100 101 build: function() { 102 var self = this, 103 $el = this.options.wrapper, 104 lg = this.options.lg, 105 md = this.options.md, 106 xs = this.options.xs, 107 ls = this.options.ls, 108 $slider_wrapper = $el.closest( '.slider-wrapper' ), 109 single = this.options.single, 110 dots = this.options.dots, 111 nav = this.options.nav, 112 responsive = {}, 113 items, 114 // scrollwidth = 0 not using getscrollbarwidth 115 scrollWidth = 0, 116 count = $el.find( '> *' ).length, 117 w_xs = 576 - scrollWidth, 118 w_md = 768 - scrollWidth, 119 w_xl = theme.screen_xl - scrollWidth, 120 w_sl = theme.screen_xxl - scrollWidth; 121 122 if ( $el.find( '.product-col' ).get( 0 ) ) { 123 portoCalcSliderButtonsPosition( $slider_wrapper, $el.find( '.product-col' ).css( 'padding-left' ) ); 124 } 125 126 if ( single ) { 127 items = 1; 128 } else { 129 items = lg ? lg : 1; 130 if ( this.options.xl ) { 131 responsive[w_sl] = { items: this.options.xl, loop: ( this.options.loop && count > this.options.xl ) ? true : false }; 132 } 133 responsive[w_xl] = { items: items, loop: ( this.options.loop && count > items ) ? true : false }; 134 if ( md ) responsive[w_md] = { items: md, loop: ( this.options.loop && count > md ) ? true : false }; 135 if ( xs ) responsive[w_xs] = { items: xs, loop: ( this.options.loop && count > xs ) ? true : false }; 136 if ( ls ) responsive[0] = { items: ls, loop: ( this.options.loop && count > ls ) ? true : false }; 137 } 138 139 this.options = $.extend( true, {}, this.options, { 140 loop: ( this.options.loop && count > items ) ? true : false, 141 items: items, 142 responsive: responsive, 143 onRefresh: function() { 144 if ( $el.find( '.product-col' ).get( 0 ) ) { 145 portoCalcSliderButtonsPosition( $slider_wrapper, $el.find( '.product-col' ).css( 'padding-left' ) ); 146 } 147 }, 148 onInitialized: function() { 149 if ( $el.find( '.product-col' ).get( 0 ) ) { 150 portoCalcSliderButtonsPosition( $slider_wrapper, $el.find( '.product-col' ).css( 'padding-left' ) ); 151 } 152 //$el.find('.cloned .porto-lazyload:not(.lazy-load-loaded)').themePluginLazyLoad(); 153 154 if ( $el.find( '.owl-item.cloned' ).length ) { 155 setTimeout( function() { 156 if ( $.fn.themePluginLazyLoad ) { 157 var ins = $el.find( '.owl-item.cloned .porto-lazyload:not(.lazy-load-loaded)' ).themePluginLazyLoad( { effect: 'fadeIn', effect_speed: 400 } ); 158 if ( ins && ins.loadAndDestroy ) { 159 ins.loadAndDestroy(); 160 } 161 } 162 }, 100 ); 163 } 164 }, 165 touchDrag: ( count == 1 ) ? false : true, 166 mouseDrag: ( count == 1 ) ? false : true 167 } ); 168 169 // Auto Height Fixes 170 if ( this.options.autoHeight ) { 171 var thisobj = this; 172 $( window ).on( 'resize', function() { 173 thisobj.calcOwlHeight( $el ); 174 } ); 175 176 if ( theme.isLoaded ) { 177 setTimeout( function() { 178 thisobj.calcOwlHeight( $el ); 179 }, 100 ); 180 } else { 181 $( window ).on( 'load', function() { 182 thisobj.calcOwlHeight( $el ); 183 } ); 184 } 185 } 186 187 if ( $el.hasClass( 'has-ccols-spacing' ) ) { 188 $el.removeClass( 'has-ccols-spacing' ); 189 } 190 $el.owlCarousel( this.options ); 191 192 return this; 193 } 194 }; 195 196 // expose to scope 197 $.extend( theme, { 198 WooProductsSlider: WooProductsSlider 199 } ); 200 201 // jquery plugin 202 $.fn.themeWooProductsSlider = function( opts ) { 203 return this.map( function() { 204 var $this = $( this ); 205 206 if ( $this.data( instanceName ) ) { 207 return $this; 208 } else { 209 return new theme.WooProductsSlider( $this, opts ); 210 } 211 212 } ); 213 } 214 215 } ).apply( this, [window.theme, jQuery] ); 216 } 217 218 // Woocommerce Add to Cart, View Cart Events 219 ( function( theme, $ ) { 220 221 var $supports_html5_storage; 222 try { 223 $supports_html5_storage = ( 'sessionStorage' in window && window.sessionStorage !== null ); 224 225 window.sessionStorage.setItem( 'wc', 'test' ); 226 window.sessionStorage.removeItem( 'wc' ); 227 } catch ( err ) { 228 $supports_html5_storage = false; 229 } 230 231 var setCartCreationTimestamp = function() {
232 if ( $supports_html5_storage ) { 233 sessionStorage.setItem( 'wc_cart_created', ( new Date() ).getTime() ); 234 } 235 }; 236 237 var setCartHash = function( cart_hash ) { 238 if ( $supports_html5_storage && wc_cart_fragments_params ) { 239 localStorage.setItem( wc_cart_fragments_params.cart_hash_key, cart_hash ); 240 sessionStorage.setItem( wc_cart_fragments_params.cart_hash_key, cart_hash ); 241 } 242 }; 243 244 var initAjaxRemoveCartItem = function() { 245 $( document ).off( 'click', '.widget_shopping_cart .remove-product, .shop_table.cart .remove-product, .shop_table.review-order .remove-product' ).on( 'click', '.widget_shopping_cart .remove-product, .shop_table.cart .remove-product, .shop_table.review-order .remove-product', function( e ) { 246 e.preventDefault(); 247 var $this = $( this ); 248 var cart_id = $this.data( "cart_id" ); 249 var product_id = $this.data( "product_id" ); 250 var is_checkout = false; 251 $this.closest( 'li' ).find( '.ajax-loading' ).show(); 252 253 if ( 'undefined' == typeof cart_id ) { 254 is_checkout = true; 255 cart_id = $this.closest( '.cart_item' ).data( 'key' ); 256 } 257 $.ajax( { 258 type: 'POST', 259 dataType: 'json', 260 url: theme.ajax_url, 261 data: { 262 action: "porto_cart_item_remove", 263 nonce: js_porto_vars.porto_nonce, 264 cart_id: cart_id 265 }, 266 success: function( response ) { 267 updateCartFragment( response ); 268 $( document.body ).trigger( 'wc_fragments_refreshed' ); 269 var this_page = window.location.toString(), 270 item_count = $( response.fragments['div.widget_shopping_cart_content'] ).find( '.mini_cart_item' ).length; 271 272 this_page = this_page.replace( 'add-to-cart', 'added-to-cart' ); 273 $( '.viewcart-' + product_id ).removeClass( 'added' ); 274 $( '.porto_cart_item_' + cart_id ).remove(); 275 276 // Block widgets and fragments 277 if ( item_count == 0 && ( $( 'body' ).hasClass( 'woocommerce-cart' ) || $( 'body' ).hasClass( 'woocommerce-checkout' ) ) ) { 278 $( '.page-content' ).fadeTo( 400, 0.8 ).block( { 279 message: null, 280 overlayCSS: { 281 opacity: 0.2 282 } 283 } ); 284 } else { 285 $( 'form.woocommerce-cart-form, #order_review, .updating, .cart_totals' ).fadeTo( 400, 0.8 ).block( { 286 message: null, 287 overlayCSS: { 288 opacity: 0.2 289 } 290 } ); 291 } 292 293 // Unblock 294 $( '.widget_shopping_cart, .updating' ).stop( true ).css( 'opacity', '1' ).unblock(); 295 296 // Cart page elements 297 if ( item_count == 0 && ( $( 'body' ).hasClass( 'woocommerce-cart' ) || $( 'body' ).hasClass( 'woocommerce-checkout' ) ) ) { 298 $( '.page-content' ).load( this_page + ' .page-content:eq(0) > *', function() { 299 $( '.page-content' ).stop( true ).css( 'opacity', '1' ).unblock(); 300 } ); 301 } else { 302 $( 'form.woocommerce-cart-form' ).load( this_page + ' form.woocommerce-cart-form:eq(0) > *', function() { 303 $( 'form.woocommerce-cart-form' ).stop( true ).css( 'opacity', '1' ).unblock(); 304 } ); 305 306 $( '.cart_totals' ).load( this_page + ' .cart_totals:eq(0) > *', function() { 307 $( '.cart_totals' ).stop( true ).css( 'opacity', '1' ).unblock(); 308 } ); 309 310 // Checkout page elements 311 $( '#order_review' ).load( this_page + ' #order_review:eq(0) > *', function() { 312 $( '#order_review' ).stop( true ).css( 'opacity', '1' ).unblock(); 313 } ); 314 } 315 } 316 } ); 317 318 return false; 319 } ); 320 }; 321 322 var refreshCartFragment = function() { 323 initAjaxRemoveCartItem(); 324 if ( $.cookie( 'woocommerce_items_in_cart' ) > 0 ) { 325 $( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).show(); 326 } else { 327 $( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).hide(); 328 } 329 }; 330 331 var updateCartFragment = function( data ) { 332 if ( data && data.fragments ) { 333 var fragments = data.fragments, 334 cart_hash = data.cart_hash; 335 336 $.each( fragments, function( key, value ) { 337 $( key ).replaceWith( value ); 338 } ); 339 if ( typeof wc_cart_fragments_params === 'undefined' ) { 340 return; 341 } 342 /* Storage Handling */
343 if ( $supports_html5_storage ) { 344 var prev_cart_hash = sessionStorage.getItem( 'wc_cart_hash' ); 345 346 if ( prev_cart_hash === null || prev_cart_hash === undefined || prev_cart_hash === '' ) { 347 setCartCreationTimestamp(); 348 } 349 sessionStorage.setItem( wc_cart_fragments_params.fragment_name, JSON.stringify( fragments ) ); 350 setCartHash( cart_hash ); 351 } 352 } 353 }; 354 355 $( function() { 356 357 refreshCartFragment(); 358 359 // add ajax cart loading 360 $( document ).on( 'click', '.add_to_cart_button', function( e ) { 361 var $this = $( this ); 362 if ( typeof theme.noAjaxCart == 'undefined' ) { 363 theme.noAjaxCart = ! $( '#wc-add-to-cart-js' ).length; 364 } 365 if ( $this.is( '.product_type_simple' ) || $this.is( '.jck_wssv_add_to_cart' ) ) { 366 if ( 'SPAN' == $this.prop( 'tagName' ) && ( theme.noAjaxCart || ! $this.attr( 'data-product_id' ) ) ) { 367 window.location.href = $this.attr( 'href' ); 368 } 369 370 if ( $.fn.tooltip ) { 371 $this.tooltip( 'hide' ); 372 } 373 374 if ( $this.attr( 'data-product_id' ) ) { 375 $this.addClass( 'product-adding' ); 376 377 // add to cart notifaction style 2, 3 378 if ( $this.hasClass( 'viewcart-style-2' ) || $this.hasClass( 'viewcart-style-3' ) ) { 379 if ( $this.closest( '.porto-hotspot' ).length == 0 && $this.closest( '.menu-block' ).length == 0 && ! $( '#loading-mask' ).length ) { 380 $( 'body' ).append( '<div id="loading-mask"><div class="background-overlay"></div></div>' ); 381 } 382 if ( !$( this ).closest( '.product' ).find( '.loader-container' ).length ) { 383 $( this ).closest( '.product' ).find( '.product-image' ).append( '<div class="loader-container"><div class="loader"><i class="porto-ajax-loader"></i></div></div>' ); 384 } 385 $( this ).closest( '.product' ).find( '.loader-container' ).show(); 386 } 387 } 388 } else if ( 'SPAN' == $this.prop( 'tagName' ) ) { 389 window.location.href = $this.attr( 'href' ); 390 } 391 } ); 392 393 $( document.body ).on( 'added_to_cart', function() { 394 $( 'ul.products li.product .added_to_cart, .porto-tb-item .added_to_cart' ).remove(); 395 initAjaxRemoveCartItem(); 396 } ); 397 398 $( document.body ).on( 'wc_cart_button_updated', function() { 399 $( 'ul.products li.product .added_to_cart, .porto-tb-item .added_to_cart' ).remove(); 400 } ); 401 402 $( document.body ).on( 'wc_fragments_refreshed wc_fragments_loaded', function() { 403 refreshCartFragment(); 404 } ); 405 406 $( document ).on( 'click', '.product-image .viewcart, .after-loading-success-message .viewcart', function( e ) { 407 if ( wc_add_to_cart_params.cart_url ) { 408 window.location.href = wc_add_to_cart_params.cart_url; 409 } 410 e.preventDefault(); 411 } ); 412 var porto_product_add_cart_timer = null; 413 $( document ).on( 'added_to_cart', 'body', function( event ) { 414 var $mc_item = $( '#mini-cart .cart-items' ); 415 if ( $mc_item.length ) { 416 $mc_item.addClass( 'count-updating' ); 417 setTimeout( function() { 418 $mc_item.removeClass( 'count-updating' ); 419 }, 1000 ); 420 } 421 422 //add to cart notifaction style 2,3 423 $( 'body #loading-mask' ).remove(); 424 425 $( '.add_to_cart_button.product-adding' ).each( function() { 426 var $link = $( this ); 427 $link.removeClass( 'product-adding' ); 428 if ( $( '.woocommerce-wishlist.woocommerce-page' ).length ) { //wishlist page 429 return; 430 } 431 if ( $link.hasClass( 'viewcart-style-1' ) ) { 432 $link.closest( '.product' ).find( '.viewcart' ).addClass( 'added' ); 433 $( '.minicart-offcanvas' ).addClass( 'minicart-opened' ); 434 } else { 435 $link.closest( '.product' ).find( '.loader-container' ).hide(); 436 if ( $link.closest( 'li.outofstock' ).length ) { 437 return; 438 } 439 var $msg; 440 if ( $link.hasClass( 'viewcart-style-2' ) ) { 441 $msg = $( '.after-loading-success-message .success-message-container' ).eq( 0 ); 442 $msg.find( '.product-name' ).text( $link.closest( '.product' ).find( '.woocommerce-loop-product__title, .product-loop-title, .post-title a' ).text() ); 443 } else { 444 $msg = $( '.after-loading-success-message .success-message-container' ).last().clone().removeClass( 'd-none' ); 445 $msg.find( '.product-name' ).empty().append( $link.closest( '.product' ).find( '.product-loop-title, .post-title a' ).clone() ); 446 } 447 $msg.find( '.msg-box img' ).remove(); 448 if ( $link.closest( '.product' ).find( '.product-image img' ).length ) { 449 var $img = $link.closest( '.product' ).find( '.product-image img' ).eq( 0 ); 450 $( '<img />' ).attr( 'src', $img.data( 'oi' ) ? $img.data( 'oi' ) : $img.attr( 'src' ) ).appendTo( $msg.find( '.msg-box' ) ).attr( 'alt', $msg.find( '.msg .product-name' ).text() ); 451 } else if ( typeof js_porto_vars.wc_placeholder_img != 'undefined' ) { 452 $( '<img />' ).attr( 'src', js_porto_vars.wc_placeholder_img ).appendTo( $msg.find( '.msg-box' ) ).attr( 'alt', $msg.find( '.msg .product-name' ).text() ); 453 } 454 $( '.after-loading-success-message' ).eq( 0 ).stop().show(); 455 456 if ( $link.hasClass( 'viewcart-style-2' ) ) { 457 if ( porto_product_add_cart_timer ) { 458 clearTimeout( porto_product_add_cart_timer ); 459 } 460 porto_product_add_cart_timer = setTimeout( function() { $( '.after-loading-success-message' ).eq( 0 ).hide(); }, 4000 ); 461 } else {
462 $msg.prependTo( '.after-loading-success-message' ); 463 theme.requestTimeout( function() { 464 $msg.addClass( 'active' ); 465 }, 50 ); 466 setTimeout( function() { $msg.find( '.mfp-close' ).trigger( 'click' ); }, 5000 ); 467 } 468 } 469 } ); 470 471 // open minicart on single product page 472 if ( this.classList.contains( 'single-product' ) ) { 473 var $minicart_obj = $( '#mini-cart.open-minicart-added:visible' ); 474 if ( $minicart_obj.length && $( '.sp-only-cart-form' ).length ) { 475 if ( $minicart_obj.closest( '.header-main.sticky' ).length && $( '#header' ).hasClass( 'scroll-down' ) ) { 476 $( window ).scrollTop( $( window).scrollTop() - 1 ); 477 } 478 setTimeout(() => { 479 $( '#header' ).removeClass( 'scroll-down' ); 480 $minicart_obj.find( '.cart-head' ).trigger( 'click' ); 481 }, 150); 482 } 483 } 484 } ); 485 486 // Fix stuck offcanvas mini cart after pressing Back from cart/checkout. 487 // On mobile bfcache restore the single-product page comes back with the 488 // mini cart still "opened" (overlay + html overflow:hidden). With a 489 // "Scroll Up" sticky header the restored `scroll-down` class hides the 490 // header â and the mini cart panel inside it â while the fixed overlay 491 // stays, leaving the page stuck behind an un-closable overlay. The 492 // added_to_cart event never re-fires on restore, so reset the mini cart 493 // and sticky-header scroll state here to make the page usable again. 494 $( window ).on( 'pageshow.portoMinicartReset', function( e ) { 495 if ( ! ( e.originalEvent && e.originalEvent.persisted ) ) { 496 return; // Only on bfcache restore; a fresh load is already clean. 497 } 498 var $offcanvas = $( '.minicart-offcanvas.minicart-opened' ); 499 if ( $offcanvas.length ) { 500 $offcanvas.removeClass( 'minicart-opened' ); 501 $( 'html' ).css( { 'overflow': '', 'margin-right': '' } ); 502 } 503 $( '#mini-cart.open' ).removeClass( 'open' ); 504 $( '#header' ).removeClass( 'scroll-down' ); 505 $( '.page-wrapper' ).removeData( 'prev-scrollpos' ); 506 } ); 507 508 $( '.after-loading-success-message .continue_shopping' ).on( 'click', function() { 509 $( '.after-loading-success-message' ).eq( 0 ).fadeOut( 200 ); 510 } ); 511 $( '.after-loading-success-message' ).on( 'click', '.mfp-close', function() { 512 var $obj = $( this ).closest( '.success-message-container' ); 513 $obj.removeClass( 'active' ); 514 theme.requestTimeout( function() { 515 $obj.slideUp( 300, function() { 516 $obj.remove(); 517 } ); 518 }, 350 ); 519 } ); 520 521 $( document.body ).on( 'click', '.variations_form .variations .filter-item-list .filter-color, .variations_form .variations .filter-item-list .filter-item', function( e ) { 522 e.preventDefault(); 523 var $this = $( this ), 524 $selector = $this.closest( 'ul' ).siblings( 'select' ); 525 if ( !$selector.length || $this.hasClass( 'disabled' ) ) { 526 return; 527 } 528 var $li_obj = $this.closest( 'li' ); 529 if ( $li_obj.hasClass( 'active' ) ) { 530 $li_obj.removeClass( 'active' ); 531 $selector.val( '' ); 532 } else { 533 $li_obj.addClass( 'active' ).siblings().removeClass( 'active' ); 534 $selector.val( $this.data( 'value' ) ); 535 } 536 $selector.trigger( 'change.wc-variation-form' ); 537 } ); 538 539 540 $( document.body ).on( 'click', '.porto-general-swatch .filter-color, .porto-general-swatch .filter-item', function( e ) { 541 e.preventDefault(); 542 var $this = $( this ), 543 $swatch_li = $this.parent(); 544 545 var $product = $( this ).closest( '.product, .product-col' ); 546 var $product_img; 547 if ( $product.hasClass( 'porto-tb-item' ) ) { // in type builder 548 $product_img = $product.find( '.porto-tb-featured-image img' ).eq( 0 ); 549 } else if ( $product.hasClass( 'product-col' ) ) { // product legacy loop 550 $product_img = $product.find( 'div.product-image .inner img:first-child' ); 551 } 552 553 var srcOrig = $product_img.data( 'original-src' ), 554 srcsetOrig = $product_img.data( 'original-srcset '), 555 sizesOrig = $product_img.data( 'original-sizes' ); 556 if ( typeof srcOrig == 'undefined' ) { 557 $product_img.data( 'original-src', $product_img.attr( 'src' ) ); 558 if ( typeof srcsetOrig == 'undefined' && $product_img.attr( 'srcset' ) ) { 559 $product_img.data( 'original-srcset', $product_img.attr( 'srcset' ) ); 560 } 561 562 if ( typeof sizesOrig == 'undefined' && $product_img.attr( 'sizes' ) ) { 563 $product_img.data( 'original-sizes', $product_img.attr( 'sizes' ) ); 564 } 565 } 566 567 var image_src = '', 568 image_srcset = '', 569 image_sizes = ''; 570 571 if ( $this.parent().hasClass( 'active' ) ) { 572 $swatch_li.removeClass( 'active' ); 573 } else { // active 574 $this.closest( 'ul' ).find( 'li' ).removeClass( 'active' ); 575 $swatch_li.addClass( 'active' ); 576 if ( $swatch_li.data( 'image-src' ) ) { 577 image_src = $swatch_li.data( 'image-src' ); 578 image_srcset = $swatch_li.data( 'image-srcset' ); 579 image_sizes = $swatch_li.data( 'image-sizes' ); 580 } 581 } 582 if ( ! image_src ) { 583 var $active_swatch = $this.closest( '.porto-general-swatch' ).find( 'li.active' ); 584 if ( $active_swatch.length && $active_swatch.data( 'image-src' ) ) { 585 image_src = $active_swatch.data( 'image-src' ); 586 image_srcset = $active_swatch.data( 'image-srcset' ); 587 image_sizes = $active_swatch.data( 'image-sizes' ); 588 } else { 589 if ( $product_img.data('original-src' ) ) { 590 image_src = $product_img.data('original-src' ); 591 } 592 593 if ( $product_img.data( 'original-srcset' ) ) { 594 image_srcset = $product_img.data( 'original-srcset' ); 595 } 596 597 if ( $product_img.data( 'original-sizes' ) ) { 598 image_sizes = $product_img.data( 'original-sizes' ); 599 } 600 } 601 } 602 if ( image_src ) { 603 $product_img.attr( 'src', image_src ).attr( 'srcset', image_srcset ).attr( 'image_sizes', image_sizes ); 604 var $image_slider = $product.find( '.owl-carousel' ); 605 606 if ( $image_slider.length ) { 607 $image_slider.trigger( 'to.owl.carousel', [0, 300, true] ); 608 } 609 } 610 }); 611 612 613 $( document ).on( 'wc_variation_form', '.variations_form', function() { 614 $( this ).addClass( 'vf_init' ); 615 if ( $( this ).find( '.filter-item-list' ).length < 1 ) { 616 return; 617 } 618 $( this ).find( '.variations select' ).trigger( 'focusin' ); 619 } ); 620 $( document ).on( 'updated_wc_div', function() { 621 if ( $.fn.themePluginLazyLoad ) { 622 $( '.woocommerce-cart-form .porto-lazyload' ).themePluginLazyLoad(); 623 } 624 } ); 625 $( document ).on( 'found_variation reset_data', '.variations_form', function( e, args ) { 626 // attribute description 627 var $this = $( this ); 628 if ( $this.find( '.product-attr-description' ).length ) { 629 if ( typeof args == 'undefined' ) { 630 $this.find( '.product-attr-description' ).removeClass( 'active' ); 631 } else { 632 $this.find( '.product-attr-description' ).addClass( 'active' ); 633 $this.find( '.product-attr-description .attr-desc' ).removeClass( 'active' ); 634 $this.find( '.variations select' ).each( function() { 635 var $obj = $( this ); 636 $this.find( '.product-attr-description .attr-desc[data-attrid="' + $obj.val() + '"]' ).addClass( 'active' ); 637 } ); 638 } 639 } 640 641 if ( $this.find( ".filter-item-list" ).length < 1 ) { 642 return; 643 } 644 $this.find( ".filter-item-list" ).each( function() { 645 if ( $( this ).next( "select" ).length < 1 ) { 646 return; 647 } 648 var selector = $( this ).next( "select" ), 649 //html = '', 650 $list = $( this ); 651 $list.find( 'li.active' ).removeClass( 'active' ); 652 $list.find( '.filter-color, .filter-item' ).removeClass( 'enabled' ).removeClass( 'disabled' ); 653 selector.children( "option" ).each( function() { 654 /*var isColor = typeof $(this).data('color') != 'undefined' ? true : false, 655 isImage = typeof $(this).data('image') != 'undefined' ? true : false, 656 spanClass = isColor ? "filter-color" : ( isImage ? "filter-item filter-image" : "filter-item" );*/ 657 if ( !$( this ).val() ) { 658 return; 659 } 660 $list.find( '[data-value="' + $( this ).val().replace(/"/g, '\\\"') + '"]' ).addClass( 'enabled' ); 661 if ( $( this ).val() == selector.val() ) { 662 $list.find( '[data-value="' + $( this ).val().replace(/"/g, '\\\"') + '"]' ).parent().addClass( 'active' ); 663 } 664 /*html += '<li'; 665 if ($(this).val() == selector.val()) { 666 html += ' class="active"'; 667 } 668 html += '><a href="#" data-value="'+ escape( $(this).val() ) +'" class="' + spanClass + '"'; 669 if (isColor) { 670 html += ' style="background-color: #' + escape( $(this).data('color').replace('#','') ) + '"'; 671 } 672 if (isImage) { 673 html += ' style="background-image:url(' + $(this).data('image') + ')"'; 674 } 675 html += '>'; 676 if (!isColor) { 677 html += $(this).text(); 678 } 679 html += '</a></li>';*/ 680 } ); 681 $list.find( '.filter-color:not(.enabled), .filter-item:not(.enabled)' ).addClass( 'disabled' ); 682 //$(this).html(html); 683 } ); 684 } ); 685 686 // daily sale 687 $( document ).on( 'found_variation reset_data', '.variations_form', function( e, obj ) { 688 var $wrapper = $( this ).closest( '.product' ), 689 $timer = $wrapper.find( '.sale-product-daily-deal.for-some-variations' ); 690 if ( !$timer.length ) { 691 $timer = $wrapper.find( '.porto-product-sale-timer' ).eq( 0 ); 692 if ( !$timer.length ) { 693 return; 694 } 695 } 696 if ( obj && obj.is_purchasable && typeof obj.porto_date_on_sale_to != 'undefined' && obj.porto_date_on_sale_to ) {
697 var saleTimer = $timer.find( '.porto_countdown-dateAndTime' ); 698 if ( saleTimer.data( 'terminal-date' ) != obj.porto_date_on_sale_to ) { 699 var newDate = new Date( obj.porto_date_on_sale_to ); 700 saleTimer.porto_countdown( 'option', { until: newDate } ); 701 saleTimer.data( 'terminal-date', obj.porto_date_on_sale_to ); 702 } 703 $timer.slideDown(); 704 } else { 705 if ( $timer.is( ':hidden' ) ) { 706 $timer.hide(); 707 } else { 708 $timer.slideUp(); 709 } 710 } 711 } ); 712 713 $( 'body' ).on( 'click', '.product-attr-description > a', function( e ) { 714 e.preventDefault(); 715 $( this ).next().stop().slideToggle( 400 ); 716 } ); 717 718 // if product was already added to cart, show check icon in add to cart button and view cart button in single product page 719 if ( $( document.body ).hasClass( 'single-product' ) ) { 720 $( document ).on( 'woocommerce_variation_has_changed', '.variations_form', function( e, variation ) { 721 $( document.body ).removeClass( 'single-add-to-cart' ); 722 } ); 723 $( document ).on( 'found_variation', '.variations_form', function( e, variation ) { 724 try { 725 var cart_items = JSON.parse( sessionStorage.getItem( wc_cart_fragments_params.fragment_name ) ); 726 if ( cart_items['div.widget_shopping_cart_content'] ) { 727 var cart_item = $( cart_items['div.widget_shopping_cart_content'] ).find( '.porto-variation-' + variation.variation_id ); 728 if ( cart_item.length ) { 729 theme.requestFrame( function() { 730 $( document.body ).addClass( 'single-add-to-cart' ); 731 } ); 732 } 733 } 734 } catch ( e ) { 735 } 736 } ); 737 } 738 739 // Mini Cart Quantity on Cart Popup or Offcanvas 740 var timeout; 741 742 $( document ).on( 'change input', '.cart_list .quantity .qty, .woocommerce-checkout-review-order-table .quantity .qty', function() { 743 this.value = this.value.replace(/[^0-9]/g, ''); 744 var input = $(this); 745 var itemID = ''; 746 var qtyVal = input.val(); 747 var maxValue = input.attr( 'max' ); 748 var is_checkout = false; 749 750 clearTimeout( timeout ); 751 752 if ( parseInt( qtyVal ) > parseInt( maxValue ) ) { 753 qtyVal = maxValue; 754 } 755 if ( input.closest( '.cart_list' ).length ) { 756 itemID = input.parents( '.woocommerce-mini-cart-item' ).data( 'key' ); 757 } else { 758 is_checkout = true; 759 itemID = input.closest( '.cart_item' ).data( 'key' ); 760 } 761 timeout = setTimeout( function() { 762 if ( ! is_checkout ) { 763 input.parents( '.mini_cart_item' ).find( '.ajax-loading' ).show(); 764 } 765 $.ajax( { 766 url : theme.ajax_url, 767 data : { 768 action : 'porto_update_cart_item', 769 item_id: itemID, 770 qty : qtyVal 771 }, 772 success : function( data ) { 773 if ( data && data.fragments ) { 774 updateCartFragment( data ); 775 $( document.body ).trigger( 'wc_fragments_refreshed' ); 776 } 777 if ( is_checkout ) { 778 input.closest( 'form.checkout' ).trigger( 'update' ); 779 } else { 780 input.parents( '.mini_cart_item' ).find( '.ajax-loading' ).hide(); 781 } 782 }, 783 dataType: 'json', 784 method : 'GET' 785 } ); 786 }, 500 ); 787 } ); 788 789 if ( $( 'form.woocommerce-cart-form button.update-button-hidden' ).length > 0 ) { 790 $( document ).on( 'change input', 'form.woocommerce-cart-form .product-quantity input', function () { 791 this.value = this.value.replace(/[^0-9]/g, ''); 792 var $form = $( this ).closest( 'form' ), 793 $updateBtn = $form.find( '.update-button-hidden' ); 794 795 $updateBtn.removeAttr( 'disabled' ); 796 $updateBtn.click(); 797 } ); 798 } 799 800 // fix dummy yith ajax requests on first load 801 if ( 'undefined' !== typeof yith_wcwl_l10n && yith_wcwl_l10n.reload_on_found_variation && $('.products-container .variations_form').length ) { 802 var porto_update_reload_wishlist_fn = function() { 803 yith_wcwl_l10n.reload_on_found_variation = true; 804 if ( $(this).closest( '.products-container' ).length ) { 805 yith_wcwl_l10n.reload_on_found_variation = false; 806 } 807 }; 808 $('.products-container').one( 'woocommerce_variation_has_changed woocommerce_variation_select_change', '.variations_form', function() { 809 yith_wcwl_l10n.reload_on_found_variation = true; 810 $( document ).off( 'update_variation_values', '.variations_form', porto_update_reload_wishlist_fn ); 811 } ); 812 $( document ).on( 'update_variation_values', '.variations_form', porto_update_reload_wishlist_fn ); 813 } 814 } ); 815 816 } ).apply( this, [window.theme, jQuery] ); 817 818 819 // Woocommerce Product Image Slider 820 ( function( theme, $ ) { 821 822 theme = theme || {}; 823 824 var duration = 300, 825 flag = false; 826 827 $.extend( theme, { 828 829 WooProductImageSlider: { 830 831 defaults: { 832 elements: '.product-image-slider' 833 }, 834 835 initialize: function( $elements ) { 836 837 this.$elements = ( $elements || $( this.defaults.elements ) ); 838 if ( !this.$elements.length && !$( '.product-images-block' ).length ) { 839 return this; 840 } 841 // if ( theme.isMobile() ) { 842 // let $zoom = this.$elements.siblings( '.zoom' ); 843 // if ( $zoom.length ) { 844 // this.$elements.off( 'click' ).on( 'click', function() { 845 // $zoom.trigger( 'click' ); 846 // } ); 847 // } 848 // } 849/* 850 if ( !$.fn.owlCarousel ) { 851 852 this.$elements.each(function(){ 853 var links = [], 854 $this = $( this ); 855 if ( theme.product_image_popup ) { 856 var i = 0; 857 $this.find( 'img' ).each( function() { 858 var slide = {}; 859 860 slide.src = $( this ).attr( 'href' ); 861 slide.title = $( this ).attr( 'alt' ); 862 slide.w = parseInt( $( this ).attr( 'data-large_image_width' ) ); 863 slide.h = parseInt( $( this ).attr( 'data-large_image_height' ) ); 864 865 links[i] = slide; 866 i++; 867 } ); 868 } 869 870 $this.data( 'links', links ); 871 872 if ( theme.product_image_popup ) { 873 var $zoom_buttons = $this.siblings( '.zoom' ); 874 $zoom_buttons.off( 'click' ).on( 'click', function( e ) { 875 if ( ! $this.data( 'links' ).length ) { 876 return; 877 } 878 e.preventDefault(); 879 if ( typeof PhotoSwipe == 'undefined' ) { 880 return; 881 } 882 var options = $.extend( { 883 index: 0, 884 addCaptionHTMLFn: function( item, captionEl ) { 885 if ( ! item.title ) { 886 captionEl.children[0].textContent = ''; 887 return false; 888 } 889 captionEl.children[0].textContent = item.title; 890 return true; 891 } 892 }, wc_single_product_params.photoswipe_options ); 893 894 // Initializes and opens PhotoSwipe. 895 var photoswipe = new PhotoSwipe( $( '.pswp' )[0], PhotoSwipeUI_Default, $this.data( 'links' ), options ); 896 photoswipe.init(); 897 898 } ); 899 } 900 });
901 return false; 902 } 903*/ 904 905 this.build(); 906 907 return this; 908 }, 909 910 build: function() { 911 var self = this, 912 thumbs_count = theme.product_thumbs_count; 913 914 if ( theme.product_zoom && ( !( 'ontouchstart' in document ) || ( ( 'ontouchstart' in document ) && theme.product_zoom_mobile ) ) ) { 915 var zoomConfig = { 916 responsive: true, 917 zoomWindowFadeIn: 200, 918 zoomWindowFadeOut: 100, 919 zoomType: js_porto_vars.zoom_type, 920 cursor: 'grab' 921 }; 922 923 if ( js_porto_vars.zoom_type == 'lens' ) { 924 zoomConfig.scrollZoom = js_porto_vars.zoom_scroll; 925 zoomConfig.lensSize = js_porto_vars.zoom_lens_size; 926 zoomConfig.lensShape = js_porto_vars.zoom_lens_shape; 927 zoomConfig.containLensZoom = js_porto_vars.zoom_contain_lens; 928 zoomConfig.lensBorderSize = js_porto_vars.zoom_lens_border; 929 zoomConfig.borderColour = js_porto_vars.zoom_border_color; 930 } 931 932 if ( js_porto_vars.zoom_type == 'inner' ) { 933 zoomConfig.borderSize = 0; 934 } else { 935 zoomConfig.borderSize = js_porto_vars.zoom_border; 936 } 937 zoomConfig.zoomActivation = 'dbltouch'; 938 939 if ( !self.$elements.length ) { 940 var $images_grid = $( '.product-images-block' ); 941 if ( $images_grid.length ) { 942 self.initZoom( $images_grid, zoomConfig ); 943 } 944 } 945 } 946 947 self.$elements.each( function() { 948 var $this = $( this ), 949 $product = $this.closest( '.product' ); 950 if ( !$product.length ) { 951 $product = $this.closest( '.product_layout, .product-layout-image' ).eq( 0 ); 952 } 953 var $thumbs_slider = $product.find( '.product-thumbs-slider' ), 954 $thumbs = $product.find( '.product-thumbnails-inner' ), 955 $thumbs_vertical_slider = $product.find( '.product-thumbs-vertical-slider' ), 956 currentSlide = 0, 957 count = $this.find( '> *' ).length; 958 959 $this.find( '> *:first-child' ).imagesLoaded( function() { 960 961 var links = []; 962 if ( theme.product_image_popup ) { 963 var i = 0; 964 $this.find( '.img-thumbnail img' ).each( function() { 965 var slide = {}, _imageItem = $( this ); 966 if ( _imageItem.closest( '.vd-image' ).length ) { 967 return; 968 } 969 slide.src = _imageItem.attr( 'href' ); 970 slide.title = _imageItem.attr( 'alt' ); 971 slide.w = parseInt( _imageItem.attr( 'data-large_image_width' ) ); 972 slide.h = parseInt( _imageItem.attr( 'data-large_image_height' ) ); 973 974 links[i] = slide; 975 i++; 976 } ); 977 } 978 979 if ( $.fn.owlCarousel ) { 980 $thumbs_slider.removeClass( 'has-ccols-spacing' ); 981 $thumbs_slider.owlCarousel( { 982 rtl: theme.rtl, 983 loop: false, 984 autoplay: false, 985 items: thumbs_count, 986 nav: false, 987 navText: ["", ""], 988 dots: false, 989 rewind: true, 990 margin: 8, 991 stagePadding: 1, 992 lazyLoad: true, 993 onInitialized: function() { 994 self.selectThumb( null, $thumbs_slider, 0 ); 995 if ( $thumbs_slider.find( '.owl-item' ).length >= thumbs_count ) 996 $thumbs_slider.append( '<div class="thumb-nav"><div class="thumb-prev"></div><div class="thumb-next"></div></div>' ); 997 } 998 } ).on( 'click', '.owl-item', function() { 999 self.selectThumb( $this, $thumbs_slider, $( this ).index() ); 1000 } ); 1001 if ( $thumbs_vertical_slider.length > 0 && typeof $.fn.slick == 'function' ) { 1002 var slickOptions = { 1003 dots: false, 1004 vertical: true, 1005 slidesToShow: thumbs_count, 1006 slidesToScroll: 1, 1007 infinite: false, 1008 } 1009 if ( thumbs_count >= 5 ) { 1010 slickOptions['responsive'] = [ 1011 { 1012 breakpoint: 992, 1013 settings: { 1014 slidesToShow: 4, 1015 } 1016 }, 1017 { 1018 breakpoint: 768, 1019 settings: { 1020 slidesToShow: 3, 1021 } 1022 } 1023 ] 1024 } 1025 $thumbs_vertical_slider.slick( slickOptions ).on( 'click', '.slick-slide', function() { 1026 self.selectVerticalSliderThumb( $this, $thumbs_vertical_slider, $( this ).data( 'slick-index' ) ); 1027 } ); 1028 $( '.product-layout-transparent .product-image-slider' ).on( 'resized.owl.carousel', function() { 1029 $( window ).trigger( 'resize.slick' ); 1030 } ); 1031 1032 self.selectVerticalSliderThumb( null, $thumbs_vertical_slider, 0 ); 1033 if ( $thumbs_vertical_slider.find( '.porto-lazyload' ).length ) { 1034 theme.requestTimeout( function() { 1035 $thumbs_vertical_slider.find( '.slick-cloned .porto-lazyload:not(.lazy-load-loaded)' ).each( function() { 1036 $( this ).attr( 'src', $( this ).data( 'oi' ) ).removeAttr( 'data-oi' ).addClass( 'lazy-load-loaded' ); 1037 } ); 1038 }, 100 ); 1039 } 1040 } 1041 1042 self.selectVerticalThumb( null, $thumbs, 0 ); 1043 $thumbs.off( 'click', '.img-thumbnail' ).on( 'click', '.img-thumbnail', function() { 1044 self.selectVerticalThumb( $this, $thumbs, $( this ).index() ); 1045 } ); 1046 1047 $thumbs_slider.off( 'click', '.thumb-prev' ).on( 'click', '.thumb-prev', function( e ) { 1048 var currentThumb = $thumbs_slider.data( 'currentThumb' ); 1049 self.selectThumb( $this, $thumbs_slider, --currentThumb ); 1050 } ); 1051 $thumbs_slider.off( 'click', '.thumb-next' ).on( 'click', '.thumb-next', function( e ) { 1052 var currentThumb = $thumbs_slider.data( 'currentThumb' ); 1053 self.selectThumb( $this, $thumbs_slider, ++currentThumb ); 1054 } ); 1055 1056 var itemsCount = typeof $this.data( 'items' ) != 'undefined' ? $this.data( 'items' ) : 1, 1057 itemsResponsive = typeof $this.data( 'responsive' ) != 'undefined' ? $this.data( 'responsive' ) : {}, 1058 centerItem = typeof $this.data( 'centeritem' ) != 'undefined' ? true : false, 1059 margin = typeof $this.data( 'margin' ) != 'undefined' ? $this.data( 'margin' ) : 0, 1060 loop = ( count > 1 ) ? ( typeof $this.data( 'loop' ) != 'undefined' ? $this.data( 'loop' ) : true ) : false; 1061 for ( var itemCount in itemsResponsive ) { 1062 itemsResponsive[itemCount] = { items: itemsResponsive[itemCount] }; 1063 } 1064 $this.removeClass( 'has-ccols-spacing' ); 1065 $this.owlCarousel( { 1066 rtl: theme.rtl, 1067 loop: loop, 1068 autoplay: false, 1069 items: itemsCount, 1070 margin: margin, 1071 responsive: itemsResponsive, 1072 autoHeight: true, 1073 nav: true, 1074 navText: ["", ""], 1075 dots: false, 1076 rewind: true, 1077 lazyLoad: true, 1078 center: centerItem, 1079 onInitialized: function() { 1080 if ( $this.find( '.owl-item.cloned' ).length ) { 1081 setTimeout( function() { 1082 if ( $.fn.themePluginLazyLoad ) { 1083 var ins = $this.find( '.owl-item.cloned .porto-lazyload:not(.lazy-load-loaded)' ).themePluginLazyLoad( { effect: 'fadeIn', effect_speed: 400 } ); 1084 if ( ins && ins.loadAndDestroy ) { 1085 ins.loadAndDestroy(); 1086 } 1087 } 1088 }, 100 ); 1089 } 1090 //$this.find('.cloned .porto-lazyload:not(.lazy-load-loaded)').themePluginLazyLoad(); 1091 self.initZoom( $this, zoomConfig ); 1092 }, 1093 onTranslate: function( event ) { 1094 currentSlide = event.item.index - $this.find( '.cloned' ).length / 2; 1095 currentSlide = ( currentSlide + event.item.count ) % event.item.count; 1096 self.selectThumb( null, $thumbs_slider, currentSlide ); 1097 self.selectVerticalThumb( null, $thumbs, currentSlide ); 1098 self.selectVerticalSliderThumb( null, $thumbs_vertical_slider, currentSlide ); 1099 1100 /*var $obj = event.relatedTarget.items(currentSlide).find('img.owl-lazy:not(.owl-lazy-loaded)'); 1101 if ($obj.length) { 1102 var src = $obj.attr('href'), 1103 elevateZoom = $obj.data('elevateZoom'), 1104 smallImage = $obj.data('src') ? $obj.data('src') : $obj.attr('src'); 1105 if (typeof elevateZoom != 'undefined') { 1106 elevateZoom.swaptheimage(smallImage, src); 1107 } 1108 }*/ 1109 }, 1110 onRefreshed: function() { 1111 if ( theme.product_zoom && ( !( 'ontouchstart' in document ) || ( ( 'ontouchstart' in document ) && theme.product_zoom_mobile ) ) ) { 1112 $this.find( 'img' ).each( function() { 1113 var $this = $( this ), 1114 src = typeof $this.attr( 'href' ) != 'undefined' ? $this.attr( 'href' ) : ( $this.data( 'oi' ) ? $this.data( 'oi' ) : $this.attr( 'src' ) ), 1115 elevateZoom = $this.data( 'elevateZoom' ), 1116 smallImage = $this.data( 'src' ) ? $this.data( 'src' ) : ( $this.data( 'oi' ) ? $this.data( 'oi' ) : $this.attr( 'src' ) ); 1117 if ( typeof elevateZoom != 'undefined' ) { 1118 elevateZoom.startZoom(); 1119 elevateZoom.swaptheimage( smallImage, src ); 1120 } else if ( $.fn.elevateZoom ) { 1121 zoomConfig.zoomContainer = $this.parent(); 1122 if ( ! $this.closest( '.vd-image' ).length ) { 1123 $this.elevateZoom( zoomConfig ); 1124 } 1125 } 1126 } ); 1127 } 1128 } 1129 } ); 1130 } else { 1131 self.initZoom( $this, zoomConfig ); 1132 } 1133 1134 $this.data( 'links', links ); 1135 1136 if ( theme.product_image_popup ) { 1137 var $zoom_buttons = $this.siblings( '.zoom' ); 1138 $zoom_buttons.off( 'click' ).on( 'click', function( e ) { 1139 if ( ! $this.data( 'links' ).length ) { 1140 return; 1141 } 1142 e.preventDefault(); 1143 if ( typeof PhotoSwipe == 'undefined' ) { 1144 return; 1145 } 1146 var options = $.extend( { 1147 index: currentSlide ? currentSlide : 0, 1148 addCaptionHTMLFn: function( item, captionEl ) { 1149 if ( ! item.title ) { 1150 captionEl.children[0].textContent = ''; 1151 return false; 1152 } 1153 captionEl.children[0].textContent = item.title; 1154 return true; 1155 } 1156 }, wc_single_product_params.photoswipe_options ); 1157 1158 // Initializes and opens PhotoSwipe. 1159 var photoswipe = new PhotoSwipe( $( '.pswp' )[0], PhotoSwipeUI_Default, $this.data( 'links' ), options ); 1160 photoswipe.init(); 1161 1162 } ); 1163 } 1164 1165 } ); 1166 } ); 1167 1168 return self; 1169 }, 1170 1171 selectThumb: function( $image_slider, $thumbs_slider, index ) { 1172 if ( flag || !$thumbs_slider.length ) return; 1173 1174 flag = true; 1175 var len = $thumbs_slider.find( '.owl-item' ).length, 1176 actives = [], 1177 i = 0; 1178 1179 index = ( index + len ) % len; 1180 if ( $image_slider ) { 1181 $image_slider.trigger( 'to.owl.carousel', [index, duration, true] ); 1182 } 1183 $thumbs_slider.find( '.owl-item' ).removeClass( 'selected' ); 1184 $thumbs_slider.find( '.owl-item:eq(' + index + ')' ).addClass( 'selected' ); 1185 $thumbs_slider.data( 'currentThumb', index ); 1186 $thumbs_slider.find( '.owl-item.active' ).each( function() { 1187 actives[i++] = $( this ).index(); 1188 } ); 1189 if ( $.inArray( index, actives ) == -1 ) { 1190 if ( Math.abs( index - actives[0] ) > Math.abs( index - actives[actives.length - 1] ) ) { 1191 $thumbs_slider.trigger( 'to.owl.carousel', [( index - actives.length + 1 ) % len, duration, true] ); 1192 } else { 1193 $thumbs_slider.trigger( 'to.owl.carousel', [index % len, duration, true] ); 1194 } 1195 } 1196 flag = false; 1197 }, 1198 1199 selectVerticalSliderThumb: function( $image_slider, $thumbs_vertical_slider, index ) { 1200 if ( flag || !$thumbs_vertical_slider.length ) return; 1201 flag = true; 1202 if ( 'undefined' == typeof $thumbs_vertical_slider[0].slick ) { 1203 return; 1204 } 1205 var len = $thumbs_vertical_slider[0].slick.slideCount, 1206 actives = [], 1207 i = 0; 1208 index = ( index + len ) % len; 1209 if ( $image_slider ) { 1210 $image_slider.trigger( 'to.owl.carousel', [index, duration, true] ); 1211 } 1212 $thumbs_vertical_slider.find( '.slick-slide' ).removeClass( 'selected' ); 1213 $thumbs_vertical_slider.find( '.slick-slide:eq(' + index + ')' ).addClass( 'selected' ); 1214 $thumbs_vertical_slider.data( 'currentThumb', index ); 1215 $thumbs_vertical_slider.find( '.slick-slide.slick-active' ).each( function() { 1216 actives[i++] = $( this ).index(); 1217 } ); 1218 if ( $.inArray( index, actives ) == -1 ) { 1219 if ( Math.abs( index - actives[0] ) > Math.abs( index - actives[actives.length - 1] ) ) { 1220 $thumbs_vertical_slider.get( 0 ).slick.goTo( ( index - actives.length + 1 ) % len, false ); 1221 } else { 1222 $thumbs_vertical_slider.get( 0 ).slick.goTo( index % len, false ); 1223 } 1224 } 1225 flag = false; 1226 }, 1227 1228 selectVerticalThumb: function( $image_slider, $thumbs, index ) { 1229 if ( flag || !$thumbs.length ) return; 1230 flag = true; 1231 var len = $thumbs.find( '.img-thumbnail' ).length, 1232 i = 0; 1233 1234 index = ( index + len ) % len; 1235 if ( $image_slider ) { 1236 $image_slider.trigger( 'to.owl.carousel', [index, duration, true] ); 1237 } 1238 $thumbs.find( '.img-thumbnail' ).removeClass( 'selected' ); 1239 $thumbs.find( '.img-thumbnail:eq(' + index + ')' ).addClass( 'selected' ); 1240 $thumbs.data( 'currentThumb', index ); 1241 flag = false; 1242 }, 1243 1244 initZoom: function( $this, zoomConfig ) { 1245 if ( theme.product_zoom && ( !( 'ontouchstart' in document ) || ( ( 'ontouchstart' in document ) && theme.product_zoom_mobile ) ) ) { 1246 $this.find( 'img' ).each( function() { 1247 var $this = $( this ); 1248 zoomConfig.zoomContainer = $this.parent(); 1249 if ( $.fn.elevateZoom ) { 1250 if ( ! $this.closest( '.vd-image' ).length ) { 1251 $this.elevateZoom( zoomConfig ); 1252 } 1253 } else { 1254 setTimeout( function() { 1255 if ( $.fn.elevateZoom ) { 1256 if ( ! $this.closest( '.vd-image' ).length ) { 1257 $this.elevateZoom( zoomConfig ); 1258 } 1259 } 1260 }, 1000 ); 1261 } 1262 } ); 1263 } 1264 } 1265 } 1266 1267 } ); 1268 1269 } ).apply( this, [window.theme, jQuery] ); 1270 1271 1272 // Woocommerce Quick View 1273 ( function( theme, $ ) { 1274 1275 theme = theme || {}; 1276 1277 $.extend( theme, { 1278 1279 WooQuickView: { 1280 1281 initialize: function() { 1282 1283 this.events(); 1284 1285 return this; 1286 }, 1287 1288 events: function() { 1289 var self = this; 1290 1291 $( document ).on( 'click', '.quickview', function( e ) { 1292 e.preventDefault(); 1293 1294 if ( !$.fn.elevateZoom && !$( '#porto-script-jquery-elevatezoom' ).length ) { 1295 var js = document.createElement( 'script' ); 1296 js.id = 'porto-script-jquery-elevatezoom'; 1297 $( js ).appendTo( 'body' ).attr( 'src', js_porto_vars.ajax_loader_url.replace( '/images/[email protected]', '/js/libs/jquery.elevatezoom.min.js' ) ); 1298 } 1299 1300 var $this = $( this ), 1301 pid = $this.attr( 'data-id' ); 1302 1303 function init_quick_view_window() { 1304 1305 var args = { 1306 href: theme.ajax_url, 1307 ajax: { 1308 data: { 1309 action: 'porto_product_quickview', 1310 variation_flag: typeof wc_add_to_cart_variation_params !== 'undefined', 1311 pid: pid, 1312 nonce: js_porto_vars.porto_nonce 1313 } 1314 }, 1315 type: 'ajax', 1316 helpers: { 1317 overlay: { 1318 locked: true, 1319 fixed: true 1320 } 1321 }, 1322 tpl: { 1323 error: '<p class="fancybox-error">' + theme.request_error + '</p>', 1324 closeBtn: '<a title="' + js_porto_vars.popup_close + '" class="fancybox-item fancybox-close" href="javascript:;"></a>', 1325 next: '<a title="' + js_porto_vars.popup_next + '" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>', 1326 prev: '<a title="' + js_porto_vars.popup_prev + '" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>' 1327 }, 1328 autoSize: true, 1329 autoWidth: true, 1330 afterShow: function( flag ) { 1331 theme.requestTimeout( function() { 1332 var $quickviewEl = $( '.quickview-wrap-' + pid
1332); 1333 if ( $quickviewEl.length == 0 && $( '.woocommerce-wishlist' ).length ) { // if select variation on wishlist page 1334 $quickviewEl = $( '.quickview-wrap' ); 1335 } 1336 if ( typeof flag == 'undefined' || flag ) { 1337 porto_woocommerce_init(); 1338 } 1339 theme.WooProductImageSlider.initialize( $quickviewEl.find( '.product-image-slider' ) ); 1340 1341 // compatibility issue with Yith WooCommerce Booking form 1342 if ( $( document.body ).hasClass( 'yith-booking' ) ) { 1343 $( document ).trigger( 'yith-wcbk-init-booking-form' ); 1344 } 1345 1346 // Variation Form 1347 var form_variation = $quickviewEl.find( 'form.variations_form' ); 1348 if ( form_variation.length > 0 ) { 1349 form_variation.wc_variation_form(); 1350 } 1351 1352 // Enqueue Countdown, Countdown-loader 1353 if ( $( '.quickview-wrap-' + pid + ' .porto_countdown' ).length && ! theme.isFirstLoad && typeof $.fn.porto_countdown == 'undefined' ) { 1354 theme.isFirstLoad = true; 1355 var scripts = ['countdown.min.js', 'countdown-loader.min.js']; 1356 for ( let index = 0; index < scripts.length; index++ ) { 1357 if ( !document.getElementById( scripts[index] ) ) { 1358 var wf, script; 1359 wf = document.createElement( 'script' ); 1360 script = document.scripts[0]; 1361 wf.id = scripts[index]; 1362 wf.src = js_porto_vars.func_url + 'shortcodes/assets/js/' + scripts[index]; 1363 script.parentNode.insertBefore( wf, script ); 1364 } 1365 } 1366 } 1367 $( document.body ).trigger( 'porto_init_countdown', [$quickviewEl] ); 1368 1369 // Ajax load at the first by Yith Wishlist Plugin 1370 if ( ( 'undefined' !== typeof yith_wcwl_l10n ) && yith_wcwl_l10n.enable_ajax_loading ) { 1371 if ( $( '.fancybox-opened .wishlist-fragment' ).length ) { 1372 var options = {}, 1373 $product = $( '.fancybox-opened .wishlist-fragment' ), 1374 id = $product.attr( 'class' ).split( ' ' ).filter( ( val ) => { 1375 return val.length && val !== 'exists'; 1376 } ).join( yith_wcwl_l10n.fragments_index_glue ); 1377 options[id] = $product.data( 'fragment-options' ); 1378 1379 if ( !options ) { 1380 return; 1381 } 1382 1383 var ajaxData = { 1384 action: yith_wcwl_l10n.actions.load_fragments, 1385 context: 'frontend', 1386 fragments: options 1387 }; 1388 1389 if ( typeof yith_wcwl_l10n.nonce != 'undefined' ) { 1390 ajaxData.nonce = yith_wcwl_l10n.nonce.load_fragments_nonce; 1391 } 1392 1393 $.ajax( { 1394 ajaxData, 1395 method: 'post', 1396 success: function( data ) { 1397 if ( typeof data.fragments !== 'undefined' ) { 1398 $.each( data.fragments, function( i, v ) { 1399 var itemSelector = '.' + i.split( yith_wcwl_l10n.fragments_index_glue ).filter( ( val ) => { return val.length && val !== 'exists' && val !== 'with-count'; } ).join( '.' ), 1400 toReplace = $( itemSelector ); 1401 1402 // find replace tempalte 1403 var replaceWith = $( v ).filter( itemSelector ); 1404 1405 if ( !replaceWith.length ) { 1406 replaceWith = $( v ).find( itemSelector ); 1407 } 1408 1409 if ( toReplace.length && replaceWith.length ) { 1410 toReplace.replaceWith( replaceWith ); 1411 } 1412 } ); 1413 } 1414 }, 1415 url: yith_wcwl_l10n.ajax_url 1416 } ); 1417 } 1418 } 1419 // Compatibility with Woo Variation Gallery 1420 $( document ).trigger( 'woo_variation_gallery_init' ); 1421 }, 200 ); 1422 }, 1423 onUpdate: function() { 1424 theme.requestTimeout( function() { 1425 var $quickviewEl = $( '.quickview-wrap-' + pid ); 1426 if ( $quickviewEl.length == 0 && $( '.woocommerce-wishlist' ).length ) { // if select variation on wishlist page 1427 $quickviewEl = $( '.quickview-wrap' ); 1428 } 1429 if ( js_porto_vars.use_skeleton_screen.indexOf( 'quickview' ) == -1 || !js_porto_vars.quickview_skeleton ) { 1430 porto_woocommerce_init(); 1431 } 1432 var $slider = $quickviewEl.find( '.product-image-slider' ); 1433 if ( typeof $slider.data( 'owl.carousel' ) != 'undefined' && typeof $slider.data( 'owl.carousel' )._invalidated != 'undefined' ) 1434 $slider.data( 'owl.carousel' )._invalidated.width = true; 1435 $slider.trigger( 'refresh.owl.carousel' ); 1436 $( document.body ).trigger( 'porto_init_countdown', [$quickviewEl] ); 1437 }, 300 ); 1438 } 1439 }; 1440 if ( js_porto_vars.use_skeleton_screen.indexOf( 'quickview' ) != -1 && js_porto_vars.quickview_skeleton ) { 1441 delete args['href']; 1442 delete args['ajax']; 1443 args['type'] = 'inline'; 1444 $.fancybox.open( 1445 js_porto_vars.quickview_skeleton, 1446 args 1447 ); 1448 $.ajax( { 1449 url: theme.ajax_url, 1450 type: 'post', 1451 dataType: 'html', 1452 data: { 1453 action: 'porto_product_quickview', 1454 variation_flag: typeof wc_add_to_cart_variation_params !== 'undefined', 1455 pid: pid, 1456 nonce: js_porto_vars.porto_nonce 1457 }, 1458 success: function( res ) { 1459 var $res = $( res ); 1460 $res.imagesLoaded( function() { 1461 $( '.skeleton-body.product' ).replaceWith( $res ); 1462 theme.WooQtyField.initialize(); 1463 $( window ).trigger( 'resize' ); 1464 args['afterShow'].call( false ); 1465 } ); 1466 } 1467 } ); 1468 } else { 1469 if ( typeof $.fancybox == 'function' ) { 1470 $.fancybox( args ); 1471 } else if ( typeof $.fancybox == 'object' && $.fancybox.version && 0 === $.fancybox.version.indexOf( '3' ) ) { 1472 args['src'] = args['href']; 1473 args['ajax']['settings'] = { 1474 data: args['ajax']['data'] 1475 }; 1476 $.fancybox.open( args ); 1477 } 1478 } 1479 } 1480 1481 if ( $.fn.fancybox ) { 1482 init_quick_view_window(); 1483 } else if ( !$( '#porto-script-jquery-fancybox' ).length ) { 1484 var js1 = document.createElement( 'script' ); 1485 js1.id = 'porto-script-jquery-fancybox'; 1486 $( js1 ).appendTo( 'body' ).on( 'load', function() { 1487 init_quick_view_window(); 1488 } ).attr( 'src', js_porto_vars.ajax_loader_url.replace( '/images/[email protected]', '/js/libs/jquery.fancybox.min.js' ) ); 1489 } 1490 1491 return false; 1492 } ); 1493 1494 // ajax add to cart on quickview 1495 if ( typeof wc_add_to_cart_params != 'undefined' ) { 1496 $( document.body ).on( 'wc_cart_button_updated', function( e, $button ) { 1497 if ( $button.closest( '.sp-only-cart-form' ).length ) { 1498 $button.closest( '.sp-only-cart-form' ).find( '.added_to_cart' ).addClass( 'wc-action-btn view-cart-btn button wc-forward' ); 1499 } 1500 });
1501 $( document.body ).on( 'click', '.sp-only-cart-form .single_add_to_cart_button:not(.disabled, .wpcbn-btn), .single-product .single_add_to_cart_button:not(.disabled, .wpcbn-btn)', function( e ) { 1502 if ( $( this ).closest( '.single-product' ).hasClass( 'product-type-external' ) || $( this ).closest( '.single-product' ).hasClass( 'product-type-grouped' ) ) { 1503 return true; 1504 } 1505 if ( $( this ).hasClass( 'readmore' ) ) { 1506 return true; 1507 } 1508 e.preventDefault(); 1509 1510 var $button = $( this ), 1511 product_id = $button.val(), 1512 variation_id = $button.closest( 'form' ).find( 'input[name="variation_id"]' ).val(), 1513 quantity = $button.closest( 'form' ).find( 'input[name="quantity"]' ).val(); 1514 if ( $button.hasClass( 'loading' ) ) { 1515 return false; 1516 } 1517 $button.removeClass( 'added' ); 1518 $button.addClass( 'loading' ); 1519 $button.parent().addClass( 'porto-ajax-loading' ); 1520 if ( !$button.siblings( '.porto-loading-icon' ).length ) { 1521 let $last = $button.siblings( 'button:last-of-type' ); 1522 $( '<span class="porto-loading-icon"></span>' ).insertAfter( $last.length ? $last : $button ); 1523 } 1524 1525 var data = { 1526 action: 'porto_add_to_cart', 1527 product_id: variation_id ? variation_id : product_id, 1528 quantity: quantity 1529 }; 1530 if ( variation_id ) { 1531 var $variations = $button.closest( 'form' ).find( '.variations select' ); 1532 if ( $variations.length ) { 1533 $variations.each( function() { 1534 var name = $( this ).data( 'attribute_name' ), 1535 val = $( this ).val(); 1536 if ( name && val ) { 1537 data[name] = val; 1538 } 1539 } ); 1540 } 1541 } 1542 1543 // Trigger event. 1544 $( document.body ).trigger( 'adding_to_cart', [$button, data] ); 1545 1546 $.ajax( { 1547 type: 'POST', 1548 url: theme.ajax_url, 1549 data: data, 1550 dataType: 'json', 1551 success: function( response ) { 1552 $button.parent().removeClass( 'porto-ajax-loading' ); 1553 if ( !response ) { 1554 return; 1555 } 1556 if ( response.error && response.product_url ) { 1557 window.location = response.product_url; 1558 return; 1559 } 1560 // Redirect to cart option 1561 if ( wc_add_to_cart_params.cart_redirect_after_add === 'yes' ) { 1562 window.location = wc_add_to_cart_params.cart_url; 1563 return; 1564 } 1565 1566 // Trigger event. 1567 $( document.body ).trigger( 'added_to_cart', [response.fragments, response.cart_hash, $button] ); 1568 } 1569 } ); 1570 } ); 1571 } 1572 1573 return self; 1574 } 1575 } 1576 1577 } ); 1578 1579 } ).apply( this, [window.theme, jQuery] ); 1580 1581 1582 // Woocommerce Qty Field 1583 ( function( theme, $ ) { 1584 1585 theme = theme || {}; 1586 1587 $.extend( theme, { 1588 1589 WooQtyField: { 1590 1591 initialize: function() { 1592 1593 this.build() 1594 .events(); 1595 1596 return this; 1597 }, 1598 1599 qty_handler: function() { 1600 var $obj = $( this ); 1601 if ( $obj.closest( '.quantity' ).next( '.add_to_cart_button[data-quantity]' ).length ) { 1602 var count = $obj.val(); 1603 if ( count ) { 1604 $obj.closest( '.quantity' ).next( '.add_to_cart_button[data-quantity]' ).attr( 'data-quantity', count ); 1605 } 1606 } 1607 }, 1608 1609 build: function() { 1610 var self = this; 1611 1612 // Quantity buttons 1613 $( 'div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)' ).addClass( 'buttons_added' ).append( '<button type="button" value="+" class="plus">+</button>' ).prepend( '<button type="button" value="-" class="minus">-</button>' ); 1614 1615 // Target quantity inputs on product pages 1616 $( 'input.qty:not(.product-quantity input.qty)' ).each( function() { 1617 var min = parseFloat( $( this ).attr( 'min' ) ); 1618 1619 if ( min && min > 0 && parseFloat( $( this ).val() ) < min ) { 1620 $( this ).val( min ); 1621 } 1622 } ); 1623 1624 $( 'input.qty:not(.product-quantity input.qty)' ).off( 'change', self.qty_handler ).on( 'change', self.qty_handler ); 1625 1626 $( document ).off( 'click', '.quantity .plus, .quantity .minus' ).on( 'click', '.quantity .plus, .quantity .minus', function() { 1627 1628 // Get values 1629 var $qty = $( this ).closest( '.quantity' ).find( '.qty' ), 1630 currentVal = parseFloat( $qty.val() ), 1631 max = parseFloat( $qty.attr( 'max' ) ), 1632 min = parseFloat( $qty.attr( 'min' ) ), 1633 step = $qty.attr( 'step' ); 1634 1635 // Format values 1636 if ( !currentVal || currentVal === '' || currentVal === 'NaN' ) currentVal = 0; 1637 if ( max === '' || max === 'NaN' ) max = ''; 1638 if ( min === '' || min === 'NaN' ) min = 0; 1639 if ( step === 'any' || step === '' || step === undefined || parseFloat( step )
1639=== 'NaN' ) step = 1; 1640 1641 // Change the value 1642 if ( $( this ).is( '.plus' ) ) { 1643 1644 if ( max && ( max == currentVal || currentVal > max ) ) { 1645 $qty.val( max ); 1646 } else { 1647 $qty.val( currentVal + parseFloat( step ) ); 1648 } 1649 1650 } else { 1651 1652 if ( min && ( min == currentVal || currentVal < min ) ) { 1653 $qty.val( min ); 1654 } else if ( currentVal > 0 ) { 1655 $qty.val( currentVal - parseFloat( step ) ); 1656 } 1657 1658 } 1659 1660 // Trigger change event 1661 $qty.trigger( 'change' ); 1662 } ); 1663 1664 return self; 1665 }, 1666 1667 events: function() { 1668 var self = this; 1669 1670 $( document ).ajaxComplete( function( event, xhr, options ) { 1671 self.build(); 1672 } ); 1673 1674 return self; 1675 } 1676 } 1677 1678 } ); 1679 1680 } ).apply( this, [window.theme, jQuery] ); 1681 1682 1683 // Woocommerce Variation Form 1684 ( function( theme, $ ) { 1685 1686 theme = theme || {}; 1687 1688 var duration = 300; 1689 1690 $.extend( theme, { 1691 1692 WooVariationForm: { 1693 1694 initialize: function() { 1695 1696 this.init().events(); 1697 1698 return this; 1699 }, 1700 1701 init: function() { 1702 $( '.variations_form' ).each( function() { 1703 var $variation_form = $( this ), 1704 $reset_variations = $variation_form.find( '.reset_variations' ); 1705 1706 if ( $reset_variations.css( 'visibility' ) == 'hidden' ) 1707 $reset_variations.hide(); 1708 } ); 1709 return this; 1710 }, 1711 1712 events: function() { 1713 var self = this; 1714 1715 $( document ).on( 'check_variations', '.variations_form', function( event, exclude, focus ) { 1716 var $variation_form = $( this ), 1717 $reset_variations = $variation_form.find( '.reset_variations' ); 1718 1719 if ( $reset_variations.css( 'visibility' ) == 'hidden' ) 1720 $reset_variations.hide(); 1721 } ); 1722 1723 $( document ).on( 'reset_image', '.variations_form', function( event ) { 1724 var $product = $( this ).closest( '.product, .product-col' ), 1725 $product_img = $product.find( 'div.product-images .woocommerce-main-image' ); 1726 if ( $product.hasClass( 'porto-tb-item' ) ) { // in type builder 1727 $product_img = $product.find( '.porto-tb-featured-image img' ).eq( 0 ); 1728 } else if ( $product.hasClass( 'product-col' ) ) { // shop pages 1729 $product_img = $product.find( 'div.product-image .inner img:first-child' ); 1730 } 1731 var o_src = $product_img.attr( 'data-o_src' ), 1732 o_title = $product_img.attr( 'data-o_title' ), 1733 o_href = $product_img.attr( 'data-o_href' ), 1734 $thumb_img = $product.find( '.woocommerce-main-thumb' ), 1735 o_thumb_src = $thumb_img.attr( 'data-o_src' ); 1736 1737 var $image_slider = $product.find( '.product-image-slider' ), 1738 $thumbs_slider = $product.find( '.product-thumbs-slider' ), 1739 links; 1740 1741 if ( $image_slider.length ) { 1742 $image_slider.trigger( 'to.owl.carousel', [0, duration, true] ); 1743 links = $image_slider.data( 'links' ); 1744 } 1745 if ( $thumbs_slider.length ) { 1746 $thumbs_slider.trigger( 'to.owl.carousel', [0, duration, true] ); 1747 $thumbs_slider.find( '.owl-item:eq(0)' ).trigger( 'click' ); 1748 } 1749 1750 if ( o_src ) { 1751 $product_img 1752 .attr( 'src', o_src ) 1753 .attr( 'srcset', '' ) 1754 .attr( 'alt', o_title ) 1755 .attr( 'href', o_href ); 1756 1757 $product_img.each( function() { 1758 var elevateZoom = $( this ).data( 'elevateZoom' ); 1759 if ( typeof elevateZoom != 'undefined' ) { 1760 elevateZoom.swaptheimage( $( this ).attr( 'src' ), $( this ).attr( 'src' ) ); 1761 } 1762 } ); 1763 1764 if ( theme.product_image_popup && typeof links != 'undefined' ) { 1765 links[0].src = o_href; 1766 links[0].title = o_title; 1767 } 1768 } 1769 if ( o_thumb_src ) { 1770 $thumb_img.attr( 'src', o_thumb_src ); 1771 } 1772 } ); 1773 1774 $( document ).on( 'found_variation', '.variations_form', function( event, variation ) { 1775 1776 if ( typeof variation == 'undefined' ) { 1777 return; 1778 } 1779 1780 var $product = $( this ).closest( '.product, .product-col' ), 1781 $image_slider = $product.find( '.product-image-slider' ), 1782 $thumbs_slider = $product.find( '.product-thumbs-slider' ), 1783 links; 1784 1785 if ( $image_slider.length ) { 1786 $image_slider.trigger( 'to.owl.carousel', [0, duration, true] ); 1787 links = $image_slider.data( 'links' ); 1788 } 1789 if ( $thumbs_slider.length ) { 1790 $thumbs_slider.trigger( 'to.owl.carousel', [0, duration, true] ); 1791 $thumbs_slider.find( '.owl-item:eq(0)' ).trigger( 'click' ); 1792 } 1793 1794 var $shop_single_image = $product.find( 'div.product-images .woocommerce-main-image' ).length ? $product.find( 'div.product-images .woocommerce-main-image' ) : $( '.single-product div.product-images .woocommerce-main-image' ), 1795 productimage = $shop_single_image.attr( 'data-o_src' ), 1796 imagetitle = $shop_single_image.attr( 'data-o_title' ), 1797 imagehref = $shop_single_image.attr( 'data-o_href' ), 1798 $shop_thumb_image = $product.find( '.woocommerce-main-thumb' ), 1799 thumbimage = $shop_thumb_image.attr( 'data-o_src' ), 1800 variation_image = variation.image_src, 1801 variation_link = variation.image_link, 1802 variation_title = variation.image_title, 1803 variation_thumb = variation.image_thumb; 1804 1805 if ( $product.hasClass( 'porto-tb-item' ) ) { // in type builder 1806 $shop_single_image = $product.find( '.porto-tb-featured-image img' ).eq( 0 ); 1807 productimage = $shop_single_image.attr( 'data-o_src' ); 1808 variation_image = variation.image.thumb_src; 1809 } else if ( $product.hasClass( 'product-col' ) ) { // shop pages 1810 $shop_single_image = $product.find( 'div.product-image .inner img:first-child' ); 1811 productimage = $shop_single_image.attr( 'data-o_src' ); 1812 variation_image = variation.image.thumb_src; 1813 } 1814 1815 if ( !productimage ) { 1816 productimage = $shop_single_image.attr( 'data-oi' ) ? $shop_single_image.attr( 'data-oi' ) : ( ( !$shop_single_image.attr( 'src' ) ) ? '' : $shop_single_image.attr( 'src' ) ); 1817 $shop_single_image.attr( 'data-o_src', productimage ); 1818 } 1819 1820 if ( !imagehref ) { 1821 imagehref = ( !$shop_single_image.attr( 'href' ) ) ? '' : $shop_single_image.attr( 'href' ); 1822 $shop_single_image.attr( 'data-o_href', imagehref ); 1823 } 1824 1825 if ( !imagetitle ) { 1826 imagetitle = ( !$shop_single_image.attr( 'alt' ) ) ? '' : $shop_single_image.attr( 'alt' ); 1827 $shop_single_image.attr( 'data-o_title', imagetitle ); 1828 } 1829 1830 if ( !thumbimage ) { 1831 thumbimage = $shop_thumb_image.attr( 'data-oi' ) ? $shop_thumb_image.attr( 'data-oi' ) : ( ( !$shop_thumb_image.attr( 'src' ) ) ? '' : $shop_thumb_image.attr( 'src' ) ); 1832 $shop_thumb_image.attr( 'data-o_src', thumbimage ); 1833 } 1834 1835 if ( variation_image ) { 1836 $shop_single_image.attr( 'src', variation_image ); 1837 $shop_single_image.attr( 'srcset', '' ); 1838 $shop_single_image.attr( 'alt', variation_title ); 1839 $shop_single_image.attr( 'href', variation_link ); 1840 $shop_thumb_image.attr( 'src', variation_thumb ); 1841 if ( theme.product_image_popup && typeof links != 'undefined' ) { 1842 links[0].src = variation_link; 1843 links[0].title = variation_title; 1844 } 1845 } else { 1846 $shop_single_image.attr( 'src', productimage ); 1847 $shop_single_image.attr( 'srcset', '' ); 1848 $shop_single_image.attr( 'alt', imagetitle ); 1849 $shop_single_image.attr( 'href', imagehref ); 1850 $shop_thumb_image.attr( 'src', thumbimage ); 1851 if ( theme.product_image_popup && typeof links != 'undefined' ) { 1852 links[0].src = imagehref; 1853 links[0].title = imagetitle; 1854 } 1855 } 1856 $shop_single_image.each( function() { 1857 var elevateZoom = $( this ).data( 'elevateZoom' ); 1858 if ( typeof elevateZoom != 'undefined' ) { 1859 elevateZoom.swaptheimage( $( this ).attr( 'src' ), $( this ).attr( 'src' ) ); 1860 } 1861 } ); 1862 } ); 1863 1864 // fix scrolling to top issue on fancybox quickview whenever updating variation 1865 var porto_fb_update_trigger = null; 1866 $( document ).on( 'found_variation reset_image', '.variations_form', function( event, variation ) { 1867 if ( $( this ).closest( '.fancybox-inner' ).length && $.fancybox ) { 1868 $( window ).off( 'resize.fb', $.fancybox.update ); 1869 if ( porto_fb_update_trigger ) { 1870 theme.deleteTimeout( porto_fb_update_trigger ); 1871 } 1872 porto_fb_update_trigger = theme.requestTimeout( function() { 1873 $( window ).on( 'resize.fb', $.fancybox.update ); 1874 $.fancybox.reposition(); 1875 porto_fb_update_trigger = false; 1876 }, 600 ); 1877 } 1878 } ); 1879 1880 return self; 1881 } 1882 } 1883 1884 } ); 1885 1886 } ).apply( this, [window.theme, jQuery] ); 1887 1888 1889 // Woocommerce Events 1890 ( function( theme, $ ) { 1891 1892 theme = theme || {}; 1893 1894 $.extend( theme, { 1895 1896 WooEvents: { 1897 1898 initialize: function() { 1899 1900 this.events(); 1901 1902 return this; 1903 }, 1904 1905 events: function() { 1906 var self = this; 1907 1908 // wcml currency switcher 1909 $( document ).on( 'click', '.wcml-switcher li', function() { 1910 if ( $( this ).parent().attr( 'disabled' ) == 'disabled' ) 1911 return; 1912 var currency = $( this ).attr( 'rel' ); 1913 self.loadCurrency( currency ); 1914 } ); 1915 1916 // woocommerce currency switcher 1917 $( document ).on( 'click', '.woocs-switcher li', function() { 1918 if ( $( this ).parent().attr( 'disabled' ) == 'disabled' ) 1919 return; 1920 var currency = $( this ).attr( 'rel' ); 1921 self.loadWoocsCurrency( currency ); 1922 } ); 1923 1924 return self; 1925 }, 1926 1927 loadCurrency: function( currency ) { 1928 $( '.wcml-switcher' ).attr( 'disabled', 'disabled' ); 1929 $( '.wcml-switcher' ).append( '<li class="loading"></li>' ); 1930 var data = { action: 'wcml_switch_currency', currency: currency }; 1931 $.ajax( { 1932 type: 'post', 1933 url: theme.ajax_url, 1934 data: { 1935 action: 'wcml_switch_currency', 1936 currency: currency 1937 }, 1938 success: function( response ) { 1939 $( '.wcml-switcher' ).removeAttr( 'disabled' ); 1940 $( '.wcml-switcher' ).find( '.loading' ).remove(); 1941 window.location = window.location.href; 1942 } 1943 } ); 1944 }, 1945 1946 loadWoocsCurrency: function( currency ) { 1947 $( '.woocs-switcher' ).attr( 'disabled', 'disabled' ); 1948 $( '.woocs-switcher' ).append( '<li class="loading"></li>' ); 1949 var l = window.location.href; 1950 l = l.split( '?' ); 1951 l = l[0];
1952 var string_of_get = '?'; 1953 woocs_array_of_get.currency = currency; 1954 1955 if ( Object.keys( woocs_array_of_get ).length > 0 ) { 1956 jQuery.each( woocs_array_of_get, function( index, value ) { 1957 string_of_get = string_of_get + "&" + index + "=" + value; 1958 } ); 1959 } 1960 window.location = l + string_of_get; 1961 }, 1962 1963 removeParameterFromUrl: function( url, parameter ) { 1964 return url 1965 .replace( new RegExp( '[?&]' + parameter + '=[^&#]*(#.*)?$' ), '$1' ) 1966 .replace( new RegExp( '([?&])' + parameter + '=[^&]*&' ), '$1' ); 1967 } 1968 } 1969 1970 } ); 1971 1972 } ).apply( this, [window.theme, jQuery] ); 1973 1974 ( function( theme, $ ) { 1975 1976 $( document ).ready( function() { 1977 // Woocommerce Qty Field 1978 if ( typeof theme.WooQtyField !== 'undefined' ) { 1979 theme.WooQtyField.initialize(); 1980 } 1981 1982 // Woocommerce Quick View 1983 if ( typeof theme.WooQuickView !== 'undefined' ) { 1984 theme.WooQuickView.initialize(); 1985 } 1986 1987 // Woocommerce Events 1988 if ( typeof theme.WooEvents !== 'undefined' ) { 1989 theme.WooEvents.initialize(); 1990 } 1991 1992 // disable drop down 1993 if ( !( 'ontouchstart' in document ) ) { 1994 $( '.mini-cart' ).on( 'hide.bs.dropdown', function() { 1995 return false; 1996 } ); 1997 } else { 1998 $( '#mini-cart .cart-head' ).on( 'click', function( e ) { 1999 $( this ).parent().toggleClass( 'open' ); 2000 } ); 2001 $( 'html,body' ).on( 'click', function( e ) { 2002 if ( $( '#mini-cart' ).hasClass( 'open' ) && !$( e.target ).closest( '#mini-cart' ).length ) { 2003 $( '#mini-cart' ).removeClass( 'open' ); 2004 } 2005 } ); 2006 } 2007 2008 $( document ).on( 'tabactivate', '.woocommerce-tabs', function( e, ui ) { 2009 var label = $( ui ).attr( 'data-target' ); 2010 var panel = $( ui ).closest( '.woocommerce-tabs' ).find( '[aria-labelledby="' + label + '"' ); 2011 theme.refreshVCContent( panel ); 2012 } ); 2013 2014 // Perfect WooCommerce Brand Plugin 2015 $( document ).find( '.pwb-columns a[href="' + window.location.href + '"' ).each( function(){ 2016 $( this ).addClass( 'active' ); 2017 } ) 2018 } ); 2019 } ).apply( this, [window.theme, jQuery] ); 2020 2021 2022 ( function( theme, $, undefined ) { 2023 2024 $( document ).ready( function() { 2025 2026 /*===================================================================================*/ 2027 /* TOOLTIP FOR YITH WISHLIST, COMPARE, ADD TO CART, QUICK VIEW 2028 /*===================================================================================*/ 2029 if ( ! theme.isMobile() ) { 2030 $( document ).on( 'yith_wcwl_init_after_ajax', function() { 2031 $( '.product-col .add_to_wishlist:not([data-bs-original-title]), .product-col .yith-wcwl-wishlistaddedbrowse > a:not([data-bs-original-title]), .product-col .yith-wcwl-wishlistexistsbrowse > a:not([data-bs-original-title])' ).each( function() { 2032 let _this = $( this ); 2033 if ( ! _this.attr( 'title' ) ) { 2034 _this.attr( 'title', _this.text().trim() ); 2035 } 2036 _this.tooltip(); 2037 } ); 2038 } ); 2039 } 2040 // Woocommerce Variation Form 2041 theme.WooVariationForm.initialize(); 2042 2043 // Woocommerce Product Image Slider 2044 if ( typeof theme.initAsync == 'function' ) { 2045 theme.WooProductImageSlider.initialize(); 2046 porto_woocommerce_init(); 2047 } else { 2048 $.when( theme.asyncDeferred ).done( function() { 2049 theme.WooProductImageSlider.initialize(); 2050 porto_woocommerce_init(); 2051 } ); 2052 } 2053 2054 // Yith plugins compatibility 2055 $( document ).on( 'yith_wccl_product_gallery_loaded', function() { 2056 theme.WooProductImageSlider.initialize(); 2057 } ); 2058 2059 $( window ).on( 'vc_reload', function() { 2060 porto_woocommerce_init(); 2061 $( '.type-product' ).addClass( 'product' ); 2062 } ); 2063 2064 // Add wishlist popup 2065 /*if ( !$( '#yith-wcwl-popup-message' ).length ) { 2066 $( 'body' ).prepend( $( '<div>' ).attr( 'id', 'yith-wcwl-popup-message' ).html( '<div id="yith-wcwl-message"></div>' ).hide() ); 2067 }*/ 2068 2069 // shop horizontal filter 2070 $( document ).on( 'click', '.porto-product-filters-toggle a', function( e ) { 2071 e.preventDefault(); 2072 $( this ).closest( '.porto-product-filters-toggle' ).toggleClass( 'opened' ); 2073 var $products_wrapper = $( this ).closest( '#main' ).find( '.main-content' ).find( 'ul.products' ), offset, $main = $( this ).closest( '#main' ).find( '.main-content-wrap' ); 2074 $main.toggleClass( 'opened' ); 2075 if ( $main.hasClass( 'opened' ) ) { 2076 offset = -1; 2077 } else { 2078 offset = 1; 2079 } 2080 if ( $products_wrapper.hasClass( 'grid' ) ) { 2081 var cols_lg_index = 0, cols_md_index = 0, width_lg_index = 0, width_md_index = 0; 2082 for ( var i = 1; i <= 8; i++ ) { 2083 if ( !cols_lg_index && $products_wrapper.hasClass( 'ccols-xl-' + i ) ) { 2084 cols_lg_index = i; 2085 if ( i + offset >= 1 ) { 2086 $products_wrapper.removeClass( 'ccols-xl-' + i ); 2087 $products_wrapper.addClass( 'ccols-xl-' + ( i + offset ) ); 2088 } 2089 } 2090 if ( !cols_md_index && $products_wrapper.hasClass( 'ccols-lg-' + i ) ) { 2091 cols_md_index = i; 2092 if ( i + offset >= 1 ) { 2093 $products_wrapper.removeClass( 'ccols-lg-' + i ); 2094 if ( offset === -1 ) { 2095 $products_wrapper.addClass( 'ccols-md-' + i ); 2096 } 2097 $products_wrapper.addClass( 'ccols-lg-' + ( i + offset ) ); 2098 } 2099 } 2100 if ( !width_lg_index && $products_wrapper.hasClass( 'pwidth-lg-' + i ) ) { 2101 width_lg_index = i; 2102 if ( i + offset >= 1 ) { 2103 $products_wrapper.removeClass( 'pwidth-lg-' + i ); 2104 $products_wrapper.addClass( 'pwidth-lg-' + ( i + offset ) ); 2105 } 2106 } 2107 if ( !width_md_index && $products_wrapper.hasClass( 'pwidth-md-' + i ) ) { 2108 width_md_index = i; 2109 if ( i + offset >= 1 ) { 2110 $products_wrapper.removeClass( 'pwidth-md-' + i ); 2111 $products_wrapper.addClass( 'pwidth-md-' + ( i + offset ) ); 2112 } 2113 } 2114 } 2115 } 2116 theme.requestTimeout( function() { 2117 $( window ).trigger( 'scroll' ); 2118 // Update Carousel 2119 $( document ).find( '.owl-carousel' ).each( function( e ) { 2120 var $this = $( this ); 2121 if ( $this.data( 'owl.carousel' ) ) { 2122 $this.trigger( 'refresh.owl.carousel' ); 2123 } 2124 } ); 2125 // Update Swiper 2126 $( document ).find( '.swiper-container' ).each( function( e ) { 2127 var $this = $( this ), 2128 $instance = $this.data( 'swiper' ); 2129 if ( $instance ) {
2130 $instance.update(); 2131 } 2132 } ); 2133 }, 300 ); 2134 2135 if ( $main.hasClass( 'opened' ) ) { 2136 $.cookie( 'porto_horizontal_filter', 'opened' ); 2137 } else { 2138 $.cookie( 'porto_horizontal_filter', 'closed' ); 2139 } 2140 theme.refreshStickySidebar( true ); 2141 2142 return false; 2143 } ); 2144 if ( $.cookie && 'opened' == $.cookie( 'porto_horizontal_filter' ) && $( '#main .porto-products-filter-body' ).length && !theme.isTablet() ) { 2145 $( '.porto-product-filters-toggle a' ).trigger( 'click' ); 2146 $( '#main .porto-products-filter-body [data-plugin-sticky]:not(.manual)' ).addClass( 'manual' ); 2147 setTimeout( function() { 2148 var $obj = $( '#main .porto-products-filter-body [data-plugin-sticky].manual' ), 2149 pluginOptions = $obj.data( 'plugin-options' ); 2150 $obj.removeClass( 'manual' ).themeSticky( pluginOptions ); 2151 theme.requestTimeout( function() { 2152 $( window ).trigger( 'scroll' ); 2153 }, 100 ); 2154 }, 500 ); 2155 } 2156 2157 $( document ).on( 'click', '.porto-product-filters.style2 .widget-title', function( e ) { 2158 e.preventDefault(); 2159 if ( $( this ).next().is( ':hidden' ) ) { 2160 $( '.porto-product-filters.style2 .widget-title' ).next().hide(); 2161 $( '.porto-product-filters.style2 .widget' ).removeClass( 'opened' ); 2162 $( this ).next().show(); 2163 $( this ).next().find( 'input[type="text"]:first-child' ).focus(); 2164 } else { 2165 $( this ).next().hide(); 2166 } 2167 $( this ).parent().toggleClass( 'opened' ); 2168 return false; 2169 } ); 2170 $( 'body' ).on( 'click', function( e ) { 2171 if ( !$( e.target ).is( '.porto-product-filters' ) && !$( e.target ).is( '.porto-product-filters *' ) ) { 2172 $( '.porto-product-filters.style2 .widget-title' ).next().hide(); 2173 $( '.porto-product-filters.style2 .widget' ).removeClass( 'opened' ); 2174 } 2175 } ); 2176 2177 // Perform AJAX login on form submit 2178 $( 'body' ).on( 'click', '#login-form-popup form .woocommerce-Button', function( e ) { 2179 var $this = $( this ), 2180 $form = $this.closest( 'form' ), 2181 isLogin = $this.hasClass( 'login-btn' ); 2182 if ( !isLogin && !$this.hasClass( 'register-btn' ) ) { 2183 isLogin = $form.hasClass( 'login' ); 2184 } 2185 $form.find( '#email' ).val( $form.find( '#username' ).val() ); 2186 $form.find( 'p.status' ).show().text( js_porto_vars.login_popup_waiting_msg ? js_porto_vars.login_popup_waiting_msg : 'Please wait...' ).addClass( 'loading' ); 2187 $form.find( 'button[type=submit]' ).attr( 'disabled', 'disabled' ); 2188 $.ajax( { 2189 type: 'POST', 2190 dataType: 'json', 2191 url: theme.ajax_url, 2192 data: $form.serialize() + '&action=porto_account_login_popup_' + ( isLogin ? 'login' : 'register' ), 2193 success: function( data ) { 2194 $form.find( 'p.status' ).html( data.message.replace( '/<script.*?\/script>/s', '' ) ).removeClass( 'loading' ); 2195 $form.find( 'button[type=submit]' ).removeAttr( 'disabled' ); 2196 if ( data.loggedin === true ) { 2197 window.location.reload(); 2198 } 2199 } 2200 } ); 2201 e.preventDefault(); 2202 } ); 2203 2204 // shortcodes 2205 var $ajax_tab_cache = {}; 2206 $( document ).on( 'click', '.porto-products.show-category .product-categories a', function( e ) { 2207 e.preventDefault(); 2208 var $this = $( this ), $form = $this.closest( '.porto-products' ).find( '.pagination-form' ), id = $this.closest( '.porto-products' ).attr( 'id' ), group = []; 2209 $( this ).parent().siblings().removeClass( 'current' ); 2210 $( this ).parent().addClass( 'current' ); 2211 if ( typeof $this.data( 'sort_id' ) != 'undefined' ) {
2212 $form.find( 'input[name="orderby"]' ).val( $this.data( 'sort_id' ) ); 2213 group = $this.data( 'sort_id' ); 2214 $form.find( 'input[name="category"]' ).val( '' ); 2215 } 2216 if ( typeof $this.data( 'cat_id' ) != 'undefined' ) { 2217 if ( typeof $this.data( 'sort_id' ) == 'undefined' ) { 2218 $form.find( 'input[name="orderby"]' ).val( $form.find( 'input[name="original_orderby"]' ).val() ); 2219 group = $form.find( 'input[name="original_orderby"]' ).val(); 2220 } 2221 if ( typeof $form.data( 'original_cat_id' ) == 'undefined' ) { 2222 $form.data( 'original_cat_id', $form.find( 'input[name="category"]' ).val() ); 2223 group = $form.find( 'input[name="category"]' ).val(); 2224 } 2225 if ( $this.data( 'cat_id' ) ) { 2226 $form.find( 'input[name="category"]' ).val( $this.data( 'cat_id' ) ); 2227 group = $this.data( 'cat_id' ); 2228 } else { 2229 if ( $form.data( 'original_cat_id' ) ) { 2230 $form.find( 'input[name="category"]' ).val( $form.data( 'original_cat_id' ) ); 2231 group = $form.data( 'original_cat_id' ); 2232 } else {
2233 $form.find( 'input[name="category"]' ).val( '' ); 2234 group = ''; 2235 } 2236 } 2237 } 2238 var data = $form.serialize() + '&product-page=1&action=porto_woocommerce_shortcodes_products&nonce=' + js_porto_vars.porto_nonce; 2239 $this.closest( '.porto-products' ).find( 'ul.products' ).trigger( 'porto_update_products', [data, '', $this, id, group] ); 2240 } ); 2241 $( document ).on( 'click', '.porto-products .page-numbers a', function( e ) { 2242 var $this = $( this ), pagination_style, 2243 $shop_container = $this.closest( '.porto-products' ).find( 'ul.products' ), 2244 cur_page = $shop_container.data( 'cur_page' ), 2245 max_page = $shop_container.data( 'max_page' ), 2246 $form = $this.closest( '.porto-products' ).find( '.pagination-form' ); 2247 e.preventDefault(); 2248 if ( $this.closest( '.pagination' ).hasClass( 'load-more' ) ) { 2249 if ( !cur_page || !max_page || ++cur_page > max_page ) { 2250 return; 2251 } 2252 pagination_style = 'load_more'; 2253 $this.data( 'text', $this.text() ); 2254 $this.text( js_porto_vars.loader_text ); 2255 } else { 2256 var url = new RegExp( "product-page(=|/)([^(&|/)]*)", "i" ).exec( this.href ); 2257 cur_page = url && unescape( url[2] ) || ""; 2258 pagination_style = 'default'; 2259 } 2260 var page_var = cur_page ? '&product-page=' + escape( cur_page ) : '', data = $form.serialize() + page_var + '&action=porto_woocommerce_shortcodes_products&nonce=' + js_porto_vars.porto_nonce; 2261 $shop_container.trigger( 'porto_update_products', [data, pagination_style, $this] ); 2262 if ( 'default' == pagination_style ) { 2263 theme.scrolltoContainer( $shop_container ); 2264 } 2265 } ); 2266 $( document ).on( 'porto_update_products', 'ul.products', function( e, data, pagination_style, $obj, id, group ) { 2267 var $this = $( this ); 2268 // ajax tab 2269 if ( undefined == $ajax_tab_cache[id] || -1 == Object.keys( $ajax_tab_cache[id] ).indexOf( group ) ) { 2270 porto_ajax_load_products( $this, data, pagination_style, $ajax_tab_cache, id, group ); 2271 } else { 2272 var response = $ajax_tab_cache[id][group]; 2273 //animation 2274 $this.css( 'opacity', 0 ); 2275 $this.animate( 2276 { 2277 'opacity': 1, 2278 }, 2279 400, 2280 function() { 2281 $this.css( 'opacity', '' ); 2282 } 2283 ); 2284 2285 porto_ajax_load_products_success( $this, response, pagination_style ); 2286 } 2287 } ); 2288 2289 // initialize woocommerce actions after skeleton loading 2290 var skeletonLoadingTrigger; 2291 $( '.skeleton-loading' ).on( 'skeleton-loaded', function() { 2292 var $this = $( this ); 2293 if ( skeletonLoadingTrigger ) { 2294 theme.deleteTimeout( skeletonLoadingTrigger ); 2295 } 2296 porto_woocommerce_variations_init( $this ); 2297 2298 // yith wishlist pro compatibility 2299 if ( $this.hasClass( 'products' ) || $this.hasClass( 'product' ) ) { 2300 $( document ).trigger( 'yith_infs_added_elem' ); 2301 } 2302 2303 skeletonLoadingTrigger = theme.requestTimeout( function() { 2304 porto_woocommerce_init(); 2305 if ( $( 'body' ).hasClass( 'single-product' ) ) { 2306 theme.WooVariationForm.init(); 2307 var $image_slider = $( '.product-image-slider' ); 2308 if ( $image_slider.length && $image_slider.data( 'owl.carousel' ) ) { 2309 $image_slider.trigger( 'refresh.owl.carousel' ); 2310 } else { 2311 theme.WooProductImageSlider.initialize(); 2312 } 2313 $( '.wc-tabs-wrapper, .woocommerce-tabs, #rating' ).trigger( 'init' ); 2314 2315 // compatibility issue with Yith WooCommerce Booking form 2316 if ( $( document.body ).hasClass( 'yith-booking' ) ) { 2317 $( document ).trigger( 'yith-wcbk-init-booking-form' ); 2318 } 2319 } 2320 2321 // refresh cart content 2322 if ( $this.find( '.widget_shopping_cart_content' ).length ) { 2323 $( document.body ).trigger( 'wc_fragment_refresh' ); 2324 } 2325 }, 100 ); 2326 } ); 2327 } ); 2328 2329 var stickyShop = function() { 2330 2331 // sticky add to cart 2332 var $sticky_product_obj = $( '.single-product .sticky-product' ), 2333 is_elementor_editor = $( document.body ).hasClass( 'elementor-editor-active' ), 2334 $sticky_product_form; 2335 2336 var init_sticky_add_to_cart_fn = function( $sticky_product_obj, is_elementor_editor ) { 2337 if ( is_elementor_editor && elementorFrontend && elementorFrontend.hooks ) { 2338 elementorFrontend.hooks.addAction( 'frontend/element_ready/porto_cp_addcart_sticky.default', function( $obj ) { 2339 $sticky_product_obj = $( '.single-product .sticky-product' ); 2340 window.dispatchEvent( new Event( 'scroll' ) ); 2341 } ); 2342 } 2343 2344 $sticky_product_form = $( 'form.cart:visible' ).eq(0); 2345 2346 window.addEventListener( 'scroll', function() { 2347 var scrollTop = $( window ).scrollTop(), 2348 offset = theme.adminBarHeight() + ( theme.StickyHeader.sticky_height > 1 ? theme.StickyHeader.sticky_height : 0 ), 2349 prevScrollPos = $sticky_product_obj.data('prev-pos') ? $sticky_product_obj.data('prev-pos') : 0; 2350 2351 if ( ! $sticky_product_obj.hasClass( 'show-mobile' ) && $( window ).width() < 768 ) { 2352 $( 'body' ).css( 'padding-bottom', '' ); 2353 } else if ( $sticky_product_form.length && $sticky_product_form.offset().top + $sticky_product_form.height() / 2 <= scrollTop + offset ) { 2354 if ( $( '.page-wrapper' ).hasClass( 'sticky-scroll-up' ) && ! $( 'html' ).hasClass( 'porto-search-opened' ) && $sticky_product_obj.hasClass( 'pos-top' ) ) { 2355 if ( scrollTop >= prevScrollPos ) { 2356 $sticky_product_obj.addClass('scroll-down'); 2357 } else { 2358 $sticky_product_obj.removeClass('scroll-down'); 2359 } 2360 2361 var scrollUpOffset = - theme.StickyHeader.sticky_height; 2362 if ( 'undefined' == typeof ( theme.StickyHeader.sticky_height ) ) { 2363 $sticky_product_obj.data( 'prev-pos', 0 ); 2364 } else { 2365 // The transition of Sticky isn't working in this area 2366 var $transitionOffset = ( offset > 100 ) ? offset : 100; 2367 if ( $( 'form.cart' ).offset().top + $sticky_product_obj.outerHeight() + $transitionOffset < scrollTop + offset + scrollUpOffset ) { 2368 $sticky_product_obj.addClass( 'sticky-ready' ); 2369 } else { 2370 $sticky_product_obj.removeClass( 'sticky-ready' ); 2371 } 2372 $sticky_product_obj.data( 'prev-pos', scrollTop ); 2373 } 2374 } 2375 2376 var porto_progress_obj = $( '.porto-scroll-progress.fixed-top.fixed-under-header' ); 2377 if ( porto_progress_obj.length > 0 ) { 2378 offset += porto_progress_obj.height(); 2379 } 2380 2381 $sticky_product_obj.removeClass( 'hide' ); 2382 if ( !$sticky_product_obj.hasClass( 'pos-bottom' ) ) {
2383 $sticky_product_obj.css( 'top', offset ); 2384 } else if ( $sticky_product_obj.hasClass( 'show-mobile' ) || ( ! $sticky_product_obj.hasClass( 'show-mobile' ) && $( window ).width() >= 768 ) ) { 2385 $( 'body' ).css( 'padding-bottom', $sticky_product_obj.outerHeight() ); 2386 } 2387 } else { 2388 $sticky_product_obj.addClass( 'hide' ); 2389 if ( $sticky_product_obj.hasClass( 'pos-bottom' ) && ( $sticky_product_obj.hasClass( 'show-mobile' ) || ( ! $sticky_product_obj.hasClass( 'show-mobile' ) && $( window ).width() >= 768 ) ) ) { 2390 $( 'body' ).css( 'padding-bottom', '' ); 2391 } 2392 } 2393 }, { passive: true } ); 2394 $sticky_product_obj.find( '.add-to-cart .button' ).on( 'click', function( e ) { 2395 e.preventDefault(); 2396 if ( $sticky_product_obj.find( '.add-to-cart .qty' ).length ) { 2397 $( '.single-product form .quantity .qty' ).filter(function() { 2398 if ( $( this ).closest( '.product-col' ).length ) { 2399 return false; 2400 } 2401 return true; 2402 }).val( $sticky_product_obj.find( '.add-to-cart .qty' ).val() ); 2403 } 2404 $( '.single-product form .single_add_to_cart_button' ).filter(function() { 2405 if ( $( this ).closest( '.product-col' ).length ) { 2406 return false; 2407 } 2408 return true; 2409 }).eq(0).trigger( 'click' ); 2410 } ); 2411 $( '.single-product .entry-summary .quantity' ).clone().prependTo( '.single-product .sticky-product .add-to-cart' ); 2412 2413 var origin_img = $sticky_product_obj.find( '.sticky-image img' ).data( 'oi' ) ? $sticky_product_obj.find( '.sticky-image img' ).data( 'oi' ) : $sticky_product_obj.find( '.sticky-image img' ).attr( 'src' ), 2414 origin_price = $sticky_product_obj.find( '.price' ).html(), 2415 origin_stock = $sticky_product_obj.find( '.availability' ).html(), 2416 is_variation = false; 2417 $( document ).on( 'found_variation reset_data', '.variations_form', function( e, obj ) { 2418 if ( $( e.currentTarget ).closest( '.product-col' ).length == 0 ) { 2419 if ( obj ) { 2420 is_variation = true; 2421 $sticky_product_obj.find( '.sticky-image img' ).attr( 'src', obj.image_thumb ? obj.image_thumb : origin_img ); 2422 $sticky_product_obj.find( '.price' ).replaceWith( obj.price_html ); 2423 $sticky_product_obj.find( '.availability' ).html( obj.availability_html ? obj.availability_html : origin_stock ); 2424 } else if ( is_variation ) { 2425 is_variation = false; 2426 $sticky_product_obj.find( '.sticky-image img' ).attr( 'src', origin_img ); 2427 $sticky_product_obj.find( '.price' ).html( origin_price ); 2428 $sticky_product_obj.find( '.availability' ).html( origin_stock ); 2429 } 2430 } 2431 } ); 2432 }; 2433 2434 if ( $sticky_product_obj.length || is_elementor_editor ) { 2435 init_sticky_add_to_cart_fn( $sticky_product_obj, is_elementor_editor ); 2436 } else if ( $( 'div.product.skeleton-loading' ).length ) { 2437 $( 'div.product.skeleton-loading' ).on( 'skeleton-loaded', function() { 2438 $sticky_product_obj = $( '.single-product .sticky-product' ); 2439 init_sticky_add_to_cart_fn( $sticky_product_obj, is_elementor_editor ); 2440 } ); 2441 } else { 2442 $( document.body ).on( 'porto_elementor_editor_init', function() { 2443 var $sticky_product_obj = $( '.single-product .sticky-product' ), 2444 is_elementor_editor = $( document.body ).hasClass( 'elementor-editor-active' ); 2445 if ( $sticky_product_obj.length || is_elementor_editor ) { 2446 init_sticky_add_to_cart_fn( $sticky_product_obj, is_elementor_editor ); 2447 } 2448 } ); 2449 } 2450 2451 // sticky filter on mobile 2452 if ( 1 === $( '.shop-loop-before' ).length ) { 2453 var porto_progress_obj = $( '.porto-scroll-progress.fixed-top.fixed-under-header' ), 2454 porto_progress_height = 0; 2455 if ( porto_progress_obj.length > 0 ) { 2456 var flag = false; 2457 if ( porto_progress_obj.is( ':hidden' ) ) { 2458 porto_progress_obj.show(); 2459 flag = true; 2460 } 2461 porto_progress_height = porto_progress_obj.height(); 2462 if ( flag ) { 2463 porto_progress_obj.hide(); 2464 } 2465 } else { 2466 porto_progress_height = 0; 2467 } 2468 2469 var init_filter_sticky = function() { 2470 var $obj = $( '.shop-loop-before' ), 2471 prevScrollPos = $obj.data('prev-pos') ? $obj.data('prev-pos') : 0, 2472 scrollUpOffset = 0, 2473 $pageWrapper = $( '.page-wrapper' ); 2474 if ( 'none' == $obj.css( 'display' ) ) { 2475 // Found Nothing 2476 return; 2477 } 2478 if ( !$obj.prev( '.filter-placeholder' ).length ) { 2479 $( '<div class="filter-placeholder m-0"></div>' ).insertBefore( $obj ); 2480 } 2481 var $ph = $obj.prev( '.filter-placeholder' ), 2482 scrollTop = $( window ).scrollTop(), 2483 offset = theme.adminBarHeight() + theme.StickyHeader.sticky_height + porto_progress_height - 1, 2484 objHeight = $obj.outerHeight() + parseInt( $obj.css( 'margin-bottom' ) ); 2485 if ( $( '.page-wrapper' ).hasClass( 'sticky-scroll-up' ) ) { 2486 if ( scrollTop >= prevScrollPos ) { 2487 $obj.addClass('scroll-down'); 2488 } else { 2489 $obj.removeClass('scroll-down'); 2490 } 2491 // Header is scroll-up Sticky Type 2492 scrollUpOffset = - theme.StickyHeader.sticky_height; 2493 if ( 'undefined' == typeof ( theme.StickyHeader.sticky_height ) ) { 2494 $obj.data( 'prev-pos', 0 ); 2495 } else { 2496 // The transition of Sticky isn't working in this area 2497 var $transitionOffset = ( offset > 100 ) ? offset : 100; 2498 if ( $ph.offset().top + objHeight + $transitionOffset < scrollTop + offset + scrollUpOffset ) { 2499 $obj.addClass( 'sticky-ready' ); 2500 } else { 2501 $obj.removeClass( 'sticky-ready' ); 2502 } 2503 $obj.data( 'prev-pos', scrollTop ); 2504 } 2505 } 2506 // if ( $( 'html.filter-sidebar-opened' ).length ) { 2507 // $ph.css( 'height', '' ); 2508 // return; 2509 // } 2510 if ( ( $ph.offset().top + objHeight < scrollTop + offset + scrollUpOffset ) ) { 2511 if ( ! $pageWrapper.hasClass( 'sticky-scroll-up' ) || ( $pageWrapper.hasClass( 'sticky-scroll-up' ) && 0 !== prevScrollPos ) ) { 2512 $ph.css( 'height', objHeight );
2513 $obj.css( 'top', offset ); 2514 $obj.addClass( 'sticky' ); 2515 } 2516 } else { 2517 $ph.css( 'height', '' ); 2518 $obj.removeClass( 'sticky' ).css( 'top', '' ); 2519 } 2520 }; 2521 if ( window.innerWidth < 992 ) { 2522 window.removeEventListener( 'scroll', init_filter_sticky ); 2523 window.addEventListener( 'scroll', init_filter_sticky, { passive: true } ); 2524 init_filter_sticky(); 2525 } 2526 var request_timer = null, 2527 old_win_width = window.innerWidth; 2528 $( window ).on( 'resize', function() { 2529 if ( old_win_width != window.innerWidth ) { 2530 if ( request_timer ) { 2531 theme.deleteTimeout( request_timer ); 2532 request_timer = false; 2533 } 2534 if ( window.innerWidth < 992 ) { 2535 request_timer = theme.requestTimeout( function() { 2536 window.removeEventListener( 'scroll', init_filter_sticky ); 2537 window.addEventListener( 'scroll', init_filter_sticky, { passive: true } ); 2538 $( window ).trigger( 'scroll' ); 2539 }, 100 ); 2540 } else { 2541 window.removeEventListener( 'scroll', init_filter_sticky ); 2542 $( '.shop-loop-before' ).removeClass( 'sticky' ).css( 'top', '' ).prev( '.filter-placeholder' ).css( 'height', '' ); 2543 } 2544 2545 if ( $sticky_product_obj.length ) { 2546 $sticky_product_form = $( 'form.cart:visible' ).eq(0); 2547 } 2548 old_win_width = window.innerWidth; 2549 } 2550 } ); 2551 } 2552 } 2553 if ( theme.isReady ) { // Finish init 2554 stickyShop(); 2555 } 2556 $( document ).on( 'porto_theme_init', stickyShop ); 2557 2558 // cart page accordion 2559 $( '.cart-v2 .cart_totals .accordion-toggle.out' ).removeClass( 'out' ); 2560 $( document ).ajaxComplete( function( event, xhr, options ) { 2561 $( '.cart-v2 .cart_totals .accordion-toggle.out' ).each( function() { 2562 if ( $( $( this ).attr( 'href' ) ).length && $( $( this ).attr( 'href' ) ).is( ':hidden' ) ) { 2563 $( this ).removeClass( 'collapsed' ); 2564 $( $( this ).attr( 'href' ) ).addClass( 'show' ); 2565 } 2566 } ); 2567 } ); 2568 2569 // porto products filter element 2570 $( '.porto_products_filter_form .btn-submit' ).on( 'click', function( e ) { 2571 e.preventDefault(); 2572 var data = $( this ).closest( 'form' ).serializeArray(), 2573 submit_data = ''; 2574 for ( var i in data ) { 2575 var param = data[i]; 2576 if ( param.value ) { 2577 if ( submit_data ) { 2578 submit_data += '&'; 2579 } 2580 submit_data += param.name + '=' + param.value; 2581 if ( 'min_price' == param.name ) { 2582 var max_price = $( this ).closest( 'form' ).find( '.porto_dropdown_price_range option:selected' ).data( 'maxprice' ); 2583 if ( max_price ) { 2584 submit_data += '&max_price=' + max_price; 2585 } 2586 } 2587 } 2588 } 2589 var action_url = $( this ).closest( 'form' ).attr( 'action' ); 2590 location.href = action_url + ( -1 === action_url.indexOf( '?' ) ? '?' : '&' ) + submit_data; 2591 } ); 2592 2593 // yith wishlist 2594 if ( $( '.wishlist_table.responsive' ).length ) { 2595 $( window ).on( 'resize', function() { 2596 var media = window.matchMedia( '(max-width: 768px)' ), 2597 $wishlist_table = $( '.wishlist_table.responsive' ); 2598 if ( $wishlist_table.hasClass( 'traditional' ) ) { 2599 if ( media.matches ) { 2600 $wishlist_table.addClass( 'mobile' ); 2601 } else { 2602 $wishlist_table.removeClass( 'mobile' ); 2603 } 2604 } 2605 } ); 2606 } 2607 2608 // pre-order 2609 if ( js_porto_vars.pre_order ) { 2610 var porto_pre_order = { 2611 init: function() { 2612 this.$add_to_cart_btn = $( '.product-summary-wrap .single_add_to_cart_button:not(.wpcbn-btn)' ); 2613 this.add_to_cart_label = this.$add_to_cart_btn.html(); 2614 $( '.product-summary-wrap form.variations_form' ).on( 'show_variation', function( e, v, p ) { 2615 if ( v.porto_pre_order ) { 2616 porto_pre_order.$add_to_cart_btn.html( v.porto_pre_order_label ); 2617 if ( v.porto_pre_order_date ) { 2618 $( this ).find( '.woocommerce-variation-description' ).append( v.porto_pre_order_date ); 2619 } 2620 } else { 2621 porto_pre_order.$add_to_cart_btn.html( porto_pre_order.add_to_cart_label ); 2622 } 2623 } ).on( 'hide_variation', function() { 2624 porto_pre_order.$add_to_cart_btn.html( porto_pre_order.add_to_cart_label ); 2625 } ); 2626 } 2627 }; 2628 if ( $( 'div.product.skeleton-loading' ).length ) { 2629 $( 'div.product.skeleton-loading' ).on( 'skeleton-loaded', function() { 2630 porto_pre_order.init(); 2631 } ); 2632 } else { 2633 porto_pre_order.init(); 2634 } 2635 } 2636 2637 // refresh yith wishlist 2638 if ( $( '#header .my-wishlist .wishlist-count' ).length ) { 2639 $( document.body ).on( 'added_to_wishlist removed_from_wishlist added_to_cart', function( e ) { 2640 var $obj = $( '#header .my-wishlist .wishlist-count' ); 2641 if ( $obj.text() ) { 2642 $.ajax( { 2643 type: 'POST', 2644 dataType: 'json', 2645 url: theme.ajax_url, 2646 data: { 2647 action: 'porto_refresh_wishlist_count', 2648 nonce: js_porto_vars.porto_nonce, 2649 }, 2650 success: function( response ) { 2651 if ( response || 0 === response ) { 2652 $obj.addClass( 'count-updating' ).text( Number( response ) ); 2653 setTimeout( function() { 2654 $obj.removeClass( 'count-updating' ); 2655 }, 1000 ); 2656 } 2657 } 2658 } ); 2659 } 2660 } ); 2661 } 2662
2663 // fix contact form 7 role="alert" issue in cart page 2664 if ( $( document.body ).hasClass( 'woocommerce-cart' ) && $( '.wpcf7 .screen-reader-response' ).length ) { 2665 $( '.wpcf7 .screen-reader-response' ).attr( 'role', '' ); 2666 } 2667 2668 // fix dokan search vendor 2669 $( '#dokan-store-listing-filter-form-wrap .store-search-input' ).on( 'keydown', function( e ) { 2670 if ( e.which && event.which == 13 ) { 2671 $( this ).closest( 'form' ).find( '#apply-filter-btn' ).trigger( 'click' ); 2672 e.preventDefault(); 2673 } 2674 } ); 2675 2676 // add spinner to block 2677 if ( $.fn.block ) { 2678 var funcBlock = $.fn.block; 2679 $.fn.block = function( opts ) { 2680 if ( this.hasClass( 'yith-wcwl-add-to-wishlist' ) ) { 2681 this.children().addClass( 'pe-none opacity-6' ); 2682 return this; 2683 } 2684 if ( this.is( '.woocommerce-checkout' ) ) { 2685 this.append( '<div class="loader-container d-block"><div class="loader"><i class="porto-ajax-loader"></i></div></div>' ); 2686 } 2687 return funcBlock.call( this, opts ); 2688 } 2689 2690 var funcUnblock = $.fn.unblock; 2691 $.fn.unblock = function( opts ) { 2692 if ( this.hasClass( 'yith-wcwl-add-to-wishlist' ) ) { 2693 this.children().removeClass( 'pe-none opacity-6' ); 2694 return this; 2695 } 2696 funcUnblock.call( this, opts ); 2697 this.is( '.processing' ) || ( this.is( '.woocommerce-checkout' ) && this.children( '.loader-container' ).remove() ); 2698 return this; 2699 } 2700 } 2701 $( 'body' ).on( 'click', '.single_add_to_cart_button.scroll-to-sticky', function (e) { 2702 $( 'html, body' ).animate( 2703 { scrollTop: $( 'form.cart' ).offset().top - 200 } 2704 ); 2705 } ) 2706 } )( window.theme, jQuery ); 2707 2708 // Compare 2709 ( function( theme, $ ) { 2710 // remove margin-right 2711 $( 'body' ).on( 'click', '.yith_woocompare_colorbox #cboxClose, #cboxOverlay', function() { 2712 $( 'html' ).css( { 'overflow': '', 'margin-right': '' } ); 2713 } ); 2714 } )( window.theme, window.jQuery ); 2715 2716} )(); 2717 2718function porto_woocommerce_init( $wrap ) { 2719 'use strict'; 2720 2721 if ( !$wrap ) { 2722 $wrap = jQuery( document.body ); 2723 } 2724 // Woo Widget Toggle 2725 ( function( $ ) { 2726 2727 if ( $.fn.themeWooWidgetToggle ) { 2728 2729 $( function() { 2730 $wrap.find( '.widget_filter_by_brand, .widget_product_categories, .widget_price_filter, .widget_layered_nav, .widget_layered_nav_filters, .widget_rating_filter, .widget-woof, .porto_widget_price_filter, #wcfmmp-store .widget.sidebar-box, #wcfmmp-store-lists-sidebar .sidebar-box' ).find( '.widget-title' ).each( function() { 2731 var $this = $( this ), 2732 opts; 2733 2734 var pluginOptions = $this.data( 'plugin-options' ); 2735 if ( pluginOptions ) 2736 opts = pluginOptions; 2737 2738 $this.themeWooWidgetToggle( opts ); 2739 } ); 2740 } ); 2741 2742 } 2743 2744 // Woo Widget Accordion 2745 if ( $.fn.themeWooWidgetAccordion ) { 2746 2747 $( function() { 2748 $wrap.find( '.widget_filter_by_brand, .widget_product_categories, .widget_price_filter, .widget_layered_nav, .widget_layered_nav_filters, .widget_rating_filter, .widget-woof, #wcfmmp-store .widget.sidebar-box, #wcfmmp-store-lists-sidebar .sidebar-box' ).each( function() { 2749 var $this = $( this ), 2750 opts; 2751 2752 var pluginOptions = $this.data( 'plugin-options' ); 2753 if ( pluginOptions ) 2754 opts = pluginOptions; 2755 2756 $this.themeWooWidgetAccordion( opts ); 2757 } ); 2758 } ); 2759 2760 } 2761 2762 // Woo Products Slider 2763 if ( $.fn.themeWooProductsSlider ) { 2764 2765 $( function() { 2766 var $direct_carousels = $wrap.find( '.products-slider:not(.manual)' ).filter( function() { 2767 if ( $( this ).closest( '.porto-carousel:not(.owl-loaded)' ).length ) { 2768 return false; 2769 } 2770 return true; 2771 } ); 2772 var $parent_carousel = $wrap.find( '.porto-carousel:not(.owl-loaded)' ).filter( function() { 2773 if ( $( this ).find( '.products-slider:not(.manual)' ).length ) { 2774 return true; 2775 } 2776 return false; 2777 } ); 2778 if ( $parent_carousel.length ) { 2779 $parent_carousel.one( 'initialized.owl.carousel', function() { 2780 $( this ).find( '.products-slider:not(.manual)' ).each( function() { 2781 var $this = $( this ); 2782 $this.themeWooProductsSlider( $this.data( 'plugin-options' ) ); 2783 } ); 2784 } ); 2785 } 2786 2787 $direct_carousels.each( function() { 2788 var $this = $( this ), 2789 opts; 2790 2791 var pluginOptions = $this.data( 'plugin-options' ); 2792 if ( pluginOptions ) 2793 opts = pluginOptions; 2794 2795 setTimeout( function() { 2796 $this.themeWooProductsSlider( opts ); 2797 }, 0 ); 2798 } ); 2799 } ); 2800 } 2801 2802 /*===================================================================================*/ 2803 /* TOOLTIP FOR YITH WISHLIST, COMPARE, ADD TO CART, QUICK VIEW 2804 /*===================================================================================*/ 2805 if ( ! theme.isMobile() ) { 2806 $wrap.find( '.product-col .quickview, .product-col .add_to_cart_read_more, .product-col .add_to_cart_button, .product-col a.compare, .product-col .add_to_wishlist, .product-col .yith-wcwl-wishlistaddedbrowse > a, .product-col .yith-wcwl-wishlistexistsbrowse > a' ).each( function() { 2807 let _this = $( this ); 2808 // Exclude
2809 let $productCol = _this.closest( '.product-col' ); 2810 if ( _this.closest( '.porto-tb-woo-link' ).hasClass( 'no-tooltip' ) ) { 2811 return; 2812 } 2813 if ( _this.hasClass( 'add_to_cart_read_more' ) || _this.hasClass( 'add_to_cart_button' ) ) { 2814 if ( $productCol.hasClass( 'product-wq_onimage' ) || $productCol.hasClass( 'product-onimage' ) || $productCol.hasClass( 'product-outimage' ) || $productCol.hasClass( 'product-default' ) ) { 2815 return; 2816 } 2817 if ( _this.closest( 'ul.products' ).hasClass( 'list' ) ) { 2818 return; 2819 } 2820 } 2821 if ( _this.hasClass( 'quickview' ) ) { 2822 if ( $productCol.hasClass( 'product-wq_onimage' ) || $productCol.hasClass( 'product-onimage3' ) || $productCol.hasClass( 'product-onimage2' ) || $productCol.hasClass( 'product-onimage' ) || $productCol.hasClass( 'product-outimage_aq_onimage' ) ) { 2823 return; 2824 } 2825 } 2826 if ( ! _this.attr( 'title' ) ) { 2827 _this.attr( 'title', _this.text().trim() ); 2828 } 2829 _this.tooltip(); 2830 } ); 2831 } 2832 2833 } )( jQuery ); 2834} 2835 2836function porto_woocommerce_variations_init( $parent_obj ) { 2837 'use strict'; 2838 2839 theme.requestTimeout( function() { 2840 var form_variation = $parent_obj.find( 'form.variations_form:not(.vf_init)' ); 2841 if ( form_variation.length && jQuery.fn.wc_variation_form ) { 2842 form_variation.each( function() { 2843 var data_a = jQuery._data( this, 'events' ); 2844 if ( !data_a || !data_a['show_variation'] ) { 2845 jQuery( this ).wc_variation_form(); 2846 } 2847 } ); 2848 } 2849 }, 100 ); 2850} 2851function porto_ajax_load_products( $obj, data, pagination_style, $ajax_tab_cache, id, group ) { 2852 'use strict'; 2853 ( function( $ ) { 2854 if ( $obj.hasClass( 'loading' ) ) { 2855 return; 2856 } 2857 $obj.addClass( 'loading' ); 2858 if ( 'load_more' != pagination_style ) { 2859 $obj.addClass( 'yith-wcan-loading' ); 2860 if ( !$obj.children( '.porto-loading-icon' ).length ) { 2861 $obj.append( '<i class="porto-loading-icon"></i>' ); 2862 } 2863 } 2864 if ( $ajax_tab_cache[id] == undefined ) { 2865 $ajax_tab_cache[id] = {}; 2866 } 2867 $.ajax( { 2868 url: theme.ajax_url, 2869 data: data, 2870 type: 'post', 2871 success: function( response ) { 2872 //cache 2873 if ( $( response ).length ) { 2874 $ajax_tab_cache[id][group] = $( response ).html(); 2875 } else { 2876 $ajax_tab_cache[id][group] = ''; 2877 } 2878 porto_ajax_load_products_success( $obj, response, pagination_style ); 2879 }, 2880 complete: function() { 2881 $obj.removeClass( 'loading' ); 2882 } 2883 } ); 2884 } )( jQuery ); 2885} 2886 2887function porto_ajax_load_products_success( $obj, success, pagination_style ) { 2888 'use strict'; 2889 2890 ( function( $ ) { 2891 let _successProducts = $( success ).find( 'ul.products' ); 2892 if ( $obj.data( 'cur_page' ) && _successProducts.data( 'cur_page' ) ) { 2893 $obj.data( 'cur_page', _successProducts.data( 'cur_page' ) ); 2894 } 2895 if ( ! ( $obj.hasClass( 'grid-creative' ) && typeof $obj.attr( 'data-plugin-masonry' ) != 'undefined' ) ) { 2896 _successProducts.children( ':not(.grid-col-sizer)' ).addClass( 'fadeInUp animated' ); 2897 } 2898 if ( 'load_more' == pagination_style ) { 2899 $obj.append( _successProducts.html() ); 2900 } else { 2901 if ( $obj.hasClass( 'owl-carousel' ) ) { 2902 $obj.parent().css( 'min-height', $obj.parent().height() ); 2903 } 2904 if ( $obj.hasClass( 'grid-creative' ) && typeof $obj.attr( 'data-plugin-masonry' ) != 'undefined' ) { 2905 $obj.isotope( 'remove', $obj.children() ); 2906 $obj.find( '.grid-col-sizer' ).remove(); 2907 var newItems = _successProducts.children(); 2908 $obj.append( newItems ); 2909 $obj.isotope( 'appended', newItems ); 2910 $obj.imagesLoaded( function() { 2911 $obj.isotope( 'layout' ); 2912 } ); 2913 } else { 2914 if ( $( success ).length ) { 2915 $obj.html( _successProducts.html() ); 2916 } else { 2917 $obj.html( '' ); 2918 } 2919 } 2920 } 2921 2922 if ( $obj.hasClass( 'owl-carousel' ) && $.fn.themeWooProductsSlider ) { 2923 $obj.trigger( 'destroy.owl.carousel' ); 2924 theme.requestTimeout( function() { 2925 var pluginOptions = $obj.data( 'plugin-options' ), opts; 2926 if ( pluginOptions ) 2927 opts = pluginOptions; 2928 $obj.data( '__wooProductsSlider', '' ).themeWooProductsSlider( opts ); 2929 $obj.parent().css( 'min-height', '' ); 2930 }, 100 ); 2931 } 2932 if ( $obj.closest( '.porto-products' ).find( '.shop-loop-after' ).length ) { 2933 if ( $( success ).find( '.shop-loop-after' ).length ) { 2934 $obj.closest( '.porto-products' ).find( '.shop-loop-after' ).replaceWith( $( success ).find( '.shop-loop-after' ) ); 2935 } else { 2936 $obj.closest( '.porto-products' ).find( '.shop-loop-after' ).remove(); 2937 } 2938 } 2939 if ( typeof $obj.data( 'infinitescroll' ) != 'undefined' ) { 2940 var infinitescrollData = $obj.data( 'infinitescroll' ); 2941 infinitescrollData.options.state.currPage = 1; 2942 $obj.data( 'infinitescroll', infinitescrollData ); 2943 } 2944 $obj.removeClass( 'yith-wcan-loading' ); 2945 if ( 'load_more' == pagination_style && typeof $obj != 'undefined' && typeof $obj.data( 'text' ) != 'undefined' ) { 2946 $obj.text( $obj.data( 'text' ) ); 2947 } 2948 $( document ).trigger( "yith-wcan-ajax-filtered" ); 2949 } )( jQuery ); 2950}
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.