https://professionalsecurity.co.uk/wp-content/themes/soledad/inc/woocommerce/js/penci-woocommerce.js
1( 2 function ( $ ) { 3 'use strict' 4 var PENCI = PENCI || {} 5 6 /* Check mobile device 7 ---------------------------------------------------------------*/ 8 PENCI.isMobile = function () { 9 var isMobile = false 10 if ( /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test( navigator.userAgent ) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test( navigator.userAgent.
10substr( 0, 4 ) ) ) { 11 isMobile = true 12 } 13 return isMobile 14 } 15 16 /* Elementor Edit Mode 17 ---------------------------------------------------------------*/ 18 PENCI.elAction = function ( name, callback ) { 19 $( window ).on( 'elementor/frontend/init', function () { 20 if ( !elementorFrontend.isEditMode() ) { 21 return 22 } 23 24 elementorFrontend.hooks.addAction( name, callback ) 25 } ) 26 } 27 28 /* YITH Plugin loading icon 29 ---------------------------------------------------------------*/ 30 PENCI.yith = function () { 31 var $list_producs = $( 'ul.products' ) 32 33 $list_producs.on( 'click', '.add_to_wishlist.single_add_to_wishlist', function ( e ) { 34 var $singleBtn = $( this ) 35 $singleBtn.addClass( 'loading' ) 36 } ) 37 38 $list_producs.on( 'added_to_wishlist', function () { 39 $singleBtn.removeClass( 'loading' ) 40 } ) 41 42 $( document ).on( 'click', '.button.yith-wcqv-button', function ( e ) { 43 var $singleBtn = $( this ) 44 $singleBtn.addClass( 'loading' ) 45 } ) 46 47 $( document ).on( 'qv_loader_stop', function () { 48 var $singleBtn = $( '.button.yith-wcqv-button' ) 49 if ( $singleBtn.hasClass( 'loading' ) ) { 50 $singleBtn.removeClass( 'loading' ) 51 } 52 } ) 53 54 $( document ).on( 'click', '.product a.compare:not(.added)', function ( e ) { 55 var $singleBtn = $( this ) 56 $singleBtn.addClass( 'loading' ) 57 } ) 58 59 $( 'body' ).on( 'yith_woocompare_open_popup', function ( e, data ) { 60 data.button.removeClass( 'loading' ) 61 } ) 62 } 63 64 /* Product Image Slider 65 ---------------------------------------------------------------*/ 66 PENCI.productslider = function ( zoom = true, quickview = false ) { 67 68 var $slider = $( '.penci-product-gallery-slider.splide' ), 69 $thumbnail_slider = $( '.penci-thumbnail-slider.splide' ), 70 $wrapper = $( '.woocommerce-product-gallery' ), $thumb_list = '.penci-thumbnail-image-wrapper', 71 $gallery_list = '.penci-product-gallery-items', $rtl = false, $lazy = 'ondemand', $centerMode = true, 72 slides = 3, $vertical 73 74 $wrapper.removeClass( 'no-js' ) 75 76 if ( quickview ) { 77 $thumb_list = '.quick-view-wrapper .penci-thumbnail-image-wrapper' 78 $gallery_list = '.quick-view-wrapper .penci-product-gallery-items' 79 } 80 81 if ( $( 'body' ).hasClass( 'rtl' ) ) { 82 $rtl = true 83 } 84 85 if ( $wrapper.hasClass( 'thumbnail-left' ) || $wrapper.hasClass( 'thumbnail-right' ) ) { 86 $vertical = 'vertical' 87 } 88 89 if ( $wrapper.hasClass( 'quickview-screen' ) || $wrapper.hasClass( 'thumbnail-bottom' ) ) { 90 $vertical = 'horizontal' 91 } 92 93 if ( window.matchMedia( '(max-width: 767px)' ).matches ) { 94 $vertical = 'horizontal' 95 } 96 97 $thumbnail_slider.on( 'click', 'a', function ( e ) { 98 e.preventDefault() 99 } ) 100 101 if ( $slider.length > 0 && $thumbnail_slider.length > 0 ) { 102 103 var $thumb_arg = { 104 slidesPerView: 5, 105 direction: $vertical, 106 spaceBetween: 10, 107 loop: true, 108 slideActiveClass: 'active', 109 slideToClickedSlide: true, 110 breakpoints: { 111 320: { 112 direction: 'horizontal', 113 }, 114 768: { 115 direction: 'horizontal', 116 }, 117 1170: { 118 direction: $vertical, 119 }, 120 }, 121 navigation: { 122 nextEl: '.penci-custom-thumbnail-nav .penci-product-slider-next', 123 prevEl: '.penci-custom-thumbnail-nav .penci-product-slider-prev', 124 }, 125 } 126 127 var swiper_thumbnail_list = new Swiper( $thumb_list, $thumb_arg ) 128 129 var swiper_gallery_list = new Swiper( $gallery_list, { 130 slidesPerView: 1, 131 loop: true, 132 thumbs: { 133 swiper: swiper_thumbnail_list, 134 }, 135 } ) 136 137 if ( $('body').hasClass('rtl') ) { 138 swiper_gallery_list.changeLanguageDirection( 'ltr' ) 139 } 140 141 } else if ( $slider.length > 0 ) { 142 var $slider_options 143 if ( $slider.hasClass( 'fullwidth-container' ) || $slider.hasClass( 'fullwidth' ) ) { 144 145 $( $gallery_list ).addClass( 'penci-owl-carousel penci-owl-carousel-slider' ) 146 147 148 const swiper = new Swiper( $gallery_list, { 149 loop: true, 150 spaceBetween: 30, 151 centeredSlides: true, 152 slidesPerView: 3, 153 breakpoints: { 154 320: { 155 slidesPerView: 1, spaceBetween: 0, 156 }, 768: { 157 slidesPerView: 1, spaceBetween: 0, nav: false, 158 }, 1170: { 159 slidesPerView: 3, 160 }, 161 }, 162 } ) 163 } else { 164 const swiper = new Swiper( $gallery_list, { 165 loop: true, 166 spaceBetween: 0, 167 slidesPerView: 1, 168 } ) 169 } 170 171 if ( $('body').hasClass('rtl') ) { 172 swiper.changeLanguageDirection( 'ltr' ) 173 } 174 } 175 176 if ( zoom && $slider.length > 0 ) { 177 swiper_gallery_list.on( 'slideChange', function ( e ) { 178 179 var $slideritem = $( $gallery_list ).find( '.woocommerce-product-gallery__wrapper' ).eq( e.realIndex ).find( '.woocommerce-product-gallery__image' ),
180 image = $slideritem.find( 'img' ) 181 182 if ( image.data( 'large_image_width' ) > $slideritem.width() ) { 183 $slideritem.trigger( 'zoom.destroy' ) 184 if ( typeof $slideritem.zoom === 'function' ) { 185 $slideritem.zoom() 186 } 187 } 188 189 } ) 190 } 191 192 193 $( '.variations_form' ).each( function () { 194 var $this = $( this ) 195 $this.on( 'woocommerce_update_variation_values', function () { 196 setTimeout( function () { 197 if ( $thumbnail_slider.length > 0 ) { 198 var $imgid = $this.attr( 'current-image' ), 199 $slideitem = $slider.find( 'figure[data-attr_id=\'' + $imgid + '\']' ).data( 'slide_item' ) 200 201 if ( $slideitem !== undefined ) { 202 swiper_gallery_list.slideTo( $slideitem ) 203 } else { 204 swiper_gallery_list.slideTo( 0 ) 205 } 206 } 207 }, 100 ) 208 209 } ) 210 } ) 211 } 212 213 /* Product Quick View 214 ---------------------------------------------------------------*/ 215 PENCI.quickview = function () { 216 $( 'body' ).on( 'click', '.penci-quickview-button', function ( e ) { 217 e.preventDefault() 218 var $this = $( this ), productID = $this.data( 'pid' ), data = { 219 pid: productID, action: 'penci_quickview', nonce: penciwoo.nonce, 220 } 221 222 $this.addClass( 'loading' ) 223 224 var initPopup = function ( data ) { 225 var items = $( data ) 226 227 $.magnificPopup.open( { 228 items: { 229 src: items, type: 'inline', 230 }, fixedContentPos: true, removalDelay: 500, callbacks: { 231 beforeOpen: function () { 232 this.st.mainClass = 'quick-view-wrapper woocommerce' 233 }, open: function () { 234 var $form = $( '.variations_form' ) 235 $form.each( function () { 236 $( this ).wc_variation_form().find( '.variations select:eq(0)' ).change() 237 } ) 238 PENCI.productslider( false, true ) 239 $form.trigger( 'wc_variation_form' ) 240 }, 241 }, 242 } ) 243 } 244 245 $.ajax( { 246 url: penciwoo.ajaxUrl, data: data, method: 'get', success: function ( data ) { 247 initPopup( data ) 248 }, complete: function () { 249 $this.removeClass( 'loading' ) 250 PENCI.swatches( '.quick-view-wrapper .variations_form' ) 251 PENCI.select2button() 252 PENCI.loadingicon() 253 }, 254 } ) 255 } ) 256 257 $(document).ready(function() { 258 $(document.body).on('added_to_cart', function() { 259 if (typeof $.magnificPopup !== 'undefined') { 260 $.magnificPopup.close(); 261 } 262 }); 263 }); 264 } 265 266 /* Product Wish List 267 ---------------------------------------------------------------*/ 268 PENCI.wishlist = function () { 269 $( document ).on( 'click', '.penci-addtowishlist:not(.added)', function ( e ) { 270 e.preventDefault() 271 var $this = $( this ), productID = $this.data( 'pid' ), data = { 272 pid: productID, action: 'penci_add_to_wishlist', nonce: penciwoo.nonce, 273 } 274 $.ajax( { 275 url: penciwoo.ajaxUrl, data: data, method: 'get', beforeSend: function () { 276 $this.addClass( 'loading' ) 277 }, success: function ( response ) { 278 $this.addClass( 'added' ).attr( 'href', response.data.url ).html( penciwoo.browsewishlist ).attr( 'title', penciwoo.browsewishlist ).attr( 'data-tippy-content', penciwoo.browsewishlist ) 279 $( '.top-search-classes.wishlist-icon .wishlist-contents > span' ).html( response.data.total ) 280 $( '.penci-mobile-bottom-nav li.wishlist span.current-item' ).html( response.data.total ) 281 PENCI.tippyContent() 282 PENCI.notify( '<a href="' + response.data.item_link + '"><img class="product_image" src="' + response.data.img + '" alt=""/></a><div><a class="toast-title" href="' + response.data.item_link + '">' + response.data.title + '</a><p>' + penciwoo.addwishlist + '.</p></div>', '<div class="woocommerce notify_bottom"><a class="button wishlist_url" href="' + response.data.url + '">' + penciwoo.browsewishlist + '</a></div>', 'added_to_cart' ) 283 }, complete: function () { 284 $this.removeClass( 'loading' ) 285 }, 286 } ) 287 } ) 288 289 $( document ).on( 'click', '.penci-removewishlist', function ( e ) { 290 e.preventDefault() 291 var $this = $( this ), productID = $this.data( 'pid' ), data = { 292 pid: productID, action: 'penci_remove_wishlist_item', nonce: penciwoo.nonce, 293 } 294 $.ajax( { 295 url: penciwoo.ajaxUrl, data: data, method: 'get', beforeSend: function () { 296 $this.addClass( 'loading' ) 297 }, success: function ( response ) {
298 $( '.top-search-classes.wishlist-icon .wishlist-contents > span' ).html( response.data.total ) 299 $( '.penci-mobile-bottom-nav li.wishlist span.current-item' ).html( response.data.total ) 300 var $container = $( '.penci-custom-products' ) 301 if ( 0 === response.data.total ) { 302 $container.append( '<div class="penci-wishlist-products-empty-text"><h3 class="penci-wishlist-empty-title">' + penciwoo.wishlist_empty_heading + '</h3>' + penciwoo.wishlist_empty_text + '<p class="return-to-shop"><a class="button" href="' + penciwoo.shoppage + '">' + penciwoo.returnshop + '</a></p></div>' ) 303 } 304 PENCI.notify( '<a href="' + response.data.item_link + '"><img class="product_image" src="' + response.data.img + '" alt=""/></a><div><a class="toast-title" href="' + response.data.item_link + '">' + response.data.title + '</a><p>' + penciwoo.removewishlist + '.</p></div>', ' ', 'added_to_cart' ) 305 306 }, complete: function () { 307 $this.removeClass( 'loading' ) 308 $this.closest( 'li.product' ).remove() 309 }, 310 } ) 311 } ) 312 } 313 314 /* Product Compare 315 ---------------------------------------------------------------*/ 316 PENCI.compare = function () { 317 $( 'body' ).on( 'click', '.penci-compare:not(.added)', function ( e ) { 318 e.preventDefault() 319 var $this = $( this ), productID = $this.data( 'pid' ), method = $this.data( 'method' ), data = { 320 pid: productID, method: method, action: 'penci_add_to_compare', nonce: penciwoo.nonce, 321 } 322 $.ajax( { 323 url: penciwoo.ajaxUrl, data: data, method: 'get', beforeSend: function () { 324 $this.addClass( 'loading' ) 325 }, success: function ( response ) { 326 var comparetext = penciwoo.addtocompare, 327 compare_footer = '<div class="woocommerce notify_bottom"><a class="button compare_url" href="' + response.data.url + '">' + penciwoo.browsecompare + '</a></div>' 328 if ( 'add' === method ) { 329 $this.addClass( 'added' ).attr( 'href', response.data.url ).attr( 'title', penciwoo.browsecompare ).html( penciwoo.browsecompare ).attr( 'data-tippy-content', penciwoo.browsecompare ) 330 PENCI.tippyContent() 331 } else { 332 var currentId = $this.closest( '.penci-products-compare-table' ) 333 currentId.find( '[data-productid="' + productID + '"]' ).remove() 334 comparetext = penciwoo.removecompare 335 compare_footer = '' 336 } 337 $( '.top-search-classes.compare-icon .compare-contents > span' ).html( response.data.total ) 338 $( '.penci-mobile-bottom-nav li.compare span.current-item' ).html( response.data.total ) 339 var $container = $( '.penci-products-compare-table.woocommerce' ) 340 if ( 0 === response.data.total ) { 341 $container.empty().append( '<div class="penci-empty-compare penci-empty-page penci-empty-page-text"><h3 class="penci-compare-empty-title">' + penciwoo.compare_empty_heading + '</h3>' + penciwoo.compare_empty_text + '</p><p class="return-to-shop"><a class="button" href="' + penciwoo.shoppage + '">' + penciwoo.returnshop + '</a></div>' ) 342 } 343 PENCI.notify( '<a href="' + response.data.item_link + '"><img class="product_image" src="' + response.data.img + '" alt=""/></a><div><a class="toast-title" href="' + response.data.item_link + '">' + response.data.title + '</a><p>' + comparetext + '.</p></div>', compare_footer, 'added_to_cart' ) 344 }, complete: function () { 345 $this.removeClass( 'loading' ) 346 }, 347 } ) 348 } ) 349 } 350 351 /* Product Swatches 352 ---------------------------------------------------------------*/ 353 PENCI.swatches = function ( selector ) { 354 $( selector ).each( function () { 355 var $form = $( this ) 356 357 $form.addClass( 'swatches-support' ).on( 'click', '.swatch', function ( e ) { 358 e.preventDefault() 359 360 var $el = $( this ), $select = $el.closest( '.value' ).find( 'select' ), 361 value = $el.attr( 'data-value' ) 362 363 if ( $el.hasClass( 'disabled' ) ) { 364 return 365 } 366 367 // For old WC. 368 $select.trigger( 'focusin' ) 369 370 // Check if this combination is available. 371 if ( !$select.find( 'option[value="' + value + '"]' ).length ) { 372 $el.siblings( '.swatch' ).removeClass( 'selected' ) 373 $select.val( '' ).change() 374 $form.trigger( 'penci_no_matching_variations', [$el] ) 375 return 376 } 377 378 if ( $el.hasClass( 'selected' ) ) { 379 $select.val( '' ) 380 $el.removeClass( 'selected' ) 381 } else { 382 $el.addClass( 'selected' ).siblings( '.selected' ).removeClass( 'selected' ) 383 $select.val( value ) 384 } 385 $select.change() 386 } ).on( 'woocommerce_variation_select_change', function () { 387 $form.addClass( 'has-selected-swatch' ) 388 } ).on( 'click', '.reset_variations', function () { 389 $form.find( '.swatch.selected' ).removeClass( 'selected' ) 390 $form.find( '.swatch.disabled' ).removeClass( 'disabled' ) 391 $form.removeClass( 'has-selected-swatch' ) 392 } ).on( 'woocommerce_update_variation_values', function () { 393 setTimeout( function () { 394 $form.find( 'tbody tr' ).each( function () { 395 var $variationRow = $( this ), $options = $variationRow.find( 'select' ).find( 'option' ), 396 $selected = $options.filter( ':selected' ), values = [] 397 398 $options.each( function ( index, option ) { 399 if ( option.value !== '' ) { 400 values.push( option.value ) 401 } 402 } ) 403 404 $variationRow.find( '.swatch' ).each( function () { 405 var $swatch = $( this ), value = $swatch.attr( 'data-value' ) 406 407 if ( values.indexOf( value ) > - 1 ) { 408 $swatch.removeClass( 'disabled' ) 409 } else { 410 $swatch.addClass( 'disabled' ) 411 412 if ( $selected.length && value === $selected.val() ) { 413 $swatch.removeClass( 'selected' ) 414 } 415 } 416 } ) 417 } ) 418 }, 100 ) 419 } ).on( 'penci_no_matching_variations', function () { 420 window.alert( wc_add_to_cart_variation_params.i18n_no_matching_variations_text ) 421 } ) 422 } ) 423 } 424 425 /* Product Quantity 426 ---------------------------------------------------------------*/ 427 PENCI.quantity = function () { 428 if ( !String.prototype.getDecimals ) { 429 String.prototype.getDecimals = function () { 430 var num = this, match = ( 431 '' + num 432 ).match( /(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/ ) 433 434 if ( !match ) { 435 return 0 436 } 437 438 return Math.max( 0, ( 439 match[1] ? match[1].length : 0 440 ) - ( 441 match[2] ? + match[2] : 0 442 ) ) 443 } 444 } 445 446 $( 'body' ).on( 'click', '.plus, .minus', function () { 447 var $this = $( this ), $qty = $this.closest( '.quantity' ).find( '.qty' ), 448 currentVal = parseFloat( $qty.val() ), max = parseFloat( $qty.attr( 'max' ) ), 449 min = parseFloat( $qty.attr( 'min' ) ), step = $qty.attr( 'step' ) 450 451 if ( !currentVal || currentVal === '' || currentVal === 'NaN' ) { 452 currentVal = 0 453 } 454 if ( max === '' || max === 'NaN' ) { 455 max = '' 456 } 457 if ( min === '' || min === 'NaN' ) { 458 min = 0 459 } 460 if ( step === 'any' || step === '' || step === undefined || parseFloat( step )
460== 'NaN' ) { 461 step = '1' 462 } 463 464 if ( $this.is( '.plus' ) ) { 465 if ( max && ( 466 currentVal >= max 467 ) ) { 468 $qty.val( max ) 469 } else { 470 $qty.val( ( 471 currentVal + parseFloat( step ) 472 ).toFixed( step.getDecimals() ) ) 473 } 474 } else { 475 if ( min && ( 476 currentVal <= min 477 ) ) { 478 $qty.val( min ) 479 } else if ( currentVal > 0 ) { 480 $qty.val( ( 481 currentVal - parseFloat( step ) 482 ).toFixed( step.getDecimals() ) ) 483 } 484 } 485 486 $qty.trigger( 'change' ) 487 } ) 488 } 489 490 /* Product Loop 491 ---------------------------------------------------------------*/ 492 PENCI.productLoop = function () { 493 $( 'body' ).on( 'click', '.penci-swatch-item', function () { 494 var current_swatches = $( this ), $this = $( this ).closest( '.penci-soledad-product' ), 495 $imgMain = $this.find( '.penci-main-loop-image > img' ), 496 $hoverImg = $this.find( '.hover-img > a img' ) 497 $this.addClass( 'loading-image' ).removeClass( 'active-custom-swatches' ) 498 $this.find( '.penci-swatch-item' ).removeClass( 'active-swatches' ) 499 var $variable_img_src = $( this ).data( 'image-src' ), 500 $variable_img_srcset = $( this ).data( 'image-srcset' ), 501 $variable_img_sizes = $( this ).data( 'image-sizes' ) 502 if ( $variable_img_src ) { 503 $imgMain.attr( 'src', $variable_img_src ).attr( 'srcset', $variable_img_srcset ).attr( 'sizes', $variable_img_sizes ).one( 'load', function () { 504 $this.removeClass( 'loading-image' ).addClass( 'active-custom-swatches' ) 505 current_swatches.addClass( 'active-swatches' ) 506 } ) 507 508 if ( $hoverImg.length > 0 ) { 509 $hoverImg.attr( 'src', $variable_img_src ).attr( 'srcset', $variable_img_srcset ).attr( 'sizes', $variable_img_sizes ) 510 } 511 } 512 } ) 513 } 514 515 /* Product Tippy 516 ---------------------------------------------------------------*/ 517 PENCI.tippyContent = function () { 518 if ( PENCI.isMobile() || window.matchMedia( '(max-width: 768px)' ).matches ) { 519 return false 520 } 521 522 $( '.penci-product-loop-button .button' ).each( function () { 523 $( this ).attr( 'data-tippy-content', $( this ).text() ) 524 } ) 525 526 tippy( 'ul.products.icon-align-vertical.icon-position-top-left .penci-product-loop-button .button', { 527 placement: 'right', 528 } ) 529 530 tippy( 'ul.products.icon-align-vertical.icon-position-bottom-left .penci-product-loop-button .button', { 531 placement: 'right', 532 } ) 533 534 tippy( 'ul.products.icon-align-vertical.icon-position-top-right .penci-product-loop-button .button', { 535 placement: 'left', 536 } ) 537 538 tippy( 'ul.products.icon-align-vertical.icon-position-bottom-right .penci-product-loop-button .button', { 539 placement: 'left', 540 } ) 541 542 tippy( 'ul.products.icon-align-horizontal .penci-product-loop-button .button', { 543 placement: 'top', 544 } ) 545 546 tippy( '.penci-swatch-item', { placement: 'top' } ) 547 tippy( '.soledad-product-filter .layer-term-name.penci-tooltip', { placement: 'top' } ) 548 } 549 550 /* Product Ajax Filter 551 ---------------------------------------------------------------*/ 552 553 PENCI.updateURL = function ( uri, key, value ) { 554 var re = new RegExp( '([?&])' + key + '=.*?(&|$)', 'i' ) 555 var separator = uri.indexOf( '?' ) !== - 1 ? '&' : '?' 556 if ( uri.match( re ) ) { 557 return uri.replace( re, '$1' + key + '=' + value + '$2' ) 558 } else { 559 return uri + separator + key + '=' + value 560 } 561 } 562 563 PENCI.ajaxfilter = function () { 564 565 $( document ).on( 'change', 'select.orderby', function ( event ) { 566 var $form = $( this ).closest( 'form' ) 567 $form.find( '[name="_pjax"]' ).remove() 568 $.pjax( { 569 timeout: 5000, container: '#main', fragment: '#main', url: '?' + $form.serialize(), 570 } ) 571 } ) 572 573 $( document ).on( 'change', 'select.penci-widget-layered-nav-dropdown', function ( event ) { 574 var $form = $( this ).closest( 'form' ), $attr_name = $( this ).data( 'slug' ), 575 $updateURL = PENCI.updateURL( window.location.href, 'filter_' + $attr_name, $( this ).val() ) 576 $form.find( '[name="_pjax"]' ).remove() 577 $form.find( '[name="filter_' + $attr_name + '"]' ).val( this.value ) 578 $.pjax( { 579 timeout: 5000, 580 container: '.penci-woo-page-container', 581 fragment: '.penci-woo-page-container', 582 url: $updateURL, 583 } ) 584 } ) 585 586 $( '.woocommerce-ordering' ).on( 'submit', function ( e ) { 587 e.preventDefault( e ) 588 } ) 589 590 $( document ).on( 'submit', '.widget_price_filter form', function ( event ) { 591 event.preventDefault( event ) 592 $.pjax( { 593 timeout: 5000, 594 container: '.penci-woo-page-container', 595 fragment: '.penci-woo-page-container', 596 url: '?' + $( this ).serialize(), 597 } ) 598 } ) 599 600 $( '.penci-widget-layered-nav-dropdown-form' ).on( 'submit', function ( e ) { 601 e.preventDefault( e ) 602 } ) 603 604 $.each( [ 605 'body:not(.elementor-page) a.layered-nav-link', 606 'body:not(.elementor-page) .penci-products-shop-view a', 607 'body:not(.elementor-page) .soledad-price-filter a', 608 'body:not(.elementor-page) .penci-products-per-page a', 609 'body:not(.elementor-page) .penci-widget-stock-status a', 610 'body:not(.elementor-page) .widget_rating_filter a', 611 'body:not(.elementor-page) .penci-active-filters a', 612 'body:not(.elementor-page) .woocommerce-pagination ul li a', 613 ], function ( index, value ) { 614 $( document ).pjax( value, { 615 timeout: 10000, 616 container: '.penci-woo-page-container', 617 fragment: '.penci-woo-page-container', 618 scrollTo: false, 619 } ) 620 } ) 621
622 $( document ).on( 'pjax:send', function ( xhr, options ) { 623 var mainClass = $( xhr.relatedTarget ), bodyClass = $( mainClass ).closest( 'body' ) 624 625 if ( ! $( 'body' ).hasClass('woocommerce') ) { 626 return; 627 } 628 629 $( 'body' ).addClass( 'pre-load-content' ) 630 if ( penciwoo.scrolltotopajax > 0 && !bodyClass.hasClass( 'elementor-page' ) ) { 631 var element = document.querySelector( '#header' ) 632 element.scrollIntoView( { behavior: 'smooth', block: 'end' } ) 633 } 634 } ) 635 636 $( document ).on( 'pjax:complete', function () { 637 $( 'body' ).removeClass( 'pre-load-content' ) 638 PENCI.tippyContent() 639 PENCI.pagination() 640 PENCI.loadingicon() 641 PENCI.productQuery() 642 PENCI.productCarousel() 643 PENCI.fixproductIconsize() 644 PENCI.quickshop() 645 PENCI.misc() 646 PENCI.product_sticky_sidebar() 647 $( document.body ).trigger( 'wc_fragment_refresh' ) 648 $( document.body ).trigger( 'init_price_filter' ) 649 } ) 650 651 $( 'body' ).on( 'click', '.woocommerce-pagination.ajax-pagination li a', function ( e ) { 652 653 if ( $( 'body' ).hasClass( 'penci-wishlist-page' ) ) { 654 return 655 } 656 657 e.preventDefault() 658 var reged = new RegExp( /\?product-page=([0-9\-]+)\&?/ ), link = $( this ).attr( 'href' ), 659 $settings = $( this ).closest( '.woocommerce-pagination.ajax-pagination' ).data( 'settings' ), 660 $contentID = $( this ).closest( '.page-unique-part' ).data( 'part' ), 661 $contentParent = $( this ).closest( '.elementor-widget-container' ), 662 $currentpage = reged.test( link ) 663 664 665 if ( $currentpage ) { 666 $.ajax( { 667 url: penciwoo.ajaxUrl, data: { 668 'action': 'penci_ajax_load_products', 669 'settings': $settings, 670 'preloader': true, 671 'product-page': link.match( reged )[1], 672 'requestid': penciwoo.nonce, 673 }, method: 'get', beforeSend: function () { 674 $contentParent.addClass( 'pre-load-content' ) 675 }, success: function ( data ) { 676 var result = data, innerRes = $( result ).html() 677 $contentParent.removeClass( 'pre-load-content' ) 678 $contentParent.find( '.' + $contentID ).empty().html( innerRes ) 679 PENCI.tippyContent() 680 PENCI.loadingicon() 681 PENCI.fixproductIconsize() 682 PENCI.quickshop() 683 }, 684 } ) 685 } else { 686 $.ajax( { 687 url: link, method: 'get', beforeSend: function () { 688 $contentParent.addClass( 'pre-load-content' ) 689 }, success: function ( data ) { 690 var result = data, innerRes = $( result ).html() 691 $contentParent.removeClass( 'pre-load-content' ) 692 $contentParent.find( '.' + $contentID ).empty().html( innerRes ) 693 PENCI.tippyContent() 694 PENCI.loadingicon() 695 PENCI.fixproductIconsize() 696 PENCI.quickshop() 697 }, 698 } ) 699 } 700 } ) 701 } 702 703 /* Product Ajax ATC 704 ---------------------------------------------------------------*/ 705 PENCI.productATC = function () { 706 $.fn.PenciserializeArrayAll = function () { 707 var rCRLF = /\r?\n/g 708 return this.map( function () { 709 return this.elements ? jQuery.makeArray( this.elements ) : this 710 } ).map( function ( i, elem ) { 711 var val = jQuery( this ).val() 712 if ( val == null ) { 713 return val == null 714 } else if ( this.type === 'checkbox' && this.checked === false ) { 715 return { name: this.name, value: this.checked ? this.value : '' } 716 } else { 717 return jQuery.isArray( val ) ? jQuery.map( val, function ( val, i ) { 718 return { name: elem.name, value: val.replace( rCRLF, '\r\n' ) } 719 } ) : { name: elem.name, value: val.replace( rCRLF, '\r\n' ) } 720 } 721 } ).get() 722 } 723 $( document ).on( 'click', 'form.cart:not(.variations_form):not(.grouped_form) .single_add_to_cart_button:not(.disabled)', function ( e ) { 724 725 var $thisbutton = $( this ), $form = $thisbutton.closest( 'form.cart' ),
726 data = $form.find( 'input:not([name="product_id"]), select, button, textarea' ).PenciserializeArrayAll() || 0, 727 mainClass = $thisbutton.closest( '.product.type-product' ) 728 729 if ( mainClass.hasClass( 'product-type-external' ) || penciwoo.addtocart_jax ) { 730 return 731 } 732 733 $.each( data, function ( i, item ) { 734 if ( 'add-to-cart' === item.name ) { 735 item.name = 'product_id' 736 item.value = $form.find( 'input[name=variation_id]' ).val() || $thisbutton.val() 737 } 738 } ) 739 740 e.preventDefault() 741 742 $( document.body ).trigger( 'adding_to_cart', [$thisbutton, data] ) 743 744 $.ajax( { 745 type: 'POST', 746 url: woocommerce_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'add_to_cart' ), 747 data: data, 748 beforeSend: function () { 749 $thisbutton.removeClass( 'added' ).addClass( 'loading' ) 750 }, 751 complete: function () { 752 $thisbutton.addClass( 'added' ).removeClass( 'loading' ) 753 }, 754 success: function ( response ) { 755 756 if ( response.error && response.product_url ) { 757 window.location = response.product_url 758 return 759 } 760 761 $( document.body ).trigger( 'added_to_cart', [ 762 response.fragments, response.cart_hash, $thisbutton, 763 ] ) 764 }, 765 } ) 766 767 return false 768 769 } ) 770 } 771 772 /* Product Ajax Variable Add to Cart 773 ---------------------------------------------------------------*/ 774 PENCI.productVATC = function () { 775 // wc_add_to_cart_params is required to continue, ensure the object exists 776 if ( typeof wc_add_to_cart_params === 'undefined' || penciwoo.addtocart_jax ) { 777 return false 778 } 779 780 // Ajax add to cart 781 $( document ).on( 'click', '.variations_form .single_add_to_cart_button', function ( e ) { 782 783 e.preventDefault() 784 785 var $variation_form = $( this ).closest( '.variations_form' ),
786 var_id = $variation_form.find( 'input[name=variation_id]' ).val(), 787 product_id = $variation_form.find( 'input[name=product_id]' ).val(), 788 quantity = $variation_form.find( 'input[name=quantity]' ).val(), 789 variations = $variation_form.find( 'select[name^=attribute]' ) 790 791 $( '.ajaxerrors' ).remove() 792 var item = {}, check = true 793 794 795 /* Updated code to work with radio button - mantish - WC Variations Radio Buttons - 8manos */ 796 if ( !variations.length ) { 797 variations = $variation_form.find( '[name^=attribute]:checked' ) 798 } 799 800 /* Backup Code for getting input variable */ 801 if ( !variations.length ) { 802 variations = $variation_form.find( 'input[name^=attribute]' ) 803 } 804 805 variations.each( function () { 806 807 var $this = $( this ), attributeName = $this.attr( 'name' ), attributevalue = $this.val(), index, 808 attributeTaxName 809 810 $this.removeClass( 'error' ) 811 812 if ( attributevalue.length === 0 ) { 813 index = attributeName.lastIndexOf( '_' ) 814 attributeTaxName = attributeName.substring( index + 1 ) 815 816 $this.addClass( 'required error' ).before( '<div class="ajaxerrors"><p>Please select ' + attributeTaxName + '</p></div>' ) 817 818 check = false 819 } else { 820 item[attributeName] = attributevalue 821 } 822 823 } ) 824 825 if ( !check ) { 826 return false 827 } 828 829 var $thisbutton = $( this ) 830 831 if ( $thisbutton.is( '.variations_form .single_add_to_cart_button' ) ) { 832 833 $thisbutton.removeClass( 'added' ) 834 $thisbutton.addClass( 'loading' ) 835 836 var data = { 837 action: 'penci_add_to_cart_variable', 838 } 839 840 $variation_form.serializeArray().map( function ( attr ) { 841 if ( attr.name !== 'add-to-cart' ) { 842 if ( attr.name.endsWith( '[]' ) ) { 843 let name = attr.name.substring( 0, attr.name.length - 2 ) 844 if ( !( 845 name in data 846 ) ) { 847 data[name] = [] 848 } 849 data[name].push( attr.value ) 850 } else { 851 data[attr.name] = attr.value 852 } 853 } 854 } ) 855 856 // Trigger event 857 $( 'body' ).trigger( 'adding_to_cart', [$thisbutton, data] ) 858 859 // Ajax action 860 $.post( wc_add_to_cart_params.ajax_url, data, function ( response ) { 861 862 if ( !response ) { 863 return 864 } 865 866 if ( response.error && response.product_url ) { 867 window.location = response.product_url 868 return 869 } 870 871 // Redirect to cart option 872 if ( wc_add_to_cart_params.cart_redirect_after_add === 'yes' ) { 873 window.location = wc_add_to_cart_params.cart_url 874 return 875 } 876 877 // Trigger event so themes can refresh other areas. 878 $( document.body ).trigger( 'added_to_cart', [ 879 response.fragments, response.cart_hash, $thisbutton, 880 ] ) 881 882 } ) 883 884 return false 885 886 } else { 887 888 return true 889 } 890 891 } ) 892 } 893 894 /* Product Ajax Quick Shop 895 ---------------------------------------------------------------*/ 896 PENCI.quickshop = function () { 897 898 if ( penciwoo.quickshop == 0 ) { 899 return false 900 } 901 902 $( 'ul.products.penci-quickshop-support' ).on( 'click', '.button.product_type_variable', function ( e ) { 903 e.preventDefault() 904 var $this = $( this ), $product = $this.closest( 'li.product' ), 905 $content = $product.find( '.quick-shop-form' ), id = $content.data( 'pid' ), 906 loadingClass = 'loading', formSelect = 'li.post-' + id + ' .variations_form' 907 908 if ( $this.hasClass( loadingClass ) ) { 909 return 910 } 911 912 if ( $product.hasClass( 'quick-shop-loaded' ) ) { 913 $product.addClass( 'quick-shop-shown' ) 914 return 915 } 916 917 $this.addClass( loadingClass ) 918 $product.addClass( 'loading-quick-shop' ) 919 920 $.ajax( { 921 url: penciwoo.ajaxUrl, data: { 922 action: 'penci_quick_shop', id: id, 923 }, method: 'get', success: function ( data ) { 924 $content.append( data ) 925 $product.find( '.variations_form' ).wc_variation_form().find( '.variations select:eq(0)' ).change() 926 $product.find( '.variations_form' ).trigger( 'wc_variation_form' ) 927 PENCI.loadingicon() 928 PENCI.swatches( formSelect ) 929 }, complete: function () { 930 setTimeout( function () { 931 $this.removeClass( loadingClass ) 932 $product.removeClass( 'loading-quick-shop' ) 933 $product.addClass( 'quick-shop-shown quick-shop-loaded' ) 934 }, 100 ) 935 }, 936 } ) 937 938 } ).on( 'click', '.quick-shop-close', function ( e ) { 939 e.preventDefault() 940 941 var $this = $( this ), $product = $this.parents( 'li.product' ) 942 943 $product.removeClass( 'quick-shop-shown' ) 944 } ) 945 946 $( 'body' ).on( 'added_to_cart', function () { 947 $( '.product' ).removeClass( 'quick-shop-shown' ) 948 } ) 949 } 950 951 /* Product Accordion 952 ---------------------------------------------------------------*/ 953 PENCI.accordion = function () { 954 $( '.woocommerce-accordion-title' ).click( function ( j ) { 955 var $parent = $( this ).parent(), $toggle = $parent.find( '.woocommerce-accordion-panel' ) 956 957 $( this ).toggleClass( 'active' ) 958 $parent.toggleClass( 'parent-active' ) 959 $toggle.slideToggle() 960 j.preventDefault() 961 } ) 962 } 963 964 /* Product Product Carousel
965 ---------------------------------------------------------------*/ 966 PENCI.productCarousel = function () { 967 968 var penci_product_section_carousel = function ( selector, columns ) { 969 var sectionProduct, mobilecol, vclass 970 971 vclass = 'swiper-' + Math.floor( Math.random() * ( 972 9999999 - 1 + 1 973 ) + 1 ) 974 sectionProduct = '.' + vclass 975 976 if ( selector.indexOf( 'ul.products' ) >= 0 ) { 977 $( selector ).addClass( 'swiper ' + vclass ) 978 } else { 979 $( selector ).find( 'ul.products' ).addClass( 'swiper ' + vclass ) 980 } 981 982 $( sectionProduct ).wrapInner( '<div class="swiper-wrapper"></div>' ) 983 $( sectionProduct ).find( 'li' ).addClass( 'swiper-slide' ) 984 $( sectionProduct ).addClass( 'penci-owl-carousel penci-owl-carousel-slider' ) 985 $( sectionProduct ).append( '<div class="penci-owl-nav"><div class="owl-prev"><i class="penciicon-left-chevron"></i></div><div class="owl-next"><i class="penciicon-right-chevron"></i></div></div>' ) 986 987 var relateProduct_arg = { 988 loop: true, 989 spaceBetween: 30, 990 slidesPerView: columns, 991 breakpoints: { 992 320: { 993 slidesPerView: 2, spaceBetween: 20, 994 }, 600: { 995 slidesPerView: 2, spaceBetween: 20, 996 }, 1000: { 997 slidesPerView: columns, 998 }, 999 }, 1000 navigation: { 1001 nextEl: sectionProduct + ' .owl-next', 1002 prevEl: sectionProduct + ' .owl-prev', 1003 }, 1004 on: { 1005 init: function ( e ) { 1006 $( sectionProduct ).addClass( 'penci-owl-loaded' ) 1007 }, 1008 }, 1009 } 1010 1011 const swiper = new Swiper( sectionProduct, relateProduct_arg ) 1012 1013 } 1014 1015 $.each( [ 1016 { 1017 name: '.up-sells.products.slider', number: penciwoo.upsellproduct, 1018 }, { 1019 name: '.related.products.slider', number: penciwoo.relateproduct, 1020 }, { 1021 name: '.cart-collaterals + .cross-sells.slider', number: penciwoo.crosssellproduct, 1022 }, { 1023 name: 'ul.products.penci-woo-product-loop-categories.display-style-carousel', 1024 number: penciwoo.catcolumns, 1025 }, 1026 ], function ( key, section ) { 1027 penci_product_section_carousel( section.name, section.number ) 1028 } ) 1029 } 1030 1031 /* Product Product Sticky 1032 ---------------------------------------------------------------*/ 1033 PENCI.productSticky = function () { 1034 $( 'body.single-product' ).on( 'click', '.penci-sticky-cart .button.product_type_variable', function ( e ) { 1035 e.preventDefault() 1036 var productElement = document.querySelector( '#main' ) 1037 productElement.scrollIntoView( { behavior: 'smooth', block: 'start' } ) 1038 } ) 1039 1040 var stickyAddToCartCheck = function () { 1041 if ( ( 1042 $( '#main' ).find( '.penci-sticky-cart' ).length 1043 ) === 1 ) { 1044 var windowScroll = $( window ).scrollTop(), windowHeight = $( window ).height(), 1045 documentHeight = $( document ).height(), stickyCart = $( '.penci-sticky-cart' ), 1046 mainCart = $( 'form.cart' ), summaryOffset = mainCart.offset().top + mainCart.outerHeight() 1047 1048 if ( summaryOffset < windowScroll && windowScroll + windowHeight !== documentHeight ) { 1049 stickyCart.addClass( 'cart-sticky' ) 1050 1051 } else if ( windowScroll + windowHeight === documentHeight || summaryOffset > windowScroll ) { 1052 stickyCart.removeClass( 'cart-sticky' ) 1053 } 1054 1055 } // sticky 1056 } 1057 1058 stickyAddToCartCheck() 1059 1060 $( window ).on( 'scroll', stickyAddToCartCheck ) 1061 } 1062 1063 /* Product Pagination 1064 ---------------------------------------------------------------*/ 1065 PENCI.pagination = function () { 1066 var nextPage = $( '.woocommerce-pagination .next.page-numbers' ) 1067 if ( $.isFunction( $.fn.infiniteScroll ) && nextPage.length > 0 ) { 1068 var pPath = '.woocommerce-pagination .next.page-numbers', pAppend = 'li.product', 1069 pButton = '.view-more-button.button', pStatus = '.page-load-status', pBody = $( 'body' ), 1070 ajax_threshold = penciwoo.pagination_ajax_threshold, 1071 ajax_history = penciwoo.pagination_ajax_history, ajax_title = penciwoo.pagination_ajax_title 1072 1073 if ( pBody.hasClass( 'elementor-page' ) ) { 1074 ajax_history = false 1075 ajax_title = false 1076 } 1077 1078 $( '.infinit.penci-woo-page-container ul.products:not(.penci-woo-product-loop-categories)' ).each( function () { 1079 $( this ).infiniteScroll( { 1080 path: pPath, 1081 append: pAppend, 1082 status: pStatus, 1083 scrollThreshold: ajax_threshold, 1084 history: ajax_history, 1085 historyTitle: ajax_title, 1086 checkLastPage: true, 1087 } ) 1088 } ) 1089 1090 if ( !pBody.hasClass( 'elementor-page' ) ) { 1091 1092 1093 $( '.loadmore.penci-woo-page-container ul.products:not(.penci-woo-product-loop-categories)' ).each( function () { 1094 var idClass = '.woocommerce-pagination.loadmore-pagination .next.page-numbers', 1095 mainClass = $( this ) 1096 1097 if ( pBody.hasClass( 'elementor-page' ) ) { 1098 var id = $( this ).closest( '.penci-woo-page-container' ).data( 'section' ) 1099 idClass = '.' + id + ' .next.page-numbers' 1100 mainClass = $( '.' + id + '.loadmore.penci-woo-page-container ul.products.' + id + '-container' ) 1101 pAppend = '.' + id + ' li.product' 1102 pButton = '.' + id + '.view-more-button.button' 1103 pStatus = '.' + id + '.page-load-status' 1104 } 1105 1106 mainClass.infiniteScroll( { 1107 path: idClass, 1108 append: pAppend, 1109 scrollThreshold: false, 1110 button: pButton, 1111 status: pStatus, 1112 checkLastPage: true, 1113 history: ajax_history, 1114 historyTitle: ajax_title, 1115 debug: false, 1116 } ) 1117 } ) 1118 } 1119 1120 1121 $( '.penci-woo-page-container ul.products' ).on( 'request.infiniteScroll', function ( event, path, fetchPromise ) { 1122 $( pButton ).addClass( 'loading-posts' ) 1123 } ).on( 'load.infiniteScroll', function ( event, body, path, response ) { 1124 $( pButton ).removeClass( 'loading-posts' ) 1125 } ).on( 'append.infiniteScroll', function ( event, body, path, response ) { 1126 PENCI.tippyContent() 1127 } ).on( 'last.infiniteScroll', function ( event, body, path, response ) { 1128 $( pButton ).hide() 1129 } ) 1130 1131 if ( pBody.hasClass( 'elementor-page' ) ) { 1132 pBody.on( 'click', '.penci-ajax-more-button', function ( e ) { 1133 e.preventDefault() 1134 var thisBtn = $( this ), id = thisBtn.closest( '.penci-woo-page-container' ).data( 'section' ), 1135 contentContainer = $( '.' + id ), 1136 nextLink = contentContainer.find( '.woocommerce-pagination .next.page-numbers' ) 1137 1138 if ( nextLink.length > 0 ) { 1139 $.ajax( { 1140 url: nextLink.attr( 'href' ), method: 'get', beforeSend: function () { 1141 thisBtn.addClass( 'loading-posts' ) 1142 contentContainer.addClass( 'pre-load-content' ) 1143 }, success: function ( data ) { 1144 var content = $( data ).find( 'ul.products' ).html(), 1145 pagination = $( data ).find( '.woocommerce-pagination' ).html(), 1146 next = $( data ).find( '.woocommerce-pagination .next.page-numbers' ) 1147 contentContainer.removeClass( 'pre-load-content' ) 1148 thisBtn.removeClass( 'loading-posts' ) 1149 contentContainer.find( 'ul.products' ).append( content ) 1150 contentContainer.find( '.woocommerce-pagination' ).html( pagination ) 1151 PENCI.tippyContent() 1152 PENCI.loadingicon() 1153 PENCI.fixproductIconsize() 1154 PENCI.quickshop() 1155 if ( next.length === 0 ) { 1156 thisBtn.hide() 1157 } 1158 }, 1159 } ) 1160 } 1161 } ) 1162 } 1163 } 1164 } 1165 1166 /* Product Select2button 1167 ---------------------------------------------------------------*/ 1168 PENCI.select2button = function () { 1169 if ( penciwoo.select2button > 0 ) { 1170 $( '.variations_form.cart table.variations .value' ).each( function () { 1171 var $this = $( this ), $select = $this.find( 'select' ) 1172 if ( $this.find( '.penci-swatches' ).length < 1 ) { 1173 1174 $select.gridPicker( { 1175 canSelect: function ( element ) { 1176 return !$( element ).is( ':disabled' ) 1177 }, canUnselect: function ( element ) { 1178 return typeof this._$ui.element.attr( 'multiple' ) !== 'undefined' 1179 }, 1180 } ) 1181 } 1182 } ) 1183 } 1184 } 1185 1186 /* Product Sidebar 1187 ---------------------------------------------------------------*/ 1188 PENCI.sidecart = function () { 1189 $( document ).on( 'click', '.shoping-cart-icon a', function ( e ) { 1190 e.preventDefault() 1191 $( 'body' ).addClass( 'open-sidecart' ) 1192 } ) 1193 $( '.sidebar-cart-close' ).on( 'click', function () { 1194 $( 'body' ).removeClass( 'open-sidecart' ) 1195 } ) 1196 } 1197 1198 /* Top Widget Trigger 1199 ---------------------------------------------------------------*/ 1200 PENCI.topWidgets = function () { 1201 1202 var scrollEnable = true, bdY = $( 'body' ), filtetPanelPositon = penciwoo.fullpanelposition, 1203 filterClass = 'penci-' + filtetPanelPositon + '-filter-active' 1204 1205 if ( window.matchMedia( '(max-width: 767px)' ).matches && penciwoo.disable_mobile_autoscroll > 0 ) { 1206 scrollEnable = false 1207 } 1208 1209 $( document ).on( 'click', '.penci-product-top-filter-button > .penci-filter-button', function ( e ) { 1210 e.preventDefault() 1211 bdY.toggleClass( filterClass ) 1212 $( this ).toggleClass( 'close' ) 1213 } ) 1214 1215 $( document ).on( 'click', 'button.close-sidebar', function ( e ) { 1216 bdY.toggleClass( filterClass ) 1217 $( '.penci-product-top-filter-button > .penci-filter-button' ).toggleClass( 'close' ) 1218 } ) 1219 1220 $( document ).keyup( function ( e ) { 1221 if ( e.key === 'Escape' ) { 1222 if ( bdY.hasClass( filterClass ) ) { 1223 bdY.removeClass( filterClass ) 1224 $( '.penci-product-top-filter-button > .penci-filter-button' ).removeClass( 'close' ) 1225 } 1226 } 1227 } ) 1228 } 1229 1230 PENCI.productSwiper = function ( selector ) { 1231 1232 var tabProduct = $( selector ).find( 'ul.products' ), speed = tabProduct.data( 'speed' ), 1233 slides_per_view = tabProduct.data( 'desktop' ), 1234 slides_per_view_tablet = tabProduct.data( 'tablet' ) ? tabProduct.data( 'desktop' ) : slides_per_view, 1235 slides_per_view_mobile = tabProduct.data( 'mobile' ) ? tabProduct.data( 'mobile' ) : slides_per_view, 1236 autoplay = tabProduct.data( 'autoplay' ), center_mode = tabProduct.data( 'center_mode' ), 1237 hide_pagination_control = tabProduct.data( 'hide_pagination_control' ), 1238 hide_prev_next_buttons = tabProduct.data( 'hide_prev_next_buttons' ), 1239 datamargin = tabProduct.attr( 'data-margin' ), scroll_per_page = tabProduct.data( 'scroll_per_page' ), 1240 vclass = 'swiper_v_' + Math.floor( Math.random() * ( 1241 9999999 - 1 + 1 1242 ) + 1 ), 1243 $ids = 'swiper_v_' + Math.floor( Math.random() * ( 1244 9999999 - 1 + 1 1245 ) + 1 ) 1246 1247 if ( !tabProduct.hasClass( 'swiper' ) ) { 1248 tabProduct.addClass( 'swiper ' + vclass ) 1249 tabProduct.find( 'li' ).addClass( 'swiper-slide' ) 1250 tabProduct.wrapInner( '<div class="swiper-wrapper"></div>' ) 1251 } 1252 1253 $( 'body' ).trigger( 'slider-load' ) 1254 1255 } 1256 1257 /* Penci Ajax Product Query 1258 ---------------------------------------------------------------*/ 1259 PENCI.productQuery = function () { 1260 1261 $( '.elementor-element' ).each( function () { 1262 var telement = $( this ), 1263 defaultTab = $( telement ).find( '.penci-products-tabs .products-tabs-title li.active-tab-title' ) 1264 if ( 'carousel' === defaultTab.data( 'layout' ) ) { 1265 $( 'body' ).trigger( 'slider-load' ) 1266 } 1267 } ) 1268 1269 $( '.penci-products-tabs' ).on( 'click', '.products-tabs-title li', function ( e ) { 1270 e.preventDefault() 1271 var $this = $( this ), $setting = $this.data( 'atts' ), 1272 $elementClass = $this.closest( '.elementor-element' ), $queryID = $this.data( 'queryid' ), 1273 $layout = $this.data( 'layout' ), $queryClass = '.products-'
1273+ $queryID + '-section', 1274 $contentContainer = $elementClass.find( '.penci-tab-content-container' ), 1275 $slider = $( $queryClass ).find( 'ul.products' ) 1276 1277 if ( $this.hasClass( 'active-tab-title' ) ) { 1278 return false 1279 } 1280 1281 if ( $elementClass.find( $queryClass ).length > 0 ) { 1282 $contentContainer.find( '.penci-custom-products' ).removeClass( 'active' ) 1283 $contentContainer.find( $queryClass ).addClass( 'active' ) 1284 1285 $elementClass.find( '.products-tabs-title li' ).removeClass( 'active-tab-title' ) 1286 $this.addClass( 'active-tab-title' ) 1287 1288 if ( 'carousel' === $layout ) { 1289 $( 'body' ).trigger( 'slider-load' ) 1290 } 1291 1292 } else { 1293 $.ajax( { 1294 url: penciwoo.ajaxUrl, data: { 1295 action: 'penci_ajax_load_products', 1296 settings: $setting, 1297 requestid: penciwoo.nonce, 1298 preloader: 0, 1299 }, method: 'get', beforeSend: function () { 1300 $contentContainer.addClass( 'pre-load-content' ) 1301 }, success: function ( data ) { 1302 $contentContainer.append( data ) 1303 $contentContainer.removeClass( 'pre-load-content' ) 1304 $contentContainer.find( '.penci-custom-products' ).removeClass( 'active' ) 1305 $contentContainer.find( $queryClass ).addClass( 'active' ) 1306 $elementClass.find( '.products-tabs-title li' ).removeClass( 'active-tab-title' ) 1307 $this.addClass( 'active-tab-title' ) 1308 PENCI.tippyContent() 1309 PENCI.loadingicon() 1310 PENCI.fixproductIconsize() 1311 PENCI.quickshop() 1312 if ( 'carousel' === $layout ) { 1313 $( 'body' ).trigger( 'slider-load' ) 1314 } 1315 }, 1316 } ) 1317 } 1318 } ).on( 'click', '.page-numbers a', function ( e ) { 1319 1320 var linkURL = $( this ).attr( 'href' ).toString() 1321 1322 if ( linkURL.indexOf( 'penci_ajax_load_products' ) >= 0 ) { 1323 1324 var parentClass = $( this ).closest( '.page-unique-part' ), 1325 containerUnit = '.' + parentClass.data( 'part' ), 1326 parentConent = $( '.penci-tab-content-container' ), postURL = $( this ).attr( 'href' ) 1327 $.ajax( { 1328 url: postURL, method: 'get', beforeSend: function () { 1329 parentConent.addClass( 'pre-load-content' ) 1330 }, success: function ( data ) { 1331 parentConent.find( containerUnit ).remove() 1332 parentConent.append( data ) 1333 parentConent.removeClass( 'pre-load-content' ) 1334 parentConent.find( containerUnit ).addClass( 'active' ) 1335 PENCI.tippyContent() 1336 }, 1337 } ) 1338 } 1339 1340 e.preventDefault() 1341 } ) 1342 1343 $( document ).on( 'click', '.penci-swatches-divider', function () { 1344 var $click = $( this ), $item = $click.closest( '.penci-swatches-list' ) 1345 $item.find( '.penci-swatch-item' ).removeClass( 'hidden' ) 1346 $click.hide() 1347 } ) 1348 1349 } 1350 1351 /* Penci Notify 1352 ---------------------------------------------------------------*/ 1353 PENCI.notify = function ( title, message, type ) { 1354 if ( penciwoo.toast_notify > 0 && title && message && type ) { 1355 1356 var $icon = type 1357 1358 if ( type === 'added_to_cart' ) { 1359 $icon = false 1360 } 1361 1362 $.toast( { 1363 heading: title, 1364 text: message, 1365 icon: $icon, 1366 position: penciwoo.toast_notify_position, 1367 textAlign: penciwoo.toast_notify_text_align, 1368 showHideTransition: penciwoo.toast_notify_transition, 1369 hideAfter: penciwoo.toast_notify_hide_after, 1370 bgColor: penciwoo.toast_notify_bg_color, 1371 textColor: penciwoo.toast_notify_text_color, 1372 } ) 1373 } 1374 } 1375 1376 /* Penci Misc Template 1377 ---------------------------------------------------------------*/ 1378 PENCI.ajaxNotify = function ( $id ) { 1379 $.ajax( { 1380 url: penciwoo.ajaxUrl, data: { 1381 action: 'penci_get_product_info', requestid: penciwoo.nonce, id: $id, 1382 }, method: 'get', success: function ( response ) { 1383 PENCI.notify( '<a href="' + response.data.item_link + '"><img class="product_image" src="' + response.data.img + '" alt=""/></a><div><a class="toast-title" href="' + response.data.item_link + '">' + response.data.title + '</a><p>' + penciwoo.addtocart + '.</p></div>', penciwoo.toast_notify_shop_sucess_text + '<div class="woocommerce notify_bottom"><a class="button shop_url" href="' + penciwoo.toast_notify_shop_url + '">' + penciwoo.toast_notify_shop_text + '</a><a class="button checkout_url" href="' + penciwoo.checkout_url + '">' + penciwoo.checkout_text + '</a></div>', 'added_to_cart' ) 1384 }, 1385 } ) 1386 } 1387 1388 /* Penci Misc Template 1389 ---------------------------------------------------------------*/ 1390 PENCI.getURLparam = function ( sParam ) { 1391 var sPageURL = window.location.search.substring( 1 ), sURLVariables = sPageURL.split( '&' ), sParameterName, 1392 i 1393 1394 for ( i = 0; i < sURLVariables.length; i ++ ) { 1395 sParameterName = sURLVariables[i].split( '=' ) 1396 1397 if ( sParameterName[0] === sParam ) { 1398 return typeof sParameterName[1] === undefined ? true : decodeURIComponent( sParameterName[1] ) 1399 } 1400 } 1401 return false 1402 } 1403 1404 PENCI.misc = function () { 1405 var body = $( 'body' ) 1406 if ( body.find( '.penci-mobile-bottom-nav' ).length > 0 ) { 1407 body.addClass( 'mobile-bottom-nav-active' ) 1408 } 1409 1410 $( '.penci-mobile-bottom-nav li.filter a' ).on( 'click', function ( e ) { 1411 e.preventDefault() 1412 $( 'body' ).addClass( 'open-filter-side' ) 1413 } ) 1414 $( '.sidebar-filter-close, .sidebar-filter-close-button' ).on( 'click', function () { 1415 $( 'body' ).removeClass( 'open-filter-side penci-side-right-filter-active penci-side-left-filter-active' ) 1416 $( '.penci-product-top-filter-button > .penci-filter-button' ).removeClass( 'close' ) 1417 } ) 1418 $( '.penci-top-relate-post .top-ralate-item' ).each( function () { 1419 if ( PENCI.isMobile() ) { 1420 var tItem = $( this ), title = tItem.find( 'h4' ).text(), link = tItem.find( 'a' ).attr( 'href' ) 1421 tItem.attr( 'data-tippy-content', title ) 1422 tippy( '[data-tippy-content]', { placement: 'bottom' } ) 1423 $( this ).on( 'click', function () { 1424 window.location.href = link 1425 } ) 1426 } 1427 } ) 1428 1429 $( '.widget_layered_nav_filters a,.soledad-product-filter li.chosen a.layered-nav-link' ).each( function () { 1430 var theme_demo_mods = penciwoo.demo_mods, currentURL = $( this ).attr( 'href' ) 1431 $.each( theme_demo_mods, function ( index, attr ) { 1432 var value = PENCI.getURLparam( attr ) 1433 if ( value.length > 0 ) { 1434 currentURL = PENCI.updateURL( currentURL, attr, value ) 1435 } 1436 } ) 1437 1438 $( this ).attr( 'href', currentURL ) 1439 } ) 1440 } 1441 1442 /* Penci Woo Extra 1443 ---------------------------------------------------------------*/ 1444 1445 PENCI.wooextra = function () { 1446 1447 $( 'body' ).on( 'wc_cart_button_updated', function () { 1448 $( '.penci-product-loop-button' ).find( 'a.added_to_cart.wc-forward' ).remove() 1449 } ) 1450 1451 $( document ).on( 'added_to_cart', function ( event, fragments, cart_hash, $button ) { 1452 1453 if ( 'dropdown' !== penciwoo.cartstyle.toString() ) { 1454 $( 'body' ).addClass( 'open-sidecart' ) 1455 } 1456 1457 if ( penciwoo.cartnotify > 0 ) { 1458 1459 var $id 1460 1461 if ( $button.data( 'product_id' ) ) { 1462 $id = $button.data( 'product_id' ) 1463 } else { 1464 if ( $button.closest( 'form.cart' ).data( 'product_id' ) ) { 1465 $id = $button.closest( 'form.cart' ).data( 'product_id' ) 1466 } else if ( $button.attr( 'value' ) ) { 1467 $id = $button.attr( 'value' ) 1468 } 1469 } 1470 1471 if ( $id ) { 1472 PENCI.ajaxNotify( $id ) 1473 return false 1474 } 1475 1476 } 1477 } ) 1478 } 1479 1480 /* Penci Loading 1481 ---------------------------------------------------------------*/ 1482 PENCI.loadingicon = function () { 1483 1484 var penci_loading_icon = '<span class="penci-loading-icon"><span class="bubble"></span><span class="bubble"></span><span class="bubble"></span></span>', 1485 elAdd = [ 1486 '.single_add_to_cart_button', 1487 'ul.product-style-5 .penci-product-loop-top a.button.add_to_cart_button', 1488 'ul.product-style-3 .penci-product-loop-image a.button.add_to_cart_button', 1489 'ul.product-standard a.button', 1490 '.penci-list-action .button', 1491 '.woocommerce.penci-products-compare-table a.button.add_to_cart_button', 1492 '.hotspot-product .button', 1493 ] 1494 1495 $.each( elAdd, function ( index, value ) { 1496 $( value ).append( penci_loading_icon ).addClass( 'has-new-preload' ) 1497 } ) 1498 } 1499 1500 /* Penci Product Filter 1501 ---------------------------------------------------------------*/ 1502 PENCI.productFilters = function () { 1503 var removeValue = function ( $mainInput, currentVal ) { 1504 if ( $mainInput.length === 0 ) { 1505 return 1506 } 1507 1508 var mainInputVal = $mainInput.val() 1509 1510 if ( mainInputVal.indexOf( ',' ) > 0 ) { 1511 $mainInput.val( mainInputVal.replace( ',' + currentVal, '' ).replace( currentVal + ',', '' ) ) 1512 } else { 1513 $mainInput.val( mainInputVal.replace( currentVal, '' ) ) 1514 } 1515 } 1516 1517 $( '.penci-pf-checkboxes li > .pf-value' ).on( 'click', function ( e ) { 1518 e.preventDefault() 1519 var $this = $( this ), $li = $this.parent(), $widget = $this.parents( '.penci-pf-checkboxes' ), 1520 $mainInput = $widget.find( '.result-input' ), $results = $widget.find( '.penci-pf-results' ), 1521 multiSelect = $widget.hasClass( 'multi_select' ), mainInputVal = $mainInput.val(), 1522 currentText = $this.data( 'title' ), currentVal = $this.data( 'val' ) 1523 1524 if ( multiSelect ) { 1525 if ( !$li.hasClass( 'pf-active' ) ) { 1526 if ( mainInputVal === '' ) { 1527 $mainInput.val( currentVal ) 1528 } else { 1529 $mainInput.val( mainInputVal + ',' + currentVal ) 1530 } 1531 1532 $results.prepend( '<li class="selected-value" data-title="' + currentVal + '">' + currentText + '</li>' ) 1533 $li.addClass( 'pf-active' ) 1534 } else { 1535 removeValue( $mainInput, currentVal ) 1536 $results.find( 'li[data-title="' + currentVal + '"]' ).remove() 1537 $li.removeClass( 'pf-active' ) 1538 } 1539 } else { 1540 if ( !$li.hasClass( 'pf-active' ) ) { 1541 $mainInput.val( currentVal ) 1542 $results.find( '.selected-value' ).remove() 1543 $results.prepend( '<li class="selected-value" data-title="' + currentVal + '">' + currentText + '</li>' ) 1544 $li.parents( '.penci-scroll-content' ).find( '.pf-active' ).removeClass( 'pf-active' ) 1545 $li.addClass( 'pf-active' ) 1546 } else { 1547 $mainInput.val( '' ) 1548 $results.find( '.selected-value' ).remove() 1549 $li.removeClass( 'pf-active' ) 1550 } 1551 } 1552 } ) 1553 1554 // Label clear 1555 var $checkboxes = $( '.penci-pf-checkboxes' ) 1556 $checkboxes.on( 'click', '.selected-value', function () { 1557 var $this = $( this ), $widget = $this.parents( '.penci-pf-checkboxes' ), 1558 $mainInput = $widget.find( '.result-input' ), currentVal = $this.data( 'title' ) 1559 1560 // Price filter clear 1561 if ( currentVal === 'price-filter' ) { 1562 var min = $this.data( 'min' ), max = $this.data( 'max' ), 1563 $slider = $widget.find( '.price_slider_widget' ) 1564 $slider.slider( 'values', 0, min ) 1565 $slider.slider( 'values', 1, max ) 1566 $widget.find( '.min_price' ).val( '' ) 1567 $widget.find( '.max_price' ).val( '' ) 1568 $( 'body' ).trigger( 'filter_price_slider_slide', [ 1569 min, max, min, max, $slider, 1570 ] ) 1571 return 1572 } 1573 1574 removeValue( $mainInput, currentVal ) 1575 $widget.find( '.pf-value[data-val="' + currentVal + '"]' ).parent().removeClass( 'pf-active' ) 1576 $this.remove() 1577 } ) 1578 1579 // Checkboxes value dropdown 1580 $checkboxes.each( function () { 1581 var $this = $( this ), $btn = $this.find( '.penci-pf-title' ), 1582 $list = $btn.siblings( '.penci-pf-dropdown' ), multiSelect = $this.hasClass( 'multi_select' ) 1583 1584 $btn.on( 'click', function ( e ) { 1585 var target = e.target 1586 1587 if ( $( target ).is( $btn.find( '.selected-value' ) ) ) { 1588 return 1589 } 1590 1591 if ( !$this.hasClass( 'opened' ) ) { 1592 $this.addClass( 'opened' ) 1593 $list.slideDown( 100 ) 1594 setTimeout( function () { 1595 $( document ).trigger( 'wdProductFiltersOpened' ) 1596 }, 300 ) 1597 } else { 1598 close() 1599 } 1600 } ) 1601 1602 $( document ).on( 'click', function ( e ) { 1603 var target = e.target 1604 1605 if ( $this.hasClass( 'opened' ) && ( 1606 multiSelect && !$( target ).is( $this ) && !$( target ).parents().is( $this ) 1607 ) || ( 1608 !multiSelect && !$( target ).is( $btn ) && !$( target ).parents().is( $btn ) 1609 ) ) { 1610 close() 1611 } 1612 } ) 1613 1614 var close = function () { 1615 $this.removeClass( 'opened' ) 1616 $list.slideUp( 100 ) 1617 } 1618 } ) 1619
1620 var removeEmptyValues = function ( $selector ) { 1621 $selector.find( '.penci-pf-checkboxes' ).each( function () { 1622 var $this = $( this ) 1623 1624 if ( !$this.find( 'input[type="hidden"]' ).val() ) { 1625 $this.find( 'input[type="hidden"]' ).remove() 1626 } 1627 } ) 1628 } 1629 1630 var changeFormAction = function ( $form ) { 1631 var activeCat = $form.find( '.penci-pf-categories .pf-active .pf-value' ) 1632 1633 if ( activeCat.length > 0 ) { 1634 $form.attr( 'action', activeCat.attr( 'href' ) ) 1635 } 1636 } 1637 1638 // Price slider init 1639 $( 'body' ).on( 'filter_price_slider_create filter_price_slider_slide', function ( event, min, max, minPrice, maxPrice, $slider ) { 1640 var minHtml = accounting.formatMoney( min, { 1641 symbol: woocommerce_price_slider_params.currency_format_symbol, 1642 decimal: woocommerce_price_slider_params.currency_format_decimal_sep, 1643 thousand: woocommerce_price_slider_params.currency_format_thousand_sep, 1644 precision: woocommerce_price_slider_params.currency_format_num_decimals, 1645 format: woocommerce_price_slider_params.currency_format, 1646 } ) 1647 1648 var maxHtml = accounting.formatMoney( max, { 1649 symbol: woocommerce_price_slider_params.currency_format_symbol, 1650 decimal: woocommerce_price_slider_params.currency_format_decimal_sep, 1651 thousand: woocommerce_price_slider_params.currency_format_thousand_sep, 1652 precision: woocommerce_price_slider_params.currency_format_num_decimals, 1653 format: woocommerce_price_slider_params.currency_format, 1654 } ) 1655 1656 $slider.siblings( '.filter_price_slider_amount' ).find( 'span.from' ).html( minHtml ) 1657 $slider.siblings( '.filter_price_slider_amount' ).find( 'span.to' ).html( maxHtml ) 1658 1659 var $results = $slider.parents( '.penci-pf-checkboxes' ).find( '.penci-pf-results' ), 1660 value = $results.find( '.selected-value' ) 1661 1662 if ( min === minPrice && max === maxPrice ) { 1663 value.remove() 1664 } else { 1665 if ( value.length === 0 ) { 1666 $results.prepend( '<li class="selected-value" data-title="price-filter" data-min="' + minPrice + '" data-max="' + maxPrice + '">' + minHtml + ' - ' + maxHtml + '</li>' ) 1667 } else { 1668 value.html( minHtml + ' - ' + maxHtml ) 1669 } 1670 } 1671 1672 $( 'body' ).trigger( 'price_slider_updated', [ 1673 min, max, 1674 ] ) 1675 } ) 1676 1677 $( '.penci-pf-price-range .price_slider_widget' ).each( function () { 1678 var $this = $( this ), $minInput = $this.siblings( '.filter_price_slider_amount' ).find( '.min_price' ), 1679 $maxInput = $this.siblings( '.filter_price_slider_amount' ).find( '.max_price' ), 1680 minPrice = parseInt( $minInput.data( 'min' ) ), maxPrice = parseInt( $maxInput.data( 'max' ) ), 1681 currentMinPrice = parseInt( $minInput.val() ), currentMaxPrice = parseInt( $maxInput.val() ) 1682 1683 $( '.price_slider_widget, .price_label' ).show() 1684 1685 $this.slider( { 1686 range: true, animate: true, min: minPrice, max: maxPrice, values: [ 1687 currentMinPrice, currentMaxPrice, 1688 ], create: function () { 1689 if ( currentMinPrice === minPrice && currentMaxPrice === maxPrice ) { 1690 $minInput.val( '' ) 1691 $maxInput.val( '' ) 1692 } 1693 1694 $( 'body' ).trigger( 'filter_price_slider_create', [ 1695 currentMinPrice, currentMaxPrice, minPrice, maxPrice, $this, 1696 ] ) 1697 }, slide: function ( event, ui ) { 1698 if ( ui.values[0] === minPrice && ui.values[1] === maxPrice ) { 1699 $minInput.val( '' ) 1700 $maxInput.val( '' ) 1701 } else { 1702 $minInput.val( ui.values[0] ) 1703 $maxInput.val( ui.values[1] ) 1704 } 1705 1706 $( 'body' ).trigger( 'filter_price_slider_slide', [ 1707 ui.values[0], ui.values[1], minPrice, maxPrice, $this, 1708 ] ) 1709 }, change: function ( event, ui ) { 1710 $( 'body' ).trigger( 'price_slider_change', [ 1711 ui.values[0], ui.values[1], 1712 ] ) 1713 }, 1714 } ) 1715 } ) 1716 1717 // Submit filter form 1718 $( '.penci-product-filters' ).one( 'click', '.penci-pf-btn button', function () { 1719 var $this = $( this ), $form = $this.parents( '.penci-product-filters' ) 1720 removeEmptyValues( $form ) 1721 changeFormAction( $form ) 1722 1723 if ( !$( 'body' ).hasClass( 'penci-ajax-shop-on' ) || typeof ( 1724 $.fn.pjax 1725 ) == 'undefined' || !$form.hasClass( 'with-ajax' ) ) { 1726 return 1727 } 1728 1729 $.pjax( { 1730 container: '.penci-woo-page-container', 1731 fragment: '.penci-woo-page-container', 1732 url: $form.attr( 'action' ), 1733 data: $form.serialize(), 1734 scrollTo: false, 1735 } ) 1736 1737 $this.prop( 'disabled', true ) 1738 } ) 1739
1740 // Create labels after ajax 1741 $( '.penci-pf-checkboxes .pf-active > .pf-value' ).each( function () { 1742 var $this = $( this ), 1743 resultsWrapper = $this.parents( '.penci-pf-checkboxes' ).find( '.penci-pf-results' ) 1744 1745 resultsWrapper.prepend( '<li class="selected-value" data-title="' + $this.data( 'val' ) + '">' + $this.data( 'title' ) + '</li>' ) 1746 } ) 1747 } 1748 1749 /* Penci Category Dropdown 1750 ---------------------------------------------------------------*/ 1751 PENCI.categoryDropdown = function () { 1752 $( '.penci-search-cat' ).each( function () { 1753 var dd = $( this ), btn = dd.find( '> a' ), input = dd.find( '> input' ), 1754 list = dd.find( '> .penci-dropdown' ), $searchInput = dd.parent().parent().find( '.s' ) 1755 1756 $searchInput.on( 'focus', function () { 1757 inputPadding() 1758 } ) 1759 1760 $( document ).on( 'click', function ( e ) { 1761 var target = e.target 1762 1763 if ( list.hasClass( 'penci-opened' ) && !$( target ).is( '.penci-search-cat' ) && !$( target ).parents().is( '.penci-search-cat' ) ) { 1764 hideList() 1765 return false 1766 } 1767 } ) 1768 1769 btn.on( 'click', function ( e ) { 1770 e.preventDefault() 1771 1772 if ( list.hasClass( 'penci-opened' ) ) { 1773 hideList() 1774 } else { 1775 showList() 1776 } 1777 1778 return false 1779 } ) 1780 1781 list.on( 'click', 'a', function ( e ) { 1782 e.preventDefault() 1783 var $this = $( this ), value = $this.data( 'val' ), label = $this.text() 1784 1785 list.find( '.current-item' ).removeClass( 'current-item' ) 1786 $this.parent().addClass( 'current-item' ) 1787 1788 if ( value !== 0 ) { 1789 list.find( 'ul:not(.children) > li:first-child' ).show() 1790 } else if ( value === 0 ) { 1791 list.find( 'ul:not(.children) > li:first-child' ).hide() 1792 } 1793 1794 btn.find( 'span' ).text( label ) 1795 input.val( value ).trigger( 'cat_selected' ) 1796 hideList() 1797 inputPadding() 1798 } ) 1799 1800 function showList() { 1801 list.addClass( 'penci-opened' ) 1802 1803 if ( typeof ( 1804 $.fn.devbridgeAutocomplete 1805 ) != 'undefined' ) { 1806 dd.parent().siblings( '[type="text"]' ).devbridgeAutocomplete( 'hide' ) 1807 } 1808 1809 setTimeout( function () { 1810 $( document ).trigger( 'wdSimpleDropdownOpened' ) 1811 }, 300 ) 1812 } 1813 1814 function hideList() { 1815 list.removeClass( 'penci-opened' ) 1816 } 1817 1818 function inputPadding() { 1819 if ( $( window ).width() <= 768 || $searchInput.hasClass( 'penci-padding-inited' ) || 'yes' !== penciwoo.search_input_padding ) { 1820 return 1821 } 1822 1823 var paddingValue = dd.innerWidth() + dd.parent().siblings( '.searchsubmit' ).innerWidth() + 17, 1824 padding = 'padding-right' 1825 1826 if ( $( 'body' ).hasClass( 'rtl' ) ) { 1827 padding = 'padding-left' 1828 } 1829 1830 $searchInput.css( padding, paddingValue ) 1831 $searchInput.addClass( 'penci-padding-inited' ) 1832 } 1833 } ) 1834 } 1835 1836 /* Countdown 1837 ---------------------------------------------------------------*/ 1838 PENCI.product_countdown = function () { 1839 $( '.penci-time-countdown' ).each( function () { 1840 var $this = $( this ) 1841 dayjs.extend( window.dayjs_plugin_utc ) 1842 dayjs.extend( window.dayjs_plugin_timezone ) 1843 var time = dayjs.tz( $this.data( 'end-date' ), $this.data( 'timezone' ) ) 1844 $this.countdown( time.toDate(), function ( event ) { 1845 $this.html( event.strftime( '' + '<span class="countdown-days">%-D <span>' + penciwoo.countdown_days + '</span></span> ' + '<span class="countdown-hours">%H <span>' + penciwoo.countdown_hours + '</span></span> ' + '<span class="countdown-min">%M <span>' + penciwoo.countdown_mins + '</span></span> ' + '<span class="countdown-sec">%S <span>' + penciwoo.countdown_sec + '</span></span>' ) ) 1846 } ) 1847 } ) 1848 } 1849 1850 /* Product Sticky sidebar 1851 ----------------------------------------------------------------*/ 1852 PENCI.product_sticky_sidebar = function () { 1853 if ( $().theiaStickySidebar ) { 1854 var top_margin = 90 1855 if ( $( 'body' ).hasClass( 'admin-bar' ) && $( 'body' ).hasClass( 'penci-vernav-enable' ) ) { 1856 top_margin = 62 1857 } else if ( !$( 'body' ).hasClass( 'admin-bar' ) && $( 'body' ).hasClass( 'penci-vernav-enable' ) ) { 1858 top_margin = 30 1859 } else if ( $( 'body' ).hasClass( 'admin-bar' ) && !$( 'body' ).hasClass( 'penci-vernav-enable' ) ) { 1860 top_margin = 122 1861 } 1862 1863 $( '#main.penci-main-sticky-sidebar, #sidebar.penci-sticky-sidebar' ).the
1863iaStickySidebar( { 1864 // settings 1865 additionalMarginTop: top_margin, 1866 } ) 1867 1868 $( '.penci-product-summary.penci-main-sticky-sidebar, .woocommerce-product-gallery.penci-sticky-sidebar' ).theiaStickySidebar( { 1869 // settings. 1870 additionalMarginTop: top_margin, 1871 } ) 1872 1873 $( '.sidebar-bottom .penci-content-sticky-sidebar .bottom-content, .sidebar-bottom .penci-content-sticky-sidebar #sidebar.penci-sticky-sidebar' ).theiaStickySidebar( { 1874 // settings. 1875 additionalMarginTop: top_margin, 1876 } ) 1877 } // if sticky 1878 } 1879 1880 /* Product Sidebar Quantity 1881 ----------------------------------------------------------------*/ 1882 PENCI.sidecartQuantity = function () { 1883 var timeout 1884 $( document ).on( 'change input', '.woocommerce-mini-cart .quantity .qty', function () { 1885 var input = $( this ), qtyVal = input.val(), itemID = input.parents( '.mini_cart_item' ).data( 'key' ), 1886 penci_loading_icon = '<span class="penci-loading-icon"><span class="bubble"></span><span class="bubble"></span><span class="bubble"></span></span>' 1887 1888 clearTimeout( timeout ) 1889 1890 timeout = setTimeout( function () { 1891 input.parents( '.mini_cart_item' ).append( penci_loading_icon ).addClass( 'loading' ) 1892 1893 $.ajax( { 1894 url: penciwoo.ajaxUrl, data: { 1895 action: 'penci_shop_update_cart_item', item_id: itemID, qty: qtyVal, 1896 }, success: function ( data ) { 1897 if ( data && data.fragments ) { 1898 $.each( data.fragments, function ( key, value ) { 1899 if ( $( key ).hasClass( 'widget_shopping_cart_content' ) ) { 1900 var dataItemValue = $( value ).find( '.woocommerce-mini-cart-item[data-key="' + itemID + '"]' ), 1901 dataFooterValue = $( value ).find( '.woocommerce-mini-cart__total' ), 1902 $itemSelector = $( key ).find( '.woocommerce-mini-cart-item[data-key="' + itemID + '"]' ) 1903 1904 if ( !data.cart_hash ) { 1905 $( key ).replaceWith( value ) 1906 } else { 1907 $itemSelector.replaceWith( dataItemValue ) 1908 $( '.woocommerce-mini-cart__total' ).replaceWith( dataFooterValue ) 1909 } 1910 } else { 1911 $( key ).replaceWith( value ) 1912 } 1913 } ) 1914 } 1915 }, dataType: 'json', method: 'GET', 1916 } ) 1917 }, 500 ) 1918 } ) 1919 } 1920 1921 /* Product Sticky sidebar 1922 ----------------------------------------------------------------*/ 1923 PENCI.fixproductIconsize = function () { 1924 $( 'ul.products' ).find( 'li.product' ).each( function ( e ) { 1925 var productC = $( this ), productZ = productC.closest( 'ul.products' ), 1926 productB = productC.find( '.penci-product-loop-button' ).innerHeight(), 1927 productW = productC.find( '.penci-product-loop-top' ).innerHeight() 1928 if ( productB > productW ) { 1929 productZ.addClass( 'penci-small-width' ) 1930 } else { 1931 productZ.removeClass( 'penci-small-width' ) 1932 } 1933 } ) 1934 $( '.widget.soledad-product-filter' ).each( function () { 1935 var items = $( this ).find( 'ul.swatches-display-list li' ).length, 1936 height = $( this ).find( 'ul.swatches-display-list li' ).outerHeight(), standard = penciwoo.wdgh 1937 1938 if ( PENCI.isMobile() || window.matchMedia( '(max-width: 768px)' ).matches ) { 1939 standard = penciwoo.wdgmh 1940 } 1941 1942 $( this ).addClass( 'penci-scroll-inactive' ).removeClass( 'penci-scroll-active' ) 1943 1944 if ( items * height + items * 5.32 > standard ) { 1945 $( this ).removeClass( 'penci-scroll-inactive' ).addClass( 'penci-scroll-active' ) 1946 } 1947 } ) 1948 } 1949 1950 /* Hotspot Product 1951 ----------------------------------------------------------------*/ 1952 PENCI.producthotspot = function () { 1953 $( '.penci-image-hotspot' ).each( function () { 1954 var _this = $( this ) 1955 var btn = _this.find( '.hotspot-btn' ) 1956 var parentWrapper = _this.parents( '.penci-image-hotspot-wrapper' ) 1957 1958 if ( !parentWrapper.hasClass( 'hotspot-action-click' ) && $( window ).width() > 1024 ) { 1959 return 1960 } 1961 1962 btn.on( 'click', function () { 1963 if ( _this.hasClass( 'hotspot-opened' ) ) { 1964 _this.removeClass( 'hotspot-opened' ) 1965 } else { 1966 _this.addClass( 'hotspot-opened' ) 1967 _this.siblings().removeClass( 'hotspot-opened' ) 1968 } 1969 1970 $( document ).trigger( 'wood-images-loaded' ) 1971 return false 1972 } ) 1973 1974 $( document ).on( 'click', function ( e ) { 1975 var target = e.target 1976 1977 if ( _this.hasClass( 'hotspot-opened' ) && !$( target ).is( '.penci-image-hotspot' ) && !$( target ).parents().is( '.penci-image-hotspot' ) ) { 1978 _this.removeClass( 'hotspot-opened' ) 1979 return false 1980 } 1981 } ) 1982 } ) 1983 1984 //Image loaded 1985 $( '.penci-image-hotspot-wrapper' ).each( function () { 1986 var _this = $( this ) 1987 _this.imagesLoaded( function () { 1988 _this.addClass( 'loaded' ) 1989 } ) 1990 } ) 1991 1992 $( '.pc-image-hotspot .hotspot-content' ).each( function () { 1993 var content = $( this ), offsetLeft = content.offset().left, offsetRight = $( window ).width() - ( 1994 offsetLeft + content.outerWidth() 1995 ) 1996 1997 if ( $( window ).width() > 768 ) { 1998 if ( offsetLeft <= 0 ) { 1999 content.addClass( 'hotspot-overflow-right' ) 2000 } 2001 if ( offsetRight <= 0 ) { 2002 content.addClass( 'hotspot-overflow-left' ) 2003 } 2004 } 2005 2006 if ( $( window ).width() <= 768 ) { 2007 if ( offsetLeft <= 0 ) { 2008 content.css( 'marginLeft', Math.abs( offsetLeft - 15 ) + 'px' ) 2009 } 2010 if ( offsetRight <= 0 ) { 2011 content.css( 'marginLeft', offsetRight - 15 + 'px' ) 2012 } 2013 } 2014 } ) 2015 } 2016
2017 /* Soledad on Mobile 2018 ----------------------------------------------------------------*/ 2019 PENCI.mobileTrigger = function () { 2020 $( document ).on( 'mouseenter mousemove touchstart', '.penci-soledad-product', function ( e ) { 2021 var $this = $( this ) 2022 $this.closest( 'ul.products' ).find( '.penci-soledad-product' ).removeClass( 'penci-hover' ) 2023 $this.addClass( 'penci-hover' ) 2024 } ) 2025 } 2026 2027 /* Init functions 2028 ---------------------------------------------------------------*/ 2029 $( document ).ready( function () { 2030 PENCI.yith() 2031 PENCI.quickview() 2032 PENCI.wishlist() 2033 PENCI.compare() 2034 PENCI.swatches( '.entry-summary .variations_form' ) 2035 PENCI.productslider() 2036 PENCI.quantity() 2037 PENCI.productLoop() 2038 PENCI.productATC() 2039 PENCI.productVATC() 2040 PENCI.quickshop() 2041 PENCI.accordion() 2042 PENCI.productCarousel() 2043 PENCI.productSticky() 2044 PENCI.tippyContent() 2045 PENCI.pagination() 2046 PENCI.select2button() 2047 PENCI.topWidgets() 2048 PENCI.productQuery() 2049 PENCI.productFilters() 2050 PENCI.misc() 2051 PENCI.categoryDropdown() 2052 PENCI.product_countdown() 2053 PENCI.product_sticky_sidebar() 2054 PENCI.loadingicon() 2055 PENCI.sidecartQuantity() 2056 PENCI.producthotspot() 2057 PENCI.fixproductIconsize() 2058 PENCI.wooextra() 2059 if ( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( navigator.userAgent ) ) { 2060 PENCI.mobileTrigger() 2061 } 2062 if ( 'dropdown' !== penciwoo.cartstyle.toString() ) { 2063 PENCI.sidecart() 2064 } 2065 if ( penciwoo.ajaxshop > 0 ) { 2066 PENCI.ajaxfilter() 2067 } 2068 $( window ).on( 'resize', function () { 2069 PENCI.fixproductIconsize() 2070 } ) 2071 } ) 2072 2073 // Hook to Elementor Edit. 2074 $.each( ['frontend/element_ready/penci_product_deals.default'], function ( index, value ) { 2075 PENCI.elAction( value, function () { 2076 PENCI.fixproductIconsize() 2077 } ) 2078 } ) 2079 2080 $.each( ['frontend/element_ready/penci_products_tabs.default'], function ( index, value ) { 2081 PENCI.elAction( value, function () { 2082 PENCI.productQuery() 2083 PENCI.fixproductIconsize() 2084 PENCI.tippyContent() 2085 } ) 2086 } ) 2087 2088 $.each( ['frontend/element_ready/penci_product_hotspot.default'], function ( index, value ) { 2089 PENCI.elAction( value, function () { 2090 PENCI.producthotspot() 2091 } ) 2092 } ) 2093 2094 $.each( [ 2095 'frontend/element_ready/penci_products.default', 2096 'frontend/element_ready/penci_product_categories.default', 2097 'frontend/element_ready/penci_products_brands.default', 2098 ], function ( index, value ) { 2099 PENCI.elAction( value, function () { 2100 $( 'body' ).trigger( 'slider-load' ) 2101 PENCI.misc() 2102 PENCI.fixproductIconsize() 2103 PENCI.tippyContent() 2104 } ) 2105 } ) 2106 } 2107)( jQuery )
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.