1var baselThemeModule; 2/* global basel_settings */ 3(function($) { 4 'use strict'; 5 6 baselThemeModule = (function() { 7 var baselTheme = { 8 popupEffect : 'mfp-move-horizontal', 9 shopLoadMoreBtn : '.basel-products-load-more.load-on-scroll', 10 supports_html5_storage: false, 11 ajaxLinks : '.basel-product-categories a, .widget_product_categories a, .widget_layered_nav_filters a, .filters-area a, body.post-type-archive-product:not(.woocommerce-account) .woocommerce-pagination a, body.tax-product_cat:not(.woocommerce-account) .woocommerce-pagination a, .basel-woocommerce-layered-nav a, .widget_product_tag_cloud a, .basel-products-shop-view a, .basel-price-filter a, .woocommerce-widget-layered-nav a, .basel-clear-filters-wrapp a, .basel-woocommerce-sort-by a, .woocommerce-widget-layered-nav-list a, .basel-widget-stock-status a', 12 mainCarouselArg : { 13 rtl : $('body').hasClass('rtl'), 14 items : 1, 15 autoplay : basel_settings.product_slider_autoplay, 16 autoplayTimeout: 3000, 17 loop : basel_settings.product_slider_autoplay, 18 dots : false, 19 nav : false, 20 autoHeight : basel_settings.product_slider_auto_height === 'yes', 21 navText : false, 22 onRefreshed : function() { 23 $(window).trigger('resize'); 24 } 25 } 26 }; 27 28 try { 29 baselTheme.supports_html5_storage = ('sessionStorage' in window && window.sessionStorage !== null); 30 31 window.sessionStorage.setItem('basel', 'test'); 32 window.sessionStorage.removeItem('basel'); 33 } 34 catch (err) { 35 baselTheme.supports_html5_storage = false; 36 } 37 38 return { 39 init: function() { 40 this.$window = $(window); 41 42 this.$document = $(document); 43 44 this.$body = $('body'); 45 46 this.windowWidth = this.$window.width(); 47 48 this.productFilters(); 49 this.woocommercePriceSlider(); 50 this.updateCartWidgetFromLocalStorage(); 51 this.categoriesAccordion(); 52 this.categoriesMenuBtns(); 53 this.filterDropdowns(); 54 this.headerBanner(); 55 this.verticalHeader(); 56 this.splitNavHeader(); 57 this.visibleElements(); 58 this.bannersHover(); 59 this.parallax(); 60 this.googleMap(); 61 this.scrollTop(); 62 this.quickViewInit(); 63 this.quickShop(); 64 this.sidebarMenu(); 65 this.addToCart(); 66 this.productImages(); 67 this.productImagesGallery(); 68 this.stickyDetails(); 69 this.mfpPopup(); 70 this.swatchesVariations(); 71 this.swatchesOnGrid(); 72 this.blogMasonry(); 73 this.blogLoadMore(); 74 this.productsTabs(); 75 this.portfolioLoadMore(); 76 this.equalizeColumns(); 77 this.menuSetUp(); 78 this.onePageMenu(); 79 this.mobileNavigation(); 80 this.simpleDropdown(); 81 this.woocommerceWrappTable(); 82 this.wishList(); 83 this.compare(); 84 this.baselCompare(); 85 this.promoPopup(); 86 this.cookiesPopup(); 87 this.productVideo(); 88 this.product360Button(); 89 this.stickyFooter(); 90 this.updateWishListNumberInit(); 91 this.cartWidget(); 92 this.ajaxFilters(); 93 this.filtersArea(); 94 this.categoriesMenu(); 95 this.searchFullScreen(); 96 this.loginTabs(); 97 this.productAccordion(); 98 this.countDownTimer(); 99 this.mobileFastclick(); 100 this.woocommerceComments(); 101 this.woocommerceQuantity(); 102 this.initZoom(); 103 this.videoPoster(); 104 this.addToCartAllTypes(); 105 this.contentPopup(); 106 this.mobileSearchIcon(); 107 this.shopHiddenSidebar(); 108 this.loginSidebar(); 109 this.stickyAddToCart(); 110 this.stickySidebarBtn(); 111 this.lazyLoading(); 112 this.owlCarouselInit(); 113 this.baselSliderLazyLoad(); 114 this.portfolioPhotoSwipe(); 115 this.sortByWidget(); 116 this.footerWidgetsAccordion(); 117 this.wishlist(); 118 this.variationsPrice();
119 this.googleMapInit(); 120 this.commentImage(); 121 this.commentImagesUploadValidation(); 122 this.moreCategoriesButton(); 123 this.swatchesLimit(); 124 this.categoriesDropdowns(); 125 this.miniCartQuantity(); 126 this.shopMasonry(); 127 this.frequentlyBoughtTogether(); 128 this.dynamicDiscountsTable(); 129 this.freeGiftsTable(); 130 131 // baselThemeModule.$window.trigger('resize'); 132 133 baselThemeModule.$body.addClass('document-ready'); 134 135 baselThemeModule.$body.on('updated_cart_totals', function() { 136 baselThemeModule.woocommerceWrappTable(); 137 }); 138 139 $( document.body ).on('updated_cart_totals updated_checkout', function(e) { 140 baselThemeModule.btnsToolTips(); 141 }); 142 }, 143 144 googleMapsCallback : function () { 145 return ''; 146 }, 147 148 removeDuplicatedStylesFromHTML: function(html, callback) { 149 var $data = $('<div class="temp-wrapper"></div>').append(html); 150 var $links = $data.find('link'); 151 var counter = 0; 152 var timeout = false; 153 154 if (0 === $links.length || 'yes' === basel_settings.combined_css) { 155 callback(html); 156 return; 157 } 158 159 setTimeout(function() { 160 if (counter <= $links.length && !timeout) { 161 callback($($data.html())); 162 timeout = true; 163 } 164 }, 500); 165 166 $links.each(function() { 167 var $link = $(this); 168 var id = $link.attr('id'); 169 var href = $link.attr('href'); 170 171 $link.remove(); 172 173 if ('undefined' === typeof basel_page_css[id]) { 174 $('head').append($link.on('load', function() { 175 counter++; 176 177 basel_page_css[id] = href; 178 179 if (counter >= $links.length && !timeout) { 180 callback($($data.html())); 181 timeout = true; 182 } 183 })); 184 } else { 185 counter++; 186 187 if (counter >= $links.length && !timeout) { 188 callback($($data.html())); 189 timeout = true; 190 } 191 } 192 }); 193 }, 194 195 miniCartQuantity: function() { 196 var timeout; 197 198 baselThemeModule.$document.on('change input', '.woocommerce-mini-cart .quantity .qty', function() { 199 var input = $(this); 200 var qtyVal = input.val(); 201 var itemID = input.parents('.woocommerce-mini-cart-item').data('key'); 202 var cart_hash_key = basel_settings.cart_hash_key; 203 var fragment_name = basel_settings.fragment_name; 204 205 clearTimeout(timeout); 206 207 timeout = setTimeout(function() { 208 input.parents('.mini_cart_item').addClass('basel-loading'); 209 210 $.ajax({ 211 url : basel_settings.ajaxurl, 212 data : { 213 action : 'basel_update_cart_item', 214 item_id: itemID, 215 qty : qtyVal 216 }, 217 success : function(data) { 218 if (data && data.fragments) { 219 220 $.each(data.fragments, function(key, value) { 221 $(key).replaceWith(value); 222 }); 223 224 if (baselTheme.supports_html5_storage) { 225 sessionStorage.setItem(fragment_name, JSON.stringify(data.fragments)); 226 localStorage.setItem(cart_hash_key, data.cart_hash); 227 sessionStorage.setItem(cart_hash_key, data.cart_hash); 228 229 if (data.cart_hash) { 230 sessionStorage.setItem('wc_cart_created', (new Date()).getTime()); 231 } 232 } 233 234 baselThemeModule.$body.trigger( 'wc_fragments_refreshed' ); 235 } 236 }, 237 dataType: 'json', 238 method : 'GET' 239 }); 240 }, 500); 241 }); 242 }, 243 244 categoriesDropdowns: function() { 245 $('.dropdown_product_cat').on('change', function() { 246 if ($(this).val()) { 247 var this_page; 248 var home_url = basel_settings.home_url; 249 if (home_url.indexOf('?') > 0) { 250 this_page = home_url + '&product_cat=' + jQuery(this).val(); 251 } else { 252 this_page = home_url + '?product_cat=' + jQuery(this).val(); 253 } 254 location.href = this_page; 255 } else { 256 location.href = basel_settings.shop_url; 257 } 258 }); 259 260 $('.widget_product_categories').each(function() { 261 var $select = $(this).find('select'); 262 263 if ($().selectWoo) { 264 $select.selectWoo({ 265 minimumResultsForSearch: 5, 266 width : '100%', 267 allowClear : true, 268 placeholder : basel_settings.product_categories_placeholder, 269 language : { 270 noResults: function() { 271 return basel_settings.product_categories_no_results; 272 } 273 } 274 }); 275 } 276 }); 277 }, 278 279 swatchesLimit: function() { 280 $('.basel-swatches-divider').on('click', function() { 281 var $this = $(this); 282 283 $this.parent().find('.swatch-on-grid').removeClass('basel-hidden'); 284 $this.parent().addClass('basel-all-shown'); 285 }); 286 }, 287 288 moreCategoriesButton: function() { 289 $('.basel-more-cat').each(function() { 290 var $wrapper = $(this); 291 292 $wrapper.find('.basel-more-cat-btn a').on('click', function(e) { 293 e.preventDefault(); 294 $wrapper.addClass('basel-show-cat'); 295 }); 296 }); 297 }, 298 299 commentImage: function() { 300 $('form.comment-form').attr('enctype', 'multipart/form-data'); 301 }, 302 303 commentImagesUploadValidation: function() { 304 var $form = $('.comment-form'); 305 var $input = $form.find('#basel-add-img-btn'); 306 var allowedMimes = []; 307 308 if ($input.length === 0) { 309 return; 310 } 311 312 $.each(basel_settings.comment_images_upload_mimes, function(index, value) { 313 allowedMimes.push(String(value)); 314 }); 315 316 $form.find('#basel-add-img-btn').on('change', function() { 317 $form.find('.basel-add-img-count').text(basel_settings.comment_images_added_count_text.replace('%s', this.files.length)); 318 }); 319 320 $form.on('submit', function(e) { 321 $form.find('.woocommerce-error').remove(); 322 323 var hasLarge = false;
324 var hasNotAllowedMime = false; 325 326 if ($input[0].files.length > basel_settings.comment_images_count) { 327 showError(basel_settings.comment_images_count_text); 328 e.preventDefault(); 329 } 330 331 Array.prototype.forEach.call($input[0].files, function(file) { 332 var size = file.size; 333 var type = String(file.type); 334 335 if (size > basel_settings.comment_images_upload_size) { 336 hasLarge = true; 337 } 338 339 if ($.inArray(type, allowedMimes) < 0) { 340 hasNotAllowedMime = true; 341 } 342 }); 343 344 if (hasLarge) { 345 showError(basel_settings.comment_images_upload_size_text); 346 e.preventDefault(); 347 } 348 349 if (hasNotAllowedMime) { 350 showError(basel_settings.comment_images_upload_mimes_text); 351 e.preventDefault(); 352 } 353 }); 354 355 function showError(text) { 356 $form.prepend('<ul class="woocommerce-error" role="alert"><li>' + text + '</li></ul>'); 357 } 358 }, 359 360 googleMapInit: function() { 361 $('.google-map-container').each(function() { 362 var $map = $(this); 363 var data = $map.data('map-args'); 364 365 var config = { 366 locations : [ 367 { 368 lat : data.latitude, 369 lon : data.longitude, 370 icon : data.marker_icon, 371 animation: google.maps.Animation.DROP 372 } 373 ], 374 controls_on_map: false, 375 map_div : '#' + data.selector, 376 start : 1, 377 map_options : { 378 zoom : parseInt(data.zoom), 379 scrollwheel: 'yes' === data.mouse_zoom 380 } 381 }; 382 383 if (data.json_style) { 384 config.styles = {}; 385 config.styles[basel_settings.google_map_style_text] = JSON.parse(data.json_style); 386 } 387 388 if ('yes' === data.marker_text_needed) { 389 config.locations[0].html = data.marker_text; 390 } 391 392 if ('button' === data.init_type) { 393 $map.find('.basel-init-map').on('click', function(e) { 394 e.preventDefault(); 395 396 if ($map.hasClass('basel-map-inited')) { 397 return; 398 } 399 400 $map.addClass('basel-map-inited'); 401 new Maplace(config).Load(); 402 }); 403 } else if ('scroll' === data.init_type) { 404 baselThemeModule.$window.on('scroll', function() { 405 if (window.innerHeight + baselThemeModule.$window.scrollTop() + parseInt(data.init_offset) > $map.offset().top) { 406 if ($map.hasClass('basel-map-inited')) { 407 return; 408 } 409 410 $map.addClass('basel-map-inited'); 411 new Maplace(config).Load(); 412 } 413 }); 414 415 baselThemeModule.$window.on('scroll'); 416 } else { 417 new Maplace(config).Load(); 418 } 419 }); 420 }, 421 422 variationsPrice: function() { 423 if ('no' === basel_settings.single_product_variations_price) { 424 return; 425 } 426 427 $('.variations_form').each(function() { 428 var $form = $(this); 429 var $price = $form.parent().find('> .price').first(); 430 var priceOriginalHtml = $price.html(); 431 432 $form.on('show_variation', function(e, variation) { 433 if (variation.price_html.length > 1) { 434 $price.html(variation.price_html); 435 } 436 }); 437 438 $form.on('hide_variation', function() { 439 $price.html(priceOriginalHtml); 440 }); 441 }); 442 }, 443 444 wishlist: function() { 445 var cookiesName = 'basel_wishlist_count'; 446 447 if (baselThemeModule.$body.hasClass('logged-in')) { 448 cookiesName += '_logged'; 449 } 450 451 if (basel_settings.is_multisite) { 452 cookiesName += '_' + basel_settings.current_blog_id; 453 } 454 455 var $widget = $('.wishlist-info-widget'); 456 var cookie = Cookies.get(cookiesName); 457 458 if ($widget.length > 0 && 'undefined' !== typeof cookie) { 459 try { 460 var count = JSON.parse(cookie); 461 $widget.find('.wishlist-count').text(count); 462 } 463 catch (e) { 464 console.log('cant parse cookies json'); 465 } 466 } 467 468 baselThemeModule.$body.on('click', '.wishlist-btn-wrapper a, .basel-wishlist-btn a', function(e) { 469 var $this = $(this); 470 var productId = $this.data('product-id'); 471 var addedText = $this.data('added-text'); 472 var key = $this.data('key'); 473 474 if ($this.hasClass('added')) { 475 return true; 476 } 477 478 e.preventDefault(); 479 480 $this.addClass('loading'); 481 482 $.ajax({ 483 url : basel_settings.ajaxurl, 484 data : { 485 action : 'basel_add_to_wishlist', 486 product_id: productId,
487 key : key 488 }, 489 dataType: 'json', 490 method : 'GET', 491 success : function(response) { 492 if (response) { 493 $this.addClass('added'); 494 baselThemeModule.$document.trigger('added_to_wishlist'); 495 496 if (response.wishlist_content) { 497 updateWishlist(response); 498 } 499 500 if ($this.find('span').length > 0) { 501 $this.find('span').text(addedText); 502 } else { 503 $this.text(addedText); 504 } 505 } else { 506 console.log('something wrong loading wishlist data ', 507 response); 508 } 509 }, 510 error : function() { 511 console.log( 512 'We cant add to wishlist. Something wrong with AJAX response. Probably some PHP conflict.'); 513 }, 514 complete: function() { 515 $this.removeClass('loading'); 516 } 517 }); 518 }); 519 520 baselThemeModule.$body.on('click', '.basel-wishlist-content .basel-remove-button', function(e) { 521 var $this = $(this); 522 var productId = $this.data('product-id'); 523 var key = $this.data('key'); 524 525 if ($this.hasClass('added')) { 526 return true; 527 } 528 529 e.preventDefault(); 530 531 $this.addClass('loading'); 532 533 $.ajax({ 534 url : basel_settings.ajaxurl, 535 data : { 536 action : 'basel_remove_from_wishlist', 537 product_id: productId, 538 key : key 539 }, 540 dataType: 'json', 541 method : 'GET', 542 success : function(response) { 543 if (response.wishlist_content) { 544 updateWishlist(response); 545 } else { 546 console.log('something wrong loading wishlist data ', 547 response); 548 } 549 }, 550 error : function() { 551 console.log( 552 'We cant remove from wishlist. Something wrong with AJAX response. Probably some PHP conflict.'); 553 }, 554 complete: function() { 555 $this.removeClass('loading'); 556 } 557 }); 558 }); 559 560 function updateWishlist(data) { 561 var $headerWidget = $('.wishlist-info-widget'); 562 563 if ($headerWidget.length > 0) { 564 $headerWidget.find('.wishlist-count').text(data.count); 565 } 566 567 var $wishlistContent = $('.basel-wishlist-content'); 568 if ($wishlistContent.length > 0 && !$wishlistContent.hasClass('basel-wishlist-preview')) { 569 $wishlistContent.replaceWith(data.wishlist_content); 570 } 571 572 baselThemeModule.swatchesVariations(); 573 baselThemeModule.btnsToolTips(); 574 baselThemeModule.countDownTimer(); 575 baselThemeModule.swatchesLimit(); 576 } 577 }, 578 579 footerWidgetsAccordion: function() { 580 if (baselThemeModule.windowWidth > 767) { 581 return; 582 } 583 584 $('.footer-widget-collapse .widget-title').on('click', function() { 585 var $title = $(this); 586 var $widget = $title.parent(); 587 var $content = $widget.find('> *:not(.widget-title)'); 588 589 if ($widget.hasClass('footer-widget-opened')) { 590 $widget.removeClass('footer-widget-opened'); 591 $content.stop().slideUp(200); 592 } else { 593 $widget.addClass('footer-widget-opened'); 594 $content.stop().slideDown(200); 595 } 596 }); 597 }, 598 599 sortByWidget: function() { 600 if (baselThemeModule.$body.hasClass('basel-ajax-shop-off')) { 601 return; 602 } 603 604 var $wcOrdering = $('.woocommerce-ordering'); 605 606 $wcOrdering.on('change', 'select.orderby', function() { 607 var $form = $(this).closest('form'); 608 609 $form.find('[name="_pjax"]').remove(); 610 611 $.pjax({ 612 container : '.main-page-wrapper', 613 timeout : basel_settings.pjax_timeout, 614 url : '?' + $form.serialize(), 615 scrollTo : false, 616 renderCallback: function(context, html, afterRender) { 617 baselThemeModule.removeDuplicatedStylesFromHTML(html, function(html) { 618 context.html(html); 619 afterRender(); 620 baselThemeModule.shopPageInit(); 621 baselThemeModule.$document.trigger('basel-images-loaded'); 622 }); 623 } 624 }); 625 }); 626 627 $wcOrdering.on('submit', function(e) { 628 e.preventDefault(e); 629 }); 630 }, 631 632 portfolioPhotoSwipe: function() { 633 baselThemeModule.$document.on('click', '.portfolio-enlarge', function(e) { 634 e.preventDefault(); 635 var $parent = $(this).parents('.portfolio-entry'); 636 var index = $parent.index(); 637 var items = getPortfolioImages(); 638 baselThemeModule.callPhotoSwipe(index, items); 639 }); 640 641 var getPortfolioImages = function() { 642 var items = []; 643 $('.portfolio-entry').find('figure a img').each(function() { 644 var $this = $(this); 645 646 items.push({ 647 src: $this.attr('src'), 648 w : $this.attr('width'), 649 h : $this.attr('height') 650 }); 651 }); 652 return items; 653 }; 654 }, 655 656 productFilters: function() { 657 var removeValue = function($mainInput, currentVal) { 658 if ($mainInput.length === 0) { 659 return; 660 } 661 var mainInputVal = $mainInput.val(); 662 if (mainInputVal.indexOf(',') > 0) { 663 $mainInput.val(mainInputVal.replace(',' + currentVal, '').replace(currentVal + ',', '')); 664 } else { 665 $mainInput.val(mainInputVal.replace(currentVal, '')); 666 } 667 }; 668 669 $('.basel-pf-checkboxes li > .pf-value').on('click', function(e) { 670 e.preventDefault(); 671 var $this = $(this); 672 var $li = $this.parent(); 673 var $widget = $this.parents('.basel-pf-checkboxes'); 674 var $mainInput = $widget.find('.result-input'); 675 var $results = $widget.find('.basel-pf-results'); 676 677 var multiSelect = $widget.hasClass('multi_select'); 678 var mainInputVal = $mainInput.val(); 679 var currentText = $this.data('title'); 680 var currentVal = $this.data('val'); 681 682 if (multiSelect) { 683 if (!$li.hasClass('pf-active')) { 684 if (!mainInputVal) { 685 $mainInput.val(currentVal); 686 } else { 687 $mainInput.val(mainInputVal + ',' + currentVal); 688 } 689 $results.prepend('<li class="selected-value" data-title="' + currentVal + '">' + currentText + '</li>'); 690 $li.addClass('pf-active'); 691 } else { 692 removeValue($mainInput, currentVal); 693 $results.find('li[data-title="' + currentVal + '"]').remove(); 694 $li.removeClass('pf-active'); 695 } 696 } else { 697 if (!$li.hasClass('pf-active')) { 698 $mainInput.val(currentVal); 699 $results.find('.selected-value').remove(); 700 $results.prepend('<li class="selected-value" data-title="' + currentVal + '">' + currentText + '</li>'); 701 $li.parents('.basel-scroll-content').find('.pf-active').removeClass('pf-active'); 702 $li.addClass('pf-active'); 703 } else { 704 $mainInput.val(''); 705 $results.find('.selected-value').remove(); 706 $li.removeClass('pf-active'); 707 } 708 } 709 }); 710 711 var $pfCheckbox = $('.basel-pf-checkboxes'); 712 $pfCheckbox.on('click', '.selected-value', function() { 713 var $this = $(this); 714 var $widget = $this.parents('.basel-pf-checkboxes'); 715 var $mainInput = $widget.find('.result-input'); 716 var currentVal = $this.data('title'); 717 718 // Price filter clear. 719 if (currentVal === 'price-filter') { 720 var min = $this.data('min'); 721 var max = $this.data('max'); 722 var $slider = $widget.find('.price_slider_widget'); 723 $slider.slider('values', 0, min); 724 $slider.slider('values', 1, max); 725 $widget.find('.min_price').val(''); 726 $widget.find('.max_price').val(''); 727 baselThemeModule.$body.trigger('filter_price_slider_slide', [ 728 min, 729 max, 730 min, 731 max, 732 $slider 733 ]); 734 return; 735 } 736 737 removeValue($mainInput, currentVal); 738 $widget.find('.pf-value[data-val="' + currentVal + '"]').parent().removeClass('pf-active'); 739 $this.remove(); 740 }); 741 742 //Checkboxes value dropdown 743 $pfCheckbox.each(function() { 744 var $this = $(this); 745 var $btn = $this.find('.basel-pf-title'); 746 var $list = $btn.siblings('.basel-pf-dropdown'); 747 var multiSelect = $this.hasClass('multi_select'); 748 749 $btn.on('click', function(e) { 750 var target = e.target; 751 if ($(target).is($btn.find('.selected-value'))) { 752 return; 753 } 754 755 if (!$this.hasClass('opened')) { 756 $this.addClass('opened'); 757 $list.slideDown(100); 758 } else { 759 close(); 760 } 761 }); 762 763 baselThemeModule.$document.on('click', function(e) { 764 var target = e.target; 765 if ($this.hasClass('opened') && (multiSelect && !$(target).is($this) && !$(target).parents().is($this)) || (!multiSelect && !$(target).is($btn) && !$(target).parents().is($btn))) { 766 close(); 767 } 768 }); 769 770 var close = function() { 771 $this.removeClass('opened'); 772 $list.slideUp(100); 773 }; 774 }); 775 776 var removeEmptyValues = function($selector) { 777 $selector.find('.basel-pf-checkboxes').each(function() { 778 var $this = $(this); 779 if (!$this.find('input[type="hidden"]').val()) { 780 $this.find('input[type="hidden"]').remove(); 781 } 782 }); 783 }; 784 785 var changeFormAction = function($form) { 786 var activeCat = $form.find('.basel-pf-categories .pf-active .pf-value'); 787 if (activeCat.length > 0) { 788 $form.attr('action', activeCat.attr('href')); 789 } 790 }; 791 792 //Price slider init 793 baselThemeModule.$body.on('filter_price_slider_create filter_price_slider_slide', function(event, min, max, minPrice, maxPrice, $slider) { 794 var minHtml = accounting.formatMoney(min, { 795 symbol : woocommerce_price_slider_params.currency_format_symbol, 796 decimal : woocommerce_price_slider_params.currency_format_decimal_sep, 797 thousand : woocommerce_price_slider_params.currency_format_thousand_sep, 798 precision: woocommerce_price_slider_params.currency_format_num_decimals, 799 format : woocommerce_price_slider_params.currency_format 800 }); 801 802 var maxHtml = accounting.formatMoney(max, { 803 symbol : woocommerce_price_slider_params.currency_format_symbol, 804 decimal : woocommerce_price_slider_params.currency_format_decimal_sep, 805 thousand : woocommerce_price_slider_params.currency_format_thousand_sep, 806 precision: woocommerce_price_slider_params.currency_format_num_decimals, 807 format : woocommerce_price_slider_params.currency_format 808 }); 809 810 $slider.siblings('.filter_price_slider_amount').find('span.from').html(minHtml); 811 $slider.siblings('.filter_price_slider_amount').find('span.to').html(maxHtml); 812 813 var $results = $slider.parents('.basel-pf-checkboxes').find('.basel-pf-results'); 814 var value = $results.find('.selected-value'); 815 if (min == minPrice && max == maxPrice) { 816 value.remove(); 817 } else { 818 if (value.length === 0) { 819 $results.prepend('<li class="selected-value" data-title="price-filter" data-min="' + minPrice + '" data-max="' + maxPrice + '">' + minHtml + ' - ' + maxHtml + '</li>'); 820 } else { 821 value.html(minHtml + ' - ' + maxHtml); 822 } 823 } 824 825 baselThemeModule.$body.trigger('price_slider_updated', [ 826 min, 827 max 828 ]); 829 }); 830 831 $('.basel-pf-price-range .price_slider_widget').each(function() { 832 var $this = $(this); 833 var $minInput = $this.siblings('.filter_price_slider_amount').find('.min_price'); 834 var $maxInput = $this.siblings('.filter_price_slider_amount').find('.max_price'); 835 var minPrice = parseInt($minInput.data('min')); 836 var maxPrice = parseInt($maxInput.data('max')); 837 var currentMinPrice = parseInt($minInput.val()); 838 var currentMaxPrice = parseInt($maxInput.val()); 839 840 $('.price_slider_widget, .price_label').show(); 841 842 $this.slider({ 843 range : true, 844 animate: true, 845 min : minPrice, 846 max : maxPrice, 847 values : [ 848 currentMinPrice, 849 currentMaxPrice 850 ], 851 create : function() { 852 if (currentMinPrice == minPrice && currentMaxPrice == maxPrice) { 853 $minInput.val(''); 854 $maxInput.val(''); 855 } 856 baselThemeModule.$body.trigger('filter_price_slider_create', [ 857 currentMinPrice, 858 currentMaxPrice, 859 minPrice, 860 maxPrice, 861 $this 862 ]); 863 }, 864 slide : function(event, ui) { 865 if (ui.values[0] == minPrice && ui.values[1] == maxPrice) { 866 $minInput.val(''); 867 $maxInput.val(''); 868 } else { 869 $minInput.val(ui.values[0]); 870 $maxInput.val(ui.values[1]); 871 } 872 baselThemeModule.$body.trigger('filter_price_slider_slide', [ 873 ui.values[0], 874 ui.values[1], 875 minPrice, 876 maxPrice, 877 $this 878 ]); 879 }, 880 change : function(event, ui) { 881 baselThemeModule.$body.trigger('price_slider_change', [ 882 ui.values[0], 883 ui.values[1] 884 ]); 885 } 886 }); 887 }); 888 889 // Submit filter form. 890 $('.basel-product-filters').one('click', '.basel-pf-btn button', function() { 891 var $this = $(this); 892 var $form = $this.parents('.basel-product-filters'); 893 removeEmptyValues($form); 894 changeFormAction($form); 895 896 if (!baselThemeModule.$body.hasClass('basel-ajax-shop-on') || typeof ($.fn.pjax) == 'undefined' || !$form.hasClass('with-ajax')) { 897 return; 898 } 899 $.pjax({ 900 container : '.main-page-wrapper', 901 timeout : basel_settings.pjax_timeout, 902 url : $form.attr('action'), 903 data : $form.serialize(), 904 scrollTo : false, 905 renderCallback: function(context, html, afterRender) { 906 baselThemeModule.removeDuplicatedStylesFromHTML(html, function(html) { 907 context.html(html); 908 afterRender(); 909 baselThemeModule.shopPageInit(); 910 baselThemeModule.$document.trigger('basel-images-loaded'); 911 }); 912 } 913 }); 914 $this.prop('disabled', true); 915 }); 916
917 // Create labels after ajax. 918 $('.basel-pf-checkboxes .pf-active > .pf-value').each(function() { 919 var $this = $(this); 920 var resultsWrapper = $this.parents('.basel-pf-checkboxes').find('.basel-pf-results'); 921 resultsWrapper.prepend('<li class="selected-value" data-title="' + $this.data('val') + '">' + $this.data('title') + '</li>'); 922 }); 923 924 }, 925 926 owlCarouselInit: function() { 927 $('[data-owl-carousel]:not(.scroll-init)').each(function() { 928 owlInit($(this)); 929 }); 930 931 if (typeof ($.fn.waypoint) != 'undefined') { 932 $('[data-owl-carousel].scroll-init').waypoint(function() { 933 var $this = $($(this)[0].element); 934 owlInit($this); 935 }, { 936 offset: '100%' 937 }); 938 } 939 940 function owlInit($this) { 941 var $owl = $this.find('.owl-carousel'); 942 var options = { 943 rtl : baselThemeModule.$body.hasClass('rtl'), 944 items : $this.data('desktop') ? $this.data('desktop') : 1, 945 responsive : { 946 979: { 947 items: $this.data('desktop') ? $this.data('desktop') : 1 948 }, 949 768: { 950 items: $this.data('desktop_small') ? $this.data('desktop_small') : 1 951 }, 952 479: { 953 items: $this.data('tablet') ? $this.data('tablet') : 1 954 }, 955 0 : { 956 items: $this.data('mobile') ? $this.data('mobile') : 1 957 } 958 }, 959 autoplay : $this.data('autoplay') === 'yes', 960 autoplayHoverPause: $this.data('autoplay') === 'yes', 961 autoplayTimeout : $this.data('speed') ? $this.data('speed') : 5000, 962 dots : $this.data('hide_pagination_control') !== 'yes', 963 nav : $this.data('hide_prev_next_buttons') !== 'yes', 964 autoHeight : $this.data('autoheight') === 'yes', 965 slideBy : !$this.data('scroll_per_page') ? 1 : 'page', 966 navText : false, 967 center : $this.data('center_mode') === 'yes', 968 loop : $this.data('wrap') === 'yes', 969 dragEndSpeed : $this.data('dragendspeed') ? $this.data('dragendspeed') : 200, 970 onRefreshed : function() { 971 baselThemeModule.$window.trigger('resize'); 972 } 973 }; 974 975 if ($this.data('sliding_speed')) { 976 options.smartSpeed = $this.data('sliding_speed'); 977 options.dragEndSpeed = $this.data('sliding_speed'); 978 } 979 980 if ($this.data('animation')) { 981 options.animateOut = $this.data('animation'); 982 options.mouseDrag = false; 983 } 984 985 if ($this.data('content_animation')) { 986 function determinePseudoActive() { 987 var id = $owl.find('.owl-item.active').find('.basel-slide').attr('id'); 988 $owl.find('.owl-item.pseudo-active').removeClass('pseudo-active'); 989 var $els = $owl.find('[id="' + id + '"]'); 990 $els.each(function() { 991 var $this = $(this); 992 if (!$this.parent().hasClass('active')) { 993 $this.parent().addClass('pseudo-active'); 994 } 995 }); 996 } 997 998 determinePseudoActive(); 999 options.onTranslated = function() { 1000 determinePseudoActive(); 1001 }; 1002 } 1003 1004 baselThemeModule.$window.on('vc_js', function() { 1005 $owl.trigger('refresh.owl.carousel'); 1006 }); 1007 1008 // Fix for css in files. 1009 $owl.find('link').appendTo('head'); 1010 1011 $owl.owlCarousel(options); 1012 1013 if ($this.data('autoheight') === 'yes') { 1014 $owl.imagesLoaded(function() { 1015 $owl.trigger('refresh.owl.carousel'); 1016 }); 1017 } 1018 } 1019 }, 1020 1021 baselSliderLazyLoad: function() { 1022 $('.basel-slider').on('changed.owl.carousel', function(event) { 1023 var $this = $(this); 1024 var active = $this.find('.owl-item').eq(event.item.index); 1025 var id = active.find('.basel-slide').attr('id'); 1026 var $els = $this.find('[id="' + id + '"]'); 1027 1028 active.find('.basel-slide').addClass('basel-loaded'); 1029 $els.each(function() { 1030 $(this).addClass('basel-loaded'); 1031 }); 1032 }); 1033 }, 1034 1035 lazyLoading: function() { 1036 if (!window.addEventListener || !window.requestAnimationFrame || !document.getElementsByClassName) { 1037 return; 1038 } 1039 1040 var pItem = document.getElementsByClassName('basel-lazy-load'), pCount, timer; 1041 1042 baselThemeModule.$document.on('basel-images-loaded added_to_cart', function() { 1043 inView(); 1044 }); 1045 1046 $('.basel-scroll-content, .basel-sidebar-content').on('scroll', function() { 1047 baselThemeModule.$document.trigger('basel-images-loaded'); 1048 }); 1049 1050 // WooCommerce tabs fix 1051 $('.wc-tabs > li').on('click', function() { 1052 baselThemeModule.$document.trigger('basel-images-loaded'); 1053 }); 1054 1055 // scroll and resize events 1056 window.addEventListener('scroll', scroller, false); 1057 window.addEventListener('resize', scroller, false); 1058 1059 // DOM mutation observer 1060 if (MutationObserver) { 1061 1062 var observer = new MutationObserver(function() { 1063 if (pItem.length !== pCount) { 1064 inView(); 1065 } 1066 }); 1067 1068 observer.observe(document.body, { 1069 subtree : true, 1070 childList : true, 1071 attributes : true, 1072 characterData: true 1073 }); 1074 1075 } 1076 1077 // initial check 1078 inView(); 1079 1080 // throttled scroll/resize 1081 function scroller() { 1082 timer = timer || setTimeout(function() { 1083 timer = null; 1084 inView(); 1085 }, 100); 1086 } 1087 1088 // image in view? 1089 function inView() { 1090 if (pItem.length) { 1091 requestAnimationFrame(function() { 1092 var offset = parseInt(basel_settings.lazy_loading_offset); 1093 var wT = window.pageYOffset, wB = wT + window.innerHeight + offset, cRect, pT, pB, p = 0; 1094 1095 while (p < pItem.length) { 1096 1097 cRect = pItem[p].getBoundingClientRect(); 1098 pT = wT + cRect.top; 1099 pB = pT + cRect.height; 1100 1101 if (wT < pB && wB > pT && !pItem[p].loaded) { 1102 loadFullImage(pItem[p], p); 1103 } else { 1104 p++; 1105 } 1106 1107 } 1108 1109 pCount = pItem.length; 1110 }); 1111 } 1112 } 1113 1114 function loadFullImage(item) { 1115 item.onload = addedImg; 1116 1117 if (item.querySelector('img') !== null) { 1118 item.querySelector('img').onload = addedImg; 1119 item.querySelector('img').src = item.dataset.baselSrc; 1120 item.querySelector('source').srcset = item.dataset.baselSrc; 1121 1122 if (typeof (item.dataset.srcset) != 'undefined') { 1123 item.querySelector('img').srcset = item.dataset.srcset; 1124 } 1125 } 1126 1127 item.src = item.dataset.baselSrc; 1128 if (typeof (item.dataset.srcset) != 'undefined') { 1129 item.srcset = item.dataset.srcset; 1130 } 1131 1132 item.loaded = true; 1133 1134 // replace image 1135 function addedImg() { 1136 requestAnimationFrame(function() { 1137 item.classList.add('basel-loaded'); 1138 1139 var $masonry = jQuery(item).parents('.view-masonry .gallery-images, .grid-masonry, .masonry-container'); 1140 if ($masonry.length > 0) { 1141 $masonry.isotope('layout'); 1142 } 1143 var $categories = jQuery(item).parents('.categories-masonry'); 1144 if ($categories.length > 0) { 1145 $categories.packery(); 1146 } 1147 }); 1148 } 1149 } 1150 }, 1151 1152 productLoaderPosition: function() { 1153 var reculc = function() { 1154 $('.basel-products-loader').each(function() { 1155 var $loader = $(this), 1156 $loaderWrap = $loader.parent(); 1157 1158 if ($loader.length === 0) { 1159 return; 1160 } 1161 1162 $loader.css('left', $loaderWrap.offset().left + $loaderWrap.outerWidth() / 2); 1163 }); 1164 }; 1165 1166 baselThemeModule.$window.off('scroll.loaderVerticalPosition'); 1167 1168 baselThemeModule.$window.on('scroll.loaderVerticalPosition', reculc); 1169 }, 1170 1171 stickySidebarBtn: function() { 1172 var $trigger = $('.basel-show-sidebar-btn'); 1173 var $stickyBtn = $('.shop-sidebar-opener'); 1174 1175 if ($stickyBtn.length <= 0 || $trigger.length <= 0 || baselThemeModule.windowWidth >= 1024) { 1176 return; 1177 } 1178 1179 var stickySidebarBtnToggle = function() { 1180 var btnOffset = $trigger.offset().top + $trigger.outerHeight(); 1181 var windowScroll = baselThemeModule.$window.scrollTop(); 1182 1183 if (btnOffset < windowScroll) { 1184 $stickyBtn.addClass('basel-sidebar-btn-shown'); 1185 } else { 1186 $stickyBtn.removeClass('basel-sidebar-btn-shown'); 1187 } 1188 }; 1189 1190 stickySidebarBtnToggle(); 1191 1192 baselThemeModule.$window.on('scroll', stickySidebarBtnToggle); 1193 baselThemeModule.$window.on('resize', stickySidebarBtnToggle); 1194 }, 1195 1196 stickyAddToCart: function() { 1197 var $trigger = $('.summary-inner .cart'); 1198 var $stickyBtn = $('.basel-sticky-btn'); 1199 1200 if ($stickyBtn.length <= 0 || $trigger.length <= 0 || (baselThemeModule.windowWidth <= 768 && $stickyBtn.hasClass('mobile-off'))) { 1201 return; 1202 } 1203 1204 var summaryOffset = $trigger.offset().top + $trigger.outerHeight(); 1205 var $scrollToTop = $('.scrollToTop'); 1206 1207 var stickyAddToCartToggle = function() { 1208 var windowScroll = baselThemeModule.$window.scrollTop(); 1209 var windowHeight = baselThemeModule.$window.height(); 1210 var documentHeight = baselThemeModule.$document.height(); 1211 1212 if (summaryOffset < windowScroll && windowScroll + windowHeight !== documentHeight) { 1213 $stickyBtn.addClass('basel-sticky-btn-shown'); 1214 $scrollToTop.addClass('basel-sticky-btn-shown'); 1215 1216 } else if (windowScroll + windowHeight === documentHeight || summaryOffset > windowScroll) { 1217 $stickyBtn.removeClass('basel-sticky-btn-shown'); 1218 $scrollToTop.removeClass('basel-sticky-btn-shown'); 1219 } 1220 }; 1221 1222 stickyAddToCartToggle(); 1223 1224 baselThemeModule.$window.on('scroll', stickyAddToCartToggle); 1225 1226 $('.basel-sticky-add-to-cart, .basel-sticky-btn-cart .basel-buy-now-btn').on('click', function(e) { 1227 e.preventDefault(); 1228 $('html, body').animate({
1229 scrollTop: $('.summary-inner').offset().top 1230 }, 800); 1231 }); 1232 1233 // Wishlist. 1234 $('.basel-sticky-btn .basel-sticky-btn-wishlist a').on('click', function(e) { 1235 if (!$(this).hasClass('added')) { 1236 e.preventDefault(); 1237 } 1238 1239 $('.entry-summary .basel-wishlist-btn').trigger('click'); 1240 }); 1241 1242 baselThemeModule.$document.on('added_to_wishlist', function() { 1243 $('.basel-sticky-btn .basel-sticky-btn-wishlist a').addClass('added'); 1244 }); 1245 1246 // Compare. 1247 $('.basel-sticky-btn .basel-sticky-btn-compare a').on('click', function(e) { 1248 if (!$(this).hasClass('added')) { 1249 e.preventDefault(); 1250 } 1251 1252 $('.entry-summary .basel-compare-btn').trigger('click'); 1253 }); 1254 1255 baselThemeModule.$document.on('added_to_compare', function() { 1256 $('.basel-sticky-btn .basel-sticky-btn-compare a').addClass('added'); 1257 }); 1258 1259 // Quantity. 1260 $('.basel-sticky-btn-cart .qty').on('change', function() { 1261 $('.summary-inner .qty').val($(this).val()); 1262 }); 1263 1264 $('.summary-inner .qty').on('change', function() { 1265 $('.basel-sticky-btn-cart .qty').val($(this).val()); 1266 }); 1267 }, 1268 1269 shopLoader: function() { 1270 var loaderClass = '.basel-shop-loader', 1271 contentClass = '.products[data-source="main_loop"]', 1272 sidebarClass = '.area-sidebar-shop', 1273 sidebarLeftClass = 'sidebar-left', 1274 hiddenClass = 'hidden-loader', 1275 hiddenTopClass = 'hidden-from-top', 1276 hiddenBottomClass = 'hidden-from-bottom'; 1277 1278 var loaderVerticalPosition = function() { 1279 var $products = $(contentClass), 1280 $loader = $products.parent().find(loaderClass); 1281 1282 if ($products.length < 1) { 1283 return; 1284 } 1285 1286 var offset = baselThemeModule.$window.height() / 2, 1287 scrollTop = baselThemeModule.$window.scrollTop(), 1288 holderTop = $products.offset().top - offset, 1289 holderHeight = $products.height(), 1290 holderBottom = holderTop + holderHeight - 100; 1291 1292 if (scrollTop < holderTop) { 1293 $loader.addClass(hiddenClass + ' ' + hiddenTopClass); 1294 } else if (scrollTop > holderBottom) { 1295 $loader.addClass(hiddenClass + ' ' + hiddenBottomClass); 1296 } else { 1297 $loader.removeClass(hiddenClass + ' ' + hiddenTopClass + ' ' + hiddenBottomClass); 1298 } 1299 }; 1300 1301 var loaderHorizontalPosition = function() { 1302 var $products = $(contentClass), 1303 $sidebar = $(sidebarClass), 1304 $loader = $products.parent().find(loaderClass), 1305 sidebarWidth = $sidebar.outerWidth(); 1306 1307 if ($products.length < 1) { 1308 return; 1309 } 1310 1311 if (sidebarWidth > 0 && $sidebar.hasClass(sidebarLeftClass)) { 1312 if (baselThemeModule.$body.hasClass('rtl')) { 1313 $loader.css({ 1314 'marginLeft': -sidebarWidth / 2 - 15 1315 }); 1316 } else { 1317 $loader.css({ 1318 'marginLeft': sidebarWidth / 2 - 15 1319 }); 1320 } 1321 } else if (sidebarWidth > 0) { 1322 if (baselThemeModule.$body.hasClass('rtl')) { 1323 $loader.css({ 1324 'marginLeft': sidebarWidth / 2 - 15 1325 }); 1326 } else { 1327 $loader.css({ 1328 'marginLeft': -sidebarWidth / 2 - 15 1329 }); 1330 } 1331 } 1332 }; 1333 1334 baselThemeModule.$window.off('scroll.loaderVerticalPosition'); 1335 baselThemeModule.$window.off('loaderHorizontalPosition'); 1336 1337 baselThemeModule.$window.on('scroll.loaderVerticalPosition', loaderVerticalPosition); 1338 baselThemeModule.$window.on('resize.loaderHorizontalPosition', loaderHorizontalPosition); 1339 }, 1340 1341 loginSidebar: function() { 1342 var body = baselThemeModule.$body; 1343 1344 $('.login-side-opener').on('click', function(e) { 1345 e.preventDefault(); 1346 if (isOpened()) { 1347 closeWidget(); 1348 } else { 1349 setTimeout(function() { 1350 openWidget(); 1351 }, 10); 1352 } 1353 }); 1354 1355 body.on('click touchstart', '.basel-close-side', function() { 1356 if (isOpened()) { 1357 closeWidget(); 1358 } 1359 }); 1360 1361 body.on('click', '.widget-close', function(e) { 1362 e.preventDefault(); 1363 if (isOpened()) { 1364 closeWidget(); 1365 } 1366 }); 1367 1368 var closeWidget = function() { 1369 body.removeClass('basel-login-side-opened'); 1370 }; 1371 1372 var openWidget = function() { 1373 body.addClass('basel-login-side-opened'); 1374 }; 1375 1376 var isOpened = function() { 1377 return body.hasClass('basel-login-side-opened'); 1378 }; 1379 }, 1380 1381 headerBanner: function() { 1382 var banner_version = basel_settings.header_banner_version, 1383 banner_btn = basel_settings.header_banner_close_btn, 1384 banner_enabled = basel_settings.header_banner_enabled; 1385 if (Cookies.get('basel_tb_banner_' + banner_version) == 'closed' || banner_btn == false || banner_enabled == false) { 1386 return; 1387 } 1388 var banner = $('.header-banner'); 1389 1390 if (!baselThemeModule.$body.hasClass('page-template-maintenance')) { 1391 baselThemeModule.$body.addClass('header-banner-display'); 1392 } 1393 1394 banner.on('click', '.close-header-banner', function(e) { 1395 e.preventDefault(); 1396 closeBanner(); 1397 }); 1398 1399 var closeBanner = function() { 1400 baselThemeModule.$body.removeClass('header-banner-display').addClass('header-banner-hide'); 1401 Cookies.set('basel_tb_banner_' + banner_version, 'closed', { 1402 expires: 60, 1403 path : '/' 1404 }); 1405 }; 1406 }, 1407 1408 shopHiddenSidebar: function() { 1409 baselThemeModule.$body.on('click', '.basel-show-sidebar-btn, .basel-sticky-sidebar-opener', function(e) { 1410 e.preventDefault(); 1411 if ($('.sidebar-container').hasClass('show-hidden-sidebar')) { 1412 baselThemeModule.hideShopSidebar(); 1413 } else { 1414 showSidebar(); 1415 } 1416 }); 1417 1418 baselThemeModule.$body.on('click touchstart', '.basel-close-side, .basel-close-sidebar-btn', function() { 1419 baselThemeModule.hideShopSidebar(); 1420 }); 1421 1422 var showSidebar = function() { 1423 $('.sidebar-container').addClass('show-hidden-sidebar'); 1424 baselThemeModule.$body.addClass('basel-show-hidden-sidebar'); 1425 $('.basel-show-sidebar-btn').addClass('btn-clicked'); 1426 }; 1427 }, 1428 1429 hideShopSidebar: function() { 1430 $('.basel-show-sidebar-btn').removeClass('btn-clicked'); 1431 $('.sidebar-container').removeClass('show-hidden-sidebar'); 1432 baselThemeModule.$body.removeClass('basel-show-hidden-sidebar'); 1433 }, 1434 1435 mobileSearchIcon: function() { 1436 var body = baselThemeModule.$body; 1437 $('.mobile-search-icon.search-button').on('click', function(e) { 1438 if (baselThemeModule.windowWidth > 991) { 1439 return; 1440 } 1441 1442 e.preventDefault(); 1443 if (!body.hasClass('act-mobile-menu')) { 1444 body.addClass('act-mobile-menu'); 1445 $('.mobile-nav .searchform').find('input[type="text"]').focus(); 1446 } 1447 }); 1448 }, 1449 1450 contentPopup: function() { 1451 $('.basel-popup-with-content').magnificPopup({ 1452 type : 'inline', 1453 removalDelay: 500, 1454 tClose : basel_settings.close, 1455 tLoading : basel_settings.loading, 1456 callbacks : { 1457 beforeOpen: function() { 1458 this.st.mainClass = baselTheme.popupEffect + ' content-popup-wrapper'; 1459 }, 1460 open : function() { 1461 baselThemeModule.$document.trigger('basel-images-loaded'); 1462 } 1463 } 1464 }); 1465 }, 1466 1467 addToCartAllTypes: function() { 1468 if (basel_settings.ajax_add_to_cart == false) { 1469 return; 1470 } 1471 1472 baselThemeModule.$body.on('submit', 'form.cart', function(e) { 1473 var $form = $(this); 1474 var $productWrapper = $form.parents('.single-product-page'); 1475 if ($productWrapper.length === 0) { 1476 $productWrapper = $form.parents('.product-quick-view'); 1477 } 1478 1479 if ($productWrapper.hasClass('product-type-external') || $productWrapper.hasClass('product-type-zakeke') || 'undefined' !== typeof e.originalEvent && $(e.originalEvent.submitter).hasClass('basel-buy-now-btn')) { 1480 return; 1481 } 1482 1483 e.preventDefault(); 1484 1485 var $thisbutton = $form.find('.single_add_to_cart_button'); 1486 var data = $form.serialize(); 1487 1488 data += '&action=basel_ajax_add_to_cart'; 1489 1490 if ($thisbutton.val()) { 1491 data += '&add-to-cart=' + $thisbutton.val(); 1492 } 1493 1494 $thisbutton.removeClass('added not-added'); 1495 $thisbutton.addClass('loading'); 1496 1497 // Trigger event 1498 baselThemeModule.$body.trigger('adding_to_cart', [ 1499 $thisbutton, 1500 data 1501 ]); 1502 1503 $.ajax({ 1504 url : basel_settings.ajaxurl, 1505 data : data, 1506 method : 'POST', 1507 success : function(response) { 1508 if (!response) { 1509 return; 1510 } 1511 1512 var this_page = window.location.toString(); 1513 1514 this_page.replace('add-to-cart', 'added-to-cart'); 1515 1516 if (response.error && response.product_url) { 1517 window.location = response.product_url; 1518 return; 1519 } 1520 1521 // Redirect to cart option 1522 if (basel_settings.cart_redirect_after_add === 'yes') { 1523 window.location = basel_settings.cart_url; 1524 return; 1525 } else { 1526 $thisbutton.removeClass('loading'); 1527 1528 var fragments = response.fragments; 1529 var cart_hash = response.cart_hash; 1530 1531 // Block fragments class 1532 if (fragments) { 1533 $.each(fragments, function(key) { 1534 $(key).addClass('updating'); 1535 }); 1536 } 1537 1538 // Replace fragments 1539 if (fragments) { 1540 $.each(fragments, function(key, value) { 1541 $(key).replaceWith(value); 1542 }); 1543 } 1544 1545 // Show notices 1546 if (response.notices.indexOf('error') > 0) { 1547 var $error = $('.woocommerce-error'); 1548 if ($error.length > 0) { 1549 $error.remove(); 1550 } 1551 $('.single-product-content').prepend(response.notices); 1552 $thisbutton.addClass('not-added'); 1553 } else { 1554 if (basel_settings.add_to_cart_action === 'widget') { 1555 $.magnificPopup.close(); 1556 } 1557 1558 // Changes button classes 1559 $thisbutton.addClass('added'); 1560 // Trigger event so themes can refresh other areas 1561 baselThemeModule.$body.trigger('added_to_cart', [ 1562 fragments, 1563 cart_hash, 1564 $thisbutton 1565 ]); 1566 } 1567 } 1568 }, 1569 error : function() { 1570 console.log('ajax adding to cart error'); 1571 }, 1572 complete: function() { } 1573 }); 1574 }); 1575 1576 baselThemeModule.$body.on('click', '.variations_form .basel-buy-now-btn', function(e) { 1577 var $addToCartBtn = $(this).siblings('.single_add_to_cart_button'); 1578 1579 if ( 'undefined' !== typeof wc_add_to_cart_variation_params && $addToCartBtn.hasClass('disabled') ) { 1580 e.preventDefault(); 1581 1582 if ($addToCartBtn.hasClass('wc-variation-is-unavailable') ) { 1583 alert( wc_add_to_cart_variation_params.i18n_unavailable_text ); 1584 } else if ( $addToCartBtn.hasClass('wc-variation-selection-needed') ) { 1585 alert( wc_add_to_cart_variation_params.i18n_make_a_selection_text ); 1586 } 1587 } 1588 }); 1589 }, 1590 1591 initZoom: function() { 1592 var $mainGallery = $('.woocommerce-product-gallery__wrapper:not(.quick-view-gallery)'); 1593 1594 if (basel_settings.zoom_enable !== 'yes') { 1595 return false;
1596 } 1597 1598 var zoomOptions = { 1599 touch: false 1600 }; 1601 1602 if ('ontouchstart' in window) { 1603 zoomOptions.on = 'click'; 1604 } 1605 1606 init($mainGallery.find('.woocommerce-product-gallery__image').eq(0)); 1607 1608 var $gallery = $('.woocommerce-product-gallery'); 1609 1610 if ($gallery.hasClass('thumbs-position-bottom') || $gallery.hasClass('thumbs-position-left')) { 1611 $mainGallery.on('changed.owl.carousel', function(e) { 1612 var $wrapper = $mainGallery.find('.woocommerce-product-gallery__image').eq(e.item.index); 1613 1614 init($wrapper); 1615 }); 1616 } else { 1617 $mainGallery.find('.product-image-wrap').each(function() { 1618 var $wrapper = $(this).find('.woocommerce-product-gallery__image'); 1619 1620 init($wrapper); 1621 }); 1622 } 1623 1624 function init($wrapper) { 1625 var image = $wrapper.find('img'); 1626 1627 if (image.data('large_image_width') > $wrapper.width()) { 1628 $wrapper.trigger('zoom.destroy'); 1629 $wrapper.zoom(zoomOptions); 1630 } 1631 } 1632 }, 1633 1634 videoPoster: function() { 1635 $('.basel-video-poster-wrapper').on('click', function() { 1636 var videoWrapper = $(this), 1637 video = videoWrapper.siblings('iframe'), 1638 videoScr = video.attr('src'), 1639 videoNewSrc = videoScr + '&autoplay=1'; 1640 1641 if (videoScr.indexOf('vimeo.com') + 1) { 1642 videoNewSrc = videoScr + '?autoplay=1'; 1643 } 1644 video.attr('src', videoNewSrc); 1645 videoWrapper.addClass('hidden-poster'); 1646 }); 1647 }, 1648 1649 fixedHeaders: function() { 1650 var getHeaderHeight = function() { 1651 var headerHeight = header.outerHeight(); 1652 1653 if (body.hasClass('sticky-navigation-only')) { 1654 headerHeight = header.find('.navigation-wrap').outerHeight(); 1655 } 1656 1657 return headerHeight; 1658 }; 1659 1660 var headerSpacer = function() { 1661 if (stickyHeader.hasClass(headerStickedClass)) { 1662 return; 1663 } 1664 $('.header-spacing').height(getHeaderHeight()).css('marginBottom', 40); 1665 }; 1666 1667 var body = baselThemeModule.$body, 1668 header = $('.main-header'), 1669 stickyHeader = header, 1670 headerHeight = getHeaderHeight(), 1671 headerStickedClass = 'act-scroll', 1672 stickyClasses = '', 1673 stickyStart = 0, 1674 links = header.find('.main-nav .menu>li>a'); 1675 1676 if (!body.hasClass('enable-sticky-header') || body.hasClass('global-header-vertical') || header.length === 0) { 1677 return; 1678 } 1679 1680 var logo = header.find('.site-logo').clone().html(), 1681 navigation = header.find('.main-nav').clone().html(), 1682 rightColumn = header.find('.right-column').clone().html(); 1683 1684 var headerClone = '<div class="sticky-header header-clone"><div class="container"><div class="site-logo">' + logo + '</div><div class="main-nav site-navigation basel-navigation">' + navigation + '</div><div class="right-column">' + rightColumn + '</div></div></div>'; 1685 1686 var $topBarWrapper = $('.topbar-wrapp'); 1687 var $headerBanner = $('.header-banner'); 1688 1689 if ($topBarWrapper.length > 0) { 1690 stickyStart = $topBarWrapper.outerHeight(); 1691 } 1692 1693 if ($headerBanner.length > 0 && body.hasClass('header-banner-display')) { 1694 stickyStart += $headerBanner.outerHeight(); 1695 } 1696 1697 if (body.hasClass('sticky-header-real')) { 1698 var headerSpace = $('<div/>').addClass('header-spacing'); 1699 header.before(headerSpace); 1700 1701 baselThemeModule.$window.on('resize', headerSpacer); 1702 headerSpacer(); 1703 1704 var timeout; 1705 1706 baselThemeModule.$window.on('scroll', function() { 1707 if (body.hasClass('header-banner-hide')) { 1708 stickyStart = ($topBarWrapper.length > 0) ? $$topBarWrapper.outerHeight() : 0; 1709 } 1710 if ($(this).scrollTop() > stickyStart) { 1711 stickyHeader.addClass(headerStickedClass); 1712 } else { 1713 stickyHeader.removeClass(headerStickedClass); 1714 clearTimeout(timeout); 1715 timeout = setTimeout(function() { 1716 headerSpacer(); 1717 }, 200); 1718 } 1719 }); 1720 1721 } else if (body.hasClass('sticky-header-clone')) { 1722 header.before(headerClone); 1723 stickyHeader = $('.sticky-header'); 1724 } 1725 1726 // Change header height smooth on scroll 1727 if (body.hasClass('basel-header-smooth')) { 1728 baselThemeModule.$window.on('scroll', function() { 1729 var space = (120 - $(this).scrollTop()) / 2; 1730 1731 if (space >= 60) { 1732 space = 60; 1733 }
1733 else if (space <= 30) { 1734 space = 30; 1735 } 1736 links.css({ 1737 paddingTop : space, 1738 paddingBottom: space 1739 }); 1740 }); 1741 } 1742 1743 if (body.hasClass('basel-header-overlap') || body.hasClass('sticky-navigation-only')) { 1744 } 1745 1746 if (!body.hasClass('basel-header-overlap') && body.hasClass('sticky-header-clone')) { 1747 header.attr('class').split(' ').forEach(function(el) { 1748 if (el.indexOf('main-header') === -1 && el.indexOf('header-') === -1) { 1749 stickyClasses += ' ' + el; 1750 } 1751 }); 1752 1753 stickyHeader.addClass(stickyClasses); 1754 1755 stickyStart += headerHeight; 1756 1757 baselThemeModule.$window.on('scroll', function() { 1758 if (body.hasClass('header-banner-hide')) { 1759 stickyStart = $('.topbar-wrapp').outerHeight() + headerHeight; 1760 } 1761 if ($(this).scrollTop() > stickyStart) { 1762 stickyHeader.addClass(headerStickedClass); 1763 } else { 1764 stickyHeader.removeClass(headerStickedClass); 1765 } 1766 }); 1767 } 1768 1769 body.addClass('sticky-header-prepared'); 1770 }, 1771 1772 verticalHeader: function() { 1773 var $header = $('.header-vertical').first(); 1774 1775 if ($header.length < 1) { 1776 return; 1777 } 1778 1779 var $body, $window, top = false, 1780 bottom = false, windowWidth, windowHeight, lastWindowPos = 0, bodyHeight, headerHeight, resizeTimer, Y = 0, delta, 1781 headerBottom, viewportBottom, scrollStep; 1782 1783 $body = baselThemeModule.$body; 1784 $window = baselThemeModule.$window; 1785 1786 $window 1787 .on('scroll', scroll) 1788 .on('resize', function() { 1789 clearTimeout(resizeTimer); 1790 resizeTimer = setTimeout(resizeAndScroll, 500); 1791 }); 1792 1793 resizeAndScroll(); 1794 1795 for (var i = 1; i < 6; i++) { 1796 setTimeout(resizeAndScroll, 100 * i); 1797 } 1798 1799 // Sidebar scrolling. 1800 function resize() { 1801 windowWidth = $window.width(); 1802 1803 if (1024 > windowWidth) { 1804 top = bottom = false; 1805 $header.removeAttr('style'); 1806 } 1807 } 1808 1809 function scroll() { 1810 var windowPos = $window.scrollTop(); 1811 1812 if (1024 > windowWidth) { 1813 return; 1814 } 1815 1816 headerHeight = $header.height(); 1817 headerBottom = headerHeight + $header.offset().top; 1818 windowHeight = $window.height(); 1819 bodyHeight = $body.height(); 1820 viewportBottom = windowHeight + $window.scrollTop(); 1821 delta = headerHeight - windowHeight; 1822 scrollStep = lastWindowPos - windowPos; 1823 1824 // If header height larger than window viewport 1825 if (delta > 0) { 1826 if (windowPos > lastWindowPos) { 1827 if (headerBottom > viewportBottom) { 1828 Y += scrollStep; 1829 } 1830 1831 if (Y < -delta) { 1832 bottom = true; 1833 Y = -delta; 1834 } 1835 1836 top = false; 1837 } else if (windowPos < lastWindowPos) { 1838 if ($header.offset().top < $window.scrollTop()) { 1839 Y += scrollStep; 1840 } 1841 1842 if (Y >= 0) { 1843 top = true; 1844 Y = 0; 1845 } 1846 1847 bottom = false; 1848 } else { 1849 if (headerBottom < viewportBottom) { 1850 Y = windowHeight - headerHeight; 1851 } 1852 1853 if (Y >= 0) { 1854 top = true; 1855 Y = 0; 1856 } 1857 } 1858 } else { 1859 Y = 0; 1860 } 1861 1862 // Change header Y coordinate 1863 $header.css({ 1864 top: Y 1865 }); 1866 1867 lastWindowPos = windowPos; 1868 } 1869 1870 function resizeAndScroll() { 1871 resize(); 1872 scroll(); 1873 } 1874 }, 1875 1876 splitNavHeader: function() { 1877 var header = $('.header-split'); 1878 1879 if (header.length <= 0) { 1880 return; 1881 } 1882 1883 var navigation = header.find('.main-nav'), 1884 navItems = navigation.find('.menu > li'), 1885 itemsNumber = navItems.length, 1886 rtl = baselThemeModule.$body.hasClass('rtl'), 1887 midIndex = parseInt(itemsNumber / 2 + 0.5 * rtl - .5), 1888 midItem = navItems.eq(midIndex), 1889 logo = header.find('.site-logo > .basel-logo-wrap'), 1890 logoWidth,
1891 leftWidth = 0, 1892 rule = (!rtl) ? 'marginRight' : 'marginLeft', 1893 rightWidth = 0; 1894 1895 var recalc = function() { 1896 logoWidth = logo.outerWidth(); 1897 leftWidth = 5; 1898 rightWidth = 0; 1899 1900 for (var i = itemsNumber - 1; i >= 0; i--) { 1901 var itemWidth = navItems.eq(i).outerWidth(); 1902 if (i > midIndex) { 1903 rightWidth += itemWidth; 1904 } else { 1905 leftWidth += itemWidth; 1906 } 1907 } 1908 1909 var diff = leftWidth - rightWidth; 1910 1911 if (rtl) { 1912 if (leftWidth > rightWidth) { 1913 navigation.find('.menu > li:first-child').css('marginRight', -diff); 1914 } else { 1915 navigation.find('.menu > li:last-child').css('marginLeft', diff + 5); 1916 } 1917 } else { 1918 if (leftWidth > rightWidth) { 1919 navigation.find('.menu > li:last-child').css('marginRight', diff + 5); 1920 } else { 1921 navigation.find('.menu > li:first-child').css('marginLeft', -diff); 1922 } 1923 } 1924 1925 midItem.css(rule, logoWidth); 1926 }; 1927 1928 logo.imagesLoaded(function() { 1929 recalc(); 1930 header.addClass('menu-calculated'); 1931 }); 1932 1933 baselThemeModule.$window.on('resize', recalc); 1934 1935 if (basel_settings.split_nav_fix) { 1936 baselThemeModule.$window.on('scroll', function() { 1937 if (header.hasClass('act-scroll') && !header.hasClass('menu-sticky-calculated')) { 1938 recalc(); 1939 header.addClass('menu-sticky-calculated'); 1940 header.removeClass('menu-calculated'); 1941 } 1942 if (!header.hasClass('act-scroll') && !header.hasClass('menu-calculated')) { 1943 recalc(); 1944 header.addClass('menu-calculated'); 1945 header.removeClass('menu-sticky-calculated'); 1946 } 1947 }); 1948 } 1949 1950 }, 1951 1952 counterShortcode: function(counter) { 1953 if (counter.attr('data-state') === 'done' || parseInt(counter.text()) !== parseInt(counter.data('final'))) { 1954 return; 1955 } 1956 1957 counter.prop('Counter', 0).animate({ 1958 Counter: counter.text() 1959 }, { 1960 duration: 3000, 1961 easing : 'swing', 1962 step : function(now) { 1963 if (now >= counter.data('final')) { 1964 counter.attr('data-state', 'done'); 1965 } 1966 counter.text(Math.ceil(now)); 1967 } 1968 }); 1969 }, 1970 1971 visibleElements: function() { 1972 $('.basel-counter .counter-value').each(function() { 1973 var $this = $(this); 1974 $this.waypoint(function() { 1975 baselThemeModule.counterShortcode($this); 1976 }, {offset: '100%'}); 1977 }); 1978 }, 1979 1980 wishList: function() { 1981 var body = baselThemeModule.$body; 1982 1983 body.on('click', '.add_to_wishlist', function() { 1984 $(this).parent().addClass('feid-in'); 1985 }); 1986 }, 1987 1988 compare: function() { 1989 var body = baselThemeModule.$body, 1990 button = $('a.compare'); 1991 1992 body.on('click', 'a.compare', function() { 1993 $(this).addClass('loading'); 1994 }); 1995 1996 body.on('yith_woocompare_open_popup', function() { 1997 button.removeClass('loading'); 1998 body.addClass('compare-opened'); 1999 }); 2000 2001 body.on('click', '#cboxClose, #cboxOverlay', function() { 2002 body.removeClass('compare-opened'); 2003 }); 2004 }, 2005 2006 baselCompare: function() { 2007 var cookiesName = 'basel_compare_list'; 2008 2009 if (basel_settings.is_multisite) { 2010 cookiesName += '_' + basel_settings.current_blog_id; 2011 } 2012 2013 var $body = baselThemeModule.$body, 2014 $widget = $('.compare-info-widget'), 2015 compareCookie = Cookies.get(cookiesName); 2016 2017 if ($widget.length > 0 && 'undefined' !== typeof compareCookie) { 2018 try { 2019 var ids = JSON.parse(compareCookie); 2020 $widget.find('.compare-count').text(ids.length); 2021 } 2022 catch (e) { 2023 console.log('cant parse cookies json'); 2024 } 2025 } else { 2026 $widget.find('.compare-count').text(0); 2027 } 2028 2029 $body.on('click', '.basel-compare-btn a, a.basel-compare-btn', function(e) { 2030 var $this = $(this), 2031 id = $this.data('id'), 2032 addedText = $this.data('added-text'); 2033 2034 if ($this.hasClass('added')) { 2035 return true; 2036 } 2037 2038 e.preventDefault(); 2039 2040 $this.addClass('loading'); 2041 2042 jQuery.ajax({ 2043 url : basel_settings.ajaxurl, 2044 data : { 2045 action: 'basel_add_to_compare', 2046 id : id 2047 }, 2048 dataType: 'json', 2049 method : 'GET', 2050 success : function(response) { 2051 if (response.table) { 2052 updateCompare(response); 2053 baselThemeModule.$document.trigger('added_to_compare'); 2054 } else { 2055 console.log('something wrong loading compare data ', response); 2056 } 2057 }, 2058 error : function() { 2059 console.log('We cant add to compare. Something wrong with AJAX response. Probably some PHP conflict.'); 2060 }, 2061 complete: function() { 2062 $this.removeClass('loading').addClass('added'); 2063 2064 if ($this.find('span').length > 0) { 2065 $this.find('span').text(addedText); 2066 } else { 2067 $this.text(addedText); 2068 } 2069 } 2070 }); 2071 2072 }); 2073 2074 // Remove from compare action 2075 $body.on('click', '.basel-compare-table .basel-remove-button', function(e) { 2076 var $table = $('.basel-compare-table'); 2077 2078 e.preventDefault(); 2079 var $this = $(this), 2080 id = $this.data('id'); 2081 2082 $table.addClass('loading'); 2083 $this.addClass('loading'); 2084 2085 jQuery.ajax({ 2086 url : basel_settings.ajaxurl, 2087 data : { 2088 action: 'basel_remove_from_compare', 2089 id : id 2090 }, 2091 dataType: 'json', 2092 method : 'GET', 2093 success : function(response) { 2094 if (response.table) { 2095 updateCompare(response); 2096 } else { 2097 console.log('something wrong loading compare data ', response); 2098 } 2099 }, 2100 error : function() { 2101 console.log('We cant remove product compare. Something wrong with AJAX response. Probably some PHP conflict.'); 2102 }, 2103 complete: function() { 2104 $table.removeClass('loading'); 2105 $this.addClass('loading'); 2106 } 2107 }); 2108 2109 }); 2110
2111 // Elements update after ajax 2112 function updateCompare(data) { 2113 var $widget = $('.compare-info-widget'); 2114 if ($widget.length > 0) { 2115 $widget.find('.compare-count').text(data.count); 2116 } 2117 2118 var $compareTable = $('.basel-compare-table'); 2119 if ($compareTable.length > 0) { 2120 $compareTable.replaceWith(data.table); 2121 } 2122 } 2123 }, 2124 2125 promoPopup: function() { 2126 var promo_version = basel_settings.promo_version; 2127 2128 if (baselThemeModule.$body.hasClass('page-template-maintenance') || basel_settings.enable_popup !== 'yes' || (basel_settings.promo_popup_hide_mobile === 'yes' && baselThemeModule.windowWidth < 768)) { 2129 return; 2130 } 2131 2132 var shown = false, 2133 pages = Cookies.get('basel_shown_pages'); 2134 2135 var showPopup = function() { 2136 $.magnificPopup.open({ 2137 items : { 2138 src: '.basel-promo-popup' 2139 }, 2140 type : 'inline', 2141 removalDelay: 400, 2142 tClose : basel_settings.close, 2143 tLoading : basel_settings.loading, 2144 callbacks : { 2145 beforeOpen: function() { 2146 this.st.mainClass = 'basel-popup-effect'; 2147 }, 2148 close : function() { 2149 Cookies.set('basel_popup_' + promo_version, 'shown', { 2150 expires: 7, 2151 path : '/' 2152 }); 2153 } 2154 } 2155 }); 2156 baselThemeModule.$document.trigger('basel-images-loaded'); 2157 }; 2158 2159 $('.basel-open-popup').on('click', function(e) { 2160 e.preventDefault(); 2161 showPopup(); 2162 }); 2163 2164 if (!pages) { 2165 pages = 0; 2166 } 2167 2168 if (pages < basel_settings.popup_pages) { 2169 pages++; 2170 Cookies.set('basel_shown_pages', pages, { 2171 expires: 7, 2172 path : '/' 2173 }); 2174 return false; 2175 } 2176 2177 if (Cookies.get('basel_popup_' + promo_version) !== 'shown') { 2178 if (basel_settings.popup_event === 'scroll') { 2179 baselThemeModule.$window.on('scroll', function() { 2180 if (shown) { 2181 return false; 2182 } 2183 if (baselThemeModule.$document.scrollTop() >= basel_settings.popup_scroll) { 2184 showPopup(); 2185 shown = true; 2186 } 2187 }); 2188 } else { 2189 setTimeout(function() { 2190 showPopup(); 2191 }, basel_settings.popup_delay); 2192 } 2193 } 2194 }, 2195 2196 productVideo: function() { 2197 $('.product-video-button a').magnificPopup({ 2198 tClose : basel_settings.close, 2199 tLoading : basel_settings.loading, 2200 type : 'iframe', 2201 iframe : { 2202 markup : '<div class="mfp-iframe-scaler mfp-with-anim">' + 2203 '<div class="mfp-close"></div>' + 2204 '<iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe>' + 2205 '</div>', 2206 patterns: { 2207 youtube: { 2208 index: 'youtube.com/', 2209 id : 'v=', 2210 src : '//www.youtube.com/embed/%id%?rel=0&autoplay=1' 2211 } 2212 } 2213 }, 2214 mainClass : 'mfp-fade', 2215 removalDelay : 500, 2216 preloader : false, 2217 disableOn : false, 2218 fixedContentPos: false, 2219 callbacks : { 2220 beforeOpen: function() { 2221 this.st.mainClass = baselTheme.popupEffect; 2222 } 2223 } 2224 }); 2225 }, 2226 2227 product360Button: function() { 2228 $('.product-360-button a').magnificPopup({ 2229 tClose : basel_settings.close, 2230 tLoading : basel_settings.loading, 2231 type : 'inline', 2232 removalDelay : 500, 2233 disableOn : false, 2234 preloader : false, 2235 fixedContentPos: false, 2236 callbacks : { 2237 beforeOpen: function() { 2238 this.st.mainClass = baselTheme.popupEffect; 2239 }, 2240 open : function() { 2241 baselThemeModule.$window.on('resize'); 2242 } 2243 } 2244 }); 2245 }, 2246 2247 cookiesPopup: function() { 2248 var cookies_version = basel_settings.cookies_version; 2249 if (Cookies.get('basel_cookies_' + cookies_version) === 'accepted') { 2250 return; 2251 } 2252 var popup = $('.basel-cookies-popup'); 2253 2254 setTimeout(function() { 2255 popup.addClass('popup-display'); 2256 popup.on('click', '.cookies-accept-btn', function(e) { 2257 e.preventDefault(); 2258 acceptCookies(); 2259 }); 2260 }, 2500); 2261 2262 var acceptCookies = function() { 2263 popup.removeClass('popup-display').addClass('popup-hide'); 2264 Cookies.set('basel_cookies_' + cookies_version, 'accepted', { 2265 expires: 60, 2266 path : '/' 2267 }); 2268 }; 2269 }, 2270 2271 googleMap: function() { 2272 var gmap = $('.google-map-container-with-content'); 2273 2274 baselThemeModule.$window.on('resize', function() { 2275 gmap.css({ 2276 'height': gmap.find('.basel-google-map.with-content').outerHeight() 2277 }); 2278 }); 2279 2280 }, 2281 2282 woocommerceWrappTable: function() { 2283 var wooTable = $('.woocommerce .shop_table:not(.wishlist_table)'); 2284 var cartTotals = $('.woocommerce .cart_totals table'); 2285 wooTable.wrap('<div class=\'responsive-table\'></div>'); 2286 cartTotals.wrap('<div class=\'responsive-table\'></div>'); 2287 }, 2288 2289 menuSetUp: function() { 2290 var mainMenu = $('.basel-navigation').find('ul.menu'), 2291 openedClass = 'item-menu-opened'; 2292 2293 mainMenu.off('click').on('click', ' > .item-event-click.menu-item-has-children > a', function(e) { 2294 var $this = $(this); 2295 e.preventDefault(); 2296 if (!$this.parent().hasClass(openedClass)) { 2297 $('.' + openedClass).removeClass(openedClass); 2298 } 2299 $this.parent().toggleClass(openedClass); 2300 }); 2301 2302 baselThemeModule.$document.on('click', function(e) { 2303 var target = e.target; 2304 if ($('.' + openedClass).length > 0 && !$(target).is('.item-event-hover') && !$(target).parents().is('.item-event-hover') && !$(target).parents().is('.' + openedClass + '')) { 2305 mainMenu.find('.' + openedClass + '').removeClass(openedClass); 2306 return false;
2307 } 2308 }); 2309 2310 var menuForIPad = function() { 2311 if (baselThemeModule.windowWidth <= 1024) { 2312 mainMenu.find(' > .item-event-hover').each(function() { 2313 $(this).data('original-event', 'hover').removeClass('item-event-hover').addClass('item-event-click'); 2314 }); 2315 } else { 2316 mainMenu.find(' > .item-event-click').each(function() { 2317 var $this = $(this); 2318 if ($this.data('original-event') === 'hover') { 2319 $this.removeClass('item-event-click').addClass('item-event-hover'); 2320 } 2321 }); 2322 } 2323 }; 2324 2325 baselThemeModule.$window.on('resize', menuForIPad); 2326 }, 2327 2328 menuOffsets: function() { 2329 var $window = baselThemeModule.$window, 2330 $header = $('.main-header'), 2331 mainMenu = $('.main-nav').find('ul.menu'); 2332 2333 mainMenu.on('mouseenter mousemove', ' > li', function() { 2334 setOffset($(this)); 2335 }); 2336 2337 var setOffset = function(li) { 2338 var dropdown = li.find(' > .sub-menu-dropdown'), 2339 siteWrapper = $('.website-wrapper'); 2340 2341 dropdown.attr('style', ''); 2342 2343 var dropdownWidth = dropdown.outerWidth(), 2344 dropdownOffset = dropdown.offset(), 2345 screenWidth = $window.width(), 2346 bodyRight = siteWrapper.outerWidth() + siteWrapper.offset().left, 2347 viewportWidth = (baselThemeModule.$body.hasClass('wrapper-boxed') || baselThemeModule.$body.hasClass('wrapper-boxed-small')) ? bodyRight : screenWidth; 2348 2349 if (!dropdownWidth || !dropdownOffset) { 2350 return; 2351 } 2352 2353 if (baselThemeModule.$body.hasClass('rtl') && dropdownOffset.left <= 0 && li.hasClass('menu-item-design-sized') && !$header.hasClass('header-vertical')) { 2354 // If right point is not in the viewport 2355 var toLeft = -dropdownOffset.left; 2356 2357 dropdown.css({ 2358 right: -toLeft - 10 2359 }); 2360 } else if (dropdownOffset.left + dropdownWidth >= viewportWidth && li.hasClass('menu-item-design-sized') && !$header.hasClass('header-vertical')) { 2361 // If right point is not in the viewport 2362 var toRight = dropdownOffset.left + dropdownWidth - viewportWidth; 2363 2364 dropdown.css({ 2365 left: -toRight - 10 2366 }); 2367 } 2368 2369 // Vertical header fit 2370 if ($header.hasClass('header-vertical')) { 2371 var bottom = dropdown.offset().top + dropdown.outerHeight(), 2372 viewportBottom = $window.scrollTop() + $window.outerHeight(); 2373 2374 if (bottom > viewportBottom) { 2375 dropdown.css({ 2376 top: viewportBottom - bottom - 10 2377 }); 2378 } 2379 } 2380 }; 2381 2382 // lis.each(function() { 2383 // setOffset($(this)); 2384 // $(this).addClass('with-offsets'); 2385 // }); 2386 }, 2387 2388 onePageMenu: function() { 2389 var scrollToRow = function(hash) { 2390 var row = $('#' + hash); 2391 2392 if (row.length < 1) { 2393 return; 2394 } 2395 2396 var position = row.offset().top; 2397 2398 $('html, body').stop().animate({ 2399 scrollTop: position - basel_settings.one_page_menu_offset 2400 }, 800, function() { 2401 activeMenuItem(hash); 2402 }); 2403 }; 2404 2405 var activeMenuItem = function(hash) { 2406 var itemHash; 2407 $('.onepage-link').each(function() { 2408 var $this = $(this); 2409 itemHash = $this.find('> a').attr('href').split('#')[1]; 2410 2411 if (itemHash == hash) { 2412 $('.onepage-link').removeClass('current-menu-item'); 2413 $this.addClass('current-menu-item'); 2414 } 2415 }); 2416 }; 2417 2418 baselThemeModule.$body.on('click', '.onepage-link > a', function(e) { 2419 var $this = $(this), 2420 hash = $this.attr('href').split('#')[1]; 2421 2422 if ($('#' + hash).length < 1) { 2423 return; 2424 } 2425 2426 e.preventDefault(); 2427 2428 scrollToRow(hash); 2429 2430 // close mobile menu 2431 $('.basel-close-side').trigger('click'); 2432 }); 2433 2434 if ($('.onepage-link').length > 0) { 2435 $('.entry-content > .vc_section, .entry-content > .vc_row').waypoint(function() { 2436 var $this = $($(this)[0].element); 2437 var hash = $this.attr('id'); 2438 activeMenuItem(hash); 2439 }, {offset: 0}); 2440 2441 // URL contains hash 2442 var locationHash = window.location.hash.split('#')[1]; 2443 2444 if (window.location.hash.length > 1) { 2445 setTimeout(function() { 2446 scrollToRow(locationHash); 2447 }, 500); 2448 } 2449 } 2450 }, 2451 2452 mobileNavigation: function() { 2453 var body = baselThemeModule.$body, 2454 mobileNav = $('.mobile-nav'), 2455 dropDownCat = $('.mobile-nav .site-mobile-menu .menu-item-has-children'), 2456 elementIcon = '<span class="icon-sub-menu"></span>'; 2457 2458 dropDownCat.append(elementIcon); 2459 2460 // Fix for menu. 2461 body.on('click', '.mobile-nav-icon, .basel-show-categories', function() { 2462 baselThemeModule.$document.trigger('basel-images-loaded'); 2463 }); 2464 2465 mobileNav.on('click', '.icon-sub-menu', function(e) { 2466 e.preventDefault(); 2467 var $this = $(this); 2468 2469 if ($this.parent().hasClass('opener-page')) { 2470 $this.parent().removeClass('opener-page').find('> ul').slideUp(200);
2471 $this.parent().removeClass('opener-page').find('.sub-menu-dropdown .container > ul').slideUp(200); 2472 $this.parent().find('> .icon-sub-menu').removeClass('up-icon'); 2473 } else { 2474 $this.parent().addClass('opener-page').find('> ul').slideDown(200); 2475 $this.parent().addClass('opener-page').find('.sub-menu-dropdown .container > ul').slideDown(200); 2476 $this.parent().find('> .icon-sub-menu').addClass('up-icon'); 2477 } 2478 }); 2479 2480 body.on('click', '.mobile-nav-icon', function() { 2481 if (body.hasClass('act-mobile-menu')) { 2482 closeMenu(); 2483 } else { 2484 openMenu(); 2485 } 2486 }); 2487 2488 body.on('click touchstart', '.basel-close-side, .basel-close-sidebar-btn', function() { 2489 closeMenu(); 2490 }); 2491 2492 body.on('click', '.mobile-nav .login-side-opener', function() { 2493 closeMenu(); 2494 }); 2495 2496 function openMenu() { 2497 body.addClass('act-mobile-menu'); 2498 } 2499 2500 function closeMenu() { 2501 body.removeClass('act-mobile-menu'); 2502 } 2503 }, 2504 2505 simpleDropdown: function() { 2506 $('.input-dropdown-inner').each(function() { 2507 var dd = $(this); 2508 var btn = dd.find('> a'); 2509 var input = dd.find('> input'); 2510 var list = dd.find('> ul'); 2511 2512 baselThemeModule.$document.on('click', function(e) { 2513 var target = e.target; 2514 if (dd.hasClass('dd-shown') && !$(target).is('.input-dropdown-inner') && !$(target).parents().is('.input-dropdown-inner')) { 2515 hideList(); 2516 return false; 2517 } 2518 }); 2519 2520 btn.on('click', function(e) { 2521 e.preventDefault(); 2522 2523 if (dd.hasClass('dd-shown')) { 2524 hideList(); 2525 } else { 2526 showList(); 2527 } 2528 return false; 2529 }); 2530 2531 list.on('click', 'a', function(e) { 2532 e.preventDefault(); 2533 var $this = $(this); 2534 var value = $this.data('val'); 2535 var label = $this.text(); 2536 list.find('.current-item').removeClass('current-item'); 2537 $this.parent().addClass('current-item'); 2538 if (value != 0) { 2539 list.find('> li:first-child').show(); 2540 } else if (value == 0) { 2541 list.find('> li:first-child').hide(); 2542 } 2543 btn.text(label); 2544 input.val(value).trigger('cat_selected'); 2545 hideList(); 2546 }); 2547 2548 function showList() { 2549 dd.addClass('dd-shown'); 2550 list.slideDown(100); 2551 2552 if (typeof ($.fn.devbridgeAutocomplete) != 'undefined') { 2553 dd.parent().siblings('[type="text"]').devbridgeAutocomplete('hide'); 2554 } 2555 } 2556 2557 function hideList() { 2558 dd.removeClass('dd-shown'); 2559 list.slideUp(100); 2560 } 2561 }); 2562 }, 2563 2564 equalizeColumns: function() { 2565 $.fn.basel_equlize = function(options) { 2566 var settings = $.extend({ 2567 child: '' 2568 }, options); 2569 2570 var that = this; 2571 2572 if (!settings.child) { 2573 that = this.find(settings.child); 2574 } 2575 2576 var resize = function() { 2577 var maxHeight = 0; 2578 2579 that.each(function() { 2580 var $this = $(this); 2581 $this.attr('style', ''); 2582 if (baselThemeModule.windowWidth > 767 && $this.outerHeight() > maxHeight) { 2583 maxHeight = $this.outerHeight(); 2584 } 2585 }); 2586 2587 that.each(function() { 2588 $(this).css({ 2589 minHeight: maxHeight 2590 }); 2591 }); 2592 }; 2593 2594 baselThemeModule.$window.on('resize', function() { 2595 resize(); 2596 }); 2597 setTimeout(function() { 2598 resize(); 2599 }, 200); 2600 setTimeout(function() { 2601 resize(); 2602 }, 500); 2603 setTimeout(function() { 2604 resize(); 2605 }, 800); 2606 }; 2607 2608 $('.equal-columns').each(function() { 2609 $(this).basel_equlize({ 2610 child: '> [class*=col-]' 2611 }); 2612 }); 2613 }, 2614 2615 blogMasonry: function() { 2616 if (typeof ($.fn.isotope) == 'undefined' || typeof ($.fn.imagesLoaded) == 'undefined') { 2617 return; 2618 } 2619 var $container = $('.masonry-container'); 2620 2621 // initialize Masonry after all images have loaded 2622 $container.imagesLoaded(function() { 2623 $container.isotope({ 2624 gutter : 0, 2625 isOriginLeft: !baselThemeModule.$body.hasClass('rtl'), 2626 itemSelector: '.blog-design-masonry, .blog-design-mask, .masonry-item' 2627 }); 2628 }); 2629 2630 $('.masonry-filter').on('click', 'a', function(e) { 2631 e.preventDefault(); 2632 var $this = $(this); 2633 2634 setTimeout(function() { 2635 jQuery(document).trigger('basel-images-loaded'); 2636 }, 300); 2637 2638 $('.masonry-filter').find('.filter-active').removeClass('filter-active'); 2639 $this.addClass('filter-active'); 2640 var filterValue = $this.attr('data-filter'); 2641 $this.parents('.portfolio-filter').siblings('.masonry-container.basel-portfolio-holder').first().isotope({ 2642 filter: filterValue 2643 }); 2644 }); 2645 }, 2646 2647 blogLoadMore: function() { 2648 $('.basel-blog-load-more').on('click', function(e) { 2649 e.preventDefault(); 2650 2651 var $this = $(this),
2652 holderId = $this.data('holder-id'), 2653 holder = $('.basel-blog-holder#' + holderId), 2654 atts = holder.data('atts'), 2655 paged = holder.data('paged'); 2656 2657 $this.addClass('loading'); 2658 2659 $.ajax({ 2660 url : basel_settings.ajaxurl, 2661 data : { 2662 atts : atts, 2663 paged : paged, 2664 action: 'basel_get_blog_shortcode' 2665 }, 2666 dataType: 'json', 2667 method : 'POST', 2668 success : function(data) { 2669 baselThemeModule.removeDuplicatedStylesFromHTML(data.items, function(html) { 2670 var $items = $(html); 2671 2672 if ($items) { 2673 if (holder.hasClass('masonry-container')) { 2674 holder.append($items).isotope('appended', $items); 2675 holder.imagesLoaded().progress(function() { 2676 holder.isotope('layout'); 2677 }); 2678 } else { 2679 holder.append($items); 2680 } 2681 2682 holder.data('paged', paged + 1); 2683 } 2684 2685 if (data.status === 'no-more-posts') { 2686 $this.hide(); 2687 } 2688 }); 2689 }, 2690 error : function() { 2691 console.log('ajax error'); 2692 }, 2693 complete: function() { 2694 $this.removeClass('loading'); 2695 } 2696 }); 2697 }); 2698 }, 2699 2700 productsLoadMore: function() { 2701 var process = false, 2702 intervalID; 2703 2704 $('.basel-products-element').each(function() { 2705 var $this = $(this), 2706 cache = [], 2707 inner = $this.find('.basel-products-holder'); 2708 2709 if (!inner.hasClass('pagination-arrows') && !inner.hasClass('pagination-more-btn')) { 2710 return; 2711 } 2712 2713 cache[1] = { 2714 items : inner.html(), 2715 status: 'have-posts' 2716 }; 2717 2718 $this.on('recalc', function() { 2719 calc(); 2720 }); 2721 2722 if (inner.hasClass('pagination-arrows')) { 2723 baselThemeModule.$window.on('resize', function() { 2724 calc(); 2725 }); 2726 } 2727 2728 var calc = function() { 2729 var height = inner.outerHeight(); 2730 $this.stop().css({minHeight: height}); 2731 }; 2732 2733 var body = baselThemeModule.$body, 2734 btnWrap = $this.find('.products-footer'), 2735 btnLeft = btnWrap.find('.basel-products-load-prev'), 2736 btnRight = btnWrap.find('.basel-products-load-next'), 2737 loadWrapp = $this.find('.basel-products-loader'), 2738 scrollTop, 2739 holderTop, 2740 btnLeftOffset, 2741 btnRightOffset, 2742 holderBottom, 2743 holderHeight, 2744 holderWidth, 2745 btnsHeight, 2746 offsetArrow = 50, 2747 offset, 2748 windowWidth; 2749 2750 if (body.hasClass('rtl')) { 2751 btnLeft = btnRight; 2752 btnRight = btnWrap.find('.basel-products-load-prev'); 2753 } 2754 2755 baselThemeModule.$window.on('scroll', function() { 2756 buttonsPos(); 2757 }); 2758 2759 setTimeout(function() { 2760 buttonsPos(); 2761 }, 500); 2762 2763 function buttonsPos() { 2764 offset = baselThemeModule.$window.height() / 2; 2765 windowWidth = baselThemeModule.$window.outerWidth(true) + 17; 2766 holderWidth = $this.outerWidth(true) + 10; 2767 scrollTop = baselThemeModule.$window.scrollTop(); 2768 holderTop = $this.offset().top - offset; 2769 btnLeftOffset = $this.offset().left - offsetArrow; 2770 btnRightOffset = btnLeftOffset + holderWidth + offsetArrow; 2771 btnsHeight = btnLeft.outerHeight(); 2772 holderHeight = $this.height() - 50 - btnsHeight; 2773 holderBottom = holderTop + holderHeight; 2774 2775 if (windowWidth <= 1047 && windowWidth >= 992 || windowWidth <= 825 && windowWidth >= 768) { 2776 btnLeftOffset += 18; 2777 btnRightOffset -= 18; 2778 } 2779 2780 if (windowWidth < 768 || body.hasClass('wrapper-boxed') || body.hasClass('wrapper-boxed-small') || $('.main-header').hasClass('header-vertical')) { 2781 btnLeftOffset += 51; 2782 btnRightOffset -= 51; 2783 } 2784 2785 btnLeft.css({ 2786 'left': btnLeftOffset + 'px' 2787 }); 2788 2789 btnRight.css({ 2790 'left': btnRightOffset + 'px' 2791 }); 2792 2793 if (scrollTop < holderTop || scrollTop > holderBottom) { 2794 btnWrap.removeClass('show-arrow'); 2795 loadWrapp.addClass('hidden-loader'); 2796 } else { 2797 btnWrap.addClass('show-arrow'); 2798 loadWrapp.removeClass('hidden-loader'); 2799 } 2800 } 2801 2802 $this.find('.basel-products-load-prev, .basel-products-load-next').on('click', function(e) { 2803 e.preventDefault(); 2804 var $this = $(this); 2805 2806 if (process || $this.hasClass('disabled')) { 2807 return; 2808 } 2809 process = true; 2810 2811 clearInterval(intervalID); 2812 2813 var holder = $this.parent().siblings('.basel-products-holder'), 2814 next = $this.parent().find('.basel-products-load-next'), 2815 prev = $this.parent().find('.basel-products-load-prev'), 2816 atts = holder.data('atts'), 2817 paged = holder.attr('data-paged'), 2818 ajaxurl = basel_settings.ajaxurl, 2819 action = 'basel_get_products_shortcode', 2820 method = 'POST'; 2821 2822 if ($this.hasClass('basel-products-load-prev')) { 2823 if (paged < 2) { 2824 return; 2825 } 2826 paged = paged - 2; 2827 } 2828 2829 paged++; 2830 2831 loadProducts('arrows', atts, ajaxurl, action, method, paged, holder, $this, cache, function(data) { 2832 holder.addClass('basel-animated-products'); 2833 2834 if (data.items) { 2835 holder.html(data.items).attr('data-paged', paged); 2836 holder.imagesLoaded().progress(function() { 2837 holder.parent().trigger('recalc'); 2838 }); 2839 2840 baselThemeModule.$document.trigger('basel-images-loaded'); 2841 2842 baselThemeModule.btnsToolTips(); 2843 baselThemeModule.swatchesLimit(); 2844 } 2845 2846 if (baselThemeModule.windowWidth < 768) { 2847 $('html, body').stop().animate({ 2848 scrollTop: holder.offset().top - 150 2849 }, 400); 2850 } 2851 2852 var iter = 0; 2853 intervalID = setInterval(function() { 2854 holder.find('.product-grid-item').eq(iter).addClass('basel-animated'); 2855 iter++; 2856 }, 100); 2857 2858 if (paged > 1) { 2859 prev.removeClass('disabled'); 2860 } else { 2861 prev.addClass('disabled'); 2862 } 2863 2864 if (data.status === 'no-more-posts') { 2865 next.addClass('disabled'); 2866 } else { 2867 next.removeClass('disabled'); 2868 } 2869 }); 2870 2871 }); 2872 }); 2873 2874 baselThemeModule.clickOnScrollButton(baselTheme.shopLoadMoreBtn, false); 2875 2876 baselThemeModule.$document.off('click', '.basel-products-load-more').on('click', '.basel-products-load-more', function(e) { 2877 e.preventDefault(); 2878 2879 if (process) { 2880 return; 2881 } 2882 process = true; 2883 2884 var $this = $(this), 2885 holder = $this.parent().siblings('.basel-products-holder'), 2886 source = holder.data('source'), 2887 action = 'basel_get_products_' + source, 2888 ajaxurl = basel_settings.ajaxurl, 2889 method = 'POST', 2890 atts = holder.data('atts'), 2891 paged = holder.data('paged'); 2892 2893 paged++; 2894 2895 if (source === 'main_loop') { 2896 ajaxurl = $this.attr('href'); 2897 method = 'GET'; 2898 } 2899 2900 loadProducts('load-more', atts, ajaxurl, action, method, paged, holder, $this, [], function(data) { 2901 if (data.items) { 2902 if (holder.hasClass('grid-masonry')) { 2903 isotopeAppend(holder, data.items); 2904 } else { 2905 holder.append(data.items); 2906 } 2907 2908 holder.imagesLoaded().progress(function() { 2909 baselThemeModule.clickOnScrollButton(baselTheme.shopLoadMoreBtn, true); 2910 }); 2911 2912 baselThemeModule.$document.trigger('basel-images-loaded'); 2913 2914 holder.data('paged', paged); 2915 2916 baselThemeModule.btnsToolTips(); 2917 baselThemeModule.swatchesLimit(); 2918 } 2919 2920 if (source === 'main_loop') { 2921 $this.attr('href', data.nextPage); 2922 if (data.status === 'no-more-posts') { 2923 $this.hide().remove(); 2924 } 2925 } 2926 2927 if (data.status === 'no-more-posts') { 2928 $this.hide().remove(); 2929 } 2930 }); 2931 }); 2932 2933 function removeURLParameter(url, parameter) { 2934 var urlparts = url.split('?'); 2935 2936 if (urlparts.length >= 2) { 2937 var prefix = encodeURIComponent(parameter) + '='; 2938 var pars = urlparts[1].split(/[&;]/g); 2939 2940 for (var i = pars.length; i-- > 0;) { 2941 if (pars[i].lastIndexOf(prefix, 0) !== -1) { 2942 pars.splice(i, 1); 2943 } 2944 } 2945 2946 return urlparts[0] + (pars.length > 0 ? '?' + pars.join('&') : ''); 2947 } 2948 2949 return url; 2950 } 2951 2952 var loadProducts = function(btnType, atts, ajaxurl, action, method, paged, holder, btn, cache, callback) { 2953 var data = { 2954 atts : atts, 2955 paged : paged, 2956 action : action, 2957 woo_ajax: 1 2958 }; 2959 2960 ajaxurl = removeURLParameter(ajaxurl, 'loop'); 2961 ajaxurl = removeURLParameter(ajaxurl, 'woo_ajax'); 2962 2963 if (cache[paged]) { 2964 holder.addClass('loading'); 2965 setTimeout(function() { 2966 callback(cache[paged]); 2967 holder.removeClass('loading'); 2968 process = false;
2969 }, 300); 2970 return; 2971 } 2972 2973 holder.addClass('loading').parent().addClass('element-loading'); 2974 2975 if (btnType === 'arrows') { 2976 holder.addClass('loading').parent().addClass('element-loading'); 2977 } 2978 2979 if (action === 'basel_get_products_main_loop') { 2980 var loop = holder.find('.product').last().data('loop'); 2981 data = { 2982 loop : loop, 2983 woo_ajax: 1 2984 }; 2985 } 2986 2987 btn.addClass('loading'); 2988 2989 $.ajax({ 2990 url : ajaxurl, 2991 data : data, 2992 dataType: 'json', 2993 method : method, 2994 success : function(data) { 2995 baselThemeModule.removeDuplicatedStylesFromHTML(data.items, function(html) { 2996 data.items = html; 2997 cache[paged] = data; 2998 callback(data); 2999 3000 if ('yes' === basel_settings.load_more_button_page_url_opt && data.currentPage){ 3001 window.history.pushState('', '', data.currentPage + window.location.search); 3002 $('.woocommerce-breadcrumb').replaceWith(data.breadcrumbs); 3003 } 3004 }); 3005 }, 3006 error : function() { 3007 console.log('ajax error'); 3008 }, 3009 complete: function() { 3010 holder.removeClass('loading').parent().removeClass('element-loading'); 3011 btn.removeClass('loading'); 3012 process = false; 3013 baselThemeModule.compare(); 3014 baselThemeModule.countDownTimer(); 3015 } 3016 }); 3017 }; 3018 3019 var isotopeAppend = function(el, items) { 3020 var $items = $(items); 3021 el.append($items).isotope('appended', $items); 3022 el.isotope('layout'); 3023 setTimeout(function() { 3024 el.isotope('layout'); 3025 }, 100); 3026 el.imagesLoaded().progress(function() { 3027 el.isotope('layout'); 3028 }); 3029 }; 3030 3031 }, 3032 3033 clickOnScrollButton: function(btnClass) { 3034 if (typeof $.fn.waypoint != 'function') { 3035 return; 3036 } 3037 3038 var $btn = $(btnClass); 3039 if ($btn.length === 0) { 3040 return; 3041 } 3042 3043 $btn.trigger('wd-waypoint-destroy'); 3044 3045 var waypoint = new Waypoint({ 3046 element: $btn[0], 3047 handler: function() { 3048 $btn.trigger('click'); 3049 }, 3050 offset : '100%' 3051 }); 3052 3053 $btn.data('waypoint-inited', true).off('wd-waypoint-destroy').on('wd-waypoint-destroy', function() { 3054 if ($btn.data('waypoint-inited')) { 3055 waypoint.destroy(); 3056 $btn.data('waypoint-inited', false); 3057 } 3058 }); 3059 }, 3060 3061 productsTabs: function() { 3062 var process = false; 3063 3064 $('.basel-products-tabs').each(function() { 3065 var $this = $(this), 3066 $inner = $this.find('.basel-tab-content'), 3067 cache = []; 3068 3069 if ($inner.find('.owl-carousel').length < 1) { 3070 cache[0] = { 3071 html: $inner.html() 3072 }; 3073 } 3074 3075 $this.find('.products-tabs-title li').on('click', function(e) { 3076 e.preventDefault(); 3077 3078 var $this = $(this), 3079 atts = $this.data('atts'), 3080 index = $this.index(); 3081 3082 if (process || $this.hasClass('active-tab-title')) { 3083 return; 3084 } 3085 process = true; 3086 3087 loadTab(atts, index, $inner, $this, cache, function(data) { 3088 if (data.html) { 3089 baselThemeModule.removeDuplicatedStylesFromHTML(data.html, function(html) { 3090 $inner.html(html); 3091 3092 baselThemeModule.$document.trigger('basel-images-loaded'); 3093 baselThemeModule.$document.trigger('basel-products-tabs-loaded'); 3094 3095 $inner.removeClass('loading').parent().removeClass('element-loading'); 3096 $this.removeClass('loading'); 3097 3098 baselThemeModule.btnsToolTips(); 3099 baselThemeModule.shopMasonry(); 3100 baselThemeModule.productLoaderPosition(); 3101 baselThemeModule.productsLoadMore(); 3102 baselThemeModule.swatchesLimit(); 3103 }); 3104 } 3105 }); 3106 3107 }); 3108 3109 var $nav = $this.find('.tabs-navigation-wrapper'), 3110 $subList = $nav.find('ul'); 3111 3112 $nav.on('click', '.open-title-menu', function() { 3113 var $btn = $(this); 3114 3115 if ($subList.hasClass('list-shown')) { 3116 $btn.removeClass('toggle-active'); 3117 $subList.removeClass('list-shown'); 3118 } else { 3119 $btn.addClass('toggle-active'); 3120 $subList.addClass('list-shown'); 3121 setTimeout(function() { 3122 baselThemeModule.$body.one('click', function(e) { 3123 var target = e.target; 3124 if (!$(target).is('.tabs-navigation-wrapper') && !$(target).parents().is('.tabs-navigation-wrapper')) { 3125 $btn.removeClass('toggle-active'); 3126 $subList.removeClass('list-shown'); 3127 return false;
3128 } 3129 }); 3130 }, 10); 3131 } 3132 }) 3133 .on('click', 'li', function() { 3134 var $btn = $nav.find('.open-title-menu'), 3135 text = $(this).text(); 3136 3137 if ($subList.hasClass('list-shown')) { 3138 $btn.removeClass('toggle-active').text(text); 3139 $subList.removeClass('list-shown'); 3140 } 3141 }); 3142 }); 3143 3144 var loadTab = function(atts, index, holder, btn, cache, callback) { 3145 btn.parent().find('.active-tab-title').removeClass('active-tab-title'); 3146 btn.addClass('active-tab-title'); 3147 3148 if (cache[index]) { 3149 holder.addClass('loading'); 3150 setTimeout(function() { 3151 process = false; 3152 callback(cache[index]); 3153 holder.removeClass('loading'); 3154 }, 300); 3155 return; 3156 } 3157 3158 holder.addClass('loading').parent().addClass('element-loading'); 3159 3160 btn.addClass('loading'); 3161 3162 $.ajax({ 3163 url : basel_settings.ajaxurl, 3164 data : { 3165 atts : atts, 3166 action: 'basel_get_products_tab_shortcode' 3167 }, 3168 dataType: 'json', 3169 method : 'POST', 3170 success : function(data) { 3171 process = false; 3172 cache[index] = data; 3173 callback(data); 3174 }, 3175 error : function() { 3176 console.log('ajax error'); 3177 }, 3178 complete: function() { 3179 process = false; 3180 baselThemeModule.compare(); 3181 } 3182 }); 3183 }; 3184 3185 }, 3186 3187 portfolioLoadMore: function() { 3188 if (typeof $.fn.waypoint != 'function') { 3189 return; 3190 } 3191 3192 var waypoint = $('.basel-portfolio-load-more.load-on-scroll').waypoint(function() { 3193 $('.basel-portfolio-load-more.load-on-scroll').trigger('click'); 3194 }, {offset: '100%'}), 3195 process = false; 3196 3197 $('.basel-portfolio-load-more').on('click', function(e) { 3198 e.preventDefault(); 3199 var $this = $(this); 3200 3201 if (process || $this.hasClass('no-more-posts')) { 3202 return; 3203 } 3204 3205 process = true; 3206 3207 var holder = $this.parent().parent().find('.basel-portfolio-holder'), 3208 source = holder.data('source'), 3209 action = 'basel_get_portfolio_' + source, 3210 ajaxurl = basel_settings.ajaxurl, 3211 dataType = 'json', 3212 method = 'POST', 3213 timeout, 3214 atts = holder.data('atts'), 3215 paged = holder.data('paged'); 3216 3217 $this.addClass('loading'); 3218 3219 var data = { 3220 atts : atts, 3221 paged : paged, 3222 action: action 3223 }; 3224 3225 if (source === 'main_loop') { 3226 ajaxurl = $this.attr('href'); 3227 method = 'GET'; 3228 data = {}; 3229 } 3230 3231 $.ajax({ 3232 url : ajaxurl, 3233 data : data, 3234 dataType: dataType, 3235 method : method, 3236 success : function(data) { 3237 baselThemeModule.removeDuplicatedStylesFromHTML(data.items, function(html) { 3238 var items = $(html); 3239 3240 if (items) { 3241 if (holder.hasClass('masonry-container')) { 3242 holder.append(items).isotope('appended', items); 3243 holder.imagesLoaded().progress(function() { 3244 holder.isotope('layout'); 3245 3246 clearTimeout(timeout); 3247 3248 timeout = setTimeout(function() { 3249 waypoint = $('.basel-portfolio-load-more.load-on-scroll').waypoint(function() { 3250 $('.basel-portfolio-load-more.load-on-scroll').trigger('click'); 3251 }, {offset: '100%'}); 3252 }, 1000); 3253 }); 3254 } else { 3255 holder.append(items); 3256 } 3257 3258 holder.data('paged', paged + 1); 3259 3260 $this.attr('href', data.nextPage); 3261 } 3262 3263 baselThemeModule.mfpPopup(); 3264 3265 if (data.status === 'no-more-posts') { 3266 $this.addClass('no-more-posts'); 3267 $this.hide(); 3268 } 3269 }); 3270 }, 3271 error : function() { 3272 console.log('ajax error'); 3273 }, 3274 complete: function() { 3275 $this.removeClass('loading'); 3276 process = false; 3277 } 3278 }); 3279 }); 3280 }, 3281 3282 shopMasonry: function() { 3283 if (typeof ($.fn.isotope) == 'undefined' || typeof ($.fn.imagesLoaded) == 'undefined') { 3284 return; 3285 } 3286 var $container = $('.elements-grid.grid-masonry'); 3287 3288 $container.imagesLoaded(function() { 3289 $container.isotope({ 3290 isOriginLeft: !baselThemeModule.$body.hasClass('rtl'), 3291 itemSelector: '.category-grid-item, .product-grid-item' 3292 }); 3293 }); 3294 3295 // Categories masonry 3296 function initMasonry() { 3297 var $catsContainer = $('.categories-masonry'); 3298 var colWidth = ($catsContainer.hasClass('categories-style-masonry')) ? '.category-grid-item' : '.col-md-3.category-grid-item'; 3299 $catsContainer.imagesLoaded(function() { 3300 $catsContainer.packery({ 3301 resizable : false, 3302 isOriginLeft: !baselThemeModule.$body.hasClass('rtl'), 3303 packery : { 3304 gutter : 0, 3305 columnWidth: colWidth 3306 }, 3307 itemSelector: '.category-grid-item' 3308 }); 3309 }); 3310 } 3311 3312 baselThemeModule.$window.on('resize', function() { 3313 initMasonry(); 3314 }); 3315 initMasonry(); 3316 }, 3317 3318 sidebarMenu: function() { 3319 var heightMegaMenu = $('.widget_nav_mega_menu').height(); 3320 var heightMegaNavigation = $('.categories-menu-dropdown').height(); 3321 var subMenuHeight = $('.widget_nav_mega_menu ul > li.menu-item-design-sized >
3321 .sub-menu-dropdown, .widget_nav_mega_menu ul > li.menu-item-design-full-width > .sub-menu-dropdown'); 3322 var megaNavigationHeight = $('.categories-menu-dropdown ul > li.menu-item-design-sized > .sub-menu-dropdown, .categories-menu-dropdown ul > li.menu-item-design-full-width > .sub-menu-dropdown'); 3323 subMenuHeight.css( 3324 'min-height', heightMegaMenu + 'px' 3325 ); 3326 3327 megaNavigationHeight.css( 3328 'min-height', heightMegaNavigation + 'px' 3329 ); 3330 }, 3331 3332 productImages: function() { 3333 var currentImage, 3334 $productGallery = $('.woocommerce-product-gallery'), 3335 $mainImages = $('.woocommerce-product-gallery__wrapper'), 3336 $thumbs = $productGallery.find('.thumbnails'), 3337 gallery = $('.photoswipe-images'), 3338 PhotoSwipeTrigger = '.basel-show-product-gallery', 3339 galleryType = 'photo-swipe'; 3340 3341 $thumbs.addClass('thumbnails-ready'); 3342 3343 if ($productGallery.hasClass('image-action-popup')) { 3344 PhotoSwipeTrigger += ', .woocommerce-product-gallery__image a'; 3345 } 3346 3347 $productGallery.on('click', '.woocommerce-product-gallery__image a', function(e) { 3348 e.preventDefault(); 3349 }); 3350 3351 $productGallery.on('click', PhotoSwipeTrigger, function(e) { 3352 e.preventDefault(); 3353 3354 currentImage = $(this).attr('href'); 3355 3356 if (galleryType === 'magnific') { 3357 $.magnificPopup.open({ 3358 type : 'image', 3359 tClose : basel_settings.close, 3360 tLoading: basel_settings.loading, 3361 image : { 3362 verticalFit: false 3363 }, 3364 items : getProductItems(), 3365 gallery : { 3366 enabled : true, 3367 navigateByImgClick: false 3368 } 3369 }, 0); 3370 } 3371 3372 if (galleryType === 'photo-swipe') { 3373 var items = getProductItems(); 3374 3375 baselThemeModule.callPhotoSwipe(getCurrentGalleryIndex(e), items); 3376 } 3377 }); 3378 3379 $thumbs.on('click', '.image-link', function(e) { 3380 e.preventDefault(); 3381 }); 3382 3383 gallery.each(function() { 3384 var $this = $(this); 3385 $this.on('click', 'a', function(e) { 3386 e.preventDefault(); 3387 var index = $(e.currentTarget).data('index') - 1; 3388 var items = getGalleryItems($this, []); 3389 baselThemeModule.callPhotoSwipe(index, items); 3390 }); 3391 }); 3392 3393 var getCurrentGalleryIndex = function(e) { 3394 if ($mainImages.hasClass('owl-carousel')) { 3395 return $mainImages.find('.owl-item.active').index(); 3396 } else { 3397 return $(e.currentTarget).parent().index(); 3398 } 3399 }; 3400 3401 var getProductItems = function() { 3402 var items = []; 3403 3404 $mainImages.find('figure a img').each(function() { 3405 var $this = $(this), 3406 src = $this.attr('data-large_image'), 3407 width = $this.attr('data-large_image_width'), 3408 height = $this.attr('data-large_image_height'), 3409 caption = $this.data('caption'); 3410 3411 items.push({ 3412 src : src, 3413 w : width, 3414 h : height, 3415 title: (basel_settings.product_images_captions === 'yes') ? caption : false 3416 }); 3417 3418 }); 3419 3420 return items; 3421 }; 3422 3423 var getGalleryItems = function($gallery, items) { 3424 var src, width, height, title; 3425 3426 $gallery.find('a').each(function() { 3427 var $this = $(this); 3428 src = $this.attr('href'); 3429 width = $this.data('width'); 3430 height = $this.data('height'); 3431 title = $this.attr('title'); 3432 if (!isItemInArray(items, src)) { 3433 items.push({ 3434 src : src, 3435 w : width, 3436 h : height, 3437 title: title 3438 }); 3439 } 3440 }); 3441 3442 return items; 3443 }; 3444 3445 var isItemInArray = function(items, src) { 3446 var i; 3447 for (i = 0; i < items.length; i++) { 3448 if (items[i].src === src) { 3449 return true; 3450 } 3451 } 3452 3453 return false; 3454 }; 3455 }, 3456 3457 callPhotoSwipe: function(index, items) { 3458 var pswpElement = document.querySelectorAll('.pswp')[0]; 3459 3460 if (baselThemeModule.$body.hasClass('rtl')) { 3461 index = items.length - index - 1; 3462 items = items.reverse(); 3463 } 3464 3465 // define options (if needed) 3466 var options = { 3467 index : index, 3468 closeOnScroll: basel_settings.photoswipe_close_on_scroll, 3469 shareButtons : [ 3470 { 3471 id : 'facebook', 3472 label: basel_settings.share_fb, 3473 url : 'https://www.facebook.com/sharer/sharer.php?u={{url}}' 3474 }, 3475 { 3476 id : 'twitter', 3477 label: basel_settings.tweet, 3478 url : 'https://twitter.com/intent/tweet?text={{text}}&url={{url}}' 3479 }, 3480 { 3481 id : 'pinterest', 3482 label: basel_settings.pin_it, 3483 url : 'https://www.pinterest.com/pin/create/button/' + 3484 '?url={{url}}&media={{image_url}}&description={{text}}' 3485 }, 3486 { 3487 id : 'download', 3488 label : basel_settings.download_image, 3489 url : '{{raw_image_url}}', 3490 download: true 3491 } 3492 ] 3493 }; 3494 3495 // Initializes and opens PhotoSwipe 3496 var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options); 3497 gallery.init(); 3498 }, 3499 3500 productImagesGallery: function() { 3501 var $mainGallery = $('.woocommerce-product-gallery__wrapper:not(.quick-view-gallery)'); 3502 var $thumbs = $('.images .thumbnails'), 3503 $mainOwl = $('.woocommerce-product-gallery__wrapper'); 3504 3505 if (basel_settings.product_gallery.images_slider) { 3506 if (basel_settings.product_slider_auto_height === 'yes') { 3507 $('.product-images').imagesLoaded(function() { 3508 initMainGallery(); 3509 }); 3510 } else { 3511 initMainGallery(); 3512 } 3513 } 3514 3515 if (basel_settings.product_gallery.thumbs_slider.enabled && basel_settings.product_gallery.images_slider) { 3516 initThumbnailsMarkup(); 3517 if (basel_settings.product_gallery.thumbs_slider.position === 'left' && jQuery(window).width() > 991) { 3518 initThumbnailsVertical(); 3519 } else { 3520 initThumbnailsHorizontal(); 3521 } 3522 } 3523 3524 function initMainGallery() { 3525 $mainGallery.trigger('destroy.owl.carousel'); 3526 $mainGallery.addClass('owl-carousel').owlCarousel(baselTheme.mainCarouselArg); 3527 baselThemeModule.$document.trigger('basel-images-loaded'); 3528 } 3529 3530 function initThumbnailsMarkup() { 3531 var markup = ''; 3532 3533 $mainGallery.find('.woocommerce-product-gallery__image').each(function() { 3534 var $this = $(this); 3535 var image = $this.data('thumb'), 3536 alt = $this.find('a > img').attr('alt'), 3537 title = $this.find('a > img').attr('title'); 3538 3539 if (!title) { 3540 title = $this.find('a picture').attr('title'); 3541 } 3542 3543 markup += '<img alt="' + alt + '" title="' + title + '" src="' + image
3543+ '" />'; 3544 }); 3545 3546 if ($thumbs.hasClass('slick-slider')) { 3547 $thumbs.slick('unslick'); 3548 } else if ($thumbs.hasClass('owl-carousel')) { 3549 $thumbs.trigger('destroy.owl.carousel'); 3550 } 3551 3552 $thumbs.empty(); 3553 $thumbs.append(markup); 3554 3555 } 3556 3557 function initThumbnailsVertical() { 3558 if ($thumbs.length === 0) { 3559 return; 3560 } 3561 3562 $thumbs.slick({ 3563 slidesToShow : basel_settings.product_gallery.thumbs_slider.items.vertical_items, 3564 slidesToScroll : basel_settings.product_gallery.thumbs_slider.items.vertical_items, 3565 vertical : true, 3566 verticalSwiping: true, 3567 infinite : false 3568 }); 3569 3570 $thumbs.on('click', 'img', function() { 3571 var i = $(this).index(); 3572 $mainOwl.trigger('to.owl.carousel', i); 3573 }); 3574 3575 $mainOwl.on('changed.owl.carousel', function(e) { 3576 var i = e.item.index; 3577 $thumbs.slick('slickGoTo', i); 3578 $thumbs.find('.active-thumb').removeClass('active-thumb'); 3579 $thumbs.find('img').eq(i).addClass('active-thumb'); 3580 }); 3581 3582 $thumbs.find('img').eq(0).addClass('active-thumb'); 3583 } 3584 3585 function initThumbnailsHorizontal() { 3586 $thumbs.addClass('owl-carousel').owlCarousel({ 3587 rtl : baselThemeModule.$body.hasClass('rtl'), 3588 items : basel_settings.product_gallery.thumbs_slider.items.desktop, 3589 responsive: { 3590 979: { 3591 items: basel_settings.product_gallery.thumbs_slider.items.desktop 3592 }, 3593 768: { 3594 items: basel_settings.product_gallery.thumbs_slider.items.desktop_small 3595 }, 3596 479: { 3597 items: basel_settings.product_gallery.thumbs_slider.items.tablet 3598 }, 3599 0 : { 3600 items: basel_settings.product_gallery.thumbs_slider.items.mobile 3601 } 3602 }, 3603 dots : false, 3604 nav : true, 3605 navText : false 3606 }); 3607 3608 var $thumbsOwl = $thumbs.owlCarousel(); 3609 3610 $thumbs.on('mousedown', '.owl-item', function() { 3611 var i = $(this).index(); 3612 $thumbsOwl.trigger('to.owl.carousel', i); 3613 $mainOwl.trigger('to.owl.carousel', i); 3614 }); 3615 3616 $mainOwl.on('changed.owl.carousel', function(e) { 3617 var i = e.item.index; 3618 $thumbsOwl.trigger('to.owl.carousel', i); 3619 $thumbs.find('.active-thumb').removeClass('active-thumb'); 3620 $thumbs.find('.owl-item').eq(i).addClass('active-thumb'); 3621 }); 3622 3623 $thumbs.find('.owl-item').eq(0).addClass('active-thumb'); 3624 } 3625 }, 3626 3627 stickyDetails: function() { 3628 if (!baselThemeModule.$body.hasClass('basel-product-design-sticky')) { 3629 return; 3630 } 3631 3632 var details = $('.entry-summary'), 3633 detailsInner = details.find('.summary-inner'), 3634 detailsWidth = details.width(), 3635 images = $('.product-images'), 3636 thumbnails = images.find('.woocommerce-product-gallery__wrapper a'), 3637 offsetThumbnils, 3638 viewportHeight = baselThemeModule.$window.height(), 3639 imagesHeight = images.outerHeight(), 3640 topOffset = 130, 3641 maxWidth = 600, 3642 innerWidth, 3643 detailsHeight = details.outerHeight(), 3644 scrollTop = baselThemeModule.$window.scrollTop(), 3645 imagesTop = images.offset().top, 3646 detailsLeft = details.offset().left + 15, 3647 imagesBottom = imagesTop + imagesHeight, 3648 detailsBottom = scrollTop + topOffset + detailsHeight; 3649 3650 details.css({ 3651 height: detailsHeight 3652 }); 3653 3654 baselThemeModule.$window.on('resize', function() { 3655 recalculate(); 3656 }); 3657 3658 baselThemeModule.$window.on('scroll', function() { 3659 onscroll(); 3660 animateThumbnails(); 3661 }); 3662 3663 images.imagesLoaded(function() { 3664 recalculate(); 3665 }); 3666 3667 function animateThumbnails() { 3668 viewportHeight = baselThemeModule.$window.height(); 3669 3670 thumbnails.each(function() { 3671 var $this = $(this); 3672 offsetThumbnils = $this.offset().top; 3673 3674 if (scrollTop > (offsetThumbnils - viewportHeight + 20)) { 3675 $this.addClass('animate-images'); 3676 } 3677 }); 3678 } 3679 3680 function onscroll() { 3681 scrollTop = baselThemeModule.$window.scrollTop(); 3682 detailsBottom = scrollTop + topOffset + detailsHeight; 3683 detailsWidth = details.width(); 3684 detailsLeft = details.offset().left + 15; 3685 imagesTop = images.offset().top; 3686 imagesBottom = imagesTop + imagesHeight; 3687 3688 if (detailsWidth > maxWidth) { 3689 innerWidth = (detailsWidth - maxWidth) / 2; 3690 detailsLeft = detailsLeft + innerWidth; 3691 } 3692 3693 // Fix after scroll the header 3694 if (scrollTop + topOffset >= imagesTop) { 3695 details.addClass('block-sticked'); 3696 3697 detailsInner.css({ 3698 top : topOffset, 3699 left : detailsLeft, 3700 width : detailsWidth, 3701 position : 'fixed', 3702 transform: 'translateY(-20px)' 3703 }); 3704 } else { 3705 details.removeClass('block-sticked'); 3706 detailsInner.css({ 3707 top : 'auto', 3708 left : 'auto', 3709 width : 'auto', 3710 position : 'relative', 3711 transform: 'translateY(0px)' 3712 }); 3713 } 3714 3715 // When rich the bottom line 3716 if (detailsBottom > imagesBottom) { 3717 details.addClass('hide-temporary'); 3718 } else { 3719 details.removeClass('hide-temporary'); 3720 } 3721 } 3722 3723 function recalculate() {
3724 viewportHeight = baselThemeModule.$window.height(); 3725 detailsHeight = details.outerHeight(); 3726 imagesHeight = images.outerHeight(); 3727 3728 // If enough space in the viewport 3729 if (detailsHeight < (viewportHeight - topOffset)) { 3730 details.addClass('in-viewport').removeClass('not-in-viewport'); 3731 } else { 3732 details.removeClass('in-viewport').addClass('not-in-viewport'); 3733 } 3734 } 3735 }, 3736 3737 mfpPopup: function() { 3738 $('.gallery').magnificPopup({ 3739 tClose : basel_settings.close, 3740 tLoading: basel_settings.loading, 3741 delegate: ' > a', 3742 type : 'image', 3743 image : { 3744 verticalFit: true 3745 }, 3746 gallery : { 3747 enabled : true, 3748 navigateByImgClick: true 3749 } 3750 }); 3751 3752 $('[data-rel="mfp"]').magnificPopup({ 3753 tClose : basel_settings.close, 3754 tLoading: basel_settings.loading, 3755 type : 'image', 3756 image : { 3757 verticalFit: true 3758 }, 3759 gallery : { 3760 enabled : false, 3761 navigateByImgClick: false 3762 } 3763 }); 3764 3765 baselThemeModule.$document.on('click', '.mfp-img', function() { 3766 var mfp = jQuery.magnificPopup.instance; 3767 mfp.st.image.verticalFit = !mfp.st.image.verticalFit; 3768 mfp.currItem.img.removeAttr('style'); 3769 mfp.updateSize(); 3770 }); 3771 }, 3772 3773 addToCart: function() { 3774 var that = this; 3775 var timeoutNumber = 0; 3776 var timeout; 3777 3778 baselThemeModule.$body.on('added_to_cart', function() { 3779 if (basel_settings.add_to_cart_action === 'popup') { 3780 var html = [ 3781 '<div class="added-to-cart">', 3782 '<p>' + basel_settings.added_to_cart + '</p>', 3783 '<a href="#" class="btn btn-style-link close-popup">' + basel_settings.continue_shopping + '</a>', 3784 '<a href="' + basel_settings.cart_url + '" class="btn btn-color-primary view-cart">' + basel_settings.view_cart + '</a>', 3785 '</div>' 3786 ].join(''); 3787 3788 $.magnificPopup.open({ 3789 tClose : basel_settings.close, 3790 tLoading : basel_settings.loading, 3791 removalDelay: 500, 3792 callbacks : { 3793 beforeOpen: function() { 3794 this.st.mainClass = baselTheme.popupEffect + ' cart-popup-wrapper'; 3795 } 3796 }, 3797 items : { 3798 src : '<div class="white-popup add-to-cart-popup mfp-with-anim popup-added_to_cart">' + html + '</div>', 3799 type: 'inline' 3800 } 3801 }); 3802 3803 $('.white-popup').on('click', '.close-popup', function(e) { 3804 e.preventDefault(); 3805 $.magnificPopup.close(); 3806 }); 3807 3808 closeAfterTimeout(); 3809 } else if (basel_settings.add_to_cart_action === 'widget') { 3810 clearTimeout(timeoutNumber); 3811 3812 var currentHeader = ($('.sticky-header.act-scroll').length > 0) ? $('.sticky-header .dropdown-wrap-cat') : $('.main-header .dropdown-wrap-cat'); 3813 3814 var $opener = $('.cart-widget-opener a'); 3815 if ($opener.length > 0) { 3816 $opener.trigger('click'); 3817 } else if ($('.shopping-cart .a').length > 0) { 3818 $('.shopping-cart .dropdown-wrap-cat').addClass('display-widget'); 3819 timeoutNumber = setTimeout(function() { 3820 $('.display-widget').removeClass('display-widget'); 3821 }, 3500); 3822 } else { 3823 currentHeader.addClass('display-widget'); 3824 timeoutNumber = setTimeout(function() { 3825 $('.display-widget').removeClass('display-widget'); 3826 }, 3500); 3827 } 3828 3829 closeAfterTimeout(); 3830 } 3831 3832 that.btnsToolTips(); 3833 }); 3834 3835 var closeAfterTimeout = function() { 3836 if ('yes' !== basel_settings.add_to_cart_action_timeout) { 3837 return false; 3838 } 3839 3840 clearTimeout(timeout); 3841 3842 timeout = setTimeout(function() { 3843 $('.basel-close-side').trigger('click'); 3844 $.magnificPopup.close(); 3845 }, parseInt(basel_settings.add_to_cart_action_timeout_number) * 1000); 3846 }; 3847 }, 3848 3849 updateWishListNumberInit: function() { 3850 if (basel_settings.wishlist === 'no' || $('.wishlist-count').length <= 0) { 3851 return; 3852 } 3853 3854 var that = this; 3855 3856 if (baselTheme.supports_html5_storage) { 3857 3858 try { 3859 var wishlistNumber = sessionStorage.getItem('basel_wishlist_number'), 3860 cookie_hash = Cookies.get('basel_wishlist_hash'); 3861 3862 if (wishlistNumber === null || wishlistNumber === undefined || wishlistNumber === '') { 3863 wishlistNumber = 0; 3864 } 3865 3866 if (cookie_hash === null || cookie_hash === undefined || cookie_hash === '') { 3867 cookie_hash = 0; 3868 } 3869 3870 if (wishlistNumber == cookie_hash) { 3871 this.setWishListNumber(wishlistNumber); 3872 } else { 3873 throw 'No wishlist number'; 3874 } 3875 } 3876 catch (err) { 3877 this.updateWishListNumber(); 3878 } 3879 3880 } else { 3881 this.updateWishListNumber(); 3882 } 3883 3884 baselThemeModule.$body.on('added_to_cart added_to_wishlist removed_from_wishlist', function() { 3885 that.updateWishListNumber(); 3886 that.btnsToolTips(); 3887 that.woocommerceWrappTable(); 3888 }); 3889 }, 3890 3891 updateCartWidgetFromLocalStorage: function() { 3892 if (baselTheme.supports_html5_storage) { 3893 try { 3894 var wc_fragments = JSON.parse(sessionStorage.getItem(wc_cart_fragments_params.fragment_name)); 3895 3896 if (wc_fragments && wc_fragments['div.widget_shopping_cart_content']) { 3897 3898 $.each(wc_fragments, function(key, value) { 3899 $(key).replaceWith(value); 3900 }); 3901 3902 baselThemeModule.$body.trigger('wc_fragments_loaded'); 3903 } else { 3904 throw 'No fragment'; 3905 } 3906 3907 } 3908 catch (err) { 3909 console.log('cant update cart widget'); 3910 } 3911 } 3912 }, 3913 3914 updateWishListNumber: function() { 3915 var that = this; 3916 $.ajax({ 3917 url : basel_settings.ajaxurl, 3918 data : { 3919 action: 'basel_wishlist_number' 3920 }, 3921 method : 'get', 3922 success: function(data) { 3923 that.setWishListNumber(data); 3924 if (baselTheme.supports_html5_storage) { 3925 sessionStorage.setItem('basel_wishlist_number', data); 3926 } 3927 } 3928 }); 3929 }, 3930 3931 setWishListNumber: function(num) { 3932 num = ($.isNumeric(num)) ? num : 0; 3933 $('.wishlist-info-widget .wishlist-count').text(num); 3934 }, 3935 3936 cartWidget: function() { 3937 var widget = $('.cart-widget-opener'), 3938 body = baselThemeModule.$body; 3939 3940 widget.on('click', 'a', function(e) { 3941 if (!isCart() && !isCheckout()) { 3942 e.preventDefault(); 3943 } 3944 3945 if (isOpened()) { 3946 closeWidget(); 3947 } else { 3948 setTimeout(function() { 3949 openWidget(); 3950 }, 10); 3951 } 3952 }); 3953 3954 body.on('click touchstart', '.basel-close-side', function() { 3955 if (isOpened()) { 3956 closeWidget(); 3957 } 3958 }); 3959 3960 body.on('click', '.widget-close', function(e) { 3961 e.preventDefault(); 3962 if (isOpened()) { 3963 closeWidget(); 3964 } 3965 }); 3966 3967 baselThemeModule.$document.on('keyup', function(e) { 3968 if (e.keyCode === 27 && isOpened()) { 3969 closeWidget(); 3970 } 3971 }); 3972 3973 var closeWidget = function() { 3974 baselThemeModule.$body.removeClass('basel-cart-opened'); 3975 }; 3976 3977 var openWidget = function() { 3978 if (isCart() || isCheckout()) { 3979 return false;
3980 } 3981 baselThemeModule.$body.addClass('basel-cart-opened'); 3982 }; 3983 3984 var isOpened = function() { 3985 return baselThemeModule.$body.hasClass('basel-cart-opened'); 3986 }; 3987 3988 var isCart = function() { 3989 return baselThemeModule.$body.hasClass('woocommerce-cart'); 3990 }; 3991 3992 var isCheckout = function() { 3993 return baselThemeModule.$body.hasClass('woocommerce-checkout'); 3994 }; 3995 3996 baselThemeModule.$document.on('wc_fragments_refreshed wc_fragments_loaded added_to_cart', function() { 3997 baselThemeModule.$document.trigger('basel-images-loaded'); 3998 }); 3999 }, 4000 4001 bannersHover: function() { 4002 var $banner = $('.promo-banner.hover-4'); 4003 4004 if ($banner.length > 0) { 4005 $banner.panr({ 4006 sensitivity : 20, 4007 scale : false, 4008 scaleOnHover : true, 4009 scaleTo : 1.15, 4010 scaleDuration : .34, 4011 panY : true, 4012 panX : true, 4013 panDuration : 0.5, 4014 resetPanOnMouseLeave: true 4015 }); 4016 } 4017 }, 4018 4019 parallax: function() { 4020 $('.parallax-yes').each(function() { 4021 var $bgobj = $(this); 4022 baselThemeModule.$window.on('scroll', function() { 4023 var yPos = -(baselThemeModule.$window.scrollTop() / $bgobj.data('speed')); 4024 var coords = 'center ' + yPos + 'px'; 4025 $bgobj.css({ 4026 backgroundPosition: coords 4027 }); 4028 }); 4029 }); 4030 4031 $('.basel-parallax').each(function() { 4032 var $this = $(this); 4033 if ($this.hasClass('wpb_column')) { 4034 $this.find('> .vc_column-inner').parallax('50%', 0.3); 4035 } else { 4036 $this.parallax('50%', 0.3); 4037 } 4038 }); 4039 }, 4040 4041 scrollTop: function() { 4042 baselThemeModule.$window.on('scroll', function() { 4043 if ($(this).scrollTop() > 100) { 4044 $('.scrollToTop').addClass('button-show'); 4045 } else { 4046 $('.scrollToTop').removeClass('button-show'); 4047 } 4048 }); 4049 4050 $('.scrollToTop').on('click', function() { 4051 $('html, body').animate({ 4052 scrollTop: 0 4053 }, 800); 4054 return false; 4055 }); 4056 }, 4057 4058 quickViewInit: function() { 4059 var that = this; 4060 // Open popup with product info when click on Quick View button 4061 baselThemeModule.$document.on('click', '.open-quick-view', function(e) { 4062 4063 e.preventDefault(); 4064 4065 if ($('.open-quick-view').hasClass('loading')) { 4066 return true; 4067 } 4068 4069 var $this = $(this); 4070 var productId = $this.data('id'), 4071 loopName = $this.data('loop-name'), 4072 loop = $this.data('loop'), 4073 prev = '', 4074 next = '', 4075 loopBtns = $('.quick-view').find('[data-loop-name="' + loopName + '"]'), 4076 btn = $this; 4077 4078 btn.addClass('loading'); 4079 4080 if (typeof loopBtns[loop - 1] != 'undefined') { 4081 prev = loopBtns.eq(loop - 1).addClass('quick-view-prev'); 4082 prev = $('<div>').append(prev.clone()).html(); 4083 } 4084 4085 if (typeof loopBtns[loop + 1] != 'undefined') { 4086 next = loopBtns.eq(loop + 1).addClass('quick-view-next'); 4087 next = $('<div>').append(next.clone()).html(); 4088 } 4089 4090 that.quickViewLoad(productId, btn, prev, next); 4091 }); 4092 }, 4093 4094 quickViewCarousel: function() { 4095 var $wrapper = $('.product-quick-view .woocommerce-product-gallery__wrapper'); 4096 $wrapper.trigger('destroy.owl.carousel'); 4097 $wrapper.addClass('owl-carousel').owlCarousel({ 4098 rtl : baselThemeModule.$body.hasClass('rtl'), 4099 items : 1, 4100 dots : false, 4101 nav : true, 4102 navText: false 4103 }); 4104 }, 4105 4106 quickViewLoad: function(id, btn) { 4107 var data = { 4108 id : id, 4109 action: 'basel_quick_view' 4110 }; 4111 4112 var initPopup = function(data) { 4113 var items = $(data); 4114 4115 $.magnificPopup.open({ 4116 items : { 4117 src : items, 4118 type: 'inline' 4119 }, 4120 tClose : basel_settings.close, 4121 tLoading : basel_settings.loading, 4122 removalDelay: 500, 4123 callbacks : { 4124 beforeOpen: function() { 4125 this.st.mainClass = baselTheme.popupEffect; 4126 }, 4127 open : function() { 4128 var $form = $('.variations_form'); 4129 $form.each(function() { 4130 $(this).wc_variation_form().find('.variations select:eq(0)').change(); 4131 }); 4132 $form.trigger('wc_variation_form'); 4133 baselThemeModule.$body.trigger('basel-quick-view-displayed'); 4134 baselThemeModule.swatchesVariations(); 4135 4136 baselThemeModule.btnsToolTips(); 4137 baselThemeModule.swatchesLimit(); 4138 baselThemeModule.quickViewCarousel(); 4139 } 4140 } 4141 }); 4142 }; 4143 4144 $.ajax({ 4145 url : basel_settings.ajaxurl, 4146 data : data, 4147 method : 'get', 4148 success : function(data) { 4149 baselThemeModule.removeDuplicatedStylesFromHTML(data, function(data) { 4150 if (basel_settings.quickview_in_popup_fix) { 4151 $.magnificPopup.close(); 4152 setTimeout(function() { 4153 initPopup(data); 4154 }, 500); 4155 } else { 4156 initPopup(data); 4157 } 4158 }); 4159 }, 4160 complete: function() { 4161 btn.removeClass('loading'); 4162 }, 4163 error : function() { 4164 } 4165 }); 4166 }, 4167 4168 quickShop: function() { 4169 var btnSelector = '.btn-quick-shop'; 4170 4171 baselThemeModule.$document.on('click', btnSelector, function(e) { 4172 e.preventDefault(); 4173 4174 var $this = $(this), 4175 $product = $this.parents('.product'), 4176 $content = $product.find('.quick-shop-form'), 4177 id = $this.data('id'), 4178 loadingClass = 'btn-loading'; 4179 4180 if ($this.hasClass(loadingClass)) { 4181 return; 4182 } 4183 4184 // Simply show quick shop form if it is already loaded with AJAX previously 4185 if ($product.hasClass('quick-shop-loaded')) { 4186 $product.addClass('quick-shop-shown'); 4187 return; 4188 } 4189 4190 $this.addClass(loadingClass); 4191 $product.addClass('loading-quick-shop'); 4192 4193 $.ajax({ 4194 url : basel_settings.ajaxurl, 4195 data : { 4196 action: 'basel_quick_shop', 4197 id : id 4198 }, 4199 method : 'get', 4200 success : function(data) { 4201 4202 // insert variations form 4203 $content.append(data); 4204 4205 initVariationForm($product); 4206 baselThemeModule.$body.trigger('basel-quick-view-displayed'); 4207 baselThemeModule.swatchesVariations(); 4208 baselThemeModule.btnsToolTips(); 4209 baselThemeModule.swatchesLimit(); 4210 4211 }, 4212 complete: function() { 4213 $this.removeClass(loadingClass); 4214 $product.removeClass('loading-quick-shop'); 4215 $product.addClass('quick-shop-shown quick-shop-loaded'); 4216 } 4217 }); 4218 }) 4219 .on('click', '.quick-shop-close', function() { 4220 var $this = $(this), 4221 $product = $this.parents('.product'); 4222 4223 $product.removeClass('quick-shop-shown'); 4224 }); 4225 4226 function initVariationForm($product) { 4227 $product.find('.variations_form').wc_variation_form().find('.variations select:eq(0)').change(); 4228 $product.find('.variations_form').trigger('wc_variation_form'); 4229 } 4230 }, 4231 4232 btnsToolTips: function() { 4233 $('.basel-tooltip, .product-actions-btns > a, .product-grid-item .add_to_cart_button, .quick-view a, .product-compare-button a, .product-grid-item .yith-wcwl-add-to-wis
4233hlist a').on('mouseenter touchstart', function() { 4234 var $this = $(this); 4235 4236 if ($(window).width() <= 1024 || $this.hasClass('basel-tooltip-inited')) { 4237 return; 4238 } 4239 4240 $this.find('.basel-tooltip-label').remove(); 4241 $this.addClass('basel-tooltip').prepend('<span class="basel-tooltip-label">' + $this.text() + '</span>'); 4242 4243 $this.addClass('basel-tooltip-inited'); 4244 }); 4245 }, 4246 4247 stickyFooter: function() { 4248 if (!baselThemeModule.$body.hasClass('sticky-footer-on') || baselThemeModule.windowWidth < 991) { 4249 return; 4250 } 4251 4252 var $footer = $('.footer-container'), 4253 $page = $('.main-page-wrapper'), 4254 $window = baselThemeModule.$window; 4255 4256 var $prefooter = $('.basel-prefooter'); 4257 if ($prefooter.length > 0) { 4258 $page = $prefooter; 4259 } 4260 4261 var footerOffset = function() { 4262 $page.css({ 4263 marginBottom: $footer.outerHeight() 4264 }); 4265 }; 4266 4267 $window.on('resize', footerOffset); 4268 4269 $footer.imagesLoaded(function() { 4270 footerOffset(); 4271 }); 4272 4273 var footerScrollFix = function() { 4274 var windowScroll = $window.scrollTop(); 4275 var footerOffsetTop = baselThemeModule.$document.outerHeight() - $footer.outerHeight(); 4276 4277 if (footerOffsetTop < windowScroll + $footer.outerHeight() + $window.outerHeight()) { 4278 $footer.addClass('visible-footer'); 4279 } else { 4280 $footer.removeClass('visible-footer'); 4281 } 4282 }; 4283 4284 footerScrollFix(); 4285 $window.on('scroll', footerScrollFix); 4286 }, 4287 4288 swatchesVariations: function() { 4289 var $variation_forms = $('.variations_form'); 4290 var variationGalleryReplace = false; 4291 4292 // Firefox mobile fix. 4293 $('.variations_form .label').on('click', function(e) { 4294 if ($(this).siblings('.value').hasClass('with-swatches')) { 4295 e.preventDefault(); 4296 } 4297 }); 4298 4299 $variation_forms.each(function() { 4300 var $variation_form = $(this); 4301 4302 if ($variation_form.data('swatches')) { 4303 return; 4304 } 4305 $variation_form.data('swatches', true); 4306 4307 if (!$variation_form.data('product_variations')) { 4308 $variation_form.find('.swatches-select').find('> div').addClass('swatch-enabled'); 4309 } 4310 4311 if ($('.swatches-select > div').hasClass('active-swatch')) { 4312 $variation_form.addClass('variation-swatch-selected'); 4313 } 4314 4315 $variation_form.on('click', '.swatches-select > div', function() { 4316 var $this = $(this); 4317 var value = $this.data('value'); 4318 var id = $this.parent().data('id'); 4319 4320 resetSwatches($variation_form); 4321 4322 if ($this.hasClass('active-swatch')) { 4323 return; 4324 } 4325 4326 if ($this.hasClass('swatch-disabled')) { 4327 return; 4328 } 4329 $variation_form.find('select#' + id).val(value).trigger('change'); 4330 $this.parent().find('.active-swatch').removeClass('active-swatch'); 4331 $this.addClass('active-swatch'); 4332 resetSwatches($variation_form); 4333 }) 4334 .on('click', '.reset_variations', function() { 4335 $variation_form.find('.active-swatch').removeClass('active-swatch'); 4336 }) 4337 .on('reset_data', function() { 4338 var $this = $(this); 4339 var all_attributes_chosen = true; 4340 var some_attributes_chosen = false; 4341 4342 $variation_form.find('.variations select').each(function() { 4343 var value = $this.val() || ''; 4344 4345 if (value.length === 0) { 4346 all_attributes_chosen = false; 4347 } else { 4348 some_attributes_chosen = true; 4349 } 4350 4351 }); 4352 4353 if (all_attributes_chosen) { 4354 $this.parent().find('.active-swatch').removeClass('active-swatch'); 4355 } 4356 4357 $variation_form.removeClass('variation-swatch-selected'); 4358 4359 var $mainOwl = $('.woocommerce-product-gallery__wrapper.owl-carousel'); 4360 4361 resetSwatches($variation_form); 4362 4363 if ($mainOwl.length === 0) { 4364 return; 4365 } 4366 4367 if (basel_settings.product_slider_auto_height === 'yes') { 4368 if (!isQuickView() && isVariationGallery('default') && variationGalleryReplace) { 4369 $mainOwl.trigger('destroy.owl.carousel'); 4370 } 4371 $('.product-images').imagesLoaded(function() { 4372 $mainOwl = $mainOwl.owlCarousel(baselTheme.mainCarouselArg); 4373 $mainOwl.trigger('refresh.owl.carousel'); 4374 }); 4375 } else { 4376 $mainOwl = $mainOwl.owlCarousel(baselTheme.mainCarouselArg); 4377 $mainOwl.trigger('refresh.owl.carousel'); 4378 } 4379 4380 $mainOwl.trigger('to.owl.carousel', 0); 4381 4382 replaceMainGallery('default', $variation_form); 4383 }) 4384 .on('reset_image', function() { 4385 var $thumb = $('.thumbnails img').first(); 4386 if (!isQuickView() && !isQuickShop($variation_form)) { 4387 $thumb.wc_reset_variation_attr('src'); 4388 } 4389 }) 4390 .on('show_variation', function(e, variation) { 4391 // Firefox fix after reload page. 4392 if ( $variation_form.find('.basel-swatch').length && ! $variation_form.find('.basel-swatch.active-swatch').length ) { 4393 $variation_form.find('select').each(function () { 4394 var $select = $(this); 4395 var value = $select.val(); 4396 4397 if ( ! value ) { 4398 return; 4399 } 4400 4401 $select.siblings('.swatches-select').find('.basel-swatch[data-value=' + value + ']').addClass('active-swatch'); 4402 }); 4403 } 4404 4405 if (!variation.image.src) { 4406 return; 4407 } 4408 4409 // See if the gallery has an image with the same original src as the image we want to switch to. 4410 var galleryHasImage = $variation_form.parents('.single-product-content').find('.thumbnails img[data-o_src="' + variation.image.thumb_src + '"]').length > 0; 4411 var $firstThumb = $variation_form.parents('.single-product-content').find('.thumbnails img').first(); 4412 4413 // If the gallery has the image, reset the images. We'll scroll to the correct one. 4414 if (galleryHasImage) { 4415 $firstThumb.wc_reset_variation_attr('src'); 4416 } 4417 4418 if (!isQuickShop($variation_form) && !replaceMainGallery(variation.variation_id, $variation_form)) { 4419 if ($firstThumb.attr('src') != variation.image.thumb_src) { 4420 $firstThumb.wc_set_variation_attr('src', variation.image.src); 4421 } 4422 baselThemeModule.initZoom(); 4423 } 4424 4425 var $mainOwl = $('.woocommerce-product-gallery__wrapper'); 4426 4427 $variation_form.addClass('variation-swatch-selected'); 4428 4429 if (!isQuickShop($variation_form) && !isQuickView()) { 4430 scrollToTop(); 4431 } 4432 4433 if (!$mainOwl.hasClass('owl-carousel')) { 4434 return; 4435 } 4436 4437 if (basel_settings.product_slider_auto_height === 'yes') { 4438 if (!isQuickView() && isVariationGallery(variation.variation_id) && variationGalleryReplace) { 4439 $mainOwl.trigger('destroy.owl.carousel'); 4440 } 4441 $('.product-images').imagesLoaded(function() { 4442 $mainOwl = $mainOwl.owlCarousel(baselTheme.mainCarouselArg); 4443 $mainOwl.trigger('refresh.owl.carousel'); 4444 }); 4445 } else { 4446 $mainOwl = $mainOwl.owlCarousel(baselTheme.mainCarouselArg); 4447 $mainOwl.trigger('refresh.owl.carousel'); 4448 } 4449 4450 var $thumbs = $('.images .thumbnails'); 4451 4452 $mainOwl.trigger('to.owl.carousel', 0); 4453 4454 if ($thumbs.hasClass('owl-carousel')) { 4455 $thumbs.owlCarousel().trigger('to.owl.carousel', 0); 4456 $thumbs.find('.active-thumb').removeClass('active-thumb'); 4457 $thumbs.find('.owl-item').eq(0).addClass('active-thumb'); 4458 } else if ($thumbs.length > 0) { 4459 $thumbs.slick('slickGoTo', 0); 4460 $thumbs.find('.active-thumb').removeClass('active-thumb'); 4461 $thumbs.find('img').eq(0).addClass('active-thumb'); 4462 } 4463 }); 4464 }); 4465 4466 var resetSwatches = function($variation_form) { 4467 // If using AJAX 4468 if (!$variation_form.data('product_variations')) { 4469 return; 4470 } 4471 4472 $variation_form.find('.variations select').each(function() { 4473 4474 var select = $(this); 4475 var swatch = select.parent().find('.swatches-select'); 4476 var options = select.html(); 4477 4478 options = $(options); 4479 4480 swatch.find('> div').removeClass('swatch-enabled').addClass('swatch-disabled'); 4481 4482 options.each(function() { 4483 var $this = $(this); 4484 var value = $this.val(); 4485 4486 if ($this.hasClass('enabled')) { 4487 swatch.find('div[data-value="' + value + '"]').removeClass('swatch-disabled').addClass('swatch-enabled'); 4488 } else { 4489 swatch.find('div[data-value="' + value + '"]').addClass('swatch-disabled').removeClass('swatch-enabled'); 4490 } 4491 }); 4492 }); 4493 }; 4494 4495 var scrollToTop = function() { 4496 if ((basel_settings.swatches_scroll_top_desktop == 1 && baselThemeModule.windowWidth >= 1024) || (basel_settings.swatches_scroll_top_mobile == 1 && baselThemeModule.windowWidth <= 1024)) { 4497 var $page = $('html, body'); 4498 4499 $page.stop(true); 4500 baselThemeModule.$window.on('mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { 4501 $page.stop(true); 4502 }); 4503 $page.animate({ 4504 scrollTop: $('.product-image-summary').offset().top - 150 4505 }, 800); 4506 } 4507 }; 4508 4509 var isQuickShop = function($form) { 4510 return $form.parent().hasClass('quick-shop-form'); 4511 }; 4512 4513 var isQuickView = function() { 4514 return $('.single-product-content').hasClass('product-quick-view'); 4515 }; 4516 4517 var isVariationGallery = function(key) { 4518 if (typeof basel_variation_gallery_data === 'undefined' && typeof basel_qv_variation_gallery_data === 'undefined') { 4519 return; 4520 } 4521 4522 var variation_gallery_data = isQuickView() ? basel_qv_variation_gallery_data : basel_variation_gallery_data; 4523 4524 return typeof variation_gallery_data !== 'undefined' && variation_gallery_data && variation_gallery_data[key]; 4525 }; 4526 4527 var replaceMainGallery = function(key, $variationForm) { 4528 if (!isVariationGallery(key) || isQuickShop($variationForm) || ('default' === key && !variationGalleryReplace)) { 4529 return false;
4530 } 4531 4532 var variation_gallery_data = isQuickView() ? basel_qv_variation_gallery_data : basel_variation_gallery_data; 4533 4534 var imagesData = variation_gallery_data[key]; 4535 var $mainGallery = $variationForm.parents('.single-product-content').find('.woocommerce-product-gallery__wrapper'); 4536 $mainGallery.empty(); 4537 4538 for (var index = 0; index < imagesData.length; index++) { 4539 var $html = '<figure data-thumb="' + imagesData[index].data_thumb + '" class="woocommerce-product-gallery__image">'; 4540 4541 if (!isQuickView()) { 4542 $html += '<a href="' + imagesData[index].href + '">'; 4543 } 4544 4545 $html += imagesData[index].image; 4546 4547 if (!isQuickView()) { 4548 $html += '</a>'; 4549 } 4550 4551 $html += '</figure>'; 4552 4553 $mainGallery.append($html); 4554 } 4555 4556 baselThemeModule.productImagesGallery(); 4557 baselThemeModule.quickViewCarousel(); 4558 $('.woocommerce-product-gallery__image').trigger('zoom.destroy'); 4559 if (!isQuickView()) { 4560 baselThemeModule.initZoom(); 4561 } 4562 4563 variationGalleryReplace = 'default' !== key; 4564 4565 return true; 4566 }; 4567 4568 }, 4569 4570 swatchesOnGrid: function() { 4571 baselThemeModule.$body.on('click', '.swatch-on-grid', function() { 4572 4573 var src, srcset, image_sizes; 4574 4575 var $this = $(this); 4576 var imageSrc = $this.data('image-src'), 4577 imageSrcset = $this.data('image-srcset'), 4578 imageSizes = $this.data('image-sizes'); 4579 4580 if (typeof imageSrc == 'undefined') { 4581 return; 4582 } 4583 4584 var product = $this.parents('.product-grid-item'), 4585 image = product.find('.product-element-top > a > img'), 4586 srcOrig = image.data('original-src'), 4587 source = product.find('.product-element-top > a > picture source'), 4588 srcsetOrig = image.data('original-srcset'), 4589 sizesOrig = image.data('original-sizes'); 4590 4591 if (typeof srcOrig == 'undefined') { 4592 image.data('original-src', image.attr('src')); 4593 } 4594 4595 if (typeof srcsetOrig == 'undefined') { 4596 image.data('original-srcset', image.attr('srcset')); 4597 } 4598 4599 if (typeof sizesOrig == 'undefined') { 4600 image.data('original-sizes', image.attr('sizes')); 4601 } 4602 4603 if ($this.hasClass('current-swatch')) { 4604 src = srcOrig; 4605 srcset = srcsetOrig; 4606 image_sizes = sizesOrig; 4607 $this.removeClass('current-swatch'); 4608 product.removeClass('product-swatched'); 4609 } else { 4610 $this.parent().find('.current-swatch').removeClass('current-swatch'); 4611 $this.addClass('current-swatch'); 4612 product.addClass('product-swatched'); 4613 src = imageSrc; 4614 srcset = imageSrcset; 4615 image_sizes = imageSizes; 4616 } 4617 4618 if (image.attr('src') === src) { 4619 return; 4620 } 4621 4622 product.addClass('loading-image'); 4623 4624 image.attr('src', src).attr('srcset', srcset).attr('image_sizes', image_sizes).one('load', function() { 4625 product.removeClass('loading-image'); 4626 }); 4627 4628 if (source.length > 0) { 4629 source.attr('srcset', srcset).attr('image_sizes', image_sizes); 4630 } 4631 }); 4632 }, 4633 4634 ajaxFilters: function() { 4635 if (!baselThemeModule.$body.hasClass('basel-ajax-shop-on') || typeof ($.fn.pjax) == 'undefined' || baselThemeModule.$body.hasClass('single-product')) { 4636 return; 4637 } 4638 4639 var that = this, 4640 filtersState = false; 4641 4642 baselThemeModule.$body.on('click', '.post-type-archive-product .products-footer .woocommerce-pagination a', function() { 4643 scrollToTop(); 4644 }); 4645 4646 baselThemeModule.$document.pjax(baselTheme.ajaxLinks, '.main-page-wrapper', { 4647 timeout : basel_settings.pjax_timeout, 4648 scrollTo : false, 4649 renderCallback: function(context, html, afterRender) { 4650 baselThemeModule.removeDuplicatedStylesFromHTML(html, function(html) { 4651 context.html(html); 4652 afterRender(); 4653 baselThemeModule.shopPageInit(); 4654 baselThemeModule.$document.trigger('basel-images-loaded'); 4655 }); 4656 } 4657 }); 4658 4659 baselThemeModule.$document.on('click', '.widget_price_filter form .button', function() { 4660 var form = $('.widget_price_filter form'); 4661 console.log(form.serialize()); 4662 $.pjax({ 4663 container : '.main-page-wrapper', 4664 timeout : basel_settings.pjax_timeout, 4665 url : form.attr('action'), 4666 data : form.serialize(), 4667 scrollTo : false, 4668 renderCallback: function(context, html, afterRender) { 4669 baselThemeModule.removeDuplicatedStylesFromHTML(html, function(html) { 4670 context.html(html); 4671 afterRender(); 4672 baselThemeModule.shopPageInit(); 4673 baselThemeModule.$document.trigger('basel-images-loaded'); 4674 }); 4675 } 4676 }); 4677 4678 return false;
4679 }); 4680 4681 baselThemeModule.$document.on('pjax:error', function(xhr, textStatus, error) { 4682 console.log('pjax error ' + error); 4683 }); 4684 4685 baselThemeModule.$document.on('pjax:start', function() { 4686 baselThemeModule.$body.addClass('basel-loading'); 4687 baselThemeModule.hideShopSidebar(); 4688 }); 4689 4690 baselThemeModule.$document.on('pjax:beforeReplace', function() { 4691 if ($('.filters-area').hasClass('filters-opened') && basel_settings.shop_filters_close === 'yes') { 4692 filtersState = true; 4693 baselThemeModule.$body.addClass('body-filters-opened'); 4694 } 4695 }); 4696 4697 baselThemeModule.$document.on('pjax:complete', function() { 4698 that.shopPageInit(); 4699 4700 scrollToTop(); 4701 4702 baselThemeModule.$document.trigger('basel-images-loaded'); 4703 4704 $('.basel-sidebar-content').on('scroll', function() { 4705 baselThemeModule.$document.trigger('basel-images-loaded'); 4706 }); 4707 4708 baselThemeModule.$body.removeClass('basel-loading'); 4709 }); 4710 4711 baselThemeModule.$document.on('pjax:end', function() { 4712 if (filtersState) { 4713 $('.filters-area').css('display', 'block'); 4714 baselThemeModule.openFilters(200); 4715 filtersState = false; 4716 } 4717 4718 baselThemeModule.$body.removeClass('basel-loading'); 4719 }); 4720 4721 var scrollToTop = function() { 4722 if (basel_settings.ajax_scroll === 'no') { 4723 return false; 4724 } 4725 4726 var $scrollTo = $(basel_settings.ajax_scroll_class), 4727 scrollTo = $scrollTo.offset().top - basel_settings.ajax_scroll_offset; 4728 4729 $('html, body').stop().animate({ 4730 scrollTop: scrollTo 4731 }, 400); 4732 }; 4733 }, 4734 4735 shopPageInit: function() { 4736 this.shopMasonry(); 4737 this.ajaxSearch(); 4738 this.btnsToolTips(); 4739 this.compare(); 4740 this.filterDropdowns(); 4741 this.categoriesMenuBtns(); 4742 this.sortByWidget(); 4743 this.categoriesAccordion(); 4744 this.woocommercePriceSlider(); 4745 this.updateCartWidgetFromLocalStorage(); 4746 this.countDownTimer(); 4747 this.shopLoader(); 4748 this.stickySidebarBtn(); 4749 this.productFilters(); 4750 this.categoriesDropdowns(); 4751 this.swatchesLimit(); 4752 4753 baselThemeModule.clickOnScrollButton(baselTheme.shopLoadMoreBtn, false); 4754 4755 $('.woocommerce-ordering').on('change', 'select.orderby', function() { 4756 var $this = $(this); 4757 $this.closest('form').find('[name="_pjax"]').remove(); 4758 $this.closest('form').submit(); 4759 }); 4760 4761 baselThemeModule.$body.on('updated_wc_div', function() { 4762 baselThemeModule.$document.trigger('basel-images-loaded'); 4763 }); 4764 4765 // baselThemeModule.$document.trigger('resize.vcRowBehaviour'); 4766 4767 baselThemeModule.$document.trigger('basel-shop-page-inited'); 4768 }, 4769 4770 filterDropdowns: function() { 4771 $('.basel-widget-layered-nav-dropdown-form').each(function() { 4772 var $form = $(this); 4773 var $select = $form.find('select'); 4774 var slug = $select.data('slug'); 4775 4776 $select.on('change', function() { 4777 var val = $(this).val(); 4778 $('input[name=filter_' + slug + ']').val(val); 4779 }); 4780 4781 if ($().selectWoo) { 4782 $select.selectWoo({ 4783 placeholder : $select.data('placeholder'), 4784 minimumResultsForSearch: 5, 4785 width : '100%', 4786 allowClear : !$select.attr('multiple'), 4787 language : { 4788 noResults: function() { 4789 return $select.data('noResults'); 4790 } 4791 } 4792 }).on('select2:unselecting', function() { 4793 $(this).data('unselecting', true); 4794 }).on('select2:opening', function(e) { 4795 var $this = $(this); 4796 if ($this.data('unselecting')) { 4797 $this.removeData('unselecting'); 4798 e.preventDefault(); 4799 } 4800 }); 4801 } 4802 }); 4803 4804 function ajaxAction($element) { 4805 var $form = $element.parent('.basel-widget-layered-nav-dropdown-form'); 4806 if (!baselThemeModule.$body.hasClass('basel-ajax-shop-on') || typeof ($.fn.pjax) == 'undefined') { 4807 return; 4808 } 4809 4810 $.pjax({ 4811 container : '.main-page-wrapper', 4812 timeout : basel_settings.pjax_timeout, 4813 url : $form.attr('action'), 4814 data : $form.serialize(), 4815 scrollTo : false, 4816 renderCallback: function(context, html, afterRender) { 4817 baselThemeModule.removeDuplicatedStylesFromHTML(html, function(html) { 4818 context.html(html); 4819 afterRender(); 4820 baselThemeModule.shopPageInit(); 4821 baselThemeModule.$document.trigger('basel-images-loaded'); 4822 }); 4823 } 4824 }); 4825 } 4826 4827 $('.basel-widget-layered-nav-dropdown__submit').on('click', function() { 4828 var $this = $(this); 4829 if (!$this.siblings('select').attr('multiple') || !baselThemeModule.$body.hasClass('basel-ajax-shop-on')) { 4830 return; 4831 } 4832 4833 ajaxAction($this); 4834 4835 $this.prop('disabled', true); 4836 }); 4837 4838 $('.basel-widget-layered-nav-dropdown-form select').on('change', function() { 4839 var $this = $(this); 4840 if (!baselThemeModule.$body.hasClass('basel-ajax-shop-on')) { 4841 $this.parent().submit(); 4842 return; 4843 } 4844 4845 ajaxAction($this); 4846 }); 4847 }, 4848 4849 backHistory: function() { 4850 history.go(-1); 4851 4852 setTimeout(function() { 4853 $('.filters-area').removeClass('filters-opened').stop().hide(); 4854 $('.open-filters').removeClass('btn-opened'); 4855 if (baselThemeModule.windowWidth < 992) { 4856 $('.basel-product-categories').removeClass('categories-opened').stop().hide(); 4857 $('.basel-show-categories').removeClass('button-open'); 4858 } 4859 4860 baselThemeModule.woocommercePriceSlider(); 4861 }, 20); 4862 }, 4863 4864 categoriesMenu: function() { 4865 if (baselThemeModule.windowWidth > 991) { 4866 return; 4867 } 4868 4869 var categories = $('.basel-product-categories'), 4870 time = 200; 4871 4872 baselThemeModule.$body.on('click', '.icon-drop-category', function() { 4873 var $this = $(this); 4874 if ($this.parent().find('> ul').hasClass('child-open')) { 4875 $this.removeClass('basel-act-icon').parent().find('> ul').slideUp(time).removeClass('child-open'); 4876 } else { 4877 $this.addClass('basel-act-icon').parent().find('> ul').slideDown(time).addClass('child-open'); 4878 } 4879 }); 4880 4881 baselThemeModule.$body.on('click', '.basel-show-categories', function(e) { 4882 e.preventDefault(); 4883 4884 if (isOpened()) { 4885 closeCats(); 4886 } else { 4887 openCats(); 4888 } 4889 }); 4890 4891 baselThemeModule.$body.on('click', '.basel-product-categories a', function() { 4892 closeCats(); 4893 categories.stop().attr('style', ''); 4894 }); 4895 4896 var isOpened = function() { 4897 return $('.basel-product-categories').hasClass('categories-opened'); 4898 }; 4899 4900 var openCats = function() { 4901 $('.basel-product-categories').addClass('categories-opened').stop().slideDown(time); 4902 $('.basel-show-categories').addClass('button-open'); 4903 4904 }; 4905 4906 var closeCats = function() { 4907 $('.basel-product-categories').removeClass('categories-opened').stop().slideUp(time); 4908 $('.basel-show-categories').removeClass('button-open'); 4909 }; 4910 }, 4911 4912 categoriesMenuBtns: function() { 4913 if (baselThemeModule.windowWidth > 991) { 4914 return; 4915 } 4916 4917 var categories = $('.basel-product-categories'), 4918 subCategories = categories.find('li > ul'), 4919 iconDropdown = '<span class="icon-drop-category"></span>'; 4920 4921 categories.addClass('responsive-cateogires'); 4922 subCategories.parent().addClass('has-sub').prepend(iconDropdown); 4923 }, 4924 4925 categoriesAccordion: function() { 4926 if (basel_settings.categories_toggle === 'no') { 4927 return; 4928 } 4929 4930 var $widget = $('.widget_product_categories'), 4931 $list = $widget.find('.product-categories'), 4932 $openBtn = $('<div class="basel-cats-toggle" />'), 4933 time = 300; 4934 4935 $list.find('.cat-parent').each(function() { 4936 var $this = $(this); 4937 4938 if ($this.find(' > .basel-cats-toggle').length > 0) { 4939 return; 4940 } 4941 if ($this.find(' > .children').length === 0 || $this.find(' > .children > *').length === 0) { 4942 return; 4943 } 4944 4945 $this.append('<div class="basel-cats-toggle"></div>'); 4946 }); 4947 4948 $('body').on('click', '.basel-cats-toggle', function() { 4949 var $btn = $(this), 4950 $subList = $btn.prev(); 4951 4952 if ($subList.hasClass('list-shown')) { 4953 $btn.removeClass('toggle-active');
4954 $subList.stop(true, true).slideUp(time).removeClass('list-shown'); 4955 } else { 4956 $subList.parent().parent().find('> li > .list-shown').slideUp().removeClass('list-shown'); 4957 $subList.parent().parent().find('> li > .toggle-active').removeClass('toggle-active'); 4958 $btn.addClass('toggle-active'); 4959 $subList.stop(true, true).slideDown(time).addClass('list-shown'); 4960 } 4961 }); 4962 4963 if ($list.find('li.current-cat.cat-parent, li.current-cat-parent').length > 0) { 4964 $list.find('li.current-cat.cat-parent, li.current-cat-parent').find('> .basel-cats-toggle').click(); 4965 } 4966 4967 }, 4968 4969 woocommercePriceSlider: function() { 4970 var $products = $('.products'); 4971 var $minPrice = $('.price_slider_amount #min_price'); 4972 if (typeof woocommerce_price_slider_params === 'undefined' || $minPrice.length < 1 || !$.fn.slider) { 4973 return false; 4974 } 4975 4976 var $slider = $('.price_slider'); 4977 if ($slider.slider('instance') !== undefined) { 4978 return; 4979 } 4980 4981 // Get markup ready for slider 4982 $('input#min_price, input#max_price').hide(); 4983 $('.price_slider, .price_label').show(); 4984 4985 // Price slider uses jquery ui 4986 var min_price = $minPrice.data('min'), 4987 max_price = $('.price_slider_amount #max_price').data('max'), 4988 current_min_price = parseInt(min_price, 10), 4989 current_max_price = parseInt(max_price, 10); 4990 4991 if ($products.attr('data-min_price') && $products.attr('data-min_price').length > 0) { 4992 current_min_price = parseInt($products.attr('data-min_price'), 10); 4993 } 4994 if ($products.attr('data-max_price') && $products.attr('data-max_price').length > 0) { 4995 current_max_price = parseInt($products.attr('data-max_price'), 10); 4996 } 4997 4998 $slider.slider({ 4999 range : true, 5000 animate: true, 5001 min : min_price, 5002 max : max_price, 5003 values : [ 5004 current_min_price, 5005 current_max_price 5006 ], 5007 create : function() { 5008 $('.price_slider_amount #min_price').val(current_min_price); 5009 $('.price_slider_amount #max_price').val(current_max_price); 5010 5011 baselThemeModule.$body.trigger('price_slider_create', [ 5012 current_min_price, 5013 current_max_price 5014 ]); 5015 }, 5016 slide : function(event, ui) { 5017 $('input#min_price').val(ui.values[0]); 5018 $('input#max_price').val(ui.values[1]); 5019 5020 baselThemeModule.$body.trigger('price_slider_slide', [ 5021 ui.values[0], 5022 ui.values[1] 5023 ]); 5024 }, 5025 change : function(event, ui) { 5026 baselThemeModule.$body.trigger('price_slider_change', [ 5027 ui.values[0], 5028 ui.values[1] 5029 ]); 5030 } 5031 }); 5032 5033 setTimeout(function() { 5034 baselThemeModule.$body.trigger('price_slider_create', [ 5035 current_min_price, 5036 current_max_price 5037 ]); 5038 if ($slider.find('.ui-slider-range').length > 1) { 5039 $slider.find('.ui-slider-range').first().remove(); 5040 } 5041 }, 10); 5042 }, 5043 5044 filtersArea: function() { 5045 var filters = $('.filters-area'), 5046 time = 200; 5047 5048 baselThemeModule.$body.on('click', '.open-filters', function(e) { 5049 e.preventDefault(); 5050 5051 if (isOpened()) { 5052 closeFilters(); 5053 } else { 5054 baselThemeModule.openFilters(); 5055 setTimeout(function() { 5056 baselThemeModule.shopLoader(); 5057 }, time); 5058 } 5059 }); 5060 5061 if (basel_settings.shop_filters_close === 'no') { 5062 baselThemeModule.$body.on('click', baselTheme.ajaxLinks, function() { 5063 if (isOpened()) { 5064 closeFilters(); 5065 } 5066 }); 5067 } 5068 5069 var isOpened = function() { 5070 filters = $('.filters-area'); 5071 return filters.hasClass('filters-opened'); 5072 }; 5073 5074 var closeFilters = function() { 5075 filters = $('.filters-area'); 5076 filters.removeClass('filters-opened'); 5077 filters.stop().slideUp(time); 5078 $('.open-filters').removeClass('btn-opened'); 5079 }; 5080 }, 5081 5082 openFilters: function(time) { 5083 var filters = $('.filters-area'); 5084 filters.addClass('filters-opened'); 5085 filters.stop().slideDown(time); 5086 $('.open-filters').addClass('btn-opened'); 5087 setTimeout(function() { 5088 filters.addClass('filters-opened'); 5089 baselThemeModule.$body.removeClass('body-filters-opened'); 5090 baselThemeModule.$document.trigger('basel-images-loaded'); 5091 }, time); 5092 }, 5093 5094 ajaxSearch: function() { 5095 var escapeRegExChars = function(value) { 5096 return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); 5097 }; 5098 5099 $('form.basel-ajax-search').each(function() { 5100 var $this = $(this), 5101 number = parseInt($this.data('count')), 5102 thumbnail = parseInt($this.data('thumbnail')), 5103 symbols_count = parseInt($this.data('symbols_count')), 5104 productCat = $this.find('[name="product_cat"]'), 5105 $results = $this.parent().find('.basel-search-results'), 5106 price = parseInt($this.data('price')), 5107 url = basel_settings.ajaxurl + '?action=basel_ajax_search', 5108 postType = $this.data('post_type'), 5109 sku = $this.data('sku'); 5110 5111 if (number > 0) { 5112 url += '&number=' + number; 5113 } 5114 5115 url += '&post_type=' + postType; 5116 5117 $results.on('click', '.view-all-result', function() { 5118 $this.submit(); 5119 }); 5120 5121 if (productCat.length && productCat.val() !== '') { 5122 url += '&product_cat=' + productCat.val(); 5123 } 5124 5125 $this.find('[type="text"]').on('focus keyup', function() { 5126 var $input = $(this); 5127 5128 if ($input.hasClass('basel-search-inited')) { 5129 return; 5130 } 5131 5132 $input.devbridgeAutocomplete({ 5133 serviceUrl : url, 5134 appendTo : $results, 5135 minChars : symbols_count, 5136 deferRequestBy : basel_settings.ajax_search_delay, 5137 onSelect : function(suggestion) { 5138 if (suggestion.permalink.length > 0) { 5139 window.location.href = suggestion.permalink; 5140 } 5141 }, 5142 onSearchStart : function() { 5143 $this.addClass('search-loading'); 5144 }, 5145 beforeRender : function(container) { 5146 $(container).find('.suggestion-divider-text').parent().addClass('suggestion-divider'); 5147 if (container[0].childElementCount > 2) { 5148 $(container).append('<div class="view-all-result"><span>' + basel_settings.all_results + '</span></div>'); 5149 } 5150 5151 }, 5152 onSearchComplete: function() { 5153 $this.removeClass('search-loading'); 5154 5155 baselThemeModule.$document.trigger('basel-images-loaded'); 5156 }, 5157 formatResult : function(suggestion, currentValue) { 5158 if (currentValue === '&') { 5159 currentValue = '&'; 5160 } 5161 var pattern = '(' + escapeRegExChars(currentValue) + ')', 5162 returnValue = ''; 5163 5164 if (suggestion.divider) { 5165 returnValue += ' <h5 class="suggestion-divider-text">' + suggestion.divider + '</h5>'; 5166 } 5167 5168 if (thumbnail && suggestion.thumbnail) { 5169 returnValue += ' <div class="suggestion-thumb">' + suggestion.thumbnail + '</div>'; 5170 } 5171 5172 if (suggestion.value) { 5173 returnValue += '<h4 class="suggestion-title result-title">' + suggestion.value 5174 .replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>') 5175 .replace(/<(\/?strong)>/g, '<$1>') + '</h4>'; 5176 } 5177 5178 if (sku && suggestion.sku) { 5179 returnValue += ' <div class="suggestion-sku">' + suggestion.sku + '</div>'; 5180 } 5181 5182 if (price && suggestion.price) { 5183 returnValue += ' <div class="suggestion-price price">' + suggestion.price + '</div>'; 5184 } 5185 5186 return returnValue; 5187 } 5188 }); 5189 5190 if (productCat.length) { 5191 var searchForm = $this.find('[type="text"]').devbridgeAutocomplete(), 5192 serviceUrl = basel_settings.ajaxurl + '?action=basel_ajax_search'; 5193 5194 if (number > 0) { 5195 serviceUrl += '&number=' + number; 5196 } 5197 serviceUrl += '&post_type=' + postType; 5198 5199 productCat.on('cat_selected', function() { 5200 if (productCat.val()) { 5201 searchForm.setOptions({ 5202 serviceUrl: serviceUrl + '&product_cat=' + productCat.val() 5203 }); 5204 } else { 5205 searchForm.setOptions({ 5206 serviceUrl: serviceUrl 5207 }); 5208 } 5209 5210 searchForm.hide(); 5211 searchForm.onValueChange(); 5212 }); 5213 } 5214 5215 $input.addClass('basel-search-inited'); 5216 }); 5217 5218 baselThemeModule.$document.on('click', function(e) { 5219 var target = e.target; 5220 5221 if (!$(target).is('.search-extended') && !$(target).parents().is('.search-extended')) { 5222 $this.find('[type="text"]').devbridgeAutocomplete('hide'); 5223 } 5224 }); 5225 5226 $('.basel-search-results').on('click', function(e) { 5227 e.stopPropagation(); 5228 }); 5229 }); 5230 }, 5231 5232 searchFullScreen: function() { 5233 var body = baselThemeModule.$body,
5234 searchWrapper = $('.basel-search-wrapper'); 5235 5236 body.on('click', '.search-button > a', function(e) { 5237 e.preventDefault(); 5238 5239 if (!searchWrapper.find('.searchform').hasClass('basel-ajax-search') && $('.search-button').hasClass('basel-search-dropdown') || baselThemeModule.windowWidth < 1024) { 5240 return; 5241 } 5242 5243 if ($('.sticky-header.act-scroll').length > 0) { 5244 searchWrapper = $('.sticky-header .basel-search-wrapper'); 5245 } else { 5246 searchWrapper = $('.main-header .basel-search-wrapper'); 5247 } 5248 if (isOpened()) { 5249 closeWidget(); 5250 } else { 5251 setTimeout(function() { 5252 openWidget(); 5253 }, 10); 5254 } 5255 }); 5256 5257 body.on('click', '.basel-close-search, .main-header, .sticky-header, .topbar-wrapp, .main-page-wrapper, .header-banner', function(event) { 5258 if (!$(event.target).is('.basel-close-search') && $(event.target).closest('.basel-search-wrapper').length) { 5259 return; 5260 } 5261 5262 if (isOpened()) { 5263 closeWidget(); 5264 } 5265 }); 5266 5267 var closeWidget = function() { 5268 baselThemeModule.$body.removeClass('basel-search-opened'); 5269 searchWrapper.removeClass('search-overlap'); 5270 }; 5271 5272 var openWidget = function() { 5273 var $bar = $('#wpadminbar'); 5274 var $mainHeader = $('.main-header'); 5275 var $topBar = $('.topbar-wrapp'); 5276 var $spacing = $('.header-spacing'); 5277 var $stickyHeader = $('.sticky-header'); 5278 var bar = $bar.length > 0 ? $bar.outerHeight() : 0; 5279 var banner = $('.header-banner').outerHeight(); 5280 var offset = $mainHeader.outerHeight() + bar; 5281 5282 if (!$mainHeader.hasClass('act-scroll')) { 5283 offset += $topBar.length > 0 ? $topBar.outerHeight() : 0; 5284 if (baselThemeModule.$body.hasClass('header-banner-display')) { 5285 offset += banner; 5286 } 5287 } 5288 5289 if ($stickyHeader.hasClass('header-clone') && $stickyHeader.hasClass('act-scroll')) { 5290 offset = $stickyHeader.outerHeight() + bar; 5291 } 5292 5293 if ($mainHeader.hasClass('header-menu-top') && $spacing) { 5294 offset = $spacing.outerHeight() + bar; 5295 if (baselThemeModule.$body.hasClass('header-banner-display')) { 5296 offset += banner; 5297 } 5298 } 5299 5300 if ($('.header-menu-top').hasClass('act-scroll')) { 5301 offset = $('.header-menu-top.act-scroll .navigation-wrap').outerHeight() + bar; 5302 } 5303 5304 searchWrapper.css('top', offset); 5305 5306 baselThemeModule.$body.addClass('basel-search-opened'); 5307 searchWrapper.addClass('search-overlap'); 5308 setTimeout(function() { 5309 searchWrapper.find('input[type="text"]').focus(); 5310 baselThemeModule.$window.one('scroll', function() { 5311 if (isOpened()) { 5312 closeWidget(); 5313 } 5314 }); 5315 }, 300); 5316 }; 5317 5318 var isOpened = function() { 5319 return baselThemeModule.$body.hasClass('basel-search-opened'); 5320 }; 5321 }, 5322 5323 loginTabs: function() { 5324 var tabs = $('.basel-register-tabs'), 5325 btn = tabs.find('.basel-switch-to-register'), 5326 title = $('.col-register-text h2'), 5327 loginText = tabs.find('.login-info'), 5328 classOpened = 'active-register', 5329 loginLabel = btn.data('login'), 5330 registerLabel = btn.data('register'), 5331 loginTitleLabel = btn.data('login-title'), 5332 registerTitleLabel = btn.data('reg-title'); 5333 5334 btn.on('click', function(e) { 5335 e.preventDefault(); 5336 5337 if (isShown()) { 5338 hideRegister(); 5339 } else { 5340 showRegister(); 5341 } 5342 5343 if (baselThemeModule.windowWidth < 768) { 5344 $('html, body').stop().animate({ 5345 scrollTop: tabs.offset().top - 50 5346 }, 400); 5347 } 5348 }); 5349 5350 var showRegister = function() { 5351 tabs.addClass(classOpened); 5352 btn.text(loginLabel); 5353 if (loginText.length > 0) { 5354 title.text(loginTitleLabel); 5355 } 5356 }; 5357 5358 var hideRegister = function() { 5359 tabs.removeClass(classOpened); 5360 btn.text(registerLabel); 5361 if (loginText.length > 0) { 5362 title.text(registerTitleLabel); 5363 } 5364 }; 5365 5366 var isShown = function() { 5367 return tabs.hasClass(classOpened); 5368 }; 5369 }, 5370 5371 productAccordion: function() { 5372 var $accordion = $('.tabs-layout-accordion'); 5373 var time = 300; 5374 var hash = window.location.hash; 5375 var url = window.location.href; 5376 5377 if (hash.toLowerCase().indexOf('comment-') >= 0 || hash === '#reviews' || hash === '#tab-reviews') { 5378 $accordion.find('.tab-title-reviews').addClass('active'); 5379 } else if (url.indexOf('comment-page-') > 0 || url.indexOf('cpage=') > 0) { 5380 $accordion.find('.tab-title-reviews').addClass('active'); 5381 } else { 5382 $accordion.find('.basel-accordion-title').first().addClass('active'); 5383 } 5384 5385 $('.woocommerce-review-link').on('click', function() { 5386 $('.basel-accordion-title.tab-title-reviews').click(); 5387 }); 5388 5389 $accordion.on('click', '.basel-accordion-title', function(e) { 5390 e.preventDefault(); 5391 5392 var $this = $(this), 5393 $panel = $this.siblings('.woocommerce-Tabs-panel'); 5394 5395 if ($this.hasClass('active')) { 5396 $this.removeClass('active'); 5397 $panel.stop().slideUp(time); 5398 } else { 5399 $accordion.find('.basel-accordion-title').removeClass('active'); 5400 $accordion.find('.woocommerce-Tabs-panel').slideUp(); 5401 $this.addClass('active'); 5402 $panel.stop().slideDown(time); 5403 } 5404 5405 baselThemeModule.$window.trigger('resize'); 5406 5407 setTimeout(function() { 5408 baselThemeModule.$window.trigger('resize'); 5409 }, time); 5410 5411 baselThemeModule.$document.trigger('basel-images-loaded'); 5412 }); 5413 }, 5414 5415 countDownTimer: function() { 5416 $('.basel-timer').each(function() { 5417 var $this = $(this); 5418 var timeZone = $this.data('timezone'); 5419 dayjs.extend(window.dayjs_plugin_utc); 5420 dayjs.extend(window.dayjs_plugin_timezone); 5421 var time = dayjs.tz($this.data('end-date'), timeZone); 5422 $this.countdown(time.toDate(), function(event) { 5423 $this.html(event.strftime('' 5424 + '<span class="countdown-days">%-D <span>' + basel_settings.countdown_days + '</span></span> ' 5425 + '<span class="countdown-hours">%H <span>' + basel_settings.countdown_hours + '</span></span> ' 5426 + '<span class="countdown-min">%M <span>' + basel_settings.countdown_mins + '</span></span> ' 5427 + '<span class="countdown-sec">%S <span>' + basel_settings.countdown_sec + '</span></span>')); 5428 }); 5429 }); 5430 }, 5431 5432 mobileFastclick: function() { 5433 if ('addEventListener' in document) { 5434 document.addEventListener('DOMContentLoaded', function() { 5435 FastClick.attach(document.body); 5436 }, false); 5437 } 5438 }, 5439 5440 woocommerceComments: function() { 5441 var hash = window.location.hash; 5442 var url = window.location.href; 5443 5444 if (hash.toLowerCase().indexOf('comment-') >= 0 || hash === '#reviews' || hash === '#tab-reviews' || url.indexOf('comment-page-') > 0 || url.indexOf('cpage=') > 0 || hash === '#tab-basel_additional_tab' || hash === '#tab-basel_custom_tab') { 5445 5446 setTimeout(function() { 5447 window.scrollTo(0, 0); 5448 }, 1); 5449 5450 setTimeout(function() { 5451 if ($(hash).length > 0) { 5452 $('html, body').stop().animate({
5453 scrollTop: $(hash).offset().top - 100 5454 }, 400); 5455 } 5456 }, 10); 5457 } 5458 }, 5459 5460 woocommerceQuantity: function() { 5461 if (!String.prototype.getDecimals) { 5462 String.prototype.getDecimals = function() { 5463 var num = this, 5464 match = ('' + num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/); 5465 if (!match) { 5466 return 0; 5467 } 5468 return Math.max(0, (match[1] ? match[1].length : 0) - (match[2] ? +match[2] : 0)); 5469 }; 5470 } 5471 5472 baselThemeModule.$document.on('click', '.plus, .minus', function() { 5473 // Get values 5474 var $this = $(this); 5475 var $qty = $this.closest('.quantity').find('.qty'), 5476 currentVal = parseFloat($qty.val()), 5477 max = parseFloat($qty.attr('max')), 5478 min = parseFloat($qty.attr('min')), 5479 step = $qty.attr('step'); 5480 5481 // Format values 5482 if (!currentVal || currentVal === '' || currentVal === 'NaN') { 5483 currentVal = 0; 5484 } 5485 if (max === '' || max === 'NaN') { 5486 max = ''; 5487 } 5488 if (min === '' || min === 'NaN') { 5489 min = 0; 5490 } 5491 if (step === 'any' || step === '' || step === undefined || parseFloat(step) === 'NaN') { 5492 step = '1'; 5493 } 5494 5495 // Change the value 5496 if ($this.is('.plus')) { 5497 if (max && (currentVal >= max)) { 5498 $qty.val(max); 5499 } else { 5500 $qty.val((currentVal + parseFloat(step)).toFixed(step.getDecimals())); 5501 } 5502 } else { 5503 if (min && (currentVal <= min)) { 5504 $qty.val(min); 5505 } else if (currentVal > 0) { 5506 $qty.val((currentVal - parseFloat(step)).toFixed(step.getDecimals())); 5507 } 5508 } 5509 5510 $qty.trigger('change'); 5511 }); 5512 }, 5513 5514 frequentlyBoughtTogether: function () { 5515 $('form.basel-fbt-form').each( function () { 5516 var timeout = ''; 5517 var $form = $(this); 5518 5519 $form.on('change', '.basel-fbt-product input, .basel-fbt-product select', function () { 5520 var $this = $(this); 5521 var productsID = getProductsId($form); 5522 var mainProduct = $form.find('input[name=basel-fbt-main-product]').val(); 5523 var btn = $form.find('.basel-fbt-purchase-btn'); 5524 5525 if ( ! productsID || 'undefined' === typeof productsID[mainProduct] ) { 5526 return; 5527 } 5528 5529 if ( 2 > Object.keys(productsID).length ) { 5530 btn.addClass('disabled'); 5531 } else { 5532 btn.removeClass('disabled'); 5533 } 5534 5535 var $carousel = $form.parents('.basel-fbt').find('.owl-carousel') 5536 var index = $this.parents('.basel-fbt-product').index(); 5537 5538 if ( !$($carousel.find('.owl-item')[index]).hasClass('active') ) { 5539 if ( 1 === index && 'undefined' !== typeof $carousel.data('owl.carousel') && 1 < $carousel.data('owl.carousel').settings.items ) { 5540 index = 0; 5541 } 5542 5543 $carousel.trigger('to.owl.carousel', [index, 500, true]); 5544 } 5545 5546 clearTimeout(timeout); 5547 5548 timeout = setTimeout(function () { 5549 updatePrice($form, productsID); 5550 }, 1000); 5551 }); 5552 5553 $form.on('change', '.basel-fbt-product select', function () { 5554 var $this = $(this); 5555 var productID = $this.parents('.basel-fbt-product').data('id'); 5556 var productWrapper = $this.parents('.basel-fbt').find('.product-grid-item[data-id=' + productID + ']'); 5557 var $img = productWrapper.find('a > img, a > picture > img'); 5558 var imageSrc = $this.find('option:selected').data('image-src'); 5559 var imageSrcset = $this.find('option:selected').data('image-srcset'); 5560 5561 if ( $img.attr('srcset') ) { 5562 if ( ! imageSrcset ) { 5563 imageSrcset = imageSrc; 5564 } 5565 5566 $img.attr('srcset', imageSrcset); 5567 } 5568 5569 $img.attr('src', imageSrc); 5570 }); 5571 5572 $form.on('click', '.basel-fbt-purchase-btn', function (e) { 5573 e.preventDefault(); 5574 5575 var $this = $(this); 5576 5577 if ( $this.hasClass('disabled') ) { 5578 return; 5579 } 5580 5581 var productsID = getProductsId($form); 5582 var mainProduct = $form.find('input[name=basel-fbt-main-product]').val(); 5583 var bundlesId = $form.find('input[name=basel-fbt-bundle-id]').val(); 5584 5585 if ( ! productsID || 'undefined' === typeof productsID[mainProduct] ) { 5586 return; 5587 } 5588 5589 clearTimeout(timeout); 5590 5591 $this.addClass('loading'); 5592 5593 $.ajax({ 5594 url : basel_settings.ajaxurl, 5595 data : { 5596 action : 'basel_purchasable_fbt_products', 5597 products_id : productsID, 5598 main_product : mainProduct, 5599 bundle_id : bundlesId, 5600 key : basel_settings.frequently_bought, 5601 }, 5602 method : 'POST', 5603 success : function(response) { 5604 var $noticeWrapper = $('.woocommerce-notices-wrapper'); 5605 $noticeWrapper.empty(); 5606 5607 if (response.notices && response.notices.indexOf('error') > 0) { 5608 $noticeWrapper.append(response.notices); 5609 5610 var scrollTo = $noticeWrapper.offset().top - basel_settings.ajax_scroll_offset; 5611 5612 $('html, body').stop().animate({ 5613 scrollTop: scrollTo 5614 }, 400); 5615 5616 return; 5617 } 5618 5619 if ('undefined' !== typeof response.fragments) { 5620 if ('undefined' !== typeof $.fn.magnificPopup && basel_settings.add_to_cart_action === 'widget') { 5621 $.magnificPopup.close(); 5622 } 5623 5624 $this.addClass('added'); 5625 5626 baselThemeModule.$body.trigger('added_to_cart', [ 5627 response.fragments, 5628 response.cart_hash, 5629 '' 5630 ]); 5631 5632 $( document.body ).trigger( 'wc_fragments_refreshed' ); 5633 } 5634 }, 5635 error : function() { 5636 console.log('ajax error'); 5637 }, 5638 complete: function() { 5639 $this.removeClass('loading'); 5640 } 5641 }); 5642 }); 5643 }); 5644 5645 function getProductsId($form) { 5646 var productsID = {}; 5647 5648 $form.find('.basel-fbt-product').each( function () { 5649 var $this = $(this); 5650 var $input = $(this).find('input'); 5651 var productId = $this.data('id'); 5652 var productWrapper = $form.parents('.basel-fbt'); 5653 5654 if ( $input.length ) { 5655 if ( $input.is(':checked') ) { 5656 if ( $this.find('.basel-fbt-product-variation').length ) { 5657 productsID[productId] = $this.find('.basel-fbt-product-variation select').val(); 5658 } else { 5659 productsID[productId] = ''; 5660 } 5661 5662 productWrapper.find('.product.post-' + productId ).removeClass('basel-disabled-fbt'); 5663 } else if ( ! $input.parents('.basel-fbt-form').hasClass('basel-checkbox-uncheck') ) { 5664 productWrapper.find('.product.post-' + productId).addClass('basel-disabled-fbt'); 5665 } 5666 } else { 5667 if ( $this.find('.basel-fbt-product-variation').length ) { 5668 productsID[productId] = $this.find('.basel-fbt-product-variation select').val(); 5669 } else { 5670 productsID[productId] = ''; 5671 } 5672 } 5673 }); 5674 5675 return productsID; 5676 } 5677 5678 function updatePrice( $wrapper, productsID ) { 5679 var mainProduct = $wrapper.find('input[name=basel-fbt-main-product]').val(); 5680 var bundleId = $wrapper.find('input[name=basel-fbt-bundle-id]').val(); 5681 5682 $wrapper.find('.basel-loader-overlay').addClass( 'loading' ); 5683 5684 $.ajax({ 5685 url : basel_settings.ajaxurl, 5686 data : { 5687 action : 'basel_update_frequently_bought_price', 5688 products_id : productsID, 5689 main_product: mainProduct, 5690 bundle_id : bundleId, 5691 }, 5692 method : 'POST', 5693 success : function(response) { 5694 if (response.fragments) { 5695 $.each( response.fragments, function( key, value ) { 5696 $( key ).replaceWith(value); 5697 }); 5698 } 5699 }, 5700 error : function() { 5701 console.log('ajax error'); 5702 }, 5703 complete: function() { 5704 $wrapper.find('.basel-loader-overlay').removeClass('loading'); 5705 } 5706 }); 5707 } 5708 }, 5709 5710 dynamicDiscountsTable: function () { 5711 let $dynamicDiscountsTable = $('.basel-dynamic-discounts'); 5712 5713 if (!$dynamicDiscountsTable.length) { 5714 return; 5715 } 5716 5717 let $variation_forms = $('.variations_form'); 5718 let originalPriceTable = $dynamicDiscountsTable.html(); 5719 5720 function reInitPricingTableRowsClick() { 5721 $('.basel-dynamic-discounts tbody tr').each(function () { 5722 let $row = $(this); 5723 let min = $row.data('min'); 5724 5725 $row.off('click').on('click', function() { 5726 let $quantityInput = $('.quantity input.qty[name="quantity"]'); 5727 5728 $quantityInput.val(min).trigger('change'); 5729 }); 5730 }); 5731 } 5732 5733 function addActiveClassToTable( $pricing_table, currentQuantityValue ) { 5734 $pricing_table.find('tbody tr').each(function () { 5735 let $row = $(this); 5736 let min = $row.data('min'); 5737 let max = $row.data('max'); 5738 5739 if ( ( ! max && min <= currentQuantityValue ) || ( min <= currentQuantityValue && currentQuantityValue <= max ) ) { 5740 $row.addClass('basel-active'); 5741 } else { 5742 $row.removeClass('basel-active'); 5743 } 5744 }); 5745 } 5746 5747 $variation_forms.each(function () { 5748 let $variation_form = $(this); 5749 5750 $variation_form.on('found_variation', function (event, variation) { 5751 $.ajax({ 5752 url : basel_settings.ajaxurl, 5753 data : { 5754 action : 'basel_update_discount_dynamic_discounts_table', 5755 variation_id: variation.variation_id, 5756 }, 5757 beforeSend: function () { 5758 $dynamicDiscountsTable.find('.basel-loader-overlay').addClass('basel-loading'); 5759 }, 5760 success : ( data ) => { 5761 $dynamicDiscountsTable.html( data ); 5762 reInitPricingTableRowsClick(); 5763 5764 addActiveClassToTable( $('.basel-dynamic-discounts'), $(this).find('[name="quantity"]').val() ); 5765 $dynamicDiscountsTable.find('.basel-loader-overlay').removeClass('basel-loading'); 5766 }, 5767 dataType: 'json', 5768 method : 'GET' 5769 }); 5770 }) 5771 5772 $variation_form.on('click', '.reset_variations', function () { 5773 $dynamicDiscountsTable.html(originalPriceTable); 5774 reInitPricingTableRowsClick(); 5775 5776 addActiveClassToTable( $('.basel-dynamic-discounts'), $(this).closest('form').find('.quantity input.qty[name="quantity"]').val() ); 5777 }); 5778 }); 5779 5780 reInitPricingTableRowsClick(); 5781 5782 $('.quantity input.qty[name="quantity"]').off('change').on('change', function() { 5783 addActiveClassToTable( $dynamicDiscountsTable, $(this).val() ); 5784 }); 5785 }, 5786 5787 freeGiftsTable: function () { 5788 var isCheckout = $('.woocommerce-checkout').length > 0; 5789 var isCart = $('.woocommerce-cart').length > 0; 5790 5791 if (!isCheckout && !isCart) { 5792 return; 5793 } 5794 5795 $(document).on('click', '.basel-add-gift-product', function (e) { 5796 e.preventDefault() 5797 5798 var $this = $(this); 5799 5800 if ( $this.hasClass('basel-disabled') ) { 5801 return; 5802 } 5803 5804 var fgTableWrapper = $this.parents('.basel-fg'); 5805 var loaderOverlay = fgTableWrapper.find('.basel-loader-overlay'); 5806 var productId = $this.data('productId'); 5807 5808 loaderOverlay.addClass('loading'); 5809 5810 $.ajax({ 5811 url : basel_settings.ajaxurl, 5812 data : { 5813 action: 'basel_add_gift_product', 5814 product_id: productId, 5815 security: $this.data('security'), 5816 is_checkout: isCheckout ? '1' : '0', 5817 }, 5818 method : 'POST', 5819 success : function(response) { 5820 if (!response) { 5821 return; 5822 } 5823 5824 jQuery(document.body).trigger(isCheckout ? 'update_checkout' : 'wc_update_cart'); 5825 }, 5826 error : function() { 5827 console.log('ajax adding gift to cart error'); 5828 }, 5829 complete: function() { 5830 loaderOverlay.removeClass('loading'); 5831 } 5832 }); 5833 }) 5834 } 5835 }; 5836 }()); 5837})(jQuery); 5838 5839jQuery(document).ready(function() {
5840 baselThemeModule.init(); 5841}); 5842 5843window.onpopstate = function() { 5844 baselThemeModule.sortByWidget(); 5845} 5846 5847jQuery(window).on('baselEventStarted', function() { 5848 baselThemeModule.fixedHeaders(); 5849 baselThemeModule.menuSetUp(); 5850 baselThemeModule.btnsToolTips(); 5851 baselThemeModule.shopLoader(); 5852 baselThemeModule.productLoaderPosition(); 5853 baselThemeModule.menuOffsets(); 5854 baselThemeModule.ajaxSearch(); 5855 baselThemeModule.productsLoadMore(); 5856}); 5857 5858window.onload = function() { 5859 var events = [ 5860 'keydown', 5861 'scroll', 5862 'mouseover', 5863 'touchmove', 5864 'touchstart', 5865 'mousedown', 5866 'mousemove' 5867 ]; 5868 5869 var triggerListener = function(e) { 5870 jQuery(window).trigger('baselEventStarted'); 5871 removeListener(); 5872 }; 5873 5874 var removeListener = function() { 5875 events.forEach(function(eventName) { 5876 window.removeEventListener(eventName, triggerListener); 5877 }); 5878 }; 5879 5880 var addListener = function(eventName) { 5881 window.addEventListener(eventName, triggerListener); 5882 }; 5883 5884 events.forEach(function(eventName) { 5885 addListener(eventName); 5886 }); 5887};
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.