1$.ajaxSetup({ cache: false }); 2 3var main = { 4 init: function () { 5 var _this = this; 6 7 _this.breadcrumbsScroll(); 8 _this.expandAccordionText(); 9 _this.expandText(); 10 _this.switchThemeType(); 11 if(!globalThemeSettings.isMobile && !globalThemeSettings.isDesktopDisplayMobileInterface){ 12 _this.defineWidthWindowIsMobile(); 13 14 $(window).on('resize', _this.defineWidthWindowIsMobile); 15 } 16 }, 17 breadcrumbsScroll: function (){ 18 var breadcrumbsWrap = $('.js-breadcrumbs-scroll'); 19 20 if(breadcrumbsWrap.length){ 21 var breadcrumbsWrapWidth = breadcrumbsWrap[0].scrollWidth, 22 breadcrumbsLastItem = breadcrumbsWrap.find("li").last(), 23 scrollLeft = breadcrumbsWrapWidth; 24 25 if(breadcrumbsLastItem.length){ 26 scrollLeft = scrollLeft - breadcrumbsLastItem[0].scrollWidth - 25; 27 } 28 breadcrumbsWrap.scrollLeft(scrollLeft); 29 } 30 }, 31 expandAccordionText: function (){ 32 $('body').on("click", ".js-extend-accordion-title", function (){ 33 var outerList = $(this).closest('.extend-accordion__list'), 34 openItem = outerList.find(".js-extend-accordion-item.open"), 35 currentItem = $(this).closest(".js-extend-accordion-item"), 36 currentItemText = currentItem.find(".js-extend-accordion-text"); 37 38 if(openItem.length){ 39 var openItemText = openItem.find(".js-extend-accordion-text"); 40 41 openItemText.slideUp(250, function() { 42 openItem.addClass("close").removeClass("open"); 43 }); 44 } 45 if(!currentItemText.is(":visible")){ 46 currentItemText.slideDown(250, function() { 47 currentItem.addClass("open").removeClass("close"); 48 }); 49 }else{ 50 currentItemText.slideUp(250, function() { 51 currentItem.addClass("close").removeClass("open"); 52 }); 53 } 54 }); 55 }, 56 expandText: function (){ 57 $('body').on("click", ".js-open-expand-text", function (){ 58 var wrap = $(this).closest(".js-expand-text-item"), 59 text = wrap.find(".js-expand-text"); 60 61 if(!text.is(":visible")){ 62 text.slideDown(250, function() { 63 wrap.addClass("open").removeClass("close"); 64 }); 65 }else{ 66 text.slideUp(250, function() { 67 wrap.addClass("close").removeClass("open"); 68 }); 69 } 70 }); 71 }, 72 defineWidthWindowIsMobile: function (){ 73 var isMobileCookie = $.cookie("is_mobile") == 1, 74 isWindowWidthMobile = $(window).width() < 1024; 75 76 if(isMobileCookie && !isWindowWidthMobile){ 77 $.cookie("is_mobile", 0); 78 location.reload(); 79 }else if(!isMobileCookie && isWindowWidthMobile){ 80 $.cookie("is_mobile", 1); 81 location.reload(); 82 } 83 }, 84 switchThemeType: function (){ 85 var outerWrap = $('.js-switch-type-theme'); 86 87 outerWrap.on("click", function (){ 88 if( $("html").hasClass("dark-theme")){ 89 $("html").removeClass("dark-theme"); 90 localStorage.setItem("type_theme", "light"); 91 }else{ 92 $("html").addClass("dark-theme"); 93 localStorage.setItem("type_theme", "dark"); 94 } 95 }); 96 } 97}; 98 99var dropDownList = { 100 init: function (){ 101 var _this = this; 102 103 _this.open('.js-drop-down-toggle', '.js-drop-down-list'); 104 }, 105 open: function (linkSelector, wrapParentSelector){ 106 var _this = this; 107 108 $('body').on("click", linkSelector, function(){ 109 var list = $(this).closest(wrapParentSelector); 110 111 list.siblings().removeClass('open'); 112 list.siblings().find(wrapParentSelector).removeClass('open'); 113 114 if(list.hasClass('open')){ 115 list.removeClass('open'); 116 }else{ 117 list.addClass('open'); 118 } 119 }); 120 121 $('body').on("click", linkSelector+ ' a', function(event){ 122 event.preventDefault(); 123 }); 124 125 $(document).click(function(event) { 126 if(!$(event.target).closest(wrapParentSelector).length) { 127 $(wrapParentSelector).each(function (){ 128 $(this).removeClass('open'); 129 }); 130 } 131 }); 132 } 133}; 134 135var anchorLink = { 136 init: function (){ 137 var anchorLink = $('.js-move-to-tab'); 138 139 anchorLink.on("click", function(event){ 140 event.preventDefault(); 141 142 var $this = $(this), 143 idWrapContent = $this.data('tab-content'); 144 145 var contentTabWrap = $('.js-tab-content#' + idWrapContent), 146 contentAccordionTabWrap = $('.js-accordion-tab#' + idWrapContent), 147 contentPopupTabWrap = $('.js-popup-tab-content#' + idWrapContent), 148 content = $('#' + idWrapContent); 149 150 if(contentTabWrap.length){ 151 tabs.moveToTabContent($this, contentTabWrap); 152 }else if(contentAccordionTabWrap.length){ 153 accordionTabs.moveToTabContent($this, contentAccordionTabWrap); 154 }else if(contentPopupTabWrap.length){ 155 popupTabs.openTab(contentPopupTabWrap); 156 }else{ 157 var top = content.offset().top - 40; 158 if($('.js-header-fixed').length){ 159 top = top - 70; 160 } 161 $('html,body').animate({ 162 scrollTop: top 163 }, 500); 164 } 165 }); 166 } 167} 168 169var tabs = { 170 init: function (){ 171 var _this = this; 172 173 _this.initSelectTab(); 174 _this.selectTab(); 175 }, 176 selectTab: function (){ 177 var _this = this, 178 button = $('.js-tab'); 179 180 button.on("click", function(){ 181 var $this = $(this); 182 183 _this.setSelectTab($this); 184 }); 185 }, 186 setSelectTab: function (button){ 187 var _this = this, 188 contentWrapId = button.data('tab-content'), 189 content = button.closest('.js-tabs-outer').find('.js-tab-content'), 190 currentContent = button.closest('.js-tabs-outer').find('#' + contentWrapId), 191 prevTab = button.closest('.js-tabs-outer').find('.js-tab.selected'); 192 193 _this.tabAddClassSelect(button); 194 195 content.removeClass('selected'); 196 currentContent.addClass('selected'); 197 198 iframes.load(currentContent.find('.js-iframe-load')); 199 spoilerWrap.addButton(currentContent.find('.js-spoiler-outer')); 200 201 var tabsWrapScroll = button.closest('.js-tabs-outer').find('.js-tabs-wrap-scroll'); 202 if(tabsWrapScroll.length){ 203 var isTabsWrapHasScroll = tabsWrapScroll[0].offsetWidth < tabsWrapScroll[0].scrollWidth; 204 205 if(isTabsWrapHasScroll){ 206 var tabsWrapScrollLeft = tabsWrapScroll[0].scrollLeft, 207 $thisTabOffset = button.offset(), 208 $thisTabOffsetLeft = $thisTabOffset.left; 209 210 if(prevTab.length){ 211 var prevTabOffset = prevTab.offset(), 212 prevTabOffsetLeft = prevTabOffset.left; 213 } 214 215 /* еÑли пеÑеклÑÑание по Ñабам в пÑавÑÑ ÑÑоÑонÑ, Ñо ÑкÑолл двигаеÑÑÑ Ð²Ð¿Ñаво */ 216 if(!prevTab.length || prevTabOffsetLeft < $thisTabOffsetLeft){ 217 tabsWrapScroll.animate({scrollLeft: tabsWrapScrollLeft + $thisTabOffsetLeft - 10}, 500); 218 219 /* еÑли пеÑеклÑÑание по Ñабам в левÑÑ (обÑаÑнÑÑ) ÑÑоÑонÑ, Ñо ÑкÑолл двигаеÑÑÑ Ð²Ð»ÐµÐ²Ð¾ (назад) */ 220 }else if(prevTabOffsetLeft > $thisTabOffsetLeft){ 221 var $thisTabWidth = button.outerWidth(true), 222 $thisTabOffsetRight = $thisTabOffsetLeft + $thisTabWidth, 223 tabsWrapWidth = tabsWrapScroll.outerWidth(true); 224 225 tabsWrapScroll.animate({scrollLeft: tabsWrapScrollLeft + $thisTabOffsetRight - tabsWrapWidth - 10}, 500); 226 } 227 } 228 } 229 }, 230 moveToTabContent: function (anchorLink, currentTabContent){ 231 var _this = this,
232 tabsOuterWrap = currentTabContent.closest(".js-tabs-outer"), 233 allTabsContent = tabsOuterWrap.find('.js-tab-content'), 234 tab = tabsOuterWrap.find('.js-tab'), 235 thisTfb = tabsOuterWrap.find('.js-tab[data-tab-content="'+anchorLink.data('tab-content')+'"]'); 236 237 _this.tabAddClassSelect(thisTfb); 238 239 allTabsContent.removeClass('selected'); 240 currentTabContent.addClass('selected'); 241 242 var top = currentTabContent.offset().top - 115; 243 if($('.js-header-fixed').length){ 244 top = top - 75; 245 } 246 $('html,body').animate({ 247 scrollTop: top 248 }, 500); 249 }, 250 initSelectTab: function (){ 251 var tabsWrapOuter = $('.js-tabs-outer'); 252 253 if(tabsWrapOuter.length){ 254 tabsWrapOuter.each(function (){ 255 var $this = $(this), 256 selectedTab = $this.find('.js-tab.selected'); 257 258 if(!selectedTab.length){ 259 selectedTab = $this.find('.js-tab:first'); 260 261 if(selectedTab.length){ 262 var tabContent = tabsWrapOuter.find('#' + selectedTab.data('tab-content')); 263 264 if(tabContent.length){ 265 selectedTab.addClass('selected'); 266 tabContent.addClass('selected'); 267 iframes.lazyload(tabContent.find('.js-iframe-load')); 268 } 269 } 270 } 271 }); 272 } 273 }, 274 tabAddClassSelect: function (currentTab){ 275 var outerWrap = currentTab.closest(".js-tabs"), 276 prevTab = outerWrap.find(".js-tab.selected"), 277 movedWrap = outerWrap.find(".js-tab-moved-wrap"); 278 279 if(outerWrap.length && movedWrap.length && prevTab.length && currentTab.data("tab-content") != prevTab.data("tab-content")){ 280 var outerWrapPosition = outerWrap.offset(), 281 outerWrapPositionTop = outerWrapPosition.top, 282 outerWrapPositionLeft = outerWrapPosition.left, 283 284 prevTabPosition = prevTab.offset(), 285 prevTabPositionTop = prevTabPosition.top, 286 prevTabPositionLeft = prevTabPosition.left; 287 288 movedWrap.css("top", prevTabPositionTop - outerWrapPositionTop + "px"); 289 movedWrap.css("left", prevTabPositionLeft - outerWrapPositionLeft + "px"); 290 movedWrap.css("height", prevTab.outerHeight() + "px"); 291 movedWrap.css("width", prevTab.outerWidth() + "px"); 292 movedWrap.addClass("-sk-show"); 293 prevTab.removeClass("selected"); 294 295 var currentTabPosition = currentTab.offset(), 296 currentTabPositionTop = currentTabPosition.top, 297 currentTabPositionLeft = currentTabPosition.left; 298 299 movedWrap.animate({ 300 top : currentTabPositionTop - outerWrapPositionTop + "px", 301 left : currentTabPositionLeft - outerWrapPositionLeft + "px", 302 height : currentTab.outerHeight() + "px", 303 width : currentTab.outerWidth() + "px" 304 }, 100, function() { 305 movedWrap.removeClass("-sk-show"); 306 307 movedWrap.find(".js-tab").removeClass("selected"); 308 currentTab.addClass("selected"); 309 }); 310 }else{ 311 outerWrap.find(".js-tab").removeClass("selected"); 312 currentTab.addClass("selected"); 313 } 314 } 315}; 316 317var accordionTabs = { 318 init: function (){ 319 var _this = this; 320 321 _this.selectTab(); 322 }, 323 selectTab: function (){ 324 var button = $('.js-accordion-tab-title'); 325 326 button.on("click", function(){ 327 var $this = $(this), 328 currentContent = $this.closest('.js-accordion-tab'); 329 330 currentContent.toggleClass('selected'); 331 spoilerWrap.addButton(currentContent.find('.js-dropdown-wrap')); 332 iframes.load(currentContent.find('.js-iframe-load')); 333 }); 334 }, 335 moveToTabContent: function (anchorLink, currentTabContent){ 336 currentTabContent.addClass('selected'); 337 spoilerWrap.addButton(currentTabContent.find('.js-dropdown-wrap')); 338 339 var top = currentTabContent.offset().top - 40; 340 if($('.js-header-fixed').length){ 341 top = top - 70; 342 } 343 $('html,body').animate({ 344 scrollTop: top 345 }, 500); 346 } 347}; 348 349var popupTabs = { 350 init: function (){ 351 var _this = this; 352 353 _this.selectTab(); 354 _this.closeTab(); 355 }, 356 selectTab: function (){ 357 var _this = this, 358 button = $('.js-popup-tab'); 359 360 button.on("click", function(){ 361 var $this = $(this), 362 contentWrapId = $this.data('tab-content'), 363 tabContent = button.closest('.js-popup-tabs-outer').find('#' + contentWrapId); 364 365 _this.openTab(tabContent); 366 }); 367 }, 368 openTab: function (tabContent){ 369 var bg = $('.js-popup-bg'); 370 371 tabContent.css("top", "100%"); 372 tabContent.addClass("show"); 373 spoilerWrap.addButton(tabContent.find('.js-dropdown-wrap')); 374 iframes.load(tabContent.find('.js-iframe-load')); 375 tabContent.animate({ top: "30px" }, 300); 376 377 $('body').addClass("overflow-hidden"); 378 bg.addClass("-sk-show"); 379 }, 380 closeTab: function (){ 381 $('.js-popup-bg, .js-popup-tab-close').on("click", function(){ 382 var tabContent = $('.js-popup-tab-content'), 383 bg = $('.js-popup-bg'); 384 385 tabContent.animate({ top: '100%' }, 300, function (){ 386 tabContent.removeClass("show"); 387 tabContent.removeAttr("style"); 388 $('body').removeClass("overflow-hidden"); 389 bg.removeClass("-sk-show"); 390 }); 391 }); 392 } 393} 394 395var images = { 396 init: function () { 397 var _this = this; 398 399 _this.retinaLogo(); 400 _this.lazyloadImage(); 401 _this.retinaImage(); 402 }, 403 retinaLogo: function(){ 404 var logo = $('.js-logo-retina'); 405 406 if(logo.length){ 407 logo.retina({ force_original_dimensions: false }); 408 } 409 }, 410 retinaImage: function(){ 411 var image = $('.js-img-retina'); 412 413 if(image.length){ 414 image.retina({ force_original_dimensions: false }); 415 } 416 }, 417 lazyloadImage: function(){ 418 var image = $('.js-image-lazy'); 419 420 if(image.length){ 421 image.lazy({bind: "event"}); 422 } 423 } 424} 425 426var iframes = { 427 init: function () { 428 var _this = this, 429 iframes = $('.js-iframe-lazy'); 430 431 if(iframes.length){ 432 iframes.each(function(){ 433 var $this = $(this); 434 435 _this.lazyload($this); 436 }); 437 } 438 }, 439 lazyload: function(iframe){ 440 if(iframe.length){ 441 var thisSrc = iframe.data("src"),
442 timeDelay = iframe.data("delay"), 443 outerWrap = iframe.closest(".js-iframe-lazy-outer"), 444 iconLoading = outerWrap.find('.js-iframe-loading'); 445 446 if(timeDelay){ 447 timeDelay *= 1000; 448 }else{ 449 timeDelay = 3000; 450 } 451 452 setTimeout(function (){ 453 iconLoading.remove(); 454 iframe.attr('src', thisSrc); 455 iframe.removeClass('js-iframe-lazy').removeClass('js-iframe-load'); 456 }, timeDelay); 457 } 458 }, 459 load: function (iframe){ 460 if(iframe.length){ 461 var thisSrc = iframe.data("src"), 462 outerWrap = iframe.closest(".js-iframe-lazy-outer"), 463 iconLoading = outerWrap.find('.js-iframe-loading'); 464 465 iconLoading.remove(); 466 iframe.attr('src', thisSrc); 467 iframe.removeClass('js-iframe-lazy').removeClass('js-iframe-load'); 468 } 469 } 470} 471 472 473 474var touch = { 475 init: function () { 476 var _this = this; 477 478 _this.addTouchClass(); 479 }, 480 addTouchClass: function(){ 481 var _this = this; 482 483 if(_this.isTouchDevice()){ 484 $('body').removeClass('no-touch').addClass('touch'); 485 } 486 }, 487 isTouchDevice: function() { 488 return ( 'ontouchstart' in window ) || 489 ( navigator.maxTouchPoints > 0 ) || 490 ( navigator.msMaxTouchPoints > 0 ); 491 } 492}; 493 494var form = { 495 init: function (){ 496 var _this = this; 497 498 _this.formStyler(); 499 _this.submit(); 500 _this.numberIntType(); 501 }, 502 formStyler: function (){ 503 $('body').on('change', 'input[type="checkbox"]', function() { 504 if ($(this).is(':checked')) { 505 $(this).closest('.jq-checkbox, .js-checkbox-styler').addClass('checked'); 506 $(this).closest('label').addClass('checked'); 507 } else { 508 $(this).closest('.jq-checkbox, label, .js-checkbox-styler').removeClass('checked'); 509 $(this).closest('label').removeClass('checked'); 510 } 511 }); 512 513 $('body').on('change', 'input[type="radio"]', function() { 514 var inputs = $('input[type="radio"][name="'+$(this).attr('name')+'"]'); 515 inputs.each(function(){ 516 var input = $(this); 517 if (input.is(':checked')) { 518 input.closest('.jq-radio, .js-radio-styler').addClass('checked'); 519 input.closest('label').addClass('checked'); 520 }else{ 521 input.closest('.jq-radio, .js-radio-styler').removeClass('checked'); 522 input.closest('label').removeClass('checked'); 523 } 524 }); 525 526 }); 527 528 if(!globalThemeSettings.isFormStylerInit){ 529 return false; 530 } 531 532 var inputStyler = $('input[type="checkbox"]:not(.js-checkbox-styler-input):not(.js-none-styler):not(.shop-sk-callback__checkbox), input[type="radio"]:not(.js-radio-styler-input):not(.buy1step-auth__variant):not(.js-none-styler), .js-select'); 533 if(!inputStyler.length){ 534 return false; 535 } 536 inputStyler.styler(); 537 $('.searchpro__page-filters input[type="checkbox"], .searchpro__page-filters input[type="radio"]').styler('destroy'); 538 $('.onestep-cart input[type="checkbox"], .onestep-cart input[type="radio"]').styler('destroy'); 539 $('.js-addgifts__cart-item input[type="radio"]').styler('destroy'); 540 }, 541 submit: function (){ 542 $('body').on("click", ".js-submit-form", function (){ 543 var $this = $(this), 544 form = $this.closest("form"); 545 546 if(!$this.hasClass('disabled')){ 547 form.submit(); 548 } 549 }); 550 }, 551 numberIntType: function (){ 552 $('body').on("keyup", ".js-int-number", function(){ 553 var reg_number = /[^0-9]/g; 554 555 $(this).val($(this).val().replace(reg_number, '')); 556 }); 557 } 558}; 559 560var headerFixed = { 561 init: function (){ 562 var _this = this; 563 564 var headerFixedWrap = $('.js-header-fixed'); 565 566 if(!headerFixedWrap.length){ 567 return false; 568 } 569 570 _this.showHide(); 571 $(window).scroll(function() { 572 _this.showHide(); 573 }); 574 }, 575 showHide: function (){ 576 var _this = this, 577 wrap = $('.js-header-fixed'), 578 contentTop = $('#page-content'), 579 headerPopupMenu = $('.js-popup-catalog'), 580 isHeaderSearchAutoOpen = wrap.find(".js-auto-search").length; 581 582 if(contentTop.length && wrap.length){ 583 var t = $(document).scrollTop(), 584 contentTopX = contentTop.offset().top, 585 bootloader = $('.js-header-top-bootloader'), 586 headerWrapHeight = $('.js-header-fixed').outerHeight(true), 587 productCartFixedPanel = $('.js-product-fixed-cart'); 588 589 if (t >= (contentTopX + 60) && !productCartFixedPanel.is(":visible")) { 590 if(!headerPopupMenu.is(":visible") && !isHeaderSearchAutoOpen){ 591 wrap.addClass("sk-fixed"); 592 if(!bootloader.length){ 593 wrap.after("<div class='js-header-top-bootloader header-top-bootloader' style='height: " + headerWrapHeight + "px'></div>"); 594 } 595 } 596 } else { 597 if(wrap.is(":visible")){ 598 wrap.removeClass("sk-fixed"); 599 bootloader.remove(); 600 } 601 } 602 } 603 } 604}; 605 606var productCartPanelFixed = { 607 init: function (){ 608 var _this = this; 609 610 var $productCartPanelFixed = $(".js-product-fixed-cart"); 611 612 if($productCartPanelFixed.length){ 613 _this.showHide(); 614 $(window).scroll(function() { 615 _this.showHide(); 616 }); 617 } 618 }, 619 showHide: function (){ 620 var _this = this, 621 mobileFixedNav = $('.js-mobile-fixed-nav'), 622 cartFixed = $('.js-product-fixed-cart'), 623 cartProductCard = $('#cart-form .js-product-main-cart'); 624 625 if(cartProductCard.length && cartFixed.length){ 626 var t = $(document).scrollTop(), 627 cartProductCardX = cartProductCard.offset().top, 628 cartProductCardHeight = cartProductCard.outerHeight(true); 629 630 if (t >= (cartProductCardX + cartProductCardHeight + 30)) { 631 if(!cartFixed.is(":visible")){ 632 mobileFixedNav.addClass("-sk-m-hide"); 633 cartFixed.addClass("sk-fixed"); 634 cartFixed.find(".js-img").lazy(); 635 } 636 } else { 637 if(cartFixed.is(":visible")){ 638 mobileFixedNav.removeClass("-sk-m-hide"); 639 cartFixed.removeClass("sk-fixed"); 640 } 641 } 642 } 643 } 644}; 645 646var skcallback = { 647 init: function (){ 648 649 /* remove */ 650 $('body').on("click", '.js-sk-callback-open', function (event){ 651 $.magnificPopup.open({ 652 items: { 653 src: ".js-sk-callback-block", 654 type: 'inline' 655 } 656 }); 657 }); 658 /* remove */ 659 } 660}; 661 662var searchForm = { 663 init: function (){ 664 var _this = this; 665 666 _this.quickSearch() 667 _this.showClearButton() 668 _this.clearInput() 669 }, 670 quickSearch: function (){ 671 var input = $('.js-input-search-auto'); 672 673 if(!input.length){ 674 return false; 675 } 676 677 input.on("keyup", function(){ 678 var $this = $(this), 679 value = $this.val(), 680 form = $this.closest('form'), 681 url = form.attr("action"), 682 resultWrap = form.find('.js-search-auto-result'); 683 684 if(value.length >= 3){ 685 $.get(url + '?'+form.serialize()+'&ajax=1', function(data) { 686 var content = $(data).find('.js-auto-search'); 687 688 if(content.length){ 689 resultWrap.show(); 690 resultWrap.html(content.prop("outerHTML")); 691 }else{ 692 resultWrap.html(""); 693 } 694 }); 695 }else{ 696 resultWrap.html(""); 697 resultWrap.hide(); 698 } 699 }); 700 701 input.on("paste", function(){ 702 var $input = $(this); 703 704 setTimeout(function() {
705 $input.keyup(); 706 }, 100); 707 }); 708 709 $('body').on("click", '.js-auto-search-close', function (){ 710 var resultWrap = $(this).closest('.js-search-auto-result') 711 712 resultWrap.html(""); 713 resultWrap.hide(); 714 }); 715 }, 716 showClearButton: function (){ 717 $('.js-input-search').on("keyup", function (){ 718 var $this = $(this), 719 form = $this.closest('form'), 720 buttonClear = form.find('.js-clear-form'), 721 val = $this.val(); 722 723 if(val){ 724 buttonClear.removeClass("-hide"); 725 }else{ 726 buttonClear.addClass("-hide"); 727 } 728 }); 729 }, 730 clearInput: function (){ 731 var buttonClear = $('.js-clear-form'); 732 733 buttonClear.on("click", function(){ 734 var $this = $(this), 735 form = $this.closest('form'), 736 input = form.find('.js-input-search'), 737 autoSearchPopup = form.find('.js-search-auto-result'); 738 739 input.attr("value", ""); 740 autoSearchPopup.html(""); 741 autoSearchPopup.hide(); 742 $this.addClass("-hide"); 743 }); 744 } 745}; 746 747var openMap = { 748 init: function (){ 749 $('.js-popup-map').on("click", function(){ 750 $.magnificPopup.open({ 751 disableOn: 700, 752 type: 'iframe', 753 mainClass: 'mfp-fade mfp-map', 754 removalDelay: 160, 755 preloader: false, 756 fixedContentPos: false, 757 items: { 758 src: $(this).data('href'), 759 type: 'iframe' 760 } 761 }, 0); 762 }); 763 } 764}; 765 766var submenu = { 767 setPosition: function (wrapOuter, subMenu){ 768 if(subMenu.length){ 769 var wrapOuterOffset = wrapOuter.offset(), 770 wrapOuterOffsetLeft = wrapOuterOffset.left, 771 wrapOuterOffsetRight = parseFloat(wrapOuterOffsetLeft) + parseFloat(wrapOuter.outerWidth()); 772 773 subMenu.removeClass('to-left').removeAttr('style'); 774 subMenu.css('display', 'block'); 775 var subMenuOffset = subMenu.offset(), 776 subMenuOffsetLeft = subMenuOffset.left, 777 subMenuWidth = parseFloat(subMenu.outerWidth(true)), 778 subMenuOffsetRight = (parseFloat(subMenuOffsetLeft) + subMenuWidth); 779 780 if(wrapOuterOffsetRight < subMenuOffsetRight){ 781 subMenu.addClass('to-left'); 782 } 783 subMenu.removeAttr('style'); 784 subMenu.css('display', 'block'); 785 } 786 }, 787}; 788 789var headerMenu = { 790 init: function (){ 791 var _this = this; 792 793 _this.hoverByItem(); 794 }, 795 hoverByItem: function (){ 796 /* for touch device */ 797 $('body').find('.js-header-menu-item, .js-header-submenu-item a').click(function (event){ 798 var isMobile = $('body').hasClass('touch'); 799 if(isMobile){ 800 var submenu = $(this).closest('.js-header-menu-item, .js-header-submenu-item').find('.js-header-submenu-outer').first(); 801 802 if(submenu.length && submenu.is(':hidden')){ 803 event.preventDefault(); 804 } 805 } 806 }); 807 808 $('body').on("mouseover", '.js-header-menu-item, .js-header-submenu-item', function () { 809 var item = $(this); 810 811 item.find('.js-header-submenu-outer').first().stop(true).delay(150).fadeIn(1, function (){ 812 item.addClass('hover'); 813 submenu.setPosition($(this).closest('.l-wrapper'), $(this)); 814 815 $(this).addClass('show'); 816 $(this).removeAttr('style'); 817 }); 818 }); 819 820 $('body').on("mouseout", '.js-header-menu-item, .js-header-submenu-item', function () { 821 var item = $(this); 822 823 item.find('.js-header-submenu-outer').first().stop(true).delay(150).fadeOut(1, function(){ 824 item.removeClass('hover'); 825 $(this).removeClass('show'); 826 }); 827 }); 828 829 } 830} 831 832var mobileMainMenu = { 833 init: function (){ 834 var _this = this; 835 836 _this.open(); 837 _this.closePopupByBtn(); 838 _this.closePopupByBg(); 839 _this.openSubmenu(); 840 _this.back(); 841 _this.goByBreadcrumb(); 842 }, 843 open: function (){ 844 var _this = this, 845 btn = $('.js-mm-mobile-open'), 846 bg = $('.js-popup-bg'); 847 848 btn.on("click", function (){ 849 var popup = $('.js-mm-mobile') 850 851 if(popup.length){ 852 var isRetina = popup.data('retina'), 853 isLazy = popup.data('lazy'); 854 855 bg.addClass("-sk-show"); 856 $('body').addClass("overflow-hidden"); 857 858 popup.css("top", "110%"); 859 popup.addClass("-sk-open"); 860 popup.animate({ 861 top : "30px" 862 }, function (){ 863 if(isLazy){ 864 popup.find('.js-img, .js-banner').lazy({ 865 delay: 50, 866 onFinishedAll: function(element) { 867 if(isRetina){ 868 categoriesImages.retinaImages(popup.find('.js-img')); 869 } 870 } 871 }); 872 }else if(isRetina){ 873 categoriesImages.retinaImages(popup.find('.js-img')); 874 } 875 }); 876 } 877 }); 878 }, 879 closePopupByBtn: function (){ 880 var _this = this, 881 btnClose = $('.js-mm-mobile-close'); 882 883 btnClose.on("click", function (){ 884 var popup = $(this).closest('.js-mm-mobile'); 885 886 _this.closePopup(popup); 887 }); 888 }, 889 closePopupByBg: function (){ 890 var _this = this, 891 bg = $('.js-popup-bg'); 892 893 bg.on("click", function (){ 894 var popup = $('.js-mm-mobile'); 895 896 _this.closePopup(popup); 897 }); 898 }, 899 closePopup: function (popup){ 900 var _this = this; 901 902 if(popup.length){ 903 var bg = $('.js-popup-bg'), 904 submenu = popup.find('.js-mm-mobile-submenu.-sk-open'); 905 906 if(submenu.length){ 907 _this.closeSubmenu(submenu); 908 } 909 910 popup.animate({ 911 top : "110%" 912 }, 200, function() { 913 popup.removeClass("-sk-open"); 914 bg.removeClass("-sk-show"); 915 $('body').removeClass("overflow-hidden"); 916 917 var tabCatalog = popup.find('.js-tab[data-tab-content="main-menu-catalog"]'); 918 tabs.setSelectTab(tabCatalog); 919 }); 920 } 921 }, 922 closeSubmenu: function (submenu){ 923 submenu.animate({ 924 top : "110%" 925 }, 200, function() { 926 submenu.removeClass("-sk-open"); 927 }); 928 }, 929 openSubmenu: function (){ 930 var _this = this, 931 menuItem = $('.js-mm-mobile-item'); 932 933 menuItem.on("click", function (event){ 934 var $this = $(this), 935 id = $this.data("id"),
936 menu = $this.closest(".js-mm-mobile"), 937 submenu = menu.find('.js-mm-mobile-submenu[data-id="' + id + '"]'); 938 939 if(submenu.length){ 940 event.preventDefault(); 941 942 var isRetina = menu.data('retina'), 943 isLazy = menu.data('lazy'); 944 945 submenu.css("top", "110%"); 946 submenu.addClass("-sk-open"); 947 submenu.animate({ 948 top : "30px" 949 }, function (){ 950 if(isLazy){ 951 submenu.find('.js-submenu-img, .js-brand-img').lazy({ 952 delay: 50, 953 onFinishedAll: function(element) { 954 if(isRetina){ 955 categoriesImages.retinaImages(submenu.find('.js-submenu-img')); 956 } 957 } 958 }); 959 }else if(isRetina){ 960 categoriesImages.retinaImages(submenu.find('.js-submenu-img')); 961 } 962 }); 963 } 964 }); 965 }, 966 back: function (){ 967 var _this = this, 968 backButton = $('.js-mm-mobile-submenu-back'); 969 970 backButton.on("click", function (){ 971 var $this = $(this), 972 submenu = $this.closest(".js-mm-mobile-submenu"); 973 974 if(submenu.length){ 975 _this.closeSubmenu(submenu); 976 } 977 }); 978 979 }, 980 goByBreadcrumb: function (){ 981 var _this = this, 982 breadcrumb = $('.js-mm-mobile-breadcrumb'); 983 984 breadcrumb.on("click", function (){ 985 var $this = $(this), 986 id = $this.data("id"), 987 sumbenuToGo = null; 988 989 if(id == 'home'){ 990 sumbenuToGo = $this.closest('.js-mm-mobile'); 991 }else{ 992 sumbenuToGo = $this.closest('.js-mm-mobile-submenu[data-id="'+id+'"]'); 993 } 994 995 996 if(sumbenuToGo.length && sumbenuToGo != null){ 997 var sumbenuToGoSumbenus = sumbenuToGo.find('.js-mm-mobile-submenu'); 998 999 if(sumbenuToGoSumbenus.length){ 1000 _this.closeSubmenu(sumbenuToGoSumbenus); 1001 } 1002 } 1003 }); 1004 }, 1005} 1006 1007var mobilePopup = { 1008 init: function (){ 1009 var _this = this; 1010 1011 _this.openPopup(); 1012 _this.closePopupByBtn(); 1013 _this.closePopupByBg(); 1014 }, 1015 openPopup: function (){ 1016 var _this = this, 1017 btn = $('.js-popup-btn'), 1018 bg = $('.js-popup-bg'); 1019 1020 btn.on("click", function (){ 1021 var popup = $('.js-popup-mobile[data-popup="'+ $(this).data("popup") +'"]'); 1022 1023 if(popup.length){ 1024 popup.css("top", "110%"); 1025 popup.addClass("-sk-open"); 1026 bg.addClass("-sk-show"); 1027 $('body').addClass("overflow-hidden"); 1028 1029 popup.animate({ 1030 top : "30px" 1031 }); 1032 } 1033 }); 1034 }, 1035 closePopupByBtn: function (){ 1036 var _this = this, 1037 btnClose = $('.js-popup-close'); 1038 1039 btnClose.on("click", function (){ 1040 var popup = $(this).closest('.js-popup-mobile'); 1041 1042 _this.closePopup(popup); 1043 }); 1044 }, 1045 closePopupByBg: function (){ 1046 var _this = this, 1047 bg = $('.js-popup-bg'); 1048 1049 bg.on("click", function (){ 1050 var popup = $('.js-popup-mobile'); 1051 1052 _this.closePopup(popup); 1053 }); 1054 }, 1055 closePopup: function (popup){ 1056 if(popup.length){ 1057 var bg = $('.js-popup-bg'); 1058 1059 popup.animate({ 1060 top : "110%" 1061 }, 200, function() { 1062 popup.removeClass("-sk-open"); 1063 bg.removeClass("-sk-show"); 1064 $('body').removeClass("overflow-hidden"); 1065 }); 1066 1067 var formFilter = popup.find(".js-mobile-filter"); 1068 if(formFilter.length){ 1069 filterForm.clearAllInputsSearchVariantForm(formFilter); 1070 } 1071 } 1072 } 1073} 1074 1075var responsiveMenu = { 1076 init: function (){ 1077 var _this = this; 1078 1079 _this.responsive(); 1080 window.addEventListener("resize", responsiveMenu.responsive); 1081 }, 1082 responsive: function(){ 1083 var _this = this; 1084 1085 jQuery.each($(".js-resp-nav"), function(){ 1086 responsiveMenu.responsived($(".js-resp-nav"), '.js-resp-nav-el', '.js-resp-nav-sub', ''); 1087 }); 1088 responsiveMenu.responsived($(".js-header-menu"), '.js-header-menu-item', '.js-header-submenu'); 1089 }, 1090 responsived: function(menu, itemSelector, subwrapSelector){ 1091 var _this = this, 1092 menuWidth = menu.width(), 1093 ItemElse = menu.find(itemSelector + '[data-type="else"]'), 1094 ItemElseSubwrap = ItemElse.find(subwrapSelector), 1095 ItemElseSubwrapItems = ItemElse.find(itemSelector), 1096 ItemElseWidth = parseFloat(ItemElse.removeClass('hide').outerWidth(true)), 1097 classElement = menu.data("class-el"), 1098 classSubElement = menu.data("class-sub-el"); 1099 1100 if(ItemElseSubwrapItems.length){ 1101 if(classSubElement){ 1102 ItemElseSubwrapItems.removeClass(classSubElement); 1103 } 1104 if(classElement){ 1105 ItemElseSubwrapItems.addClass(classElement); 1106 } 1107 var clone = ItemElseSubwrapItems.clone(); 1108 clone.insertBefore(ItemElse); 1109 } 1110 1111 ItemElse.addClass('hide'); 1112 ItemElseSubwrap.html(""); 1113 1114 var items = menu.children(itemSelector + ':not([data-type="else"])'), 1115 allItemsWidth = 0; 1116 1117 jQuery.each(items, function(){ 1118 var $this = $(this), 1119 elWidth = parseFloat($this.outerWidth(true)); 1120 1121 if((allItemsWidth + elWidth + ItemElseWidth) > menuWidth){ 1122 ItemElse.removeClass('hide'); 1123 var clone = $this.clone(); 1124 1125 if(classElement){ 1126 clone.removeClass(classElement); 1127 } 1128 if(classSubElement){ 1129 clone.addClass(classSubElement); 1130 } 1131 clone.appendTo(ItemElseSubwrap); 1132 elWidth += $this.outerWidth(true); 1133 $this.remove(); 1134 } 1135 allItemsWidth += elWidth; 1136 }); 1137 1138 menu.css("overflow", "visible"); 1139 menu.removeClass("responsived-before-init"); 1140 } 1141}; 1142 1143var modalForm = { 1144 init: function (){ 1145 var _this = this; 1146 1147 _this.loadContentForm('a.js-form-popup'); 1148 _this.loadContentForm('.js-ajax-form a[href="/login/"]'); 1149 _this.loadContentForm('.js-ajax-form a[href="/forgotpassword/"]'); 1150 _this.loadContentForm('.js-ajax-form a[href="/site/forgotpassword/"]');
1151 _this.submitForm(); 1152 }, 1153 loadContentForm : function (selectorBtnElement){ 1154 var _this = this; 1155 var selectorContent = '.js-ajax-form'; 1156 1157 $('body').on("click", selectorBtnElement, function (event){ 1158 event.preventDefault(); 1159 var url = $(this).attr('href')+"?ajax=1"; 1160 1161 $.magnificPopup.close(); 1162 $('body').prepend("<div class='js-loading-bg mfp-bg mfp-ready'><div class='mfp-preloader'></div></div>"); 1163 1164 $.get(url, function(data) { 1165 $('.js-loading-bg').remove(); 1166 1167 var content = $(data).find(selectorContent); 1168 _this.openModal(content, url); 1169 }); 1170 }); 1171 }, 1172 openModal: function (content, url){ 1173 var _this = this; 1174 1175 $(content).find('form').attr("action", url); 1176 $(content).find('input[type="checkbox"], input[type="radio"], .js-select').styler(); 1177 1178 $.magnificPopup.open({ 1179 items: { 1180 src: "<div class='popup-content popup-content--auth'>"+content.outerHTML()+"</div>" 1181 }, 1182 type: 'inline' 1183 }, 0); 1184 }, 1185 submitForm: function(){ 1186 var _this = this; 1187 1188 $('body').on("submit", '.js-ajax-form form', function(event){ 1189 var wrapForm = $(this).closest('.js-ajax-form'); 1190 if (!wrapForm.find('.wa-login-form-wrapper').length && !wrapForm.find('.wa-forgotpassword-form-wrapper').length) { 1191 event.preventDefault(); 1192 1193 var url = $(this).attr("action"), 1194 data = $(this).serialize(), 1195 btn = $(this).find('input[type="submit"]'); 1196 1197 btn.hide(); 1198 btn.after($('<i class="icon16 loading js-loading"></i>')); 1199 1200 $.post(url, data, function(data){ 1201 var content = $(data).find('.js-ajax-form'); 1202 if(content.length > 0){ 1203 _this.openModal(content, url); 1204 btn.show(); 1205 $(this).find(".js-loading").remove(); 1206 }else{ 1207 window.location.reload(); 1208 } 1209 }); 1210 } 1211 }); 1212 } 1213 1214}; 1215 1216var videoPopup = { 1217 init: function(){ 1218 $("body").on("click", '.js-video-popup', function(e){ 1219 e.preventDefault(); 1220 var href = $(this).data("href"); 1221 1222 if(href){ 1223 $.magnificPopup.open({ 1224 items: { 1225 src: href 1226 }, 1227 type: 'iframe', 1228 mainClass: 'mfp-fade', 1229 removalDelay: 160, 1230 preloader: false, 1231 fixedContentPos: false, 1232 iframe: { 1233 patterns: { 1234 youtube_short: { 1235 index: 'youtu.be/', 1236 id: 'youtu.be/', 1237 src: '//www.youtube.com/embed/%id%?autoplay=1' 1238 }, 1239 rutube: { 1240 index: 'rutube.ru/', 1241 id: 'video/', 1242 src: 'https://rutube.ru/play/embed/%id%' 1243 }, 1244 vk: { 1245 index: 'vk.com/', 1246 id: function(url) { 1247 const regex = /video(-?\d+)_(-?\d+)/; 1248 const match = url.match(regex); 1249 1250 if (match) { 1251 const oid = match[1]; 1252 const id = match[2]; 1253 return 'oid='+oid+'&id='+id; 1254 } else { 1255 return url; 1256 } 1257 }, 1258 src: 'https://vk.com/video_ext.php?%id%' 1259 }, 1260 } 1261 } 1262 }, 0); 1263 } 1264 }); 1265 }, 1266}; 1267 1268var switchVersionSite = { 1269 init: function (){ 1270 var _this = this; 1271 1272 _this.switchVersion(); 1273 _this.hideBtn();
1274 }, 1275 switchVersion: function (){ 1276 $('.js-switch-version-btn').on("click", function (event){ 1277 event.preventDefault(); 1278 1279 if($.cookie("is_desktop_for_mobile")){ 1280 $.cookie("is_desktop_for_mobile", "", {path: '/', expires: 5}); 1281 }else{ 1282 $.cookie("is_desktop_for_mobile", 1, {path: '/', expires: 5}); 1283 } 1284 location.reload(); 1285 }) 1286 }, 1287 hideBtn: function (){ 1288 $('.js-switch-version-remove').on("click", function (event){ 1289 event.preventDefault(); 1290 1291 $.cookie("is_hide_btn_version_site", 1, {path: '/', expires: 1}); 1292 $('.js-switch-version').remove(); 1293 }) 1294 } 1295}; 1296 1297var contentPopup = { 1298 init: function (){ 1299 var _this = this; 1300 1301 _this.loadPage(); 1302 _this.loadInline(); 1303 }, 1304 loadPage: function (){ 1305 var _this = this; 1306 1307 $('body').on("click", '.js-page-popup', function (event){ 1308 event.preventDefault(); 1309 1310 var $this = $(this), 1311 href = $this.attr('href'); 1312 1313 if(!href){ 1314 href = $this.data('href'); 1315 } 1316 1317 $.magnificPopup.close(); 1318 $('body').prepend("<div class='js-loading-bg mfp-bg mfp-ready'><div class='mfp-preloader'></div></div>"); 1319 1320 $.get(href + "?popup=1", function(data) { 1321 $('.js-loading-bg').remove(); 1322 var content = false, 1323 data = $("<div>").append(data); 1324 1325 if($(data)) { 1326 if ($(data).find('.js-page-popup-content').length) { 1327 content = $(data).find('.js-page-popup-content'); 1328 } 1329 if(content){ 1330 _this.openModal(content, 'page'); 1331 }else{ 1332 location.href = href; 1333 } 1334 } 1335 }); 1336 }); 1337 }, 1338 loadInline: function (){ 1339 var _this = this; 1340 1341 $('body').on("click", '.js-content-popup', function (event){ 1342 event.preventDefault(); 1343 1344 var id = $(this).data("href"); 1345 1346 if(id){ 1347 var content = $("#" + id).clone(); 1348 if(content.length){ 1349 content.removeClass("display-none"); 1350 _this.openModal(content, "custom"); 1351 } 1352 } 1353 }); 1354 }, 1355 openModal: function (content, type){ 1356 var addClass = null 1357 if(type){ 1358 addClass = " popup-content--" + type; 1359 } 1360 $.magnificPopup.open({ 1361 items: { 1362 src: "<div class='popup-content" + addClass + "'>" + content.outerHTML() + "</div>" 1363 }, 1364 type: 'inline' 1365 }, 0); 1366 1367 }, 1368}; 1369 1370var selectCurrency = { 1371 init: function (){ 1372 if(!$(".js-currency").length){ 1373 return false; 1374 } 1375 1376 $(".js-currency").on("click", function (e) { 1377 e.preventDefault(); 1378 var url = location.href; 1379 1380 if(url.indexOf('#') > -1){ 1381 url = url.substr(0, url.indexOf('#')); 1382 } 1383 1384 if (url.indexOf('?') == -1) { 1385 url += '?'; 1386 } else { 1387 url += '&'; 1388 } 1389 1390 location.href = url + 'currency=' + $(this).data("value"); 1391 }); 1392 } 1393}; 1394 1395var selectLang = { 1396 init: function (){ 1397 if(!$(".js-language").length){ 1398 return false; 1399 } 1400 1401 $(".js-language").on("click", function (event) { 1402 event.preventDefault(); 1403 var url = location.href; 1404 1405 if(url.indexOf('#') > -1){ 1406 url = url.substr(0, url.indexOf('#')); 1407 } 1408 1409 if (url.indexOf('?') == -1) { 1410 url += '?'; 1411 } else { 1412 url += '&'; 1413 } 1414 1415 location.href = url + 'locale=' + $(this).data("value"); 1416 }); 1417 } 1418}; 1419 1420var headerMainMenu = { 1421 init: function (){ 1422 var _this = this; 1423 1424 _this.openMenu(); 1425 _this.closeByInnerButton(); 1426 _this.closeByOuter(); 1427 _this.openSubs(); 1428 _this.openSubslvl3Dropdown(); 1429 _this.openSubslvl4Dropdown(); 1430 }, 1431 openMenu: function(){ 1432 var _this = this, 1433 btn = $('.js-header-catalog-open'), 1434 bg = $('.js-popup-bg'), 1435 menu = $('.js-popup-catalog'), 1436 isLazy = menu.data('lazy'), 1437 isRetina = menu.data('retina'); 1438 1439 btn.on("click", function(){ 1440 var $this = $(this); 1441 1442 if(menu.is(':visible')){ 1443 _this.closeMenu(); 1444 }else{ 1445 $this.addClass('open'); 1446 menu.addClass('open'); 1447 bg.addClass('-sk-show'); 1448
1449 var headerFixed = $this.closest(".js-header-fixed.sk-fixed"); 1450 if(headerFixed.length){ 1451 var heightHeaderFixed = headerFixed.outerHeight(), 1452 windowHeader = $(window).height(); 1453 1454 menu.css("height", (windowHeader-heightHeaderFixed) + "px") 1455 } 1456 } 1457 1458 if(isLazy){ 1459 categoriesImages.lazyImages(menu.find('.js-img'), isRetina); 1460 }else if(isRetina){ 1461 categoriesImages.retinaImages(menu.find('.js-img')); 1462 } 1463 }); 1464 }, 1465 closeByInnerButton: function (){ 1466 var _this = this, 1467 btn = $('.js-popup-catalog-close'); 1468 1469 btn.on("click", function(){ 1470 _this.closeMenu(); 1471 }); 1472 }, 1473 closeByOuter: function (){ 1474 var _this = this; 1475 1476 $(document).click(function(event) { 1477 if(!$(event.target).closest(".js-popup-catalog").length && !$(event.target).hasClass("js-header-catalog-open") && !$(event.target).closest(".js-header-catalog-open").length) { 1478 _this.closeMenu(); 1479 } 1480 }); 1481 }, 1482 closeMenu: function(){ 1483 var _this = this, 1484 btn = $('.js-header-catalog-open'), 1485 bg = $('.js-popup-bg'), 1486 menu = $('.js-popup-catalog'); 1487 1488 if(menu.hasClass("open")){ 1489 menu.removeClass('open').removeAttr("style"); 1490 bg.removeClass('-sk-show'); 1491 btn.removeClass('open'); 1492 } 1493 }, 1494 openSubs: function () { 1495 var menu = $('.js-popup-catalog'), 1496 isLazyImages = menu.data("lazy"), 1497 isRetinaImages = menu.data("retina"), 1498 openSubmenuTimeout = null; 1499 1500 menu.find('.js-popup-catalog-item').hover(function () { 1501 var $thisItem = $(this), 1502 itemId = $thisItem.data("id"), 1503 currentMenu = $thisItem.closest('.js-popup-catalog'), 1504 allSubcats = currentMenu.find('.js-popup-submenu'), 1505 subcats = currentMenu.find('.js-popup-submenu[data-parent-id="'+itemId+'"]'); 1506 1507 clearTimeout(openSubmenuTimeout); 1508 openSubmenuTimeout = setTimeout(function (){ 1509 currentMenu.find('.js-popup-submenu-dropdown-lvl3, .js-popup-submenu-dropdown-lvl4').removeClass('open'); 1510 currentMenu.find('.js-popup-submenu-dropdown-item').removeClass('hover'); 1511 $thisItem.siblings().removeClass('hover'); 1512 allSubcats.removeClass('open'); 1513 currentMenu.removeClass('full-open'); 1514 $thisItem.addClass('hover'); 1515 subcats.addClass("open"); 1516 subcats.closest(".js-popup-catalog").addClass("full-open"); 1517 }, 100); 1518 1519 if(isLazyImages){ 1520 categoriesImages.lazyImages(subcats.find('.js-submenu-img'), isRetinaImages); 1521 categoriesImages.lazyImages(subcats.find('.js-brand-img'), false); 1522 }else if(isRetinaImages){ 1523 categoriesImages.retinaImages(subcats.find('.js-submenu-img')); 1524 } 1525 1526 var link = $thisItem.find('a').first(); 1527 if(subcats.length && touch.isTouchDevice()) { 1528 link.one("click", function (event) { 1529 event.preventDefault(); 1530 }); 1531 } 1532 }, function(){ 1533 clearTimeout(openSubmenuTimeout); 1534 }); 1535 }, 1536 openSubslvl3Dropdown: function (){ 1537 var menu = $('.js-popup-catalog'), 1538 isLazyImages = menu.data("lazy"), 1539 isRetinaImages = menu.data("retina"), 1540 openSubmenuTimeout = null; 1541 1542 $('.js-popup-submenu-dropdown-lvl2 > .js-popup-submenu-dropdown-item').hover(function () { 1543 var $this = $(this), 1544 currentMenu = $this.closest('.js-popup-catalog'), 1545 allSubcats = currentMenu.find('.js-popup-submenu-dropdown-lvl3'), 1546 itemId = $this.data("id"), 1547 subcats = currentMenu.find('.js-popup-submenu-dropdown-lvl3[data-parent-id="'+itemId+'"]'); 1548 1549 clearTimeout(openSubmenuTimeout); 1550 openSubmenuTimeout = setTimeout(function(){ 1551 $this.siblings().removeClass("hover"); 1552 currentMenu.find('.js-popup-submenu-dropdown-lvl4').removeClass('open'); 1553 currentMenu.find('.js-popup-submenu-dropdown-lvl3 .js-popup-submenu-dropdown-item').removeClass('hover'); 1554 allSubcats.removeClass("open"); 1555 $this.addClass('hover'); 1556 subcats.addClass("open"); 1557 }, 100); 1558 1559 if(isLazyImages){ 1560 categoriesImages.lazyImages(subcats.find('.js-submenu-img'), isRetinaImages); 1561 }else if(isRetinaImages){ 1562 categoriesImages.retinaImages(subcats.find('.js-submenu-img')); 1563 } 1564 1565 var link = $this; 1566 if(subcats.length && touch.isTouchDevice()) { 1567 link.one("click", function (event) { 1568 event.preventDefault(); 1569 }); 1570 } 1571 }, function (){ 1572 clearTimeout(openSubmenuTimeout); 1573 }); 1574 }, 1575 openSubslvl4Dropdown: function (){ 1576 var menu = $('.js-popup-catalog'), 1577 isLazyImages = menu.data("lazy"), 1578 isRetinaImages = menu.data("retina"), 1579 openSubmenuTimeout = null; 1580 1581 1582 $('.js-popup-submenu-dropdown-lvl3 > .js-popup-submenu-dropdown-item').hover(function () { 1583 var $this = $(this), 1584 currentMenu = $this.closest('.js-popup-catalog'), 1585 allSubcats = currentMenu.find('.js-popup-submenu-dropdown-lvl4'), 1586 itemId = $this.data("id"), 1587 subcats = currentMenu.find('.js-popup-submenu-dropdown-lvl4[data-parent-id="'+itemId+'"]'); 1588 1589 clearTimeout(openSubmenuTimeout); 1590 openSubmenuTimeout = setTimeout(function(){ 1591 $this.siblings().removeClass('hover'); 1592 allSubcats.removeClass("open"); 1593 $this.addClass('hover'); 1594 subcats.addClass("open"); 1595 }, 100); 1596 1597 if(isLazyImages){ 1598 categoriesImages.lazyImages(subcats.find('.js-submenu-img'), isRetinaImages); 1599 }else if(isRetinaImages){ 1600 categoriesImages.retinaImages(subcats.find('.js-submenu-img')); 1601 } 1602 1603 var link = $this; 1604 if(subcats.length && touch.isTouchDevice()) { 1605 link.one("click", function (event) { 1606 event.preventDefault(); 1607 }); 1608 } 1609 }, function (){ 1610 clearTimeout(openSubmenuTimeout); 1611 }); 1612 } 1613}; 1614 1615var sidebarMainMenu = { 1616 init: function (){ 1617 var _this = this; 1618 1619 _this.openSubs(); 1620 _this.closeSubsByBtn(); 1621 _this.openSubslvl3Dropdown(); 1622 _this.openSubslvl4Dropdown(); 1623 _this.retinaImagesFirstlvl($('.js-sidebar-catalog'));
1624 }, 1625 retinaImagesFirstlvl: function (menu){ 1626 if(menu.length){ 1627 var isLazyImages = menu.data("lazy"), 1628 isRetinaImages = menu.data("retina"); 1629 1630 if(isLazyImages){ 1631 categoriesImages.lazyImages(menu.find('.js-img'), isRetinaImages); 1632 }else if(isRetinaImages){ 1633 categoriesImages.retinaImages(menu.find('.js-img')); 1634 } 1635 } 1636 }, 1637 closeSubsByBtn: function (){ 1638 var _this = this, 1639 closeBtn = $('.js-sidebar-catalog-close'); 1640 1641 closeBtn.on("click", function (){ 1642 var item = $(this).closest(".js-sidebar-catalog-item"); 1643 1644 _this.closeSubs(item); 1645 }); 1646 }, 1647 closeSubs: function (item){ 1648 var currentMenu = item.closest('.js-sidebar-catalog'); 1649 1650 currentMenu.removeClass("full-open"); 1651 currentMenu.find('.js-sidebar-submenu-dropdown-lvl3, .js-sidebar-submenu-dropdown-lvl4').removeClass('open'); 1652 currentMenu.find('.js-sidebar-submenu-dropdown-item').removeClass('hover'); 1653 item.removeClass('hover'); 1654 $('.js-popup-bg').removeClass('-sk-show'); 1655 }, 1656 openSubs: function () { 1657 var _this = this, 1658 menu = $('.js-sidebar-catalog'), 1659 isLazyImages = menu.data("lazy"), 1660 isRetinaImages = menu.data("retina"), 1661 bg = $('.js-popup-bg'), 1662 openSubmenuTimeout = null; 1663 1664 $('.js-sidebar-catalog-item').hover(function () { 1665 var $thisItem = $(this), 1666 subcats = $(this).find('.js-sidebar-submenu'); 1667 1668 clearTimeout(openSubmenuTimeout); 1669 openSubmenuTimeout = setTimeout(function (){ 1670 menu.find('.js-sidebar-submenu-dropdown-lvl3, .js-sidebar-submenu-dropdown-lvl4').removeClass('open'); 1671 menu.find('.js-sidebar-submenu-dropdown-item').removeClass('hover'); 1672 $thisItem.siblings().removeClass("hover"); 1673 $thisItem.addClass('hover'); 1674 if(subcats.length){ 1675 menu.addClass("full-open"); 1676 bg.addClass('-sk-show'); 1677 }else{ 1678 menu.removeClass("full-open"); 1679 bg.removeClass('-sk-show'); 1680 } 1681 }, 100); 1682 1683 if(isLazyImages){ 1684 categoriesImages.lazyImages($(this).find('.js-submenu-img'), isRetinaImages); 1685 categoriesImages.lazyImages($(this).find('.js-brand-img'), false); 1686 }else if(isRetinaImages){ 1687 categoriesImages.retinaImages($(this).find('.js-submenu-img')); 1688 } 1689 1690 var link = $thisItem.find('a').first(); 1691 if(subcats.length && touch.isTouchDevice()) { 1692 link.one("click", function (event) { 1693 event.preventDefault(); 1694 }); 1695 } 1696 1697 }, function(){ 1698 clearTimeout(openSubmenuTimeout); 1699 }); 1700 1701 menu.mouseleave(function(){ 1702 clearTimeout(openSubmenuTimeout); 1703 1704 var openItem = $(this).find('.js-sidebar-catalog-item.hover'); 1705 1706 _this.closeSubs(openItem); 1707 }); 1708 }, 1709 openSubslvl3Dropdown: function (){ 1710 var menu = $('.js-sidebar-catalog'), 1711 isLazyImages = menu.data("lazy"), 1712 isRetinaImages = menu.data("retina"), 1713 openSubmenuTimeout = null; 1714 1715 $('.js-sidebar-submenu-dropdown-lvl2 > .js-sidebar-submenu-dropdown-item').hover(function () { 1716 var $this = $(this), 1717 itemId = $this.data("id"), 1718 allSubcats = menu.find('.js-sidebar-submenu-dropdown-lvl3'), 1719 subcats = menu.find('.js-sidebar-submenu-dropdown-lvl3[data-parent-id="'+itemId+'"]'); 1720 1721 clearTimeout(openSubmenuTimeout); 1722 openSubmenuTimeout = setTimeout(function(){ 1723 $this.siblings().removeClass("hover"); 1724 menu.find('.js-sidebar-submenu-dropdown-lvl4').removeClass('open'); 1725 menu.find('.js-sidebar-submenu-dropdown-lvl3 .js-sidebar-submenu-dropdown-item').removeClass('hover'); 1726 allSubcats.removeClass("open"); 1727 $this.addClass('hover'); 1728 subcats.addClass("open"); 1729 }, 100); 1730 1731 if(isLazyImages){ 1732 categoriesImages.lazyImages($this.find('.js-submenu-img'), isRetinaImages); 1733 }else if(isRetinaImages){ 1734 categoriesImages.retinaImages($this.find('.js-submenu-img')); 1735 } 1736 1737 var link = $this; 1738 if(subcats.length && touch.isTouchDevice()) { 1739 link.one("click", function (event) { 1740 event.preventDefault(); 1741 }); 1742 } 1743 }, function (){ 1744 clearTimeout(openSubmenuTimeout); 1745 }); 1746 }, 1747 openSubslvl4Dropdown: function (){ 1748 var menu = $('.js-sidebar-catalog'), 1749 isLazyImages = menu.data("lazy"), 1750 isRetinaImages = menu.data("retina"), 1751 openSubmenuTimeout = null; 1752 1753 $('.js-sidebar-submenu-dropdown-lvl3 > .js-sidebar-submenu-dropdown-item').hover(function () { 1754 var $this = $(this), 1755 itemId = $this.data("id"), 1756 allSubcats = menu.find('.js-sidebar-submenu-dropdown-lvl4'), 1757 subcats = menu.find('.js-sidebar-submenu-dropdown-lvl4[data-parent-id="'+itemId+'"]'); 1758 1759 clearTimeout(openSubmenuTimeout); 1760 openSubmenuTimeout = setTimeout(function(){ 1761 allSubcats.removeClass("open"); 1762 $this.siblings().removeClass("hover"); 1763 $this.addClass('hover'); 1764 subcats.addClass("open"); 1765 }, 100); 1766 1767 if(isLazyImages){ 1768 categoriesImages.lazyImages($this.find('.js-submenu-img'), isRetinaImages); 1769 }else if(isRetinaImages){ 1770 categoriesImages.retinaImages($this.find('.js-submenu-img')); 1771 } 1772 1773 var link = $this; 1774 if(subcats.length && touch.isTouchDevice()) { 1775 link.one("click", function (event) { 1776 event.preventDefault(); 1777 }); 1778 } 1779 }, function (){ 1780 clearTimeout(openSubmenuTimeout); 1781 }); 1782 } 1783} 1784 1785var horizontalMainMenu = { 1786 init: function (){ 1787 var _this = this, 1788 horizontalCatalog = $('.js-horizontal-catalog'); 1789 1790 if(!horizontalCatalog.length){ 1791 return false; 1792 } 1793 1794 horizontalMainMenu.responsive(); 1795 window.addEventListener("resize", horizontalMainMenu.responsive); 1796 _this.openSubcategories(); 1797 _this.retinaImagesFirstlvl(horizontalCatalog); 1798 _this.closeSubsByBtn(); 1799 _this.openSubslvl3Dropdown(); 1800 _this.openSubslvl4Dropdown(); 1801 }, 1802 responsive: function (){ 1803 var _this = this, 1804 menu = $('.js-horizontal-catalog-items'), 1805 menuWidth = menu.width(), 1806 ItemElse = menu.find('.js-horizontal-catalog-item[data-type="else"]'), 1807 ItemElseWidth = parseFloat(ItemElse.removeClass('sk-hide').outerWidth(true)), 1808 ItemElseSubmenuWrap = ItemElse.find('.js-horizontal-submenu-else'), 1809 items = menu.children('.js-horizontal-catalog-item:not([data-type="else"])'), 1810 allItemsWidth = 0; 1811 1812 var menuMarginLeft = parseInt(menu.css("margin-left")); 1813 if(menu.hasClass('responsived-before-init') && menuMarginLeft < 0){ 1814 menuWidth = menuWidth - menuMarginLeft; 1815 } 1816 1817 items.removeClass("sk-hide"); 1818 ItemElse.addClass('sk-hide'); 1819 ItemElseSubmenuWrap.html(""); 1820 ItemElseSubmenuWrap.append($('.js-horizontal-catalog-else-items').html()); 1821 ItemElse.find(".js-horizontal-submenu-item").addClass('sk-hide'); 1822 1823 jQuery.each(items, function(){ 1824 var $this = $(this), 1825 elWidth = parseFloat($this.outerWidth(true)), 1826 id = $this.data("id"); 1827 1828 if((allItemsWidth + elWidth + ItemElseWidth) > menuWidth){ 1829 ItemElse.removeClass('sk-hide'); 1830 ItemElse.find(".js-horizontal-submenu-item[data-id='" + id + "']").removeClass('sk-hide'); 1831 1832 elWidth += $this.outerWidth(true); 1833 $this.addClass("sk-hide"); 1834 } 1835 allItemsWidth += elWidth; 1836 }); 1837 1838 menu.css("overflow", "visible"); 1839 menu.removeClass("responsived-before-init"); 1840 }, 1841 openSubcategories: function () { 1842 var _this = this, 1843 menu = $('.js-horizontal-catalog'), 1844 isLazyImages = menu.data("lazy"), 1845 isRetinaImages = menu.data("retina"), 1846 openSubmenuTimeout = null, 1847 bg = $('.js-popup-bg'); 1848 1849 menu.find('.js-horizontal-catalog-item').hover(function () { 1850 var $thisItem = $(this), 1851 currentMenu = $thisItem.closest('.js-horizontal-catalog'), 1852 allSubcats = currentMenu.find('.js-horizontal-submenu'), 1853 subcats = $thisItem.find('.js-horizontal-submenu').first(); 1854 1855 clearTimeout(openSubmenuTimeout); 1856 openSubmenuTimeout = setTimeout(function (){ 1857 currentMenu.find('.js-horizontal-submenu-dropdown-lvl3, .js-
1857horizontal-submenu-dropdown-lvl4').removeClass('open'); 1858 currentMenu.find('.js-horizontal-submenu-dropdown-item').removeClass('hover'); 1859 $thisItem.siblings().removeClass('hover'); 1860 allSubcats.removeClass('open'); 1861 $thisItem.addClass('hover'); 1862 subcats.addClass("open"); 1863 1864 if(subcats.length){ 1865 bg.addClass('-sk-show'); 1866 }else{ 1867 bg.removeClass('-sk-show'); 1868 } 1869 }, 100); 1870 1871 if(isLazyImages){ 1872 categoriesImages.lazyImages($(this).find('.js-submenu-img'), isRetinaImages); 1873 categoriesImages.lazyImages($(this).find('.js-brand-img'), false); 1874 }else if(isRetinaImages){ 1875 categoriesImages.retinaImages($(this).find('.js-submenu-img')); 1876 } 1877 1878 var link = $thisItem.find('a').first(); 1879 if(subcats.length && touch.isTouchDevice()) { 1880 link.one("click", function (event) { 1881 event.preventDefault(); 1882 }); 1883 } 1884 }, function () { 1885 clearTimeout(openSubmenuTimeout); 1886 }); 1887 1888 $('.js-horizontal-catalog-items').mouseleave(function(){ 1889 clearTimeout(openSubmenuTimeout); 1890 1891 var openItem = $(this).find('.js-horizontal-catalog-item.hover'); 1892 1893 _this.closeSubs(openItem); 1894 }); 1895 }, 1896 openSubslvl3Dropdown: function (){ 1897 var menu = $('.js-horizontal-catalog'), 1898 isLazyImages = menu.data("lazy"), 1899 isRetinaImages = menu.data("retina"), 1900 openSubmenuTimeout = null; 1901 1902 $('body').on("mouseover", '.js-horizontal-submenu-dropdown-lvl2 > .js-horizontal-submenu-dropdown-item', function (){ 1903 var $this = $(this), 1904 itemId = $this.data("id"), 1905 allSubcats = menu.find('.js-horizontal-submenu-dropdown-lvl3'), 1906 subcats = menu.find('.js-horizontal-submenu-dropdown-lvl3[data-parent-id="'+itemId+'"]'); 1907 1908 clearTimeout(openSubmenuTimeout); 1909 openSubmenuTimeout = setTimeout(function(){ 1910 $this.siblings().removeClass("hover"); 1911 menu.find('.js-horizontal-submenu-dropdown-lvl4').removeClass('open'); 1912 menu.find('.js-horizontal-submenu-dropdown-lvl3 .js-horizontal-submenu-dropdown-item').removeClass('hover'); 1913 allSubcats.removeClass("open"); 1914 $this.addClass('hover'); 1915 subcats.addClass("open"); 1916 }, 100); 1917 1918 if(isLazyImages){ 1919 categoriesImages.lazyImages($this.find('.js-submenu-img'), isRetinaImages); 1920 }else if(isRetinaImages){ 1921 categoriesImages.retinaImages($this.find('.js-submenu-img')); 1922 } 1923 1924 var link = $this; 1925 if(subcats.length && touch.isTouchDevice()) { 1926 link.one("click", function (event) { 1927 event.preventDefault(); 1928 }); 1929 } 1930 }); 1931 1932 $('body').on("mouseout", '.js-horizontal-submenu-dropdown-lvl2 > .js-horizontal-submenu-dropdown-item', function (){ 1933 clearTimeout(openSubmenuTimeout); 1934 }); 1935 }, 1936 openSubslvl4Dropdown: function (){ 1937 var menu = $('.js-horizontal-catalog'), 1938 isLazyImages = menu.data("lazy"), 1939 isRetinaImages = menu.data("retina"), 1940 openSubmenuTimeout = null; 1941 1942 $('body').on("mouseover", '.js-horizontal-submenu-dropdown-lvl3 > .js-horizontal-submenu-dropdown-item', function (){ 1943 var $this = $(this), 1944 itemId = $this.data("id"), 1945 allSubcats = menu.find('.js-horizontal-submenu-dropdown-lvl4'), 1946 subcats = menu.find('.js-horizontal-submenu-dropdown-lvl4[data-parent-id="'+itemId+'"]'); 1947 1948 clearTimeout(openSubmenuTimeout); 1949 openSubmenuTimeout = setTimeout(function(){ 1950 allSubcats.removeClass("open"); 1951 $this.siblings().removeClass("hover"); 1952 $this.addClass('hover'); 1953 subcats.addClass("open"); 1954 }, 100); 1955 1956 if(isLazyImages){ 1957 categoriesImages.lazyImages($this.find('.js-submenu-img'), isRetinaImages); 1958 }else if(isRetinaImages){ 1959 categoriesImages.retinaImages($this.find('.js-submenu-img')); 1960 } 1961 1962 var link = $this; 1963 if(subcats.length && touch.isTouchDevice()) { 1964 link.one("click", function (event) { 1965 event.preventDefault(); 1966 }); 1967 } 1968 }); 1969 1970 $('body').on("mouseout", '.js-horizontal-submenu-dropdown-lvl3 > .js-horizontal-submenu-dropdown-item', function (){ 1971 clearTimeout(openSubmenuTimeout); 1972 }); 1973 }, 1974 closeSubs: function (item){ 1975 var currentMenu = item.closest('.js-horizontal-catalog'); 1976 1977 currentMenu.find('.js-horizontal-submenu-dropdown-lvl3, .js-
1977horizontal-submenu-dropdown-lvl4').removeClass('open'); 1978 currentMenu.find('.js-horizontal-submenu-dropdown-item').removeClass('hover'); 1979 item.removeClass('hover'); 1980 $('.js-popup-bg').removeClass('-sk-show'); 1981 }, 1982 closeSubsByBtn: function (){ 1983 var _this = this, 1984 closeBtn = $('.js-horizontal-catalog-close'); 1985 1986 closeBtn.on("click", function (){ 1987 var item = $(this).closest(".js-horizontal-catalog-item"); 1988 1989 _this.closeSubs(item); 1990 }); 1991 }, 1992 retinaImagesFirstlvl: function (menu){ 1993 var isLazyImages = menu.data("lazy"), 1994 isRetinaImages = menu.data("retina"); 1995 1996 if(isLazyImages){ 1997 categoriesImages.lazyImages(menu.find('.js-horizontal-catalog-icon'), isRetinaImages); 1998 }else if(isRetinaImages){ 1999 categoriesImages.retinaImages(menu.find('.js-horizontal-catalog-icon')); 2000 } 2001 } 2002}; 2003 2004var categoriesImages = { 2005 init: function (){ 2006 var _this = this; 2007 2008 _this.categoriesList(); 2009 }, 2010 categoriesList: function() { 2011 var _this = this, 2012 categories = $('.js-categories-list'); 2013 2014 categories.each(function (){ 2015 var $this = $(this), 2016 isRetina = $this.data('retina'), 2017 isLazy = $this.data('lazy'), 2018 images = $this.find('.js-img'); 2019 2020 if(isLazy){ 2021 _this.lazyImages(images, isRetina); 2022 }else if(isRetina){ 2023 _this.retinaImages(images); 2024 } 2025 }); 2026 }, 2027 lazyImages: function (images, isRetina){ 2028 var _this = this; 2029 2030 images.lazy({ 2031 afterLoad: function (element){ 2032 element.closest(".js-white-wrap").addClass("-white-wrap"); 2033 if(isRetina){ 2034 _this.imageDataAt2x(element); 2035 element.retina({force_original_dimensions: false}); 2036 } 2037 } 2038 }); 2039 }, 2040 retinaImages: function (images){ 2041 var _this = this; 2042 2043 images.each(function(){ 2044 var $this = $(this); 2045 _this.imageDataAt2x($this); 2046 }).promise().done(function(){ 2047 images.retina({force_original_dimensions: false}); 2048 }); 2049 }, 2050 imageDataAt2x: function (image){ 2051 var imgUrl = image.attr('src'); 2052 2053 if(imgUrl.indexOf("?") >= 0){ 2054 var fileExtensionWithGet = imgUrl.substring(imgUrl.lastIndexOf('.') + 1), 2055 imgUrl2x = imgUrl.replace("." + fileExtensionWithGet, "@2x." + fileExtensionWithGet); 2056 2057 image.attr("data-at2x", imgUrl2x); 2058 } 2059 } 2060}; 2061 2062 2063 2064var slider = { 2065 $slider: $('.js-slider'), 2066 init: function (){ 2067 var _this = this; 2068 2069 if(_this.$slider.length){ 2070 _this.sliderAuto(); 2071 2072 _this.sliderInteraction(); 2073 2074 _this.retinaFirstImage(); 2075 } 2076 }, 2077 retinaFirstImage: function (){ 2078 var _this = this; 2079 2080 var isRetina = _this.$slider.data("retina"), 2081 firstImg = _this.$slider.find(".js-img").first(); 2082 2083 if(isRetina && $.Retina && firstImg.length && !firstImg.hasClass('owl-lazy')){ 2084 firstImg.retina({force_original_dimensions: false}); 2085 } 2086 }, 2087 sliderAuto: function (){ 2088 var _this = this; 2089 2090 var pause = parseInt(_this.$slider.data("pause")) * 1000; 2091 2092 if(pause > 0){ 2093 _this.sliderInit(null, pause); 2094 } 2095 }, 2096 sliderInteraction: function (){ 2097 var _this = this; 2098 2099 var sliderNav = $('.js-slider-init-interaction'); 2100 sliderNav.on("click", function (){ 2101 _this.sliderInit($(this).data("index"), false); 2102 _this.$slider.trigger('stop.owl.autoplay'); 2103 }); 2104 2105 _this.$slider.hammer().on("swipeleft swiperight", function(event){ 2106 if(event.type == 'swipeleft'){ 2107 _this.sliderInit("next", false); 2108 }else if(event.type == 'swiperight'){ 2109 _this.sliderInit("prev", false); 2110 } 2111 2112 if(_this.$slider.hasClass("owl-loaded")){ 2113 _this.$slider.trigger('stop.owl.autoplay'); 2114 } 2115 }); 2116 }, 2117 sliderInit: function (goToSlid, pause){ 2118 var _this = this; 2119 2120 if(_this.$slider.hasClass("owl-loaded")){ 2121 return false; 2122 } 2123 2124 var auto = (pause) ? true : false, 2125 isLazy = _this.$slider.data("lazy"), 2126 isRetina = _this.$slider.data("retina"), 2127 isNav = _this.$slider.data("nav"), 2128 isDots = _this.$slider.data("pages"); 2129 2130 var params = { 2131 loop: true, 2132 dots: isDots, 2133 dotsEach: 1, 2134 nav: isNav, 2135 navElement: "div", 2136 navText: ['',''],
2137 navContainer: _this.$slider.closest(".js-slider-outer").find('.js-slider-nav'), 2138 dotsContainer: _this.$slider.closest(".js-slider-outer").find('.js-slider-dots'), 2139 lazyLoad: isLazy, 2140 lazyLoadEager: 1, 2141 items: 1.15, 2142 margin: 0, 2143 onInitialize: function (event){ 2144 _this.$slider.closest(".js-slider-outer").find('.js-slider-init-interaction.owl-prev, .js-slider-init-interaction.owl-next').remove(); 2145 _this.$slider.closest(".js-slider-outer").find('.js-slider-init-interaction').removeClass("js-slider-init-interaction"); 2146 }, 2147 onInitialized: function (event){ 2148 owlCarouselAdd.dotsShow($(event.currentTarget).closest('.js-slider-outer').find(".owl-dot")); 2149 2150 if (typeof $.autobadgeFrontend !== 'undefined') { 2151 $.autobadgeFrontend.reinit(); 2152 } 2153 }, 2154 onTranslate: function(){ 2155 _this.$slider.addClass("_switch"); 2156 }, 2157 onTranslated: function(event){ 2158 var slider = $(event.currentTarget), 2159 activeSlide = slider.find(".owl-item.active"); 2160 2161 if(!activeSlide.length){ 2162 activeSlide = slider.find(".owl-item:first-child"); 2163 } 2164 2165 if(activeSlide.length) { 2166 var activeImage = activeSlide.find(".js-img"); 2167 2168 if (activeImage.length && isRetina && activeImage.attr('src').indexOf('?') < 0) { 2169 activeImage.retina({force_original_dimensions: false}); 2170 } 2171 } 2172 2173 if (typeof $.autobadgeFrontend !== 'undefined') { 2174 $.autobadgeFrontend.reinit(); 2175 } 2176 }, 2177 onDragged: function(event){ 2178 if (typeof $.autobadgeFrontend !== 'undefined') { 2179 $.autobadgeFrontend.reinit(); 2180 } 2181 }, 2182 onLoadedLazy: function(event){ 2183 var slider = $(event.currentTarget), 2184 activeSlide = slider.find(".owl-item.active"), 2185 activeImage = activeSlide.find(".owl-lazy"); 2186 2187 activeImage.removeClass("owl-lazy"); 2188 }, 2189 onChanged: function (event){ 2190 owlCarouselAdd.dotsShow($(event.currentTarget).closest('.js-slider-outer').find(".owl-dot")); 2191 } 2192 }; 2193 2194 if(auto){ 2195 params["autoplay"] = true; 2196 params["autoplayTimeout"] = pause; 2197 params["autoplayHoverPause"] = true; 2198 } 2199 2200 _this.$slider.owlCarousel(params); 2201 2202 _this.$slider.find('.owl-prev, .owl-next, .owl-dot').on('click', function(e) { 2203 _this.$slider.trigger('stop.owl.autoplay'); 2204 }); 2205 2206 if(goToSlid){ 2207 if(goToSlid == "prev") { 2208 _this.$slider.trigger("prev.owl.carousel"); 2209 }else if(goToSlid == "next"){ 2210 _this.$slider.trigger("next.owl.carousel"); 2211 }else { 2212 _this.$slider.trigger("to.owl.carousel", [parseInt(goToSlid)]); 2213 setTimeout(function (){ 2214 _this.$slider.trigger('refresh.owl.carousel'); 2215 }, 200); 2216 2217 } 2218 } 2219 } 2220}; 2221 2222var countdown = { 2223 init: function (){ 2224 var _this = this; 2225 2226 $(".js-countdown").each(function(){ 2227 var $this = $(this); 2228 2229 _this.display($this); 2230 }); 2231 }, 2232 display: function (wrap){ 2233 if(wrap.length){ 2234 var dateEnd = wrap.data("end"), 2235 dayText = wrap.data("day-text"), 2236 isWrap = wrap.data("wrap"); 2237 2238 wrap.countdown(dateEnd, function(event) { 2239 if(isWrap){ 2240 wrap.find('.js-countdown-days').html(event.strftime('%D')); 2241 wrap.find('.js-countdown-hours').html(event.strftime('%H')); 2242 wrap.find('.js-countdown-minutes').html(event.strftime('%M')); 2243 wrap.find('.js-countdown-seconds').html(event.strftime('%S')); 2244 }else{
2245 wrap.text(event.strftime('%D ' + dayText + ' %H:%M:%S')); 2246 } 2247 }); 2248 } 2249 } 2250}; 2251 2252var productsPreviewList = { 2253 init: function () { 2254 var _this = this, 2255 productList = $('.js-preview-products:not(.js-products-carousel)'); 2256 2257 productList.each(function(){ 2258 _this.images($(this)); 2259 }); 2260 }, 2261 images: function (productList){ 2262 var _this = this, 2263 isRetina = productList.data('retina'), 2264 isLazy = productList.data('image-lazy'), 2265 productImage = productList.find(".js-img"); 2266 2267 if(isLazy){ 2268 productImage.lazy({ 2269 visibleOnly: true, 2270 afterLoad: function(element) { 2271 element.removeClass("owl-lazy"); 2272 element.closest(".js-white-wrap").addClass("-white-wrap"); 2273 if(isRetina){ 2274 element.retina({force_original_dimensions: false}); 2275 } 2276 new productGalleryTile(); 2277 }, 2278 }); 2279 }else if(isRetina){ 2280 productImage.retina({force_original_dimensions: false}); 2281 } 2282 }, 2283}; 2284 2285var productsCarousel = { 2286 carouselProductsWrap: $('.js-products-carousel-outer'), 2287 init: function (){ 2288 var _this = this; 2289 2290 if(!_this.carouselProductsWrap.length){ 2291 return false; 2292 } 2293 2294 _this.prepareProductListCarousels(); 2295 _this.carouselInteraction(); 2296 2297 $(window).on('resize', _this.carouselsInit); 2298 }, 2299 carouselsInit: function (){ 2300 var _this = this; 2301 2302 productsCarousel.carouselProductsWrap.each(function (){ 2303 var $this = $(this), 2304 carousel = $(this).find('.js-products-carousel'), 2305 carouselWidth = carousel.outerWidth(), 2306 itemCarousel = $(this).find(".js-product-outer"), 2307 countItems = itemCarousel.length, 2308 widthItem = itemCarousel.first().outerWidth(true), 2309 widthAllItems = widthItem * countItems, 2310 isCarousel = widthAllItems > carouselWidth + 30; 2311 2312 if(isCarousel){ 2313 productsCarousel.carousel($this); 2314 $this.addClass("-carousel"); 2315 }else{ 2316 $this.removeClass("-carousel"); 2317 } 2318 }); 2319 }, 2320 prepareProductListCarousels: function (){ 2321 var _this = this; 2322 2323 _this.carouselProductsWrap.each(function (){ 2324 var $this = $(this), 2325 carousel = $this.find('.js-products-carousel'), 2326 carouselWidth = carousel.outerWidth(), 2327 itemCarousel = $this.find(".js-product-outer"), 2328 countItems = itemCarousel.length, 2329 widthItem = itemCarousel.first().outerWidth(true), 2330 widthAllItems = widthItem * countItems, 2331 isCarousel = widthAllItems > carouselWidth + 30; 2332 2333 if(isCarousel){ 2334 var wrapButtons = $this.find(".js-carousel-direction"); 2335 2336 wrapButtons.append('<div data-index="prev" class="js-init-interaction owl-prev"></div>'); 2337 wrapButtons.append('<div data-index="next" class="js-init-interaction owl-next"></div>'); 2338 2339 $this.addClass("-carousel"); 2340 }else{ 2341 $this.removeClass("-carousel"); 2342 } 2343 2344 var carouselOffsetRight = carousel.offset().left + carousel.outerWidth(); 2345 itemCarousel.slice(0,8).each(function (){ 2346 var itemOffsetLeft = $(this).offset().left; 2347 if (itemOffsetLeft < carouselOffsetRight) { 2348 var image = $(this).find('.js-img'), 2349 isLazyImage = image.hasClass('owl-lazy'), 2350 isRetina = carousel.data('retina'); 2351 2352 if(isLazyImage){ 2353 image.Lazy({ 2354 afterLoad: function(element) { 2355 element.removeClass("owl-lazy");
2356 element.closest(".js-white-wrap").addClass("-white-wrap"); 2357 if (isRetina) { 2358 element.retina({force_original_dimensions: false}); 2359 } 2360 }, 2361 }); 2362 }else if(isRetina){ 2363 image.retina(); 2364 } 2365 } 2366 }); 2367 }); 2368 }, 2369 carouselInteraction: function (){ 2370 var _this = this, 2371 productCarouselNav = $('.js-init-interaction'); 2372 2373 productCarouselNav.on("click", function (){ 2374 var carousel = $(this).closest('.js-products-carousel-outer'); 2375 2376 _this.carousel(carousel, $(this).data("index")); 2377 }); 2378 2379 if(touch.isTouchDevice()){ 2380 $('.js-products-carousel').each(function (){ 2381 var $productList = $(this); 2382 2383 $productList.hammer().on("swipeleft swiperight", function(event){ 2384 var carousel = $(this), 2385 carouselWidth = carousel.outerWidth(), 2386 itemCarousel = $(this).find(".js-product-outer"), 2387 countItems = itemCarousel.length, 2388 widthItem = itemCarousel.first().outerWidth(true), 2389 widthAllItems = widthItem * countItems, 2390 isSwipe = widthAllItems > carouselWidth + 30; 2391 2392 if(isSwipe){ 2393 var $productListCarousel = $(this).closest(".js-products-carousel-outer"); 2394 2395 if(event.type == 'swipeleft'){ 2396 _this.carousel($productListCarousel, "next"); 2397 }else if(event.type == 'swiperight'){ 2398 _this.carousel($productListCarousel, "prev"); 2399 } 2400 } 2401 }); 2402 }); 2403 } 2404 }, 2405 carousel: function (productsList, goToSlide){ 2406 if(productsList.hasClass("carousel-init")){ 2407 return false; 2408 } 2409 2410 var carousel = productsList.find('.js-products-carousel'), 2411 navigation = productsList.find('.js-carousel-direction'), 2412 isSidebar = carousel.closest('.js-content-cols-sidebar'), 2413 is_lazy = productsList.find('.js-preview-products').data('image-lazy'), 2414 isDots = carousel.data('dots'), 2415 is_retina = productsList.find('.js-preview-products').data('retina'), 2416 type = productsList.find('.js-preview-products').data('type-preview'), 2417 responsive = {}, 2418 tempDotsWrap = productsList.find('.owl-dot'); 2419 2420 tempDotsWrap.remove(); 2421 2422 if(type == 'mini_h') { 2423 if (isSidebar.length && !globalThemeSettings.isMobile) { 2424 responsive = { 2425 0: {items: 1.12, margin: 0}, 2426 381: {items: 1.2, margin: 0}, 2427 551: {items: 2.2, margin: 0}, 2428 801: {items: 3, margin: 0} 2429 }; 2430 } else { 2431 responsive = { 2432 0: {items: 1.12, margin: 0}, 2433 381: {items: 1.2, margin: 0}, 2434 551: {items: 2.2, margin: 0}, 2435 801: {items: 3, margin: 0}, 2436 1201: {items: 4, margin: 0} 2437 }; 2438 } 2439 }else if(type == 'mini_v'){ 2440 if (isSidebar.length && !globalThemeSettings.isMobile) { 2441 responsive = { 2442 0: {items: 2.1, margin: 0}, 2443 401: {items: 2.1, margin: 0}, 2444 541: {items: 3.2, margin: 0}, 2445 681: {items: 4.2, margin: 0}, 2446 801: {items: 4, margin: 0}, 2447 851: {items: 5, margin: 0}, 2448 1025: {items: 4, margin: 0}, 2449 1251: {items: 5, margin: 0}, 2450 1401: {items: 6, margin: 0} 2451 }; 2452 } else { 2453 responsive = { 2454 0: {items: 2.1, margin: 0}, 2455 401: {items: 2.1, margin: 0}, 2456 541: {items: 3.2, margin: 0}, 2457 681: {items: 4.2, margin: 0}, 2458 801: {items: 4, margin: 0}, 2459 851: {items: 5, margin: 0}, 2460 1025: {items: 6, margin: 0}, 2461 1251: {items: 7, margin: 0} 2462 }; 2463 } 2464 }else{ 2465 if (isSidebar.length && !globalThemeSettings.isMobile) { 2466 responsive = { 2467 0: {items: 1.2, margin: 0}, 2468 360: {items: 1.2, margin: 0}, 2469 501: {items: 2.2, margin: 0}, 2470 801: {items: 3.2, margin: 0}, 2471 1025: {items: 3, margin: 0}, 2472 1371: {items: 4, margin: 0} 2473 }; 2474 } else { 2475 responsive = { 2476 0: {items: 1.2, margin: 0}, 2477 360: {items: 1.2, margin: 0}, 2478 501: {items: 2.2, margin: 0}, 2479 801: {items: 3.2, margin: 0}, 2480 1025: {items: 3, margin: 0}, 2481 1151: {items: 4, margin: 0}, 2482 1381: {items: 5, margin: 0} 2483 }; 2484 } 2485 } 2486 2487 carousel.addClass("owl-carousel").addClass("owl-theme"); 2488 productsList.addClass("carousel-init"); 2489 carousel.owlCarousel({ 2490 loop: true, 2491 nav: true, 2492 dots: isDots, 2493 mouseDrag: false, 2494 navText: ['',''], 2495 navElement: "div", 2496 dotsEach: 1, 2497 navContainer: navigation, 2498 responsive: responsive, 2499 lazyLoad: is_lazy, 2500 onInitialize: function (event){ 2501 productsList.find(".js-init-interaction").remove(); 2502 }, 2503 onInitialized: function (event){ 2504 owlCarouselAdd.dotsShow($(event.currentTarget).closest('.js-products-carousel-outer').find(".owl-dot"));
2505 }, 2506 onDragged: function(event){ 2507 if (typeof $.autobadgeFrontend !== 'undefined') { 2508 $.autobadgeFrontend.reinit(); 2509 } 2510 }, 2511 onTranslated: function(event){ 2512 if (typeof $.autobadgeFrontend !== 'undefined') { 2513 $.autobadgeFrontend.reinit(); 2514 } 2515 }, 2516 onLoadedLazy: function(event){ 2517 var wrap = $(event.currentTarget); 2518 if (wrap.length && is_retina) { 2519 wrap.find(".owl-item.active .owl-lazy").retina({force_original_dimensions: false}); 2520 } 2521 wrap.find(".js-white-wrap").addClass("-white-wrap"); 2522 }, 2523 onChanged: function (event){ 2524 owlCarouselAdd.dotsShow($(event.currentTarget).closest('.js-products-carousel-outer').find(".owl-dot")); 2525 } 2526 }); 2527 if(goToSlide){ 2528 if(goToSlide == "prev") { 2529 carousel.trigger("prev.owl.carousel"); 2530 }else if(goToSlide == "next"){ 2531 carousel.trigger("next.owl.carousel"); 2532 }else{ 2533 carousel.trigger("to.owl.carousel", [parseInt(goToSlide)]); 2534 } 2535 } 2536 } 2537}; 2538 2539var promosCarousel = { 2540 carouselWrap: $('.js-promos-carousel-outer'), 2541 init: function (){ 2542 var _this = this; 2543 2544 if(!_this.carouselWrap.length){ 2545 return false; 2546 } 2547 2548 _this.prepareListCarousels(); 2549 _this.carouselInteraction(); 2550 2551 $(window).on('resize', _this.carouselsInit); 2552 }, 2553 carouselsInit: function (){ 2554 var _this = this; 2555 2556 promosCarousel.carouselWrap.each(function (){ 2557 var $this = $(this), 2558 carouselWrapWidth = $this.outerWidth(true), 2559 carouselItems = $this.find('.js-promo'), 2560 carouselItemsWidth = 0; 2561 2562 carouselItems.each(function (){ 2563 var $oneItem = $(this), 2564 itemWidth = $oneItem.outerWidth(); 2565 2566 carouselItemsWidth += itemWidth; 2567 }); 2568 2569 var isCarousel = (carouselWrapWidth + 25) < carouselItemsWidth; 2570 2571 if(isCarousel){ 2572 promosCarousel.carousel($this); 2573 $this.addClass("-carousel"); 2574 }else{ 2575 $this.removeClass("-carousel"); 2576 } 2577 }); 2578 }, 2579 prepareListCarousels: function (){ 2580 var _this = this; 2581 2582 _this.carouselWrap.each(function (){ 2583 var carousel = $(this).find('.js-promos-carousel'), 2584 carouselWidth = carousel.outerWidth(), 2585 itemCarousel = $(this).find(".js-promo"), 2586 countItems = itemCarousel.length, 2587 widthItem = itemCarousel.first().outerWidth(true), 2588 widthAllItems = widthItem * countItems, 2589 isCarousel = widthAllItems > carouselWidth + 25; 2590 2591 if(isCarousel){ 2592 var wrapButtons = $(this).find(".js-carousel-direction"); 2593 2594 wrapButtons.append('<div data-index="prev" class="js-init-interaction owl-prev"></div>'); 2595 wrapButtons.append('<div data-index="next" class="js-init-interaction owl-next"></div>'); 2596 2597 $(this).addClass("-carousel"); 2598 }else{ 2599 $(this).removeClass("-carousel"); 2600 } 2601 2602 var carouselOffsetRight = carousel.offset().left + carousel.outerWidth(); 2603 itemCarousel.slice(0,5).each(function (){ 2604 var itemOffsetLeft = $(this).offset().left; 2605 if (itemOffsetLeft < carouselOffsetRight) { 2606 var image = $(this).find('.js-img'), 2607 isLazyImage = image.hasClass('owl-lazy'), 2608 isRetina = carousel.data('retina'); 2609 2610 if(isLazyImage){ 2611 image.Lazy({ 2612 afterLoad: function(element) { 2613 element.removeClass("owl-lazy"); 2614 if (isRetina) { 2615 element.retina(); 2616 } 2617 }, 2618 }); 2619 }else if(isRetina){ 2620 image.retina(); 2621 } 2622 } 2623 }); 2624 }); 2625 }, 2626 carouselInteraction: function (){ 2627 var _this = this, 2628 carouselNav = $('.js-init-interaction'); 2629 2630 carouselNav.on("click", function (){ 2631 var carousel = $(this).closest('.js-promos-carousel-outer'); 2632 2633 _this.carousel(carousel, $(this).data("index")); 2634 }); 2635 2636 if(touch.isTouchDevice()){ 2637 $('.js-promos-carousel').each(function (){ 2638 var $list = $(this); 2639 2640 $list.hammer().on("swipeleft swiperight", function(event){ 2641 var carousel = $(this), 2642 carouselWidth = carousel.outerWidth(), 2643 itemCarousel = $(this).find(".js-promo"), 2644 countItems = itemCarousel.length, 2645 widthItem = itemCarousel.first().outerWidth(true), 2646 widthAllItems = widthItem * countItems, 2647 isCarousel = widthAllItems > carouselWidth + 25; 2648 2649 if(isCarousel){
2650 var $listCarousel = $(this).closest(".js-promos-carousel-outer"); 2651 2652 if(event.type == 'swipeleft'){ 2653 _this.carousel($listCarousel, "next"); 2654 }else if(event.type == 'swiperight'){ 2655 _this.carousel($listCarousel, "prev"); 2656 } 2657 } 2658 }); 2659 }); 2660 } 2661 }, 2662 carousel: function (itemList, goToSlide){ 2663 if(itemList.hasClass("carousel-init")){ 2664 return false; 2665 } 2666 var carousel = itemList.find('.js-promos-carousel'), 2667 isSidebar = carousel.closest('.js-content-cols-sidebar'), 2668 is_lazy = carousel.data('lazy'), 2669 is_retina = carousel.data('retina'), 2670 isDots = carousel.data('dots'), 2671 isNav = carousel.data('nav'), 2672 isVertical = (carousel.data('format') == "vertical"), 2673 tempNavWrap = itemList.find('.owl-prev, .owl-next'), 2674 tempDotsWrap = itemList.find('.owl-dot'), 2675 responsive = {}; 2676 2677 tempNavWrap.remove(); 2678 tempDotsWrap.remove(); 2679 2680 if(isVertical){ 2681 if (isSidebar.length && !globalThemeSettings.isMobile) { 2682 responsive = { 2683 0: {items: 1.12, margin: 0}, 2684 360: {items: 1.25, margin: 0}, 2685 551: {items: 2.25, margin: 0}, 2686 801: {items: 3.55, margin: 0}, 2687 1025: {items: 2.25, margin: 0}, 2688 1101: {items: 2.5, margin: 0}, 2689 1201: {items: 3.55, margin: 0} 2690 }; 2691 } else { 2692 responsive = { 2693 0: {items: 1.12, margin: 0}, 2694 360: {items: 1.25, margin: 0}, 2695 551: {items: 2.25, margin: 0}, 2696 801: {items: 3.55, margin: 0}, 2697 1025: {items: 3.55, margin: 0}, 2698 1100: {items: 4.35, margin: 0}, 2699 2700 }; 2701 } 2702 }else{ 2703 if (isSidebar.length && !globalThemeSettings.isMobile) { 2704 responsive = { 2705 0: {items: 1.17, margin: 0}, 2706 360: {items: 1.14, margin: 0}, 2707 801: {items: 1.27, margin: 0}, 2708 901: {items: 1.34, margin: 0}, 2709 1025: {items: 1.16, margin: 0}, 2710 1101: {items: 1.25, margin: 0}, 2711 1201: {items: 2.1, margin: 0} 2712 }; 2713 } else { 2714 responsive = { 2715 0: {items: 1.17, margin: 0}, 2716 360: {items: 1.17, margin: 0}, 2717 801: {items: 1.3, margin: 0}, 2718 901: {items: 1.37, margin: 0}, 2719 1025: {items: 2.1, margin: 0}, 2720 2721 }; 2722 } 2723 } 2724 2725 itemList.find(".js-init-interaction").removeClass("js-init-interaction"); 2726 carousel.addClass("owl-carousel").addClass("owl-theme"); 2727 itemList.addClass("carousel-init"); 2728 carousel.owlCarousel({ 2729 loop: true, 2730 nav: isNav, 2731 dots: isDots, 2732 mouseDrag: false, 2733 navText: ['',''], 2734 navElement: "div", 2735 dotsEach: 1, 2736 navContainer: itemList.find('.js-carousel-direction'), 2737 dotsContainer: itemList.find('.js-carousel-dots'), 2738 responsive: responsive, 2739 lazyLoad: is_lazy, 2740 onInitialized: function (event){ 2741 owlCarouselAdd.dotsShow($(event.currentTarget).closest('.js-promos-carousel-outer').find(".owl-dot")); 2742 }, 2743 onLoadedLazy: function(event){ 2744 2745 var wrap = $(event.currentTarget); 2746 if (wrap.length && is_retina) { 2747 wrap.find(".owl-item.active .owl-lazy").retina(); 2748 } 2749 }, 2750 onChanged: function (event){ 2751 owlCarouselAdd.dotsShow($(event.currentTarget).closest('.js-promos-carousel-outer').find(".owl-dot"));
2752 } 2753 }); 2754 2755 if(goToSlide){ 2756 if(goToSlide == "prev") { 2757 carousel.trigger("prev.owl.carousel"); 2758 }else if(goToSlide == "next"){ 2759 carousel.trigger("next.owl.carousel"); 2760 }else{ 2761 carousel.trigger("to.owl.carousel", [parseInt(goToSlide)]); 2762 } 2763 } 2764 } 2765}; 2766 2767var reviewsCarousel = { 2768 carouselWrap: $('.js-reviews-carousel-outer'), 2769 init: function (){ 2770 var _this = this; 2771 2772 if(!_this.carouselWrap.length){ 2773 return false; 2774 } 2775 2776 _this.prepareListCarousels(); 2777 _this.carouselInteraction(); 2778 2779 $(window).one('resize', _this.carouselsInit); 2780 }, 2781 carouselsInit: function (){ 2782 reviewsCarousel.carouselWrap.each(function (){ 2783 var $this = $(this), 2784 carouselWrapWidth = $this.outerWidth(true), 2785 carouselItems = $this.find('.js-review'), 2786 carouselItemsWidth = 0; 2787 2788 carouselItems.each(function (){ 2789 var $oneItem = $(this), 2790 itemWidth = $oneItem.outerWidth(); 2791 2792 carouselItemsWidth += itemWidth; 2793 }); 2794 2795 if((carouselWrapWidth + 25) < carouselItemsWidth){ 2796 reviewsCarousel.carousel($this); 2797 } 2798 }); 2799 }, 2800 prepareListCarousels: function (){ 2801 var _this = this; 2802 2803 _this.carouselWrap.each(function (){ 2804 var carousel = $(this).find('.js-reviews-carousel'), 2805 carouselWidth = carousel.outerWidth(), 2806 itemCarousel = $(this).find(".js-review"), 2807 countItems = itemCarousel.length, 2808 widthItem = itemCarousel.first().outerWidth(true), 2809 widthAllItems = widthItem * countItems, 2810 isCarousel = widthAllItems > carouselWidth + 20; 2811 2812 if(isCarousel){ 2813 var wrapButtons = $(this).find(".js-carousel-direction"); 2814 2815 wrapButtons.append('<div data-index="prev" class="js-init-interaction owl-prev"></div>'); 2816 wrapButtons.append('<div data-index="next" class="js-init-interaction owl-next"></div>'); 2817 2818 $(this).addClass("-carousel"); 2819 } 2820 2821 var carouselOffsetRight = carousel.offset().left + carousel.outerWidth(); 2822 itemCarousel.slice(0,3).each(function (){ 2823 var itemOffsetLeft = $(this).offset().left; 2824 if (itemOffsetLeft < carouselOffsetRight) { 2825 var image = $(this).find('.js-img'), 2826 isLazyImage = image.hasClass('owl-lazy'), 2827 isRetina = carousel.data('retina'); 2828 2829 if(isLazyImage){ 2830 image.Lazy({ 2831 afterLoad: function(element) { 2832 element.removeClass("owl-lazy"); 2833 if (isRetina) { 2834 element.retina(); 2835 } 2836 }, 2837 }); 2838 }else if(isRetina){ 2839 image.retina(); 2840 } 2841 2842 } 2843 }); 2844 }); 2845 }, 2846 carouselInteraction: function (){ 2847 var _this = this, 2848 carouselNav = $('.js-init-interaction'); 2849 2850 carouselNav.on("click", function (){ 2851 var carousel = $(this).closest('.js-reviews-carousel-outer'); 2852 2853 _this.carousel(carousel, $(this).data("index")); 2854 }); 2855 2856 if(touch.isTouchDevice()){ 2857 $('.js-reviews-carousel').each(function (){ 2858 var $list = $(this); 2859 2860 $list.hammer().on("swipeleft swiperight", function(event){ 2861 var carousel = $(this), 2862 carouselWidth = carousel.outerWidth(), 2863 itemCarousel = $(this).find(".js-review"), 2864 countItems = itemCarousel.length, 2865 widthItem = itemCarousel.first().outerWidth(true), 2866 widthAllItems = widthItem * countItems, 2867 isCarousel = widthAllItems > carouselWidth + 20; 2868 2869 if(isCarousel){
2870 var $listCarousel = $(this).closest(".js-reviews-carousel-outer"); 2871 2872 if(event.type == 'swipeleft'){ 2873 _this.carousel($listCarousel, "next"); 2874 }else if(event.type == 'swiperight'){ 2875 _this.carousel($listCarousel, "prev"); 2876 } 2877 } 2878 }); 2879 }); 2880 } 2881 }, 2882 carousel: function (itemList, goToSlide){ 2883 if(itemList.hasClass("carousel-init")){ 2884 return false; 2885 } 2886 var carousel = itemList.find('.js-reviews-carousel'), 2887 navigation = itemList.find('.js-carousel-direction'), 2888 dots = itemList.find('.js-carousel-dots'), 2889 isSidebar = carousel.closest('.js-content-cols-sidebar'), 2890 is_lazy = carousel.data('image-lazy'), 2891 is_retina = carousel.data('retina'), 2892 responsive = {}; 2893 2894 itemList.find(".js-init-interaction").remove(); 2895 responsive = { 2896 0: { items: 1.11, margin: 0 }, 2897 801: { items: 1.44, margin: 0 }, 2898 1151: { items: 2.22, margin: 0 } 2899 }; 2900 2901 carousel.addClass("owl-carousel").addClass("owl-theme"); 2902 itemList.addClass("carousel-init"); 2903 carousel.owlCarousel({ 2904 loop: true, 2905 nav: true, 2906 dots: true, 2907 mouseDrag: false, 2908 navText: ['',''], 2909 navElement: "div", 2910 navContainer: navigation, 2911 dotsContainer: dots, 2912 responsive: responsive, 2913 lazyLoad: is_lazy, 2914 dotsEach: 1, 2915 onInitialized: function (event){ 2916 owlCarouselAdd.dotsShow($(event.currentTarget).closest('.js-reviews-carousel-outer').find(".owl-dot")); 2917 }, 2918 onLoadedLazy: function(event){ 2919 var wrap = $(event.currentTarget); 2920 if (wrap.length && is_retina) { 2921 wrap.find(".owl-item.active .owl-lazy").retina(); 2922 } 2923 }, 2924 onChanged: function (event){ 2925 owlCarouselAdd.dotsShow($(event.currentTarget).closest('.js-reviews-carousel-outer').find(".owl-dot")); 2926 } 2927 }); 2928 if(goToSlide){ 2929 if(goToSlide == "prev") { 2930 carousel.trigger("prev.owl.carousel"); 2931 }else if(goToSlide == "next"){ 2932 carousel.trigger("next.owl.carousel"); 2933 }else{ 2934 carousel.trigger("to.owl.carousel", [parseInt(goToSlide)]); 2935 } 2936 } 2937 } 2938}; 2939 2940var owlCarouselAdd = { 2941 dotsShow: function (dots){ 2942 if(!dots.length) return false; 2943 if(dots.length < 6 ){ 2944 dots.addClass("-sk-show"); 2945 2946 return false; 2947 } 2948 2949 var dotActive = dots.filter(".active"), 2950 prevElements = dotActive.prevAll(), 2951 countPrevElements = prevElements.length, 2952 nextElements = dotActive.nextAll(), 2953 countNextElements = nextElements.length; 2954 2955 dotActive.siblings().removeClass("-sk-show"); 2956 2957 var dotsShow = dotActive.add($(prevElements[0])).add($(prevElements[1])).add($(nextElements[0])).add($(nextElements[1])); 2958 2959 if(countNextElements < 2){ 2960 dotsShow = dotsShow.add($(prevElements[2])); 2961 } 2962 if(countNextElements < 1){ 2963 dotsShow = dotsShow.add($(prevElements[3])); 2964 } 2965 2966 if(countPrevElements < 2){ 2967 dotsShow = dotsShow.add($(nextElements[2])); 2968 } 2969 if(countPrevElements < 1){ 2970 dotsShow = dotsShow.add($(nextElements[3])); 2971 } 2972 2973 dotsShow.addClass("-sk-show"); 2974 } 2975}; 2976 2977var sidebarCarousel = { 2978 init: function (){ 2979 var _this = this; 2980 2981 var carouselProducts = $('.js-sidebar-carousel-outer'); 2982 carouselProducts.each(function (){ 2983 _this.carousel($(this)); 2984 }); 2985 }, 2986 carousel: function (productsList){
2987 var carouselWrap = productsList.find('.js-sidebar-carousel'), 2988 countVisible = parseInt(carouselWrap.data("count-visible")), 2989 isLazy = carouselWrap.data("image-lazy"), 2990 isRetina = carouselWrap.data("retina"); 2991 2992 carouselWrap.jCarouselLite({ 2993 btnNext: productsList.find(".js-sidebar-carousel-next"), 2994 btnPrev: productsList.find(".js-sidebar-carousel-prev"), 2995 vertical: true, 2996 visible: countVisible ? countVisible : 3, 2997 scroll: 3, 2998 afterEnd: function(a) { 2999 if(isLazy){ 3000 a.find('.js-img').lazy({ 3001 afterLoad: function(element) { 3002 if(isRetina){ 3003 element.retina({force_original_dimensions: false}); 3004 } 3005 }, 3006 }); 3007 } 3008 } 3009 }); 3010 } 3011}; 3012 3013var spoilerWrap = { 3014 init: function (){ 3015 var _this = this; 3016 3017 _this.addButton($('.js-spoiler-outer')); 3018 _this.open(); 3019 }, 3020 addButton: function (wrap){ 3021 wrap.each(function (){ 3022 var wrapOuter = $(this).find(".js-spoiler-wrap"), 3023 maxHeight = wrapOuter.data("max-height"), 3024 wrapText = $(this).find(".js-spoiler"), 3025 linkMore = $(this).find('.js-spoiler-more-wrap'); 3026 3027 linkMore.remove(); 3028 wrapOuter.removeClass("close"); 3029 if (wrapOuter.length && maxHeight){ 3030 wrapOuter.css("max-height", maxHeight + "px"); 3031 } 3032 if(wrapOuter.length && wrapText.length && wrapOuter.outerHeight() < wrapText.outerHeight()){ 3033 var textMore = wrapOuter.data("text-more"); 3034 3035 wrapOuter.addClass("close"); 3036 wrapOuter.removeClass("overflow-visible"); 3037 wrapOuter.after("<div class='js-spoiler-more-wrap spoiler-more-wrap'><span class='js-spoiler-more link-ac-border -sk-small'>"+textMore+" <i class='sk-icon far fa-long-arrow-alt-down'></i></span> </div>"); 3038 }else{ 3039 wrapOuter.removeAttr("style"); 3040 wrapOuter.addClass("overflow-visible"); 3041 } 3042 }); 3043 }, 3044 open: function (){ 3045 $('body').on("click", ".js-spoiler-more", function(){ 3046 var $this = $(this),
3047 wrapOuter = $this.closest('.js-spoiler-outer').find(".js-spoiler-wrap"), 3048 wrapText = $this.closest('.js-spoiler-outer').find(".js-spoiler"), 3049 maxHeight = wrapOuter.data("max-height"), 3050 textMore = wrapOuter.data("text-more") + " <i class='sk-icon far fa-long-arrow-alt-down'></i>", 3051 textHide = wrapOuter.data("text-hide") + " <i class='sk-icon far fa-long-arrow-alt-up'></i>"; 3052 3053 if($this.hasClass("open")){ 3054 wrapOuter.css("max-height", wrapText.outerHeight() + "px"); 3055 $this.removeClass("open"); 3056 $this.html(textMore); 3057 wrapOuter.addClass("close"); 3058 wrapOuter.removeClass("overflow-visible"); 3059 wrapOuter.animate({maxHeight: maxHeight}, 500); 3060 }else{ 3061 wrapOuter.animate({maxHeight: wrapText.outerHeight() + "px"}, 500, function(){ 3062 wrapOuter.css("max-height", "none"); 3063 wrapOuter.removeClass("close"); 3064 wrapOuter.addClass("overflow-visible"); 3065 }); 3066 3067 $this.addClass("open"); 3068 $this.html(textHide); 3069 } 3070 }); 3071 } 3072}; 3073 3074 3075var skusDropdown = { 3076 init: function (){ 3077 var _this = this; 3078 3079 _this.openByHead(); 3080 _this.select(); 3081 _this.setTitle(); 3082 _this.closeByClickOutside(); 3083 }, 3084 openByHead: function (){ 3085 var _this = this; 3086 3087 $('body').on("click", ".js-sku-dropdown-head", function (){ 3088 var $outerWrap = $(this).closest(".js-sku-dropdown"); 3089 3090 if($outerWrap.length){ 3091 if($outerWrap.hasClass('-sk-open')){ 3092 _this.close($outerWrap); 3093 }else{ 3094 _this.open($outerWrap); 3095 } 3096 } 3097 }); 3098 }, 3099 closeByClickOutside: function (){ 3100 var _this = this; 3101 3102 $(document).click(function(event) { 3103 if(!$(event.target).closest(".js-sku-dropdown").length) { 3104 $(".js-sku-dropdown").each(function (){ 3105 _this.close($(this)); 3106 }); 3107 } 3108 }); 3109 }, 3110 open: function ($outerWrap){ 3111 var _this = this, 3112 $itemsWrap = $outerWrap.find('.js-sku-dropdown-items'), 3113 $outerWrapSiblings = $outerWrap.siblings(); 3114 3115 $outerWrapSiblings.removeClass("-sk-open"); 3116 $outerWrapSiblings.find(".js-sku-dropdown-items").hide(); 3117 3118 $outerWrap.addClass("-sk-open"); 3119 $itemsWrap.slideDown(200); 3120 }, 3121 close: function ($outerWrap){ 3122 var $itemsWrap = $outerWrap.find('.js-sku-dropdown-items'); 3123 3124 $itemsWrap.slideUp(200, function (){ 3125 $outerWrap.removeClass("-sk-open"); 3126 }); 3127 }, 3128 select: function (){ 3129 var _this = this; 3130 3131 $('body').on("click", ".js-sku-dropdown-item", function (event){ 3132 if($(this).prop("tagName").toLowerCase() == 'a'){ 3133 event.preventDefault(); 3134 } 3135 3136 var currentItem = $(this), 3137 outerWrap = currentItem.closest(".js-sku-dropdown"); 3138 3139 _this.close(outerWrap); 3140 _this.setValueInput(currentItem); 3141 }); 3142 }, 3143 addClassSelect: function (currentItem){ 3144 currentItem.addClass("selected").siblings().removeClass("selected"); 3145 }, 3146 setValueInput: function (currentItem){ 3147 var outerWrap = currentItem.closest(".js-sku-dropdown"), 3148 value = currentItem.data("value"), 3149 input = outerWrap.find('.sku-feature'); 3150 3151 input.val(value).change(); 3152 }, 3153 setTitle: function (){ 3154 var _this = this; 3155 3156 $('body').on("change", '.sku-feature, .skus input[type=radio]', function (){ 3157 var $this = $(this), 3158 outerWrap = $this.closest(".js-sku-dropdown"); 3159 3160 if(outerWrap.length){ 3161 var value = $this.val(), 3162 currentItem = outerWrap.find(".js-sku-dropdown-item[data-value='"+value+"']"); 3163 3164 if(currentItem.length){ 3165 var cloneCurrentItem = currentItem.clone(); 3166 cloneCurrentItem.find("input, .js-radio-styler").remove(); 3167 3168 var currentItemText = cloneCurrentItem.html(), 3169 headCurrentWrap = outerWrap.find('.js-sku-dropdown-current'); 3170 3171 skusDropdown.addClassSelect(currentItem); 3172 headCurrentWrap.html(currentItemText) 3173 } 3174 } 3175 }); 3176 } 3177}; 3178 3179var optionsInline = { 3180 init: function (){ 3181 var _this = this; 3182 3183 _this.select(); 3184 _this.setSelect(); 3185 _this.showAll(); 3186 }, 3187 showAll: function (){ 3188 var _this = this; 3189 3190 $('body').on('click', '.js-option-buttons-else', function (){ 3191 var $this = $(this), 3192 outerList = $this.closest('.js-option-buttons-list'); 3193 3194 outerList.toggleClass('-sk-close').toggleClass('-sk-open'); 3195 }); 3196 }, 3197 select: function (){ 3198 var _this = this; 3199 3200 $('body').on("click", ".js-option-buttons-item", function (event){ 3201 event.preventDefault(); 3202 3203 var currentItem = $(this); 3204 3205 _this.setValueInput(currentItem); 3206 }); 3207 }, 3208 3209 setValueInput: function (currentItem){
3210 var outerWrap = currentItem.closest(".js-option-buttons"), 3211 value = currentItem.data("value"), 3212 input = outerWrap.find('.sku-feature'); 3213 3214 input.val(value).change(); 3215 }, 3216 setSelect: function (){ 3217 var _this = this; 3218 3219 $('body').on("change", '.sku-feature', function (){ 3220 var $this = $(this), 3221 outerWrap = $this.closest(".js-option-buttons"); 3222 3223 if(outerWrap.length){ 3224 var value = $this.val(), 3225 currentItem = outerWrap.find(".js-option-buttons-item[data-value='"+value+"']"); 3226 3227 if(currentItem.length){ 3228 skusDropdown.addClassSelect(currentItem); 3229 } 3230 } 3231 }); 3232 } 3233} 3234 3235var ProductGallery = { 3236 init: function(){ 3237 var _this = this; 3238 3239 3240 _this.previewsCarouselInit(); 3241 _this.mainCarouselInit(); 3242 _this.popupVideo(); 3243 3244 /* popup gallery */ 3245 $('body').on("click", ".js-product-image-popup", function (e) { 3246 e.preventDefault(); 3247 3248 var mainGallery = $(this).closest('.js-product').find(".js-product-gallery"); 3249 if (mainGallery.data('photoswipe')){ 3250 _this.popupGalleryPhotoswipe($(this), mainGallery); 3251 }else{ 3252 _this.popupGallerySwipebox($(this), mainGallery); 3253 } 3254 }); 3255 3256 var mainGallery = $('.js-product-gallery'), 3257 firstImage = mainGallery.find('.js-product-gallery-item').first(); 3258 3259 /* retina for first image */ 3260 var isRetina = mainGallery.data('retina'); 3261 if(isRetina && firstImage.length){ 3262 setTimeout(function (){ 3263 var firstImageWidth = firstImage.find('img').width(); 3264 3265 firstImage.find('img').css("max-width", firstImageWidth + "px").retina({force_original_dimensions: false}); 3266 }, 3000); 3267 } 3268 3269 /* zoom for first image */ 3270 var isZoom = mainGallery.find('.js-zoom').length; 3271 if(isZoom && firstImage && !touch.isTouchDevice()){ 3272 _this.productImageZoom(firstImage); 3273 } 3274 3275 /* select preview image */ 3276 $("body").on("click", ".js-gallery-preview", function (event) { 3277 event.preventDefault(); 3278 3279 _this.previewSelect($(this)); 3280 }); 3281 }, 3282 popupGalleryPhotoswipe: function(preview, mainGallery){ 3283 var mainGalleryImages = preview.closest('.js-product').find(".js-product-image-popup"), 3284 mainGallery = mainGalleryImages.closest(".js-product-gallery-main"); 3285 3286 $('body').on("click", ".pswp button", function (event){ 3287 event.preventDefault(); 3288 }); 3289 3290 var previews = preview.closest('.js-product').find('.js-product-gallery-item'), 3291 pswpElement = document.querySelectorAll('.pswp')[0], 3292 position = preview.data('position'), 3293 items = []; 3294 3295 if (previews.length){ 3296 previews.each(function () { 3297 var image = $(this); 3298 3299 items.push({src: image.attr("href"), w: 0, h: 0}); 3300 }); 3301 } 3302 3303 var options = { 3304 index: position, 3305 shareEl: false, 3306 history: false 3307 }; 3308 3309 var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options); 3310 3311 gallery.listen('gettingData', function (index, item) { 3312 if (item.w < 1 || item.h < 1) { // unknown size 3313 var img = new Image(); 3314 img.onload = function () { 3315 item.w = this.width; 3316 item.h = this.height; 3317 gallery.updateSize(true); 3318 }; 3319 img.src = item.src; 3320 } 3321 }); 3322 gallery.init(); 3323 }, 3324 popupGallerySwipebox: function(mainGalleryCurrentImage, mainGallery){ 3325 var isPopupGalleryPreviews = mainGallery.data('popup-previews'), 3326 previewsImages = mainGalleryCurrentImage.closest('.js-product').find('.js-gallery-preview'); 3327 3328 var popupImages = []; 3329 if (previewsImages.length) { 3330 previewsImages.each(function () { 3331 if(!$(this).data('video')){ 3332 popupImages.push({href: $(this).attr('href'), src: $(this).find('img').attr('src')}); 3333 } 3334 }); 3335 } else { 3336 popupImages.push({href: mainGalleryCurrentImage.attr('href'), src: mainGalleryCurrentImage.find('img').attr('src')}); 3337 } 3338 3339 var position = mainGalleryCurrentImage.data('position'); 3340 3341 $.swipebox(popupImages, { 3342 useSVG : false,
3343 hideBarsDelay: false, 3344 loopAtEnd: true, 3345 thumbs: true, 3346 initialIndexOnArray: position, 3347 beforeOpen: function (){ 3348 /* коÑÑÑÐ»Ñ Ð´Ð»Ñ ÑÐ½Ð´ÐµÐºÑ ÑовеÑника */ 3349 $( '.js-swipebox-overlay' ).remove(); 3350 }, 3351 afterOpen: function() { 3352 if (isPopupGalleryPreviews && popupImages.length > 1){ 3353 var imagesThumbsHtml = '', currentIndex = parseInt($('#swipebox-slider .slide.current').data("index")); 3354 popupImages.forEach(function(element, index) { 3355 var addClass = "swipebox-thumbs_el js-swipebox-thumbs-el"; 3356 3357 if (currentIndex === index) { 3358 addClass += " active"; 3359 } 3360 3361 imagesThumbsHtml += '<a class="' + addClass + '" data-index="' + index + '" href="' + element.href + '"><img src="' + element.src + '" /></a>'; 3362 }); 3363 3364 $('#swipebox-container').append('<div id="swipebox-thumbs" class="swipebox-thumbs">'+imagesThumbsHtml+'</div>'); 3365 $('#swipebox-slider').css("padding-bottom", (parseInt($('#swipebox-thumbs').outerHeight()) + 30) + 'px'); 3366 if(globalThemeSettings.isRetina){ 3367 if($('.js-swipebox-thumbs-el').length){ 3368 $('.js-swipebox-thumbs-el img').retina(); 3369 } 3370 } 3371 } 3372 $('#swipebox-bottom-bar').addClass("swipebox-bottom-bar--pos-center"); 3373 $('#swipebox-arrows').addClass("swipebox-arrows--pos-center"); 3374 3375 var closeSwipe = function() { 3376 var $closeButton = $("#swipebox-close"); 3377 if ($closeButton.length) { 3378 $closeButton.trigger("click"); 3379 } 3380 $(document).off("scroll", closeSwipe); 3381 }; 3382 $(document).on("scroll", closeSwipe); 3383 } 3384 }); 3385 }, 3386 productImageZoom: function(mainGalleryImages){ 3387 var mainGallery = mainGalleryImages.closest('.js-product-gallery'); 3388 3389 if(mainGalleryImages.length && mainGallery.length){ 3390 mainGalleryImages.each(function(){ 3391 var zoomWrap = $(this).find('.js-zoom'), 3392 zoomImg = $(this).find('img'); 3393 3394 if(!zoomImg.hasClass('zoomImg')){ 3395 zoomWrap.zoom({ 3396 url: $(this).attr('href'), 3397 onZoomIn: function (){ 3398 zoomWrap.addClass("zooming"); 3399 }, 3400 onZoomOut: function (){ 3401 zoomWrap.removeClass("zooming"); 3402 } 3403 }); 3404 } 3405 }); 3406 } 3407 }, 3408 previewsCarouselInit: function(){ 3409 var _this = this, 3410 $previewsWrap = $('.js-product-gallery-previews-outer'); 3411 3412 $previewsWrap.each(function (){ 3413 var $this = $(this), 3414 carousel = $this.find('.js-product-gallery-previews-carousel'); 3415 3416 if(carousel.length){ 3417 _this.previewsCarousel(carousel); 3418 } 3419 3420 var isLazy = $this.data("image-lazy"), 3421 isRetina = $this.data("retina"); 3422 3423 if(isLazy){ 3424 var previewImg = $this.find('.js-img'); 3425 previewImg.lazy({ 3426 afterLoad: function(element) { 3427 if(isRetina){ 3428 element.retina(); 3429 } 3430 }, 3431 }); 3432 } 3433 }); 3434 }, 3435 previewsCarousel: function ($previewsWrap){ 3436 var $outer = $previewsWrap.closest('.js-product-gallery-previews-outer'); 3437 3438 $previewsWrap.jCarouselLite({ 3439 btnNext: $outer.find(".js-product-gallery-previews-next"), 3440 btnPrev: $outer.find(".js-product-gallery-previews-prev"), 3441 vertical: true, 3442 visible: 4, 3443 scroll: 1, 3444 circular: false, 3445 activeClass: "active", 3446 responsive:false, 3447 autoCSS: false, 3448 btnGo: $previewsWrap.find(".js-gallery-preview, .js-gallery-preview-video"), 3449 init: function (){ 3450 $previewsWrap.addClass("-sk-carousel-init"); 3451 } 3452 }); 3453 },
3454 previewsCarouselSetPosition: function (carousel, position){ 3455 carousel.trigger('go', position) 3456 }, 3457 previewSelect: function (preview, isPositionChange){ 3458 var _this = this; 3459 3460 if(preview.length){ 3461 preview.closest('.js-product').find('.js-gallery-preview').removeClass('selected'); 3462 preview.addClass('selected'); 3463 3464 var previewPosition = preview.data("position"); 3465 3466 var image_id = preview.data("id"); 3467 if(image_id){ 3468 var mainGallery = preview.closest('.js-product').find('.js-product-gallery'), 3469 mainGalleryPosition = mainGallery.find('.js-product-gallery-item').filter("[data-id='" + image_id + "']").data("position"); 3470 3471 _this.mainCarousel(mainGallery, mainGalleryPosition); 3472 3473 if(isPositionChange){ 3474 _this.previewsCarouselSetPosition($(".js-product-gallery-previews-carousel"), previewPosition); 3475 } 3476 } 3477 } 3478 }, 3479 mainCarouselInit: function (){ 3480 var _this = this; 3481 3482 var mainGallery = $('.js-product-gallery'); 3483 3484 $("body").on("click", '.js-product-gallery-init-interaction', function (event){ 3485 event.preventDefault(); 3486 3487 _this.mainCarousel($(this).closest(".js-product-gallery"), $(this).data("index")); 3488 }); 3489 3490 _this.swipeLargePhoto(mainGallery); 3491 }, 3492 swipeLargePhoto: function (mainGallery){ 3493 var _this = this; 3494 3495 if(touch.isTouchDevice() && mainGallery.length && !mainGallery.hasClass('owl-carousel')){ 3496 mainGallery.hammer().on("swipeleft swiperight", function(event){ 3497 if(event.type == 'swipeleft'){ 3498 _this.mainCarousel(mainGallery, "next"); 3499 }else if(event.type == 'swiperight'){ 3500 _this.mainCarousel(mainGallery, "prev"); 3501 } 3502 }); 3503 } 3504 }, 3505 mainCarousel: function(mainGallery, position){ 3506 if(mainGallery.length){ 3507 var _this = this; 3508 3509 if(!mainGallery.hasClass('owl-carousel')){ 3510 mainGallery.addClass('owl-carousel'); 3511 mainGallery.find('.js-product-gallery-dots').remove(); 3512 3513 var isRetina = mainGallery.data("retina"), 3514 autoHeight = mainGallery.data("auto-height"); 3515 3516 if(autoHeight){ 3517 var mainGalleryFirstItem = mainGallery.find('.js-product-gallery-item').first(), 3518 heightFirstItem = mainGalleryFirstItem.outerHeight(); 3519 3520 mainGalleryFirstItem.next().css("height", heightFirstItem + "px"); 3521 } 3522 3523 mainGallery.owlCarousel({ 3524 loop: false, 3525 nav: false, 3526 margin: 0, 3527 items: 1, 3528 lazyLoad: true, 3529 autoHeight: autoHeight, 3530 dots: mainGallery.data("dots"), 3531 startPosition: 0, 3532 mouseDrag: false, 3533 onLoadedLazy: function(event){ 3534 var gallery = $(event.currentTarget); 3535 3536 if (gallery.length && isRetina) { 3537 var image = gallery.find(".owl-item.active .owl-lazy"), 3538 widthImage = image.width(); 3539 3540 if(widthImage > 1){ 3541 image.css("max-width", widthImage + "px") 3542 } 3543 image.retina({force_original_dimensions: false}) 3544 } 3545 3546 gallery.find('.js-product-gallery-item').css("height", "auto"); 3547 var itemActive = gallery.find(".owl-item.active"), 3548 itemActiveHeight = itemActive.find('.js-product-gallery-item').outerHeight(true), 3549 itemNext = itemActive.next(); 3550 3551 gallery.find(".owl-height").css("height", itemActiveHeight + "px"); 3552 if(itemNext.length){ 3553 itemNext.find('.js-product-gallery-item').css("height", itemActiveHeight + "px"); 3554 } 3555 }, 3556 onInitialized: function(event){ 3557 var gallery = $(event.currentTarget); 3558 3559 if(!touch.isTouchDevice()){ 3560 _this.productImageZoom(mainGallery.find(".js-product-gallery-item")); 3561 } 3562 owlCarouselAdd.dotsShow($(event.currentTarget).closest('.js-product-gallery').find(".owl-dot"));
3563 3564 gallery.find('.owl-stage-outer').css("height", "auto"); 3565 }, 3566 onChanged: function (event){ 3567 var gallery = $(event.currentTarget), 3568 currentItemIndex = event.item.index, 3569 currentItem = gallery.find('.js-product-gallery-item[data-position="'+currentItemIndex+'"]'), 3570 currentItemId = currentItem.data("id"); 3571 3572 if(currentItemId){ 3573 var previews = gallery.closest('.js-product').find('.js-gallery-preview'), 3574 currentPreview = previews.filter("[data-id='" + currentItemId + "']"); 3575 3576 _this.previewSelect(currentPreview, true); 3577 } 3578 3579 owlCarouselAdd.dotsShow($(event.currentTarget).closest('.js-product-gallery').find(".owl-dot")); 3580 }, 3581 onDragged: function(event){ 3582 var gallery = $(event.currentTarget); 3583 3584 if(gallery.length){ 3585 var previews = gallery.closest('.js-product').find('.js-gallery-preview'), 3586 image = $(gallery).find(".owl-item.active .js-product-gallery-item"), 3587 image_id = image.data("id"); 3588 3589 if(image_id){ 3590 var currentPreview = previews.filter("[data-id='" + image_id + "']"); 3591 3592 _this.previewSelect(currentPreview, true); 3593 } 3594 } 3595 } 3596 }); 3597 } 3598 3599 mainGallery.trigger('resize.owl.carousel'); 3600 3601 if(typeof position !== 'undefined' ){ 3602 if(position == "prev") { 3603 mainGallery.trigger("prev.owl.carousel"); 3604 }else if(position == "next"){ 3605 mainGallery.trigger("next.owl.carousel"); 3606 }else{ 3607 mainGallery.trigger("to.owl.carousel", [parseInt(position)]); 3608 } 3609 } 3610 } 3611 }, 3612 popupVideo: function (){ 3613 $('body').on('touchstart touchend touchup', '.js-mfp-fade-product-video', function(event) { 3614 event.stopPropagation(); 3615 }); 3616 3617 $('body').on('click', '.js-popup-video-close', function (){ 3618 var popupVideo = $(this).closest('.js-product-video-popup'); 3619 popupVideo.removeClass("_opened"); 3620 popupVideo.find('iframe').attr("src", ""); 3621 }); 3622 3623 $('body').on('click', '.js-product-video-popup', function (){ 3624 $(this).removeClass("_opened"); 3625 $(this).find('iframe').removeAttr("src"); 3626 }); 3627 3628 $("body").on("click", '.js-gallery-popup-video', function(event){ 3629 event.preventDefault(); 3630 var href = $(this).attr("href"), 3631 productOuter = $(this).closest('.js-product'), 3632 productPopupVideo = productOuter.find('.js-product-video-popup'); 3633 3634 if(productPopupVideo.length){ 3635 productPopupVideo.addClass("_opened"); 3636 var iframe = productPopupVideo.find('.js-iframe-load'), 3637 iframeSrc = iframe.data("src"); 3638 3639 iframe.attr('src', iframeSrc); 3640 }else{ 3641 if(href){ 3642 $.magnificPopup.close(); 3643 $.magnificPopup.open({ 3644 items: { 3645 src: href 3646 }, 3647 type: 'iframe', 3648 mainClass: 'mfp-fade js-mfp-fade-product-video', 3649 removalDelay: 160, 3650 preloader: false, 3651 fixedContentPos: false, 3652 iframe: { 3653 patterns: { 3654 youtube_short: { 3655 index: 'youtu.be/', 3656 id: 'youtu.be/', 3657 src: '//www.youtube.com/embed/%id%?autoplay=1' 3658 }, 3659 rutube: { 3660 index: 'rutube.ru/', 3661 id: 'video/', 3662 src: 'https://rutube.ru/play/embed/%id%' 3663 }, 3664 vk: { 3665 index: 'vk.com/', 3666 id: function(url) { 3667 const regex = /video(-?\d+)_(-?\d+)/; 3668 const match = url.match(regex); 3669 3670 if (match) { 3671 const oid = match[1]; 3672 const id = match[2]; 3673 return 'oid='+oid+'&id='+id; 3674 } else { 3675 return url; 3676 } 3677 }, 3678 src: 'https://vk.com/video_ext.php?%id%' 3679 }, 3680 } 3681 } 3682 }, 0); 3683 } 3684 } 3685 }); 3686 } 3687}; 3688 3689var postsCarousel = { 3690 carouselWrap: $('.js-posts-carousel-outer'), 3691 init: function (){ 3692 var _this = this; 3693 3694 if(!_this.carouselWrap.length){ 3695 return false; 3696 } 3697 3698 _this.carouselInteraction(); 3699 }, 3700 carouselsInit: function (){ 3701 reviewsCarousel.carouselWrap.each(function (){ 3702 var $this = $(this); 3703 3704 reviewsCarousel.carousel($this); 3705 }); 3706 }, 3707 carouselInteraction: function (){ 3708 var _this = this, 3709 carouselNav = $('.js-init-interaction'); 3710 3711 carouselNav.on("click", function (){ 3712 var carousel = $(this).closest('.js-posts-carousel-outer'); 3713 3714 _this.carousel(carousel, $(this).data("index")); 3715 }); 3716 3717 if(touch.isTouchDevice()){ 3718 $('.js-posts-carousel').each(function (){ 3719 var $list = $(this); 3720 3721 $list.hammer().on("swipeleft swiperight", function(event){
3722 var $listCarousel = $(this).closest(".js-posts-carousel-outer"); 3723 3724 if(event.type == 'swipeleft'){ 3725 _this.carousel($listCarousel, "next"); 3726 }else if(event.type == 'swiperight'){ 3727 _this.carousel($listCarousel, "prev"); 3728 } 3729 }); 3730 }); 3731 } 3732 }, 3733 carousel: function (itemList, goToSlide){ 3734 if(itemList.hasClass("carousel-init") || $(window).width() > 880){ 3735 return false; 3736 } 3737 3738 var carousel = itemList.find('.js-posts-carousel'), 3739 is_lazy = carousel.data('image-lazy'), 3740 is_retina = carousel.data('retina'), 3741 responsive = { 0: { items: 1.18, margin: 0 }, 881: {items: 2, margin: 0}}; 3742 3743 carousel.addClass("owl-carousel").addClass("owl-theme"); 3744 itemList.addClass("carousel-init"); 3745 carousel.owlCarousel({ 3746 loop: true, 3747 nav: false, 3748 dots: true, 3749 mouseDrag: false, 3750 dotsEach: 1, 3751 navText: ['',''], 3752 navElement: "div", 3753 responsive: responsive, 3754 dotsContainer: itemList.find('.js-carousel-dots'), 3755 lazyLoad: is_lazy, 3756 onInitialize: function (event){ 3757 itemList.find(".js-init-interaction").remove(); 3758 }, 3759 onInitialized: function (event){ 3760 owlCarouselAdd.dotsShow($(event.currentTarget).closest(".js-posts-carousel-outer").find(".owl-dot")); 3761 }, 3762 onLoadedLazy: function(event){ 3763 var wrap = $(event.currentTarget); 3764 if (wrap.length && is_retina) { 3765 wrap.find(".owl-item.active .owl-lazy").retina(); 3766 } 3767 }, 3768 onChanged: function (event){ 3769 owlCarouselAdd.dotsShow($(event.currentTarget).closest(".js-posts-carousel-outer").find(".owl-dot")); 3770 }, 3771 }); 3772 if(goToSlide){ 3773 if(goToSlide == "prev") { 3774 carousel.trigger("prev.owl.carousel"); 3775 }else if(goToSlide == "next"){ 3776 carousel.trigger("next.owl.carousel"); 3777 }else{ 3778 carousel.trigger("to.owl.carousel", [parseInt(goToSlide)]); 3779 } 3780 } 3781 } 3782}; 3783 3784var footerDropdownMenu = { 3785 init: function (){ 3786 $('.js-footer-menu-dropdown-head').on("click", function (){ 3787 var $this = $(this), 3788 outerWrap = $this.closest('.js-footer-menu-dropdown'), 3789 linksWrap = outerWrap.find('.js-footer-menu-dropdown-body'); 3790 3791 3792 if(linksWrap.is(':visible')){ 3793 linksWrap.slideUp(); 3794 outerWrap.removeClass("-open"); 3795 }else{ 3796 linksWrap.slideDown(); 3797 outerWrap.addClass("-open"); 3798 } 3799 }); 3800 } 3801} 3802 3803var categorySubcategoriesLinks = { 3804 init: function (){ 3805 var categoriesScroll = $('.js-subcategories-links-scroll'); 3806 3807 if(categoriesScroll.length){ 3808 var categoriesScrollWidth = $('.js-subcategories-links-scroll')[0].scrollWidth, 3809 categoriesScrollWrapWidth = $('.js-subcategories-links-scroll').width(); 3810 3811 if(categoriesScrollWidth > categoriesScrollWrapWidth){ 3812 categoriesScroll.addClass('-sk-scroll-shadow'); 3813 } 3814 3815 categoriesScroll.on("scroll", function (){ 3816 $(this).removeClass('-sk-scroll-shadow'); 3817 }); 3818 } 3819 } 3820} 3821 3822var subscribeForm = { 3823 init: function (){ 3824 var _this = this; 3825 3826 _this.submitForm(); 3827 _this.openCaptcha(); 3828 }, 3829 openCaptcha: function (){ 3830 var emailField = $('.js-subscribe-input'); 3831 3832 emailField.on("focus", function (){ 3833 var captcha = emailField.closest('form').find('.js-subscribe-captcha'); 3834 3835 if(!captcha.find('.wa-invisible-recaptcha').length){ 3836 captcha.addClass("-sk-show"); 3837 } 3838 }); 3839 3840 $(document).click(function(event) { 3841 if(!$(event.target).closest("#mailer-subscribe-form").length) { 3842 $("#mailer-subscribe-form .js-subscribe-captcha").removeClass('-sk-show'); 3843 } 3844 }); 3845 }, 3846 submitForm: function (){ 3847 var _this = this; 3848 $('#mailer-subscribe-form input.charset').val(document.charset || document.characterSet); 3849 $('#mailer-subscribe-form').submit(function() { 3850 var form = $(this), 3851 email_input = form.find('.js-subscribe-input'), 3852 email_submit = form.find('.js-submit-form'), 3853 email_agree = form.find('input[name="agree"]'), 3854 loader = form.find('.js-subscribe-load'), 3855 error = false, 3856 usualCaptcha = form.find('.js-subscribe-captcha'), 3857 usualCaptchaInput = usualCaptcha.find('.wa-captcha-input'), 3858 errorMessage = form.find('.js-subscribe-error'); 3859 3860 email_input.removeClass('error'); 3861 email_agree.closest('.js-subscribe-agree').removeClass('error'); 3862 3863 if(email_agree.length > 0 && !email_agree.is(':checked')){ 3864 email_agree.closest('.js-subscribe-agree').addClass('error'); 3865 error = true; 3866 } 3867 if(!email_input.val()){ 3868 email_input.addClass('error'); 3869 error = true; 3870 }else{ 3871 if(!validateEmail(email_input.val())){ 3872 email_input.addClass('error'); 3873 error = true; 3874 }else{ 3875 if (!usualCaptcha.length){ 3876 email_input.attr('name', 'email'); 3877 } 3878 } 3879 } 3880 if(error === false){ 3881 email_submit.hide(); 3882 loader.show(); 3883 errorMessage.hide(); 3884 errorMessage.find(".js-text-error").remove(); 3885 usualCaptchaInput.removeClass("error"); 3886 3887 var url = form.attr("action"); 3888 if (url.substr(0,4) === "http") { 3889 url = url.replace("http:", "").replace("https:", ""); 3890 } 3891 3892 $.post(url, form.serialize(), function (response) { 3893 if (!usualCaptcha.length){ 3894 email_input.attr('name', 'username'); 3895 } 3896 3897 if(response.status == "ok"){ 3898 3899 if(response.data.html){ 3900 $('.js-subscribe-success').html(response.data.html); 3901 } 3902 $('.js-subscribe-success').show(); 3903 errorMessage.hide(); 3904 errorMessage.find(".js-text-error").remove(); 3905 usualCaptchaInput.removeClass("error"); 3906 email_input.val(""); 3907 }else{ 3908 if(response.errors){ 3909 var errorText = Object.entries(response.errors).toString(); 3910 errorText = errorText.replace(","," "); 3911
3912 if(errorText.indexOf("captcha") !== -1 && usualCaptchaInput.length){ 3913 usualCaptchaInput.addClass("error"); 3914 usualCaptcha.addClass("show"); 3915 } 3916 errorMessage.append("<span class='js-text-error'>: "+errorText+"</span>"); 3917 } 3918 errorMessage.show(); 3919 } 3920 email_submit.show(); 3921 loader.hide(); 3922 }); 3923 }else{ 3924 if (!usualCaptcha.length){ 3925 email_input.attr('name', 'username'); 3926 } 3927 } 3928 return false; 3929 }) 3930 } 3931}; 3932 3933var cart = { 3934 init: function (){ 3935 var _this = this; 3936 3937 _this.addToCart(); 3938 _this.cartDialog(); 3939 }, 3940 cartDialog: function(){ 3941 var _this = this; 3942 3943 $('body').on( "click", ".js-product-card-dialog", function (event){ 3944 event.preventDefault(); 3945 3946 var $this = $(this), 3947 isReloadCart = $this.closest("[data-reload-cart='true']").length, 3948 href = $(this).data('href'); 3949 3950 $.magnificPopup.open({ 3951 items: { 3952 src: href 3953 }, 3954 type: 'ajax', 3955 callbacks: { 3956 parseAjax: function(mfpResponse) { 3957 if($(mfpResponse.data).find(".js-product-popup-outer").length){ 3958 mfpResponse.data = $(mfpResponse.data).find(".js-product-popup"); 3959 }else{ 3960 mfpResponse.data = $(mfpResponse.data); 3961 } 3962 }, 3963 ajaxContentAdded: function() { 3964 /* for cart page crossselling */ 3965 if(isReloadCart){ 3966 this.content.attr("data-reload-cart", true); 3967 } 3968 3969 var productCard = this.content.find('.js-product'); 3970 if(productCard.length && productCard.data('id')){ 3971 productListUser.viewed(productCard.data('id')); 3972 } 3973 3974 if (typeof $.autobadgeFrontend !== 'undefined') { 3975 $.autobadgeFrontend.reinit(); 3976 } 3977 3978 if(!touch.isTouchDevice()){ 3979 ProductGallery.productImageZoom(this.content.find(".js-product-gallery-el").first()); 3980 } 3981 ProductGallery.previewsCarouselInit(); 3982 3983 this.content.find('.js-product-main-content-scroll').scrollbar(); 3984 ProductGallery.swipeLargePhoto(this.content.find('.js-product-gallery')); 3985 }, 3986 open: function() { 3987 3988 $.magnificPopup.instance._onFocusIn = function(e) { 3989 if( $(e.target).closest( '#storequickorder' ) ) { 3990 return true; 3991 } 3992 $.magnificPopup.proto._onFocusIn.call(this,e); 3993 }; 3994 } 3995 } 3996 }, 0); 3997 }); 3998 }, 3999 addToCart: function (){ 4000 var _this = this; 4001 4002 $('body').on('submit', '.js-add-to-cart', function (event){ 4003 event.preventDefault(); 4004 var $this = $(this), 4005 skuId = $this.data("sku-id"), 4006 data = $this.serialize(), 4007 dataObject = $this.serializeObject(), 4008 action = $this.attr('action'), 4009 button = $this.find('.js-submit-form'), 4010 buttonAdded = $this.find('.js-button-added'), 4011 quantityWrap = $this.find('.js-quantity-section, .js-product-list-quantity-section'); 4012 4013 if(quantityWrap.length || buttonAdded.length){ 4014 button.addClass("-sk-hide"); 4015 quantityWrap.removeClass('-sk-hide').addClass("-sk-loading"); 4016 buttonAdded.removeClass('-sk-hide'); 4017 } 4018 button.addClass("-sk-loading"); 4019 $.post(action + '?html=1', data, function (response) { 4020 quantityWrap.removeClass("-sk-loading"); 4021 button.removeClass("-sk-loading"); 4022 4023 if (response.status == 'ok') { 4024 if(skuId){ 4025 var allSkuProducts = $('.js-product[data-sku-id="'+ skuId +'"]'), 4026 alladded2CartBtns = allSkuProducts.find('.js-submit-form, .js-product-card-dialog'); 4027 4028 alladded2CartBtns.addClass("added"); 4029 } 4030 4031 if(quantityWrap.length){ 4032 if(typeof response.data.item_id !== 'undefined'){ 4033 quantityWrap.attr("data-cart-item-id", response.data.item_id); 4034 activeQuantityField.active(quantityWrap);
4035 quantityWrap.data("controller").cart_item_id = response.data.item_id; 4036 4037 if(typeof alladded2CartBtns != undefined && alladded2CartBtns.length){ 4038 alladded2CartBtns.each(function (){ 4039 var cartBtn = $(this), 4040 thisProduct = cartBtn.closest('.js-product'), 4041 thisCartAddedBtn = thisProduct.find('.js-button-added'), 4042 thisQuantity = thisProduct.find(".js-quantity-section, .js-product-list-quantity-section"); 4043 4044 if(thisQuantity.length){ 4045 thisQuantity.attr("data-cart-item-id", response.data.item_id); 4046 activeQuantityField.active(thisQuantity); 4047 thisQuantity.data("controller").cart_item_id = response.data.item_id; 4048 4049 cartBtn.addClass("-sk-hide"); 4050 thisQuantity.removeClass('-sk-hide'); 4051 } 4052 4053 thisCartAddedBtn.removeClass('-sk-hide'); 4054 }); 4055 } 4056 }else{ 4057 button.removeClass("-sk-hide"); 4058 quantityWrap.addClass('-sk-hide'); 4059 buttonAdded.addClass('-sk-hide'); 4060 } 4061 } 4062 _this.updatePreviewCart(response.data.count, response.data.total); 4063 4064 4065 if(skuId && typeof dataObject.quantity !== 'undefined' && typeof response.data.item_id !== 'undefined'){ 4066 _this.updateCartItems($this.data("sku-id"), response.data.item_id, dataObject.quantity); 4067 } 4068 4069 /* 4070 var popupProductSelectOptions = $('.js-product-popup-options'); 4071 if(popupProductSelectOptions.length > 0){ 4072 $.magnificPopup.close(); 4073 } 4074 */ 4075 4076 var alertMsg = globalThemeSettings.cartAddedAlertMessage; 4077 popupMiniMessage.show(alertMsg.msg, null, alertMsg.btn, alertMsg.url); 4078 4079 4080 /* for cart page crossselling */ 4081 if($this.closest("[data-reload-cart='true']").length){ 4082 location.reload(); 4083 } 4084 } else if (response.status == 'fail') { 4085 if(quantityWrap.length){ 4086 button.removeClass("-sk-hide"); 4087 quantityWrap.addClass('-sk-hide'); 4088 buttonAdded.addClass('-sk-hide'); 4089 } 4090 popupMiniMessage.show(response.errors, 'error'); 4091 } 4092 }, "json"); 4093 }); 4094 }, 4095 updatePreviewCart: function (count, total){ 4096 var _this = this, 4097 cartPreview = $('.js-cart-preview'), 4098 cartCount = $('.js-cart-preview-count'), 4099 cartTotal = $('.js-cart-preview-total'); 4100 4101 cartTotal.html(total); 4102 cartCount.html(count); 4103 if(count){ 4104 cartCount.removeClass('-sk-empty'); 4105 cartPreview.removeClass('-sk-empty'); 4106 }else{ 4107 cartCount.addClass('-sk-empty'); 4108 cartPreview.addClass('-sk-empty'); 4109 } 4110 4111 if(cartPreview.find(".js-products-popup").length){ 4112 cartPreview.find(".js-products-popup").html(""); 4113 } 4114 }, 4115 updateCartItems: function (sku_id, cart_item_id, quantity){ 4116 var cart_items = globalThemeSettings.cartItems; 4117 4118 if(!sku_id && cart_items){ 4119 $.each(cart_items, function(index, value) { 4120 if(value && value.id == cart_item_id){ 4121 sku_id = index; 4122 } 4123 }); 4124 } 4125 4126 if(sku_id){ 4127 if(quantity == 0){ 4128 delete cart_items[sku_id]; 4129 }else if(typeof cart_items[sku_id] != 'undefined'){ 4130 cart_items[sku_id].quantity = quantity; 4131 }else{ 4132 cart_items[sku_id] = {id: cart_item_id, quantity: quantity}; 4133 } 4134 4135 globalThemeSettings.cartItems = cart_items; 4136 } 4137 4138 } 4139}; 4140 4141var popupMiniMessage = { 4142 init: function (){ 4143 var _this = this; 4144 4145 _this.close(); 4146 }, 4147 show: function (text, type, btnTitle, btnUrl) { 4148 if(text){ 4149 if(!type) type = "info"; 4150 4151 var messageHtml = '<div class="js-popup-mini-messages-item popup-mini-messages__item -sk-hide -sk-'+ type +'">' + text; 4152 4153 if(btnTitle && btnUrl){ 4154 messageHtml += '<a class="popup-mini-messages__btn button small" href="' + btnUrl + '">' + btnTitle + '</a>'; 4155 } 4156 4157 messageHtml += '<span class="js-popup-mini-messages-close popup-mini-messages__close far fa-times"></span>'; 4158 messageHtml += '</div>'; 4159 4160 if(!$('.js-popup-mini-messages').length){ 4161 $('body').append('<div class="js-popup-mini-messages popup-mini-messages"></div>'); 4162 } 4163 4164 var wrap = $('.js-popup-mini-messages'); 4165 wrap.append(messageHtml); 4166 4167 var message = wrap.find('.js-popup-mini-messages-item').last(); 4168 4169 message.css("right", '100%'); 4170 message.removeClass('-sk-hide'); 4171 message.animate({ 4172 right : 0 4173 }, 200); 4174 4175 setTimeout(function (){ 4176 message.animate({ 4177 left : "100%" 4178 }, 200, function (){ 4179 message.remove(); 4180 }); 4181 }, 5000); 4182 } 4183 }, 4184 close: function (){ 4185 $('body').on("click", '.js-popup-mini-messages-close', function (){ 4186 var $close = $(this),
4187 $message = $close.closest(".js-popup-mini-messages-item"); 4188 4189 $message.animate({ 4190 left : "100%" 4191 }, 100, function (){ 4192 $message.remove(); 4193 }); 4194 }); 4195 } 4196}; 4197 4198var productListUser = { 4199 init: function() { 4200 var _this = this; 4201 4202 _this.compare(); 4203 _this.favorites(); 4204 _this.clear(); 4205 _this.viewed(); 4206 }, 4207 viewed: function(){ 4208 var _this = this, 4209 productPageCartForm = $('#cart-form'); 4210 4211 if(productPageCartForm.length && productPageCartForm.data('id')){ 4212 _this.add('viewed_list', productPageCartForm.data('id'), globalThemeSettings.countViewed); 4213 } 4214 }, 4215 compare: function(){ 4216 var _this = this; 4217 4218 _this.list( 4219 'shop_compare', 4220 $(".js-preview-compare"), 4221 $(".js-compare-count"), 4222 globalThemeSettings.compareAddedAlertMessage, 4223 '.js-add-to-compare' 4224 ); 4225 }, 4226 favorites: function(){ 4227 var _this = this; 4228 4229 _this.list( 4230 'favorites_list', 4231 $(".js-preview-favorite"), 4232 $(".js-favorite-count"), 4233 globalThemeSettings.favoriteAddedAlertMessage, 4234 '.js-add-to-favorites', 4235 null, 4236 globalThemeSettings.countFavorites 4237 ); 4238 }, 4239 list: function (listName, wrapPreview, wrapCount, alertMessage, btn, callback, limit){ 4240 var _this = this; 4241 4242 $("body").on('click', btn, function (event) { 4243 event.preventDefault(); 4244 var $this = $(this), 4245 countInList = 0, 4246 productId = $(this).data('product'), 4247 isAdd = !$this.hasClass('selected'); 4248 4249 $(btn + "[data-product='"+productId+"']").toggleClass('selected'); 4250 if (isAdd) { 4251 countInList = _this.add(listName, productId, limit); 4252 4253 popupMiniMessage.show(alertMessage.msg, null, alertMessage.btn, alertMessage.url); 4254 } else { 4255 countInList = _this.remove(listName, productId); 4256 4257 } 4258 wrapCount.html(countInList); 4259 if(countInList > 0){ 4260 wrapPreview.removeClass('sk-empty'); 4261 }else{ 4262 wrapPreview.addClass('sk-empty'); 4263 } 4264 4265 var headerPopupWrap = wrapCount.closest('.js-popup-products-link').find('.js-products-popup'); 4266 if(headerPopupWrap.length){ 4267 headerPopupWrap.html(""); 4268 } 4269 4270 if(callback){ 4271 callback({that: $this, productId: productId, isAdded: isAdd}); 4272 } 4273 }); 4274 }, 4275 add: function(listName, productId, limit){ 4276 var _this = this, list = $.cookie(listName), listArr = []; 4277 4278 if (list && list != "null" && list != "0" ) { 4279 list = list.replace(",null", ""); 4280 list = list.replace(",0", ""); 4281 var listArr = list.split(','); 4282 4283 var i = $.inArray(productId + '', listArr); 4284 if (i != -1) { 4285 listArr.splice(i, 1); 4286 } 4287 } 4288 listArr.unshift(productId); 4289 4290 if(limit){ 4291 listArr.splice(limit); 4292 } 4293 4294 _this.save(listArr, listName); 4295 4296 return listArr.length; 4297 }, 4298 remove: function(listName, productId){ 4299 var _this = this, list = $.cookie(listName); 4300 4301 if (list) { 4302 list = list.split(','); 4303 } else { 4304 list = []; 4305 } 4306 var i = $.inArray(productId + '', list); 4307 if (i != -1) { 4308 list.splice(i, 1); 4309 } 4310 4311 _this.save(list, listName); 4312 4313 return list.length; 4314 }, 4315 get: function(listName){ 4316 return $.cookie(listName); 4317 }, 4318 save: function(list, listName){ 4319 if (list.length > 0) { 4320 for(var i = 0; i < list.length; i ++){ 4321 if (!parseInt(list[i])){ 4322 list.splice(i, 1); 4323 } 4324 } 4325 } 4326 if (list.length > 0) { 4327 $.cookie(listName, list.join(','), { expires: 90, path: '/'}); 4328 } else { 4329 $.cookie(listName, null, {path: '/'}); 4330 } 4331 }, 4332 clear: function (){ 4333 var _this = this, btn = $('.js-clear-user-list'); 4334 4335 btn.on("click", function (){ 4336 var $this = $(this), 4337 list = [], 4338 listName = $this.data("list") + "_list"; 4339 4340 _this.save(list, listName); 4341 location.reload(); 4342 }); 4343 } 4344}; 4345 4346var pagesTree = { 4347 init: function (){ 4348 var _this = this, 4349 treeCats = $('.js-pages-tree'); 4350 4351 if(!treeCats.length){ 4352 return false; 4353 } 4354 4355 _this.open(); 4356 4357 var currentCat = treeCats.find('.selected'), 4358 outWrap = currentCat.parents(".js-subpages"); 4359 4360 outWrap.removeClass('hide'); 4361 outWrap.each(function(){ 4362 $(this).parent().find('.js-subpages-open').first().addClass('selected'); 4363 }); 4364 }, 4365 open: function (){ 4366 var _this = this; 4367 4368 var openBtn = $('.js-subpages-open'); 4369 4370 openBtn.click(function(){ 4371 var $this = $(this), subs = $($this.parent().find('.js-subpages')[0]); 4372 4373 if(!subs.is(':visible')){ 4374 subs.slideDown(); 4375 $this.addClass('selected'); 4376 }else{ 4377 subs.slideUp(); 4378 $this.removeClass('selected'); 4379 } 4380 }); 4381 }, 4382 4383}; 4384 4385function Product(form, options) { 4386 this.form = $(form); 4387 this.add2cart = this.form.find(".add2cart"); 4388 this.skFastButton = this.form.find(".js-sk-button-fastorder"); 4389 this.fastButton = this.form.find(".js-button-fastorder"); 4390 this.discount = this.form.find(".js-product-discount"); 4391 this.savedWrap = this.form.find(".js-product-saving"); 4392 this.bonusesCountWrap = this.form.find(".js-product-bonus-count"); 4393 this.button = this.add2cart.find("input[type=submit], .js-submit-form"); 4394 this.buttonAdded = this.add2cart.find(".js-button-added"); 4395 this.isSkuUrl = this.form.data("sku-url"); 4396 4397 this.$productSkusNames = this.form.find(".js-product-skus-names"); 4398 this.$price = this.form.find(".js-product-price"); 4399 this.$product_total = this.form.find(".js-product-card-total"); 4400 this.$comparePrice = this.form.find(".js-compare-price"); 4401 this.$price_total = this.form.find(".js-product-price-total"); 4402 this.$base_price = this.form.find(".js-product-base-price"); 4403 this.$stock_base_ratio = this.form.find(".js-stock-base-ratio"); 4404 this.$stock_base_ratio_total = this.form.find(".js-stock-base-ratio-total"); 4405 this.sku_id = options.product.sku_id; 4406 this.sku = options.product.skus[this.sku_id]; 4407 this.skus = options.product.skus; 4408 4409 this.$quantity_field = this.form.find(".js-quantity-field"); 4410 if(this.$quantity_field.length){
4411 this.quantity_controller = this.$quantity_field.data("controller"); 4412 this.$quantity_section = this.quantity_controller.$wrapper; 4413 } 4414 4415 // ÐгноÑиÑоваÑÑ Ð¾Ð³ÑаниÑÐµÐ½Ð¸Ñ Ñкладов 4416 this.ignore_stock_count = options["ignore_stock_count"]; 4417 4418 // ÐаÑÑÑойки дÑобнÑÑ 4419 this.fractional_config = formatFractionalConfig(options["fractional_config"]); 4420 // ÐаÑÑив Ñ ÐµÐ´Ð¸Ð½Ð¸Ñами измеÑÐµÐ½Ð¸Ñ 4421 this.units = options["units"]; 4422 4423 function formatFractionalConfig(config) { 4424 if (config) { 4425 config.frac_enabled = (config.frac_enabled === "1"); 4426 config.stock_units_enabled = (config.stock_units_enabled === "1"); 4427 config.base_units_enabled = (config.base_units_enabled === "1"); 4428 } else { 4429 config = {}; 4430 } 4431 4432 return config; 4433 } 4434 4435 this.featurestipsPlugin(); 4436 4437 for (var k in options) { 4438 this[k] = options[k]; 4439 } 4440 var self = this; 4441 // add to cart block: services 4442 this.form.find(".services input[type=checkbox]").change(function () { 4443 var obj = $('select[name="service_variant[' + $(this).val() + ']"]'); 4444 if (obj.length) { 4445 if ($(this).is(':checked')) { 4446 obj.removeAttr('disabled'); 4447 } else { 4448 obj.attr('disabled', 'disabled'); 4449 } 4450 } 4451 self.updatePrice(); 4452 }); 4453 4454 this.form.find(".services .service-variants").on('change', function () { 4455 self.updatePrice(); 4456 }); 4457 4458 this.form.find('.inline-select a').click(function () { 4459 var d = $(this).closest('.inline-select'); 4460 d.find('a.selected').removeClass('selected'); 4461 $(this).addClass('selected'); 4462 d.find('.sku-feature').val($(this).data('value')).change(); 4463 }); 4464 4465 this.form.find(".skus input[type=radio], .skus select").change(function () { 4466 var image_id = null, 4467 is_disabled = false, 4468 sku_id = $(this).val(); 4469 4470 var sku = (self.skus[sku_id] ? self.skus[sku_id] : null); 4471 if (!sku) { 4472 console.log("SKU ERROR"); 4473 return false; 4474 } 4475 4476 self.sku_id = sku_id; 4477 self.sku = sku; 4478 4479 self.updateProductSkusNames(self.sku); 4480 4481 if(typeof self.quantity_controller != 'undefined'){ 4482 self.quantity_controller.update({ 4483 step: (globalThemeSettings.isPremium) ? self.sku.order_count_step: 1, 4484 min: (globalThemeSettings.isPremium) ? self.sku.order_count_min : 1, 4485 max: (!self.ignore_stock_count && self.sku.count > 0 && globalThemeSettings.isPremium ? self.sku.count : 0), 4486 stock_base_ratio: self.sku.stock_base_ratio 4487 }); 4488 } 4489 4490 if($(this).attr("type") == "radio"){ 4491 image_id = $(this).data('image-id'); 4492 is_disabled = $(this).data('disabled'); 4493 }else{ 4494 image_id = $(this).find('option:selected').data('image-id'); 4495 is_disabled = $(this).find('option:selected').data('disabled'); 4496 } 4497 4498 if (is_disabled) { 4499 self.button.attr('disabled', 'disabled').addClass('disabled'); 4500 self.skFastButton.addClass('disabled'); 4501 self.fastButton.addClass('disabled'); 4502 } else { 4503 self.button.removeAttr('disabled').removeClass('disabled'); 4504 self.skFastButton.removeClass('disabled'); 4505 self.fastButton.removeClass('disabled'); 4506 } 4507 4508 if (typeof image_id !== 'undefined'){ 4509 self.selectImage(image_id); 4510 } 4511 self.updateSkuServices(sku_id); 4512 self.updateSkuProductCode(sku_id); 4513 self.updateSkuStock(sku_id); 4514 self.updatePrice(); 4515 if (self.isSkuUrl){ 4516 self.updateURLSku(sku_id); 4517 } 4518 self.form.attr("data-sku-id", sku.id); 4519 self.form.data("sku-id", sku.id); 4520 self.checkInCart(sku_id); 4521 self.updateFeaturesList(sku_id); 4522 }); 4523 4524 if($('.skus input[type=radio]').length) { 4525 var $initial_cb = this.form.find(".skus input[type=radio]:checked:not(:disabled)"); 4526 if (!$initial_cb.length) { 4527 var first_sku = this.form.find(".skus input[type=radio]:not(:disabled):first"); 4528 if(first_sku.length){ 4529 $initial_cb = this.form.find(".skus input[type=radio]:not(:disabled):first").click().prop('checked', true); 4530 this.form.find(".js-radio-styler").removeClass("checked"); 4531 first_sku.closest('.js-radio-styler').addClass("checked"); 4532 first_sku.closest('.js-sku-dropdown-item').addClass("selected").siblings().removeClass("selected"); 4533 } 4534 } 4535 }else if($('.skus option').length){ 4536 var $initial_cb = this.form.find(".skus option:selected:not(:disabled)"); 4537 if (!$initial_cb.length) { 4538 $initial_cb = this.form.find(".skus option:not(:disabled):first").click().prop('selected', true); 4539 } 4540 } 4541 4542 if(typeof $initial_cb !== 'undefined' && $initial_cb.length && $initial_cb.data('image-id')) { 4543 $initial_cb.change(); 4544 4545 if ($initial_cb.length && $initial_cb.data('image-id')) { 4546 self.selectImage($initial_cb.data("image-id")); 4547 } 4548 } 4549 4550 this.form.find(".sku-feature").change(function () { 4551 var key = ""; 4552 self.form.find(".sku-feature").each(function () { 4553 key += $(this).data('feature-id') + ':' + $(this).val() + ';'; 4554 }); 4555 var sku = self.features[key]; 4556 if (sku) { 4557 self.sku_id = sku_id = sku.id; 4558 self.sku = self.skus[self.sku_id]; 4559 4560 self.updateProductSkusNames(self.sku); 4561 4562 if(typeof self.quantity_controller != 'undefined') { 4563 self.quantity_controller.update({ 4564 step: (globalThemeSettings.isPremium) ? self.sku.order_count_step: 1, 4565 min: (globalThemeSettings.isPremium) ? self.sku.order_count_min : 1, 4566 max: (!self.ignore_stock_count && self.sku.count > 0 && globalThemeSettings.isPremium ? self.sku.count : 0), 4567 stock_base_ratio: self.sku.stock_base_ratio 4568 }); 4569 } 4570 4571 if(sku.image_id){ 4572 self.selectImage(sku.image_id); 4573 } 4574 self.updateSkuServices(sku.id); 4575 self.updateSkuProductCode(sku.id); 4576 self.updateSkuStock(sku.id); 4577 if (sku.available) { 4578 self.button.removeAttr('disabled').removeClass('disabled'); 4579 self.skFastButton.removeClass('disabled'); 4580 self.fastButton.removeClass('disabled'); 4581 } else { 4582 self.form.find("div.stocks div").hide(); 4583 self.form.find(".sku-no-stock").show(); 4584 self.button.attr('disabled', 'disabled').addClass('disabled'); 4585 self.skFastButton.addClass('disabled'); 4586 self.fastButton.addClass('disabled'); 4587 } 4588 self.add2cart.find(".price").data('price', sku.price); 4589 self.updatePrice(sku.price, sku.compare_price); 4590 if (self.isSkuUrl){ 4591 self.updateURLSku(sku.id); 4592 } 4593 self.form.attr("data-sku-id", sku.id); 4594 self.form.data("sku-id", sku.id); 4595 self.checkInCart(sku.id); 4596 self.updateFeaturesList(sku.id); 4597 } else { 4598 self.form.find("div.stocks div").hide(); 4599 self.form.find(".sku-no-stock").show(); 4600 self.button.attr('disabled', 'disabled').addClass('disabled'); 4601 self.skFastButton.addClass('disabled'); 4602 self.fastButton.addClass('disabled'); 4603 self.form.find(".compare-at-price").addClass("display-none"); 4604 self.form.find(".price").empty(); 4605 self.updateProductSkusNames(null); 4606 } 4607 if(globalThemeSettings.isProductOptionsCrossoutNotAvailable){ 4608 self.checkFeaturesInStock(); 4609 } 4610 });
4611 this.form.find(".sku-feature:first").change(); 4612 4613 if (!this.form.find('.skus input[type="radio"]:checked').length) { 4614 this.form.find('.skus input[type="radio"]:enabled:first').attr('checked', 'checked'); 4615 } 4616 if (!this.form.find(".skus option:selected").length) { 4617 this.form.find(".skus option:enabled:first").attr('selected', 'selected'); 4618 } 4619 4620 if(typeof this.$quantity_section != 'undefined'){ 4621 this.$quantity_section.on("quantity.changed", function (){ 4622 self.updatePrice(); 4623 }) 4624 } 4625 4626 self.showAllSkus(); 4627 self.showAllStocks(); 4628} 4629 4630Product.prototype.checkFeaturesInStock = function (){ 4631 var self = this, 4632 features = self.form.find(".sku-feature"), 4633 featuresOptions = self.form.find('.inline-select a'); 4634 4635 featuresOptions.removeClass("-not-available"); 4636 featuresOptions.each(function (){ 4637 var option = $(this), 4638 optionValue = option.data('value'), 4639 optionFeatureId = option.closest('.inline-select').find('.sku-feature').data("feature-id"), 4640 optionKey = optionFeatureId + ":" + optionValue + ";"; 4641 4642 var skuKey = "", sku = null; 4643 features.each(function () { 4644 var feature = $(this), 4645 featureId = feature.data("feature-id"); 4646 4647 if(optionFeatureId == featureId){ 4648 skuKey += optionKey; 4649 4650 }else{ 4651 var selectedOption = feature.closest('.inline-select').find('a.selected'), 4652 selectedOptionId = selectedOption.data("value"); 4653 4654 skuKey += featureId + ":" + selectedOptionId + ";"; 4655 } 4656 }); 4657 4658 if(skuKey && self.features[skuKey]){ 4659 sku = self.features[skuKey]; 4660 4661 if(!sku.available){ 4662 option.addClass("-not-available"); 4663 }else{ 4664 option.removeClass("-not-available"); 4665 } 4666 } 4667 }); 4668}; 4669 4670Product.prototype.selectImage = function(image_id){ 4671 if (typeof image_id !== 'undefined'){ 4672 var previewImage = $(this).closest('.js-product').find("#product-image-" + image_id); 4673 4674 if(previewImage.length) { 4675 ProductGallery.previewSelect(previewImage, true); 4676 }else{ 4677 var mainImage = $('.js-product-gallery-item[data-id="'+image_id+'"]'); 4678 if(mainImage.length){ 4679 var position = mainImage.data('position'), 4680 mainGallery = mainImage.closest(".js-product-gallery"); 4681 4682 ProductGallery.mainCarousel(mainGallery, position); 4683 } 4684 } 4685 } 4686} 4687 4688Product.prototype.getEscapedText = function( bad_string ) { 4689 return $("<div>").text( bad_string ).html(); 4690}; 4691 4692Product.prototype.currencyFormat = function (number, no_html) { 4693 // Format a number with grouped thousands 4694 // 4695 // + original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com) 4696 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 4697 // + bugfix by: Michael White (http://crestidg.com) 4698 4699 var i, j, kw, kd, km; 4700 var decimals = this.currency.frac_digits; 4701 var dec_point = this.currency.decimal_point; 4702 var thousands_sep = this.currency.thousands_sep; 4703 4704 // input sanitation & defaults 4705 if( isNaN(decimals = Math.abs(decimals)) ){ 4706 decimals = 2; 4707 } 4708 if( dec_point == undefined ){ 4709 dec_point = ","; 4710 } 4711 if( thousands_sep == undefined ){ 4712 thousands_sep = "."; 4713 } 4714 4715 i = parseInt(number = (+number || 0).toFixed(decimals)) + ""; 4716 4717 if( (j = i.length) > 3 ){ 4718 j = j % 3; 4719 } else{ 4720 j = 0; 4721 } 4722 4723 km = (j ? i.substr(0, j) + thousands_sep : ""); 4724 kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep); 4725 //kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).slice(2) : ""); 4726 kd = (decimals && (number - i) ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : ""); 4727 4728 4729 var number = km + kw + kd; 4730 var s = no_html ? this.currency.sign : this.currency.sign_html; 4731 if (!this.currency.sign_position) { 4732 return s + this.currency.sign_delim + number; 4733 } else { 4734 return number + this.currency.sign_delim + s; 4735 } 4736}; 4737 4738Product.prototype.updateSkuProductCode = function (sku_id) { 4739 if(this.form.find(".js-product-code").length > 0){ 4740 this.form.find(".js-product-code").hide(); 4741 this.form.find(".sku-" + sku_id + "-product-code").show(); 4742 } 4743}; 4744 4745Product.prototype.updateSkuStock = function (sku_id) { 4746 this.form.find("div.stocks div").hide(); 4747 var stock_wrap = this.form.find(".sku-" + sku_id + "-stock"); 4748 stock_wrap.show(); 4749 4750 var cart_title = this.button.data('cart-title'), 4751 cart_preload_title = this.button.data('cart-preorder-title'); 4752 4753 if(cart_title && cart_preload_title){ 4754 var html_icon = null; 4755 if(this.button.find('.js-icon').length){ 4756 var html_icon = this.button.find('.js-icon').outerHTML(); 4757 } 4758 4759 if(stock_wrap.find('.js-stock-preorder').length){ 4760 this.button.html(html_icon + cart_preload_title); 4761 }else{ 4762 this.button.html(html_icon + cart_title); 4763 } 4764 } 4765}; 4766 4767Product.prototype.serviceVariantHtml= function (id, name, price) { 4768 var that = this, 4769 price_string = Price.formatPrice(price, { currency: that.currency, html: false }); 4770 4771 return $('<option data-price="' + price + '" value="' + id + '"></option>').text(name + ' (+' + price_string + ')'); 4772}; 4773 4774Product.prototype.updateSkuServices = function (sku_id) { 4775 if(this.form.find(".js-product-code").length > 0){ 4776 this.form.find(".js-product-code").hide(); 4777 this.form.find(".sku-" + sku_id + "-product-code").show(); 4778 } 4779 4780 this.form.find("div.stocks div").hide(); 4781 this.form.find(".sku-" + sku_id + "-stock").show(); 4782 for (var service_id in this.services[sku_id]) { 4783 var v = this.services[sku_id][service_id]; 4784 4785 if (v === false) { 4786 this.form.find(".service-" + service_id).hide().find('input,select').attr('disabled', 'disabled').removeAttr('checked'); 4787 this.form.find(".service-" + service_id).find(".js-checkbox-styler, label").addClass("disabled"); 4788 } else { 4789 this.form.find(".service-" + service_id).show().find('input').removeAttr('disabled'); 4790 this.form.find(".service-" + service_id).find(".js-checkbox-styler, label").removeClass("disabled"); 4791 4792 if (typeof (v) == 'string' || typeof (v) == 'number') { 4793 var price_string = Price.formatPrice(v, { currency: this.currency, html: false}); 4794 4795 this.form.find(".service-" + service_id + ' .service-price').html(price_string); 4796 this.form.find(".service-" + service_id + ' input').data('price', v); 4797 } else { 4798 var select = this.form.find(".service-" + service_id + ' .service-variants'); 4799 var selected_variant_id = select.val(); 4800 for (var variant_id in v) { 4801 var obj = select.find('option[value=' + variant_id + ']'); 4802 if (v[variant_id] === false) { 4803 obj.hide(); 4804 obj.attr('disabled', 'disabled'); 4805 if (obj.attr('value') == selected_variant_id) { 4806 selected_variant_id = false; 4807 } 4808 } else { 4809 if (!selected_variant_id) { 4810 selected_variant_id = variant_id; 4811 } 4812 obj.removeAttr('disabled'); 4813 obj.replaceWith(this.serviceVariantHtml(variant_id, v[variant_id][0], v[variant_id][1])); 4814 } 4815 } 4816 if(!selected_variant_id){ 4817 selected_variant_id = this.form.find(".service-" + service_id + ' .service-variants').find("option:not(.disable):first").attr("value"); 4818 } 4819 this.form.find(".service-" + service_id + ' .service-variants').val(selected_variant_id).trigger('refresh'); 4820 } 4821 } 4822 } 4823}; 4824 4825Product.prototype.updatePrice = function () { 4826 var self = this, 4827 price = self.sku["price"], 4828 compare_price = self.sku["compare_price"], 4829 stock_base_ratio = self.sku.stock_base_ratio, 4830 stock_unit_name, 4831 base_unit_name; 4832 4833 price = (parseFloat(price) >= 0 ? parseFloat(price) : 0); 4834 compare_price = (parseFloat(compare_price) > 0 ? parseFloat(compare_price) : null); 4835 stock_base_ratio = (parseFloat(stock_base_ratio) > 0 ? parseFloat(stock_base_ratio) : null); 4836 4837 if (self.fractional_config && typeof self.fractional_config["stock_units_enabled"] !== "undefined" && self.fractional_config["stock_units_enabled"]) { 4838 if (self.product.stock_unit_id && self.units[self.product.stock_unit_id]) { 4839 stock_unit_name = self.units[self.product.stock_unit_id].name_short; 4840 } 4841 } 4842 4843 if (self.fractional_config && typeof self.fractional_config["base_units_enabled"] !== "undefined" && self.fractional_config["base_units_enabled"]) { 4844 if (self.product.base_unit_id && (self.product.stock_unit_id !== self.product.base_unit_id) && self.units[self.product.base_unit_id] && stock_base_ratio) { 4845 base_unit_name = self.units[self.product.base_unit_id].name_short; 4846 } 4847 } 4848 4849 function formatNumber(number) { 4850 var result = number; 4851 if (typeof number !== "string") { return result; } 4852 4853 var parts = number.split("."); 4854 if (parts.length === 2) { 4855 var tail = parts[1], 4856 result2 = [], 4857 result3 = [parts[0]]; 4858 4859 if (tail.length) { 4860 for (var i = 0; i < tail.length; i++) { 4861 var letter = tail[tail.length - (i+1)]; 4862 if (letter !== "0" || result2.length) { 4863 result2.push(letter); 4864 } 4865 } 4866 if (result2.length) { 4867 result3.push(result2.reverse().join("")); 4868 } 4869 } 4870 result = result3.join("."); 4871 } 4872 return result; 4873 } 4874 4875 var services_price = self.getServicePrice(), 4876 price_sum = (this.$price_total.length) ? price : (price + services_price), 4877 compare_sum = (compare_price); 4878 4879 var price_string = Price.formatPrice(price_sum, { currency: self.currency, unit: stock_unit_name }); 4880 self.$price.html(price_string); 4881 4882 if (compare_price > price && price > 0) { 4883 var compare_price_string = Price.formatPrice(compare_sum, { currency: self.currency, unit: stock_unit_name }); 4884 self.$comparePrice.html(compare_price_string).removeClass("display-none"); 4885 } else { 4886 self.$comparePrice.addClass("display-none"); 4887 } 4888 4889 self.updateDiscount(price,compare_price); 4890 self.updateSaved(price,compare_price); 4891 self.updateTotalPrice(price); 4892 self.updateBonuses(price); 4893 4894 if (self.$base_price.length) { 4895 if (base_unit_name) { 4896 var base_sub = (price_sum/stock_base_ratio), 4897 base_price_string = Price.formatPrice(base_sub, { currency: self.currency, unit: base_unit_name }); 4898 4899 self.$base_price.html(base_price_string).addClass("display-none"); 4900 } else { 4901 self.$base_price.removeClass("display-none"); 4902 } 4903 } 4904 4905 4906 if (self.$stock_base_ratio.length) { 4907 if (stock_base_ratio) { 4908 self.$stock_base_ratio.html(formatNumber(self.sku.stock_base_ratio)).show(); 4909 } else { 4910 self.$stock_base_ratio.hide().html(""); 4911 } 4912 } 4913 4914 var $wrapZeroPrice = self.form.find(".js-price-zero"), 4915 $wrapPrices = self.form.find(".js-product-base-price, .js-product-prices"); 4916 4917 if ($wrapZeroPrice.length && price == 0){ 4918 $wrapZeroPrice.removeClass("display-none"); 4919 $wrapPrices.addClass("display-none"); 4920 }else{ 4921 $wrapZeroPrice.addClass("display-none"); 4922 $wrapPrices.removeClass("display-none"); 4923 } 4924 4925} 4926 4927Product.prototype.updateDiscount = function (price, compare_price) { 4928 if (this.discount.length){ 4929 var discount = 0, 4930 typeRound = this.discount.data('round'), 4931 minimal = parseInt(this.discount.data('minimal')); 4932 4933 this.discount.addClass('display-none'); 4934 if(compare_price > price && price > 0){ 4935 discount = ((compare_price- price)/compare_price)*100; 4936 if (typeRound == "ceil"){
4937 discount = Math.ceil(discount); 4938 }else if (typeRound == "floor"){ 4939 discount = Math.floor(discount); 4940 }else{ 4941 discount = Math.round(discount); 4942 } 4943 if(discount >= minimal){ 4944 this.discount.html('-' + discount + '%').removeClass('display-none'); 4945 } 4946 } 4947 } 4948} 4949 4950Product.prototype.updateSaved = function (price, compare_price) { 4951 if (this.savedWrap.length){ 4952 this.savedWrap.addClass('display-none'); 4953 if(compare_price > price && price > 0){ 4954 var saved = compare_price - price; 4955 4956 this.savedWrap.html("-" + currencyFormat(saved)).removeClass('display-none'); 4957 } 4958 } 4959} 4960 4961Product.prototype.updateBonuses = function (price) { 4962 var self = this; 4963 4964 if (this.bonusesCountWrap.length && this.is_affiliate && this.affiliate_credit_rate){ 4965 4966 4967 var outer = this.bonusesCountWrap.closest(".js-product-bonus-outer"); 4968 outer.addClass('sk-hide'); 4969 4970 var quantity = 1; 4971 if(this.$quantity_field.length) { 4972 quantity = validate("float", this.$quantity_field.val()); 4973 } 4974 4975 var services_price = self.getServicePrice(), 4976 priceTotal = 0; 4977 4978 if(outer.data("service-add")){ 4979 priceTotal = (price + services_price) * quantity; 4980 }else{ 4981 priceTotal = price * quantity; 4982 } 4983 4984 var bonus = priceTotal/this.affiliate_credit_rate; 4985 4986 if(this.affiliate_rounding){ 4987 bonus = Math.floor(bonus); 4988 }else{ 4989 bonus = parseFloat(bonus.toString().match(/^-?\d+(?:\.\d{0,2})?/)[0]); 4990 } 4991 4992 this.bonusesCountWrap.text(bonus); 4993 4994 if(!bonus){ 4995 outer.addClass('sk-hide'); 4996 }else{ 4997 outer.removeClass('sk-hide'); 4998 } 4999 } 5000} 5001 5002Product.prototype.getServicePrice = function (){ 5003 var self = this, 5004 $checkedServices = self.form.find(".services input:checked"), 5005 services_price = 0; 5006 5007 $checkedServices.each( function () { 5008 var $service = $(this), 5009 service_value = $service.val(), 5010 service_price = 0; 5011 5012 var $serviceVariants = self.form.find(".service-" + service_value + " .service-variants"); 5013 5014 if ($serviceVariants.length) { 5015 service_price = parseFloat( $serviceVariants.find(":selected").data("price") ); 5016 } else { 5017 service_price = parseFloat( $service.data("price") ); 5018 } 5019 services_price += service_price; 5020 }); 5021 5022 return services_price; 5023} 5024 5025Product.prototype.updateTotalPrice = function (price){ 5026 var self = this; 5027 5028 if(this.$product_total.length && this.$price_total.length){ 5029 var quantity = 1; 5030 if(this.$quantity_field.length) { 5031 quantity = validate("float", this.$quantity_field.val()); 5032 } 5033 5034 var services_price = self.getServicePrice(), 5035 priceTotal = (price + services_price) * quantity; 5036 5037 if(priceTotal){ 5038 this.$product_total.removeClass("display-none"); 5039 }else{ 5040 this.$product_total.addClass("display-none"); 5041 } 5042 5043 priceTotal = Price.formatPrice(priceTotal, { currency: this.currency }); 5044 this.$price_total.html(priceTotal); 5045 } 5046} 5047 5048Product.prototype.showAllSkus = function () { 5049 $(".js-product-skus-show").on("click", function (){ 5050 var $this = $(this), 5051 outerWrap = $this.closest(".js-product-skus"), 5052 textShow = $this.data("text-show"), 5053 textHide = $this.data("text-hide"); 5054 5055 if($this.hasClass("open")){ 5056 outerWrap.find(".js-product-skus-item").addClass("hide"); 5057 $this.removeClass("open"); 5058 if(textShow && textHide){ 5059 $this.html(textShow + '<span class="sk-icon far fa-ellipsis-h"></span>'); 5060 } 5061 }else{ 5062 outerWrap.find(".js-product-skus-item").removeClass("hide"); 5063 $this.addClass("open"); 5064 if(textShow && textHide){ 5065 $this.html(textHide + '<span class="sk-icon far fa-ellipsis-h"></span>'); 5066 } 5067 } 5068 });
5069}; 5070 5071Product.prototype.showAllStocks = function () { 5072 $(".js-product-stocks-show").on("click", function (){ 5073 var $this = $(this), 5074 outerWrap = $this.closest(".js-product-stocks"), 5075 textShow = $this.data("text-show"), 5076 textHide = $this.data("text-hide"); 5077 5078 if($this.hasClass("open")){ 5079 outerWrap.find(".js-product-stocks-item").addClass("hide"); 5080 $this.removeClass("open"); 5081 if(textShow && textHide){ 5082 $this.html(textShow + '<span class="sk-icon far fa-ellipsis-h"></span>'); 5083 } 5084 }else{ 5085 outerWrap.find(".js-product-stocks-item").removeClass("hide"); 5086 $this.addClass("open"); 5087 if(textShow && textHide){ 5088 $this.html(textHide + '<span class="sk-icon far fa-ellipsis-h"></span>'); 5089 } 5090 } 5091 }); 5092}; 5093 5094Product.prototype.updateURLSku = function(sku_id) { 5095 var key_name = "sku"; 5096 var search_object = stringToObject(window.location.search.substring(1)); 5097 5098 if (sku_id) { 5099 search_object[key_name] = sku_id; 5100 } else { 5101 delete search_object[key_name]; 5102 } 5103 5104 var search_string = objectToString(search_object); 5105 var new_URL = location.origin + location.pathname + search_string + location.hash; 5106 5107 if (typeof history.replaceState === "function") { 5108 history.replaceState(null, document.title, new_URL); 5109 } 5110 5111 function stringToObject(string) { 5112 var result = {}; 5113 5114 string = string.split("&"); 5115 5116 $.each(string, function(i, value) { 5117 if (value) { 5118 var pair = value.split("="); 5119 result[ decodeURIComponent( pair[0] ) ] = decodeURIComponent( pair[1] ? pair[1] : "" ); 5120 } 5121 }); 5122 5123 return result; 5124 } 5125 5126 function objectToString(object) { 5127 var result = "", 5128 array = []; 5129 5130 $.each(object, function(key, value) { 5131 array.push(encodeURIComponent(key) + "=" + encodeURIComponent(value)); 5132 }); 5133 5134 if (array.length) { 5135 result = "?" + array.join("&"); 5136 } 5137 5138 return result; 5139 } 5140}; 5141 5142Product.prototype.updateFeaturesList = function(sku_id) { 5143 var self = this, 5144 featuresOuter = $('.js-product-features'); 5145 5146 if(typeof this.sku_features != 'undefined' && typeof this.product_skus_features[sku_id] != 'undefined' && featuresOuter.length){ 5147 var featuresList = this.sku_features, 5148 productFeaturesList = this.product_skus_features[sku_id], 5149 featuresCount = parseInt(this.short_features_count), 5150 featuresAliasesList = this.short_features_codes ? this.short_features_codes.split(',') : []; 5151 5152 if(typeof this.schema_itemprops != 'undefined'){ 5153 var schema_itemprops = this.schema_itemprops; 5154 } 5155 5156 featuresOuter.each(function (){ 5157 var featuresOne = $(this).find('.js-product-features-wrap'), 5158 isShortListFeatures = $(this).data("short-list"), 5159 viewFeatures = featuresOne.data("view"), 5160 isSchemaOrg = $(this).data('schema-org'); 5161 5162 featuresOne.html(""); 5163 var indexIteration = 1; 5164 5165 for(var f_code in productFeaturesList) { 5166 var f_value = productFeaturesList[f_code], 5167 isDivider = (typeof featuresList[f_code] != 'undefined' && typeof featuresList[f_code].type != 'undefined' && featuresList[f_code].type == 'divider'), 5168 itemFeaturesClass = "", 5169 itemFeaturesValueClass = "", 5170 htmlFeature = ""; 5171 5172 if(typeof featuresList[f_code] == 'undefined' && typeof featuresList[f_code + ".0"] != 'undefined'){ 5173 featuresList[f_code] = featuresList[f_code + ".0"]; 5174 featuresList[f_code].name = featuresList[f_code + ".0"].name; 5175 } 5176 if(typeof featuresList[f_code] != 'undefined' && typeof featuresList[f_code].type != 'undefined'){ 5177 if(isShortListFeatures && featuresCount && indexIteration > featuresCount){ 5178 break; 5179 } 5180 if(isShortListFeatures && featuresAliasesList.length && $.inArray(f_code, featuresAliasesList) === -1){ 5181 continue; 5182 } 5183 if(isShortListFeatures && isDivider){ 5184 continue; 5185 } 5186 5187 if(viewFeatures == 'short'){ 5188 itemFeaturesClass = "sh-product-features__item"; 5189 itemFeaturesValueClass = "sh-product-features__value"; 5190 if(isDivider){ 5191 itemFeaturesClass += " " +"divider"; 5192 } 5193 5194 htmlFeature += '<span class="'+ itemFeaturesClass +'">'; 5195 htmlFeature += "<span class=\"sh-product-features__title\">" + featuresList[f_code].name + ":</span>"; 5196 5197 if(featuresList[f_code].type == 'color'){ 5198 itemFeaturesValueClass += " -sk-colors"; 5199 } 5200 5201 var itemPropAttr = "", itemprop = null; 5202 if(isSchemaOrg && typeof schema_itemprops != 'undefined'){ 5203 $.each(schema_itemprops, function(i, v) { 5204 if(i == f_code){ 5205 itemprop = v; 5206 } 5207 }); 5208 5209 if(itemprop !== null){ 5210 itemPropAttr = ' itemprop="'+ itemprop +'"'; 5211 } 5212 5213 if(itemprop !== null && itemprop == 'brand'){ 5214 itemPropAttr += ' itemscope itemtype="https://schema.org/Brand"'; 5215 f_value = '<span itemprop="name">'+f_value+'</span>'; 5216 } 5217 5218 } 5219 5220 htmlFeature += "<span "+ itemPropAttr +" class='"+itemFeaturesValueClass+"'>" + f_value + "</span>"; 5221 htmlFeature += '</span>'; 5222 5223 }else if(viewFeatures == 'list'){ 5224 itemFeaturesClass = "l-product-features__item"; 5225 if(isDivider){ 5226 itemFeaturesClass += " " +"divider"; 5227 } 5228 5229 htmlFeature += '<div class="'+ itemFeaturesClass +'">'; 5230 htmlFeature += "<span class=\"l-product-features__title\">" + featuresList[f_code].name + ":</span>"; 5231 5232 itemFeaturesValueClass = "l-product-features__value"; 5233 if(featuresList[f_code].type == 'color'){ 5234 itemFeaturesValueClass = itemFeaturesValueClass + " -sk-colors"; 5235 } 5236 5237 var itemPropAttr = "", itemprop = null; 5238 if(isSchemaOrg && typeof schema_itemprops != 'undefined'){ 5239 $.each(schema_itemprops, function(i, v) { 5240 if(i == f_code){ 5241 itemprop = v; 5242 } 5243 }); 5244 5245 if(itemprop !== null){ 5246 itemPropAttr = ' itemprop="'+ itemprop +'"'; 5247 } 5248 5249 if(itemprop !== null && itemprop == 'brand'){ 5250 itemPropAttr += ' itemscope itemtype="https://schema.org/Brand"'; 5251 f_value = '<span itemprop="name">'+f_value+'</span>'; 5252 } 5253 5254 } 5255 5256 htmlFeature += "<span class='"+itemFeaturesValueClass+"' "+itemPropAttr+">" + f_value + "</span>"; 5257 htmlFeature += '</div>'; 5258 }else{ 5259 itemFeaturesClass = "t-product-features__item"; 5260 if(isDivider){ 5261 itemFeaturesClass += " " +"divider"; 5262 } 5263 htmlFeature = '<div class="'+ itemFeaturesClass +'">'; 5264 htmlFeature += "<span class=\"t-product-features__title\">" + featuresList[f_code].name + "</span>"; 5265 5266 var itemPropAttr = "", itemprop = null; 5267 if(isSchemaOrg && typeof schema_itemprops != 'undefined'){ 5268 $.each(schema_itemprops, function(i, v) { 5269 if(i == f_code){ 5270 itemprop = v; 5271 } 5272 }); 5273 5274 if(itemprop !== null){ 5275 itemPropAttr = ' itemprop="'+ itemprop +'"'; 5276 } 5277 5278 if(itemprop !== null && itemprop == 'brand'){ 5279 itemPropAttr += ' itemscope itemtype="https://schema.org/Brand"'; 5280 f_value = '<span itemprop="name">'+f_value+'</span>'; 5281 } 5282 5283 } 5284 htmlFeature += '<span class="t-product-features__value"'+ itemPropAttr +'>'; 5285 5286 if(!isDivider){ 5287 if(isShortListFeatures && featuresList[f_code].type == 'color'){ 5288 htmlFeature += "<span class=\"-sk-colors\">"; 5289 } 5290 htmlFeature += f_value; 5291 if(isShortListFeatures && featuresList[f_code].type == 'color'){ 5292 htmlFeature += "</span>"; 5293 } 5294 } 5295 htmlFeature += "</span>"; 5296 htmlFeature += "</div>"; 5297 } 5298 5299 featuresOne.append(htmlFeature); 5300 indexIteration++; 5301 } 5302 } 5303 }); 5304 } 5305}; 5306 5307Product.prototype.featurestipsPlugin = function (featuresOuter){
5308 var featurestips_tip = $("div.featurestips_tip"), 5309 events = featurestips_tip.data("events"); 5310 5311 if(featurestips_tip.length && typeof events !== 'undefined'){ 5312 if(typeof events.mouseover !== 'undefined'){ 5313 $('div.featurestips_tip').unbind("hover"); 5314 5315 $('body').on("mouseover", 'div.featurestips_tip', function() { 5316 var element = $('span.featurestips_icon', this); 5317 var top = element.offset().top; 5318 var left = element.offset().left; 5319 var iconSize = element.height(); 5320 $('div.featurestips_view', this).offset({top: top + iconSize + 10}); 5321 $(this).addClass("active"); 5322 $('div.featurestips_view', this).css("visibility", "visible"); 5323 }); 5324 5325 $('body').on("mouseout", 'div.featurestips_tip', function() { 5326 $('div.featurestips_view', this).css("visibility", "hidden"); 5327 $(this).removeClass("active"); 5328 }); 5329 }else{ 5330 $('div.featurestips_tip, div.featurestips_view').unbind("hover"); 5331 5332 $('body').on("click", "div.featurestips_tip", function(featurestipsevent) { 5333 var element = $('span.featurestips_icon', this); 5334 var top = element.offset().top; 5335 var iconSize = element.height(); 5336 $('div.featurestips_view', this).offset({top: top + iconSize + 10}); 5337 $(this).addClass("active"); 5338 $('div.featurestips_view', this).css("visibility", "visible"); 5339 featurestipsevent.preventDefault(); 5340 featurestipsevent.stopPropagation(); 5341 }); 5342 $('body').on("click", "div.featurestips_view", function(featurestipsevent) { 5343 featurestipsevent.stopPropagation(); 5344 }); 5345 } 5346 } 5347} 5348 5349Product.prototype.updateProductSkusNames = function (sku){ 5350 var self = this; 5351 5352 if(typeof sku != undefined && sku != null){ 5353 self.$productSkusNames.text(sku.name); 5354 }else{ 5355 self.$productSkusNames.text(""); 5356 } 5357} 5358 5359Product.prototype.checkInCart = function (sku_id){ 5360 var self = this; 5361 5362 if(sku_id && typeof globalThemeSettings.cartItems !== 'undefined' && globalThemeSettings.cartItems != null && typeof globalThemeSettings.cartItems[sku_id] !== 'undefined') { 5363 self.button.addClass('-sk-hide').addClass('added'); 5364 if(typeof self.$quantity_section !== 'undefined'){ 5365 self.$quantity_section.removeClass('-sk-hide'); 5366 self.buttonAdded.removeClass('-sk-hide').removeClass('added'); 5367 } 5368 if(typeof globalThemeSettings.cartItems[sku_id]['quantity'] !== 'undefined' && globalThemeSettings.cartItems[sku_id]['quantity'] > 0){ 5369 self.quantity_controller.update({ 5370 value: globalThemeSettings.cartItems[sku_id]['quantity'] 5371 }); 5372 5373 self.$quantity_section.data("controller").cart_item_id = globalThemeSettings.cartItems[sku_id].id; 5374 self.$quantity_section.attr("data-cart-item-id", globalThemeSettings.cartItems[sku_id].id); 5375 } 5376 }else{ 5377 self.button.removeClass('-sk-hide').removeClass('added'); 5378 if(typeof self.$quantity_section !== 'undefined'){ 5379 self.$quantity_section.addClass('-sk-hide'); 5380 self.$quantity_section.removeAttr("data-cart-item-id"); 5381 self.buttonAdded.addClass('-sk-hide'); 5382 } 5383 5384 self.quantity_controller.update({ 5385 value: 1 5386 }); 5387 } 5388}; 5389 5390var Price = { 5391 currencies: { 5392 "default": { 5393 code : null, 5394 fraction_divider: ".", 5395 fraction_size : 2, 5396 group_divider : " ", 5397 group_size : 3, 5398 pattern_html : "<span class=\"price\">%s</span>", 5399 pattern_text : "%s", 5400 pattern_unit : "%s/%unit", 5401 rounding : 0.01 5402 } 5403 }, 5404 addCurrency: function(currency_data) { 5405 var self = this; 5406 5407 if (currency_data) { 5408 self.currencies[currency_data["code"]] = currency_data; 5409 } 5410 }, 5411 formatPrice: function(price, options) { 5412 var self = this, 5413 result = price; 5414 5415 options = (typeof options !== "undefined" ? options : {}); 5416 options.unit = (typeof options.unit === "string" ? options.unit : null); 5417 options.html = (typeof options.html === "boolean" ? options.html : true); 5418 options.currency = (typeof options.currency === "string" ? options.currency : "default"); 5419 5420 if (!options.currency || !self.currencies[options.currency]) { 5421 console.error("ERROR: Currency is not exist"); 5422 return result; 5423 } 5424 5425 var format = self.currencies[options.currency]; 5426 5427 try { 5428 price = parseFloat(price); 5429 if (price >= 0) { 5430 price = price.toFixed(format.fraction_size); 5431 5432 var price_floor = Math.floor(price), 5433 price_string = getGroupedString("" + price_floor, format.group_size, format.group_divider), 5434 fraction_string = getFractionString(price - price_floor); 5435 5436 result = (options.html ? format.pattern_html : format.pattern_text) 5437 .replace("%s", price_string + fraction_string ); 5438 5439 if (options.unit) { 5440 var unit = (options.html ? '<span class="unit">'+options.unit+'</span>' : options.unit); 5441 result = format.pattern_unit 5442 .replace("%s", result) 5443 .replace("%unit", unit); 5444 } 5445 } 5446 } catch(e) { 5447 if (console && console.log) { 5448 console.log(e.message, price); 5449 } 5450 } 5451 5452 if (options.html) { 5453 result = '<span class="price-wrapper">'+result+'</span>'; 5454 } 5455 5456 return result; 5457 5458 function getGroupedString(string, size, divider) { 5459 var result = ""; 5460 5461 if (!(size && string && divider)) { 5462 return string; 5463 } 5464 5465 var string_array = string.split("").reverse(); 5466 5467 var groups = []; 5468 var group = []; 5469 5470 for (var i = 0; i < string_array.length; i++) { 5471 var letter = string_array[i], 5472 is_first = (i === 0), 5473 is_last = (i === string_array.length - 1), 5474 delta = (i % size); 5475 5476 if (delta === 0 && !is_first) { 5477 groups.unshift(group); 5478 group = []; 5479 } 5480 group.unshift(letter); 5481 5482 if (is_last) { 5483 groups.unshift(group); 5484 } 5485 } 5486 for (i = 0; i < groups.length; i++) { 5487 var is_last_group = (i === groups.length - 1), 5488 _group = groups[i].join(""); 5489 5490 result += _group + ( is_last_group ? "" : divider ); 5491 } 5492 return result; 5493 } 5494 5495 function getFractionString(number) { 5496 var result = ""; 5497 5498 if (number > 0) { 5499 number = number.toFixed(format.fraction_size + 1); 5500 number = Math.round(number * Math.pow(10, format.fraction_size))/Math.pow(10, format.fraction_size); 5501 var string = number.toFixed(format.fraction_size); 5502 result = string.replace("0.", format.fraction_divider); 5503 } 5504 return result; 5505 } 5506 } 5507}; 5508 5509var activeQuantityField = { 5510 init: function (){ 5511 var _this = this; 5512 5513 $('.js-add-to-cart').on('keyup keypress', function(e) { 5514 var keyCode = e.keyCode || e.which; 5515 if (keyCode === 13) { 5516 e.preventDefault(); 5517 return false; 5518 } 5519 }); 5520 5521 $('body').on("hover", ".js-product-list-quantity-section:not(.js-quantity-active)", function (event){ 5522 _this.active($(this)); 5523 }); 5524 }, 5525 active: function ($outer){ 5526 if(!$outer.hasClass('js-quantity-active')){ 5527 var denominator = $outer.data('denominator'), 5528 step = $outer.data('step'), 5529 min = $outer.data('min'), 5530 max = $outer.data('max'), 5531 unit = $outer.data('unit'), 5532 cart_item_id = $outer.data('cart-item-id'); 5533 5534 new Quantity({ 5535 $wrapper: $outer, 5536 denominator: denominator, 5537 step: step, 5538 min: min, 5539 max: max, 5540 unit: unit, 5541 cart_item_id: cart_item_id,
5542 sku_id: $outer.closest(".js-product").data("sku-id") 5543 }); 5544 } 5545 } 5546}; 5547 5548var validate = function(type, value) { 5549 value = (typeof value === "string" ? value : "" + value); 5550 5551 var result = value; 5552 5553 switch (type) { 5554 case "float": 5555 var float_value = parseFloat(value); 5556 if (float_value >= 0) { 5557 result = float_value.toFixed(3) * 1; 5558 } 5559 break; 5560 5561 case "number": 5562 var white_list = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", ","], 5563 letters_array = [], 5564 divider_exist = false; 5565 5566 $.each(value.split(""), function(i, letter) { 5567 if (letter === "." || letter === ",") { 5568 letter = "."; 5569 if (!divider_exist) { 5570 divider_exist = true; 5571 letters_array.push(letter); 5572 } 5573 } else { 5574 if (white_list.indexOf(letter) >= 0) { 5575 letters_array.push(letter); 5576 } 5577 } 5578 }); 5579 5580 result = letters_array.join(""); 5581 break; 5582 5583 case "integer": 5584 var white_list = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], 5585 letters_array = []; 5586 5587 $.each(value.split(""), function(i, letter) { 5588 if (white_list.indexOf(letter) >= 0) { 5589 letters_array.push(letter); 5590 } 5591 }); 5592 5593 result = letters_array.join(""); 5594 break; 5595 5596 default: 5597 break; 5598 } 5599 5600 return result; 5601}; 5602 5603function Quantity(options) { 5604 var that = this; 5605 5606 // DOM 5607 that.$wrapper = options["$wrapper"]; 5608 that.$add2cart = that.$wrapper.closest('.js-add-to-cart').find('.js-submit-form'); 5609 that.$addedCart = that.$wrapper.closest('.js-add-to-cart').find('.js-button-added'); 5610 that.$add2cartDialog = that.$wrapper.closest('.js-add-to-cart').find('.js-product-card-dialog'); 5611 that.$field = that.$wrapper.find(".js-quantity-field"); 5612 that.$min = that.$wrapper.find(".js-decrease"); 5613 that.$max = that.$wrapper.find(".js-increase"); 5614 that.$min_desc = that.$wrapper.find(".js-min-description"); 5615 that.$max_desc = that.$wrapper.find(".js-max-description"); 5616 that.$stock_base_ratio = that.$wrapper.closest('.js-product-item, .js-product').find(".js-stock-base-ratio"); 5617 that.$stock_base_ratio_total = that.$wrapper.closest('.js-product-item, .js-product').find(".js-stock-base-ratio-total"); 5618 5619 // CONST 5620 that.localeMin = globalThemeSettings.quantityLocalesMin; 5621 that.localeMax = globalThemeSettings.quantityLocalesMax; 5622 that.cartUrlSave = globalThemeSettings.cartUrlSave; 5623 that.cartUrlDelete = globalThemeSettings.cartUrlDelete; 5624 that.isSaveCartItemCount = globalThemeSettings.isSaveCartItemCount; 5625 that.denominator = (typeof options["denominator"] !== "undefined" ? validate("float", options["denominator"]) : 1); 5626 that.denominator = (that.denominator > 0 ? that.denominator : 1); 5627 that.min = (typeof options["min"] !== "undefined" ? validate("float", options["min"]) : that.denominator); 5628 that.min = (that.min > 0 ? that.min : 1); 5629 that.max = (typeof options["max"] !== "undefined" ? validate("float", options["max"]) : 0); 5630 that.max = (that.max >= 0 ? that.max : 0); 5631 that.step = (typeof options["step"] !== "undefined" ? validate("float", options["step"]) : 1); 5632 that.step = (that.step > 0 ? that.step : 1); 5633 that.action = options["action"]; 5634 that.stock_base_ratio = (that.$stock_base_ratio.length ? parseFloat(that.$stock_base_ratio.html()) : null); 5635 that.cart_item_id = (typeof options["cart_item_id"] !== "undefined" ? parseInt(options["cart_item_id"]) : null); 5636 that.sku_id = (typeof options["sku_id"] !== "undefined" ? parseInt(options["sku_id"]) : null); 5637 5638 // DYNAMIC VARS 5639 that.value = getValue(); 5640 5641 // INIT 5642 that.init(); 5643 5644 that.$wrapper.addClass('js-quantity-active'); 5645 5646 function getValue() { 5647 var value = that.$field.val(); 5648 5649 if (parseFloat(value) > 0) { 5650 // 5651 } else { 5652 that.$field.val(that.min); 5653 value = that.min; 5654 } 5655 5656 return that.validate(value); 5657 } 5658}; 5659 5660Quantity.prototype.init = function() { 5661 var that = this; 5662
5663 that.$field.data("controller", that); 5664 that.$wrapper.data("controller", that); 5665 5666 that.$wrapper.on("click", ".js-increase", function(event) { 5667 event.preventDefault(); 5668 that.set(that.value + that.step); 5669 that.setCartCount(); 5670 }); 5671 5672 that.$wrapper.on("click", ".js-decrease", function(event) { 5673 event.preventDefault(); 5674 var countValue = that.value - that.step 5675 that.set(that.value - that.step); 5676 5677 if(countValue < that.min){ 5678 that.removeCartItem(); 5679 }else{ 5680 that.setCartCount(); 5681 } 5682 }); 5683 5684 that.$field.on("input", function() { 5685 var value = that.$field.val(), 5686 new_value = (typeof value === "string" ? value : "" + value); 5687 5688 new_value = validateNumber(new_value); 5689 if (new_value !== value) { 5690 that.$field.val(new_value); 5691 } 5692 }); 5693 5694 var updateCart; 5695 that.$field.on("keyup", function() { 5696 clearTimeout(updateCart); 5697 5698 updateCart = setTimeout(function (){ 5699 var value = that.$field.val(); 5700 5701 if(value == 0){ 5702 that.removeCartItem(); 5703 }else{ 5704 that.set(that.$field.val()); 5705 that.setCartCount(); 5706 } 5707 }, 500); 5708 }); 5709 5710 that.setDescription(); 5711 5712 function validateNumber(value) { 5713 var white_list = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "."], 5714 letters_array = [], 5715 divider_exist = false; 5716 5717 value = value.replace(/,/g, "."); 5718 5719 $.each(value.split(""), function(i, letter) { 5720 if (letter === ".") { 5721 if (!divider_exist) { 5722 divider_exist = true; 5723 letters_array.push(letter); 5724 } 5725 } else { 5726 if (white_list.indexOf(letter) >= 0) { 5727 letters_array.push(letter); 5728 } 5729 } 5730 }); 5731 5732 return letters_array.join(""); 5733 } 5734}; 5735 5736/** 5737 * @param {string|number} value 5738 * @param {object?} options 5739 * */ 5740Quantity.prototype.set = function(value, options) { 5741 options = (typeof options !== "undefined" ? options : {}); 5742 5743 var that = this; 5744 5745 value = that.validate(value); 5746 that.$field.val(value); 5747 that.value = value; 5748 5749 that.setDescription(); 5750 that.setTotalBaseUnit(); 5751 5752 that.$wrapper.trigger("quantity.changed", [that.value, that]); 5753}; 5754 5755Quantity.prototype.setCartCount = function (){ 5756 var that = this; 5757 5758 if(that.isSaveCartItemCount && typeof that.cart_item_id !== "undefined" && that.cart_item_id && typeof that.value !== "undefined" && that.value){ 5759 that.$wrapper.addClass("-sk-loading"); 5760 $.post(that.cartUrlSave, {html: 1, id: that.cart_item_id, quantity: that.value}, function (response) { 5761 if(response.status == "ok"){ 5762 if(typeof response.data.error !== "undefined"){ 5763 popupMiniMessage.show(response.data.error, 'error'); 5764 } 5765 if(typeof response.data.q !== "undefined"){ 5766 that.set(response.data.q); 5767 } 5768 that.$wrapper.removeClass("-sk-loading"); 5769 cart.updatePreviewCart(response.data.count, response.data.total); 5770 cart.updateCartItems(null, that.cart_item_id, that.value); 5771 } 5772 }, "json"); 5773 } 5774}; 5775 5776Quantity.prototype.removeCartItem = function (){ 5777 var that = this; 5778 if(that.isSaveCartItemCount && typeof that.cart_item_id !== "undefined" && that.cart_item_id && typeof that.value !== "undefined" && that.value){ 5779 that.$wrapper.addClass("-sk-loading"); 5780 $.post(that.cartUrlDelete, {html: 1, id: that.cart_item_id}, function (response) { 5781 if(response.status == "ok"){ 5782 cart.updateCartItems(null, that.cart_item_id, 0); 5783 cart.updatePreviewCart(response.data.count, response.data.total); 5784 that.cart_item_id = null; 5785 that.$wrapper.removeClass("-sk-loading").addClass("-sk-hide").removeAttr("data-cart-item-id"); 5786 that.$addedCart.addClass("-sk-hide"); 5787 that.$add2cart.removeClass("-sk-hide").removeClass("added"); 5788 that.$add2cartDialog.removeClass("-sk-hide").removeClass("added"); 5789 5790 if(that.sku_id) { 5791 var allSkuProducts = $('.js-product[data-sku-id="' + that.sku_id + '"]'), 5792 allSkuProductsAdd2cart = allSkuProducts.find('.js-submit-form, .js-product-card-dialog'), 5793 allSkuProductsQuantity = allSkuProducts.find('.js-quantity-section, .js-product-list-quantity-section'), 5794 allSkuProductsBtnAdded = allSkuProducts.find('.js-button-added'); 5795 5796 allSkuProductsQuantity.removeClass("-sk-loading").addClass("-sk-hide").removeAttr("data-cart-item-id"); 5797 allSkuProductsBtnAdded.addClass("-sk-hide"); 5798 allSkuProductsAdd2cart.removeClass("-sk-hide").removeClass("added"); 5799 } 5800 } 5801 }, "json"); 5802 } 5803} 5804 5805Quantity.prototype.validate = function(value) { 5806 var that = this, 5807 result = value; 5808
5809 value = (typeof value !== "number" ? parseFloat(value) : value); 5810 value = parseFloat(value.toFixed(3)); 5811 5812 // Ð»ÐµÐ²Ð°Ñ Ð³ÑаниÑа 5813 if (!(value > 0)) { value = that.min; } 5814 5815 if (value > 0 && value < that.min) { value = that.min; } 5816 5817 // ÑенÑÑ 5818 var steps_count = Math.floor(value/that.denominator); 5819 var x1 = (that.denominator * steps_count).toFixed(3) * 1; 5820 if (x1 !== value) { 5821 value = that.denominator * (steps_count + 1); 5822 } 5823 5824 // пÑÐ°Ð²Ð°Ñ Ð³ÑаниÑа 5825 if (that.max && value > that.max) { value = that.max; } 5826 5827 return validate("float", value); 5828}; 5829 5830Quantity.prototype.update = function(options) { 5831 var that = this; 5832 5833 var min = (typeof options["min"] !== "undefined" ? validate("float", options["min"]) : that.min), 5834 max = (typeof options["max"] !== "undefined" ? (parseFloat(options["max"]) >= 0 ? validate("float", options["max"]) : 0) : that.max), 5835 step = (typeof options["step"] !== "undefined" ? validate("float", options["step"]) : that.step), 5836 stock_base_ratio = (typeof options["stock_base_ratio"] !== "undefined" ? parseFloat(options["stock_base_ratio"]) : that.stock_base_ratio), 5837 value = (typeof options["value"] !== "undefined" ? that.validate(options["value"]) : that.value); 5838 5839 if (min > 0 && min !== that.min) { that.min = min; } 5840 if (max >= 0 && max !== that.max) { that.max = max; } 5841 if (step > 0 && step !== that.step) { that.step = step; } 5842 if (stock_base_ratio > 0 && stock_base_ratio !== that.stock_base_ratio) { that.stock_base_ratio = stock_base_ratio; } 5843 if (value > 0 && value !== that.value) { that.value = value; } 5844 5845 that.set(that.value); 5846}; 5847 5848Quantity.prototype.setDescription = function(debug) { 5849 var that = this; 5850 5851 var show_step = (that.step && that.step > 0 && that.step !== 1), 5852 near_limit_class = "is-near-limit",
5853 locked_class = "is-locked", 5854 string_min = that.localeMin, 5855 string_max = that.localeMax; 5856 5857 toggleDescription(that.$min, that.$min_desc, that.min, string_min, "-"); 5858 toggleDescription(that.$max, that.$max_desc, that.max, string_max, "+"); 5859 5860 function toggleDescription($button, $desc, limit, locale, actionSymbolString) { 5861 var description = null, 5862 limit_string = locale.replace("%s", (limit ? "<span class=\"s-step\">"+limit+"</span>" : "")); 5863 5864 $button.removeClass(locked_class).removeClass(near_limit_class); 5865 5866 var is_limit = (that.value === limit && limit); 5867 5868 if (is_limit) { 5869 $button.addClass(locked_class); 5870 5871 if(actionSymbolString != "-" || limit !== 1){ 5872 description = limit_string; 5873 } 5874 } else { 5875 if (show_step) { 5876 var near_limit = (limit > 0 && validate("float", Math.abs(that.value - limit)) < that.step); 5877 if (near_limit) { 5878 $button.addClass(near_limit_class); 5879 description = limit_string; 5880 } else { 5881 description = actionSymbolString + " " + that.step; 5882 } 5883 } 5884 } 5885 5886 if (description) { 5887 $desc.html(description).addClass("active"); 5888 } else { 5889 $desc.removeClass("active").html(""); 5890 } 5891 } 5892}; 5893 5894Quantity.prototype.setTotalBaseUnit = function (){ 5895 var that = this; 5896 5897 if(that.$stock_base_ratio_total.length && that.stock_base_ratio){ 5898 var stock_base_ratio_total = validate("float", that.stock_base_ratio*that.value); 5899 5900 that.$stock_base_ratio_total.html(stock_base_ratio_total); 5901 } 5902}; 5903 5904var productPreviewGallerySwipe = { 5905 init: function (){ 5906 var _this = this; 5907 5908 _this.initCarousel(); 5909 }, 5910 initCarousel: function (){ 5911 $('.js-product-preview-gallery').hammer().off(); 5912 5913 $('.js-product-preview-gallery').hammer().on("swipeleft swiperight", function(event){ 5914 if(event.type == 'swipeleft'){ 5915 productPreviewGallerySwipe.gallerySwipe($(event.target),"next"); 5916 }else if(event.type == 'swiperight'){ 5917 productPreviewGallerySwipe.gallerySwipe($(event.target),"prev"); 5918 } 5919 }); 5920 }, 5921 gallerySwipe: function (carousel, goToSlid){ 5922 var _this = this; 5923 5924 if(carousel.hasClass("owl-loaded")){ 5925 return false; 5926 } 5927 5928 var dotsWrap = carousel.closest('.js-product-preview-gallery-outer').find(".js-product-preview-gallery-dots"), 5929 isRetina = carousel.closest('.js-preview-products').data("retina"); 5930 5931 carousel.owlCarousel({ 5932 loop: true, 5933 nav: false, 5934 margin: 0, 5935 items: 1, 5936 lazyLoad: true, 5937 autoHeight: false, 5938 dots: true, 5939 mouseDrag: false, 5940 dotsContainer: dotsWrap, 5941 onLoadedLazy: function(event){ 5942 var wrap = $(event.currentTarget); 5943 if (isRetina) { 5944 wrap.find(".owl-item.active .owl-lazy").retina({force_original_dimensions: false}); 5945 } 5946 } 5947 }); 5948 5949 if (goToSlid) { 5950 if (goToSlid == "prev") { 5951 carousel.trigger("prev.owl.carousel"); 5952 } else if (goToSlid == "next") { 5953 carousel.trigger("next.owl.carousel"); 5954 } else { 5955 carousel.trigger("to.owl.carousel", [parseInt(goToSlid)]); 5956 } 5957 } 5958 } 5959}; 5960 5961/* 5962 * ÐлиÑоÑÐ½Ð°Ñ Ð³Ð°Ð»ÐµÑÐµÑ 5963 */ 5964if (!window.productGalleryTile) { 5965 5966 productGalleryTile = (function ($) { 5967 5968 var productGalleryTile = function (params) { 5969 this.init(params); 5970 }; 5971 5972 productGalleryTile.prototype = { 5973 _config: { 5974 images: {}, 5975 heightFixed: true 5976 }, 5977 init: function (params) { 5978 var that = this; 5979 5980 if($("body").hasClass("touch") ){ 5981 return false; 5982 } 5983 that.params = $.extend({}, that._config, params); 5984 that.runGallery(); 5985 }, 5986 runGallery: function() { 5987 var that = this; 5988 var elements = $('.js-gallerytile'); 5989 elements.each(function (){ 5990 var element = $(this), 5991 block = element.find(".js-gallerytile-block"), 5992 image = element.find(".js-img"), 5993 length = element.find('.js-gallerytile-item').length, 5994 productListWrap = element.closest('.js-preview-products'), 5995 isRetina = productListWrap.data("retina"); 5996 5997 if(!image.data("src")){ 5998 image.attr("data-src", image.attr("src")) 5999 } 6000 6001 var src_default = image.data("src"); 6002 6003 if(!element.size() || !block.size() || !image.size() || length < 2 || element.hasClass("_tile-active")){ 6004 return true; 6005 } 6006 6007 element.addClass("__tile-active"); 6008 block.removeAttr("style"); 6009 block.removeClass("fixed"); 6010 element.find(".js-gallerytile-item").on("mouseenter", function(){ 6011 block.addClass("__tile-hover"); 6012 if(that.params.heightFixed){ 6013 block.css("height", block.height() + "px"); 6014 block.css("line-height", block.height() + "px"); 6015 block.addClass("fixed"); 6016 } 6017 6018 var position = $(this).data("position"), 6019 dots = block.find(".js-gallerytile-dot"), 6020 currentDot = block.find(".js-gallerytile-dot[data-position='" + position + "']"); 6021 6022 if(dots.length && currentDot.length){ 6023 dots.removeClass("sk-hover"); 6024 currentDot.addClass("sk-hover"); 6025 } 6026 6027 var src = $(this).data("img"); 6028 $('<img>').attr('src', src).load(function () { 6029 if(block.hasClass("__tile-hover")){ 6030 image.attr("src", src); 6031 if(isRetina){ 6032 image.retina({force_original_dimensions: false}); 6033 } 6034 } 6035 }); 6036 }); 6037 6038 block.on("mouseleave",function(){ 6039 image.attr("src", src_default); 6040 if(isRetina) { 6041 image.retina({force_original_dimensions: false}); 6042 } 6043 block.removeClass("__tile-hover"); 6044 block.css("height", ""); 6045 block.css("line-height", ""); 6046 block.removeClass("fixed"); 6047 }); 6048 }); 6049 } 6050 }; 6051 return productGalleryTile; 6052 })(jQuery); 6053}; 6054 6055/* 6056 * ÐнÑоÑмаÑионное ÑообÑение 6057 */ 6058var infoMessage = { 6059 init: function (container) { 6060 var _this = this; 6061 6062 if(!container.length){ 6063 return false; 6064 } 6065 6066 if(_this.checkOpen(container)){ 6067 _this.onClose(container); 6068 } 6069 }, 6070 checkOpen: function(container){ 6071 var _this = this, 6072 id = container.data('id'); 6073 6074 if(!$.cookie("info_massage_close_" + id)){ 6075 return true; 6076 } 6077 6078 return false; 6079 }, 6080 runOpen: function(container){ 6081 var _this = this; 6082 6083 container.show(); 6084 }, 6085 onClose: function(container){ 6086 var _this = this, 6087 id = container.data('id'), 6088 close = container.find('.js-info-message-close'); 6089 6090 close.on("click", function(){ 6091 container.detach(); 6092 $.cookie("info_massage_close_" + id, 1, {path: '/', expires: 365}); 6093 }); 6094 } 6095}; 6096 6097/* 6098 * ÐÐ¸Ð´Ð¶ÐµÑ Ð°ÐºÑÐ¸Ñ Ð² popup 6099 */ 6100var popupAdvert = { 6101 init: function (container){ 6102 var _this = this; 6103 6104 if(!container.length){ 6105 return false; 6106 } 6107 6108 if(_this.isNotTabu() || _this.checkOpen(container)){ 6109 _this.runLogic(container); 6110 } 6111 }, 6112 checkOpen: function(container){ 6113 var _this = this, 6114 id = container.data('id'); 6115 6116 if(!$.cookie("popup_advert_close_" + id)){ 6117 return true; 6118 } 6119 6120 return false; 6121 }, 6122 isNotTabu: function(){ 6123 var _this = this, 6124 is_tabu = $.cookie("popup_advert_tabu"); 6125 6126 if(typeof is_tabu === "undefined" && !is_tabu){ 6127 return true; 6128 } 6129 6130 return false 6131 }, 6132 runLogic: function(container){ 6133 var _this = this, 6134 time = parseInt(container.data("time")), 6135 tabu = parseInt(container.data("tabu")), 6136 id = container.data('id'); 6137 6138 if(!time){ 6139 time = 10; 6140 } 6141 if(!tabu){ 6142 tabu = 10; 6143 } 6144 setTimeout(function(){ 6145 $.magnificPopup.open({ 6146 items: { 6147 src: container, 6148 type: 'inline' 6149 }, 6150 callbacks: { 6151 open: function() { 6152 $.cookie("popup_advert_tabu", 1, {path: '/', expires: tabu}); 6153 $.cookie("widget_popup_advert_close_" + id, 1, {path: '/', expires: 365}); 6154 } 6155 } 6156 }); 6157 6158 }, time * 1000); 6159 } 6160}; 6161 6162var demoTest = { 6163 init: function (){ 6164 var _this = this; 6165 6166 if(!$('#test-settings').length){ 6167 return false; 6168 } 6169 6170 $('#open-test-settings').on("click", function(event){ 6171 event.preventDefault(); 6172 6173 $.magnificPopup.open({ 6174 items: { 6175 src: '#test-settings' 6176 }, 6177 type: 'inline' 6178 }); 6179 }); 6180 6181 $('#open-test-settings').one("click", function(event){ 6182 event.preventDefault(); 6183 6184 _this.settings();
6185 }); 6186 }, 6187 settings: function (){ 6188 var _this = this, 6189 settings = [ 6190 "color_scheme", 6191 "bs_bg_color", 6192 "bs_bg_color_font", 6193 "bs_color", 6194 "ac_bg_color", 6195 "ac_bg_color_font", 6196 "ac_color", 6197 "button_cart_bg_color", 6198 "button_cart_font_color", 6199 "button_cart_boxshadow", 6200 "button_cart_added_bg_color", 6201 "button_cart_added_font_color", 6202 "button_cart_added_boxshadow", 6203 "font", 6204 "is_horizontal_catalog", 6205 "product_card_type_main_content_desktop", 6206 "product_card_type_main_content_mobile", 6207 "product_select_options_type", 6208 "product_select_skus" 6209 ]; 6210 6211 $('#test-settings .js-color').attr("type", "color"); 6212 $('#test-settings .js-color').on("change", function (){ 6213 $(this).data("empty", 0); 6214 }); 6215 6216 $('#test-settings .js-color-clear').on("click", function (){ 6217 $("#"+$(this).data('id')).val("#ffffff").data("empty", 1); 6218 }); 6219 6220 $('#settings-form').submit(function(event){ 6221 event.preventDefault(); 6222 6223 var $this = $(this), 6224 settingsForm = $this.serializeArray(); 6225 6226 _this.saveSettings(settingsForm, settings); 6227 }); 6228 6229 $('.js-select-setting-color').on("click", function (){ 6230 var $this = $(this), 6231 value = $this.data("value"), 6232 input = $('.js-setting-color'); 6233 6234 input.val(value); 6235 $('.js-select-setting-color').removeClass("selected"); 6236 $this.addClass("selected"); 6237 }); 6238 6239 $('.js-clear-test-settings').on("click", function (){ 6240 _this.clearTestSettings(settings); 6241 }); 6242 }, 6243 saveSettings: function (values, settings){ 6244 settings.forEach(function(name){ 6245 var setting = values.find(function (item){ 6246 return item.name == name; 6247 }); 6248 6249 var input = $('#settings-form').find('input[name="' + name + '"]'); 6250 6251 if(input.attr("type")=='color' && input.data("empty") == 1){ 6252 setting.value = null; 6253 } 6254 6255 var date = new Date(), minutes = 30; 6256 date.setTime(date.getTime() + (minutes * 60 * 1000)); 6257 $.cookie(name, setting.value, { expires: date, path: '/' }); 6258 6259 window.location.reload(); 6260 }); 6261 }, 6262 clearTestSettings: function (settings){ 6263 settings.forEach(function(name){ 6264 $.removeCookie(name, { path: '/' }); 6265 }); 6266 window.location.reload(); 6267 } 6268}; 6269 6270var customGalleryPopup = { 6271 init: function (){ 6272 var _this = this, 6273 galleryImage = $('.js-custom-gallery'); 6274 6275 galleryImage.on("click", function(e){ 6276 e.preventDefault(); 6277 var images = [], 6278 current = $(this), 6279 currentGroup = $(this).data('group'), 6280 position = 0, 6281 galleryImages = []; 6282 6283 if(currentGroup){ 6284 galleryImages = $('.js-custom-gallery[data-group="'+currentGroup+'"]'); 6285 } 6286 6287 if(galleryImages.length > 1){ 6288 galleryImages.each(function (index) { 6289 var href = $(this).attr('href'), 6290 title = $(this).attr('title'); 6291 6292 if (href){ 6293 if(current.attr('href') == href){ 6294 position = index; 6295 } 6296 images.push({href: href, title: title}); 6297 } 6298 }); 6299 _this.openGallery(images, position); 6300 }else{ 6301 var href = current.attr('href'), 6302 title = current.attr('title'); 6303 6304 if(href){ 6305 images.push({href: href, title: title});
6306 _this.openGallery(images); 6307 } 6308 } 6309 }); 6310 }, 6311 openGallery: function (images, position){ 6312 $(document).on("click", 'img, #swipebox-bottom-bar, .js-swipebox-thumbs-el', function (event){ 6313 event.stopPropagation(); 6314 }); 6315 6316 $(document).on("scroll", closeSwipe); 6317 $(document).on("click", '#swipebox-overlay', closeSwipe); 6318 6319 function closeSwipe() { 6320 var $closeButton = $("#swipebox-close"); 6321 if ($closeButton.length) { 6322 $closeButton.trigger("click"); 6323 } 6324 } 6325 6326 $.swipebox(images, { 6327 useSVG : false, 6328 hideBarsDelay: false, 6329 initialIndexOnArray: position, 6330 beforeOpen: function (){ 6331 /* коÑÑÑÐ»Ñ Ð´Ð»Ñ ÑÐ½Ð´ÐµÐºÑ ÑовеÑника */ 6332 $( '.js-swipebox-overlay' ).remove(); 6333 }, 6334 afterOpen: function() { 6335 $('#swipebox-overlay').addClass('opacity-black'); 6336 $('#swipebox-bottom-bar').addClass("swipebox-bottom-bar--pos-center"); 6337 $('#swipebox-arrows').addClass("swipebox-arrows--pos-center"); 6338 } 6339 }); 6340 } 6341}; 6342 6343var spoilerListItems = { 6344 init: function (){ 6345 var $btnElse = $('.js-list-spoiler-show-all'); 6346 6347 $btnElse.on("click", function (){ 6348 var $this = $(this), 6349 $items = $this.closest(".js-list-spoiler").find(".js-hide"), 6350 textHide = $this.data("text-hide"), 6351 textShow = $this.data("text-show"); 6352 6353 if($this.hasClass("-sk-open")){ 6354 $items.addClass("-sk-hide"); 6355 $this.removeClass("-sk-open"); 6356 $this.html(textShow); 6357 }else{ 6358 $items.removeClass("-sk-hide"); 6359 $this.addClass("-sk-open"); 6360 $this.html(textHide); 6361 } 6362 }); 6363 } 6364}; 6365 6366var photosImages = { 6367 init: function (){ 6368 var _this = this; 6369 6370 _this.photosList(); 6371 }, 6372 photosList: function() { 6373 var _this = this; 6374 6375 $('.js-photos-list').each(function (){ 6376 var $this = $(this), 6377 images = $this.find(".js-img"), 6378 imagesLoaded = $this.find(".js-img:not([data-src])"), 6379 isLazy = $this.data("lazy"), 6380 isRetina = $this.data("retina"); 6381 6382 if(isLazy){ 6383 _this.lazyImages(images, isRetina); 6384 if(isRetina){ 6385 _this.retinaImages(imagesLoaded); 6386 } 6387 }else if(isRetina){ 6388 _this.retinaImages(images); 6389 } 6390 }); 6391 }, 6392 lazyImages: function (images, isRetina){ 6393 var _this = this; 6394 6395 images.lazy({ 6396 afterLoad: function(element) { 6397 if(isRetina){ 6398 _this.retinaImages($(element)); 6399 } 6400 }, 6401 onFinishedAll: function() { 6402 var outer = images.closest(".js-wookmark"); 6403 6404 if(outer.length){ 6405 outer.trigger('append_photo_list'); 6406 } 6407 } 6408 }); 6409 }, 6410 retinaImages: function (images){ 6411 images.each(function(){ 6412 var $this = $(this), 6413 imgUrl = null; 6414 6415 if($($this).is("img")){ 6416 imgUrl = $this.attr('src'); 6417 }else{ 6418 imgUrl = $this.css("background-image").replace('url(','').replace(')','').replace(/\"/gi, ""); 6419 } 6420 6421 if(imgUrl.indexOf("@2x") == -1){ 6422 var fileExtensionWithGet = imgUrl.substring(imgUrl.lastIndexOf('.') + 1), 6423 imgUrl2x = imgUrl.replace("." + fileExtensionWithGet, "@2x." + fileExtensionWithGet); 6424 6425 $this.attr("data-at2x", imgUrl2x); 6426 if(!$($this).is("img") && $.Retina.isRetina()){ 6427 $this.css("background-image", "url("+imgUrl2x+")"); 6428 } 6429 } 6430 }).promise().done(function(){ 6431 images.retina(); 6432 }); 6433 } 6434}; 6435 6436var productPopup = { 6437 init: function (){ 6438 var _this = this; 6439 6440 if(!$('.js-products-popup').length){ 6441 return false; 6442 } 6443 6444 _this.openPopup();
6445 _this.removeItemFromPopupCart(); 6446 }, 6447 openPopup: function (){ 6448 var preview = $('.js-popup-products-link'); 6449 6450 preview.each(function(){ 6451 var $this = $(this), 6452 popup = $this.find('.js-products-popup'); 6453 6454 if(popup.length){ 6455 $this.hover(function (){ 6456 var url = $this.data('url'); 6457 6458 if(!$.trim(popup.html())){ 6459 if(!$this.hasClass('empty')){ 6460 $.get(url + '?ajax=1', function(html) { 6461 var cartContentHtml = $(html).find('.js-popup-ajax'); 6462 6463 if(cartContentHtml.length){ 6464 popup.html(html); 6465 $this.addClass('open-popup'); 6466 } 6467 }); 6468 } 6469 }else{ 6470 $this.addClass('open-popup'); 6471 } 6472 }, function (){ 6473 $this.removeClass('open-popup'); 6474 }); 6475 } 6476 }); 6477 }, 6478 removeItemFromPopupCart: function (){ 6479 $("body").on("click", ".js-cart-preview-product-delete", function(){ 6480 var row = $(this).closest('.js-cart-product'), 6481 cartWrap = $(this).closest('.js-popup-ajax'), 6482 url = cartWrap.data("url"); 6483 6484 $.post(url+'delete/', {html: 1, id: row.data('id')}, function (response) { 6485 var cartProductBtn = $('input[name="product_id"][value="'+ row.data('product-id') +'"]').closest(".js-add-to-cart").find(".js-submit-form, .js-product-card-dialog"); 6486 6487 cartProductBtn.removeClass("added"); 6488 6489 row.slideUp(); 6490 6491 $('.js-cart-preview-count').html(response.data.count); 6492 $('.js-cart-preview-total').html(response.data.total); 6493 if (response.data.count == 0) { 6494 cartWrap.closest('.js-cart-preview').find('.js-products-popup').html(""); 6495 $('.js-cart-preview').addClass('empty'); 6496 } 6497 }, "json"); 6498 }); 6499 } 6500}; 6501 6502$(function(){ 6503 main.init(); 6504 anchorLink.init(); 6505 tabs.init(); 6506 accordionTabs.init(); 6507 popupTabs.init(); 6508 images.init(); 6509 iframes.init(); 6510 mobilePopup.init(); 6511 videoPopup.init(); 6512 mobileMainMenu.init(); 6513 responsiveMenu.init(); 6514 touch.init(); 6515 form.init(); 6516 productCartPanelFixed.init(); 6517 headerFixed.init(); 6518 headerMenu.init(); 6519 skcallback.init(); /* remove method */ 6520 openMap.init(); 6521 modalForm.init(); 6522 contentPopup.init(); 6523 headerMainMenu.init(); 6524 sidebarMainMenu.init(); 6525 horizontalMainMenu.init(); 6526 categoriesImages.init(); 6527 slider.init(); 6528 countdown.init(); 6529 productsPreviewList.init(); 6530 productsCarousel.init(); 6531 promosCarousel.init(); 6532 reviewsCarousel.init(); 6533 postsCarousel.init(); 6534 spoilerWrap.init(); 6535 skusDropdown.init(); 6536 optionsInline.init(); 6537 footerDropdownMenu.init(); 6538 categorySubcategoriesLinks.init(); 6539 dropDownList.init(); 6540 searchForm.init(); 6541 subscribeForm.init(); 6542 cart.init(); 6543 popupMiniMessage.init(); 6544 productListUser.init(); 6545 ProductGallery.init(); 6546 pagesTree.init(); 6547 activeQuantityField.init(); 6548 switchVersionSite.init(); 6549 infoMessage.init($('.js-info-massage')); 6550 popupAdvert.init($('.js-popup-advert')); 6551 customGalleryPopup.init(); 6552 spoilerListItems.init(); 6553 productPreviewGallerySwipe.init(); 6554 photosImages.init(); 6555 productPopup.init(); 6556 6557 if(globalThemeSettings.isLocationSelect){ 6558 selectLang.init(); 6559 } 6560 6561 if(globalThemeSettings.isCurrencySelect){ 6562 selectCurrency.init(); 6563 } 6564 6565 if(!globalThemeSettings.isMobile){ 6566 sidebarCarousel.init(); 6567 } 6568 6569 if (globalThemeSettings.isTileGalleryProductPreview){ 6570 new productGalleryTile(); 6571 } 6572 6573 if(globalThemeSettings.isDemoSettings){ 6574 demoTest.init(); 6575 } 6576}); 6577 6578function formatDate(date_string) { 6579 var date_array = date_string.split("-"); 6580 var year = date_array[0], 6581 mount = date_array[1] - 1, 6582 day = date_array[2]; 6583 return new Date(year, mount, day); 6584} 6585 6586$.fn.elementRealWidth = function () { 6587 $clone = this.clone() 6588 .css("visibility","hidden") 6589 .appendTo($('body')); 6590 var $width = $clone.outerWidth(true); 6591 $clone.remove(); 6592 return $width; 6593};
6594 6595jQuery.fn.outerHTML = function(s) { 6596 return s 6597 ? this.before(s).remove() 6598 : jQuery("<p>").append(this.eq(0).clone()).html(); 6599}; 6600 6601function viewport() { 6602 var e = window, a = 'inner'; 6603 if (!('innerWidth' in window )) { 6604 a = 'client'; 6605 e = document.documentElement || document.body; 6606 } 6607 return { width : e[ a+'Width' ] , height : e[ a+'Height' ] }; 6608} 6609 6610function removeParam(key, sourceURL) { 6611 if(sourceURL){ 6612 var rtn = sourceURL.split("?")[0], 6613 param, 6614 params_arr = [], 6615 queryString = (sourceURL.indexOf("?") !== -1) ? sourceURL.split("?")[1] : ""; 6616 6617 if (queryString !== "") { 6618 params_arr = queryString.split("&"); 6619 for (var i = params_arr.length - 1; i >= 0; i -= 1) { 6620 param = params_arr[i].split("=")[0]; 6621 if (param === key) { 6622 params_arr.splice(i, 1); 6623 } 6624 } 6625 rtn = rtn + "?" + params_arr.join("&"); 6626 } 6627 return rtn; 6628 }else{ 6629 return ""; 6630 } 6631} 6632 6633function validateEmail(email) { 6634 var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 6635 return re.test(email); 6636} 6637 6638function truncateText(text, maxLength){ 6639 if(text && parseInt(maxLength)){ 6640 var textLength = text.length; 6641 if(textLength > parseInt(maxLength)){ 6642 var resultText = text.slice(0, maxLength); 6643 6644 return resultText + "..."; 6645 } 6646 } 6647 return text; 6648} 6649 6650$.fn.pop = function() { 6651 var top = this.get(-1); 6652 this.splice(this.length-1,1); 6653 return top; 6654}; 6655 6656$.fn.shift = function() { 6657 var bottom = this.get(0); 6658 this.splice(0,1); 6659 return bottom; 6660}; 6661 6662$.urlParam = function(url, name){ 6663 var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(url); 6664 if (results==null){ 6665 return null; 6666 }else{ 6667 return results[1] || 0; 6668 } 6669} 6670 6671$.fn.serializeObject = function() { 6672 var o = {}; 6673 var a = this.serializeArray(); 6674 $.each(a, function() { 6675 if (o[this.name]) { 6676 if (!o[this.name].push) { 6677 o[this.name] = [o[this.name]]; 6678 } 6679 o[this.name].push(this.value || ''); 6680 } else { 6681 o[this.name] = this.value || ''; 6682 } 6683 }); 6684 return o; 6685}; 6686 6687function currencyFormat (number, no_html) { 6688 // Format a number with grouped thousands 6689 // 6690 // + original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com) 6691 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 6692 // + bugfix by: Michael White (http://crestidg.com) 6693 6694 var i, j, kw, kd, km; 6695 var decimals = globalThemeSettings.currency.frac_digits; 6696 var dec_point = globalThemeSettings.currency.decimal_point; 6697 var thousands_sep = globalThemeSettings.currency.thousands_sep; 6698 6699 // input sanitation & defaults 6700 if( isNaN(decimals = Math.abs(decimals)) ){ 6701 decimals = 2; 6702 } 6703 if( dec_point == undefined ){ 6704 dec_point = ","; 6705 } 6706 if( thousands_sep == undefined ){ 6707 thousands_sep = "."; 6708 } 6709 6710 i = parseInt(number = (+number || 0).toFixed(decimals)) + ""; 6711 6712 if( (j = i.length) > 3 ){ 6713 j = j % 3; 6714 } else{ 6715 j = 0; 6716 } 6717 6718 km = (j ? i.substr(0, j) + thousands_sep : ""); 6719 kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep); 6720 //kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).slice(2) : ""); 6721 kd = (decimals && (number - i) ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : ""); 6722 6723 6724 var number = km + kw + kd; 6725 var s = no_html ? globalThemeSettings.currency.sign : globalThemeSettings.currency.sign_html; 6726 if (!globalThemeSettings.currency.sign_position) { 6727 return s + globalThemeSettings.currency.sign_delim + number; 6728 } else { 6729 return number + globalThemeSettings.currency.sign_delim + s; 6730 } 6731}; 6732 6733var MatchMedia = function( media_query ) { 6734 var matchMedia = window.matchMedia, 6735 is_supported = (typeof matchMedia === "function");
6736 if (is_supported && media_query) { 6737 return matchMedia(media_query).matches 6738 } else { 6739 return false; 6740 } 6741}; 6742 6743$.fn.isInViewport = function() { 6744 var elementTop = $(this).offset().top; 6745 var elementBottom = elementTop + $(this).outerHeight(); 6746 6747 var viewportTop = $(window).scrollTop(); 6748 var viewportBottom = viewportTop + $(window).height(); 6749 6750 return elementBottom > viewportTop && elementTop < viewportBottom; 6751};
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.