1var woodmartThemeModule = {}; 2/* global woodmart_settings */ 3 4(function($) { 5 woodmartThemeModule.supports_html5_storage = false; 6 7 try { 8 woodmartThemeModule.supports_html5_storage = ('sessionStorage' in window && window.sessionStorage !== null); 9 window.sessionStorage.setItem('wd', 'test'); 10 window.sessionStorage.removeItem('wd'); 11 } 12 catch (err) { 13 woodmartThemeModule.supports_html5_storage = false; 14 } 15 16 woodmartThemeModule.$window = $(window); 17 18 woodmartThemeModule.$document = $(document); 19 20 woodmartThemeModule.$body = $('body'); 21 22 woodmartThemeModule.windowWidth = woodmartThemeModule.$window.width(); 23 24 woodmartThemeModule.removeURLParameter = function(url, parameter) { 25 var urlParts = url.split('?'); 26 27 if (urlParts.length >= 2) { 28 var prefix = encodeURIComponent(parameter) + '='; 29 var pars = urlParts[1].split(/[&;]/g); 30 31 for (var i = pars.length; i-- > 0;) { 32 if (pars[i].lastIndexOf(prefix, 0) !== -1) { 33 pars.splice(i, 1); 34 } 35 } 36 37 return urlParts[0] + (pars.length > 0 ? '?' + pars.join('&') : ''); 38 } 39 40 return url; 41 }; 42 43 woodmartThemeModule.removeDuplicatedStylesFromHTML = function(html, callback) { 44 var $data = $('<div class="temp-wrapper"></div>').append(html); 45 var $links = $data.find('link'); 46 var counter = 0; 47 var timeout = false; 48 49 if (0 === $links.length || 'yes' === woodmart_settings.combined_css) { 50 callback(html); 51 return; 52 } 53 54 setTimeout(function() { 55 if (counter <= $links.length && !timeout) { 56 callback($($data.html())); 57 timeout = true; 58 } 59 }, 500); 60 61 $links.each(function() { 62 var $link = $(this); 63 var id = $link.attr('id'); 64 var href = $link.attr('href'); 65 66 $link.remove(); 67 68 if ('undefined' === typeof woodmart_page_css[id]) { 69 $('head').append($link.on('load', function() { 70 counter++; 71 72 woodmart_page_css[id] = href; 73 74 if (counter >= $links.length && !timeout) { 75 callback($($data.html())); 76 timeout = true; 77 } 78 })); 79 } else { 80 counter++; 81 82 if (counter >= $links.length && !timeout) { 83 callback($($data.html())); 84 timeout = true; 85 } 86 } 87 }); 88 }; 89 90 woodmartThemeModule.debounce = function(func, wait, immediate) { 91 var timeout; 92 return function() { 93 var context = this; 94 var args = arguments; 95 var later = function() { 96 timeout = null; 97 98 if (!immediate) { 99 func.apply(context, args); 100 } 101 }; 102 var callNow = immediate && !timeout; 103 104 clearTimeout(timeout); 105 timeout = setTimeout(later, wait); 106 107 if (callNow) { 108 func.apply(context, args); 109 } 110 }; 111 }; 112 113 woodmartThemeModule.wdElementorAddAction = function(name, callback) { 114 woodmartThemeModule.$window.on('elementor/frontend/init', function() { 115 if (!elementorFrontend.isEditMode()) { 116 return; 117 } 118 119 elementorFrontend.hooks.addAction(name, callback); 120 }); 121 }; 122 123 woodmartThemeModule.wdElementorAddAction('frontend/element_ready/section', function($wrapper) { 124 $wrapper.removeClass('wd-animated'); 125 $wrapper.data('wd-waypoint', ''); 126 $wrapper.removeClass('wd-anim-ready'); 127 woodmartThemeModule.$document.trigger('wdElementorSectionReady'); 128 }); 129 130 woodmartThemeModule.wdElementorAddAction('frontend/element_ready/global', function($wrapper) { 131 if ($wrapper.attr('style') && $wrapper.attr('style').indexOf('transform:translate3d') === 0 && !$wrapper.hasClass('wd-parallax-on-scroll')) { 132 $wrapper.attr('style', ''); 133 } 134 $wrapper.removeClass('wd-animated'); 135 $wrapper.data('wd-waypoint', ''); 136 $wrapper.removeClass('wd-anim-ready'); 137 woodmartThemeModule.$document.trigger('wdElementorGlobalReady'); 138 }); 139 140 woodmartThemeModule.wdElementorAddAction('frontend/element_ready/column', function($wrapper) { 141 if ($wrapper.attr('style') && $wrapper.attr('style').indexOf('transform:translate3d') === 0 && !$wrapper.hasClass('wd-parallax-on-scroll')) { 142 $wrapper.attr('style', ''); 143 } 144 $wrapper.removeClass('wd-animated'); 145 $wrapper.data('wd-waypoint', ''); 146 $wrapper.removeClass('wd-anim-ready'); 147 148 setTimeout(function() { 149 woodmartThemeModule.$document.trigger('wdElementorColumnReady'); 150 }, 100); 151 }); 152 153 woodmartThemeModule.ajaxLinks = '.wd-nav-product-cat a, .widget_product_categories a, .widget_layered_nav_filters a, .woocommerce-widget-layered-nav a, .filters-area:not(.custom-content) a, body.post-type-archive-product:not(.woocommerce-account) .woocommerce-pagination a, body.tax-product_cat:not(.woocommerce-account) .woocommerce-pagination a, .wd-shop-tools a, .woodmart-woocommerce-layered-nav a, .woodmart-price-filter a, .wd-clear-filters a, .woodmart-woocommerce-sort-by a, .woocommerce-widget-layered-nav-list a, .wd-widget-stock-status a'; 154 155 woodmartThemeModule.shopLoadMoreBtn = '.wd-products-load-more.load-on-scroll'; 156 157 woodmartThemeModule.mainCarouselArg = {
158 rtl : woodmartThemeModule.$body.hasClass('rtl'), 159 items : woodmart_settings.product_gallery.thumbs_slider.position === 'centered' ? 2 : 1, 160 autoplay : woodmart_settings.product_slider_autoplay, 161 autoplayTimeout: 3000, 162 loop : woodmart_settings.product_slider_autoplay, 163 center : woodmart_settings.product_gallery.thumbs_slider.position === 'centered', 164 startPosition : woodmart_settings.product_gallery.thumbs_slider.position === 'centered' ? woodmart_settings.centered_gallery_start : 0, 165 dots : false, 166 nav : true, 167 autoHeight : woodmart_settings.product_slider_auto_height === 'yes', 168 navText : false, 169 navClass : [ 170 'owl-prev wd-btn-arrow', 171 'owl-next wd-btn-arrow' 172 ] 173 }; 174 175 woodmartThemeModule.$window.on('elementor/frontend/init', function() { 176 if (!elementorFrontend.isEditMode()) { 177 return; 178 } 179 180 if ('enabled' === woodmart_settings.elementor_no_gap) { 181 elementorFrontend.hooks.addAction('frontend/element_ready/section', function($wrapper) { 182 var cid = $wrapper.data('model-cid'); 183 184 if (typeof elementorFrontend.config.elements.data[cid] !== 'undefined') { 185 var size = elementorFrontend.config.elements.data[cid].attributes.content_width.size; 186 187 if (!size) { 188 $wrapper.addClass('wd-negative-gap'); 189 } 190 } 191 }); 192 193 elementor.channels.editor.on('change:section', function(view) { 194 var changed = view.elementSettingsModel.changed; 195 196 if (typeof changed.content_width !== 'undefined') { 197 var sectionId = view._parent.model.id; 198 var $section = $('.elementor-element-' + sectionId); 199 var size = changed.content_width.size; 200 201 if (size) { 202 $section.removeClass('wd-negative-gap'); 203 } else { 204 $section.addClass('wd-negative-gap'); 205 } 206 } 207 }); 208 } 209 }); 210 211 woodmartThemeModule.$window.on('load', function() { 212 $('.wd-preloader').delay(parseInt(woodmart_settings.preloader_delay)).addClass('preloader-hide'); 213 $('.wd-preloader-style').remove(); 214 setTimeout(function() { 215 $('.wd-preloader').remove(); 216 }, 200); 217 }); 218})(jQuery); 219 220window.onload = function() { 221 var events = [ 222 'keydown', 223 'scroll', 224 'mouseover', 225 'touchmove', 226 'touchstart', 227 'mousedown', 228 'mousemove' 229 ]; 230 231 var triggerListener = function(e) { 232 jQuery(window).trigger('wdEventStarted'); 233 removeListener(); 234 }; 235 236 var removeListener = function() { 237 events.forEach(function(eventName) { 238 window.removeEventListener(eventName, triggerListener); 239 }); 240 }; 241 242 var addListener = function(eventName) { 243 window.addEventListener(eventName, triggerListener); 244 }; 245 246 events.forEach(function(eventName) { 247 addListener(eventName); 248 }); 249}; 250/* global woodmart_settings */ 251(function($) { 252 woodmartThemeModule.adminBarSliderMenu = function() { 253 var $sliderWrapper = $('.wd-slider-wrapper'); 254 var $adminBar = $('#wpadminbar'); 255 256 if ($sliderWrapper.length > 0 && $adminBar.length > 0) { 257 $adminBar.find('#wp-admin-bar-theme-dashboard #wp-admin-bar-theme-dashboard-default').append('<li id="wp-admin-bar-woodmart_slider" class="menupop"><a class="ab-item" href="/wp-admin/edit.php?post_type=woodmart_slide">Slider<span class="wp-admin-bar-arrow" aria-hidden="true"></span></a><div class="ab-sub-wrapper"><ul class="ab-submenu"></ul></div></li>'); 258 259 $sliderWrapper.each(function() { 260 var $slider = $(this); 261 var sliderId = $slider.data('id'); 262 var sliderData = woodmart_admin_bar_sliders[sliderId]; 263 var $sliderSubMenu = $('#wp-admin-bar-woodmart_slider > .ab-sub-wrapper > .ab-submenu'); 264 if (!sliderData) { 265 return; 266 } 267 268 $sliderSubMenu.append('<li id="' + sliderId + '" class="menupop"><a href="' + sliderData.url + '" class="ab-item" target="_blank">' + sliderData.title + '<span class="wp-admin-bar-arrow" aria-hidden="true"></span></a><div class="ab-sub-wrapper"><ul class="ab-submenu"></ul></div></li>'); 269 270 $slider.find('.wd-slide').each(function() { 271 var $slide = $(this); 272 var slideId = $slide.data('id'); 273 var slideData = sliderData.slides[slideId]; 274 275 $sliderSubMenu.find('#' + sliderId + ' > .ab-sub-wrapper > .ab-submenu').append('<li><a href="' + slideData.url + '" class="ab-item" target="_blank">' + slideData.title + '</a></li>'); 276 }); 277 }); 278 } 279 }; 280 281 woodmartThemeModule.adminBarSliderMenu(); 282})(jQuery); 283 284/* global woodmart_settings */ 285(function($) { 286 $.each([ 287 'frontend/element_ready/wd_blog.default', 288 ], function(index, value) { 289 woodmartThemeModule.wdElementorAddAction(value, function() { 290 woodmartThemeModule.blogLoadMore(); 291 }); 292 }); 293 294 woodmartThemeModule.blogLoadMore = function() { 295 var btnClass = '.wd-blog-load-more.load-on-scroll', 296 process = false;
297 298 woodmartThemeModule.clickOnScrollButton(btnClass, false, false); 299 300 $('.wd-blog-load-more').on('click', function(e) { 301 e.preventDefault(); 302 303 var $this = $(this); 304 305 if (process || $this.hasClass('no-more-posts')) { 306 return; 307 } 308 309 process = true; 310 311 var holder = $this.parent().siblings('.wd-blog-holder'), 312 source = holder.data('source'), 313 action = 'woodmart_get_blog_' + source, 314 ajaxurl = woodmart_settings.ajaxurl, 315 dataType = 'json', 316 method = 'POST', 317 atts = holder.data('atts'), 318 paged = holder.data('paged'); 319 320 $this.addClass('loading'); 321 322 var data = { 323 atts : atts, 324 paged : paged, 325 action: action 326 }; 327 328 if (source === 'main_loop') { 329 ajaxurl = $this.attr('href'); 330 method = 'GET'; 331 data = {}; 332 } 333 334 $.ajax({ 335 url : ajaxurl, 336 data : data, 337 dataType: dataType, 338 method : method, 339 success : function(data) { 340 woodmartThemeModule.removeDuplicatedStylesFromHTML(data.items, function(html) { 341 var items = $(html); 342 343 if (items) { 344 if (holder.hasClass('masonry-container')) { 345 holder.append(items).isotope('appended', items); 346 holder.imagesLoaded().progress(function() { 347 holder.isotope('layout'); 348 woodmartThemeModule.clickOnScrollButton(btnClass, true, false); 349 }); 350 } else { 351 holder.append(items); 352 holder.imagesLoaded().progress(function() { 353 woodmartThemeModule.clickOnScrollButton(btnClass, true, false); 354 }); 355 } 356 357 if ('yes' === woodmart_settings.load_more_button_page_url){ 358 window.history.pushState('', '', data.currentPage); 359 } 360 holder.data('paged', paged + 1); 361 362 if (source === 'main_loop') { 363 $this.attr('href', data.nextPage); 364 if (data.status === 'no-more-posts') { 365 $this.hide().remove(); 366 } 367 } 368 } 369 370 if (data.status === 'no-more-posts') { 371 $this.addClass('no-more-posts'); 372 $this.hide(); 373 } 374 }); 375 }, 376 error : function() { 377 console.log('ajax error'); 378 }, 379 complete: function() { 380 $this.removeClass('loading'); 381 process = false; 382 } 383 }); 384 }); 385 }; 386 387 $(document).ready(function() { 388 woodmartThemeModule.blogLoadMore(); 389 }); 390})(jQuery); 391 392/* global woodmart_settings */ 393(function($) { 394 $.each([ 395 'frontend/element_ready/wd_banner_carousel.default', 396 'frontend/element_ready/wd_banner.default', 397 ], function(index, value) { 398 woodmartThemeModule.wdElementorAddAction(value, function() { 399 woodmartThemeModule.bannersHover(); 400 }); 401 }); 402 403 woodmartThemeModule.bannersHover = function() { 404 if (typeof ($.fn.panr) === 'undefined') { 405 return; 406 } 407 408 $('.promo-banner.banner-hover-parallax').panr({ 409 sensitivity : 20, 410 scale : false, 411 scaleOnHover : true, 412 scaleTo : 1.15, 413 scaleDuration : .34, 414 panY : true, 415 panX : true, 416 panDuration : 0.5, 417 resetPanOnMouseLeave: true 418 }); 419 }; 420 421 $(document).ready(function() { 422 woodmartThemeModule.bannersHover(); 423 }); 424})(jQuery); 425 426/* global woodmart_settings */ 427(function($) { 428 woodmartThemeModule.buttonSmoothScroll = function() { 429 $('.wd-button-wrapper.wd-smooth-scroll a').on('click', function(e) { 430 e.stopPropagation(); 431 e.preventDefault(); 432 433 var $button = $(this); 434 var time = $button.parent().data('smooth-time'); 435 var offset = $button.parent().data('smooth-offset'); 436 var hash = $button.attr('href').split('#')[1]; 437 438 var $anchor = $('#' + hash); 439 440 if ($anchor.length < 1) { 441 return; 442 } 443 444 var position = $anchor.offset().top; 445 446 $('html, body').animate({ 447 scrollTop: position - offset 448 }, time); 449 }); 450 }; 451 452 $(document).ready(function() { 453 woodmartThemeModule.buttonSmoothScroll(); 454 }); 455})(jQuery); 456 457/* global woodmart_settings */ 458(function($) { 459 $.each([ 460 'frontend/element_ready/wd_popup.default', 461 ], function(index, value) { 462 woodmartThemeModule.wdElementorAddAction(value, function() { 463 woodmartThemeModule.contentPopup(); 464 }); 465 }); 466 467 woodmartThemeModule.contentPopup = function() { 468 if ('undefined' === typeof $.fn.magnificPopup) { 469 return; 470 } 471 472 $('.wd-open-popup').magnificPopup({ 473 type : 'inline', 474 removalDelay: 500, //delay removal by X to allow out-animation
475 tClose : woodmart_settings.close, 476 tLoading : woodmart_settings.loading, 477 callbacks : { 478 beforeOpen: function() { 479 this.st.mainClass = 'mfp-move-horizontal content-popup-wrapper'; 480 }, 481 open : function() { 482 woodmartThemeModule.$document.trigger('wood-images-loaded'); 483 } 484 } 485 }); 486 }; 487 488 $(document).ready(function() { 489 woodmartThemeModule.contentPopup(); 490 }); 491})(jQuery); 492 493/* global woodmart_settings */ 494(function($) { 495 woodmartThemeModule.$document.on('wdProductsTabsLoaded wdUpdateWishlist wdShopPageInit', function () { 496 woodmartThemeModule.countDownTimer(); 497 }); 498 499 $.each([ 500 'frontend/element_ready/wd_products.default', 501 'frontend/element_ready/wd_products_tabs.default', 502 'frontend/element_ready/wd_countdown_timer.default', 503 ], function(index, value) { 504 woodmartThemeModule.wdElementorAddAction(value, function() { 505 woodmartThemeModule.countDownTimer(); 506 }); 507 }); 508 509 woodmartThemeModule.countDownTimer = function() { 510 $('.wd-timer').each(function() { 511 var $this = $(this); 512 dayjs.extend(window.dayjs_plugin_utc); 513 dayjs.extend(window.dayjs_plugin_timezone); 514 var time = dayjs.tz($this.data('end-date'), $this.data('timezone')); 515 $this.countdown(time.toDate(), function(event) { 516 $this.html(event.strftime('' 517 + '<span class="countdown-days">%-D <span>' + woodmart_settings.countdown_days + '</span></span> ' 518 + '<span class="countdown-hours">%H <span>' + woodmart_settings.countdown_hours + '</span></span> ' 519 + '<span class="countdown-min">%M <span>' + woodmart_settings.countdown_mins + '</span></span> ' 520 + '<span class="countdown-sec">%S <span>' + woodmart_settings.countdown_sec + '</span></span>')); 521 }); 522 }); 523 }; 524 525 $(document).ready(function() { 526 woodmartThemeModule.countDownTimer(); 527 }); 528})(jQuery); 529 530/* global woodmart_settings */ 531(function($) { 532 $.each([ 533 'frontend/element_ready/wd_counter.default' 534 ], function(index, value) { 535 woodmartThemeModule.wdElementorAddAction(value, function() { 536 woodmartThemeModule.visibleElements(); 537 }); 538 }); 539 540 woodmartThemeModule.counterShortcode = function(counter) { 541 if (counter.attr('data-state') === 'done' || parseInt(counter.text()) !== counter.data('final')) { 542 return; 543 } 544 545 counter.prop('Counter', 0).animate({ 546 Counter: counter.text() 547 }, { 548 duration: 3000, 549 easing : 'swing', 550 step : function(now) { 551 if (now >= counter.data('final')) { 552 counter.attr('data-state', 'done'); 553 } 554 555 counter.text(Math.ceil(now)); 556 } 557 }); 558 }; 559 560 woodmartThemeModule.visibleElements = function() { 561 $('.woodmart-counter .counter-value').each(function() { 562 var $this = $(this); 563 564 $this.waypoint(function() { 565 woodmartThemeModule.counterShortcode($this); 566 }, {offset: '100%'}); 567 }); 568 }; 569 570 $(document).ready(function() { 571 woodmartThemeModule.visibleElements(); 572 }); 573})(jQuery); 574 575/* global woodmart_settings */ 576(function($) { 577 $.each([ 578 'frontend/element_ready/wd_google_map.default', 579 ], function(index, value) { 580 woodmartThemeModule.wdElementorAddAction(value, function() { 581 woodmartThemeModule.googleMapInit(); 582 }); 583 }); 584 585 woodmartThemeModule.googleMapInit = function() { 586 $('.google-map-container').each(function() { 587 var $map = $(this); 588 var data = $map.data('map-args'); 589 590 var config = { 591 locations : [ 592 { 593 lat : data.latitude, 594 lon : data.longitude, 595 icon : data.marker_icon, 596 animation: google.maps.Animation.DROP 597 } 598 ], 599 controls_on_map: false, 600 map_div : '#' + data.selector, 601 start : 1, 602 map_options : { 603 zoom : parseInt(data.zoom), 604 scrollwheel: 'yes' === data.mouse_zoom 605 } 606 }; 607 608 if (data.json_style && !data.elementor) { 609 config.styles = {}; 610 config.styles[woodmart_settings.google_map_style_text] = $.parseJSON(data.json_style); 611 } else if (data.json_style && data.elementor) { 612 config.styles = {}; 613 config.styles[woodmart_settings.google_map_style_text] = $.parseJSON(atob(data.json_style)); 614 } 615 616 if ('yes' === data.marker_text_needed) { 617 config.locations[0].html = data.marker_text; 618 } 619 620 if ('button' === data.init_type) { 621 $map.find('.wd-init-map').on('click', function(e) { 622 e.preventDefault(); 623 624 if ($map.hasClass('wd-map-inited')) { 625 return; 626 } 627 628 $map.addClass('wd-map-inited'); 629 new Maplace(config).Load(); 630 }); 631 } else if ('scroll' === data.init_type) { 632 woodmartThemeModule.$window.on('scroll', function() { 633 if (window.innerHeight + woodmartThemeModule.$window.scrollTop() + parseInt(data.init_offset) > $map.offset().top) { 634 if ($map.hasClass('wd-map-inited')) { 635 return; 636 } 637 638 $map.addClass('wd-map-inited'); 639 new Maplace(config).Load(); 640 } 641 }); 642 } else if ('interaction' === data.init_type) { 643 woodmartThemeModule.$window.on('wdEventStarted', function() { 644 new Maplace(config).Load(); 645 }); 646 } else { 647 new Maplace(config).Load(); 648 } 649 }); 650 651 var $gmap = $('.google-map-container-with-content'); 652 653 woodmartThemeModule.$window.on('resize', function() { 654 $gmap.css({ 655 'height': $gmap.find('.wd-google-map.with-content').outerHeight() 656 }); 657 }); 658 }; 659 660 $(document).ready(function() {
661 woodmartThemeModule.googleMapInit(); 662 }); 663})(jQuery); 664 665/* global woodmart_settings */ 666(function($) { 667 $.each([ 668 'frontend/element_ready/wd_image_hotspot.default', 669 ], function(index, value) { 670 woodmartThemeModule.wdElementorAddAction(value, function() { 671 woodmartThemeModule.imageHotspot(); 672 }); 673 }); 674 675 woodmartThemeModule.imageHotspot = function() { 676 $('.wd-image-hotspot').each(function() { 677 var _this = $(this); 678 var btn = _this.find('.hotspot-btn'); 679 var parentWrapper = _this.parents('.wd-image-hotspot-wrapper'); 680 681 if (!parentWrapper.hasClass('hotspot-action-click') && woodmartThemeModule.$window.width() > 1024) { 682 return; 683 } 684 685 btn.on('click', function() { 686 if (_this.hasClass('hotspot-opened')) { 687 _this.removeClass('hotspot-opened'); 688 } else { 689 _this.addClass('hotspot-opened'); 690 _this.siblings().removeClass('hotspot-opened'); 691 } 692 693 woodmartThemeModule.$document.trigger('wood-images-loaded'); 694 return false; 695 }); 696 697 woodmartThemeModule.$document.on('click', function(e) { 698 var target = e.target; 699 700 if (_this.hasClass('hotspot-opened') && !$(target).is('.wd-image-hotspot') && !$(target).parents().is('.wd-image-hotspot')) { 701 _this.removeClass('hotspot-opened'); 702 return false; 703 } 704 }); 705 }); 706 707 //Image loaded 708 $('.wd-image-hotspot-wrapper').each(function() { 709 var _this = $(this); 710 _this.imagesLoaded(function() { 711 _this.addClass('loaded'); 712 }); 713 }); 714 715 $('.wd-image-hotspot .hotspot-content').each(function() { 716 var content = $(this); 717 var offsetLeft = content.offset().left; 718 var offsetRight = woodmartThemeModule.$window.width() - (offsetLeft + content.outerWidth()); 719 720 if (woodmartThemeModule.$window.width() > 768) { 721 if (offsetLeft <= 0) { 722 content.addClass('hotspot-overflow-right'); 723 } 724 if (offsetRight <= 0) { 725 content.addClass('hotspot-overflow-left'); 726 } 727 } 728 729 if (woodmartThemeModule.$window.width() <= 768) { 730 if (offsetLeft <= 0) { 731 content.css('marginLeft', Math.abs(offsetLeft - 15) + 'px'); 732 } 733 if (offsetRight <= 0) { 734 content.css('marginLeft', offsetRight - 15 + 'px'); 735 } 736 } 737 }); 738 }; 739 740 $(document).ready(function() { 741 woodmartThemeModule.imageHotspot(); 742 }); 743})(jQuery); 744 745/* global woodmart_settings */ 746(function($) { 747 $.each([ 748 'frontend/element_ready/wd_images_gallery.default' 749 ], function(index, value) { 750 woodmartThemeModule.wdElementorAddAction(value, function() { 751 woodmartThemeModule.imagesGalleryMasonry(); 752 woodmartThemeModule.imagesGalleryJustified(); 753 }); 754 }); 755 756 woodmartThemeModule.imagesGalleryMasonry = function() { 757 if (typeof ($.fn.isotope) == 'undefined' || typeof ($.fn.imagesLoaded) == 'undefined') { 758 return; 759 } 760 761 var $container = $('.view-masonry .gallery-images'); 762 763 $container.imagesLoaded(function() { 764 $container.isotope({ 765 gutter : 0, 766 isOriginLeft: !woodmartThemeModule.$body.hasClass('rtl'), 767 itemSelector: '.wd-gallery-item' 768 }); 769 }); 770 }; 771 772 woodmartThemeModule.imagesGalleryJustified = function() { 773 $('.view-justified').each(function() { 774 $(this).find('.gallery-images').justifiedGallery({ 775 margins : 1, 776 cssAnimation: true 777 }); 778 }); 779 }; 780 781 $(document).ready(function() { 782 woodmartThemeModule.imagesGalleryMasonry(); 783 woodmartThemeModule.imagesGalleryJustified(); 784 }); 785})(jQuery); 786 787/* global woodmart_settings */ 788(function($) { 789 $.each([ 790 'frontend/element_ready/wd_infobox_carousel.default', 791 'frontend/element_ready/wd_infobox.default' 792 ], function(index, value) { 793 woodmartThemeModule.wdElementorAddAction(value, function() { 794 woodmartThemeModule.infoboxSvg(); 795 }); 796 }); 797 798 woodmartThemeModule.infoboxSvg = function() { 799 $('.wd-info-box.with-animation').each(function() { 800 var $this = $(this); 801 802 if ($this.find('.info-svg-wrapper > svg').length > 0) { 803 new Vivus($this.find('.info-svg-wrapper > svg')[0], { 804 type : 'delayed', 805 duration : 200, 806 start : 'inViewport', 807 animTimingFunction: Vivus.EASE_OUT 808 }, function() {}); 809 } 810 }); 811 }; 812 813 $(document).ready(function() { 814 woodmartThemeModule.infoboxSvg(); 815 }); 816})(jQuery); 817 818/* global woodmart_settings */ 819(function($) { 820 woodmartThemeModule.instagramAjaxQuery = function() { 821 $('.instagram-widget').each(function() { 822 var $instagram = $(this); 823 824 if (!$instagram.hasClass('instagram-with-error')) { 825 return; 826 } 827 828 var username = $instagram.data('username'); 829 var atts = $instagram.data('atts'); 830 var request_param = username.indexOf('#') > -1 ? 'explore/tags/' + username.substr(1) : username; 831 var url = 'https://www.instagram.com/' + request_param + '/'; 832 833 $instagram.addClass('loading'); 834 835 $.ajax({ 836 url : url, 837 success: function(response) { 838 $.ajax({
839 url : woodmart_settings.ajaxurl, 840 data : { 841 action: 'woodmart_instagram_ajax_query', 842 body : response, 843 atts : atts 844 }, 845 dataType: 'json', 846 method : 'POST', 847 success : function(response) { 848 $instagram.parent().html(response); 849 woodmartThemeModule.$document.trigger('wdInstagramAjaxSuccess'); 850 }, 851 error : function() { 852 console.log('instagram ajax error'); 853 } 854 }); 855 }, 856 error : function() { 857 console.log('instagram ajax error'); 858 } 859 }); 860 }); 861 }; 862 863 $(document).ready(function() { 864 woodmartThemeModule.instagramAjaxQuery(); 865 }); 866})(jQuery); 867 868/* global woodmart_settings */ 869(function($) { 870 $.each([ 871 'frontend/element_ready/wd_slider.default' 872 ], function(index, value) { 873 woodmartThemeModule.wdElementorAddAction(value, function() { 874 woodmartThemeModule.sliderAnimations(); 875 woodmartThemeModule.carouselInitFlickity(); 876 woodmartThemeModule.sliderLazyLoad(); 877 }); 878 }); 879 880 woodmartThemeModule.sliderClearAnimations = function($active, firstLoad) { 881 // WPB clear on first load first slide. 882 if (firstLoad) { 883 $active.find('[class*="wpb_animate"]').each(function() { 884 var $this = $(this); 885 var classes = $this.attr('class').split(' '); 886 var name; 887 888 for (var index = 0; index < classes.length; index++) { 889 if (classes[index].indexOf('wd-anim-name_') >= 0) { 890 name = classes[index].split('_')[1]; 891 } 892 } 893 894 $this.removeClass('wpb_start_animation animated').removeClass(name); 895 }); 896 } 897 898 // WPB clear all siblings slides. 899 $active.siblings().find('[class*="wpb_animate"]').each(function() { 900 var $this = $(this); 901 var classes = $this.attr('class').split(' '); 902 var delay = 0; 903 var name; 904 905 for (var index = 0; index < classes.length; index++) { 906 if (classes[index].indexOf('wd-anim-delay_') >= 0) {
907 delay = parseInt(classes[index].split('_')[1]); 908 } 909 910 if (classes[index].indexOf('wd-anim-name_') >= 0) { 911 name = classes[index].split('_')[1]; 912 } 913 } 914 915 setTimeout(function() { 916 $this.removeClass('wpb_start_animation animated').removeClass(name); 917 }, delay); 918 }); 919 }; 920 921 woodmartThemeModule.sliderAnimations = function() { 922 $('.wd-slider').each(function() { 923 var $carousel = $(this); 924 925 $carousel.find('[class*="wd-animation"]').each(function() { 926 $(this).addClass('wd-animation-ready'); 927 }); 928 929 runAnimations(0, true); 930 931 $carousel.on('change.flickity', function(event, index) { 932 runAnimations(index, false); 933 }); 934 935 function runAnimations(slideIndex, firstLoad) { 936 var $active = $carousel.find('.wd-slide').eq(slideIndex); 937 938 woodmartThemeModule.sliderClearAnimations($active, firstLoad); 939 woodmartThemeModule.runAnimations($active, firstLoad); 940 } 941 }); 942 }; 943 944 woodmartThemeModule.runAnimations = function($active, firstLoad) { 945 // Elementor. 946 $active.siblings().find('[class*="wd-animation"]').removeClass('wd-animated'); 947 948 $active.find('[class*="wd-animation"]').each(function() { 949 var $this = $(this); 950 var classes = $this.attr('class').split(' '); 951 var delay = 0; 952 953 for (var index = 0; index < classes.length; index++) { 954 if (classes[index].indexOf('wd_delay_') >= 0) {
955 delay = parseInt(classes[index].split('_')[2]); 956 } 957 } 958 959 if (firstLoad) { 960 delay += 500; 961 } 962 963 setTimeout(function() { 964 $this.addClass('wd-animated'); 965 }, delay); 966 }); 967 968 // WPB. 969 $active.find('[class*="wpb_animate"]').each(function() { 970 var $this = $(this); 971 var classes = $this.attr('class').split(' '); 972 var delay = 0; 973 var name; 974 975 for (var index = 0; index < classes.length; index++) { 976 if (classes[index].indexOf('wd-anim-delay_') >= 0) { 977 delay = parseInt(classes[index].split('_')[1]); 978 } 979 980 if (classes[index].indexOf('wd-anim-name_') >= 0) { 981 name = classes[index].split('_')[1]; 982 } 983 } 984 985 if (firstLoad) { 986 delay += 500; 987 } 988 989 setTimeout(function() { 990 $this.removeClass('wd-off-anim').addClass('wpb_start_animation animated').addClass(name); 991 }, delay); 992 }); 993 }; 994 995 woodmartThemeModule.sliderLazyLoad = function() { 996 woodmartThemeModule.$window.on('wdEventStarted', function() { 997 $('.wd-slider').each(function() { 998 load(0, $(this)); 999 }); 1000 }); 1001 1002 $('.wd-slider').on('change.flickity', function(event, index) { 1003 load(index, $(this)); 1004 }); 1005 1006 function load(index, $slider) { 1007 var active = $slider.find('.wd-slide').eq(index); 1008 var $els = $slider.find('[id="' + active.attr('id') + '"]'); 1009 1010 $slider.find('.wd-slide').eq(index + 1).addClass('woodmart-loaded'); 1011 active.addClass('woodmart-loaded'); 1012 1013 $els.each(function() { 1014 $(this).addClass('woodmart-loaded'); 1015 }); 1016 } 1017 }; 1018 1019 woodmartThemeModule.carouselInitFlickity = function() { 1020 if (woodmartThemeModule.$body.hasClass('single-woodmart_slide')) { 1021 return; 1022 } 1023 1024 $('.wd-slider-wrapper:not(.scroll-init)').each(function() { 1025 init($(this)); 1026 }); 1027 1028 if (typeof ($.fn.waypoint) != 'undefined') { 1029 $('.wd-slider-wrapper.scroll-init').waypoint(function() { 1030 var $this = $($(this)[0].element); 1031 init($this); 1032 }, { 1033 offset: '100%' 1034 }); 1035 } 1036 1037 function init($carousel) { 1038 if (woodmartThemeModule.windowWidth <= 1024 && $carousel.hasClass('disable-owl-mobile')) { 1039 return; 1040 } 1041 1042 var loop = true; 1043 1044 // Fix fade glitch with two slide. 1045 if (($carousel.hasClass('anim-fade') || $carousel.hasClass('anim-parallax')) && $carousel.find('.wd-slide').length <= 2) { 1046 loop = false; 1047 } 1048 1049 var config = { 1050 contain : true, 1051 percentPosition : true, 1052 cellAlign : 'left', 1053 rightToLeft : woodmartThemeModule.$body.hasClass('rtl'), 1054 pageDots : 'yes' !== $carousel.data('hide_pagination_control'), 1055 prevNextButtons : 'yes' !== $carousel.data('hide_prev_next_buttons'), 1056 autoPlay : 'yes' !== $carousel.data('autoplay') ? false : parseInt($carousel.data('speed')), 1057 pauseAutoPlayOnHover: 'yes' !== $carousel.data('autoplay'), 1058 adaptiveHeight : true, 1059 imagesLoaded : true, 1060 wrapAround : loop, 1061 fade : $carousel.hasClass('anim-fade'), 1062 on : { 1063 ready: function() { 1064 setTimeout(function() { 1065 woodmartThemeModule.$document.trigger('wdCarouselFlickityInited'); 1066 }, 100); 1067 } 1068 } 1069 }; 1070 1071 $carousel.find('.wd-slider').flickity(config); 1072 1073 setTimeout(function() { 1074 $carousel.find('.wd-slider').addClass('wd-enabled'); 1075 }, 100); 1076 1077 $carousel.find('.wd-slider').on('dragStart.flickity', function() { 1078 $carousel.find('.wd-slider').addClass('wd-dragging'); 1079 }); 1080 1081 $carousel.find('.wd-slider').on('dragEnd.flickity', function() { 1082 $carousel.find('.wd-slider').removeClass('wd-dragging'); 1083 }); 1084 1085 if ($carousel.hasClass('anim-parallax')) { 1086 var flkty = $carousel.find('.wd-slider').data('flickity'); 1087 var $imgs = $('.wd-slide .wd-slide-bg'); 1088 1089 $carousel.find('.wd-slider').on('scroll.flickity', function() { 1090 flkty.slides.forEach(function(e, i) { 1091 var img = $imgs[i]; 1092 1093 var x = 0 === i 1094 ? Math.abs(flkty.x) > flkty.slidesWidth 1095 ? flkty.slidesWidth + flkty.x + flkty.slides[flkty.slides.length - 1].outerWidth + e.target 1096 : e.target + flkty.x 1097 : i === flkty.slides.length - 1 && Math.abs(flkty.x) + flkty.slides[i].outerWidth < flkty.slidesWidth 1098 ? e.target - flkty.slidesWidth + flkty.x - flkty.slides[i].outerWidth 1099 : e.target + flkty.x; 1100 1101 img.style.transform = 'translateX( ' + -.5 * x + 'px)'; 1102 }); 1103 }); 1104 } 1105 } 1106 }; 1107 1108 $(document).ready(function() { 1109 woodmartThemeModule.sliderAnimations(); 1110 woodmartThemeModule.carouselInitFlickity(); 1111 woodmartThemeModule.sliderLazyLoad(); 1112 }); 1113})(jQuery); 1114 1115/* global woodmart_settings */ 1116(function($) { 1117 woodmartThemeModule.videoPoster = function() { 1118 $('.wd-video-poster-wrapper').on('click', function() { 1119 var videoWrapper = $(this), 1120 video = videoWrapper.parent().find('iframe'), 1121 videoScr = video.attr('src'), 1122 videoNewSrc = videoScr + '&autoplay=1'; 1123 1124 if (videoScr.indexOf('vimeo.com') + 1) { 1125 videoNewSrc = videoScr + '?autoplay=1'; 1126 } 1127 1128 video.attr('src', videoNewSrc); 1129 videoWrapper.addClass('hidden-poster'); 1130 }); 1131 }; 1132 1133 $(document).ready(function() { 1134 woodmartThemeModule.videoPoster(); 1135 }); 1136})(jQuery); 1137 1138/* global woodmart_settings */ 1139(function($) { 1140 $.each([ 1141 'frontend/element_ready/wd_3d_view.default' 1142 ], function(index, value) { 1143 woodmartThemeModule.wdElementorAddAction(value, function() { 1144 woodmartThemeModule.view3d(); 1145 }); 1146 }); 1147 1148 woodmartThemeModule.view3d = function() { 1149 $('.wd-threed-view:not(.wd-product-threed)').each(function() { 1150 init($(this)); 1151 }); 1152 1153 $('.product-360-button a').on('click', function(e) { 1154 e.preventDefault(); 1155 init($('.wd-threed-view.wd-product-threed')); 1156 }); 1157 1158 function init($this) { 1159 var data = $this.data('args'); 1160 1161 if (!data || $this.hasClass('wd-threed-view-inited')) { 1162 return false;
1163 } 1164 1165 $this.ThreeSixty({ 1166 totalFrames : data.frames_count, 1167 endFrame : data.frames_count, 1168 currentFrame: 1, 1169 imgList : '.threed-view-images', 1170 progress : '.spinner', 1171 imgArray : data.images, 1172 height : data.height, 1173 width : data.width, 1174 responsive : true, 1175 navigation : true, 1176 framerate : woodmart_settings.three_sixty_framerate, 1177 }); 1178 1179 $this.addClass('wd-threed-view-inited'); 1180 } 1181 }; 1182 1183 $(document).ready(function() { 1184 woodmartThemeModule.view3d(); 1185 }); 1186})(jQuery); 1187 1188/* global woodmart_settings */ 1189(function($) { 1190 woodmartThemeModule.ageVerify = function() { 1191 if (woodmart_settings.age_verify !== 'yes' || Cookies.get('woodmart_age_verify') === 'confirmed') { 1192 return; 1193 } 1194 1195 $.magnificPopup.open({ 1196 items : { 1197 src: '.wd-age-verify' 1198 }, 1199 type : 'inline', 1200 closeOnBgClick : false, 1201 closeBtnInside : false, 1202 showCloseBtn : false, 1203 enableEscapeKey: false, 1204 removalDelay : 500, 1205 tClose : woodmart_settings.close, 1206 tLoading : woodmart_settings.loading, 1207 callbacks : { 1208 beforeOpen: function() { 1209 this.st.mainClass = 'mfp-move-horizontal wd-promo-popup-wrapper'; 1210 } 1211 } 1212 }); 1213 1214 $('.wd-age-verify-allowed').on('click', function() { 1215 Cookies.set('woodmart_age_verify', 'confirmed', { 1216 expires: parseInt(woodmart_settings.age_verify_expires), 1217 path : '/' 1218 }); 1219 1220 $.magnificPopup.close(); 1221 }); 1222 1223 $('.wd-age-verify-forbidden').on('click', function() { 1224 $('.wd-age-verify').addClass('wd-forbidden'); 1225 }); 1226 }; 1227 1228 $(document).ready(function() { 1229 woodmartThemeModule.ageVerify(); 1230 }); 1231})(jQuery); 1232 1233/* global woodmart_settings */ 1234(function($) { 1235 woodmartThemeModule.$document.on('wdShopPageInit', function () { 1236 woodmartThemeModule.ajaxSearch(); 1237 }); 1238 1239 $.each([ 1240 'frontend/element_ready/wd_search.default' 1241 ], function(index, value) { 1242 woodmartThemeModule.wdElementorAddAction(value, function() { 1243 woodmartThemeModule.ajaxSearch(); 1244 }); 1245 }); 1246 1247 woodmartThemeModule.ajaxSearch = function() { 1248 if (typeof ($.fn.devbridgeAutocomplete) == 'undefined') { 1249 return; 1250 } 1251 1252 var escapeRegExChars = function(value) { 1253 return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); 1254 }; 1255 1256 $('form.woodmart-ajax-search').each(function() { 1257 var $this = $(this), 1258 number = parseInt($this.data('count')), 1259 thumbnail = parseInt($this.data('thumbnail')), 1260 symbols_count = parseInt($this.data('symbols_count')), 1261 productCat = $this.find('[name="product_cat"]'), 1262 $results = $this.parent().find('.wd-dropdown-results > .wd-scroll-content'), 1263 postType = $this.data('post_type'), 1264 url = woodmart_settings.ajaxurl + '?action=woodmart_ajax_search', 1265 price = parseInt($this.data('price')), 1266 sku = $this.data('sku'); 1267 1268 if (number > 0) { 1269 url += '&number=' + number; 1270 } 1271 url += '&post_type=' + postType; 1272 1273 $results.on('click', '.view-all-results', function() { 1274 $this.submit(); 1275 }); 1276 1277 if (productCat.length && productCat.val() !== '') { 1278 url += '&product_cat=' + productCat.val(); 1279 } 1280 1281 $this.find('[type="text"]').on('focus keyup', function() { 1282 var $input = $(this); 1283 1284 if ($input.hasClass('wd-search-inited')) { 1285 return; 1286 } 1287 1288 $input.devbridgeAutocomplete({ 1289 serviceUrl : url, 1290 appendTo : $results, 1291 minChars : symbols_count, 1292 onSelect : function(suggestion) { 1293 if (suggestion.permalink.length > 0) { 1294 window.location.href = suggestion.permalink; 1295 } 1296 }, 1297 onHide : function() { 1298 $results.parent().removeClass('wd-opened'); 1299 }, 1300 onSearchStart : function() { 1301 $this.addClass('search-loading'); 1302 }, 1303 beforeRender : function(container) { 1304 $(container).find('.suggestion-divider-title').parent().addClass('suggestion-divider'); 1305 if (container[0].childElementCount > 2) { 1306 $(container).append('<div class="view-all-results"><span>' + woodmart_settings.all_results + '</span></div>'); 1307 } 1308 1309 $(container).removeAttr('style'); 1310 }, 1311 onSearchComplete: function() { 1312 $this.removeClass('search-loading'); 1313 1314 woodmartThemeModule.$document.trigger('wood-images-loaded'); 1315 1316 }, 1317 formatResult : function(suggestion, currentValue) { 1318 if (currentValue === '&') { 1319 currentValue = '&'; 1320 } 1321 var pattern = '(' + escapeRegExChars(currentValue) + ')', 1322 returnValue = ''; 1323 1324 if (suggestion.divider) { 1325 returnValue += ' <h5 class="suggestion-divider-title">' + suggestion.divider + '</h5>'; 1326 } 1327 1328 if (thumbnail && suggestion.thumbnail) { 1329 returnValue += ' <div class="suggestion-thumb">' + suggestion.thumbnail + '</div>'; 1330 } 1331 1332 if (suggestion.value) { 1333 returnValue += ' <div class="suggestion-content set-cont-mb-s reset-last-child">'; 1334 returnValue += '<h4 class="wd-entities-title">' + suggestion.value 1335 .replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>') 1336 .replace(/<(\/?strong)>/g, '<$1>') + '</h4>'; 1337 } 1338 1339 if (sku && suggestion.sku) { 1340 returnValue += ' <p class="suggestion-sku">' + suggestion.sku + '</p>'; 1341 } 1342 1343 if (price && suggestion.price) { 1344 returnValue += ' <p class="price">' + suggestion.price + '</p>'; 1345 } 1346 1347 if (suggestion.value) { 1348 returnValue += ' </div>'; 1349 } 1350 1351 if (suggestion.no_found) { 1352 returnValue = '<span class="no-found-msg">' + suggestion.value + '</span>'; 1353 } 1354 1355 $results.parent().addClass('wd-opened'); 1356 1357 return returnValue; 1358 } 1359 }); 1360 1361 if (productCat.length) { 1362 var searchForm = $this.find('[type="text"]').devbridgeAutocomplete(),
1363 serviceUrl = woodmart_settings.ajaxurl + '?action=woodmart_ajax_search'; 1364 1365 if (number > 0) { 1366 serviceUrl += '&number=' + number; 1367 } 1368 1369 serviceUrl += '&post_type=' + postType; 1370 1371 productCat.on('cat_selected', function() { 1372 if (productCat.val() !== '') { 1373 searchForm.setOptions({ 1374 serviceUrl: serviceUrl + '&product_cat=' + productCat.val() 1375 }); 1376 } else { 1377 searchForm.setOptions({ 1378 serviceUrl: serviceUrl 1379 }); 1380 } 1381 1382 searchForm.hide(); 1383 searchForm.onValueChange(); 1384 }); 1385 } 1386 1387 $input.addClass('wd-search-inited'); 1388 }); 1389 1390 1391 woodmartThemeModule.$document.on('click', function(e) { 1392 var target = e.target; 1393 1394 if (!$(target).is('.wd-search-form') && !$(target).parents().is('.wd-search-form') && !$(target).is('.wd-search-full-screen') && !$(target).parents().is('.wd-search-full-screen')) { 1395 $this.find('[type="text"]').devbridgeAutocomplete('hide'); 1396 } 1397 }); 1398 1399 $('.wd-dropdown-results > .wd-scroll-content').on('click', function(e) { 1400 e.stopPropagation(); 1401 }); 1402 }); 1403 }; 1404 1405 $(document).ready(function() { 1406 woodmartThemeModule.ajaxSearch(); 1407 }); 1408})(jQuery); 1409/* global xts_settings */ 1410(function($) { 1411 woodmartThemeModule.$document.on('wdElementorSectionReady wdElementorColumnReady wdElementorGlobalReady', function() { 1412 woodmartThemeModule.animations(); 1413 }); 1414 1415 woodmartThemeModule.animations = function() { 1416 if (typeof $.fn.waypoint === 'undefined') { 1417 return; 1418 } 1419 1420 $('[class*="wd-animation"]').each(function() { 1421 var $element = $(this); 1422 1423 if ('inited' === $element.data('wd-waypoint') || $element.parents('.wd-autoplay-animations-off').length > 0) { 1424 return; 1425 } 1426 1427 $element.data('wd-waypoint', 'inited'); 1428 1429 $element.waypoint(function() { 1430 var $this = $($(this)[0].element); 1431 1432 var classes = $this.attr('class').split(' '); 1433 var delay = 0; 1434 1435 for (var index = 0; index < classes.length; index++) { 1436 if (classes[index].indexOf('wd_delay_') >= 0) { 1437 delay = classes[index].split('_')[2]; 1438 } 1439 } 1440 1441 $this.addClass('wd-animation-ready'); 1442 1443 setTimeout(function() { 1444 $this.addClass('wd-animated'); 1445 }, delay); 1446 }, { 1447 offset: '90%' 1448 }); 1449 }); 1450 }; 1451 1452 $(document).ready(function() { 1453 woodmartThemeModule.animations(); 1454 }); 1455})(jQuery); 1456/* global woodmart_settings */ 1457(function($) { 1458 woodmartThemeModule.animationsOffset = function() { 1459 if (typeof ($.fn.waypoint) == 'undefined') { 1460 return; 1461 } 1462 1463 $('.wpb_animate_when_almost_visible:not(.wpb_start_animation)').waypoint(function() { 1464 var $this = $($(this)[0].element); 1465 $this.addClass('wpb_start_animation animated'); 1466 }, { 1467 offset: '100%' 1468 }); 1469 }; 1470 1471 $(document).ready(function() { 1472 woodmartThemeModule.animationsOffset(); 1473 }); 1474})(jQuery); 1475 1476/* global woodmart_settings */ 1477(function($) { 1478 woodmartThemeModule.$document.on('wdShopPageInit wdBackHistory', function () { 1479 woodmartThemeModule.backHistory(); 1480 }); 1481 1482 woodmartThemeModule.backHistory = function() { 1483 $('.wd-back-btn > a').on('click', function(e) { 1484 e.preventDefault(); 1485 1486 history.go(-1); 1487 1488 setTimeout(function() { 1489 $('.filters-area').removeClass('filters-opened').stop().hide(); 1490 if (woodmartThemeModule.$window.width() <= 1024) { 1491 $('.wd-nav-product-cat').removeClass('categories-opened').stop().hide(); 1492 } 1493 1494 woodmartThemeModule.$document.trigger('wdBackHistory'); 1495 }, 20); 1496 }); 1497 }; 1498 1499 $(document).ready(function() { 1500 woodmartThemeModule.backHistory(); 1501 }); 1502})(jQuery); 1503 1504/* global woodmart_settings */ 1505(function($) { 1506 woodmartThemeModule.$document.on('wdBackHistory wdProductsTabsLoaded wdActionAfterAddToCart wdShopPageInit wdArrowsLoadProducts wdLoadMoreLoadProducts wdUpdateWishlist wdQuickViewOpen wdQuickShopSuccess wdProductBaseHoverIconsResize', function () { 1507 woodmartThemeModule.btnsToolTips(); 1508 }); 1509 1510 $.each([ 1511 'frontend/element_ready/wd_products.default', 1512 'frontend/element_ready/wd_products_tabs.default' 1513 ], function(index, value) { 1514 woodmartThemeModule.wdElementorAddAction(value, function() { 1515 woodmartThemeModule.btnsToolTips(); 1516 }); 1517 }); 1518 1519 woodmartThemeModule.btnsToolTips = function() { 1520 $('.woodmart-css-tooltip, .wd-buttons[class*="wd-pos-r"] div > a').on('mouseenter touchstart', function () { 1521 var $this = $(this); 1522 1523 if (!$this.hasClass('wd-add-img-msg') && $(window).width() <= 1024 || $this.hasClass('wd-tooltip-inited')) { 1524 return; 1525 } 1526 1527 $this.find('.wd-tooltip-label').remove(); 1528 $this.addClass('wd-tltp').prepend('<span class="wd-tooltip-label">' + $this.text() + '</span>'); 1529 1530 var $label = $this.find('.wd-tooltip-label'); 1531 1532 $this.addClass('wd-tooltip-inited'); 1533 }); 1534 1535 // Bootstrap tooltips 1536 if (woodmartThemeModule.windowWidth <= 1024) { 1537 return; 1538 } 1539 1540 $('.wd-tooltip, .wd-hover-icons .wd-buttons .wd-action-btn:not(.wd-add-btn) > a, .wd-hover-icons .wd-buttons .wd-add-btn, body:not(.catalog-mode-on):not(.login-see-prices) .wd-hover-base .wd-bottom-actions .wd-action-btn.wd-style-icon:not(.wd-add-btn) > a, body:not(.catalog-mode-on):not(.login-see-prices) .wd-hover-base .wd-bottom-actions .wd-action-btn.wd-style-icon.wd-add-btn, .wd-hover-base .wd-compare-btn > a, .wd-products-nav .wd-back-btn').on('mouseenter touchstart', function() { 1541 var $this = $(this); 1542 1543 if ($this.hasClass('wd-tooltip-inited')) { 1544 return; 1545 } 1546 1547 $this.tooltip({ 1548 animation: false, 1549 container: 'body', 1550 trigger : 'hover', 1551 boundary: 'window', 1552 title : function() { 1553 var $this = $(this); 1554 1555 if ($this.find('.added_to_cart').length > 0) { 1556 return $this.find('.add_to_cart_button').text(); 1557 } 1558 1559 if ($this.find('.add_to_cart_button').length > 0) { 1560 return $this.find('.add_to_cart_button').text(); 1561 } 1562 1563 return $this.text(); 1564 } 1565 }); 1566 1567 $this.tooltip('show'); 1568 1569 $this.addClass('wd-tooltip-inited'); 1570 }); 1571 }; 1572 1573 $(document).ready(function() { 1574 woodmartThemeModule.btnsToolTips(); 1575 }); 1576})(jQuery); 1577 1578 1579/* global woodmart_settings */ 1580(function($) { 1581 woodmartThemeModule.callPhotoSwipe = function(index, items) { 1582 if (woodmartThemeModule.$body.hasClass('rtl')) { 1583 index = items.length - index - 1; 1584 items = items.reverse(); 1585 } 1586 1587 var options = { 1588 index : index, 1589 shareButtons : [ 1590 { 1591 id : 'facebook',
1592 label: woodmart_settings.share_fb, 1593 url : 'https://www.facebook.com/sharer/sharer.php?u={{url}}' 1594 }, 1595 { 1596 id : 'twitter', 1597 label: woodmart_settings.tweet, 1598 url : 'https://twitter.com/intent/tweet?text={{text}}&url={{url}}' 1599 }, 1600 { 1601 id : 'pinterest', 1602 label: woodmart_settings.pin_it, 1603 url : 'http://www.pinterest.com/pin/create/button/' + 1604 '?url={{url}}&media={{image_url}}&description={{text}}' 1605 }, 1606 { 1607 id : 'download', 1608 label : woodmart_settings.download_image, 1609 url : '{{raw_image_url}}', 1610 download: true 1611 } 1612 ], 1613 closeOnScroll: woodmart_settings.photoswipe_close_on_scroll 1614 }; 1615 1616 woodmartThemeModule.$body.find('.pswp').remove(); 1617 woodmartThemeModule.$body.append(woodmart_settings.photoswipe_template); 1618 var pswpElement = document.querySelectorAll('.pswp')[0]; 1619 1620 // Initializes and opens PhotoSwipe 1621 var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options); 1622 gallery.init(); 1623 }; 1624})(jQuery); 1625 1626/* global woodmart_settings */ 1627(function($) { 1628 woodmartThemeModule.clickOnScrollButton = function(btnClass, destroy, offset) { 1629 if (typeof $.fn.waypoint != 'function') { 1630 return; 1631 } 1632 1633 var $btn = $(btnClass); 1634 if ($btn.length === 0) { 1635 return; 1636 } 1637 1638 $btn.trigger('wd-waypoint-destroy'); 1639 1640 if (!offset) { 1641 offset = 0; 1642 } 1643 1644 var waypoint = new Waypoint({ 1645 element: $btn[0], 1646 handler: function() { 1647 $btn.trigger('click'); 1648 }, 1649 offset : function() { 1650 return woodmartThemeModule.$window.outerHeight() + parseInt(offset); 1651 } 1652 }); 1653 1654 $btn.data('waypoint-inited', true).off('wd-waypoint-destroy').on('wd-waypoint-destroy', function() { 1655 if ($btn.data('waypoint-inited')) { 1656 waypoint.destroy(); 1657 $btn.data('waypoint-inited', false); 1658 } 1659 }); 1660 }; 1661})(jQuery); 1662 1663/* global woodmart_settings */ 1664(function($) { 1665 woodmartThemeModule.cookiesPopup = function() { 1666 var cookies_version = woodmart_settings.cookies_version; 1667 1668 if (Cookies.get('woodmart_cookies_' + cookies_version) === 'accepted') { 1669 return; 1670 } 1671 1672 var popup = $('.wd-cookies-popup'); 1673 1674 setTimeout(function() { 1675 popup.addClass('popup-display'); 1676 popup.on('click', '.cookies-accept-btn', function(e) { 1677 e.preventDefault(); 1678 acceptCookies(); 1679 }); 1680 }, 2500); 1681 1682 var acceptCookies = function() { 1683 popup.removeClass('popup-display').addClass('popup-hide'); 1684 Cookies.set('woodmart_cookies_' + cookies_version, 'accepted', { 1685 expires: 60, 1686 path : '/' 1687 }); 1688 }; 1689 }; 1690 1691 $(document).ready(function() { 1692 woodmartThemeModule.cookiesPopup(); 1693 }); 1694})(jQuery); 1695 1696/* global woodmart_settings */ 1697(function($) { 1698 woodmartThemeModule.footerWidgetsAccordion = function() { 1699 if (woodmartThemeModule.windowWidth >= 576) { 1700 return; 1701 } 1702 1703 $('.footer-widget-collapse .widget-title').on('click', function() { 1704 var $title = $(this); 1705 var $widget = $title.parent(); 1706 var $content = $widget.find('> *:not(.widget-title)'); 1707 1708 if ($widget.hasClass('footer-widget-opened')) { 1709 $widget.removeClass('footer-widget-opened'); 1710 $content.stop().slideUp(200); 1711 } else { 1712 $widget.addClass('footer-widget-opened'); 1713 $content.stop().slideDown(200); 1714 woodmartThemeModule.$document.trigger('wood-images-loaded'); 1715 } 1716 }); 1717 }; 1718 1719 $(document).ready(function() { 1720 woodmartThemeModule.footerWidgetsAccordion(); 1721 }); 1722})(jQuery); 1723 1724/* global woodmart_settings */ 1725(function($) { 1726 woodmartThemeModule.$document.on('wdPjaxStart', function () { 1727 woodmartThemeModule.hideShopSidebar(); 1728 }); 1729 1730 woodmartThemeModule.$document.on('wdShopPageInit', function () { 1731 woodmartThemeModule.hiddenSidebar(); 1732 }); 1733 1734 woodmartThemeModule.hiddenSidebar = function() { 1735 var position = woodmartThemeModule.$body.hasClass('rtl') ? 'right' : 'left'; 1736 1737 if (woodmartThemeModule.$body.hasClass('offcanvas-sidebar-desktop') && woodmartThemeModule.windowWidth > 1024 || woodmartThemeModule.$body.hasClass('offcanvas-sidebar-tablet') && woodmartThemeModule.windowWidth <= 1024) { 1738 $('.area-sidebar-shop').addClass('wd-side-hidden wd-' + position + ' wd-inited wd-scroll'); 1739 $('.area-sidebar-shop .widget-area').addClass('wd-scroll-content'); 1740 } 1741 1742 if (woodmartThemeModule.$body.hasClass('offcanvas-sidebar-mobile') && woodmartThemeModule.windowWidth <= 768) { 1743 $('.sidebar-container').addClass('wd-side-hidden wd-' + position + ' wd-inited wd-scroll'); 1744 $('.sidebar-container .widget-area').addClass('wd-scroll-content'); 1745 } 1746
1747 woodmartThemeModule.$body.off('click', '.wd-show-sidebar-btn, .wd-sidebar-opener').on('click', '.wd-show-sidebar-btn, .wd-sidebar-opener', function(e) { 1748 e.preventDefault(); 1749 1750 if ($('.sidebar-container').hasClass('wd-opened')) { 1751 woodmartThemeModule.hideShopSidebar(); 1752 } else { 1753 showSidebar(); 1754 } 1755 }); 1756 1757 woodmartThemeModule.$body.on('click touchstart', '.wd-close-side, .close-side-widget', function() { 1758 woodmartThemeModule.hideShopSidebar(); 1759 }); 1760 1761 var showSidebar = function() { 1762 $('.sidebar-container').addClass('wd-opened'); 1763 $('.wd-close-side').addClass('wd-close-side-opened'); 1764 }; 1765 1766 woodmartThemeModule.$document.trigger('wdHiddenSidebarsInited'); 1767 }; 1768 1769 woodmartThemeModule.hideShopSidebar = function() { 1770 $('.sidebar-container').removeClass('wd-opened'); 1771 $('.wd-close-side').removeClass('wd-close-side-opened'); 1772 }; 1773 1774 $(document).ready(function() { 1775 woodmartThemeModule.hiddenSidebar(); 1776 }); 1777})(jQuery); 1778 1779/* global woodmart_settings */ 1780(function($) { 1781 woodmartThemeModule.$document.on('wdHiddenSidebarsInited', function () { 1782 woodmartThemeModule.lazyLoading(); 1783 }); 1784 1785 $.each([ 1786 'frontend/element_ready/wd_products.default', 1787 'frontend/element_ready/wd_products_tabs.default', 1788 'frontend/element_ready/wd_product_categories.default', 1789 'frontend/element_ready/wd_products_brands.default', 1790 'frontend/element_ready/wd_blog.default', 1791 'frontend/element_ready/wd_images_gallery.default', 1792 'frontend/element_ready/wd_product_categories.default', 1793 'frontend/element_ready/wd_slider.default', 1794 'frontend/element_ready/wd_banner_carousel.default', 1795 'frontend/element_ready/wd_banner.default', 1796 'frontend/element_ready/wd_infobox_carousel.default', 1797 'frontend/element_ready/wd_infobox.default', 1798 'frontend/element_ready/wd_instagram.default', 1799 'frontend/element_ready/wd_testimonials.default' 1800 ], function(index, value) { 1801 woodmartThemeModule.wdElementorAddAction(value, function() { 1802 woodmartThemeModule.lazyLoading(); 1803 }); 1804 }); 1805 1806 woodmartThemeModule.lazyLoading = function() { 1807 if (!window.addEventListener || !window.requestAnimationFrame || !document.getElementsByClassName) { 1808 return; 1809 } 1810 1811 var pItem = document.getElementsByClassName('wd-lazy-load'), pCount, timer; 1812 1813 woodmartThemeModule.$document.on('wood-images-loaded added_to_cart', function() { 1814 inView(); 1815 }); 1816 1817 $('.wd-scroll-content').on('scroll', function() { 1818 woodmartThemeModule.$document.trigger('wood-images-loaded'); 1819 }); 1820 1821 // WooCommerce tabs fix 1822 $('.wc-tabs > li').on('click', function() { 1823 woodmartThemeModule.$document.trigger('wood-images-loaded'); 1824 }); 1825 1826 // scroll and resize events 1827 window.addEventListener('scroll', scroller, false); 1828 window.addEventListener('resize', scroller, false); 1829 1830 // DOM mutation observer 1831 if (MutationObserver) { 1832 var observer = new MutationObserver(function() { 1833 if (pItem.length !== pCount) { 1834 inView(); 1835 } 1836 }); 1837 1838 observer.observe(document.body, { 1839 subtree : true, 1840 childList : true, 1841 attributes : true, 1842 characterData: true 1843 }); 1844 } 1845 1846 // initial check 1847 inView(); 1848 1849 // throttled scroll/resize 1850 function scroller() { 1851 timer = timer || setTimeout(function() { 1852 timer = null; 1853 inView(); 1854 }, 100); 1855 } 1856 1857 // image in view? 1858 function inView() { 1859 if (pItem.length) { 1860 requestAnimationFrame(function() { 1861 var offset = parseInt(woodmart_settings.lazy_loading_offset); 1862 var wT = window.pageYOffset, wB = wT + window.innerHeight + offset, cRect, pT, pB, p = 0; 1863 1864 while (p < pItem.length) { 1865 cRect = pItem[p].getBoundingClientRect(); 1866 pT = wT + cRect.top; 1867 pB = pT + cRect.height; 1868 1869 if (wT < pB && wB > pT && !pItem[p].loaded) { 1870 loadFullImage(pItem[p], p); 1871 } else { 1872 p++; 1873 } 1874 } 1875 1876 pCount = pItem.length; 1877 }); 1878 } 1879 } 1880 1881 // replace with full image 1882 function loadFullImage(item) { 1883 item.onload = addedImg; 1884 1885 if (item.querySelector('img') !== null) { 1886 item.querySelector('img').onload = addedImg; 1887 item.querySelector('img').src = item.dataset.woodSrc; 1888 item.querySelector('source').srcset = item.dataset.woodSrc; 1889 1890 if (typeof (item.dataset.srcset) != 'undefined') { 1891 item.querySelector('img').srcset = item.dataset.srcset; 1892 } 1893 } 1894 1895 item.src = item.dataset.woodSrc; 1896 if (typeof (item.dataset.srcset) != 'undefined') { 1897 item.srcset = item.dataset.srcset; 1898 } 1899 1900 item.loaded = true; 1901 1902 // replace image 1903 function addedImg() { 1904 requestAnimationFrame(function() { 1905 item.classList.add('wd-loaded'); 1906 1907 var $masonry = jQuery(item).parents('.view-masonry .gallery-images, .grid-masonry, .masonry-container'); 1908 if ($masonry.length > 0) { 1909 $masonry.isotope('layout'); 1910 } 1911 var $categories = jQuery(item).parents('.categories-masonry'); 1912 if ($categories.length > 0) { 1913 $categories.packery(); 1914 } 1915 }); 1916 } 1917 } 1918 }; 1919 1920 $(document).ready(function() { 1921 woodmartThemeModule.lazyLoading(); 1922 }); 1923})(jQuery); 1924 1925/* global woodmart_settings */ 1926(function($) { 1927 $.each([ 1928 'frontend/element_ready/wd_blog.default', 1929 'frontend/element_ready/wd_portfolio.default', 1930 ], function(index, value) { 1931 woodmartThemeModule.wdElementorAddAction(value, function() { 1932 woodmartThemeModule.masonryLayout(); 1933 }); 1934 }); 1935 1936 woodmartThemeModule.masonryLayout = function() { 1937 if (typeof ($.fn.isotope) === 'undefined' || typeof ($.fn.imagesLoaded) === 'undefined') { 1938 return; 1939 } 1940 1941 var $container = $('.masonry-container'); 1942 1943 $container.imagesLoaded(function() { 1944 $container.isotope({ 1945 gutter : 0, 1946 isOriginLeft: !woodmartThemeModule.$body.hasClass('rtl'), 1947 itemSelector: '.blog-design-masonry, .blog-design-mask, .masonry-item' 1948 }); 1949 }); 1950 }; 1951 1952 $(document).ready(function() { 1953 woodmartThemeModule.masonryLayout(); 1954 }); 1955})(jQuery); 1956 1957/* global woodmart_settings */ 1958(function($) { 1959 woodmartThemeModule.$document.on('wdPortfolioLoadMoreLoaded', function () { 1960 woodmartThemeModule.mfpPopup(); 1961 }); 1962 1963 woodmartThemeModule.mfpPopup = function() { 1964 if ('undefined' === typeof $.fn.magnificPopup) { 1965 return; 1966 } 1967 1968 $('.gallery').magnificPopup({ 1969 delegate : ' > a', 1970 type : 'image', 1971 removalDelay: 500,
1972 tClose : woodmart_settings.close, 1973 tLoading : woodmart_settings.loading, 1974 callbacks : { 1975 beforeOpen: function() { 1976 this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure mfp-with-anim'); 1977 this.st.mainClass = 'mfp-move-horizontal'; 1978 } 1979 }, 1980 image : { 1981 verticalFit: true 1982 }, 1983 gallery : { 1984 enabled : true, 1985 navigateByImgClick: true 1986 } 1987 }); 1988 }; 1989 1990 $(document).ready(function() { 1991 woodmartThemeModule.mfpPopup(); 1992 }); 1993})(jQuery); 1994 1995/* global woodmart_settings */ 1996(function($) { 1997 woodmartThemeModule.$document.on('wdInstagramAjaxSuccess wdLoadDropdownsSuccess', function() { 1998 woodmartThemeModule.owlCarouselInit(); 1999 }); 2000 2001 $.each([ 2002 'frontend/element_ready/wd_products.default', 2003 'frontend/element_ready/wd_products_tabs.default', 2004 'frontend/element_ready/wd_product_categories.default', 2005 'frontend/element_ready/wd_products_brands.default', 2006 'frontend/element_ready/wd_blog.default', 2007 'frontend/element_ready/wd_portfolio.default', 2008 'frontend/element_ready/wd_images_gallery.default', 2009 'frontend/element_ready/wd_product_categories.default', 2010 'frontend/element_ready/wd_banner_carousel.default', 2011 'frontend/element_ready/wd_infobox_carousel.default', 2012 'frontend/element_ready/wd_instagram.default', 2013 'frontend/element_ready/wd_testimonials.default' 2014 ], function(index, value) { 2015 woodmartThemeModule.wdElementorAddAction(value, function() { 2016 woodmartThemeModule.owlCarouselInit(); 2017 }); 2018 }); 2019 2020 woodmartThemeModule.owlCarouselInit = function() { 2021 $('div[data-owl-carousel]:not(.scroll-init):not(.wd-slider-wrapper)').each(function() { 2022 owlInit($(this)); 2023 }); 2024 2025 2026 if (typeof ($.fn.waypoint) != 'undefined') { 2027 $('div[data-owl-carousel].scroll-init:not(.wd-slider-wrapper)').waypoint(function() { 2028 var $this = $($(this)[0].element); 2029 owlInit($this); 2030 }, { 2031 offset: '100%' 2032 }); 2033 } 2034 2035 function owlInit($this) { 2036 var $owl = $this.find('.owl-carousel'); 2037 2038 if (woodmartThemeModule.windowWidth <= 1024 && $this.hasClass('disable-owl-mobile') || $owl.hasClass('owl-loaded')) { 2039 return; 2040 } 2041 2042 var options = { 2043 rtl : woodmartThemeModule.$body.hasClass('rtl'), 2044 items : $this.data('desktop') ? $this.data('desktop') : 1, 2045 responsive : { 2046 1025: { 2047 items: $this.data('desktop') ? $this.data('desktop') : 1 2048 }, 2049 769 : { 2050 items: $this.data('tablet_landscape') ? $this.data('tablet_landscape') : 1 2051 }, 2052 577 : { 2053 items: $this.data('tablet') ? $this.data('tablet') : 1 2054 }, 2055 0 : { 2056 items: $this.data('mobile') ? $this.data('mobile') : 1 2057 } 2058 }, 2059 autoplay : $this.data('autoplay') === 'yes', 2060 autoplayHoverPause: $this.data('autoplay') === 'yes', 2061 autoplayTimeout : $this.data('speed') ? $this.data('speed') : 5000, 2062 dots : $this.data('hide_pagination_control') !== 'yes', 2063 nav : $this.data('hide_prev_next_buttons') !== 'yes', 2064 autoHeight : $this.data('autoheight') === 'yes', 2065 slideBy : typeof $this.data('scroll_per_page') !== 'undefined' ? 1 : 'page', 2066 navText : false, 2067 navClass : ['owl-prev wd-btn-arrow', 'owl-next wd-btn-arrow'], 2068 center : $this.data('center_mode') === 'yes', 2069 loop : $this.data('wrap') === 'yes', 2070 dragEndSpeed : $this.data('dragendspeed') ? $this.data('dragendspeed') : 200 2071 }; 2072 2073 if ($this.data('sliding_speed')) { 2074 options.smartSpeed = $this.data('sliding_speed'); 2075 options.dragEndSpeed = $this.data('sliding_speed'); 2076 } 2077 2078 if ($this.data('animation')) { 2079 options.animateOut = $this.data('animation'); 2080 options.mouseDrag = true; 2081 } 2082 2083 function determinePseudoActive() { 2084 var id = $owl.find('.owl-item.active').find('.wd-slide').attr('id'); 2085 var $els = $owl.find('[id="' + id + '"]'); 2086 2087 $owl.find('.owl-item.pseudo-active').removeClass('pseudo-active'); 2088 $els.each(function() { 2089 var $this = $(this); 2090 2091 if (!$this.parent().hasClass('active')) { 2092 $this.parent().addClass('pseudo-active'); 2093 } 2094 }); 2095 } 2096 2097 if ($this.data('content_animation')) { 2098 determinePseudoActive(); 2099 2100 options.onTranslated = function() { 2101 determinePseudoActive(); 2102 }; 2103 } 2104 2105 woodmartThemeModule.$window.on('vc_js', function() { 2106 $owl.trigger('refresh.owl.carousel'); 2107 }); 2108 2109 // Fix for css in files. 2110 $owl.find('link').appendTo('head'); 2111 2112 $owl.owlCarousel(options); 2113 2114 if ($this.data('autoheight') === 'yes') { 2115 $owl.imagesLoaded(function() { 2116 $owl.trigger('refresh.owl.carousel'); 2117 }); 2118 } 2119 } 2120 }; 2121 2122 $(document).ready(function() { 2123 woodmartThemeModule.owlCarouselInit(); 2124 }); 2125})(jQuery); 2126 2127/* global woodmart_settings */ 2128(function($) { 2129 woodmartThemeModule.parallax = function() { 2130 if (woodmartThemeModule.windowWidth <= 1024) { 2131 return; 2132 } 2133 2134 $('.wd-parallax').each(function() { 2135 var $this = $(this); 2136 2137 if ($this.hasClass('wpb_column')) { 2138 $this.find('> .vc_column-inner').parallax('50%', 0.3); 2139 } else { 2140 $this.parallax('50%', 0.3); 2141 } 2142 }); 2143 }; 2144 2145 $(document).ready(function() { 2146 woodmartThemeModule.parallax(); 2147 }); 2148})(jQuery); 2149 2150/* global woodmart_settings */ 2151(function($) { 2152 woodmartThemeModule.photoswipeImages = function() { 2153 $('.photoswipe-images').each(function() { 2154 var $this = $(this); 2155 2156 $this.on('click', 'a', function(e) { 2157 e.preventDefault(); 2158 var index = $(e.currentTarget).data('index') - 1; 2159 var items = getGalleryItems($this, []); 2160 2161 woodmartThemeModule.callPhotoSwipe(index, items); 2162 }); 2163 }); 2164 2165 var getGalleryItems = function($gallery, items) { 2166 var src, width, height, title; 2167 2168 $gallery.find('a').each(function() { 2169 var $this = $(this); 2170 2171 src = $this.attr('href'); 2172 width = $this.data('width'); 2173 height = $this.data('height'); 2174 title = $this.attr('title'); 2175 2176 if (!isItemInArray(items, src)) { 2177 items.push({ 2178 src : src, 2179 w : width, 2180 h : height, 2181 title: title 2182 }); 2183 } 2184 }); 2185 2186 return items; 2187 }; 2188 2189 var isItemInArray = function(items, src) { 2190 var i; 2191 for (i = 0; i < items.length; i++) { 2192 if (items[i].src === src) { 2193 return true; 2194 } 2195 } 2196 2197 return false;
2198 }; 2199 }; 2200 2201 $(document).ready(function() { 2202 woodmartThemeModule.photoswipeImages(); 2203 }); 2204})(jQuery); 2205 2206/* global woodmart_settings */ 2207(function($) { 2208 woodmartThemeModule.promoPopup = function() { 2209 var promo_version = woodmart_settings.promo_version; 2210 2211 if (woodmartThemeModule.$body.hasClass('page-template-maintenance') || woodmart_settings.enable_popup !== 'yes' || (woodmart_settings.promo_popup_hide_mobile === 'yes' && woodmartThemeModule.windowWidth < 768) || (Cookies.get('woodmart_age_verify') !== 'confirmed' && woodmart_settings.age_verify === 'yes')) { 2212 return; 2213 } 2214 2215 var shown = false, 2216 pages = Cookies.get('woodmart_shown_pages'); 2217 2218 var showPopup = function() { 2219 $.magnificPopup.open({ 2220 items : { 2221 src: '.wd-promo-popup' 2222 }, 2223 type : 'inline', 2224 removalDelay: 500, //delay removal by X to allow out-animation 2225 tClose : woodmart_settings.close, 2226 tLoading : woodmart_settings.loading, 2227 callbacks : { 2228 beforeOpen: function() { 2229 this.st.mainClass = 'mfp-move-horizontal wd-promo-popup-wrapper'; 2230 }, 2231 close : function() { 2232 Cookies.set('woodmart_popup_' + promo_version, 'shown', { 2233 expires: 7, 2234 path : '/' 2235 }); 2236 } 2237 } 2238 }); 2239 2240 woodmartThemeModule.$document.trigger('wood-images-loaded'); 2241 }; 2242 2243 $('.woodmart-open-newsletter').on('click', function(e) { 2244 e.preventDefault(); 2245 showPopup(); 2246 }); 2247 2248 if (!pages) { 2249 pages = 0; 2250 } 2251 2252 if (pages < woodmart_settings.popup_pages) { 2253 pages++; 2254 2255 Cookies.set('woodmart_shown_pages', pages, { 2256 expires: 7, 2257 path : '/' 2258 }); 2259 2260 return false; 2261 } 2262 2263 if (Cookies.get('woodmart_popup_' + promo_version) !== 'shown') { 2264 if (woodmart_settings.popup_event === 'scroll') { 2265 woodmartThemeModule.$window.on('scroll', function() { 2266 if (shown) { 2267 return false; 2268 } 2269 2270 if (woodmartThemeModule.$document.scrollTop() >= woodmart_settings.popup_scroll) { 2271 showPopup(); 2272 shown = true; 2273 } 2274 }); 2275 } else { 2276 setTimeout(function() { 2277 showPopup(); 2278 }, woodmart_settings.popup_delay); 2279 } 2280 } 2281 }; 2282 2283 $(document).ready(function() { 2284 woodmartThemeModule.promoPopup(); 2285 }); 2286})(jQuery); 2287 2288/* global woodmart_settings */ 2289(function($) { 2290 woodmartThemeModule.scrollTop = function() { 2291 var $scrollTop = $('.scrollToTop'); 2292 2293 woodmartThemeModule.$window.on('scroll', function() { 2294 if ($(this).scrollTop() > 100) { 2295 $scrollTop.addClass('button-show'); 2296 } else { 2297 $scrollTop.removeClass('button-show'); 2298 } 2299 }); 2300 2301 $scrollTop.on('click', function() { 2302 $('html, body').animate({ 2303 scrollTop: 0 2304 }, 800); 2305 return false; 2306 }); 2307 }; 2308 2309 $(document).ready(function() { 2310 woodmartThemeModule.scrollTop(); 2311 }); 2312})(jQuery); 2313 2314/* global woodmart_settings */ 2315(function($) { 2316 woodmartThemeModule.searchFullScreen = function() { 2317 var searchWrapper = $('.wd-search-full-screen'); 2318 2319 woodmartThemeModule.$body.on('click', '.wd-header-search.wd-display-full-screen > a', function(e) { 2320 e.preventDefault(); 2321 2322 if ($(this).parent().find('.wd-search-dropdown').length > 0 || woodmartThemeModule.$body.hasClass('global-search-dropdown')) { 2323 return; 2324 } 2325 2326 if (isOpened()) { 2327 closeWidget(); 2328 } else { 2329 setTimeout(function() { 2330 openWidget(); 2331 }, 10); 2332 } 2333 }); 2334 2335 woodmartThemeModule.$body.on('click', '.wd-close-search a, .main-page-wrapper, .header-banner', function(event) { 2336 2337 if (!$(event.target).is('.wd-close-search a') && $(event.target).closest('.wd-search-full-screen').length) { 2338 return; 2339 } 2340 2341 if (isOpened()) { 2342 closeWidget(); 2343 } 2344 }); 2345 2346 var closeByEsc = function(e) { 2347 if (e.keyCode === 27) { 2348 closeWidget(); 2349 woodmartThemeModule.$body.unbind('keyup', closeByEsc); 2350 } 2351 }; 2352 2353 var closeWidget = function() { 2354 woodmartThemeModule.$body.removeClass('wd-search-opened'); 2355 searchWrapper.removeClass('wd-opened'); 2356 }; 2357 2358 var openWidget = function() { 2359 var $bar = $('#wpadminbar'); 2360 var barHeight = $bar.length > 0 ? $bar.outerHeight() : 0; 2361 var $sticked = $('.whb-sticked'); 2362 var $mainHeader = $('.whb-main-header'); 2363 var offset; 2364 2365 if ($sticked.length > 0) { 2366 if ($('.whb-clone').length > 0) { 2367 offset = $sticked.outerHeight() + barHeight; 2368 } else { 2369 offset = $mainHeader.outerHeight() + barHeight; 2370 } 2371 } else { 2372 offset = $mainHeader.outerHeight() + barHeight; 2373 if (woodmartThemeModule.$body.hasClass('header-banner-display')) { 2374 offset += $('.header-banner').outerHeight(); 2375 } 2376 } 2377
2378 searchWrapper.css('top', offset); 2379 2380 // Close by esc 2381 woodmartThemeModule.$body.on('keyup', closeByEsc); 2382 woodmartThemeModule.$body.addClass('wd-search-opened'); 2383 2384 searchWrapper.addClass('wd-opened'); 2385 2386 setTimeout(function() { 2387 searchWrapper.find('input[type="text"]').focus(); 2388 2389 if ( woodmartThemeModule.windowWidth > 1024 ) { 2390 woodmartThemeModule.$window.one('scroll', function() { 2391 if (isOpened()) { 2392 closeWidget(); 2393 } 2394 }); 2395 } 2396 }, 300); 2397 }; 2398 2399 var isOpened = function() { 2400 return woodmartThemeModule.$body.hasClass('wd-search-opened'); 2401 }; 2402 }; 2403 2404 $(document).ready(function() { 2405 woodmartThemeModule.searchFullScreen(); 2406 }); 2407})(jQuery); 2408 2409/* global woodmart_settings */ 2410(function($) { 2411 woodmartThemeModule.$document.on('wdElementorColumnReady', function () { 2412 woodmartThemeModule.stickyColumn(); 2413 }); 2414 2415 woodmartThemeModule.stickyColumn = function() { 2416 $('.woodmart-sticky-column').each(function() { 2417 var $column = $(this), 2418 offset = 150; 2419 2420 var classes = $column.attr('class').split(' '); 2421 2422 for (var index = 0; index < classes.length; index++) { 2423 if (classes[index].indexOf('wd_sticky_offset_') >= 0) { 2424 var data = classes[index].split('_'); 2425 offset = parseInt(data[3]); 2426 } 2427 } 2428 2429 $column.find(' > .vc_column-inner > .wpb_wrapper').trigger('sticky_kit:detach'); 2430 $column.find(' > .vc_column-inner > .wpb_wrapper').stick_in_parent({ 2431 offset_top: offset 2432 }); 2433 }); 2434 2435 $('.wd-elementor-sticky-column').each(function() { 2436 var $column = $(this); 2437 var offset = 150; 2438 var classes = $column.attr('class').split(' '); 2439 2440 for (var index = 0; index < classes.length; index++) { 2441 if (classes[index].indexOf('wd_sticky_offset_') >= 0) { 2442 var data = classes[index].split('_'); 2443 offset = parseInt(data[3]); 2444 } 2445 } 2446 2447 var $widgetWrap = $column.find('> .elementor-column-wrap > .elementor-widget-wrap'); 2448 2449 if ($widgetWrap.length <= 0) { 2450 $widgetWrap = $column.find('> .elementor-widget-wrap'); 2451 } 2452 2453 $widgetWrap.stick_in_parent({ 2454 offset_top: offset 2455 }); 2456 }); 2457 }; 2458 2459 $(document).ready(function() { 2460 woodmartThemeModule.stickyColumn(); 2461 }); 2462})(jQuery); 2463 2464/* global woodmart_settings */ 2465(function($) { 2466 woodmartThemeModule.stickyFooter = function() { 2467 if (!woodmartThemeModule.$body.hasClass('sticky-footer-on') || woodmartThemeModule.$window.width() <= 1024) { 2468 return; 2469 } 2470 2471 var $footer = $('.footer-container'), 2472 $page = $('.main-page-wrapper'), 2473 $prefooter = $('.wd-prefooter'), 2474 $window = woodmartThemeModule.$window; 2475 2476 if ($prefooter.length > 0) { 2477 $page = $prefooter; 2478 } 2479 2480 var footerOffset = function() { 2481 $page.css({ 2482 marginBottom: $footer.outerHeight() 2483 }); 2484 }; 2485 2486 $window.on('resize', footerOffset); 2487 2488 $footer.imagesLoaded(function() { 2489 footerOffset(); 2490 }); 2491 2492 //Safari fix 2493 var footerSafariFix = function() { 2494 if (!$('html').hasClass('browser-Safari')) { 2495 return; 2496 } 2497 2498 var windowScroll = $window.scrollTop(); 2499 var footerOffsetTop = woodmartThemeModule.$document.outerHeight() - $footer.outerHeight(); 2500 2501 if (footerOffsetTop < windowScroll + $footer.outerHeight() + $window.outerHeight()) { 2502 $footer.addClass('visible-footer'); 2503 } else { 2504 $footer.removeClass('visible-footer'); 2505 } 2506 }; 2507 2508 footerSafariFix(); 2509 $window.on('scroll', footerSafariFix); 2510 }; 2511 2512 $(document).ready(function() { 2513 woodmartThemeModule.stickyFooter(); 2514 }); 2515})(jQuery); 2516 2517/* global woodmart_settings */ 2518(function($) { 2519 woodmartThemeModule.stickySocialButtons = function() { 2520 $('.wd-sticky-social').addClass('buttons-loaded'); 2521 }; 2522 2523 $(document).ready(function() { 2524 woodmartThemeModule.stickySocialButtons(); 2525 }); 2526})(jQuery); 2527 2528/* global woodmart_settings */ 2529(function($) { 2530 woodmartThemeModule.widgetsHidable = function() { 2531 woodmartThemeModule.$document.on('click', '.widget-hidable .widget-title', function() { 2532 var $this = $(this); 2533 var $content = $this.siblings('ul, div, form, label, select'); 2534 2535 $this.parent().toggleClass('widget-hidden'); 2536 $content.stop().slideToggle(200); 2537 }); 2538 }; 2539 2540 $(document).ready(function() { 2541 woodmartThemeModule.widgetsHidable(); 2542 }); 2543})(jQuery); 2544 2545/* global woodmart_settings */ 2546(function($) { 2547 woodmartThemeModule.headerBanner = function() { 2548 var banner_version = woodmart_settings.header_banner_version; 2549 2550 if ('closed' === Cookies.get('woodmart_tb_banner_' + banner_version) || 'no' === woodmart_settings.header_banner_close_btn || 'no' === woodmart_settings.header_banner_enabled) { 2551 return; 2552 } 2553 2554 if (!woodmartThemeModule.$body.hasClass('page-template-maintenance')) { 2555 woodmartThemeModule.$body.addClass('header-banner-display'); 2556 } 2557 2558 $('.header-banner').on('click', '.close-header-banner', function(e) { 2559 e.preventDefault(); 2560 closeBanner(); 2561 }); 2562 2563 var closeBanner = function() { 2564 woodmartThemeModule.$body.removeClass('header-banner-display').addClass('header-banner-hide'); 2565 2566 Cookies.set('woodmart_tb_banner_' + banner_version, 'closed', { 2567 expires: 60, 2568 path : '/' 2569 }); 2570 }; 2571 }; 2572 2573 $(document).ready(function() { 2574 woodmartThemeModule.headerBanner(); 2575 }); 2576})(jQuery); 2577 2578/* global woodmart_settings */ 2579(function($) { 2580 woodmartThemeModule.headerBuilder = function() { 2581 var $header = $('.whb-header'), 2582 $headerBanner = $('.header-banner'), 2583 $stickyElements = $('.whb-sticky-row'), 2584 $firstSticky = '',
2585 $window = woodmartThemeModule.$window, 2586 isSticked = false, 2587 stickAfter = 300, 2588 cloneHTML = '', 2589 previousScroll, 2590 isHideOnScroll = $header.hasClass('whb-hide-on-scroll'); 2591 2592 $stickyElements.each(function() { 2593 var $this = $(this); 2594 2595 if ($this[0].offsetHeight > 10) { 2596 $firstSticky = $this; 2597 return false; 2598 } 2599 }); 2600 2601 // Real header sticky option 2602 if ($header.hasClass('whb-sticky-real') || $header.hasClass('whb-scroll-slide')) { 2603 var $adminBar = $('#wpadminbar'); 2604 var headerHeight = $header.find('.whb-main-header')[0].offsetHeight; 2605 var adminBarHeight = $adminBar.length > 0 ? $adminBar[0].offsetHeight : 0; 2606 2607 if ($header.hasClass('whb-sticky-real')) { 2608 // if no sticky rows 2609 if ($firstSticky.length === 0 || $firstSticky[0].offsetHeight < 10) { 2610 return; 2611 } 2612 2613 $header.addClass('whb-sticky-prepared').css({ 2614 paddingTop: headerHeight 2615 }); 2616 2617 stickAfter = $firstSticky.offset().top - adminBarHeight; 2618 } 2619 2620 if ($header.hasClass('whb-scroll-slide')) { 2621 stickAfter = headerHeight + adminBarHeight; 2622 } 2623 } 2624 2625 if ($header.hasClass('whb-sticky-clone')) { 2626 var data = []; 2627 data['cloneClass'] = $header.find('.whb-general-header').attr('class'); 2628 2629 if (isHideOnScroll) { 2630 data['wrapperClasses'] = 'whb-hide-on-scroll'; 2631 } 2632 2633 cloneHTML = woodmart_settings.whb_header_clone; 2634 2635 cloneHTML = cloneHTML.replace(/<%([^%>]+)?%>/g, function(replacement) { 2636 var selector = replacement.slice(2, -2); 2637 2638 return $header.find(selector).length 2639 ? $('<div>') 2640 .append($header.find(selector).first().clone()) 2641 .html() 2642 : (data[selector] !== undefined) ? data[selector] : ''; 2643 }); 2644 2645 cloneHTML = cloneHTML.replace(/<link[^>]*>/g, ''); 2646 2647 $header.after(cloneHTML); 2648 $header = $header.parent().find('.whb-clone'); 2649 2650 $header.find('.whb-row').removeClass('whb-flex-equal-sides').addClass('whb-flex-flex-middle'); 2651 } 2652 2653 $window.on('scroll', function() { 2654 var after = stickAfter; 2655 var currentScroll = woodmartThemeModule.$window.scrollTop(); 2656 var windowHeight = woodmartThemeModule.$window.height(); 2657 var documentHeight = woodmartThemeModule.$document.height(); 2658 2659 if ($headerBanner.length > 0 && woodmartThemeModule.$body.hasClass('header-banner-display')) { 2660 after += $headerBanner[0].offsetHeight; 2661 } 2662 2663 if (!$('.close-header-banner').length && $header.hasClass('whb-scroll-stick')) { 2664 after = stickAfter; 2665 } 2666 2667 if (currentScroll > after) { 2668 stickHeader(); 2669 } else { 2670 unstickHeader(); 2671 } 2672 2673 var startAfter = 100; 2674 2675 if ($header.hasClass('whb-scroll-stick')) { 2676 startAfter = 500; 2677 } 2678 2679 if (isHideOnScroll) { 2680 if (previousScroll - currentScroll > 0 && currentScroll > after) { 2681 $header.addClass('whb-scroll-up'); 2682 $header.removeClass('whb-scroll-down'); 2683 } else if (currentScroll - previousScroll > 0 && currentScroll + windowHeight !== documentHeight && currentScroll > (after + startAfter)) { 2684 $header.addClass('whb-scroll-down'); 2685 $header.removeClass('whb-scroll-up'); 2686 } else if (currentScroll <= after) { 2687 $header.removeClass('whb-scroll-down'); 2688 $header.removeClass('whb-scroll-up'); 2689 } else if (currentScroll + windowHeight >= documentHeight - 5) { 2690 $header.addClass('whb-scroll-up'); 2691 $header.removeClass('whb-scroll-down'); 2692 } 2693 } 2694 2695 previousScroll = currentScroll; 2696 }); 2697 2698 function stickHeader() { 2699 if (isSticked) { 2700 return; 2701 } 2702 2703 isSticked = true; 2704 $header.addClass('whb-sticked'); 2705 menuDropdownRecalc(); 2706 } 2707 2708 function unstickHeader() { 2709 if (!isSticked) { 2710 return; 2711 } 2712 2713 isSticked = false; 2714 $header.removeClass('whb-sticked'); 2715 menuDropdownRecalc(); 2716 } 2717 2718 function menuDropdownRecalc() { 2719 if (!$header.hasClass('whb-boxed')) { 2720 return; 2721 } 2722 2723 $('.wd-offsets-calculated .wd-dropdown-menu').attr('style', ''); 2724 $('.wd-offsets-calculated').removeClass('wd-offsets-calculated'); 2725 woodmartThemeModule.$window.trigger('wdHeaderBuilderStickyChanged'); 2726 } 2727 2728 woodmartThemeModule.$document.trigger('wdHeaderBuilderInited'); 2729 }; 2730 2731 woodmartThemeModule.$window.on('wdEventStarted', function() { 2732 woodmartThemeModule.headerBuilder(); 2733 }); 2734})(jQuery); 2735 2736/* global woodmart_settings */ 2737(function($) { 2738 woodmartThemeModule.mobileSearchIcon = function() { 2739 woodmartThemeModule.$body.on('click', '.wd-header-search-mobile:not(.wd-display-full-screen)', function(e) { 2740 e.preventDefault();
2741 var $nav = $('.mobile-nav'); 2742 2743 if (!$nav.hasClass('wd-opened')) { 2744 $nav.addClass('wd-opened'); 2745 $('.wd-close-side').addClass('wd-close-side-opened'); 2746 $('.mobile-nav .searchform').find('input[type="text"]').focus(); 2747 } 2748 }); 2749 }; 2750 2751 $(document).ready(function() { 2752 woodmartThemeModule.mobileSearchIcon(); 2753 }); 2754})(jQuery); 2755 2756/* global woodmart_settings */ 2757(function($) { 2758 woodmartThemeModule.fullScreenMenu = function() { 2759 $('.wd-header-fs-nav > a').on('click', function(e) { 2760 e.preventDefault(); 2761 2762 $('.wd-fs-menu').addClass('wd-opened'); 2763 }); 2764 2765 woodmartThemeModule.$document.on('keyup', function(e) { 2766 if (e.keyCode === 27) { 2767 $('.wd-fs-close').click(); 2768 } 2769 }); 2770 2771 $('.wd-fs-close').on('click', function() { 2772 $('.wd-fs-menu').removeClass('wd-opened'); 2773 2774 setTimeout(function() { 2775 $('.wd-nav-fs .menu-item-has-children').removeClass('sub-menu-open'); 2776 $('.wd-nav-fs .menu-item-has-children .wd-nav-opener').removeClass('wd-active'); 2777 }, 200); 2778 }); 2779 2780 $('.wd-nav-fs > .menu-item-has-children > a, .wd-nav-fs .wd-dropdown-fs-menu.wd-design-default .menu-item-has-children > a').append('<span class="wd-nav-opener"></span>'); 2781 2782 $('.wd-nav-fs').on('click', '.wd-nav-opener', function(e) { 2783 e.preventDefault(); 2784 var $icon = $(this), 2785 $parentItem = $icon.parent().parent(); 2786 2787 if ($parentItem.hasClass('sub-menu-open')) { 2788 $parentItem.removeClass('sub-menu-open'); 2789 $icon.removeClass('wd-active'); 2790 } else { 2791 $parentItem.siblings('.sub-menu-open').find('.wd-nav-opener').removeClass('wd-active'); 2792 $parentItem.siblings('.sub-menu-open').removeClass('sub-menu-open'); 2793 $parentItem.addClass('sub-menu-open'); 2794 $icon.addClass('wd-active'); 2795 } 2796 }); 2797 }; 2798 2799 $(document).ready(function() { 2800 woodmartThemeModule.fullScreenMenu(); 2801 }); 2802})(jQuery); 2803 2804/* global woodmart_settings */ 2805(function($) { 2806 woodmartThemeModule.menuDropdownsAJAX = function() { 2807 woodmartThemeModule.$body.on('mousemove', checkMenuProximity); 2808 2809 function checkMenuProximity(event) { 2810 $('.menu').has('.dropdown-load-ajax').each(function() { 2811 var $menu = $(this); 2812 2813 if ($menu.hasClass('dropdowns-loading') || $menu.hasClass('dropdowns-loaded')) { 2814 return; 2815 } 2816 2817 if (!isNear($menu, 50, event)) { 2818 return; 2819 } 2820 2821 loadDropdowns($menu); 2822 }); 2823 } 2824 2825 function loadDropdowns($menu) { 2826 $menu.addClass('dropdowns-loading'); 2827 2828 var storageKey = woodmart_settings.menu_storage_key + '_' + $menu.attr('id'); 2829 var storedData = false; 2830 2831 var $items = $menu.find('.dropdown-load-ajax'), 2832 ids = []; 2833 2834 $items.each(function() { 2835 ids.push($(this).find('.dropdown-html-placeholder').data('id')); 2836 }); 2837 2838 if (woodmart_settings.ajax_dropdowns_save && woodmartThemeModule.supports_html5_storage) { 2839 var unparsedData = localStorage.getItem(storageKey); 2840 2841 try { 2842 storedData = JSON.parse(unparsedData); 2843 } 2844 catch (e) { 2845 console.log('cant parse Json', e); 2846 } 2847 } 2848 if (storedData) { 2849 renderResults(storedData); 2850 } else { 2851 $.ajax({ 2852 url : woodmart_settings.ajaxurl, 2853 data : { 2854 action: 'woodmart_load_html_dropdowns', 2855 ids : ids 2856 }, 2857 dataType: 'json', 2858 method : 'POST', 2859 success : function(response) { 2860 if (response.status === 'success') { 2861 renderResults(response.data); 2862 if (woodmart_settings.ajax_dropdowns_save && woodmartThemeModule.supports_html5_storage) { 2863 localStorage.setItem(storageKey, JSON.stringify(response.data)); 2864 } 2865 } else { 2866 console.log('loading html dropdowns returns wrong data - ', response.message); 2867 } 2868 }, 2869 error : function() { 2870 console.log('loading html dropdowns ajax error'); 2871 } 2872 }); 2873 } 2874 2875 function renderResults(data) { 2876 Object.keys(data).forEach(function(id) { 2877 woodmartThemeModule.removeDuplicatedStylesFromHTML(data[id], function(html) { 2878 $menu.find('[data-id="' + id + '"]').replaceWith(html); 2879 2880 $menu.addClass('dropdowns-loaded'); 2881 setTimeout(function() { 2882 $menu.removeClass('dropdowns-loading'); 2883 }, 1000); 2884 }); 2885 }); 2886 2887 woodmartThemeModule.$document.trigger('wdLoadDropdownsSuccess'); 2888 } 2889 } 2890 2891 function isNear($element, distance, event) { 2892 var left = $element.offset().left - distance, 2893 top = $element.offset().top - distance, 2894 right = left + $element.width() + (2 * distance), 2895 bottom = top + $element.height() + (2 * distance), 2896 x = event.pageX, 2897 y = event.pageY; 2898 2899 return (x > left && x < right && y > top && y < bottom); 2900 } 2901 }; 2902 2903 $(document).ready(function() { 2904 woodmartThemeModule.menuDropdownsAJAX(); 2905 }); 2906})(jQuery); 2907 2908/* global woodmart_settings */ 2909(function($) { 2910 woodmartThemeModule.menuOffsets = function() { 2911 var setOffset = function(li) { 2912 var $dropdown = li.find(' > .wd-dropdown-menu'); 2913 var dropdownWidth = $dropdown.outerWidth(); 2914 var dropdownOffset = $dropdown.offset(); 2915 var toRight; 2916 var viewportWidth; 2917 var dropdownOffsetRight; 2918 2919 $dropdown.attr('style', ''); 2920 2921 if (!dropdownWidth || !dropdownOffset) { 2922 return; 2923 } 2924 2925 if ($dropdown.hasClass('wd-design-full-width')) { 2926 viewportWidth = woodmartThemeModule.$window.width(); 2927 2928 if (woodmartThemeModule.$body.hasClass('rtl')) { 2929 dropdownOffsetRight = viewportWidth - dropdownOffset.left - dropdownWidth; 2930 2931 if (dropdownOffsetRight + dropdownWidth >= viewportWidth) { 2932 toRight = dropdownOffsetRight + dropdownWidth - viewportWidth; 2933 2934 $dropdown.css({ 2935 right: -toRight 2936 }); 2937 } 2938 } else { 2939 if (dropdownOffset.left + dropdownWidth >= viewportWidth) { 2940 toRight = dropdownOffset.left + dropdownWidth - viewportWidth; 2941 2942 $dropdown.css({ 2943 left: -toRight 2944 }); 2945 } 2946 } 2947 } else if ($dropdown.hasClass('wd-design-sized') || $dropdown.hasClass('wd-design-default')) { 2948 viewportWidth = woodmart_settings.site_width; 2949 2950 if (woodmartThemeModule.$window.width() < viewportWidth || ! viewportWidth || li.parents('.whb-header').hasClass('whb-full-width')) { 2951 viewportWidth = woodmartThemeModule.$window.width(); 2952 } 2953 2954 dropdownOffsetRight = viewportWidth - dropdownOffset.left - dropdownWidth; 2955 2956 var extraSpace = 15; 2957 var containerOffset = (woodmartThemeModule.$window.width() - viewportWidth) / 2; 2958 var dropdownOffsetLeft; 2959 2960 if (woodmartThemeModule.$body.hasClass('rtl')) { 2961 dropdownOffsetLeft = containerOffset + dropdownOffsetRight; 2962 2963 if (dropdownOffsetLeft + dropdownWidth >= viewportWidth) { 2964 toRight = dropdownOffsetLeft + dropdownWidth - viewportWidth; 2965 2966 $dropdown.css({ 2967 right: -toRight - extraSpace 2968 }); 2969 } 2970 } else { 2971 dropdownOffsetLeft = dropdownOffset.left - containerOffset; 2972 2973 if (dropdownOffsetLeft + dropdownWidth >= viewportWidth) { 2974 toRight = dropdownOffsetLeft + dropdownWidth - viewportWidth; 2975 2976 $dropdown.css({ 2977 left: -toRight - extraSpace 2978 }); 2979 } 2980 } 2981 } 2982 }; 2983 2984 $('.wd-header-main-nav ul.menu > li, .wd-header-secondary-nav ul.menu > li').each(function() { 2985 var $menu = $(this); 2986 2987 if ($menu.hasClass('menu-item')) { 2988 $menu = $(this).parent(); 2989 } 2990 2991 function recalc() { 2992 if ($menu.hasClass('wd-offsets-calculated')) { 2993 return; 2994 } 2995 2996 $menu.find(' > .menu-item-has-children').each(function() { 2997 setOffset($(this)); 2998 }); 2999 3000 woodmartThemeModule.$document.trigger('resize.vcRowBehaviour'); 3001 3002 $menu.addClass('wd-offsets-calculated'); 3003 } 3004 3005 $menu.on('mouseenter mousemove', function() { 3006 recalc() 3007 }); 3008 3009 woodmartThemeModule.$window.on('wdHeaderBuilderStickyChanged', recalc); 3010 3011 if ('yes' === woodmart_settings.clear_menu_offsets_on_resize) { 3012 setTimeout(function() { 3013 woodmartThemeModule.$window.on('resize', woodmartThemeModule.debounce(function() { 3014 $menu.removeClass('wd-offsets-calculated'); 3015 $menu.find(' > .menu-item-has-children > .wd-dropdown-menu').attr('style', ''); 3016 }, 300)); 3017 }, 2000); 3018 } 3019 }); 3020 }; 3021 3022 woodmartThemeModule.$window.on('wdEventStarted', function() { 3023 woodmartThemeModule.menuOffsets(); 3024 }); 3025})(jQuery); 3026 3027/* global woodmart_settings */ 3028(function($) { 3029 woodmartThemeModule.menuSetUp = function() { 3030 var hasChildClass = 'menu-item-has-children', 3031 mainMenu = $('.wd-nav'), 3032 openedClass = 'wd-opened'; 3033 3034 $('.mobile-nav').find('ul.wd-nav-mobile').find(' > li').has('.wd-dropdown-menu').addClass(hasChildClass); 3035 3036 woodmartThemeModule.$document.on('click', '.wd-nav > .wd-event-click > a', function(e) { 3037 e.preventDefault(); 3038 var $this = $(this); 3039 3040 if (!$this.parent().hasClass(openedClass)) { 3041 mainMenu.find('.' + openedClass).removeClass(openedClass); 3042 } 3043 3044 $this.parent().toggleClass(openedClass); 3045 }); 3046 3047 woodmartThemeModule.$document.on('click', function(e) { 3048 var target = e.target; 3049 3050 if ($('.' + openedClass).length > 0 && !$(target).is('.wd-event-hover') && !$(target).parents().is('.wd-event-hover') && !$(target).parents().is('.' + openedClass + '')) { 3051 mainMenu.find('.' + openedClass + '').removeClass(openedClass); 3052 } 3053 }); 3054 3055 if ('yes' === woodmart_settings.menu_item_hover_to_click_on_responsive) { 3056 function menuIpadClick() { 3057 if (woodmartThemeModule.$window.width() <= 1024) { 3058 mainMenu.find(' > .menu-item-has-children.wd-event-hover').each(function() { 3059 $(this).data('original-event', 'hover').removeClass('wd-event-hover').addClass('wd-event-click'); 3060 }); 3061 } else { 3062 mainMenu.find(' > .wd-event-click').each(function() { 3063 var $this = $(this); 3064 3065 if ($this.data('original-event') === 'hover') { 3066 $this.removeClass('wd-event-click').addClass('wd-event-hover'); 3067 } 3068 }); 3069 } 3070 } 3071 3072 menuIpadClick(); 3073 3074 woodmartThemeModule.$window.on('resize', woodmartThemeModule.debounce(function() { 3075 menuIpadClick(); 3076 }, 300)); 3077 } 3078 }; 3079 3080 $(document).ready(function() { 3081 woodmartThemeModule.menuSetUp(); 3082 }); 3083})(jQuery); 3084 3085/* global woodmart_settings */ 3086(function($) { 3087 woodmartThemeModule.mobileNavigation = function() {
3088 var body = woodmartThemeModule.$body, 3089 mobileNav = $('.mobile-nav'), 3090 dropDownCat = $('.mobile-nav .wd-nav-mobile .menu-item-has-children'), 3091 elementIcon = '<span class="wd-nav-opener"></span>'; 3092 3093 var closeSide = $('.wd-close-side'); 3094 3095 dropDownCat.append(elementIcon); 3096 3097 mobileNav.on('click', '.wd-nav-opener', function(e) { 3098 e.preventDefault(); 3099 var $this = $(this); 3100 var $parent = $this.parent(); 3101 3102 if ($parent.hasClass('opener-page')) { 3103 $parent.removeClass('opener-page').find('> ul').slideUp(200); 3104 $parent.removeClass('opener-page').find('.wd-dropdown-menu .container > ul, .wd-dropdown-menu > ul').slideUp(200); 3105 $parent.find('> .wd-nav-opener').removeClass('wd-active'); 3106 } else { 3107 $parent.addClass('opener-page').find('> ul').slideDown(200); 3108 $parent.addClass('opener-page').find('.wd-dropdown-menu .container > ul, .wd-dropdown-menu > ul').slideDown(200); 3109 $parent.find('> .wd-nav-opener').addClass('wd-active'); 3110 } 3111 3112 woodmartThemeModule.$document.trigger('wood-images-loaded'); 3113 }); 3114 3115 mobileNav.on('click', '.wd-nav-mob-tab li', function(e) { 3116 e.preventDefault(); 3117 var $this = $(this); 3118 var menuName = $this.data('menu'); 3119 3120 if ($this.hasClass('wd-active')) { 3121 return; 3122 } 3123 3124 $this.parent().find('.wd-active').removeClass('wd-active'); 3125 $this.addClass('wd-active'); 3126 $('.wd-nav-mobile').removeClass('wd-active'); 3127 $('.mobile-' + menuName + '-menu').addClass('wd-active'); 3128 3129 woodmartThemeModule.$document.trigger('wood-images-loaded'); 3130 }); 3131 3132 body.on('click', '.wd-header-mobile-nav > a', function(e) { 3133 e.preventDefault(); 3134 3135 if (mobileNav.hasClass('wd-opened')) { 3136 closeMenu(); 3137 } else { 3138 openMenu(); 3139 } 3140 }); 3141 3142 body.on('click touchstart', '.wd-close-side', function() { 3143 closeMenu(); 3144 }); 3145 3146 body.on('click', '.mobile-nav .login-side-opener', function() { 3147 closeMenu(); 3148 }); 3149 3150 function openMenu() { 3151 mobileNav.addClass('wd-opened'); 3152 closeSide.addClass('wd-close-side-opened'); 3153 woodmartThemeModule.$document.trigger('wood-images-loaded'); 3154 } 3155 3156 function closeMenu() { 3157 mobileNav.removeClass('wd-opened'); 3158 closeSide.removeClass('wd-close-side-opened'); 3159 $('.mobile-nav .searchform input[type=text]').blur(); 3160 } 3161 }; 3162 3163 $(document).ready(function() { 3164 woodmartThemeModule.mobileNavigation(); 3165 }); 3166})(jQuery); 3167 3168/* global woodmart_settings */ 3169(function($) { 3170 woodmartThemeModule.moreCategoriesButton = function() { 3171 $('.wd-more-cat').each(function() { 3172 var $wrapper = $(this); 3173 3174 $wrapper.find('.wd-more-cat-btn a').on('click', function(e) { 3175 e.preventDefault(); 3176 $wrapper.toggleClass('wd-show-cat'); 3177 }); 3178 }); 3179 }; 3180 3181 $(document).ready(function() { 3182 woodmartThemeModule.moreCategoriesButton(); 3183 }); 3184})(jQuery); 3185 3186/* global woodmart_settings */ 3187(function($) { 3188 woodmartThemeModule.onePageMenu = function() { 3189 var scrollToRow = function(hash) { 3190 var $htmlBody = $('html, body'); 3191 var row = $('#' + hash + ', .wd-menu-anchor[data-id="' + hash + '"]'); 3192 3193 $htmlBody.stop(true); 3194 3195 if (row.length < 1) { 3196 return; 3197 } 3198 3199 var position = row.offset().top; 3200 3201 $htmlBody.animate({ 3202 scrollTop: position - woodmart_settings.one_page_menu_offset 3203 }, 800); 3204 3205 setTimeout(function() { 3206 activeMenuItem(hash); 3207 }, 800); 3208 }; 3209 3210 var activeMenuItem = function(hash) { 3211 var itemHash; 3212 3213 $('.onepage-link').each(function() { 3214 var $this = $(this); 3215 itemHash = $this.find('> a').attr('href').split('#')[1]; 3216 3217 if (itemHash === hash) { 3218 $('.onepage-link').removeClass('current-menu-item'); 3219 $this.addClass('current-menu-item'); 3220 } 3221 }); 3222 }; 3223 3224 woodmartThemeModule.$body.on('click', '.onepage-link > a', function(e) { 3225 var $this = $(this), 3226 hash = $this.attr('href').split('#')[1]; 3227 3228 if ($('#' + hash).length < 1 && $('.wd-menu-anchor[data-id="' + hash + '"]').length < 1) { 3229 return; 3230 } 3231 3232 e.stopPropagation(); 3233 e.preventDefault(); 3234 3235 scrollToRow(hash); 3236 3237 // close mobile menu 3238 $('.wd-close-side').trigger('click'); 3239 $('.wd-fs-close').trigger('click'); 3240 }); 3241 3242 woodmartThemeModule.$window.scroll(function () { 3243 var scroll = woodmartThemeModule.$window.scrollTop(); 3244 var $firstLint = $('.onepage-link:first'); 3245 if ( scroll < 50 && $firstLint.length ) { 3246 activeMenuItem($firstLint.find('> a').attr('href').split('#')[1]); 3247 } 3248 }); 3249 3250 if ($('.onepage-link').length > 0) { 3251 $('.entry-content > .vc_section, .entry-content > .vc_row').waypoint(function() { 3252 var $this = $($(this)[0].element); 3253 var hash = $this.attr('id'); 3254 activeMenuItem(hash); 3255 }, {offset: 150}); 3256 3257 $('.wd-menu-anchor').waypoint(function() { 3258 activeMenuItem($($(this)[0].element).data('id')); 3259 }, { 3260 offset: function() { 3261 return $($(this)[0].element).data('offset'); 3262 } 3263 }); 3264 3265 var locationHash = window.location.hash.split('#')[1]; 3266 3267 if (window.location.hash.length > 1) { 3268 setTimeout(function() { 3269 scrollToRow(locationHash); 3270 }, 500); 3271 } 3272 } 3273 }; 3274 3275 $(document).ready(function() { 3276 woodmartThemeModule.onePageMenu(); 3277 }); 3278})(jQuery); 3279 3280/* global woodmart_settings */ 3281(function($) { 3282 woodmartThemeModule.simpleDropdown = function() { 3283 $('.wd-search-cat').each(function() { 3284 var dd = $(this); 3285 var btn = dd.find('> a'); 3286 var input = dd.find('> input'); 3287 var list = dd.find('> .wd-dropdown'); 3288 var $searchInput = dd.parent().parent().find('.s'); 3289 3290 $searchInput.on('focus', function() { 3291 inputPadding(); 3292 }); 3293 3294 woodmartThemeModule.$document.on('click', function(e) { 3295 var target = e.target; 3296 3297 if (list.hasClass('wd-opened') && !$(target).is('.wd-search-cat') && !$(target).parents().is('.wd-search-cat')) { 3298 hideList(); 3299 return false;
3300 } 3301 }); 3302 3303 btn.on('click', function(e) { 3304 e.preventDefault(); 3305 3306 if (list.hasClass('wd-opened')) { 3307 hideList(); 3308 } else { 3309 showList(); 3310 } 3311 3312 return false; 3313 }); 3314 3315 list.on('click', 'a', function(e) { 3316 e.preventDefault(); 3317 var $this = $(this); 3318 var value = $this.data('val'); 3319 var label = $this.text(); 3320 3321 list.find('.current-item').removeClass('current-item'); 3322 $this.parent().addClass('current-item'); 3323 3324 if (value !== 0) { 3325 list.find('ul:not(.children) > li:first-child').show(); 3326 } else if (value === 0) { 3327 list.find('ul:not(.children) > li:first-child').hide(); 3328 } 3329 3330 btn.find('span').text(label); 3331 input.val(value).trigger('cat_selected'); 3332 hideList(); 3333 inputPadding(); 3334 }); 3335 3336 function showList() { 3337 list.addClass('wd-opened'); 3338 3339 if (typeof ($.fn.devbridgeAutocomplete) != 'undefined') { 3340 dd.parent().siblings('[type="text"]').devbridgeAutocomplete('hide'); 3341 } 3342 3343 setTimeout(function() { 3344 woodmartThemeModule.$document.trigger('wdSimpleDropdownOpened'); 3345 }, 300); 3346 } 3347 3348 function hideList() { 3349 list.removeClass('wd-opened'); 3350 } 3351 3352 function inputPadding() { 3353 if (woodmartThemeModule.$window.width() <= 768 || $searchInput.hasClass('wd-padding-inited') || 'yes' !== woodmart_settings.search_input_padding) { 3354 return; 3355 } 3356 3357 var paddingValue = dd.innerWidth() + dd.parent().siblings('.searchsubmit').innerWidth() + 17, 3358 padding = 'padding-right'; 3359 3360 if (woodmartThemeModule.$body.hasClass('rtl')) { 3361 padding = 'padding-left'; 3362 } 3363 3364 $searchInput.css(padding, paddingValue); 3365 $searchInput.addClass('wd-padding-inited'); 3366 } 3367 }); 3368 }; 3369 3370 $(document).ready(function() { 3371 woodmartThemeModule.simpleDropdown(); 3372 }); 3373})(jQuery); 3374 3375/* global woodmart_settings */ 3376(function($) { 3377 woodmartThemeModule.ajaxPortfolio = function() { 3378 if ('no' === woodmart_settings.ajax_portfolio || 'undefined' === typeof ($.fn.pjax)) { 3379 return; 3380 } 3381 3382 var ajaxLinks = '.wd-type-links .wd-nav-portfolio a, .tax-project-cat .wd-pagination a, .post-type-archive-portfolio .wd-pagination a'; 3383 3384 woodmartThemeModule.$body.on('click', '.tax-project-cat .wd-pagination a, .post-type-archive-portfolio .wd-pagination a', function() { 3385 scrollToTop(true); 3386 }); 3387 3388 woodmartThemeModule.$document.pjax(ajaxLinks, '.main-page-wrapper', { 3389 timeout : woodmart_settings.pjax_timeout, 3390 scrollTo: false, 3391 renderCallback: function(context, html, afterRender) { 3392 woodmartThemeModule.removeDuplicatedStylesFromHTML(html, function(html) { 3393 context.html(html); 3394 afterRender(); 3395 }); 3396 } 3397 }); 3398 3399 woodmartThemeModule.$document.on('pjax:start', function() { 3400 var $siteContent = $('.site-content'); 3401 3402 $siteContent.removeClass('ajax-loaded'); 3403 $siteContent.addClass('ajax-loading'); 3404 3405 woodmartThemeModule.$document.trigger('wdPortfolioPjaxStart'); 3406 woodmartThemeModule.$window.trigger('scroll.loaderVerticalPosition'); 3407 }); 3408 3409 woodmartThemeModule.$document.on('pjax:end', function() { 3410 $('.site-content').removeClass('ajax-loading'); 3411 }); 3412 3413 woodmartThemeModule.$document.on('pjax:complete', function() { 3414 if (!woodmartThemeModule.$body.hasClass('tax-project-cat') && !woodmartThemeModule.$body.hasClass('post-type-archive-portfolio')) { 3415 return; 3416 } 3417 3418 woodmartThemeModule.$document.trigger('wdPortfolioPjaxComplete'); 3419 woodmartThemeModule.$document.trigger('wood-images-loaded'); 3420 3421 scrollToTop(false); 3422 3423 $('.wd-ajax-content').removeClass('wd-loading'); 3424 }); 3425 3426 var scrollToTop = function(type) { 3427 if (woodmart_settings.ajax_scroll === 'no' && type === false) { 3428 return false; 3429 } 3430 3431 var $scrollTo = $(woodmart_settings.ajax_scroll_class), 3432 scrollTo = $scrollTo.offset().top - woodmart_settings.ajax_scroll_offset; 3433 3434 $('html, body').stop().animate({ 3435 scrollTop: scrollTo 3436 }, 400); 3437 }; 3438 }; 3439 3440 $(document).ready(function() { 3441 woodmartThemeModule.ajaxPortfolio(); 3442 }); 3443})(jQuery); 3444 3445/* global woodmart_settings */ 3446(function($) { 3447 woodmartThemeModule.$document.on('wdPortfolioLoadMoreLoaded wdPortfolioPjaxComplete', function () { 3448 woodmartThemeModule.portfolioEffects(); 3449 }); 3450 3451 $.each([ 3452 'frontend/element_ready/wd_portfolio.default', 3453 ], function(index, value) { 3454 woodmartThemeModule.wdElementorAddAction(value, function() { 3455 woodmartThemeModule.portfolioEffects(); 3456 }); 3457 }); 3458 3459 woodmartThemeModule.portfolioEffects = function() { 3460 if (typeof ($.fn.panr) === 'undefined') { 3461 return; 3462 } 3463 3464 $('.wd-portfolio-holder .portfolio-parallax').panr({ 3465 sensitivity : 15, 3466 scale : false, 3467 scaleOnHover : true, 3468 scaleTo : 1.12, 3469 scaleDuration : 0.45, 3470 panY : true, 3471 panX : true, 3472 panDuration : 1.5, 3473 resetPanOnMouseLeave: true 3474 }); 3475 }; 3476 3477 $(document).ready(function() { 3478 woodmartThemeModule.portfolioEffects(); 3479 }); 3480})(jQuery); 3481 3482/* global woodmart_settings */ 3483(function($) { 3484 woodmartThemeModule.$document.on('wdPortfolioPjaxComplete', function () { 3485 woodmartThemeModule.portfolioLoadMore(); 3486 }); 3487 3488 $.each([ 3489 'frontend/element_ready/wd_portfolio.default' 3490 ], function(index, value) { 3491 woodmartThemeModule.wdElementorAddAction(value, function() { 3492 woodmartThemeModule.portfolioLoadMore(); 3493 }); 3494 }); 3495 3496 woodmartThemeModule.portfolioLoadMore = function() { 3497 if (typeof $.fn.waypoint !== 'function') { 3498 return; 3499 } 3500 3501 var waypoint = $('.wd-portfolio-load-more.load-on-scroll').waypoint(function() { 3502 $('.wd-portfolio-load-more.load-on-scroll').trigger('click'); 3503 }, {offset: '100%'}), 3504 process = false;
3505 3506 $('.wd-portfolio-load-more').on('click', function(e) { 3507 e.preventDefault(); 3508 3509 var $this = $(this); 3510 3511 if (process || $this.hasClass('no-more-posts')) { 3512 return; 3513 } 3514 3515 process = true; 3516 3517 var holder = $this.parent().parent().find('.wd-portfolio-holder'), 3518 source = holder.data('source'), 3519 action = 'woodmart_get_portfolio_' + source, 3520 ajaxurl = woodmart_settings.ajaxurl, 3521 dataType = 'json', 3522 method = 'POST', 3523 timeout, 3524 atts = holder.data('atts'), 3525 paged = holder.data('paged'); 3526 3527 $this.addClass('loading'); 3528 3529 var data = { 3530 atts : atts, 3531 paged : paged, 3532 action: action 3533 }; 3534 3535 if (source === 'main_loop') { 3536 ajaxurl = $this.attr('href'); 3537 method = 'GET'; 3538 data = {}; 3539 } 3540 3541 $.ajax({ 3542 url : ajaxurl, 3543 data : data, 3544 dataType: dataType, 3545 method : method, 3546 success : function(data) { 3547 woodmartThemeModule.removeDuplicatedStylesFromHTML(data.items, function(html) { 3548 var items = $(html); 3549 3550 if (items) { 3551 if (holder.hasClass('masonry-container')) { 3552 holder.append(items).isotope('appended', items); 3553 holder.imagesLoaded().progress(function() { 3554 holder.isotope('layout'); 3555 3556 clearTimeout(timeout); 3557 3558 timeout = setTimeout(function() { 3559 waypoint = $('.wd-portfolio-load-more.load-on-scroll').waypoint(function() { 3560 $('.wd-portfolio-load-more.load-on-scroll').trigger('click'); 3561 }, {offset: '100%'}); 3562 }, 1000); 3563 }); 3564 } else { 3565 holder.append(items); 3566 } 3567 3568 holder.data('paged', paged + 1); 3569 3570 $this.attr('href', data.nextPage); 3571 3572 if ('yes' === woodmart_settings.load_more_button_page_url){ 3573 window.history.pushState('', '', data.currentPage); 3574 } 3575 } 3576 3577 woodmartThemeModule.$document.trigger('wdPortfolioLoadMoreLoaded'); 3578 3579 if (data.status === 'no-more-posts') { 3580 $this.addClass('no-more-posts'); 3581 $this.hide(); 3582 } 3583 }); 3584 }, 3585 error : function() { 3586 console.log('ajax error'); 3587 }, 3588 complete: function() { 3589 $this.removeClass('loading'); 3590 process = false; 3591 } 3592 }); 3593 }); 3594 }; 3595 3596 $(document).ready(function() { 3597 woodmartThemeModule.portfolioLoadMore(); 3598 }); 3599})(jQuery); 3600 3601/* global woodmart_settings */ 3602(function($) { 3603 woodmartThemeModule.$document.on('wdPortfolioPjaxComplete', function () { 3604 woodmartThemeModule.portfolioMasonryFilters(); 3605 }); 3606 3607 $.each([ 3608 'frontend/element_ready/wd_portfolio.default', 3609 ], function(index, value) { 3610 woodmartThemeModule.wdElementorAddAction(value, function() { 3611 woodmartThemeModule.portfolioMasonryFilters(); 3612 }); 3613 }); 3614 3615 woodmartThemeModule.portfolioMasonryFilters = function() { 3616 var $filer = $('.wd-nav-portfolio'); 3617 $filer.on('click', 'li', function(e) { 3618 e.preventDefault(); 3619 var $this = $(this); 3620 var filterValue = $this.attr('data-filter'); 3621 3622 setTimeout(function() { 3623 woodmartThemeModule.$document.trigger('wood-images-loaded'); 3624 }, 300); 3625 3626 $filer.find('.wd-active').removeClass('wd-active'); 3627 $this.addClass('wd-active'); 3628 $this.parents('.portfolio-filter').siblings('.masonry-container.wd-portfolio-holder').isotope({ 3629 filter: filterValue 3630 }); 3631 }); 3632 }; 3633 3634 $(document).ready(function() { 3635 woodmartThemeModule.portfolioMasonryFilters(); 3636 }); 3637})(jQuery); 3638 3639/* global woodmart_settings */ 3640(function($) { 3641 woodmartThemeModule.$document.on('wdPortfolioPjaxComplete', function () { 3642 woodmartThemeModule.portfolioPhotoSwipe(); 3643 }); 3644 3645 $.each([ 3646 'frontend/element_ready/wd_portfolio.default', 3647 ], function(index, value) { 3648 woodmartThemeModule.wdElementorAddAction(value, function() { 3649 woodmartThemeModule.portfolioPhotoSwipe(); 3650 }); 3651 }); 3652 3653 woodmartThemeModule.portfolioPhotoSwipe = function() { 3654 woodmartThemeModule.$document.on('click', '.portfolio-enlarge', function(e) { 3655 e.preventDefault(); 3656 var $this = $(this); 3657 var $parent = $this.parents('.owl-item'); 3658 3659 if ($parent.length === 0) { 3660 $parent = $this.parents('.portfolio-entry'); 3661 } 3662 3663 var index = $parent.index(); 3664 var items = getPortfolioImages(); 3665 3666 woodmartThemeModule.callPhotoSwipe(index, items); 3667 }); 3668 3669 var getPortfolioImages = function() { 3670 var items = []; 3671 3672 $('.portfolio-entry').find('figure a img').each(function() { 3673 var $this = $(this); 3674 3675 items.push({ 3676 src: $this.attr('src'), 3677 w : $this.attr('width') ? $this.attr('width') : '300', 3678 h : $this.attr('height') ? $this.attr('height') : '300', 3679 }); 3680 }); 3681 3682 return items; 3683 }; 3684 }; 3685 3686 $(document).ready(function() { 3687 woodmartThemeModule.portfolioPhotoSwipe(); 3688 }); 3689})(jQuery); 3690 3691function ShaderX(options) { 3692 var defaults = { 3693 container : null, 3694 sizeContainer : null, 3695 autoPlay : true, 3696 vertexShader : '', 3697 fragmentShader: '', 3698 width : 0, 3699 height : 0, 3700 mouseMove : false, 3701 distImage : false 3702 }; 3703 this.options = jQuery.extend({}, defaults, options); 3704 this.container = this.options.container; 3705 this.pixelRatio = window.devicePixelRatio; 3706 this.uniforms = {}; 3707 this.time = 0; 3708 this.progress = 0; 3709 this.empty = true; 3710 this.images = {}; 3711 this.texture1 = null; 3712 this.texture2 = null; 3713 this.resizing = false;
3714 this.resizingTimeout = 0; 3715 this.border = 0; 3716 this.scale = 1; 3717 this.drawn = false; 3718 this.runned = false; 3719 this.mouseX = 0; 3720 this.mouseY = 0; 3721 this.loadedTextures = {}; 3722 if (this.options.autoPlay) { 3723 this.init(); 3724 } 3725} 3726 3727ShaderX.prototype = { 3728 3729 init: function() { 3730 var that = this; 3731 window.addEventListener('resize', function() { that.resize(); }); 3732 3733 if (this.options.autoPlay) { 3734 this.runned = true; 3735 this.render(); 3736 this.raf(); 3737 } 3738 3739 }, 3740 3741 render: function() { 3742 3743 if (!this.container.hasClass('wd-with-webgl')) { 3744 this.createCanvas(); 3745 this.container.append(this.canvas); 3746 this.container.addClass('wd-with-webgl'); 3747 } 3748 3749 if (this.gl && ((this.progress > 0 && this.progress < 1) || !this.drawn)) { 3750 this.renderCanvas(); 3751 this.drawn = true; 3752 } 3753 3754 }, 3755 3756 createCanvas: function() { 3757 this.canvas = document.createElement('CANVAS'); 3758 this.gl = this.canvas.getContext('webgl'); 3759 3760 if (!this.gl) { 3761 console.log('WebGL is not supported'); 3762 return; 3763 } 3764 3765 this.canvas.width = this.options.width * this.pixelRatio; 3766 this.canvas.height = this.options.height * this.pixelRatio; 3767 3768 var vertexShader = this.createShader(this.gl.VERTEX_SHADER, this.options.vertexShader), 3769 fragmentShader = this.createShader(this.gl.FRAGMENT_SHADER, this.options.fragmentShader); 3770 3771 this.program = this.createProgram(vertexShader, fragmentShader); 3772 3773 var positionAttributeLocation = this.gl.getAttribLocation(this.program, 'a_position'); 3774 3775 var positionBuffer = this.gl.createBuffer(); 3776 this.gl.bindBuffer(this.gl.ARRAY_BUFFER, positionBuffer); 3777 3778 var x1 = 0; 3779 var x2 = this.options.width * this.pixelRatio; 3780 var y1 = 0; 3781 var y2 = this.options.height * this.pixelRatio; 3782 3783 var positions = [ 3784 x1, 3785 y1, 3786 x2, 3787 y1, 3788 x1, 3789 y2, 3790 x1, 3791 y2, 3792 x2, 3793 y1, 3794 x2, 3795 y2 3796 ]; 3797 3798 this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(positions), this.gl.STATIC_DRAW); 3799 3800 // Tell Webthis.GL how to convert from clip space to pixels 3801 this.gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height); 3802 3803 // Clear the canvas 3804 this.gl.clearColor(0, 0, 0, 0); 3805 this.gl.clear(this.gl.COLOR_BUFFER_BIT); 3806 3807 // Tell it to use our program (pair of shaders) 3808 this.gl.useProgram(this.program); 3809 3810 // Compute the matrices 3811 var projectionMatrix = [ 3812 2 / this.gl.canvas.width, 3813 0, 3814 0, 3815 0, 3816 -2 / this.gl.canvas.height, 3817 0, 3818 -1, 3819 1, 3820 1 3821 ]; 3822 3823 this.addUniform('3fv', 'u_matrix', projectionMatrix); 3824 this.addUniform('1f', 'u_flipY', 1); 3825 this.addUniform('1f', 'u_time', 0.0); 3826 this.addUniform('2f', 'u_pixels', [ 3827 this.options.width * this.pixelRatio, 3828 this.options.height * this.pixelRatio 3829 ]); 3830 this.addUniform('1f', 'u_progress', 0); 3831 this.addUniform('2f', 'u_resolution', [ 3832 this.gl.canvas.width, 3833 this.gl.canvas.height 3834 ]); 3835 this.addUniform('2f', 'u_uvRate', [ 3836 1, 3837 1 3838 ]); 3839 this.addUniform('1f', 'u_scale', this.scale); 3840 3841 if (this.options.mouseMove) { 3842 this.addUniform('2f', 'u_mouse', [ 3843 0.5, 3844 0 3845 ]); 3846 } 3847 3848 // Turn on the attribute 3849 this.gl.enableVertexAttribArray(positionAttributeLocation); 3850 3851 // Tell the attribute how to get data out of positionBuffer (ARRAY_BUFFER) 3852 var size = 2; // 2 components per iteration 3853 var type = this.gl.FLOAT; // the data is 32bit floats 3854 var normalize = false; // don't normalize the data 3855 var stride = 0; // 0 = move forward size * sizeof(type) each iteration to get the next position 3856 var offset = 0; // start at the beginning of the buffer 3857 this.gl.vertexAttribPointer(positionAttributeLocation, size, type, normalize, stride, offset); 3858 3859 var texCoordLocation = this.gl.getAttribLocation(this.program, 'a_texCoord'); 3860 3861 // set coordinates for the rectanthis.gle 3862 var texCoordBuffer = this.gl.createBuffer(); 3863 this.gl.bindBuffer(this.gl.ARRAY_BUFFER, texCoordBuffer); 3864 this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([ 3865 0.0, 3866 0.0, 3867 1.0, 3868 0.0, 3869 0.0, 3870 1.0, 3871 0.0, 3872 1.0, 3873 1.0, 3874 0.0, 3875 1.0, 3876 1.0 3877 ]), this.gl.STATIC_DRAW); 3878 this.gl.enableVertexAttribArray(texCoordLocation); 3879 this.gl.vertexAttribPointer(texCoordLocation, 2, this.gl.FLOAT, false, 0, 0); 3880 3881 if (this.texture1) { 3882 this.loadImageTexture(this.texture1, 0); 3883 } 3884 3885 if (this.options.distImage) { 3886 var distImage = new Image(); 3887 3888 this.requestCORSIfNotSameOrigin(distImage, this.options.distImage); 3889 3890 distImage.src = this.options.distImage; 3891 3892 var that = this; 3893 3894 distImage.onload = function() { 3895 that.loadImageTexture(distImage, 2); 3896 }; 3897 } 3898 }, 3899 3900 raf: function() { 3901 if (!this.canvas) { 3902 return; 3903 } 3904 3905 var that = this; 3906 3907 function animate() { 3908 that.time += 0.03; 3909 3910 that.updateUniform('u_time', that.time); 3911 3912 if (that.options.mouseMove) { 3913 var currentMouse = that.getUniform('u_mouse'), 3914 currentX = currentMouse[0], 3915 currentY = currentMouse[1]; 3916 3917 var newX = (!currentX) ? that.mouseX : currentX + (that.mouseX - currentX) * .05, 3918 newY = (!currentY) ? that.mouseY : currentY + (that.mouseY - currentY) * .05; 3919 3920 that.updateUniform('u_mouse', [ 3921 newX, 3922 newY 3923 ]); 3924 } 3925 3926 if (that.progress < 0) { 3927 that.progress = 0; 3928 } 3929 if (that.progress > 1) { 3930 that.progress = 1; 3931 } 3932 3933 that.updateUniform('u_progress', that.progress); 3934 3935 that.updateUniform('u_scale', that.scale); 3936 3937 that.render(); 3938 that.requestID = window.requestAnimationFrame(animate); 3939 } 3940 3941 animate(); 3942 3943 }, 3944 3945 resize: function() { 3946 3947 var that = this; 3948 3949 clearTimeout(this.resizingTimeout); 3950 3951 this.resizingTimeout = setTimeout(function() { 3952 3953 if (!that.canvas) { 3954 return; 3955 } 3956 3957 var displayWidth = Math.floor(that.options.sizeContainer.outerWidth() * that.pixelRatio); 3958 var displayHeight = Math.floor(that.options.sizeContainer.outerHeight() * that.pixelRatio); 3959 3960 if (that.gl.canvas.width !== displayWidth || that.gl.canvas.height !== displayHeight) { 3961 that.gl.canvas.width = displayWidth; 3962 that.gl.canvas.height = displayHeight; 3963 } 3964 3965 that.updateUniform('u_resolution', [ 3966 displayWidth, 3967 displayHeight 3968 ]); 3969 that.updateUniform('u_pixels', [ 3970 displayWidth, 3971 displayHeight 3972 ]); 3973 that.updateUniform('u_uvRate', [ 3974 1, 3975 displayHeight / displayWidth 3976 ]); 3977 3978 that.gl.viewport(0, 0, displayWidth, displayHeight);
3979 that.drawn = false; 3980 3981 }, 500); 3982 }, 3983 3984 run: function() { 3985 if (this.runned) { 3986 return; 3987 } 3988 this.runned = true; 3989 this.render(); 3990 this.raf(); 3991 }, 3992 3993 stop: function() { 3994 if (!this.runned) { 3995 return; 3996 } 3997 window.cancelAnimationFrame(this.requestID); 3998 this.destroyCanvas(); 3999 this.container.find('canvas').remove(); 4000 this.container.removeClass('wd-with-webgl'); 4001 this.runned = false; 4002 }, 4003 4004 renderCanvas: function() { 4005 4006 if (this.empty) { 4007 return false; 4008 } 4009 4010 // this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT); 4011 this.gl.drawArrays(this.gl.TRIANGLES, 0, 6); 4012 }, 4013 4014 destroyCanvas: function() { 4015 4016 if (!this.gl) { 4017 return; 4018 } 4019 4020 this.canvas = null; 4021 this.gl.getExtension('WEBGL_lose_context').loseContext(); 4022 this.gl = null; 4023 }, 4024 4025 createShader: function(type, source) { 4026 var shader = this.gl.createShader(type); 4027 this.gl.shaderSource(shader, source); 4028 this.gl.compileShader(shader); 4029 var success = this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS); 4030 4031 if (success) { 4032 return shader; 4033 } 4034 4035 console.log(this.gl.getShaderInfoLog(shader)); 4036 this.gl.deleteShader(shader); 4037 }, 4038 4039 createProgram: function(vertexShader, fragmentShader) { 4040 var program = this.gl.createProgram(); 4041 this.gl.attachShader(program, vertexShader); 4042 this.gl.attachShader(program, fragmentShader); 4043 this.gl.linkProgram(program); 4044 var success = this.gl.getProgramParameter(program, this.gl.LINK_STATUS); 4045 4046 if (success) { 4047 return program; 4048 } 4049 4050 console.log(this.gl.getProgramInfoLog(program)); 4051 this.gl.deleteProgram(program); 4052 }, 4053 4054 addUniform: function(type, name, value) { 4055 var location = this.gl.getUniformLocation(this.program, name); 4056 4057 this.uniforms[name] = { 4058 location: location, 4059 type : type 4060 }; 4061 4062 if (value !== false) { 4063 this.updateUniform(name, value); 4064 } 4065 4066 }, 4067 4068 updateUniform: function(name, value) { 4069 if (!this.gl) { 4070 return; 4071 } 4072 4073 var uniform = this.uniforms[name]; 4074 4075 switch (uniform.type) { 4076 case '1f': 4077 this.gl.uniform1f(uniform.location, value); 4078 break; 4079 case '2f': 4080 this.gl.uniform2f(uniform.location, value[0], value[1]); 4081 break; 4082 case '1i': 4083 this.gl.uniform1i(uniform.location, value); 4084 break; 4085 case '3fv': 4086 this.gl.uniformMatrix3fv(uniform.location, false, value); 4087 break; 4088 } 4089 }, 4090 4091 getUniform: function(name, value) { 4092 if (!this.gl) { 4093 return; 4094 } 4095 4096 var uniform = this.uniforms[name]; 4097 4098 return this.gl.getUniform(this.program, uniform.location); 4099 }, 4100 4101 getImageId: function(src) { 4102 var id = ''; 4103 var parts = src.split('/'); 4104 id = parts[parts.length - 3] + '-' + parts[parts.length - 2] + '-' + parts[parts.length - 1]; 4105 return id; 4106 }, 4107 4108 loadImage: function(src, i, callback, preload) { 4109 var imageId = this.getImageId(src); 4110 var image; 4111 4112 if (this.images[imageId]) { 4113 image = this.images[imageId]; 4114 if (preload) { 4115 return; 4116 } 4117 4118 if (i === 0) { 4119 this.texture1 = image; 4120 } else if (i === 1) { 4121 this.texture2 = image; 4122 } 4123 this.loadImageTexture(image, i); 4124 this.empty = false; 4125 this.drawn = false; 4126 (callback) ? callback() : ''; 4127 return; 4128 } 4129 4130 image = new Image(); 4131 4132 this.requestCORSIfNotSameOrigin(image, src); 4133 4134 image.src = src; 4135 4136 var that = this; 4137 4138 image.onload = function() { 4139 4140 that.images[imageId] = image; 4141 if (preload) { 4142 return; 4143 } 4144 4145 if (i === 0) { 4146 that.texture1 = image; 4147 } else { 4148 that.texture2 = image; 4149 } 4150 4151 that.loadImageTexture(image, i); 4152 that.empty = false; 4153 that.drawn = false; 4154 (callback) ? callback() : ''; 4155 }; 4156 4157 }, 4158 4159 requestCORSIfNotSameOrigin: function(image, src) { 4160 if ((new URL(src, window.location.href)).origin !== window.location.origin) { 4161 image.crossOrigin = ''; 4162 } 4163 }, 4164 4165 loadImageTexture: function(image, i) { 4166 if (!this.gl) { 4167 return; 4168 } 4169 // Create texture 4170 var texture; 4171 4172 if (this.loadedTextures[i]) { 4173 texture = this.loadedTextures[i]; 4174 4175 var textureID = this.gl.TEXTURE0 + i; 4176 4177 this.gl.activeTexture(textureID); 4178 this.gl.bindTexture(this.gl.TEXTURE_2D, texture); 4179 4180 // load image to texture 4181 this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, this.gl.RGBA, this.gl.UNSIGNED_BYTE, image); 4182 4183 this.addUniform('1i', 'u_image' + i, i); 4184 this.addUniform('2f', 'u_image' + i + '_size', [ 4185 image.width, 4186 image.height 4187 ]); 4188 4189 } else { 4190 texture = this.gl.createTexture(); 4191 4192 var textureID = this.gl.TEXTURE0 + i; 4193 4194 this.gl.activeTexture(textureID); 4195 this.gl.bindTexture(this.gl.TEXTURE_2D, texture); 4196 4197 // Set texture parameters to be able to draw any size image 4198 this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE); 4199 this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE); 4200 this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR); 4201 this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR); 4202 4203 // load image to texture 4204 this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, this.gl.RGBA, this.gl.UNSIGNED_BYTE, image); 4205 4206 this.addUniform('1i', 'u_image' + i, i); 4207 this.addUniform('2f', 'u_image' + i + '_size', [ 4208 image.width, 4209 image.height 4210 ]); 4211 4212 // flip coordinates 4213 this.updateUniform('u_flipY', -1); 4214 } 4215 4216 }, 4217 4218 replaceImage: function(src) { 4219 var that = this; 4220 var imageId = this.getImageId(src); 4221 4222 if (this.texture2) { 4223 that.loadImageTexture(this.texture2, 0); 4224 that.loadImageTexture(this.texture2, 1); 4225 } 4226 4227 var ease = function(t) { return t * (2 - t); }; 4228 4229 this.loadImage(src, 1, function() { 4230 var time = 1300; 4231 var fps = 60; 4232 var frameTime = 1000 / fps; 4233 var frames = time / frameTime; 4234 var step = 1 / frames; 4235 var requestID; 4236 var t = 0; 4237 4238 function progress() { 4239 t += step; 4240 4241 that.progress = ease(t); 4242 4243 if (that.progress >= 1) { 4244 window.cancelAnimationFrame(requestID); 4245 return; 4246 } 4247 4248 requestID = window.requestAnimationFrame(progress); 4249 } 4250 4251 that.progress = 0; 4252 4253 progress(); 4254 }); 4255 } 4256}; 4257 4258woodmartThemeModule.shaders = { 4259 matrixVertex: '' + 4260 'attribute vec2 a_texCoord;' + 4261 'attribute vec2 a_position;' + 4262 'uniform mat3 u_matrix;' + 4263 'void main() {' + 4264 ' gl_Position = vec4( ( u_matrix * vec3(a_position, 1) ).xy, 0, 1);' + 4265 ' a_texCoord;' + 4266 '}', 4267 4268 sliderWithNoise: 4269 'precision mediump float;' + 4270 'uniform float u_time;' + 4271 'uniform float u_progress;' + 4272 'uniform sampler2D u_image0;' + 4273 'uniform vec2 u_image0_size;' + 4274 'uniform sampler2D u_image1;' + 4275 'uniform vec2 u_image1_size;' + 4276 'uniform vec2 u_pixels;' + 4277 'uniform vec2 u_mouse;' + 4278 'uniform vec2 u_uvRate;' + 4279 'uniform float u_scale;' + 4280 'float rand(vec2 seed) {' + 4281 ' return fract(sin(dot(seed, vec2(1.29898,7.8233))) * 4.37585453123);' + 4282 '}' + 4283 'float noise(vec2 position) {' + 4284 ' vec2 block_position = floor(position);' + 4285 4286 ' float top_left_value = rand(block_position);' + 4287 ' float top_right_value = rand(block_position + vec2(1.0, 0.0));' + 4288 ' float bottom_left_value = rand(block_position + vec2(0.0, 1.0));' + 4289 ' float bottom_right_value = rand(block_position + vec2(1.0, 1.0));' + 4290 4291 ' vec2 computed_value = smoothstep(0.0, 1.0, fract(position));' + 4292 4293 ' return mix(top_left_value, top_right_value, computed_value.x)' + 4294 ' + (bottom_left_value - top_left_value) * computed_value.y * (1.0 - computed_value.x)' + 4295 ' + (bottom_right_value - top_right_value) * computed_value.x * computed_value.y' + 4296 ' - 0.5;' + 4297 '}' + 4298 'void main() {' + 4299 ' vec2 uv = gl_FragCoord.xy/u_pixels.xy;' + 4300 ' uv.y = 1.0 - uv.y;' + 4301 ' vec2 uv2 = uv;' + 4302 ' vec2 s = u_pixels.xy/10.;' + 4303 ' vec2 i = u_image0_size/10.;' + 4304 ' float rs = s.x / s.y;' + 4305 ' float ri = i.x / i.y;' + 4306 ' vec2 new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x);' + 4307 ' vec2 offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;' + 4308 ' uv = uv * s / new + offset;' + 4309 4310 ' i = u_image1_size/10.;' + 4311 ' ri = i.x / i.y;' + 4312 ' new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x);' + 4313 ' offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;' + 4314 ' uv2 = uv2 * s / new + offset;' + 4315 4316 ' float delayValue = clamp(u_progress, 0., 1.);' +
4317 ' float d = distance(u_mouse*u_uvRate, uv*u_uvRate);' + 4318 4319 ' float ppp = ((u_progress - .5) * (u_progress - .5) - .25 );' + 4320 ' vec2 uv_offset = ppp * 1.1 * vec2( noise(uv * 10.0 + sin(u_time + uv.x * 5.0)) / 10.0, noise(uv * 10.0 + cos(u_time + uv.y * 5.0)) / 10.0);' + 4321 ' uv += uv_offset;' + 4322 ' uv2 += uv_offset;' + 4323 ' uv = (uv - vec2(.5, .5)) * u_scale + 0.5;' + 4324 ' vec4 rgba1 = texture2D( u_image0, uv );' + 4325 ' vec4 rgba2 = texture2D( u_image1, uv2 );' + 4326 ' vec4 rgba = mix(rgba1, rgba2, delayValue);' + 4327 ' gl_FragColor = rgba;' + 4328 // ' gl_FragColor = vec4(uv, 0., 1.);' + 4329 '}', 4330 4331 sliderPattern: 4332 'precision mediump float;' + 4333 'uniform float u_time;' + 4334 'uniform float u_progress;' + 4335 'uniform sampler2D u_image0;' + 4336 'uniform vec2 u_image0_size;' + 4337 'uniform sampler2D u_image1;' + 4338 'uniform vec2 u_image1_size;' + 4339 'uniform sampler2D u_image2;' + 4340 'uniform vec2 u_image2_size;' + 4341 'uniform vec2 u_pixels;' + 4342 'void main() {' + 4343 ' vec2 uv = gl_FragCoord.xy/u_pixels.xy;' + 4344 ' uv.y = 1.0 - uv.y;' + 4345 ' vec2 uv2 = uv;' + 4346 ' vec2 s = u_pixels.xy/10.;' + 4347 ' vec2 i = u_image0_size/10.;' + 4348 ' float rs = s.x / s.y;' + 4349 ' float ri = i.x / i.y;' + 4350 ' vec2 new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x);' + 4351 ' vec2 offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;' + 4352 ' uv = uv * s / new + offset;' + 4353 4354 ' i = u_image1_size/10.;' + 4355 ' ri = i.x / i.y;' + 4356 ' new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x);' + 4357 ' offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;' + 4358 ' uv2 = uv2 * s / new + offset;' + 4359 4360 'vec4 disp = texture2D(u_image2, uv);' + 4361 'float effectFactor = 0.4;' + 4362 4363 'vec2 distortedPosition = vec2(uv.x + u_progress * (disp.r*effectFactor), uv.y);' + 4364 'vec2 distortedPosition2 = vec2(uv.x - (1.0 - u_progress) * (disp.r*effectFactor), uv.y);' + 4365 4366 'vec4 _texture = texture2D(u_image0, distortedPosition);' + 4367 'vec4 _texture2 = texture2D(u_image1, distortedPosition2);' + 4368 4369 'vec4 finalTexture = mix(_texture, _texture2, u_progress);' + 4370 'gl_FragColor = finalTexture;' + 4371 // ' gl_FragColor = vec4(uv, 0., 1.);' + 4372 '}', 4373 4374 sliderWithWave: 4375 'precision mediump float;' + 4376 'uniform float u_time;' + 4377 'uniform float u_progress;' + 4378 'uniform sampler2D u_image0;' + 4379 'uniform vec2 u_image0_size;' + 4380 'uniform sampler2D u_image1;' + 4381 'uniform vec2 u_image1_size;' + 4382 'uniform vec2 u_pixels;' + 4383 'uniform vec2 u_mouse;' + 4384 'uniform vec2 u_uvRate;' + 4385 'uniform float u_scale;' + 4386 4387 ' vec2 mirrored(vec2 v) {' + 4388 ' vec2 m = mod(v,2.);' + 4389 ' return mix(m,2.0 - m, step(1.0 ,m));' + 4390 ' }' + 4391 4392 ' float tri(float p) {' + 4393 ' return mix(p,1.0 - p, step(0.5 ,p))*2.;' + 4394 ' }' + 4395 4396 'void main() {' + 4397 ' vec2 uv = gl_FragCoord.xy/u_pixels.xy;' + 4398 ' uv.y = 1.0 - uv.y;' + 4399 ' vec2 uv2 = uv;' + 4400 ' vec2 s = u_pixels.xy/10.;' + // problem on mobile devices that is why we scale the value by 10x 4401 ' vec2 i = u_image0_size.xy/10.;' + // problem on mobile devices that is why we scale the value by 10x 4402 ' float rs = s.x / s.y;' + // 0.646 4403 ' float ri = i.x / i.y;' + // 2.23 4404 ' vec2 new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, (i.y * s.x) / i.x);' + // 375. 167.9 4405 ' vec2 offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;' + 4406 ' uv = uv * s / new + offset;' + 4407 ' i = u_image1_size.xy/10.;' + 4408 ' ri = i.x / i.y;' + 4409 ' new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x);' + 4410 ' offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;' + 4411 ' uv2 = uv2 * s / new + offset;' + 4412 4413 ' float delayValue = u_progress*6.5 - uv.y*2. + uv.x - 3.0;' + 4414 ' vec2 accel = vec2(0.5,2.);' + 4415 4416 ' delayValue = clamp(delayValue,0.,1.);' + 4417 4418 ' vec2 translateValue = u_progress + delayValue*accel;' + 4419 ' vec2 translateValue1 = vec2(-0.5,1.)* translateValue;' + 4420 ' vec2 translateValue2 = vec2(-0.5,1.)* (translateValue - 1. - accel);' + 4421 4422 ' vec2 w = sin( sin(u_time) * vec2(0,0.3) + uv.yx*vec2(0,4.))*vec2(0,0.5);' + 4423 ' vec2 xy = w*(tri(u_progress)*0.5 + tri(delayValue)*0.5);' + 4424 4425 ' vec2 uv1 = uv + translateValue1 + xy;' + 4426 ' uv2 = uv2 + translateValue2 + xy;' + 4427 4428 ' vec4 rgba1 = texture2D(u_image0,mirrored(uv1));' + 4429 ' vec4 rgba2 = texture2D(u_image1,mirrored(uv2));' + 4430 4431 ' vec4 rgba = mix(rgba1,rgba2,delayValue);' + 4432 // ' gl_FragColor = vec4(0.1,0.1,0.1, 1.);' + 4433 ' gl_FragColor = rgba;' + 4434 '}', 4435 4436 hoverWave: 4437 'precision mediump float;' + 4438 'uniform float u_time;' + 4439 'uniform float u_progress;' + 4440 'uniform sampler2D u_image;' + 4441 'uniform vec2 u_pixels;' + 4442 'uniform vec2 u_mouse;' + 4443 'uniform vec2 u_uvRate;' + 4444 'uniform float u_scale;' + 4445 4446 'void main() {' + 4447 ' vec2 uv = gl_FragCoord.xy/u_pixels.xy;' + 4448 ' uv.y = 1.0 - uv.y;' +
4449 ' float d = distance(u_mouse*u_uvRate, uv*u_uvRate);' + 4450 ' float ppp = ((u_progress - .5) * (u_progress - .5) - .25 );' + 4451 ' float dY = sin(uv.y * 44.005 + u_time * 4.5) * 0.02 * ppp;' + 4452 ' float dX = sin(uv.x * 30.005 + u_time * 3.2) * 0.02 * ppp;' + 4453 ' if( u_progress > 0. && d < .1 ) {' + 4454 ' dX *= smoothstep( 0., .15, (.15 - d) ) * 5.;' + 4455 ' dY *= smoothstep( 0., .15, (.15 - d) ) * 5.;' + 4456 ' }' + 4457 ' uv.y += dY;' + 4458 ' uv.x += dX;' + 4459 ' gl_FragColor = texture2D(u_image, uv);' + 4460 '}' 4461}; 4462 4463/* global woodmart_settings */ 4464(function($) { 4465 woodmartThemeModule.$document.on('wdCarouselFlickityInited', function () { 4466 woodmartThemeModule.sliderDistortion(); 4467 }); 4468 4469 woodmartThemeModule.sliderDistortion = function() { 4470 var $elements = $('.wd-slider-wrapper.anim-distortion'); 4471 4472 if ('undefined' === typeof ShaderX || woodmartThemeModule.$body.hasClass('single-woodmart_slide')) { 4473 return; 4474 } 4475 4476 $elements.each(function() { 4477 var $slider = $(this), 4478 $slides = $slider.find('.wd-slide'), 4479 imgSrc = $slides.eq(0).data('image-url'), 4480 imgSrc2 = $slides.eq(1).data('image-url'); 4481 4482 if ($slider.hasClass('webgl-inited') || !imgSrc || !imgSrc2) { 4483 return; 4484 } 4485 4486 $slider.addClass('webgl-inited'); 4487 4488 var shaderX = new ShaderX({ 4489 container : $slider.find('.flickity-viewport'), 4490 sizeContainer : $slider, 4491 vertexShader : woodmartThemeModule.shaders.matrixVertex, 4492 fragmentShader: woodmartThemeModule.shaders[woodmart_settings.slider_distortion_effect] ? woodmartThemeModule.shaders[woodmart_settings.slider_distortion_effect] : woodmartThemeModule.shaders.sliderWithWave, 4493 width : $slider.outerWidth(), 4494 height : $slider.outerHeight(), 4495 distImage : woodmart_settings.slider_distortion_effect === 'sliderPattern' ? woodmart_settings.theme_url + '/images/dist11.jpg' : false 4496 }); 4497 4498 shaderX.loadImage(imgSrc, 0, function() { 4499 $slider.addClass('wd-canvas-image-loaded'); 4500 }); 4501 shaderX.loadImage(imgSrc, 1); 4502 shaderX.loadImage(imgSrc2, 0, undefined, true); 4503 4504 $slider.on('change.flickity', function(event, index) { 4505 imgSrc = $slides.eq(index).data('image-url'); 4506 4507 if (!imgSrc) { 4508 return; 4509 } 4510 4511 shaderX.replaceImage(imgSrc); 4512 4513 if ($slides.eq(index + 1).length > 0) { 4514 imgSrc2 = $slides.eq(index + 1).data('image-url'); 4515 if ( imgSrc2 ) { 4516 shaderX.loadImage(imgSrc2, 0, undefined, true); 4517 } 4518 } 4519 }); 4520 }); 4521 }; 4522})(jQuery); 4523 4524/* global woodmart_settings */ 4525(function($) { 4526 $.each([ 4527 'frontend/element_ready/wd_products.default', 4528 'frontend/element_ready/wd_products_tabs.default' 4529 ], function(index, value) { 4530 woodmartThemeModule.wdElementorAddAction(value, function() { 4531 woodmartThemeModule.addToCart(); 4532 }); 4533 }); 4534 4535 woodmartThemeModule.addToCart = function() { 4536 var that = this; 4537 var timeoutNumber = 0; 4538 var timeout; 4539 4540 woodmartThemeModule.$body.on('added_to_cart', function() { 4541 if (woodmart_settings.add_to_cart_action === 'popup') { 4542 var html = [ 4543 '<div class="added-to-cart">', 4544 '<h3>' + woodmart_settings.added_to_cart + '</h3>', 4545 '<a href="#" class="btn btn-style-link btn-color-default close-popup">' + woodmart_settings.continue_shopping + '</a>', 4546 '<a href="' + woodmart_settings.cart_url + '" class="btn btn-color-primary view-cart">' + woodmart_settings.view_cart + '</a>', 4547 '</div>' 4548 ].join(''); 4549 4550 $.magnificPopup.open({ 4551 removalDelay: 500, //delay removal by X to allow out-animation 4552 tClose : woodmart_settings.close, 4553 tLoading : woodmart_settings.loading, 4554 callbacks : { 4555 beforeOpen: function() { 4556 this.st.mainClass = 'mfp-move-horizontal cart-popup-wrapper'; 4557 } 4558 }, 4559 items : { 4560 src : '<div class="mfp-with-anim wd-popup white-popup popup-added_to_cart">' + html + '</div>', 4561 type: 'inline' 4562 } 4563 }); 4564 4565 $('.white-popup').on('click', '.close-popup', function(e) { 4566 e.preventDefault(); 4567 $.magnificPopup.close(); 4568 }); 4569 4570 closeAfterTimeout(); 4571 } else if (woodmart_settings.add_to_cart_action === 'widget') { 4572 clearTimeout(timeoutNumber); 4573 var $selector = $('.act-scroll .wd-header-cart .wd-dropdown-cart, .whb-sticked .wd-header-cart .wd-dropdown-cart'); 4574 4575 if ($selector.length > 0) { 4576 $selector.addClass('wd-opened'); 4577 } else { 4578 $('.whb-header .wd-header-cart .wd-dropdown-cart').addClass('wd-opened'); 4579 } 4580 4581 var $cartOpener = $('.cart-widget-opener'); 4582 if ($cartOpener.length > 0) { 4583 $cartOpener.first().trigger('click'); 4584 } 4585 4586 timeoutNumber = setTimeout(function() { 4587 $('.wd-dropdown-cart').removeClass('wd-opened'); 4588 }, 3500); 4589 4590 closeAfterTimeout(); 4591 } 4592 4593 woodmartThemeModule.$document.trigger('wdActionAfterAddToCart'); 4594 }); 4595 4596 var closeAfterTimeout = function() { 4597 if ('yes' !== woodmart_settings.add_to_cart_action_timeout) { 4598 return false;
4599 } 4600 4601 clearTimeout(timeout); 4602 4603 timeout = setTimeout(function() { 4604 $('.wd-close-side').trigger('click'); 4605 $.magnificPopup.close(); 4606 }, parseInt(woodmart_settings.add_to_cart_action_timeout_number) * 1000); 4607 }; 4608 }; 4609 4610 $(document).ready(function() { 4611 woodmartThemeModule.addToCart(); 4612 }); 4613})(jQuery); 4614 4615/* global woodmart_settings */ 4616(function($) { 4617 woodmartThemeModule.addToCartAllTypes = function() { 4618 if (woodmart_settings.ajax_add_to_cart == false) { 4619 return; 4620 } 4621 4622 woodmartThemeModule.$body.on('submit', 'form.cart', function(e) { 4623 var $form = $(this); 4624 var $productWrapper = $form.parents('.single-product-page'); 4625 4626 if ($productWrapper.length === 0) { 4627 $productWrapper = $form.parents('.product-quick-view'); 4628 } 4629 4630 if ($productWrapper.hasClass('product-type-external') || $productWrapper.hasClass('product-type-zakeke') || $productWrapper.hasClass('product-type-gift-card')) { 4631 return; 4632 } 4633 4634 e.preventDefault(); 4635 4636 var $thisbutton = $form.find('.single_add_to_cart_button'), 4637 data = $form.serialize(); 4638 4639 data += '&action=woodmart_ajax_add_to_cart'; 4640 4641 if ($thisbutton.val()) { 4642 data += '&add-to-cart=' + $thisbutton.val(); 4643 } 4644 4645 $thisbutton.removeClass('added not-added'); 4646 $thisbutton.addClass('loading'); 4647 4648 // Trigger event 4649 woodmartThemeModule.$body.trigger('adding_to_cart', [ 4650 $thisbutton, 4651 data 4652 ]); 4653 4654 $.ajax({ 4655 url : woodmart_settings.ajaxurl, 4656 data : data, 4657 method : 'POST', 4658 success : function(response) { 4659 if (!response) { 4660 return; 4661 } 4662 4663 var this_page = window.location.toString(); 4664 4665 this_page.replace('add-to-cart', 'added-to-cart'); 4666 4667 if (response.error && response.product_url) { 4668 window.location = response.product_url; 4669 return; 4670 } 4671 4672 // Redirect to cart option 4673 if (woodmart_settings.cart_redirect_after_add === 'yes') { 4674 window.location = woodmart_settings.cart_url; 4675 } else { 4676 4677 $thisbutton.removeClass('loading'); 4678 4679 var fragments = response.fragments; 4680 var cart_hash = response.cart_hash; 4681 4682 // Block fragments class 4683 if (fragments) { 4684 $.each(fragments, function(key) { 4685 $(key).addClass('updating'); 4686 }); 4687 } 4688 4689 // Replace fragments 4690 if (fragments) { 4691 $.each(fragments, function(key, value) { 4692 $(key).replaceWith(value); 4693 }); 4694 } 4695 4696 // Show notices 4697 var $noticeWrapper = $('.woocommerce-notices-wrapper'); 4698 $noticeWrapper.empty(); 4699 if (response.notices.indexOf('error') > 0) { 4700 $noticeWrapper.append(response.notices); 4701 $thisbutton.addClass('not-added'); 4702 } else { 4703 if (woodmart_settings.add_to_cart_action === 'widget') { 4704 $.magnificPopup.close(); 4705 } 4706 4707 // Changes button classes 4708 $thisbutton.addClass('added'); 4709 // Trigger event so themes can refresh other areas 4710 woodmartThemeModule.$body.trigger('added_to_cart', [ 4711 fragments, 4712 cart_hash, 4713 $thisbutton 4714 ]); 4715 } 4716 } 4717 }, 4718 error : function() { 4719 console.log('ajax adding to cart error'); 4720 }, 4721 complete: function() { } 4722 }); 4723 }); 4724 }; 4725 4726 $(document).ready(function() { 4727 woodmartThemeModule.addToCartAllTypes(); 4728 }); 4729})(jQuery); 4730 4731/* global woodmart_settings */ 4732(function($) { 4733 woodmartThemeModule.ajaxFilters = function() { 4734 if (!woodmartThemeModule.$body.hasClass('woodmart-ajax-shop-on') || typeof ($.fn.pjax) === 'undefined' || woodmartThemeModule.$body.hasClass('single-product')) { 4735 return; 4736 } 4737 4738 var that = this, 4739 filtersState = false; 4740 4741 woodmartThemeModule.$body.on('click', '.post-type-archive-product .products-footer .woocommerce-pagination a', function() { 4742 scrollToTop(true); 4743 }); 4744 4745 woodmartThemeModule.$document.pjax(woodmartThemeModule.ajaxLinks, '.main-page-wrapper', { 4746 timeout : woodmart_settings.pjax_timeout, 4747 scrollTo : false, 4748 renderCallback: function(context, html, afterRender) { 4749 woodmartThemeModule.removeDuplicatedStylesFromHTML(html, function(html) { 4750 context.html(html); 4751 afterRender(); 4752 woodmartThemeModule.$document.trigger('wdShopPageInit'); 4753 woodmartThemeModule.$document.trigger('wood-images-loaded'); 4754 }); 4755 } 4756 }); 4757 4758 if (woodmart_settings.price_filter_action === 'click') { 4759 woodmartThemeModule.$document.on('click', '.widget_price_filter form .button', function() { 4760 var form = $('.widget_price_filter form'); 4761 $.pjax({ 4762 container: '.main-page-wrapper', 4763 timeout : woodmart_settings.pjax_timeout, 4764 url : form.attr('action'), 4765 data : form.serialize(), 4766 scrollTo : false, 4767 renderCallback: function(context, html, afterRender) { 4768 woodmartThemeModule.removeDuplicatedStylesFromHTML(html, function(html) { 4769 context.html(html); 4770 afterRender(); 4771 woodmartThemeModule.$document.trigger('wdShopPageInit'); 4772 woodmartThemeModule.$document.trigger('wood-images-loaded'); 4773 }); 4774 } 4775 }); 4776 4777 return false;
4778 }); 4779 } else if (woodmart_settings.price_filter_action === 'submit') { 4780 woodmartThemeModule.$document.on('submit', '.widget_price_filter form', function(event) { 4781 $.pjax.submit(event, '.main-page-wrapper'); 4782 }); 4783 } 4784 4785 woodmartThemeModule.$document.on('pjax:error', function(xhr, textStatus, error) { 4786 console.log('pjax error ' + error); 4787 }); 4788 4789 woodmartThemeModule.$document.on('pjax:start', function() { 4790 var $siteContent = $('.site-content'); 4791 4792 $siteContent.removeClass('ajax-loaded'); 4793 $siteContent.addClass('ajax-loading'); 4794 4795 woodmartThemeModule.$document.trigger('wdPjaxStart'); 4796 woodmartThemeModule.$window.trigger('scroll.loaderVerticalPosition'); 4797 }); 4798 4799 woodmartThemeModule.$document.on('pjax:complete', function() { 4800 woodmartThemeModule.$window.off('scroll.loaderVerticalPosition'); 4801 4802 scrollToTop(false); 4803 4804 woodmartThemeModule.$document.trigger('wood-images-loaded'); 4805 4806 $('.wd-scroll-content').on('scroll', function() { 4807 woodmartThemeModule.$document.trigger('wood-images-loaded'); 4808 }); 4809 4810 $('.site-content').removeClass('ajax-loading'); 4811 4812 if (typeof woodmart_wpml_js_data !== 'undefined' && woodmart_wpml_js_data.languages) { 4813 $.each(woodmart_wpml_js_data.languages, function(index, language) { 4814 $('.wpml-ls-item-' + language.code + ' .wpml-ls-link').attr('href', language.url); 4815 }); 4816 } 4817 }); 4818 4819 woodmartThemeModule.$document.on('pjax:beforeReplace', function() { 4820 if ($('.filters-area').hasClass('filters-opened') && woodmart_settings.shop_filters_close === 'yes') { 4821 filtersState = true; 4822 woodmartThemeModule.$body.addClass('body-filters-opened'); 4823 } 4824 }); 4825 4826 woodmartThemeModule.$document.on('pjax:end', function() { 4827 var $siteContent = $('.site-content'); 4828 4829 if (filtersState) { 4830 $('.filters-area').css('display', 'block'); 4831 woodmartThemeModule.openFilters(200); 4832 filtersState = false; 4833 } 4834 4835 $siteContent.removeClass('ajax-loading'); 4836 $siteContent.addClass('ajax-loaded'); 4837 }); 4838 4839 var scrollToTop = function(type) { 4840 if (woodmart_settings.ajax_scroll === 'no' && type === false) { 4841 return false; 4842 } 4843 4844 var $scrollTo = $(woodmart_settings.ajax_scroll_class), 4845 scrollTo = $scrollTo.offset().top - woodmart_settings.ajax_scroll_offset; 4846 4847 $('html, body').stop().animate({ 4848 scrollTop: scrollTo 4849 }, 400); 4850 }; 4851 }; 4852 4853 $(document).ready(function() { 4854 woodmartThemeModule.ajaxFilters(); 4855 }); 4856})(jQuery); 4857 4858/* global woodmart_settings */ 4859(function($) { 4860 woodmartThemeModule.cartWidget = function() { 4861 var body = woodmartThemeModule.$body; 4862 4863 var cartWidgetSide = $('.cart-widget-side'); 4864 var closeSide = $('.wd-close-side'); 4865 4866 body.on('click', '.cart-widget-opener', function(e) { 4867 if (!isCart() && !isCheckout()) { 4868 e.preventDefault(); 4869 } 4870 4871 if (isOpened()) { 4872 closeWidget(); 4873 } else { 4874 setTimeout(function() { 4875 openWidget(); 4876 }, 10); 4877 } 4878 }); 4879 4880 body.on('click touchstart', '.wd-close-side', function() { 4881 if (isOpened()) { 4882 closeWidget(); 4883 } 4884 }); 4885 4886 body.on('click', '.close-side-widget', function(e) { 4887 e.preventDefault(); 4888 if (isOpened()) { 4889 closeWidget(); 4890 } 4891 }); 4892 4893 woodmartThemeModule.$document.on('keyup', function(e) { 4894 if (e.keyCode === 27 && isOpened()) { 4895 closeWidget(); 4896 } 4897 }); 4898 4899 var closeWidget = function() { 4900 cartWidgetSide.removeClass('wd-opened'); 4901 closeSide.removeClass('wd-close-side-opened'); 4902 }; 4903 4904 var openWidget = function() { 4905 if (isCart() || isCheckout()) { 4906 return false; 4907 } 4908 cartWidgetSide.addClass('wd-opened'); 4909 closeSide.addClass('wd-close-side-opened'); 4910 }; 4911 4912 var isOpened = function() { 4913 return cartWidgetSide.hasClass('wd-opened'); 4914 }; 4915 4916 var isCart = function() { 4917 return woodmartThemeModule.$body.hasClass('woocommerce-cart'); 4918 }; 4919 4920 var isCheckout = function() { 4921 return woodmartThemeModule.$body.hasClass('woocommerce-checkout'); 4922 }; 4923 }; 4924 4925 $(document).ready(function() { 4926 woodmartThemeModule.cartWidget(); 4927 }); 4928})(jQuery); 4929 4930/* global woodmart_settings */ 4931(function($) { 4932 woodmartThemeModule.$document.on('wdBackHistory wdShopPageInit', function () { 4933 woodmartThemeModule.categoriesAccordion(); 4934 }); 4935 4936 woodmartThemeModule.categoriesAccordion = function() { 4937 4938 if (woodmart_settings.categories_toggle === 'no') { 4939 return; 4940 } 4941 4942 var $widget = $('.widget_product_categories'), 4943 $list = $widget.find('.product-categories'), 4944 time = 300; 4945 4946 $list.find('.cat-parent').each(function() { 4947 var $this = $(this); 4948 4949 if ($this.find(' > .wd-cats-toggle').length > 0) { 4950 return; 4951 } 4952 if ($this.find(' > .children').length === 0 || $this.find(' > .children > *').length === 0) { 4953 return; 4954 } 4955 4956 $this.append('<div class="wd-cats-toggle"></div>'); 4957 }); 4958 4959 $list.on('click', '.wd-cats-toggle', function() { 4960 var $btn = $(this), 4961 $subList = $btn.prev(); 4962 4963 if ($subList.hasClass('list-shown')) { 4964 $btn.removeClass('toggle-active'); 4965 $subList.stop().slideUp(time).removeClass('list-shown'); 4966 } else { 4967 $subList.parent().parent().find('> li >
4967 .list-shown').slideUp().removeClass('list-shown'); 4968 $subList.parent().parent().find('> li > .toggle-active').removeClass('toggle-active'); 4969 $btn.addClass('toggle-active'); 4970 $subList.stop().slideDown(time).addClass('list-shown'); 4971 } 4972 }); 4973 4974 if ($list.find('li.current-cat.cat-parent, li.current-cat-parent').length > 0) { 4975 $list.find('li.current-cat.cat-parent, li.current-cat-parent').find('> .wd-cats-toggle').click(); 4976 } 4977 }; 4978 4979 $(document).ready(function() { 4980 woodmartThemeModule.categoriesAccordion(); 4981 }); 4982})(jQuery); 4983 4984/* global woodmart_settings */ 4985(function($) { 4986 woodmartThemeModule.$document.on('wdShopPageInit', function() { 4987 woodmartThemeModule.categoriesDropdowns(); 4988 }); 4989 4990 woodmartThemeModule.categoriesDropdowns = function() { 4991 $('.dropdown_product_cat').on('change', function() { 4992 var $this = $(this); 4993 4994 if ('' !== $this.val()) { 4995 var this_page; 4996 var home_url = woodmart_settings.home_url; 4997 4998 if (home_url.indexOf('?') > 0) { 4999 this_page = home_url + '&product_cat=' + $this.val(); 5000 } else { 5001 this_page = home_url + '?product_cat=' + $this.val(); 5002 } 5003 5004 location.href = this_page; 5005 } else { 5006 location.href = woodmart_settings.shop_url; 5007 } 5008 }); 5009 5010 $('.widget_product_categories').each(function() { 5011 var $select = $(this).find('select'); 5012 5013 if ($().selectWoo) { 5014 $select.selectWoo({ 5015 minimumResultsForSearch: 5, 5016 width : '100%', 5017 allowClear : true, 5018 placeholder : woodmart_settings.product_categories_placeholder, 5019 language : { 5020 noResults: function() { 5021 return woodmart_settings.product_categories_no_results; 5022 } 5023 } 5024 }); 5025 } 5026 }); 5027 }; 5028 5029 $(document).ready(function() { 5030 woodmartThemeModule.categoriesDropdowns(); 5031 }); 5032})(jQuery); 5033 5034/* global woodmart_settings */ 5035(function($) { 5036 woodmartThemeModule.$document.on('wdShopPageInit', function() { 5037 woodmartThemeModule.categoriesMenuBtns(); 5038 }); 5039 5040 woodmartThemeModule.categoriesMenu = function() { 5041 if (woodmartThemeModule.windowWidth > 1024) { 5042 return; 5043 } 5044 5045 var categories = $('.wd-nav-product-cat'), 5046 time = 200; 5047 5048 woodmartThemeModule.$body.on('click', '.wd-nav-opener', function(e) { 5049 var $this = $(this); 5050 e.preventDefault(); 5051 5052 if ($this.closest('.has-sub').find('> ul').hasClass('child-open')) { 5053 $this.removeClass('wd-active').closest('.has-sub').find('> ul').slideUp(time).removeClass('child-open'); 5054 } else { 5055 $this.addClass('wd-active').closest('.has-sub').find('> ul').slideDown(time).addClass('child-open'); 5056 } 5057 5058 woodmartThemeModule.$document.trigger('wood-images-loaded'); 5059 }); 5060 5061 woodmartThemeModule.$body.on('click', '.wd-btn-show-cat > a', function(e) { 5062 e.preventDefault(); 5063 5064 if (isOpened()) { 5065 closeCats(); 5066 } else { 5067 openCats(); 5068 } 5069 }); 5070 5071 woodmartThemeModule.$body.on('click', '.wd-nav-product-cat a', function(e) { 5072 if (!$(e.target).hasClass('wd-nav-opener')) { 5073 closeCats(); 5074 categories.stop().attr('style', ''); 5075 } 5076 }); 5077 5078 var isOpened = function() { 5079 return $('.wd-nav-product-cat').hasClass('categories-opened'); 5080 }; 5081 5082 var openCats = function() { 5083 $('.wd-btn-show-cat').addClass('wd-active'); 5084 $('.wd-nav-product-cat').addClass('categories-opened').stop().slideDown(time); 5085 woodmartThemeModule.$document.trigger('wood-images-loaded'); 5086 }; 5087 5088 var closeCats = function() { 5089 $('.wd-btn-show-cat').removeClass('wd-active'); 5090 $('.wd-nav-product-cat').removeClass('categories-opened').stop().slideUp(time); 5091 }; 5092 }; 5093 5094 woodmartThemeModule.categoriesMenuBtns = function() { 5095 if (woodmartThemeModule.windowWidth > 1024) { 5096 return; 5097 } 5098 5099 var categories = $('.wd-nav-product-cat'), 5100 subCategories = categories.find('li > ul'), 5101 iconDropdown = '<span class="wd-nav-opener"></span>'; 5102 5103 subCategories.parent().addClass('has-sub').append(iconDropdown); 5104 }; 5105 5106 $(document).ready(function() { 5107 woodmartThemeModule.categoriesMenu(); 5108 woodmartThemeModule.categoriesMenuBtns(); 5109 }); 5110})(jQuery); 5111 5112/* global woodmart_settings */ 5113(function($) { 5114 woodmartThemeModule.commentImage = function() { 5115 $('form.comment-form').attr('enctype', 'multipart/form-data'); 5116 5117 var $form = $('.comment-form'); 5118 var $input = $form.find('#wd-add-img-btn'); 5119 var allowedMimes = []; 5120 5121 if ($input.length === 0) { 5122 return; 5123 } 5124 5125 $.each(woodmart_settings.comment_images_upload_mimes, function(index, value) { 5126 allowedMimes.push(String(value)); 5127 }); 5128 5129 $form.find('#wd-add-img-btn').on('change', function() { 5130 $form.find('.wd-add-img-count').text(woodmart_settings.comment_images_added_count_text.replace('%s', this.files.length)); 5131 }); 5132 5133 $form.on('submit', function(e) { 5134 $form.find('.woocommerce-error').remove(); 5135 5136 var hasLarge = false;
5137 var hasNotAllowedMime = false; 5138 5139 if ($input[0].files.length > woodmart_settings.comment_images_count) { 5140 showError(woodmart_settings.comment_images_count_text); 5141 e.preventDefault(); 5142 } 5143 5144 Array.prototype.forEach.call($input[0].files, function(file) { 5145 var size = file.size; 5146 var type = String(file.type); 5147 5148 if (size > woodmart_settings.comment_images_upload_size) { 5149 hasLarge = true; 5150 } 5151 5152 if ($.inArray(type, allowedMimes) < 0) { 5153 hasNotAllowedMime = true; 5154 } 5155 }); 5156 5157 if (hasLarge) { 5158 showError(woodmart_settings.comment_images_upload_size_text); 5159 e.preventDefault(); 5160 } 5161 5162 if (hasNotAllowedMime) { 5163 showError(woodmart_settings.comment_images_upload_mimes_text); 5164 e.preventDefault(); 5165 } 5166 }); 5167 5168 function showError(text) { 5169 $form.prepend('<ul class="woocommerce-error" role="alert"><li>' + text + '</li></ul>'); 5170 } 5171 }; 5172 5173 $(document).ready(function() { 5174 woodmartThemeModule.commentImage(); 5175 }); 5176})(jQuery); 5177 5178/* global woodmart_settings */ 5179(function($) { 5180 woodmartThemeModule.$document.on('wdShopPageInit', function () { 5181 woodmartThemeModule.filterDropdowns(); 5182 }); 5183 5184 woodmartThemeModule.filterDropdowns = function() { 5185 $('.wd-widget-layered-nav-dropdown-form').each(function() { 5186 var $form = $(this); 5187 var $select = $form.find('select'); 5188 var slug = $select.data('slug'); 5189 5190 $select.change(function() { 5191 var val = $(this).val(); 5192 $('input[name=filter_' + slug + ']').val(val); 5193 }); 5194 5195 if ($().selectWoo) { 5196 $select.selectWoo({ 5197 placeholder : $select.data('placeholder'), 5198 minimumResultsForSearch: 5, 5199 width : '100%', 5200 allowClear : !$select.attr('multiple'), 5201 language : { 5202 noResults: function() { 5203 return $select.data('noResults'); 5204 } 5205 } 5206 }).on('select2:unselecting', function() { 5207 $(this).data('unselecting', true); 5208 }).on('select2:opening', function(e) { 5209 var $this = $(this); 5210 5211 if ($this.data('unselecting')) { 5212 $this.removeData('unselecting'); 5213 e.preventDefault(); 5214 } 5215 }); 5216 } 5217 }); 5218 5219 function ajaxAction($element) { 5220 var $form = $element.parent('.wd-widget-layered-nav-dropdown-form'); 5221 5222 if (!woodmartThemeModule.$body.hasClass('woodmart-ajax-shop-on') || typeof ($.fn.pjax) === 'undefined') { 5223 return; 5224 } 5225 5226 $.pjax({ 5227 container: '.main-page-wrapper', 5228 timeout : woodmart_settings.pjax_timeout, 5229 url : $form.attr('action'), 5230 data : $form.serialize(), 5231 scrollTo : false, 5232 renderCallback: function(context, html, afterRender) { 5233 woodmartThemeModule.removeDuplicatedStylesFromHTML(html, function(html) { 5234 context.html(html); 5235 afterRender(); 5236 woodmartThemeModule.$document.trigger('wdShopPageInit'); 5237 woodmartThemeModule.$document.trigger('wood-images-loaded'); 5238 }); 5239 } 5240 }); 5241 } 5242 5243 $('.wd-widget-layered-nav-dropdown__submit').on('click', function() { 5244 var $this = $(this); 5245 5246 if (!$this.siblings('select').attr('multiple') || !woodmartThemeModule.$body.hasClass('woodmart-ajax-shop-on')) { 5247 return; 5248 } 5249 5250 ajaxAction($this); 5251 5252 $this.prop('disabled', true); 5253 }); 5254 5255 $('.wd-widget-layered-nav-dropdown-form select').on('change', function() { 5256 var $this = $(this); 5257 5258 if (!woodmartThemeModule.$body.hasClass('woodmart-ajax-shop-on')) { 5259 $this.parent().submit(); 5260 return; 5261 } 5262 5263 if ($this.attr('multiple')) { 5264 return; 5265 } 5266 5267 ajaxAction($this); 5268 }); 5269 }; 5270 5271 $(document).ready(function() { 5272 woodmartThemeModule.filterDropdowns(); 5273 }); 5274})(jQuery); 5275 5276/* global woodmart_settings */ 5277(function($) { 5278 woodmartThemeModule.filtersArea = function() { 5279 var filters = $('.filters-area'), 5280 time = 200; 5281 5282 woodmartThemeModule.$body.on('click', '.open-filters', function(e) { 5283 e.preventDefault(); 5284 5285 if (isOpened()) { 5286 closeFilters(); 5287 } else { 5288 woodmartThemeModule.openFilters(time); 5289 setTimeout(function() { 5290 woodmartThemeModule.$document.trigger('wdFiltersOpened'); 5291 }, time); 5292 } 5293 }); 5294 5295 if (woodmart_settings.shop_filters_close === 'no') {
5296 woodmartThemeModule.$body.on('click', woodmartThemeModule.ajaxLinks, function() { 5297 if (isOpened()) { 5298 closeFilters(); 5299 } 5300 }); 5301 } 5302 5303 var isOpened = function() { 5304 filters = $('.filters-area'); 5305 return filters.hasClass('filters-opened'); 5306 }; 5307 5308 var closeFilters = function() { 5309 filters = $('.filters-area'); 5310 filters.removeClass('filters-opened'); 5311 filters.stop().slideUp(time); 5312 }; 5313 }; 5314 5315 woodmartThemeModule.openFilters = function(time) { 5316 var filters = $('.filters-area'); 5317 filters.stop().slideDown(time); 5318 5319 setTimeout(function() { 5320 filters.addClass('filters-opened'); 5321 woodmartThemeModule.$document.trigger('wdFiltersOpened'); 5322 5323 woodmartThemeModule.$body.removeClass('body-filters-opened'); 5324 woodmartThemeModule.$document.trigger('wood-images-loaded'); 5325 }, time); 5326 }; 5327 5328 $(document).ready(function() { 5329 woodmartThemeModule.filtersArea(); 5330 }); 5331})(jQuery); 5332 5333/* global woodmart_settings */ 5334(function($) { 5335 woodmartThemeModule.$document.on('wdShopPageInit wdProductsTabsLoaded wdArrowsLoadProducts wdLoadMoreLoadProducts wdUpdateWishlist', function () { 5336 woodmartThemeModule.gridQuantity(); 5337 }); 5338 5339 $.each([ 5340 'frontend/element_ready/wd_products.default', 5341 'frontend/element_ready/wd_products_tabs.default' 5342 ], function(index, value) { 5343 woodmartThemeModule.wdElementorAddAction(value, function() { 5344 woodmartThemeModule.gridQuantity(); 5345 }); 5346 }); 5347 5348 woodmartThemeModule.gridQuantity = function() { 5349 $('.product-grid-item').on('change input', '.quantity .qty', function() { 5350 var $this = $(this); 5351 var add_to_cart_button = $this.parent().parent().find('.add_to_cart_button'); 5352 5353 add_to_cart_button.attr('data-quantity', $this.val()); 5354 add_to_cart_button.attr('href', '?add-to-cart=' + add_to_cart_button.attr('data-product_id') + '&quantity=' + $this.val()); 5355 }); 5356 }; 5357 5358 $(document).ready(function() { 5359 woodmartThemeModule.gridQuantity(); 5360 }); 5361})(jQuery); 5362 5363/* global woodmart_settings */ 5364(function($) { 5365 woodmartThemeModule.headerCategoriesMenu = function() { 5366 if (woodmartThemeModule.windowWidth > 1024) { 5367 return; 5368 } 5369 5370 var categories = $('.wd-header-cats'), 5371 catsUl = categories.find('.categories-menu-dropdown'), 5372 subCategories = categories.find('.menu-item-has-children'), 5373 button = categories.find('.menu-opener'), 5374 time = 200, 5375 iconDropdown = '<span class="drop-category"></span>'; 5376 5377 subCategories.find('> a').before(iconDropdown); 5378 5379 catsUl.on('click', '.drop-category', function() { 5380 var $this = $(this); 5381 var sublist = $this.parent().find('> .wd-dropdown-menu, >.sub-sub-menu'); 5382 5383 if (sublist.hasClass('child-open')) { 5384 $this.removeClass('act-icon'); 5385 sublist.slideUp(time).removeClass('child-open'); 5386 } else { 5387 $this.addClass('act-icon'); 5388 sublist.slideDown(time).addClass('child-open'); 5389 } 5390 }); 5391 5392 categories.on('click', '.menu-opener', function(e) { 5393 e.preventDefault(); 5394 5395 if (isOpened()) { 5396 closeCats(); 5397 } else { 5398 openCats(); 5399 } 5400 }); 5401 5402 catsUl.on('click', 'a', function() { 5403 closeCats(); 5404 catsUl.stop().attr('style', ''); 5405 }); 5406 5407 var isOpened = function() { 5408 return catsUl.hasClass('categories-opened'); 5409 }; 5410 5411 var openCats = function() { 5412 catsUl.addClass('categories-opened').stop().slideDown(time); 5413 }; 5414 5415 var closeCats = function() { 5416 catsUl.removeClass('categories-opened').stop().slideUp(time); 5417 }; 5418 }; 5419 5420 $(document).ready(function() { 5421 woodmartThemeModule.headerCategoriesMenu(); 5422 }); 5423})(jQuery); 5424 5425/* global woodmart_settings */ 5426(function($) { 5427 woodmartThemeModule.$document.on('wdReplaceMainGalleryNotQuickView wdShowVariationNotQuickView', function () { 5428 woodmartThemeModule.initZoom(); 5429 }); 5430 5431 woodmartThemeModule.initZoom = function() { 5432 var $mainGallery = $('.woocommerce-product-gallery__wrapper:not(.quick-view-gallery)'); 5433 5434 if (woodmart_settings.zoom_enable !== 'yes') { 5435 return false; 5436 } 5437 5438 var zoomOptions = { 5439 touch: false 5440 }; 5441 5442 if ('ontouchstart' in window) { 5443 zoomOptions.on = 'click'; 5444 } 5445 5446 var $productGallery = $('.woocommerce-product-gallery'); 5447 if ($productGallery.hasClass('thumbs-position-bottom') || $productGallery.hasClass('thumbs-position-left')) { 5448 $mainGallery.on('changed.owl.carousel', function(e) { 5449 var $wrapper = $mainGallery.find('.product-image-wrap').eq(e.item.index).find('.woocommerce-product-gallery__image'); 5450 5451 init($wrapper); 5452 }); 5453 5454 init($mainGallery.find('.product-image-wrap').eq(0).find('.woocommerce-product-gallery__image')); 5455 } else { 5456 $mainGallery.find('.product-image-wrap').each(function() { 5457 var $wrapper = $(this).find('.woocommerce-product-gallery__image'); 5458 5459 init($wrapper); 5460 }); 5461 } 5462 5463 function init($wrapper) { 5464 var image = $wrapper.find('img'); 5465 if (image.data('large_image_width') > $wrapper.width()) { 5466 $wrapper.trigger('zoom.destroy'); 5467 $wrapper.zoom(zoomOptions); 5468 } 5469 } 5470 }; 5471 5472 $(document).ready(function() { 5473 woodmartThemeModule.initZoom(); 5474 }); 5475})(jQuery); 5476 5477/* global woodmart_settings */ 5478(function($) { 5479 woodmartThemeModule.loginDropdown = function() { 5480 if (woodmartThemeModule.windowWidth <= 1024) { 5481 return; 5482 } 5483 5484 $('.wd-dropdown-register').each(function() { 5485 var $this = $(this), 5486 $content = $this.find('.login-dropdown-inner'); 5487 5488 $content.find('input[id="username"]').on('click', function() { 5489 $this.addClass('wd-active-login').removeClass('wd-active-link'); 5490 }); 5491 5492 $content.find('input[id="username"]').on('input', function() { 5493 if ($this.hasClass('wd-active-login')) { 5494 $this.removeClass('wd-active-login').addClass('wd-active-link'); 5495 } 5496 }); 5497 5498 $content.find('input').not('[id="username"]').on('click', function() { 5499 $this.removeClass('wd-active-login').removeClass('wd-active-link'); 5500 }); 5501 5502 woodmartThemeModule.$document.click(function(a) { 5503 if ('undefined' != typeof (a.target.className.length) && a.target.className.indexOf('wd-dropdown-register') === -1 && a.target.className.indexOf('input-text') === -1) { 5504 $this.removeClass('wd-active-login').removeClass('wd-active-link'); 5505 } 5506 }); 5507 5508 $('.wd-dropdown-register').on('mouseout', function() { 5509 if ($this.hasClass('wd-active-link')) { 5510 $this.removeClass('wd-active-link'); 5511 } 5512 }).on('mouseleave', function() { 5513 if ($this.hasClass('wd-active-link')) { 5514 $this.removeClass('wd-active-link'); 5515 } 5516 }); 5517 }); 5518 }; 5519 5520 $(document).ready(function() { 5521 woodmartThemeModule.loginDropdown(); 5522 }); 5523})(jQuery); 5524 5525/* global woodmart_settings */ 5526(function($) { 5527 woodmartThemeModule.loginSidebar = function() { 5528 var body = woodmartThemeModule.$body; 5529 var loginFormSide = $('.login-form-side'); 5530 var closeSide = $('.wd-close-side'); 5531 5532 $('.login-side-opener').on('click', function(e) { 5533 e.preventDefault(); 5534 5535 if (isOpened()) { 5536 closeWidget(); 5537 } else { 5538 setTimeout(function() { 5539 openWidget(); 5540 }, 10); 5541 } 5542 }); 5543 5544 body.on('click touchstart', '.wd-close-side', function() { 5545 if (isOpened()) { 5546 closeWidget(); 5547 } 5548 }); 5549 5550 body.on('click', '.close-side-widget', function(e) { 5551 e.preventDefault(); 5552 if (isOpened()) { 5553 closeWidget(); 5554 } 5555 }); 5556 5557 woodmartThemeModule.$document.on('keyup', function(e) { 5558 if (e.keyCode === 27 && isOpened()) { 5559 closeWidget(); 5560 } 5561 }); 5562 5563 var closeWidget = function() { 5564 loginFormSide.removeClass('wd-opened'); 5565 closeSide.removeClass('wd-close-side-opened'); 5566 }; 5567 5568 var openWidget = function() { 5569 loginFormSide.find('form').removeClass('hidden-form'); 5570 loginFormSide.addClass('wd-opened'); 5571 closeSide.addClass('wd-close-side-opened'); 5572 }; 5573 5574 if (loginFormSide.find('.woocommerce-notices-wrapper > ul').length > 0) { 5575 openWidget(); 5576 } 5577 5578 var isOpened = function() { 5579 return loginFormSide.hasClass('wd-opened'); 5580 }; 5581 }; 5582 5583 $(document).ready(function() { 5584 woodmartThemeModule.loginSidebar(); 5585 }); 5586})(jQuery); 5587 5588/* global woodmart_settings */ 5589(function($) { 5590 woodmartThemeModule.loginTabs = function() { 5591 var tabs = $('.wd-register-tabs'), 5592 btn = tabs.find('.wd-switch-to-register'), 5593 title = $('.col-register-text h2'), 5594 loginText = tabs.find('.login-info'), 5595 classOpened = 'active-register', 5596 loginLabel = btn.data('login'), 5597 registerLabel = btn.data('register'), 5598 loginTitleLabel = btn.data('login-title'), 5599 registerTitleLabel = btn.data('reg-title'); 5600 5601 btn.on('click', function(e) { 5602 e.preventDefault(); 5603 5604 if (isShown()) { 5605 hideRegister(); 5606 } else { 5607 showRegister(); 5608 } 5609 5610 if (woodmartThemeModule.$window.width() < 768) { 5611 $('html, body').stop().animate({ 5612 scrollTop: tabs.offset().top - 90 5613 }, 400); 5614 } 5615 }); 5616 5617 var showRegister = function() { 5618 tabs.addClass(classOpened); 5619 btn.text(loginLabel); 5620 5621 if (loginText.length > 0) { 5622 title.text(loginTitleLabel); 5623 } 5624 }; 5625 5626 var hideRegister = function() { 5627 tabs.removeClass(classOpened); 5628 btn.text(registerLabel); 5629 5630 if (loginText.length > 0) { 5631 title.text(registerTitleLabel); 5632 } 5633 }; 5634 5635 var isShown = function() { 5636 return tabs.hasClass(classOpened); 5637 }; 5638 }; 5639 5640 $(document).ready(function() { 5641 woodmartThemeModule.loginTabs(); 5642 }); 5643})(jQuery); 5644 5645/* global woodmart_settings */ 5646(function($) { 5647 woodmartThemeModule.miniCartQuantity = function() { 5648 var timeout; 5649 5650 woodmartThemeModule.$document.on('change input', '.woocommerce-mini-cart .quantity .qty', function() { 5651 var input = $(this); 5652 var qtyVal = input.val(); 5653 var itemID = input.parents('.woocommerce-mini-cart-item').data('key'); 5654 var cart_hash_key = woodmart_settings.cart_hash_key; 5655 var fragment_name = woodmart_settings.fragment_name; 5656 5657 clearTimeout(timeout); 5658 5659 timeout = setTimeout(function() { 5660 input.parents('.mini_cart_item').addClass('wd-loading'); 5661 5662 $.ajax({
5663 url : woodmart_settings.ajaxurl, 5664 data : { 5665 action : 'woodmart_update_cart_item', 5666 item_id: itemID, 5667 qty : qtyVal 5668 }, 5669 success : function(data) { 5670 if (data && data.fragments) { 5671 $.each(data.fragments, function(key, value) { 5672 if ($(key).hasClass('widget_shopping_cart_content')) { 5673 var dataItemValue = $(value).find('.woocommerce-mini-cart-item[data-key="' + itemID + '"]'); 5674 var dataFooterValue = $(value).find('.shopping-cart-widget-footer'); 5675 var $itemSelector = $(key).find('.woocommerce-mini-cart-item[data-key="' + itemID + '"]'); 5676 5677 if (!data.cart_hash) { 5678 $(key).replaceWith(value); 5679 } else { 5680 $itemSelector.replaceWith(dataItemValue); 5681 $('.shopping-cart-widget-footer').replaceWith(dataFooterValue); 5682 } 5683 } else { 5684 $(key).replaceWith(value); 5685 } 5686 }); 5687 5688 if (woodmartThemeModule.supports_html5_storage) { 5689 sessionStorage.setItem(fragment_name, JSON.stringify(data.fragments)); 5690 localStorage.setItem(cart_hash_key, data.cart_hash); 5691 sessionStorage.setItem(cart_hash_key, data.cart_hash); 5692 5693 if (data.cart_hash) { 5694 sessionStorage.setItem('wc_cart_created', (new Date()).getTime()); 5695 } 5696 } 5697 } 5698 }, 5699 dataType: 'json', 5700 method : 'GET' 5701 }); 5702 }, 500); 5703 }); 5704 }; 5705 5706 $(document).ready(function() { 5707 woodmartThemeModule.miniCartQuantity(); 5708 }); 5709})(jQuery); 5710 5711/* global woodmart_settings */ 5712(function($) { 5713 woodmartThemeModule.onRemoveFromCart = function() { 5714 if ('no' === woodmart_settings.woocommerce_ajax_add_to_cart) { 5715 return; 5716 } 5717 5718 woodmartThemeModule.$document.on('click', '.widget_shopping_cart .remove', function(e) { 5719 e.preventDefault(); 5720 $(this).parent().addClass('removing-process'); 5721 }); 5722 }; 5723 5724 $(document).ready(function() { 5725 woodmartThemeModule.onRemoveFromCart(); 5726 }); 5727})(jQuery); 5728 5729/* global woodmart_settings */ 5730(function($) { 5731 woodmartThemeModule.product360Button = function() { 5732 if ('undefined' === typeof $.fn.magnificPopup) { 5733 return; 5734 } 5735 5736 $('.product-360-button a').magnificPopup({ 5737 type : 'inline', 5738 mainClass : 'mfp-fade', 5739 preloader : false, 5740 tClose : woodmart_settings.close, 5741 tLoading : woodmart_settings.loading, 5742 fixedContentPos: false, 5743 removalDelay : 500, 5744 callbacks : { 5745 beforeOpen: function() { 5746 this.st.mainClass = 'mfp-move-horizontal'; 5747 }, 5748 open : function() { 5749 woodmartThemeModule.$window.trigger('resize'); 5750 } 5751 } 5752 }); 5753 }; 5754 5755 $(document).ready(function() { 5756 woodmartThemeModule.product360Button(); 5757 }); 5758})(jQuery); 5759 5760/* global woodmart_settings */ 5761(function($) { 5762 woodmartThemeModule.productAccordion = function() { 5763 var $accordion = $('.wc-tabs-wrapper'); 5764 var time = 300; 5765 var hash = window.location.hash; 5766 var url = window.location.href; 5767 5768 if (hash.toLowerCase().indexOf('comment-') >= 0 || hash === '#reviews' || hash === '#tab-reviews') { 5769 $accordion.find('.tab-title-reviews').addClass('active'); 5770 } else if (url.indexOf('comment-page-') > 0 || url.indexOf('cpage=') > 0) { 5771 $accordion.find('.tab-title-reviews').addClass('active'); 5772 } else { 5773 $accordion.find('.wd-accordion-title').first().addClass('active'); 5774 } 5775 5776 $('.woocommerce-review-link').on('click', function() { 5777 $('.tabs-layout-accordion .wd-accordion-title.tab-title-reviews:not(.active)').click(); 5778 }); 5779 5780 $accordion.on('click', '.wd-accordion-title', function(e) { 5781 e.preventDefault(); 5782 5783 var $this = $(this), 5784 $panel = $this.siblings('.woocommerce-Tabs-panel'); 5785 5786 var currentIndex = $this.parent().index(); 5787 var oldIndex = $this.parent().siblings().find('.active').parent('.wd-tab-wrapper').index(); 5788 5789 if ($this.hasClass('active')) { 5790 oldIndex = currentIndex; 5791 $this.removeClass('active'); 5792 $panel.stop().slideUp(time); 5793 } else { 5794 $accordion.find('.wd-accordion-title').removeClass('active'); 5795 $accordion.find('.woocommerce-Tabs-panel').slideUp(); 5796 $this.addClass('active'); 5797 $panel.stop().slideDown(time); 5798 } 5799 5800 if (currentIndex === -1) { 5801 oldIndex = currentIndex; 5802 } 5803 5804 woodmartThemeModule.$window.trigger('resize'); 5805 5806 setTimeout(function() { 5807 woodmartThemeModule.$window.trigger('resize'); 5808 5809 if (woodmartThemeModule.$window.width() < 1024 && currentIndex > oldIndex) { 5810 var $header = $('.sticky-header'); 5811 var headerHeight = $header.length > 0 ? $header.outerHeight() : 0; 5812 $('html, body').animate({ 5813 scrollTop: $this.offset().top - $this.outerHeight() - headerHeight - 50 5814 }, 500); 5815 } 5816 }, time); 5817 5818 woodmartThemeModule.$document.trigger('wood-images-loaded'); 5819 }); 5820 }; 5821 5822 $(document).ready(function() { 5823 woodmartThemeModule.productAccordion(); 5824 }); 5825})(jQuery); 5826 5827/* global woodmart_settings */ 5828(function($) { 5829 woodmartThemeModule.$document.on('wdShopPageInit', function () { 5830 woodmartThemeModule.productFilters(); 5831 }); 5832 5833 $.each([ 5834 'frontend/element_ready/wd_product_filters.default' 5835 ], function(index, value) { 5836 woodmartThemeModule.wdElementorAddAction(value, function() { 5837 woodmartThemeModule.productFilters(); 5838 }); 5839 }); 5840 5841 woodmartThemeModule.productFilters = function() { 5842 var removeValue = function($mainInput, currentVal) { 5843 if ($mainInput.length === 0) { 5844 return; 5845 } 5846 5847 var mainInputVal = $mainInput.val(); 5848 5849 if (mainInputVal.indexOf(',') > 0) { 5850 $mainInput.val(mainInputVal.replace(',' + currentVal, '').replace(currentVal + ',', '')); 5851 } else { 5852 $mainInput.val(mainInputVal.replace(currentVal, '')); 5853 } 5854 }; 5855 5856 $('.wd-pf-checkboxes li > .pf-value').on('click', function(e) { 5857 e.preventDefault(); 5858 var $this = $(this); 5859 var $li = $this.parent(); 5860 var $widget = $this.parents('.wd-pf-checkboxes'); 5861 var $mainInput = $widget.find('.result-input'); 5862 var $results = $widget.find('.wd-pf-results'); 5863 5864 var multiSelect = $widget.hasClass('multi_select'); 5865 var mainInputVal = $mainInput.val(); 5866 var currentText = $this.data('title'); 5867 var currentVal = $this.data('val'); 5868 5869 if (multiSelect) { 5870 if (!$li.hasClass('pf-active')) { 5871 if (mainInputVal === '') { 5872 $mainInput.val(currentVal); 5873 } else { 5874 $mainInput.val(mainInputVal + ',' + currentVal); 5875 } 5876 5877 $results.prepend('<li class="selected-value" data-title="' + currentVal + '">' + currentText + '</li>'); 5878 $li.addClass('pf-active'); 5879 } else { 5880 removeValue($mainInput, currentVal); 5881 $results.find('li[data-title="' + currentVal + '"]').remove(); 5882 $li.removeClass('pf-active'); 5883 } 5884 } else { 5885 if (!$li.hasClass('pf-active')) { 5886 $mainInput.val(currentVal); 5887 $results.find('.selected-value').remove(); 5888 $results.prepend('<li class="selected-value" data-title="' + currentVal + '">' + currentText + '</li>'); 5889 $li.parents('.wd-scroll-content').find('.pf-active').removeClass('pf-active'); 5890 $li.addClass('pf-active'); 5891 } else { 5892 $mainInput.val(''); 5893 $results.find('.selected-value').remove(); 5894 $li.removeClass('pf-active'); 5895 } 5896 } 5897 }); 5898 5899 //Label clear 5900 var $checkboxes = $('.wd-pf-checkboxes'); 5901 $checkboxes.on('click', '.selected-value', function() { 5902 var $this = $(this); 5903 var $widget = $this.parents('.wd-pf-checkboxes'); 5904 var $mainInput = $widget.find('.result-input'); 5905 var currentVal = $this.data('title'); 5906 5907 //Price filter clear 5908 if (currentVal === 'price-filter') { 5909 var min = $this.data('min'); 5910 var max = $this.data('max'); 5911 var $slider = $widget.find('.price_slider_widget'); 5912 $slider.slider('values', 0, min); 5913 $slider.slider('values', 1, max); 5914 $widget.find('.min_price').val(''); 5915 $widget.find('.max_price').val(''); 5916 woodmartThemeModule.$body.trigger('filter_price_slider_slide', [ 5917 min, 5918 max, 5919 min, 5920 max, 5921 $slider 5922 ]); 5923 return; 5924 } 5925 5926 removeValue($mainInput, currentVal); 5927 $widget.find('.pf-value[data-val="' + currentVal + '"]').parent().removeClass('pf-active'); 5928 $this.remove(); 5929 }); 5930 5931 //Checkboxes value dropdown 5932 $checkboxes.each(function() { 5933 var $this = $(this); 5934 var $btn = $this.find('.wd-pf-title'); 5935 var $list = $btn.siblings('.wd-pf-dropdown'); 5936 var multiSelect = $this.hasClass('multi_select'); 5937 5938 $btn.on('click', function(e) { 5939 var target = e.target; 5940 5941 if ($(target).is($btn.find('.selected-value'))) { 5942 return; 5943 } 5944 5945 if (!$this.hasClass('opened')) { 5946 $this.addClass('opened'); 5947 $list.slideDown(100); 5948 setTimeout(function() { 5949 woodmartThemeModule.$document.trigger('wdProductFiltersOpened'); 5950 }, 300); 5951 } else { 5952 close(); 5953 } 5954 }); 5955 5956 woodmartThemeModule.$document.on('click', function(e) { 5957 var target = e.target; 5958 5959 if ($this.hasClass('opened') && (multiSelect && !$(target).is($this) && !$(target).parents().is($this)) || (!multiSelect && !$(target).is($btn) && !$(target).parents().is($btn))) { 5960 close(); 5961 } 5962 }); 5963 5964 var close = function() { 5965 $this.removeClass('opened'); 5966 $list.slideUp(100); 5967 }; 5968 }); 5969 5970 var removeEmptyValues = function($selector) { 5971 $selector.find('.wd-pf-checkboxes').each(function() { 5972 var $this = $(this); 5973 5974 if (!$this.find('input[type="hidden"]').val()) { 5975 $this.find('input[type="hidden"]').remove(); 5976 } 5977 }); 5978 }; 5979 5980 var changeFormAction = function($form) { 5981 var activeCat = $form.find('.wd-pf-categories .pf-active .pf-value'); 5982
5983 if (activeCat.length > 0) { 5984 $form.attr('action', activeCat.attr('href')); 5985 } 5986 }; 5987 5988 //Price slider init 5989 woodmartThemeModule.$body.on('filter_price_slider_create filter_price_slider_slide', function(event, min, max, minPrice, maxPrice, $slider) { 5990 var minHtml = accounting.formatMoney(min, { 5991 symbol : woocommerce_price_slider_params.currency_format_symbol, 5992 decimal : woocommerce_price_slider_params.currency_format_decimal_sep, 5993 thousand : woocommerce_price_slider_params.currency_format_thousand_sep, 5994 precision: woocommerce_price_slider_params.currency_format_num_decimals, 5995 format : woocommerce_price_slider_params.currency_format 5996 }); 5997 5998 var maxHtml = accounting.formatMoney(max, { 5999 symbol : woocommerce_price_slider_params.currency_format_symbol, 6000 decimal : woocommerce_price_slider_params.currency_format_decimal_sep, 6001 thousand : woocommerce_price_slider_params.currency_format_thousand_sep, 6002 precision: woocommerce_price_slider_params.currency_format_num_decimals, 6003 format : woocommerce_price_slider_params.currency_format 6004 }); 6005 6006 $slider.siblings('.filter_price_slider_amount').find('span.from').html(minHtml); 6007 $slider.siblings('.filter_price_slider_amount').find('span.to').html(maxHtml); 6008 6009 var $results = $slider.parents('.wd-pf-checkboxes').find('.wd-pf-results'); 6010 var value = $results.find('.selected-value'); 6011 6012 if (min === minPrice && max === maxPrice) { 6013 value.remove(); 6014 } else { 6015 if (value.length === 0) { 6016 $results.prepend('<li class="selected-value" data-title="price-filter" data-min="' + minPrice + '" data-max="' + maxPrice + '">' + minHtml + ' - ' + maxHtml + '</li>'); 6017 } else { 6018 value.html(minHtml + ' - ' + maxHtml); 6019 } 6020 } 6021 6022 woodmartThemeModule.$body.trigger('price_slider_updated', [ 6023 min, 6024 max 6025 ]); 6026 }); 6027 6028 $('.wd-pf-price-range .price_slider_widget').each(function() { 6029 var $this = $(this); 6030 var $minInput = $this.siblings('.filter_price_slider_amount').find('.min_price'); 6031 var $maxInput = $this.siblings('.filter_price_slider_amount').find('.max_price'); 6032 var minPrice = parseInt($minInput.data('min')); 6033 var maxPrice = parseInt($maxInput.data('max')); 6034 var currentMinPrice = parseInt($minInput.val()); 6035 var currentMaxPrice = parseInt($maxInput.val()); 6036 6037 $('.price_slider_widget, .price_label').show(); 6038 6039 $this.slider({ 6040 range : true, 6041 animate: true, 6042 min : minPrice, 6043 max : maxPrice, 6044 values : [ 6045 currentMinPrice, 6046 currentMaxPrice 6047 ], 6048 create : function() { 6049 if (currentMinPrice === minPrice && currentMaxPrice === maxPrice) { 6050 $minInput.val(''); 6051 $maxInput.val(''); 6052 } 6053 6054 woodmartThemeModule.$body.trigger('filter_price_slider_create', [ 6055 currentMinPrice, 6056 currentMaxPrice, 6057 minPrice, 6058 maxPrice, 6059 $this 6060 ]); 6061 }, 6062 slide : function(event, ui) { 6063 if (ui.values[0] === minPrice && ui.values[1] === maxPrice) { 6064 $minInput.val(''); 6065 $maxInput.val(''); 6066 } else { 6067 $minInput.val(ui.values[0]); 6068 $maxInput.val(ui.values[1]); 6069 } 6070 6071 woodmartThemeModule.$body.trigger('filter_price_slider_slide', [ 6072 ui.values[0], 6073 ui.values[1], 6074 minPrice, 6075 maxPrice, 6076 $this 6077 ]); 6078 }, 6079 change : function(event, ui) { 6080 woodmartThemeModule.$body.trigger('price_slider_change', [ 6081 ui.values[0], 6082 ui.values[1] 6083 ]); 6084 } 6085 }); 6086 }); 6087 6088 //Submit filter form 6089 $('.wd-product-filters').one('click', '.wd-pf-btn button', function() { 6090 var $this = $(this); 6091 var $form = $this.parents('.wd-product-filters'); 6092 removeEmptyValues($form); 6093 changeFormAction($form); 6094 6095 if (!woodmartThemeModule.$body.hasClass('woodmart-ajax-shop-on') || typeof ($.fn.pjax) == 'undefined' || !$form.hasClass('with-ajax')) { 6096 return; 6097 } 6098 6099 $.pjax({ 6100 container: '.main-page-wrapper', 6101 timeout : woodmart_settings.pjax_timeout, 6102 url : $form.attr('action'), 6103 data : $form.serialize(), 6104 scrollTo : false, 6105 renderCallback: function(context, html, afterRender) { 6106 woodmartThemeModule.removeDuplicatedStylesFromHTML(html, function(html) { 6107 context.html(html); 6108 afterRender(); 6109 woodmartThemeModule.$document.trigger('wdShopPageInit'); 6110 woodmartThemeModule.$document.trigger('wood-images-loaded'); 6111 }); 6112 } 6113 }); 6114 6115 $this.prop('disabled', true); 6116 }); 6117
6118 //Create labels after ajax 6119 $('.wd-pf-checkboxes .pf-active > .pf-value').each(function() { 6120 var $this = $(this); 6121 var resultsWrapper = $this.parents('.wd-pf-checkboxes').find('.wd-pf-results'); 6122 6123 resultsWrapper.prepend('<li class="selected-value" data-title="' + $this.data('val') + '">' + $this.data('title') + '</li>'); 6124 }); 6125 }; 6126 6127 $(document).ready(function() { 6128 woodmartThemeModule.productFilters(); 6129 }); 6130})(jQuery); 6131 6132/* global woodmart_settings */ 6133(function($) { 6134 woodmartThemeModule.$document.on('wdShopPageInit wdUpdateWishlist wdArrowsLoadProducts wdLoadMoreLoadProducts wdProductsTabsLoaded wdArrowsLoadProducts wdBackHistory', function() { 6135 woodmartThemeModule.productHover(); 6136 }); 6137 6138 woodmartThemeModule.wcTabsHoverFix = function() { 6139 $('.wc-tabs > li').on('click', function() { 6140 woodmartThemeModule.productHover(); 6141 }); 6142 }; 6143 6144 woodmartThemeModule.$document.on('wdProductMoreDescriptionOpen', function(event, $product) { 6145 woodmartThemeModule.productHoverRecalc($product); 6146 }); 6147 6148 $.each([ 6149 'frontend/element_ready/wd_products.default', 6150 'frontend/element_ready/wd_products_tabs.default' 6151 ], function(index, value) { 6152 woodmartThemeModule.wdElementorAddAction(value, function() { 6153 woodmartThemeModule.productHover(); 6154 }); 6155 }); 6156 6157 woodmartThemeModule.productHoverRecalc = function($el) { 6158 if ($el.hasClass('product-in-carousel')) { 6159 return; 6160 } 6161 6162 var heightHideInfo = $el.find('.fade-in-block').outerHeight(); 6163 6164 $el.find('.content-product-imagin').css({ 6165 marginBottom: -heightHideInfo 6166 }); 6167 6168 $el.addClass('hover-ready'); 6169 }; 6170 6171 woodmartThemeModule.productHover = function() { 6172 var $hoverBase = $('.wd-hover-base'); 6173 6174 if (woodmartThemeModule.windowWidth <= 1024) { 6175 $hoverBase.on('click', function(e) { 6176 var $this = $(this); 6177 var hoverClass = 'state-hover'; 6178 if (!$this.hasClass(hoverClass) && woodmart_settings.base_hover_mobile_click === 'no') { 6179 e.preventDefault(); 6180 $('.' + hoverClass).removeClass(hoverClass); 6181 $this.addClass(hoverClass); 6182 } 6183 }); 6184 6185 woodmartThemeModule.$document.on('click touchstart', function(e) { 6186 if ($(e.target).closest('.state-hover').length === 0) { 6187 $('.state-hover').removeClass('state-hover'); 6188 } 6189 }); 6190 } 6191 6192 $hoverBase.on('mouseenter mousemove touchstart', function() { 6193 var $product = $(this); 6194 var $content = $product.find('.xts-more-desc'); 6195 6196 if ($content.hasClass('wd-height-calculated')) { 6197 return; 6198 } 6199 6200 $product.imagesLoaded(function() { 6201 woodmartThemeModule.productHoverRecalc($product); 6202 }); 6203 6204 $content.addClass('wd-height-calculated'); 6205 }); 6206 6207 function productHolderWidth($holder) { 6208 if ($holder.data('column_width')) { 6209 return; 6210 } 6211 6212 var holderWidth = $holder.outerWidth(); 6213 var columns = $holder.data('columns'); 6214 var columnWidth = holderWidth / columns; 6215 6216 $holder.data('column_width', columnWidth); 6217 } 6218 6219 $('.wd-products-holder').on('mouseenter mousemove touchstart', function() { 6220 productHolderWidth($(this)); 6221 }); 6222 6223 $hoverBase.on('mouseenter mousemove touchstart', function() { 6224 if (!woodmart_settings.hover_width_small) { 6225 return; 6226 } 6227 6228 var $this = $(this); 6229 6230 productHolderWidth($this.parent('.wd-products-holder')); 6231 6232 var columnWidth = $this.parent('.wd-products-holder').data('column_width'); 6233 6234 if (!columnWidth) { 6235 return; 6236 } 6237 6238 if (255 > columnWidth || woodmartThemeModule.windowWidth <= 1024) { 6239 $this.find('.wd-add-btn').parent().addClass('wd-add-small-btn'); 6240 $this.find('.wd-add-btn').removeClass('wd-add-btn-replace').addClass('wd-action-btn wd-style-icon wd-add-cart-icon'); 6241 } else if (woodmartThemeModule.$body.hasClass('catalog-mode-on') || woodmartThemeModule.$body.hasClass('login-see-prices')) { 6242 $this.find('.wd-bottom-actions .wd-action-btn').removeClass('wd-style-icon').addClass('wd-style-text'); 6243 } 6244 6245 woodmartThemeModule.$document.trigger('wdProductBaseHoverIconsResize'); 6246 }); 6247 }; 6248 6249 $(document).ready(function() { 6250 woodmartThemeModule.productHover(); 6251 woodmartThemeModule.wcTabsHoverFix(); 6252 }); 6253})(jQuery); 6254 6255/* global woodmart_settings */ 6256(function($) { 6257 woodmartThemeModule.productImages = function() { 6258 var currentImage, 6259 $productGallery = $('.woocommerce-product-gallery'), 6260 $mainImages = $('.woocommerce-product-gallery__wrapper'), 6261 $thumbs = $productGallery.find('.thumbnails'), 6262 PhotoSwipeTrigger = '.woodmart-show-product-gallery'; 6263 6264 $thumbs.addClass('thumbnails-ready'); 6265 6266 if ($productGallery.hasClass('image-action-popup')) { 6267 PhotoSwipeTrigger += ', .woocommerce-product-gallery__image a'; 6268 } 6269 6270 $productGallery.on('click', '.woocommerce-product-gallery__image a', function(e) { 6271 e.preventDefault(); 6272 }); 6273 6274 $productGallery.on('click', PhotoSwipeTrigger, function(e) { 6275 e.preventDefault(); 6276 6277 currentImage = $(this).attr('href'); 6278 6279 var items = getProductItems(); 6280 6281 woodmartThemeModule.callPhotoSwipe(getCurrentGalleryIndex(e), items); 6282 }); 6283 6284 $thumbs.on('click', '.image-link', function(e) { 6285 e.preventDefault(); 6286 }); 6287 6288 var getCurrentGalleryIndex = function(e) { 6289 if ($mainImages.hasClass('owl-carousel')) { 6290 return $mainImages.find('.owl-item.active').index(); 6291 } else { 6292 return $(e.currentTarget).parent().parent().index(); 6293 } 6294 }; 6295 6296 var getProductItems = function() { 6297 var items = []; 6298 6299 $mainImages.find('figure a img').each(function() { 6300 var $this = $(this); 6301 var src = $this.attr('data-large_image'), 6302 width = $this.attr('data-large_image_width'), 6303 height = $this.attr('data-large_image_height'), 6304 caption = $this.data('caption'); 6305 6306 items.push({ 6307 src : src, 6308 w : width, 6309 h : height, 6310 title: (woodmart_settings.product_images_captions === 'yes') ? caption : false 6311 }); 6312 6313 }); 6314 6315 return items; 6316 }; 6317 }; 6318 6319 $(document).ready(function() { 6320 woodmartThemeModule.productImages(); 6321 }); 6322})(jQuery); 6323 6324/* global woodmart_settings */ 6325(function($) { 6326 woodmartThemeModule.$document.on('wdReplaceMainGallery', function () { 6327 woodmartThemeModule.productImagesGallery(); 6328 }); 6329 6330 woodmartThemeModule.productImagesGallery = function() { 6331 var $mainGallery = $('.woocommerce-product-gallery__wrapper:not(.quick-view-gallery)'); 6332 var $thumbs = $('.images .thumbnails'); 6333 var $mainOwl = $('.woocommerce-product-gallery__wrapper'); 6334 var thumbs_position = woodmart_settings.product_gallery.thumbs_slider.position; 6335 6336 $thumbs.addClass('thumbnails-ready'); 6337 6338 if (woodmart_settings.product_gallery.images_slider) { 6339 if (woodmart_settings.product_slider_auto_height === 'yes') { 6340 $('.product-images').imagesLoaded(function() { 6341 initMainGallery(); 6342 }); 6343 } else { 6344 initMainGallery(); 6345 } 6346 } else if (woodmartThemeModule.$window.width() <= 1024 && (thumbs_position === 'bottom_combined' || thumbs_position === 'bottom_column' || thumbs_position === 'bottom_grid')) { 6347 initMainGallery(); 6348 } 6349 6350 if (woodmart_settings.product_gallery.thumbs_slider.enabled && woodmart_settings.product_gallery.images_slider) { 6351 initThumbnailsMarkup(); 6352 if (woodmart_settings.product_gallery.thumbs_slider.position === 'left' && woodmartThemeModule.$body.width() > 1024 && typeof ($.fn.slick) != 'undefined') { 6353 initThumbnailsVertical(); 6354 } else { 6355 initThumbnailsHorizontal(); 6356 } 6357 } 6358 6359 function initMainGallery() { 6360 if ('undefined' === typeof $.fn.owlCarousel) { 6361 return; 6362 } 6363 6364 $mainGallery.trigger('destroy.owl.carousel'); 6365 $mainGallery.addClass('owl-carousel').owlCarousel(woodmartThemeModule.mainCarouselArg); 6366 woodmartThemeModule.$document.trigger('wood-images-loaded'); 6367 } 6368 6369 function initThumbnailsMarkup() { 6370 var markup = ''; 6371 6372 $mainGallery.find('.woocommerce-product-gallery__image').each(function() { 6373 var $this = $(this); 6374 var image = $this.data('thumb'), 6375 alt = $this.find('a img').attr('alt'), 6376 title = $this.find('a img').attr('title'); 6377 6378 if ( ! title ) { 6379 title = $this.find('a picture').attr('title'); 6380 } 6381 6382 markup += '<div class="product-image-thumbnail">
6382<img alt="' + alt + '" title="' + title + '" src="' + image + '" /></div>'; 6383 }); 6384 6385 if ($thumbs.hasClass('slick-slider')) { 6386 $thumbs.slick('unslick'); 6387 } else if ($thumbs.hasClass('owl-carousel')) { 6388 $thumbs.trigger('destroy.owl.carousel'); 6389 } 6390 6391 $thumbs.empty(); 6392 $thumbs.append(markup); 6393 } 6394 6395 function initThumbnailsVertical() { 6396 $thumbs.slick({ 6397 slidesToShow : woodmart_settings.product_gallery.thumbs_slider.items.vertical_items, 6398 slidesToScroll : woodmart_settings.product_gallery.thumbs_slider.items.vertical_items, 6399 vertical : true, 6400 verticalSwiping: true, 6401 infinite : false 6402 }); 6403 6404 $thumbs.on('click', '.product-image-thumbnail', function() { 6405 $mainOwl.trigger('to.owl.carousel', $(this).index()); 6406 }); 6407 6408 $mainOwl.on('changed.owl.carousel', function(e) { 6409 var i = e.item.index; 6410 6411 $thumbs.slick('slickGoTo', i); 6412 $thumbs.find('.active-thumb').removeClass('active-thumb'); 6413 $thumbs.find('.product-image-thumbnail').eq(i).addClass('active-thumb'); 6414 }); 6415 6416 $thumbs.find('.product-image-thumbnail').eq(0).addClass('active-thumb'); 6417 6418 $thumbs.imagesLoaded(function () { 6419 $thumbs.slick('setPosition'); 6420 }); 6421 } 6422 6423 function initThumbnailsHorizontal() { 6424 if ('undefined' === typeof $.fn.owlCarousel) { 6425 return; 6426 } 6427 6428 $thumbs.addClass('owl-carousel').owlCarousel({ 6429 rtl : woodmartThemeModule.$body.hasClass('rtl'), 6430 items : woodmart_settings.product_gallery.thumbs_slider.items.desktop, 6431 responsive: { 6432 1025: { 6433 items: woodmart_settings.product_gallery.thumbs_slider.items.desktop 6434 }, 6435 769 : { 6436 items: woodmart_settings.product_gallery.thumbs_slider.items.tablet_landscape 6437 }, 6438 577 : { 6439 items: woodmart_settings.product_gallery.thumbs_slider.items.tablet 6440 }, 6441 0 : { 6442 items: woodmart_settings.product_gallery.thumbs_slider.items.mobile 6443 } 6444 }, 6445 dots : false, 6446 nav : true, 6447 navText : false, 6448 navClass : ['owl-prev wd-btn-arrow', 'owl-next wd-btn-arrow'], 6449 }); 6450 6451 var $thumbsOwl = $thumbs.owlCarousel(); 6452 6453 $thumbs.on('mouseup', '.owl-item', function() { 6454 var i = $(this).index(); 6455 6456 $thumbsOwl.trigger('to.owl.carousel', i); 6457 $mainOwl.trigger('to.owl.carousel', i); 6458 }); 6459 6460 $mainOwl.on('changed.owl.carousel', function(e) { 6461 var i = e.item.index; 6462 6463 $thumbsOwl.trigger('to.owl.carousel', i); 6464 $thumbs.find('.active-thumb').removeClass('active-thumb'); 6465 $thumbs.find('.product-image-thumbnail').eq(i).addClass('active-thumb'); 6466 }); 6467 6468 $thumbs.find('.product-image-thumbnail').eq(0).addClass('active-thumb'); 6469 } 6470 }; 6471 6472 $(document).ready(function() { 6473 woodmartThemeModule.productImagesGallery(); 6474 }); 6475})(jQuery); 6476 6477/* global woodmart_settings */ 6478(function($) { 6479 woodmartThemeModule.$document.on('wdShopPageInit wdLoadMoreLoadProducts wdArrowsLoadProducts wdProductsTabsLoaded wdUpdateWishlist', function () { 6480 woodmartThemeModule.productMoreDescription(); 6481 }); 6482 6483 $.each([ 6484 'frontend/element_ready/wd_products.default', 6485 'frontend/element_ready/wd_products_tabs.default' 6486 ], function(index, value) { 6487 woodmartThemeModule.wdElementorAddAction(value, function() { 6488 woodmartThemeModule.productMoreDescription(); 6489 }); 6490 }); 6491 6492 woodmartThemeModule.productMoreDescription = function() { 6493 $('.wd-hover-base').on('mouseenter touchstart', function() { 6494 var $content = $(this).find('.wd-more-desc'); 6495 var $inner = $content.find('.wd-more-desc-inner'); 6496 var $moreBtn = $content.find('.wd-more-desc-btn'); 6497 6498 if ($content.hasClass('wd-more-desc-calculated')) { 6499 return; 6500 } 6501 6502 var contentHeight = $content.outerHeight(); 6503 var innerHeight = $inner.outerHeight(); 6504 var delta = innerHeight - contentHeight; 6505 6506 if (delta > 30) { 6507 $moreBtn.addClass('wd-shown'); 6508 } else if (delta > 0) { 6509 $content.css('height', contentHeight + delta); 6510 } 6511 6512 $content.addClass('wd-more-desc-calculated'); 6513 }); 6514 6515 woodmartThemeModule.$body.on('click', '.wd-more-desc-btn', function(e) { 6516 e.preventDefault(); 6517 var $this = $(this); 6518 6519 $this.parent().addClass('wd-more-desc-full'); 6520 6521 woodmartThemeModule.$document.trigger('wdProductMoreDescriptionOpen', [$this.parents('.wd-hover-base')]); 6522 }); 6523 }; 6524 6525 $(document).ready(function() { 6526 woodmartThemeModule.productMoreDescription(); 6527 }); 6528})(jQuery); 6529 6530/* global woodmart_settings */ 6531(function($) { 6532 woodmartThemeModule.productVideo = function() { 6533 if ('undefined' === typeof $.fn.magnificPopup) { 6534 return; 6535 } 6536 6537 $('.product-video-button a').magnificPopup({
6538 tClose : woodmart_settings.close, 6539 tLoading : woodmart_settings.loading, 6540 type : 'iframe', 6541 removalDelay : 500, 6542 iframe : { 6543 markup : '<div class="mfp-iframe-scaler mfp-with-anim">' + 6544 '<div class="mfp-close"></div>' + 6545 '<iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe>' + 6546 '</div>', 6547 patterns: { 6548 youtube: { 6549 index: 'youtube.com/', 6550 id : 'v=', 6551 src : '//www.youtube.com/embed/%id%?rel=0&autoplay=1' 6552 } 6553 } 6554 }, 6555 preloader : false, 6556 fixedContentPos: false, 6557 callbacks : { 6558 beforeOpen: function() { 6559 this.st.mainClass = 'mfp-move-horizontal'; 6560 } 6561 } 6562 }); 6563 }; 6564 6565 $(document).ready(function() { 6566 woodmartThemeModule.productVideo(); 6567 }); 6568})(jQuery); 6569 6570/* global woodmart_settings */ 6571(function($) { 6572 woodmartThemeModule.$document.on('wdProductsTabsLoaded', function() { 6573 woodmartThemeModule.productsLoadMore(); 6574 }); 6575 6576 $.each([ 6577 'frontend/element_ready/wd_products.default', 6578 'frontend/element_ready/wd_products_tabs.default' 6579 ], function(index, value) { 6580 woodmartThemeModule.wdElementorAddAction(value, function() { 6581 woodmartThemeModule.productsLoadMore(); 6582 }); 6583 }); 6584 6585 woodmartThemeModule.productsLoadMore = function() { 6586 var process = false, 6587 intervalID; 6588 6589 $('.wd-products-element').each(function() { 6590 var $this = $(this), 6591 cache = [], 6592 inner = $this.find('.wd-products-holder'); 6593 6594 if (!inner.hasClass('pagination-arrows')) { 6595 return; 6596 } 6597 6598 cache[1] = { 6599 items : inner.html(), 6600 status: 'have-posts' 6601 }; 6602 6603 var body = woodmartThemeModule.$body, 6604 btnWrap = $this.find('.products-footer'), 6605 btnLeft = btnWrap.find('.wd-products-load-prev'), 6606 btnRight = btnWrap.find('.wd-products-load-next'), 6607 loadWrapp = $this.find('.wd-products-loader'), 6608 scrollTop, 6609 holderTop, 6610 btnLeftOffset, 6611 btnRightOffset, 6612 holderBottom, 6613 holderHeight, 6614 holderWidth, 6615 btnsHeight, 6616 offsetArrow = 50, 6617 offset, 6618 windowWidth; 6619 6620 if (body.hasClass('rtl')) { 6621 btnLeft = btnRight; 6622 btnRight = btnWrap.find('.wd-products-load-prev'); 6623 } 6624 6625 woodmartThemeModule.$window.on('scroll', function() { 6626 buttonsPos(); 6627 }); 6628 6629 setTimeout(function() { 6630 buttonsPos(); 6631 }, 500); 6632 6633 function buttonsPos() { 6634 offset = woodmartThemeModule.$window.height() / 2; 6635 windowWidth = woodmartThemeModule.$window.outerWidth(true); 6636 holderWidth = $this.outerWidth(true); 6637 scrollTop = woodmartThemeModule.$window.scrollTop(); 6638 holderTop = $this.offset().top - offset; 6639 btnLeftOffset = $this.offset().left - offsetArrow; 6640 btnRightOffset = holderWidth + $this.offset().left + offsetArrow - btnRight.outerWidth(); 6641 btnsHeight = btnLeft.outerHeight(); 6642 holderHeight = $this.height() - btnsHeight; 6643 holderBottom = holderTop + holderHeight; 6644 6645 if (woodmartThemeModule.$window.width() <= 1024) { 6646 btnLeftOffset = btnLeftOffset + 35; 6647 btnRightOffset = btnRightOffset - 35; 6648 } 6649 6650 btnLeft.css({ 6651 'left': btnLeftOffset + 'px' 6652 }); 6653 6654 btnRight.css({ 6655 'left': btnRightOffset + 'px' 6656 }); 6657 6658 if (scrollTop < holderTop || scrollTop > holderBottom) { 6659 btnWrap.removeClass('show-arrow'); 6660 loadWrapp.addClass('hidden-loader'); 6661 } else { 6662 btnWrap.addClass('show-arrow'); 6663 loadWrapp.removeClass('hidden-loader'); 6664 } 6665 } 6666 6667 $this.find('.wd-products-load-prev, .wd-products-load-next').on('click', function(e) { 6668 e.preventDefault(); 6669 var $this = $(this); 6670 6671 if (process || $this.hasClass('disabled')) { 6672 return; 6673 } 6674 6675 process = true; 6676 6677 clearInterval(intervalID); 6678 6679 var holder = $this.parent().parent().prev(), 6680 next = $this.parent().find('.wd-products-load-next'), 6681 prev = $this.parent().find('.wd-products-load-prev'), 6682 atts = holder.data('atts'), 6683 action = 'woodmart_get_products_shortcode', 6684 ajaxurl = woodmart_settings.ajaxurl, 6685 dataType = 'json', 6686 method = 'POST', 6687 paged = holder.attr('data-paged'); 6688 6689 paged++; 6690 6691 if ($this.hasClass('wd-products-load-prev')) { 6692 if (paged < 2) { 6693 return; 6694 } 6695 6696 paged = paged - 2; 6697 } 6698 6699 loadProducts('arrows', atts, ajaxurl, action, dataType, method, paged, holder, $this, cache, function(data) { 6700 var isBorderedGrid = holder.hasClass('products-bordered-grid'); 6701 6702 if (!isBorderedGrid) { 6703 holder.addClass('wd-animated-products'); 6704 } 6705 6706 if (data.items.length) { 6707 holder.html(data.items).attr('data-paged', paged); 6708 holder.imagesLoaded().progress(function() { 6709 holder.parent().trigger('recalc'); 6710 }); 6711 6712 woodmartThemeModule.$document.trigger('wood-images-loaded'); 6713 woodmartThemeModule.$document.trigger('wdArrowsLoadProducts'); 6714 } 6715 6716 if (woodmartThemeModule.$window.width() < 768) { 6717 $('html, body').stop().animate({ 6718 scrollTop: holder.offset().top - 150 6719 }, 400); 6720 } 6721 6722 if (!isBorderedGrid) { 6723 var iter = 0; 6724 6725 intervalID = setInterval(function() { 6726 holder.find('.product-grid-item').eq(iter).addClass('wd-animated'); 6727 iter++; 6728 }, 100); 6729 } 6730 6731 if (paged > 1) { 6732 prev.removeClass('disabled'); 6733 } else { 6734 prev.addClass('disabled'); 6735 } 6736 6737 if (data.status === 'no-more-posts') { 6738 next.addClass('disabled'); 6739 } else { 6740 next.removeClass('disabled'); 6741 } 6742 }); 6743 }); 6744 }); 6745 6746 woodmartThemeModule.clickOnScrollButton(woodmartThemeModule.shopLoadMoreBtn, false, woodmart_settings.infinit_scroll_offset); 6747 6748 woodmartThemeModule.$document.off('click', '.wd-products-load-more').on('click', '.wd-products-load-more', function(e) { 6749 e.preventDefault(); 6750 6751 if (process) { 6752 return; 6753 } 6754 6755 process = true; 6756 6757 var $this = $(this), 6758 holder = $this.parent().siblings('.wd-products-holder'), 6759 source = holder.data('source'), 6760 action = 'woodmart_get_products_' + source,
6761 ajaxurl = woodmart_settings.ajaxurl, 6762 dataType = 'json', 6763 method = 'POST', 6764 atts = holder.data('atts'), 6765 paged = holder.data('paged'); 6766 6767 paged++; 6768 6769 if (source === 'main_loop') { 6770 ajaxurl = $(this).attr('href'); 6771 method = 'GET'; 6772 } 6773 6774 loadProducts('load-more', atts, ajaxurl, action, dataType, method, paged, holder, $this, [], function(data) { 6775 if (data.items.length) { 6776 if (holder.hasClass('grid-masonry')) { 6777 isotopeAppend(holder, data.items); 6778 } else { 6779 holder.append(data.items); 6780 } 6781 6782 if (data.status !== 'no-more-posts') { 6783 holder.imagesLoaded().progress(function() { 6784 woodmartThemeModule.clickOnScrollButton(woodmartThemeModule.shopLoadMoreBtn, true, woodmart_settings.infinit_scroll_offset); 6785 }); 6786 } 6787 6788 woodmartThemeModule.$document.trigger('wood-images-loaded'); 6789 woodmartThemeModule.$document.trigger('wdLoadMoreLoadProducts'); 6790 6791 holder.data('paged', paged); 6792 } 6793 6794 if (source === 'main_loop') { 6795 $this.attr('href', data.nextPage); 6796 6797 if (data.status === 'no-more-posts') { 6798 $this.hide().remove(); 6799 } 6800 } 6801 6802 if (data.status === 'no-more-posts') { 6803 $this.hide(); 6804 } 6805 }); 6806 }); 6807 6808 var loadProducts = function(btnType, atts, ajaxurl, action, dataType, method, paged, holder, btn, cache, callback) { 6809 var data = { 6810 atts : atts, 6811 paged : paged, 6812 action : action, 6813 woo_ajax: 1 6814 }; 6815 6816 if (method === 'GET') { 6817 ajaxurl = woodmartThemeModule.removeURLParameter(ajaxurl, 'loop'); 6818 ajaxurl = woodmartThemeModule.removeURLParameter(ajaxurl, 'woo_ajax'); 6819 } 6820 6821 if (cache[paged]) { 6822 holder.addClass('loading'); 6823 6824 setTimeout(function() { 6825 callback(cache[paged]); 6826 holder.removeClass('loading'); 6827 process = false; 6828 }, 300); 6829 6830 return; 6831 } 6832 6833 if (btnType === 'arrows') { 6834 holder.addClass('loading').parent().addClass('element-loading'); 6835 } 6836 6837 btn.addClass('loading'); 6838 6839 if (action === 'woodmart_get_products_main_loop') { 6840 var loop = holder.find('.product').last().data('loop'); 6841 data = { 6842 loop : loop, 6843 woo_ajax: 1 6844 }; 6845 } 6846 6847 $.ajax({ 6848 url : ajaxurl, 6849 data : data, 6850 dataType: dataType, 6851 method : method, 6852 success : function(data) { 6853 woodmartThemeModule.removeDuplicatedStylesFromHTML(data.items, function(html) { 6854 data.items = html; 6855 cache[paged] = data; 6856 callback(data); 6857 if ('yes' === woodmart_settings.load_more_button_page_url) { 6858 window.history.pushState('', '', data.currentPage); 6859 } 6860 }); 6861 }, 6862 error : function() { 6863 console.log('ajax error'); 6864 }, 6865 complete: function() { 6866 if (btnType === 'arrows') { 6867 holder.removeClass('loading').parent().removeClass('element-loading'); 6868 } 6869 6870 btn.removeClass('loading'); 6871 process = false; 6872 } 6873 }); 6874 }; 6875 6876 var isotopeAppend = function(el, items) { 6877 var $items = $(items); 6878 el.append($items).isotope('appended', $items); 6879 el.imagesLoaded().progress(function() { 6880 el.isotope('layout'); 6881 }); 6882 }; 6883 }; 6884 6885 $(document).ready(function() { 6886 woodmartThemeModule.productsLoadMore(); 6887 }); 6888})(jQuery); 6889 6890/* global woodmart_settings */ 6891(function($) { 6892 $.each([ 6893 'frontend/element_ready/wd_products_tabs.default' 6894 ], function(index, value) { 6895 woodmartThemeModule.wdElementorAddAction(value, function() { 6896 woodmartThemeModule.productsTabs(); 6897 }); 6898 }); 6899 6900 woodmartThemeModule.productsTabs = function() { 6901 var process = false; 6902 6903 $('.wd-products-tabs').each(function() { 6904 var $this = $(this), 6905 $inner = $this.find('.wd-tab-content'), 6906 cache = []; 6907 6908 if ($inner.find('.owl-carousel').length < 1) { 6909 cache[0] = { 6910 html: $inner.html() 6911 }; 6912 } 6913 6914 $this.find('.products-tabs-title li').on('click', function(e) { 6915 e.preventDefault(); 6916 6917 var $this = $(this), 6918 atts = $this.data('atts'), 6919 index = $this.index(); 6920 6921 if (process || $this.hasClass('active-tab-title')) { 6922 return; 6923 } 6924 process = true; 6925 6926 loadTab(atts, index, $inner, $this, cache, function(data) { 6927 if (data.html) { 6928 woodmartThemeModule.removeDuplicatedStylesFromHTML(data.html, function(html) { 6929 $inner.html(html); 6930 6931 $inner.removeClass('loading').parent().removeClass('element-loading'); 6932 $this.removeClass('loading'); 6933 6934 woodmartThemeModule.$document.trigger('wdProductsTabsLoaded'); 6935 woodmartThemeModule.$document.trigger('wood-images-loaded'); 6936 }); 6937 } 6938 }); 6939 }); 6940
6941 var $nav = $this.find('.tabs-navigation-wrapper'), 6942 $subList = $nav.find('ul'), 6943 time = 300; 6944 6945 $nav.on('click', '.open-title-menu', function() { 6946 var $btn = $(this); 6947 6948 if ($subList.hasClass('list-shown')) { 6949 $btn.removeClass('toggle-active'); 6950 $subList.stop().slideUp(time).removeClass('list-shown'); 6951 } else { 6952 $btn.addClass('toggle-active'); 6953 $subList.addClass('list-shown'); 6954 setTimeout(function() { 6955 woodmartThemeModule.$body.one('click', function(e) { 6956 var target = e.target; 6957 6958 if (!$(target).is('.tabs-navigation-wrapper') && !$(target).parents().is('.tabs-navigation-wrapper')) { 6959 $btn.removeClass('toggle-active'); 6960 $subList.removeClass('list-shown'); 6961 return false; 6962 } 6963 }); 6964 }, 10); 6965 } 6966 }) 6967 .on('click', 'li', function() { 6968 var $btn = $nav.find('.open-title-menu'), 6969 text = $(this).text(); 6970 6971 if ($subList.hasClass('list-shown')) { 6972 $btn.removeClass('toggle-active').text(text); 6973 $subList.removeClass('list-shown'); 6974 } 6975 }); 6976 }); 6977 6978 var loadTab = function(atts, index, holder, btn, cache, callback) { 6979 btn.parent().find('.active-tab-title').removeClass('active-tab-title'); 6980 btn.addClass('active-tab-title'); 6981 6982 if (cache[index]) { 6983 holder.addClass('loading'); 6984 setTimeout(function() { 6985 callback(cache[index]); 6986 holder.removeClass('loading'); 6987 process = false; 6988 }, 300); 6989 return; 6990 } 6991 6992 holder.addClass('loading').parent().addClass('element-loading'); 6993 btn.addClass('loading'); 6994 6995 $.ajax({ 6996 url : woodmart_settings.ajaxurl, 6997 data : { 6998 atts : atts, 6999 action: 'woodmart_get_products_tab_shortcode' 7000 }, 7001 dataType: 'json', 7002 method : 'POST', 7003 success : function(data) { 7004 cache[index] = data; 7005 callback(data); 7006 }, 7007 error : function() { 7008 console.log('ajax error'); 7009 }, 7010 complete: function() { 7011 process = false; 7012 } 7013 }); 7014 }; 7015 }; 7016 7017 $(document).ready(function() { 7018 woodmartThemeModule.productsTabs(); 7019 }); 7020})(jQuery); 7021 7022/* global woodmart_settings */ 7023(function($) { 7024 $.each([ 7025 'frontend/element_ready/wd_products.default', 7026 'frontend/element_ready/wd_products_tabs.default' 7027 ], function(index, value) { 7028 woodmartThemeModule.wdElementorAddAction(value, function() { 7029 woodmartThemeModule.quickShop(); 7030 }); 7031 }); 7032 7033 woodmartThemeModule.quickShop = function() { 7034 if ('no' === woodmart_settings.quick_shop) { 7035 return; 7036 } 7037 7038 var btnSelector = '.product-grid-item.product-type-variable .add_to_cart_button'; 7039 7040 woodmartThemeModule.$document.on('click', btnSelector, function(e) { 7041 e.preventDefault(); 7042 7043 var $this = $(this), 7044 $product = $this.parents('.product').first(), 7045 $content = $product.find('.quick-shop-form'), 7046 id = $product.data('id'), 7047 loadingClass = 'btn-loading'; 7048 7049 if ($this.hasClass(loadingClass)) { 7050 return; 7051 } 7052 7053 // Simply show quick shop form if it is already loaded with AJAX previously 7054 if ($product.hasClass('quick-shop-loaded')) { 7055 $product.addClass('quick-shop-shown'); 7056 woodmartThemeModule.$body.trigger('woodmart-quick-view-displayed'); 7057 return; 7058 } 7059 7060 $this.addClass(loadingClass); 7061 $product.addClass('wd-loading-quick-shop'); 7062 7063 $.ajax({ 7064 url : woodmart_settings.ajaxurl, 7065 data : { 7066 action: 'woodmart_quick_shop', 7067 id : id 7068 }, 7069 method : 'get', 7070 success : function(data) { 7071 $content.append(data); 7072 7073 initVariationForm($product); 7074 woodmartThemeModule.$document.trigger('wdQuickShopSuccess'); 7075 }, 7076 complete: function() { 7077 setTimeout(function() { 7078 $this.removeClass(loadingClass); 7079 $product.removeClass('wd-loading-quick-shop'); 7080 $product.addClass('quick-shop-shown quick-shop-loaded'); 7081 woodmartThemeModule.$body.trigger('woodmart-quick-view-displayed'); 7082 }, 100); 7083 } 7084 }); 7085 }) 7086 .on('click', '.quick-shop-close', function(e) { 7087 e.preventDefault(); 7088 7089 var $this = $(this), 7090 $product = $this.parents('.product'); 7091 7092 $product.removeClass('quick-shop-shown'); 7093 }); 7094 7095 woodmartThemeModule.$body.on('added_to_cart', function() { 7096 $('.product').removeClass('quick-shop-shown'); 7097 }); 7098 7099 function initVariationForm($product) { 7100 $product.find('.variations_form').wc_variation_form().find('.variations select:eq(0)').change(); 7101 $product.find('.variations_form').trigger('wc_variation_form'); 7102 } 7103 }; 7104 7105 $(document).ready(function() { 7106 woodmartThemeModule.quickShop(); 7107 }); 7108})(jQuery); 7109 7110/* global woodmart_settings */ 7111(function($) { 7112 $.each([ 7113 'frontend/element_ready/wd_products.default', 7114 'frontend/element_ready/wd_products_tabs.default' 7115 ], function(index, value) { 7116 woodmartThemeModule.wdElementorAddAction(value, function() { 7117 woodmartThemeModule.quickViewInit(); 7118 }); 7119 }); 7120 7121 woodmartThemeModule.$document.on('wdReplaceMainGallery', function () { 7122 woodmartThemeModule.quickViewCarousel(); 7123 }); 7124 7125 woodmartThemeModule.quickViewInit = function() { 7126 woodmartThemeModule.$document.on('click', '.open-quick-view', function(e) { 7127 e.preventDefault(); 7128 7129 if ($('.open-quick-view').hasClass('loading')) { 7130 return true; 7131 } 7132 7133 var $this = $(this), 7134 productId = $this.data('id'), 7135 loopName = $this.data('loop-name'), 7136 loop = $this.data('loop'), 7137 prev = '', 7138 next = '', 7139 loopBtns = $('.quick-view').find('[data-loop-name="' + loopName + '"]'); 7140 7141 $this.addClass('loading'); 7142 7143 if (typeof loopBtns[loop - 1] != 'undefined') { 7144 prev = loopBtns.eq(loop - 1).addClass('quick-view-prev'); 7145 prev = $('<div>').append(prev.clone()).html(); 7146 } 7147 7148 if (typeof loopBtns[loop + 1] != 'undefined') { 7149 next = loopBtns.eq(loop + 1).addClass('quick-view-next'); 7150 next = $('<div>').append(next.clone()).html(); 7151 } 7152 7153 woodmartThemeModule.quickViewLoad(productId, $this, prev, next); 7154 }); 7155 }; 7156 7157 woodmartThemeModule.quickViewCarousel = function() { 7158 if ('undefined' === typeof $.fn.owlCarousel) { 7159 return; 7160 } 7161 7162 var $quickViewCarousel = $('.product-quick-view .woocommerce-product-gallery__wrapper'); 7163 7164 $quickViewCarousel.trigger('destroy.owl.carousel'); 7165 $quickViewCarousel.addClass('owl-carousel').owlCarousel({
7166 rtl : woodmartThemeModule.$body.hasClass('rtl'), 7167 items : 1, 7168 dots : false, 7169 nav : true, 7170 navText: false, 7171 navClass : ['owl-prev wd-btn-arrow', 'owl-next wd-btn-arrow'], 7172 }); 7173 }; 7174 7175 woodmartThemeModule.quickViewLoad = function(id, btn) { 7176 var data = { 7177 id : id, 7178 action: 'woodmart_quick_view' 7179 }; 7180 7181 var initPopup = function(data) { 7182 var items = $(data); 7183 7184 $.magnificPopup.open({ 7185 items : { 7186 src : items, 7187 type: 'inline' 7188 }, 7189 tClose : woodmart_settings.close, 7190 tLoading : woodmart_settings.loading, 7191 removalDelay: 500, 7192 callbacks : { 7193 beforeOpen: function() { 7194 this.st.mainClass = 'mfp-move-horizontal quick-view-wrapper'; 7195 }, 7196 open : function() { 7197 var $form = $('.variations_form'); 7198 7199 $form.each(function() { 7200 $(this).wc_variation_form().find('.variations select:eq(0)').change(); 7201 }); 7202 7203 $form.trigger('wc_variation_form'); 7204 woodmartThemeModule.$body.trigger('woodmart-quick-view-displayed'); 7205 woodmartThemeModule.$document.trigger('wdQuickViewOpen'); 7206 setTimeout(function() { 7207 woodmartThemeModule.$document.trigger('wdQuickViewOpen300'); 7208 }, 300); 7209 woodmartThemeModule.quickViewCarousel(); 7210 } 7211 } 7212 }); 7213 }; 7214 7215 $.ajax({ 7216 url : woodmart_settings.ajaxurl, 7217 data : data, 7218 method : 'get', 7219 success : function(data) { 7220 woodmartThemeModule.removeDuplicatedStylesFromHTML(data, function(data){ 7221 if (woodmart_settings.quickview_in_popup_fix) { 7222 $.magnificPopup.close(); 7223 setTimeout(function() { 7224 initPopup(data); 7225 }, 500); 7226 } else { 7227 initPopup(data); 7228 } 7229 }); 7230 }, 7231 complete: function() { 7232 btn.removeClass('loading'); 7233 } 7234 }); 7235 }; 7236 7237 $(document).ready(function() { 7238 woodmartThemeModule.quickViewInit(); 7239 woodmartThemeModule.quickViewCarousel(); 7240 }); 7241})(jQuery); 7242 7243/* global wd_settings */ 7244(function($) { 7245 woodmartThemeModule.$document.on('wdFiltersOpened wdShopPageInit wdPjaxStart', function () { 7246 woodmartThemeModule.shopLoader(); 7247 }); 7248 7249 woodmartThemeModule.shopLoader = function() { 7250 var loaderVerticalPosition = function() { 7251 var $products = $('.products[data-source="main_loop"], .wd-portfolio-holder[data-source="main_loop"]'); 7252 var $loader = $products.parent().find('.wd-sticky-loader'); 7253 7254 if ($products.length < 1) { 7255 return; 7256 } 7257 7258 var offset = woodmartThemeModule.$window.height() / 2; 7259 var scrollTop = woodmartThemeModule.$window.scrollTop(); 7260 var holderTop = $products.offset().top - offset + 45; 7261 var holderHeight = $products.height(); 7262 var holderBottom = holderTop + holderHeight - 170; 7263 7264 if (scrollTop < holderTop) { 7265 $loader.addClass('wd-position-top'); 7266 $loader.removeClass('wd-position-stick'); 7267 } else if (scrollTop > holderBottom) { 7268 $loader.addClass('wd-position-bottom'); 7269 $loader.removeClass('wd-position-stick'); 7270 } else { 7271 $loader.addClass('wd-position-stick'); 7272 $loader.removeClass('wd-position-top wd-position-bottom'); 7273 } 7274 }; 7275 7276 woodmartThemeModule.$window.off('scroll.loaderVerticalPosition'); 7277 7278 woodmartThemeModule.$window.on('scroll.loaderVerticalPosition', loaderVerticalPosition); 7279 }; 7280 7281 $(document).ready(function() { 7282 woodmartThemeModule.shopLoader(); 7283 }); 7284})(jQuery); 7285/* global woodmart_settings */ 7286(function($) { 7287 woodmartThemeModule.$document.on('wdProductsTabsLoaded wdShopPageInit', function () { 7288 woodmartThemeModule.shopMasonry(); 7289 }); 7290 7291 $.each([ 7292 'frontend/element_ready/wd_products.default', 7293 'frontend/element_ready/wd_products_tabs.default', 7294 'frontend/element_ready/wd_products_brands.default' 7295 ], function(index, value) { 7296 woodmartThemeModule.wdElementorAddAction(value, function() { 7297 woodmartThemeModule.shopMasonry(); 7298 }); 7299 }); 7300 7301 woodmartThemeModule.shopMasonry = function() { 7302 if (typeof ($.fn.isotope) == 'undefined' || typeof ($.fn.packery) == 'undefined' || typeof ($.fn.imagesLoaded) == 'undefined') { 7303 return; 7304 } 7305 7306 var $container = $('.elements-grid.grid-masonry'); 7307 $container.imagesLoaded(function() { 7308 $container.isotope({ 7309 isOriginLeft: !woodmartThemeModule.$body.hasClass('rtl'), 7310 itemSelector: '.category-grid-item, .product-grid-item' 7311 }); 7312 }); 7313 7314 woodmartThemeModule.$window.on('resize', function() { 7315 initMasonry(); 7316 }); 7317 7318 initMasonry(); 7319 7320 function initMasonry() { 7321 var $catsContainer = $('.categories-masonry'); 7322 var colWidth = ($catsContainer.hasClass('categories-style-masonry')) ? '.category-grid-item' : '.col-lg-3.category-grid-item'; 7323 $catsContainer.imagesLoaded(function() { 7324 $catsContainer.packery({ 7325 resizable : false, 7326 isOriginLeft: !woodmartThemeModule.$body.hasClass('rtl'), 7327 packery : { 7328 gutter : 0, 7329 columnWidth: colWidth 7330 }, 7331 itemSelector: '.category-grid-item' 7332 }); 7333 }); 7334 } 7335 }; 7336 7337 $(document).ready(function() { 7338 woodmartThemeModule.shopMasonry(); 7339 }); 7340})(jQuery); 7341 7342/* global woodmart_settings */ 7343(function($) { 7344 woodmartThemeModule.$document.on('wdShopPageInit', function () { 7345 woodmartThemeModule.shopPageInit(); 7346 }); 7347 7348 woodmartThemeModule.shopPageInit = function() { 7349 woodmartThemeModule.clickOnScrollButton(woodmartThemeModule.shopLoadMoreBtn, false, woodmart_settings.infinit_scroll_offset); 7350 7351 $('body > .tooltip').remove(); 7352 7353 woodmartThemeModule.$body.on('updated_wc_div', function() { 7354 woodmartThemeModule.$document.trigger('wood-images-loaded'); 7355 }); 7356 7357 woodmartThemeModule.$document.trigger('resize.vcRowBehaviour'); 7358 }; 7359})(jQuery); 7360 7361/* global woodmart_settings */ 7362(function($) { 7363 $(window).on('elementor/frontend/init', function() { 7364 if (!elementorFrontend.isEditMode()) { 7365 return; 7366 } 7367 7368 $(window).on('resize', function() { 7369 woodmartThemeModule.singleProductTabsAccordion(); 7370 }); 7371 }); 7372 7373 woodmartThemeModule.singleProductTabsAccordion = function() { 7374 var $wcTabs = $('.woocommerce-tabs'); 7375 if (woodmartThemeModule.windowWidth > 1024 || $wcTabs.length <= 0) { 7376 return; 7377 } 7378 7379 $wcTabs.removeClass('tabs-layout-tabs').addClass('tabs-layout-accordion'); 7380 $('.single-product-page').removeClass('tabs-type-tabs').addClass('tabs-type-accordion'); 7381 }; 7382 7383 $(document).ready(function() { 7384 woodmartThemeModule.singleProductTabsAccordion(); 7385 }); 7386})(jQuery); 7387 7388/* global woodmart_settings */ 7389(function($) { 7390 woodmartThemeModule.singleProductTabsCommentsFix = function() { 7391 var url = window.location.href; 7392 var hash = window.location.hash; 7393 var $tabs = woodmartThemeModule.$body.find('.wc-tabs, ul.tabs').first(); 7394 7395 if (!$('.single-product-page').hasClass('reviews-location-separate')) { 7396 return; 7397 } 7398 7399 if (hash.toLowerCase().indexOf('comment-') >= 0 || hash === '#reviews' || hash === '#tab-reviews') { 7400 $tabs.find('li:first a').click(); 7401 } else if (url.indexOf('comment-page-') > 0 || url.indexOf('cpage=') > 0) { 7402 $tabs.find('li:first a').click(); 7403 } 7404 }; 7405 7406 $(document).ready(function() { 7407 woodmartThemeModule.singleProductTabsCommentsFix(); 7408 }); 7409})(jQuery); 7410 7411/* global woodmart_settings */ 7412(function($) { 7413 woodmartThemeModule.$document.on('wdShopPageInit', function() { 7414 woodmartThemeModule.sortByWidget(); 7415 }); 7416 7417 woodmartThemeModule.sortByWidget = function() { 7418 if (!woodmartThemeModule.$body.hasClass('woodmart-ajax-shop-on') || typeof ($.fn.pjax) == 'undefined') { 7419 return; 7420 } 7421 7422 var $wcOrdering = $('.woocommerce-ordering'); 7423 7424 $wcOrdering.on('change', 'select.orderby', function() { 7425 var $form = $(this).closest('form'); 7426 $form.find('[name="_pjax"]').remove(); 7427 7428 $.pjax({ 7429 container: '.main-page-wrapper', 7430 timeout : woodmart_settings.pjax_timeout, 7431 url : '?' + $form.serialize(), 7432 scrollTo : false, 7433 renderCallback: function(context, html, afterRender) { 7434 woodmartThemeModule.removeDuplicatedStylesFromHTML(html, function(html) { 7435 context.html(html); 7436 afterRender(); 7437 woodmartThemeModule.$document.trigger('wdShopPageInit'); 7438 woodmartThemeModule.$document.trigger('wood-images-loaded'); 7439 }); 7440 } 7441 }); 7442 }); 7443 7444 $wcOrdering.on('submit', function(e) { 7445 e.preventDefault(e); 7446 }); 7447 }; 7448 7449 $(document).ready(function() { 7450 woodmartThemeModule.sortByWidget(); 7451 }); 7452})(jQuery); 7453 7454/* global woodmart_settings */ 7455(function($) { 7456 woodmartThemeModule.stickyAddToCart = function() { 7457 var $trigger = $('form.cart'); 7458 var $stickyBtn = $('.wd-sticky-btn'); 7459 7460 if ($stickyBtn.length <= 0 || $trigger.length <= 0 || (woodmartThemeModule.$window.width() <= 768 && $stickyBtn.hasClass('mobile-off'))) { 7461 return; 7462 } 7463 7464 var summaryOffset = $trigger.offset().top + $trigger.outerHeight(); 7465 var $scrollToTop = $('.scrollToTop'); 7466 7467 var stickyAddToCartToggle = function() { 7468 var windowScroll = woodmartThemeModule.$window.scrollTop();
7469 var windowHeight = woodmartThemeModule.$window.height(); 7470 var documentHeight = woodmartThemeModule.$document.height(); 7471 7472 if (summaryOffset < windowScroll && windowScroll + windowHeight !== documentHeight) { 7473 $stickyBtn.addClass('wd-sticky-btn-shown'); 7474 $scrollToTop.addClass('wd-sticky-btn-shown'); 7475 7476 } else if (windowScroll + windowHeight === documentHeight || summaryOffset > windowScroll) { 7477 $stickyBtn.removeClass('wd-sticky-btn-shown'); 7478 $scrollToTop.removeClass('wd-sticky-btn-shown'); 7479 } 7480 }; 7481 7482 stickyAddToCartToggle(); 7483 7484 woodmartThemeModule.$window.on('scroll', stickyAddToCartToggle); 7485 7486 $('.wd-sticky-add-to-cart').on('click', function(e) { 7487 e.preventDefault(); 7488 7489 $('html, body').animate({ 7490 scrollTop: $('.elementor-widget-woocommerce-product-title,.summary-inner .product_title').offset().top 7491 }, 800); 7492 }); 7493 7494 // Wishlist. 7495 $('.wd-sticky-btn .wd-wishlist-btn a').on('click', function(e) { 7496 if (!$(this).hasClass('added')) { 7497 e.preventDefault(); 7498 } 7499 7500 $('.summary-inner > .wd-wishlist-btn a').trigger('click'); 7501 }); 7502 7503 woodmartThemeModule.$document.on('added_to_wishlist', function() { 7504 $('.wd-sticky-btn .wd-wishlist-btn a').addClass('added'); 7505 }); 7506 7507 // Compare. 7508 $('.wd-sticky-btn .wd-compare-btn a').on('click', function(e) { 7509 if (!$(this).hasClass('added')) { 7510 e.preventDefault(); 7511 } 7512 7513 $('.summary-inner > .wd-compare-btn a').trigger('click'); 7514 }); 7515 7516 woodmartThemeModule.$document.on('added_to_compare', function() { 7517 $('.wd-sticky-btn .wd-compare-btn a').addClass('added'); 7518 }); 7519 7520 // Quantity. 7521 $('.wd-sticky-btn-cart .qty').on('change', function() { 7522 $('.summary-inner .qty').val($(this).val()); 7523 }); 7524 7525 $('.summary-inner .qty').on('change', function() { 7526 $('.wd-sticky-btn-cart .qty').val($(this).val()); 7527 }); 7528 }; 7529 7530 $(document).ready(function() { 7531 woodmartThemeModule.stickyAddToCart(); 7532 }); 7533})(jQuery); 7534 7535/* global woodmart_settings */ 7536(function($) { 7537 woodmartThemeModule.$document.on('wdHeaderBuilderInited', function () { 7538 woodmartThemeModule.stickyDetails(); 7539 }); 7540 7541 woodmartThemeModule.stickyDetails = function() { 7542 if (!woodmartThemeModule.$body.hasClass('woodmart-product-sticky-on') || woodmartThemeModule.$window.width() <= 1024) { 7543 return; 7544 } 7545 7546 var details = $('.entry-summary'); 7547 7548 details.each(function() { 7549 var $column = $(this), 7550 offset = parseInt(woodmart_settings.sticky_product_details_offset), 7551 $inner = $column.find('.summary-inner'), 7552 $images = $column.parent().find('.product-images-inner'); 7553 7554 $inner.trigger('sticky_kit:detach'); 7555 $images.trigger('sticky_kit:detach'); 7556 7557 $images.imagesLoaded(function() { 7558 var diff = $inner.outerHeight() - $images.outerHeight(); 7559 7560 if (diff < -100) { 7561 $inner.stick_in_parent({ 7562 offset_top: offset 7563 }); 7564 } else if (diff > 100) { 7565 $images.stick_in_parent({ 7566 offset_top: offset 7567 }); 7568 } 7569 7570 woodmartThemeModule.$window.on('resize', woodmartThemeModule.debounce(function() { 7571 if (woodmartThemeModule.$window.width() <= 1024) { 7572 $inner.trigger('sticky_kit:detach'); 7573 $images.trigger('sticky_kit:detach'); 7574 } else if ($inner.outerHeight() < $images.outerHeight()) { 7575 $inner.stick_in_parent({ 7576 offset_top: offset 7577 }); 7578 } else { 7579 $images.stick_in_parent({ 7580 offset_top: offset 7581 }); 7582 } 7583 }, 300)); 7584 }); 7585 }); 7586 }; 7587 7588 $(document).ready(function() { 7589 woodmartThemeModule.stickyDetails(); 7590 }); 7591})(jQuery); 7592 7593/* global woodmart_settings */ 7594(function($) { 7595 woodmartThemeModule.$document.on('wdShopPageInit', function () { 7596 woodmartThemeModule.stickySidebarBtn(); 7597 }); 7598 7599 woodmartThemeModule.stickySidebarBtn = function() { 7600 var $trigger = $('.wd-show-sidebar-btn'); 7601 var $stickyBtn = $('.wd-sidebar-opener.wd-on-shop:not(.toolbar)'); 7602 7603 if ($stickyBtn.length <= 0 || $trigger.length <= 0 || woodmartThemeModule.$window.width() >= 1024) { 7604 return; 7605 } 7606 7607 var stickySidebarBtnToggle = function() { 7608 var btnOffset = $trigger.offset().top + $trigger.outerHeight(); 7609 var windowScroll = woodmartThemeModule.$window.scrollTop(); 7610 7611 if (btnOffset < windowScroll) { 7612 $stickyBtn.addClass('wd-sticky'); 7613 } else { 7614 $stickyBtn.removeClass('wd-sticky'); 7615 } 7616 }; 7617 7618 stickySidebarBtnToggle(); 7619 7620 woodmartThemeModule.$window.on('scroll', stickySidebarBtnToggle); 7621 woodmartThemeModule.$window.on('resize', stickySidebarBtnToggle); 7622 }; 7623 7624 $(document).ready(function() { 7625 woodmartThemeModule.stickySidebarBtn(); 7626 }); 7627})(jQuery); 7628 7629/* global woodmart_settings */ 7630(function($) { 7631 woodmartThemeModule.$document.on('wdShopPageInit wdArrowsLoadProducts wdLoadMoreLoadProducts wdProductsTabsLoaded', function () { 7632 woodmartThemeModule.swatchesLimit(); 7633 }); 7634 7635 woodmartThemeModule.swatchesLimit = function() { 7636 $('.wd-swatches-divider').on('click', function() { 7637 var $this = $(this).parent(); 7638 7639 $this.find('.wd-swatch').removeClass('wd-hidden'); 7640 $this.addClass('wd-all-shown'); 7641 }); 7642 }; 7643 7644 $(document).ready(function() { 7645 woodmartThemeModule.swatchesLimit(); 7646 }); 7647})(jQuery); 7648 7649/* global woodmart_settings */ 7650(function($) { 7651 $.each([ 7652 'frontend/element_ready/wd_products.default', 7653 'frontend/element_ready/wd_products_tabs.default' 7654 ], function(index, value) { 7655 woodmartThemeModule.wdElementorAddAction(value, function() { 7656 woodmartThemeModule.swatchesOnGrid(); 7657 }); 7658 }); 7659 7660 woodmartThemeModule.swatchesOnGrid = function() { 7661 woodmartThemeModule.$body.on('click', '.swatch-on-grid', function() { 7662 var src, srcset, image_sizes; 7663 7664 var $this = $(this), 7665 imageSrc = $this.data('image-src'), 7666 imageSrcset = $this.data('image-srcset'), 7667 imageSizes = $this.data('image-sizes'); 7668 7669 if (typeof imageSrc == 'undefined' || '' === imageSrc) { 7670 return; 7671 } 7672 7673 var product = $this.parents('.product-grid-item'),
7674 image = product.find('.product-image-link img'), 7675 source = product.find('.product-image-link picture source'), 7676 srcOrig = image.data('original-src'), 7677 srcsetOrig = image.data('original-srcset'), 7678 sizesOrig = image.data('original-sizes'); 7679 7680 if (typeof srcOrig == 'undefined') { 7681 image.data('original-src', image.attr('src')); 7682 } 7683 7684 if (typeof srcsetOrig == 'undefined') { 7685 image.data('original-srcset', image.attr('srcset')); 7686 } 7687 7688 if (typeof sizesOrig == 'undefined') { 7689 image.data('original-sizes', image.attr('sizes')); 7690 } 7691 7692 if ($this.hasClass('active-swatch')) { 7693 src = srcOrig; 7694 srcset = srcsetOrig; 7695 image_sizes = sizesOrig; 7696 $this.removeClass('active-swatch'); 7697 product.removeClass('product-swatched'); 7698 } else { 7699 $this.parent().find('.active-swatch').removeClass('active-swatch'); 7700 $this.addClass('active-swatch'); 7701 product.addClass('product-swatched'); 7702 src = imageSrc; 7703 srcset = imageSrcset; 7704 image_sizes = imageSizes; 7705 } 7706 7707 if (image.attr('src') === src) { 7708 return; 7709 } 7710 7711 product.addClass('wd-loading-image'); 7712 7713 image.attr('src', src).attr('srcset', srcset).attr('image_sizes', image_sizes).one('load', function() { 7714 product.removeClass('wd-loading-image'); 7715 }); 7716 7717 if (source.length > 0) { 7718 source.attr('srcset', srcset).attr('image_sizes', image_sizes); 7719 } 7720 }); 7721 }; 7722 7723 $(document).ready(function() { 7724 woodmartThemeModule.swatchesOnGrid(); 7725 }); 7726})(jQuery); 7727 7728/* global woodmart_settings */ 7729(function($) { 7730 woodmartThemeModule.$document.on('wdQuickShopSuccess wdQuickViewOpen wdUpdateWishlist', function () { 7731 woodmartThemeModule.swatchesVariations(); 7732 }); 7733 7734 woodmartThemeModule.swatchesVariations = function() { 7735 var $variation_forms = $('.variations_form'); 7736 var variationGalleryReplace = false; 7737 var swathesSelected = false; 7738 7739 // Firefox mobile fix 7740 $('.variations_form .label').on('click', function(e) { 7741 if ($(this).siblings('.value').hasClass('with-swatches')) { 7742 e.preventDefault(); 7743 } 7744 }); 7745 7746 $variation_forms.each(function() { 7747 var $variation_form = $(this); 7748 7749 if ($variation_form.data('swatches')) { 7750 return; 7751 } 7752 7753 $variation_form.data('swatches', true); 7754 7755 if (!$variation_form.data('product_variations')) { 7756 $variation_form.find('.swatches-select').find('> div').addClass('swatch-enabled'); 7757 } 7758 7759 if ($('.swatches-select > div').hasClass('active-swatch')) { 7760 $variation_form.addClass('variation-swatch-selected'); 7761 } 7762 7763 $variation_form.on('click', '.swatches-select > div', function() { 7764 var $this = $(this); 7765 var value = $this.data('value'); 7766 var id = $this.parent().data('id'); 7767 var title = $this.data('title'); 7768 7769 resetSwatches($variation_form); 7770 7771 if ($this.hasClass('active-swatch')) { 7772 return; 7773 } 7774 7775 if ($this.hasClass('swatch-disabled')) { 7776 return; 7777 } 7778 7779 $variation_form.find('select#' + id).val(value).trigger('change'); 7780 $this.parent().find('.active-swatch').removeClass('active-swatch'); 7781 $this.addClass('active-swatch'); 7782 resetSwatches($variation_form); 7783 7784 if ((woodmart_settings.swatches_labels_name === 'yes' && woodmartThemeModule.$window.width() >= 769) || woodmartThemeModule.$window.width() <= 768) { 7785 $this.parents('tr').find('.wd-attr-selected').html(title); 7786 } 7787 }) 7788 .on('woocommerce_update_variation_values', function() { 7789 resetSwatches($variation_form); 7790 }) 7791 .on('click', '.reset_variations', function() { 7792 $variation_form.find('.active-swatch').removeClass('active-swatch'); 7793 7794 if ((woodmart_settings.swatches_labels_name === 'yes' && woodmartThemeModule.$window.width() >= 769) || woodmartThemeModule.$window.width() <= 768) { 7795 $variation_form.find('.wd-attr-selected').html(''); 7796 } 7797 }) 7798 .on('reset_data', function() { 7799 var $this = $(this); 7800 var all_attributes_chosen = true; 7801 var some_attributes_chosen = false; 7802 7803 $variation_form.find('.variations select').each(function() { 7804 var value = $this.val() || ''; 7805 7806 if (value.length === 0) { 7807 all_attributes_chosen = false;
7808 } else { 7809 some_attributes_chosen = true; 7810 } 7811 7812 }); 7813 7814 if (all_attributes_chosen) { 7815 $this.parent().find('.active-swatch').removeClass('active-swatch'); 7816 } 7817 7818 $variation_form.removeClass('variation-swatch-selected'); 7819 7820 var $mainOwl = $('.woocommerce-product-gallery__wrapper.owl-carousel'); 7821 7822 resetSwatches($variation_form); 7823 7824 replaceMainGallery('default', $variation_form); 7825 7826 if (!$mainOwl.hasClass('owl-carousel')) { 7827 return; 7828 } 7829 7830 if (woodmart_settings.product_slider_auto_height === 'yes') { 7831 if (!isQuickView() && isVariationGallery('default', $variation_form) && variationGalleryReplace) { 7832 $mainOwl.trigger('destroy.owl.carousel'); 7833 } 7834 7835 $('.product-images').imagesLoaded(function() { 7836 $mainOwl = $mainOwl.owlCarousel(woodmartThemeModule.mainCarouselArg); 7837 $mainOwl.trigger('refresh.owl.carousel'); 7838 }); 7839 } else { 7840 $mainOwl = $mainOwl.owlCarousel(woodmartThemeModule.mainCarouselArg); 7841 $mainOwl.trigger('refresh.owl.carousel'); 7842 } 7843 7844 var slide_go_to = woodmart_settings.product_gallery.thumbs_slider.position === 'centered' ? woodmart_settings.centered_gallery_start : 0; 7845 7846 if (isQuickView()) { 7847 slide_go_to = 0; 7848 } 7849 7850 $mainOwl.trigger('to.owl.carousel', slide_go_to); 7851 }) 7852 .on('reset_image', function() { 7853 var $thumb = $('.thumbnails .product-image-thumbnail img').first(); 7854 7855 if (!isQuickView() && !isQuickShop($variation_form)) { 7856 $thumb.wc_reset_variation_attr('src'); 7857 } 7858 }) 7859 .on('show_variation', function(e, variation) { 7860 if (((woodmart_settings.swatches_labels_name === 'yes' && woodmartThemeModule.$window.width() >= 769) || woodmartThemeModule.$window.width() <= 768) && !swathesSelected) { 7861 $variation_form.find('.active-swatch').each(function() { 7862 var $this = $(this); 7863 var title = $this.data('title'); 7864 $this.parents('tr').find('.wd-attr-selected').html(title); 7865 }); 7866 7867 swathesSelected = true; 7868 } 7869 7870 if (!variation.image.src) { 7871 return; 7872 } 7873 7874 var galleryHasImage = $variation_form.parents('.single-product-content').find('.thumbnails .product-image-thumbnail img[data-o_src="' + variation.image.thumb_src + '"]').length > 0; 7875 var $firstThumb = $variation_form.parents('.single-product-content').find('.thumbnails .product-image-thumbnail img').first(); 7876 var originalImageUrl = $variation_form.parents('.single-product-content').find('.woocommerce-product-gallery .woocommerce-product-gallery__image > a').first().data('o_href'); 7877 7878 if (galleryHasImage) { 7879 $firstThumb.wc_reset_variation_attr('src'); 7880 } 7881 7882 if (!isQuickShop($variation_form) && !replaceMainGallery(variation.variation_id, $variation_form)) { 7883 if ($firstThumb.attr('src') !== variation.image.thumb_src) { 7884 $firstThumb.wc_set_variation_attr('src', variation.image.src); 7885 } 7886 7887 woodmartThemeModule.$document.trigger('wdShowVariationNotQuickView'); 7888 } 7889 7890 $variation_form.addClass('variation-swatch-selected'); 7891 7892 if (!isQuickShop($variation_form) && !isQuickView() && originalImageUrl !== variation.image.full_src) { 7893 scrollToTop(); 7894 } 7895 7896 var $mainOwl = $('.woocommerce-product-gallery__wrapper.owl-carousel'); 7897 7898 if (!$mainOwl.hasClass('owl-carousel')) { 7899 return; 7900 } 7901 7902 if (woodmart_settings.product_slider_auto_height === 'yes') { 7903 if (!isQuickView() && isVariationGallery(variation.variation_id, $variation_form) && variationGalleryReplace) { 7904 $mainOwl.trigger('destroy.owl.carousel'); 7905 } 7906 7907 $('.product-images').imagesLoaded(function() { 7908 $mainOwl = $mainOwl.owlCarousel(woodmartThemeModule.mainCarouselArg); 7909 $mainOwl.trigger('refresh.owl.carousel'); 7910 }); 7911 } else { 7912 $mainOwl = $mainOwl.owlCarousel(woodmartThemeModule.mainCarouselArg); 7913 $mainOwl.trigger('refresh.owl.carousel'); 7914 } 7915 7916 var $thumbs = $('.images .thumbnails'); 7917 7918 $mainOwl.trigger('to.owl.carousel', 0); 7919 7920 if ($thumbs.hasClass('owl-carousel')) { 7921 $thumbs.owlCarousel().trigger('to.owl.carousel', 0); 7922 $thumbs.find('.active-thumb').removeClass('active-thumb'); 7923 $thumbs.find('.product-image-thumbnail').eq(0).addClass('active-thumb'); 7924 } else if ($thumbs.hasClass('slick-slider')) { 7925 $thumbs.slick('slickGoTo', 0); 7926 if (!$thumbs.find('.product-image-thumbnail').eq(0).hasClass('active-thumb')) { 7927 $thumbs.find('.active-thumb').removeClass('active-thumb'); 7928 $thumbs.find('.product-image-thumbnail').eq(0).addClass('active-thumb'); 7929 } 7930 } 7931 }); 7932 }); 7933 7934 var resetSwatches = function($variation_form) { 7935 // If using AJAX 7936 if (!$variation_form.data('product_variations')) { 7937 return; 7938 } 7939 7940 $variation_form.find('.variations select').each(function() { 7941 var select = $(this); 7942 var swatch = select.parent().find('.swatches-select'); 7943 var options = select.html(); 7944 options = $(options); 7945 7946 swatch.find('> div').removeClass('swatch-enabled').addClass('swatch-disabled'); 7947 7948 options.each(function() { 7949 var value = $(this).val(); 7950 7951 if ($(this).hasClass('enabled')) { 7952 swatch.find('div[data-value="' + value + '"]').removeClass('swatch-disabled').addClass('swatch-enabled'); 7953 } else { 7954 swatch.find('div[data-value="' + value + '"]').addClass('swatch-disabled').removeClass('swatch-enabled'); 7955 } 7956 }); 7957 }); 7958 }; 7959 7960 var isQuickView = function() { 7961 return $('.single-product-content').hasClass('product-quick-view'); 7962 }; 7963 7964 var isQuickShop = function($form) { 7965 return $form.parent().hasClass('quick-shop-form'); 7966 }; 7967 7968 var isVariationGallery = function(key, $variationForm) { 7969 if ('old' === woodmart_settings.variation_gallery_storage_method) { 7970 return isVariationGalleryOld(key); 7971 } else { 7972 return isVariationGalleryNew(key, $variationForm); 7973 } 7974 }; 7975 7976 var isVariationGalleryOld = function(key) { 7977 if (typeof woodmart_variation_gallery_data === 'undefined' && typeof woodmart_qv_variation_gallery_data === 'undefined') { 7978 return; 7979 } 7980 7981 var variation_gallery_data = isQuickView() ? woodmart_qv_variation_gallery_data : woodmart_variation_gallery_data; 7982 7983 return typeof variation_gallery_data !== 'undefined' && variation_gallery_data && variation_gallery_data[key]; 7984 }; 7985 7986 var isVariationGalleryNew = function(key, $variationForm) { 7987 var data = getAdditionalVariationsImagesData($variationForm); 7988 7989 return typeof data !== 'undefined' && data && data[key] && data[key].length > 1; 7990 }; 7991 7992 var scrollToTop = function() { 7993 if ((woodmart_settings.swatches_scroll_top_desktop === 'yes' && woodmartThemeModule.$window.width() >= 1024) || (woodmart_settings.swatches_scroll_top_mobile === 'yes' && woodmartThemeModule.$window.width() <= 1024)) { 7994 var $page = $('html, body'); 7995 7996 $page.stop(true); 7997 7998 woodmartThemeModule.$window.on('mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { 7999 $page.stop(true); 8000 }); 8001 8002 $page.animate({ 8003 scrollTop: $('.product-image-summary').offset().top - 150 8004 }, 800); 8005 8006 $('.wd-swatch').tooltip('hide'); 8007 } 8008 }; 8009 8010 var getAdditionalVariationsImagesData = function($variationForm) { 8011 var rawData = $variationForm.data('product_variations'); 8012 var data = []; 8013 8014 if (!rawData) { 8015 return data; 8016 } 8017 8018 rawData.forEach(function(value) { 8019 data[value.variation_id] = value.additional_variation_images; 8020 data['default'] = value.additional_variation_images_default; 8021 }); 8022 8023 return data; 8024 }; 8025 8026 var replaceMainGallery = function(key, $variationForm) { 8027 if ('old' === woodmart_settings.variation_gallery_storage_method) { 8028 if (!isVariationGallery(key, $variationForm) || isQuickShop($variationForm) || ('default' === key && !variationGalleryReplace)) { 8029 return false;
8030 } 8031 8032 replaceMainGalleryOld(key, $variationForm); 8033 } else { 8034 if (!isVariationGallery(key, $variationForm) || isQuickShop($variationForm) || ('default' === key && !variationGalleryReplace)) { 8035 return false; 8036 } 8037 8038 var data = getAdditionalVariationsImagesData($variationForm); 8039 replaceMainGalleryNew(data[key], $variationForm); 8040 } 8041 8042 $('.woocommerce-product-gallery__image').trigger('zoom.destroy'); 8043 woodmartThemeModule.$document.trigger('wdReplaceMainGallery'); 8044 if (!isQuickView()) { 8045 woodmartThemeModule.$document.trigger('wdReplaceMainGalleryNotQuickView'); 8046 } 8047 8048 variationGalleryReplace = 'default' !== key; 8049 8050 woodmartThemeModule.$window.trigger('resize'); 8051 8052 return true; 8053 }; 8054 8055 var replaceMainGalleryOld = function(key, $variationForm) { 8056 var variation_gallery_data = isQuickView() ? woodmart_qv_variation_gallery_data : woodmart_variation_gallery_data; 8057 8058 var imagesData = variation_gallery_data[key]; 8059 var $mainGallery = $variationForm.parents('.single-product-content').find('.woocommerce-product-gallery__wrapper'); 8060 8061 $mainGallery.empty(); 8062 8063 for (var index = 0; index < imagesData.length; index++) { 8064 var $html = '<div class="product-image-wrap"><figure data-thumb="' + imagesData[index].data_thumb + '" class="woocommerce-product-gallery__image">'; 8065 8066 if (!isQuickView()) { 8067 $html += '<a href="' + imagesData[index].href + '">'; 8068 } 8069 8070 $html += imagesData[index].image; 8071 8072 if (!isQuickView()) { 8073 $html += '</a>'; 8074 } 8075 8076 $html += '</figure></div>'; 8077 8078 $mainGallery.append($html); 8079 } 8080 }; 8081 8082 var replaceMainGalleryNew = function(imagesData, $variationForm) { 8083 var $mainGallery = $variationForm.parents('.single-product-content').find('.woocommerce-product-gallery__wrapper'); 8084 $mainGallery.empty(); 8085 8086 for (var key in imagesData) { 8087 if (imagesData.hasOwnProperty(key)) { 8088 var $html = '<div class="product-image-wrap"><figure class="woocommerce-product-gallery__image" data-thumb="' + imagesData[key].thumbnail_src + '">'; 8089 8090 if (!isQuickView()) { 8091 $html += '<a href="' + imagesData[key].full_src + '" data-elementor-open-lightbox="no">'; 8092 } 8093 8094 var srcset = imagesData[key].srcset ? 'srcset="' + imagesData[key].srcset + '"' : ''; 8095 8096 $html += '<img width="' + imagesData[key].width + '" height="' + imagesData[key].height + '" src="' + imagesData[key].src + '" class="' + imagesData[key].class + '" alt="' + imagesData[key].alt + '" title="' + imagesData[key].title + '" data-caption="' + imagesData[key].data_caption + '" data-src="' + imagesData[key].data_src + '" data-large_image="' + imagesData[key].data_large_image + '" data-large_image_width="' + imagesData[key].data_large_image_width + '" data-large_image_height="' + imagesData[key].data_large_image_height + '" ' + srcset + ' sizes="' + imagesData[key].sizes + '" />'; 8097 8098 if (!isQuickView()) { 8099 $html += '</a>'; 8100 } 8101 8102 $html += '</figure></div>'; 8103 8104 $mainGallery.append($html); 8105 } 8106 } 8107 }; 8108 }; 8109 8110 $(document).ready(function() { 8111 woodmartThemeModule.swatchesVariations(); 8112 }); 8113})(jQuery); 8114 8115/* global woodmart_settings */ 8116(function($) { 8117 woodmartThemeModule.variationsPrice = function() { 8118 if ('no' === woodmart_settings.single_product_variations_price) { 8119 return; 8120 } 8121 8122 $('.variations_form').each(function() { 8123 var $form = $(this); 8124 var $price = $form.parent().find('> .price').first(); 8125 var priceOriginalHtml = $price.html(); 8126 8127 $form.on('show_variation', function(e, variation) { 8128 if (variation.price_html.length > 1) { 8129 $price.html(variation.price_html); 8130 } 8131 }); 8132 8133 $form.on('hide_variation', function() { 8134 $price.html(priceOriginalHtml); 8135 }); 8136 }); 8137 }; 8138 8139 $(document).ready(function() { 8140 woodmartThemeModule.variationsPrice(); 8141 }); 8142})(jQuery); 8143 8144/* global woodmart_settings */ 8145(function($) { 8146 woodmartThemeModule.wishlist = function() { 8147 var cookiesName = 'woodmart_wishlist_count'; 8148 8149 if (woodmartThemeModule.$body.hasClass('logged-in')) { 8150 cookiesName += '_logged'; 8151 } 8152 8153 if (woodmart_settings.is_multisite) { 8154 cookiesName += '_' + woodmart_settings.current_blog_id; 8155 } 8156 8157 var $widget = $('.wd-header-wishlist'); 8158 var cookie = Cookies.get(cookiesName); 8159 8160 if ($widget.length > 0 && 'undefined' !== typeof cookie) { 8161 try { 8162 var count = JSON.parse(cookie); 8163 $widget.find('.wd-tools-count').text(count); 8164 } 8165 catch (e) { 8166 console.log('cant parse cookies json'); 8167 } 8168 } 8169 8170 // Add to wishlist action 8171 woodmartThemeModule.$body.on('click', '.wd-wishlist-btn a', function(e) { 8172 var $this = $(this); 8173 8174 if (!$this.hasClass('added')) { 8175 e.preventDefault(); 8176 } 8177 8178 var productId = $this.data('product-id'); 8179 var addedText = $this.data('added-text'); 8180 var key = $this.data('key'); 8181 8182 if ($this.hasClass('added')) { 8183 return true; 8184 } 8185 8186 $this.addClass('loading'); 8187 8188 $.ajax({
8189 url : woodmart_settings.ajaxurl, 8190 data : { 8191 action : 'woodmart_add_to_wishlist', 8192 product_id: productId, 8193 key : key 8194 }, 8195 dataType: 'json', 8196 method : 'GET', 8197 success : function(response) { 8198 if (response) { 8199 $this.addClass('added'); 8200 woodmartThemeModule.$document.trigger('added_to_wishlist'); 8201 8202 if (response.wishlist_content) { 8203 updateWishlist(response); 8204 } 8205 8206 if ($this.find('span').length > 0) { 8207 $this.find('span').text(addedText); 8208 } else { 8209 $this.text(addedText); 8210 } 8211 } else { 8212 console.log('something wrong loading wishlist data ', response); 8213 } 8214 }, 8215 error : function() { 8216 console.log( 8217 'We cant add to wishlist. Something wrong with AJAX response. Probably some PHP conflict.'); 8218 }, 8219 complete: function() { 8220 $this.removeClass('loading'); 8221 } 8222 }); 8223 }); 8224 8225 woodmartThemeModule.$body.on('click', '.wd-wishlist-remove', function(e) { 8226 e.preventDefault(); 8227 var $this = $(this); 8228 var productId = $this.data('product-id'); 8229 var key = $this.data('key'); 8230 8231 if ($this.hasClass('added')) { 8232 return true; 8233 } 8234 8235 $this.addClass('loading'); 8236 8237 $.ajax({ 8238 url : woodmart_settings.ajaxurl, 8239 data : { 8240 action : 'woodmart_remove_from_wishlist', 8241 product_id: productId, 8242 key : key 8243 }, 8244 dataType: 'json', 8245 method : 'GET', 8246 success : function(response) { 8247 if (response.wishlist_content) { 8248 updateWishlist(response); 8249 } else { 8250 console.log('something wrong loading wishlist data ', response); 8251 } 8252 }, 8253 error : function() { 8254 console.log('We cant remove from wishlist. Something wrong with AJAX response. Probably some PHP conflict.'); 8255 }, 8256 complete: function() { 8257 $this.removeClass('loading'); 8258 } 8259 }); 8260 }); 8261 8262 // Elements update after ajax 8263 function updateWishlist(data) { 8264 var $wishlistContent = $('.wd-wishlist-content'); 8265 var $widget = $('.wd-header-wishlist'); 8266 8267 if ($widget.length > 0) { 8268 $widget.find('.wd-tools-count').text(data.count); 8269 } 8270 8271 if ($wishlistContent.length > 0 && !$wishlistContent.hasClass('wd-wishlist-preview')) { 8272 woodmartThemeModule.removeDuplicatedStylesFromHTML(data.wishlist_content, function(html) { 8273 $wishlistContent.replaceWith(html); 8274 }); 8275 } 8276 8277 woodmartThemeModule.$document.trigger('wdUpdateWishlist'); 8278 } 8279 }; 8280 8281 $(document).ready(function() { 8282 woodmartThemeModule.wishlist(); 8283 }); 8284})(jQuery); 8285 8286/* global woodmart_settings */ 8287(function($) { 8288 woodmartThemeModule.woocommerceComments = function() { 8289 var hash = window.location.hash; 8290 var url = window.location.href; 8291 8292 if (hash.toLowerCase().indexOf('comment-') >= 0 || hash === '#reviews' || hash === '#tab-reviews' || url.indexOf('comment-page-') > 0 || url.indexOf('cpage=') > 0) { 8293 setTimeout(function() { 8294 window.scrollTo(0, 0); 8295 }, 1); 8296 8297 setTimeout(function() { 8298 if ($(hash).length > 0) { 8299 $('html, body').stop().animate({ 8300 scrollTop: $(hash).offset().top - 100 8301 }, 400); 8302 } 8303 }, 10); 8304 } 8305 }; 8306 8307 $(document).ready(function() { 8308 woodmartThemeModule.woocommerceComments(); 8309 }); 8310})(jQuery); 8311 8312/* global woodmart_settings */ 8313(function($) { 8314 woodmartThemeModule.woocommerceNotices = function() { 8315 var notices = '.woocommerce-error, .woocommerce-info, .woocommerce-message, div.wpcf7-response-output, #yith-wcwl-popup-message, .mc4wp-alert, .dokan-store-contact .alert-success, .yith_ywraq_add_item_product_message';
8316 8317 woodmartThemeModule.$body.on('click', notices, function() { 8318 hideMessage($(this)); 8319 }); 8320 8321 var hideMessage = function($msg) { 8322 $msg.removeClass('shown-notice').addClass('hidden-notice'); 8323 }; 8324 }; 8325 8326 $(document).ready(function() { 8327 woodmartThemeModule.woocommerceNotices(); 8328 }); 8329})(jQuery); 8330 8331/* global woodmart_settings */ 8332(function($) { 8333 woodmartThemeModule.$document.on('wdBackHistory wdShopPageInit', function () { 8334 woodmartThemeModule.woocommercePriceSlider(); 8335 }); 8336 8337 woodmartThemeModule.woocommercePriceSlider = function() { 8338 var $min_price = $('.price_slider_amount #min_price'); 8339 var $max_price = $('.price_slider_amount #max_price'); 8340 var $products = $('.products'); 8341 8342 if (typeof woocommerce_price_slider_params === 'undefined' || $min_price.length < 1 || !$.fn.slider) { 8343 return false; 8344 } 8345 8346 var $slider = $('.price_slider'); 8347 8348 if ($slider.slider('instance') !== undefined) { 8349 return; 8350 } 8351 8352 // Get markup ready for slider 8353 $('input#min_price, input#max_price').hide(); 8354 $('.price_slider, .price_label').show(); 8355 8356 // Price slider uses $ ui 8357 var min_price = $min_price.data('min'), 8358 max_price = $max_price.data('max'), 8359 current_min_price = parseInt(min_price, 10), 8360 current_max_price = parseInt(max_price, 10); 8361 8362 if ($products.attr('data-min_price') && $products.attr('data-min_price').length > 0) { 8363 current_min_price = parseInt($products.attr('data-min_price'), 10); 8364 } 8365 8366 if ($products.attr('data-max_price') && $products.attr('data-max_price').length > 0) { 8367 current_max_price = parseInt($products.attr('data-max_price'), 10); 8368 } 8369 8370 $slider.slider({ 8371 range : true, 8372 animate: true, 8373 min : min_price, 8374 max : max_price, 8375 values : [ 8376 current_min_price, 8377 current_max_price 8378 ], 8379 create : function() { 8380 $min_price.val(current_min_price); 8381 $max_price.val(current_max_price); 8382 8383 woodmartThemeModule.$body.trigger('price_slider_create', [ 8384 current_min_price, 8385 current_max_price 8386 ]); 8387 }, 8388 slide : function(event, ui) { 8389 $('input#min_price').val(ui.values[0]); 8390 $('input#max_price').val(ui.values[1]); 8391 8392 woodmartThemeModule.$body.trigger('price_slider_slide', [ 8393 ui.values[0], 8394 ui.values[1] 8395 ]); 8396 }, 8397 change : function(event, ui) { 8398 woodmartThemeModule.$body.trigger('price_slider_change', [ 8399 ui.values[0], 8400 ui.values[1] 8401 ]); 8402 } 8403 }); 8404 8405 setTimeout(function() { 8406 woodmartThemeModule.$body.trigger('price_slider_create', [ 8407 current_min_price, 8408 current_max_price 8409 ]); 8410 8411 if ($slider.find('.ui-slider-range').length > 1) { 8412 $slider.find('.ui-slider-range').first().remove(); 8413 } 8414 }, 10); 8415 }; 8416 8417 $(document).ready(function() { 8418 woodmartThemeModule.woocommercePriceSlider(); 8419 }); 8420})(jQuery); 8421 8422/* global woodmart_settings */ 8423(function($) { 8424 woodmartThemeModule.woocommerceQuantity = function() { 8425 if (!String.prototype.getDecimals) { 8426 String.prototype.getDecimals = function() { 8427 var num = this, 8428 match = ('' + num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/); 8429 8430 if (!match) { 8431 return 0; 8432 } 8433 8434 return Math.max(0, (match[1] ? match[1].length : 0) - (match[2] ? +match[2] : 0)); 8435 }; 8436 } 8437 8438 woodmartThemeModule.$document.on('click', '.plus, .minus', function() { 8439 var $this = $(this), 8440 $qty = $this.closest('.quantity').find('.qty'), 8441 currentVal = parseFloat($qty.val()), 8442 max = parseFloat($qty.attr('max')), 8443 min = parseFloat($qty.attr('min')), 8444 step = $qty.attr('step'); 8445 8446 if (!currentVal || currentVal === '' || currentVal === 'NaN') { 8447 currentVal = 0; 8448 } 8449 if (max === '' || max === 'NaN') { 8450 max = ''; 8451 } 8452 if (min === '' || min === 'NaN') { 8453 min = 0; 8454 } 8455 if (step === 'any' || step === '' || step === undefined || parseFloat(step) == 'NaN') { 8456 step = '1'; 8457 } 8458 8459 if ($this.is('.plus')) { 8460 if (max && (currentVal >= max)) { 8461 $qty.val(max); 8462 } else { 8463 $qty.val((currentVal + parseFloat(step)).toFixed(step.getDecimals())); 8464 } 8465 } else { 8466 if (min && (currentVal <= min)) { 8467 $qty.val(min); 8468 } else if (currentVal > 0) { 8469 $qty.val((currentVal - parseFloat(step)).toFixed(step.getDecimals())); 8470 } 8471 } 8472 8473 $qty.trigger('change'); 8474 }); 8475 }; 8476 8477 $(document).ready(function() { 8478 woodmartThemeModule.woocommerceQuantity(); 8479 }); 8480})(jQuery); 8481 8482/* global woodmart_settings */ 8483(function($) { 8484 woodmartThemeModule.woocommerceWrappTable = function() { 8485 $('.shop_table:not(.shop_table_responsive):not(.woocommerce-checkout-review-order-table)').wrap('<div class=\'responsive-table\'></div>'); 8486 }; 8487 8488 $(document).ready(function() { 8489 woodmartThemeModule.woocommerceWrappTable(); 8490 }); 8491})(jQuery); 8492 8493/* global woodmart_settings */ 8494(function($) { 8495 woodmartThemeModule.woodmartCompare = function() { 8496 var cookiesName = 'woodmart_compare_list'; 8497 8498 if (woodmart_settings.is_multisite) { 8499 cookiesName += '_' + woodmart_settings.current_blog_id; 8500 } 8501
8502 var $body = woodmartThemeModule.$body, 8503 $widget = $('.wd-header-compare'), 8504 compareCookie = Cookies.get(cookiesName); 8505 8506 if ($widget.length > 0 && 'undefined' !== typeof compareCookie) { 8507 try { 8508 var ids = JSON.parse(compareCookie); 8509 $widget.find('.wd-tools-count').text(ids.length); 8510 } 8511 catch (e) { 8512 console.log('cant parse cookies json'); 8513 } 8514 } 8515 8516 $body.on('click', '.wd-compare-btn a', function(e) { 8517 var $this = $(this), 8518 id = $this.data('id'), 8519 addedText = $this.data('added-text'); 8520 8521 if ($this.hasClass('added')) { 8522 return true; 8523 } 8524 8525 e.preventDefault(); 8526 8527 $this.addClass('loading'); 8528 8529 jQuery.ajax({ 8530 url : woodmart_settings.ajaxurl, 8531 data : { 8532 action: 'woodmart_add_to_compare', 8533 id : id 8534 }, 8535 dataType: 'json', 8536 method : 'GET', 8537 success : function(response) { 8538 if (response.table) { 8539 updateCompare(response); 8540 woodmartThemeModule.$document.trigger('added_to_compare'); 8541 } else { 8542 console.log('something wrong loading compare data ', response); 8543 } 8544 }, 8545 error : function() { 8546 console.log('We cant add to compare. Something wrong with AJAX response. Probably some PHP conflict.'); 8547 }, 8548 complete: function() { 8549 $this.removeClass('loading').addClass('added'); 8550 8551 if ($this.find('span').length > 0) { 8552 $this.find('span').text(addedText); 8553 } else { 8554 $this.text(addedText); 8555 } 8556 } 8557 }); 8558 }); 8559 8560 $body.on('click', '.wd-compare-remove', function(e) { 8561 e.preventDefault(); 8562 var $this = $(this), 8563 id = $this.data('id'); 8564 8565 $this.addClass('loading'); 8566 8567 jQuery.ajax({ 8568 url : woodmart_settings.ajaxurl, 8569 data : { 8570 action: 'woodmart_remove_from_compare', 8571 id : id 8572 }, 8573 dataType: 'json', 8574 method : 'GET', 8575 success : function(response) { 8576 if (response.table) { 8577 updateCompare(response); 8578 } else { 8579 console.log('something wrong loading compare data ', response); 8580 } 8581 }, 8582 error : function() { 8583 console.log('We cant remove product compare. Something wrong with AJAX response. Probably some PHP conflict.'); 8584 }, 8585 complete: function() { 8586 $this.addClass('loading'); 8587 } 8588 }); 8589 }); 8590 8591 function updateCompare(data) { 8592 var $widget = $('.wd-header-compare'); 8593 8594 if ($widget.length > 0) { 8595 $widget.find('.wd-tools-count').text(data.count); 8596 } 8597 8598 var $wcCompareTable = $('.wd-compare-table'); 8599 if ($wcCompareTable.length > 0) { 8600 $wcCompareTable.replaceWith(data.table); 8601 } 8602 } 8603 }; 8604 8605 $(document).ready(function() { 8606 woodmartThemeModule.woodmartCompare(); 8607 }); 8608})(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.