1var main = { 2 init: function () { 3 var _this = this; 4 5 _this.retinaLogo(); 6 _this.moveTop(); 7 _this.locationChange(); 8 _this.searchAuto(); 9 _this.previewCart(); 10 _this.addTouchClass(); 11 _this.numberInput(); 12 _this.showAllPlugins(); 13 14 _this.contentHeight(); 15 setTimeout(_this.contentHeight, 2000); 16 }, 17 retinaLogo: function(){ 18 var logo = $('.js-logo-retina'); 19 20 if(logo.length){ 21 logo.retina({ force_original_dimensions: false }); 22 } 23 }, 24 moveTop: function () { 25 var linkMove = $('#move-to-top'), contentTop = $('.js-content-move'); 26 27 if(contentTop.length && linkMove.length){ 28 $(window).scroll(function() { 29 var t = $(document).scrollTop(); 30 var contentTopX = contentTop.offset().top; 31 if (t >= contentTopX) { 32 linkMove.fadeIn(); 33 } else { 34 linkMove.fadeOut(); 35 } 36 }); 37 38 linkMove.click(function(event) { 39 event.preventDefault(); 40 41 $('html,body').animate({ 42 scrollTop: 0 43 }, 500); 44 }); 45 } 46 47 }, 48 locationChange: function (){ 49 $(".js-language").on("click", function (event) { 50 event.preventDefault(); 51 52 var url = location.href; 53 if (url.indexOf('?') == -1) { 54 url += '?'; 55 } else { 56 url += '&'; 57 } 58 location.href = url + 'locale=' + $(this).data("value"); 59 }); 60 }, 61 searchAuto: function (){ 62 var input = $('.js-search-auto'); 63 64 input.on("keyup", function(){ 65 var $this = $(this), 66 value = $this.val(), 67 form = $this.closest('form'), 68 url = form.attr("action"), 69 resultWrap = form.find('.js-search-auto-result'); 70 71 if(value.length > 3){ 72 $.get(url + '?query='+value+'&ajax=1', function(data) { 73 var content = $(data).find('.js-auto-search'); 74 75 resultWrap.html(""); 76 if(content.length){ 77 resultWrap.show(); 78 resultWrap.html(content); 79 }else{ 80 resultWrap.hide(); 81 } 82 }); 83 } 84 }); 85 86 $('body').click(function (e) { 87 var popup = $(".js-search-auto-result"); 88 if (!$('.js-search-auto').is(e.target) && !popup.is(e.target) && popup.has(e.target).length == 0) { 89 popup.hide(); 90 } 91 }); 92 }, 93 previewCart: function(){ 94 var _this = this, 95 preview = $('.js-preview-cart'); 96 97 preview.each(function(){ 98 var $this = $(this), 99 popup = $this.find('.js-cart-popup'); 100 101 if(popup.length){ 102 $this.hover(function (){ 103 var url = $this.data('url'); 104 105 popup.html(""); 106 $.get(url + '?ajax=1', function(html) { 107 var cartContentHtml = $(html).find('.js-cart-ajax'); 108 109 if(cartContentHtml){ 110 popup.html(html); 111 } 112 }); 113 }); 114 } 115 }); 116 }, 117 addTouchClass: function(){ 118 if(is_touch_device()){ 119 $('body').removeClass('no-touch').addClass('touch'); 120 } 121 }, 122 numberInput: function (){ 123 $('body').on("keyup", ".js-number", function(){ 124 var reg_number = /[^0-9]/g; 125 126 $(this).val($(this).val().replace(reg_number, '')); 127 }); 128 }, 129 contentHeight: function (){ 130 var content = $('.js-content'), 131 left = $('.js-left-sidebar'), 132 right = $('.js-right-sidebar'), 133 contentPadding = parseInt(content.css('padding-top')) + parseInt(content.css('padding-bottom')); 134 135 content.css("min-height", "0"); 136 if(content.length && left.length){ 137 var contentHeight = content.outerHeight(); 138 var leftHeight = left.outerHeight(); 139 140 if(contentHeight < leftHeight){ 141 content.css("min-height", (parseFloat(leftHeight) - contentPadding - 2) + "px"); 142 } 143 } 144 145 if(content.length && right.length){ 146 var contentHeight = content.outerHeight(); 147 var rightHeight = right.outerHeight(); 148 149 if(contentHeight < rightHeight){ 150 content.css("min-height", (parseFloat(rightHeight) - contentPadding - 2) + "px"); 151 } 152 } 153 }, 154 showAllPlugins: function (){ 155 var wrap = $('.js-nav-sidebar-wrap'); 156 157 wrap.each(function(){ 158 if($(this).find(".menu-v li:hidden").length){
159 btn = $(this).find('.js-nav-sidebar-show'); 160 btn.removeClass('hide'); 161 162 btn.on("click", function(){ 163 var hideElements = $(this).closest('.js-nav-sidebar-wrap').find(".menu-v li:hidden, .menu-v li.show"); 164 165 hideElements.toggleClass("show"); 166 $(this).find('.js-icon-plus, .js-icon-minus').toggleClass("hide"); 167 }); 168 } 169 }); 170 }, 171}; 172 173var tabs = { 174 init: function (){ 175 var _this = this; 176 177 _this.initSelectTab(); 178 _this.selectTab(); 179 _this.moveToTabContent(); 180 }, 181 selectTab: function(){ 182 var button = $('.js-tab'), content = $('.js-tab-content'); 183 184 button.on("click", function(){ 185 var $this = $(this), 186 contentWrapId = $this.data('tab-content'); 187 188 button.removeClass('selected'); 189 content.removeClass('selected'); 190 191 $this.addClass('selected'); 192 $('#' + contentWrapId).addClass('selected'); 193 }); 194 }, 195 moveToTabContent: function (){ 196 var btnMoveToTab = $('.js-move-to-tab'), 197 content = $('.js-tab-content'); 198 199 btnMoveToTab.on("click", function(event){ 200 event.preventDefault(); 201 202 var $this = $(this), 203 tab = $('.js-tab'), 204 currentTabContent = $('#' + $this.data('tab-content')), 205 thisTfb = $('.js-tab[data-tab-content="'+$this.data('tab-content')+'"]'); 206 207 tab.removeClass('selected'); 208 thisTfb.addClass('selected'); 209 content.removeClass('selected'); 210 currentTabContent.addClass('selected'); 211 212 var top = currentTabContent.offset().top - 50; 213 $('html,body').animate({ 214 scrollTop: top 215 }, 500); 216 }); 217 }, 218 initSelectTab: function (){ 219 var tabsWrap = $('.js-tabs'); 220 221 if(tabsWrap.length){ 222 tabsWrap.each(function (){ 223 var $this = $(this), 224 selectedTab = $this.find('.selected'); 225 226 if(!selectedTab.length){ 227 selectedTab = $this.find('.js-tab:first'); 228 } 229 230 if(selectedTab.length){ 231 var tabContent = $('#' + selectedTab.data('tab-content')); 232 233 if(tabContent.length){ 234 selectedTab.addClass('selected'); 235 tabContent.addClass('selected'); 236 } 237 } 238 }); 239 } 240 } 241}; 242 243var accordionTabs = { 244 init: function (){ 245 var _this = this; 246 247 _this.initSelectTab(); 248 _this.selectTab(); 249 _this.moveToTabContent(); 250 }, 251 selectTab: function (){ 252 var button = $('.js-accordion-tab'); 253 254 button.on("click", function(){ 255 var $this = $(this), 256 contentWrapId = $this.data('tab-content'), 257 currentContent = button.closest('.js-accordion-tabs-outer').find('#' + contentWrapId); 258 259 if(currentContent.is(':visible')){ 260 $this.removeClass('selected'); 261 currentContent.removeClass('selected'); 262 }else{ 263 $this.addClass('selected'); 264 currentContent.addClass('selected'); 265 } 266 }); 267 }, 268 moveToTabContent: function (){ 269 var btnMoveToTab = $('.js-move-to-tab'); 270 271 btnMoveToTab.on("click", function(event){ 272 event.preventDefault(); 273 274 var $this = $(this), 275 currentTabContent = $('#' + $this.data('tab-content')), 276 tabsOuterWrap = currentTabContent.closest(".js-accordion-tabs-outer"), 277 thisTfb = tabsOuterWrap.find('.js-accordion-tab[data-tab-content="'+$this.data('tab-content')+'"]'); 278 279 thisTfb.addClass('selected'); 280 currentTabContent.addClass('selected'); 281 282 var top = currentTabContent.offset().top - 40; 283 $('html,body').animate({ 284 scrollTop: top 285 }, 500); 286 }); 287 }, 288 initSelectTab: function (){ 289 var tabsWrapOuter = $('.js-accordion-tabs-outer'); 290 291 if(tabsWrapOuter.length){ 292 tabsWrapOuter.each(function (){ 293 var $this = $(this), 294 selectedTab = $this.find('.js-accordion-tab.selected'); 295 296 if(!selectedTab.length){ 297 selectedTab = $this.find('.js-accordion-tab:first'); 298 299 if(selectedTab.length){ 300 var tabContent = tabsWrapOuter.find('#' + selectedTab.data('tab-content')); 301 302 if(tabContent.length){ 303 selectedTab.addClass('selected'); 304 tabContent.addClass('selected'); 305 } 306 } 307 } 308 }); 309 } 310 } 311}; 312 313var form = { 314 init: function (){ 315 var _this = this; 316 317 _this.formStyler(); 318 _this.submit(); 319 }, 320 formStyler: function (){ 321 $('input[type="checkbox"], input[type="radio"], .js-select').styler(); 322 $('.searchpro__page-filters input[type="checkbox"], .searchpro__page-filters input[type="radio"], .searchpro__page-filters .js-select').styler('destroy'); 323 324 $('body').on('change', 'input[type="checkbox"]', function() { 325 if ($(this).is(':checked')) { 326 $(this).closest('.jq-checkbox').addClass('checked'); 327 $(this).closest('label').addClass('checked'); 328 } else { 329 $(this).closest('.jq-checkbox, label').removeClass('checked'); 330 $(this).closest('label').removeClass('checked'); 331 } 332 }); 333 334 $('body').on('change', 'input[type="radio"]', function() { 335 var inputs = $('input[type="radio"][name="'+$(this).attr('name')+'"]'); 336 inputs.each(function(){ 337 var input = $(this); 338 if (input.is(':checked')) { 339 input.closest('.jq-radio').addClass('checked'); 340 input.closest('label').addClass('checked'); 341 }else{ 342 input.closest('.jq-radio').removeClass('checked'); 343 input.closest('label').removeClass('checked'); 344 } 345 }); 346 347 }); 348 }, 349 submit: function (){ 350 $('body').on("click", ".js-submit-form", function (){ 351 var $this = $(this), 352 form = $this.closest("form"); 353 354 if(!$this.hasClass('disabled')){ 355 form.submit(); 356 } 357 }); 358 } 359}; 360 361var selectList = { 362 init: function (){ 363 var _this = this; 364 365 $('body').on("click", '.js-select-toggle', function(){ 366 var items = $(this).closest('.js-select-list').find('.js-select-items'); 367 368 if(items.is(':visible')){ 369 items.hide(); 370 }else{ 371 items.show(); 372 } 373 }); 374 375 $('body').on("click", '.js-select-toggle a', function(event){ 376 event.preventDefault(); 377 }); 378 379 } 380}; 381 382var menu = { 383 init: function (){ 384 var _this = this; 385 386 _this.responsiveMenu(); 387 _this.resizeMenu(); 388 _this.headerMenuHover(); 389 _this.sidebar(); 390 }, 391 responsiveMenu: function(){ 392 var _this = this, items = $(".js-resp-nav"); 393 394 jQuery.each(items, function(){ 395 _this.responsived($(this)); 396 }); 397 }, 398 resizeMenu: function(){ 399 var _this = this; 400 401 $(window).resize(function() { 402 _this.responsiveMenu(); 403 }); 404 }, 405 responsived: function(menu){ 406 var _this = this, 407 menuWidth = menu.width(), 408 menuItems = menu.children('.js-resp-nav-el'), 409 ItemElse = menu.find('.js-resp-nav-else'), 410 ItemElseWidth = parseFloat(ItemElse.removeClass('hide').outerWidth(true)), 411 submenuElse = ItemElse.find('.js-resp-subnav-else'), 412 allItemsWidth = 0; 413 414 ItemElse.addClass('hide'); 415 submenuElse.html(""); 416 menuItems.removeClass('hide'); 417 418 jQuery.each(menuItems, function(){ 419 var $this = $(this), 420 elWidth = parseFloat($this.outerWidth(true)); 421 422 if((allItemsWidth + elWidth + ItemElseWidth) > menuWidth){ 423 ItemElse.removeClass('hide'); 424 $this.clone().appendTo(submenuElse); 425 $this.addClass('hide'); 426 } 427 allItemsWidth += $this.outerWidth(true); 428 }); 429 }, 430 headerMenuHover: function (){ 431 var headerMenu = $('#header-nav'), 432 mobileBtnShowHideMenu = $('.js-nav-btn[data-id="'+headerMenu.attr("id")+'"]'), 433 item = $('.js-header-nav-el'); 434 435 if(!mobileBtnShowHideMenu.is(':visible')){ 436 item.hover(function(){ 437 438 var $this = $(this), 439 subMenuWrap = $this.children('.js-header-nav-sub'); 440 441 subMenuWrap.css("padding-top", "15px"); 442 subMenuWrap.css("opacity", "0"); 443 subMenuWrap.show(); 444 subMenuWrap.animate({ paddingTop: "0" , opacity: 1}, 300 ); 445 446 },function(){ 447 var $this = $(this), 448 subMenuWrap = $this.children('.js-header-nav-sub'); 449 450 subMenuWrap.hide(); 451 }); 452 } 453 }, 454 sidebar: function (){ 455 var _this = this; 456 457 _this.sidebarInit(); 458 459 var openBtn = $('.js-menu-v-open'); 460 461 openBtn.click(function(){ 462 var $this = $(this), subs = $($this.parent().find('.js-menu-v-submenu')[0]); 463 464 if(!subs.is(':visible')){ 465 subs.show(); 466 $this.addClass('selected'); 467 }else{ 468 subs.hide(); 469 $this.removeClass('selected'); 470 } 471 }); 472 }, 473 sidebarInit: function (){ 474 var treeCats = $('.js-sidebar-menu'), 475 currentCat = treeCats.find('.selected'), 476 outWrap = currentCat.parents(".js-menu-v-submenu"); 477 478 outWrap.removeClass('hide'); 479 outWrap.each(function(){ 480 $(this).parent().find('.js-menu-v-open').first().addClass('selected'); 481 }); 482 } 483}; 484 485var slider = { 486 init: function (){ 487 var _this = this, 488 slider = $('.js-main-slider'), 489 pause = parseInt(slider.data("pause")) * 1000, 490 auto = (pause) ? true : false;
491 492 var params = { 493 loop: true, 494 margin: 0, 495 nav: true, 496 lazyLoad: true, 497 autoHeight: true, 498 items:1, 499 mouseDrag: false, 500 navText: ['', ''], 501 onTranslate: function(){ 502 slider.addClass("_switch"); 503 }, 504 onLoadedLazy: function (data){ 505 if (slider.data('type') == "product"){ 506 data.element.retina(); 507 } 508 } 509 }; 510 511 if(auto){ 512 params["autoplay"] = true; 513 params["autoplayTimeout"] = pause; 514 params["autoplayHoverPause"] = true; 515 } 516 517 if(slider.data('type') == "promo-image"){ 518 var src = slider.find("img").attr("src"); 519 $("<img>").attr("src", src).load(function() { 520 slider.owlCarousel(params); 521 }); 522 }else{ 523 slider.owlCarousel(params); 524 } 525 526 $('.js-main-slider .owl-prev, .js-main-slider .owl-next, .js-main-slider owl-dot').on('click', function(e) { 527 $('.js-main-slider').trigger('stop.owl.autoplay'); 528 }); 529 } 530}; 531 532var photoGallery = { 533 init: function (){ 534 var _this = this; 535 536 var slider = $('.js-sidebar-photos').bxSlider({ 537 nextText: '', 538 prevText: '', 539 pager: false, 540 responsive: true, 541 auto: true, 542 pause: 6500, 543 autoHover: true, 544 speed: 400, 545 useCSS: false, 546 /*auto: true, 547 mode: 'fade', // for fade out 548 captions: true*/ 549 onSliderLoad: function(currentIndex){ 550 $(".js-sidebar-photos .bx-next, .js-sidebar-photos .bx-prev, .js-sidebar-photos .bx-pager-item").click(function(){ 551 slider.stopAuto(); 552 }); 553 } 554 }); 555 } 556}; 557 558var modalForm = { 559 init: function (){ 560 var _this = this; 561 562 _this.loadContentForm('a.js-form-popup'); 563 _this.loadContentForm('.js-ajax-form a[href="/login/"]'); 564 _this.loadContentForm('.js-ajax-form a[href="/forgotpassword/"]'); 565 _this.submitForm(); 566 }, 567 loadContentForm : function (selectorBtnElement){ 568 var _this = this; 569 var selectorContent = '.js-ajax-form'; 570 571 $('body').on("click", selectorBtnElement, function (event){ 572 event.preventDefault(); 573 var url = $(this).attr('href')+"?ajax=1"; 574 575 $.magnificPopup.close(); 576 $('body').prepend("<div class='js-loading-bg mfp-bg mfp-ready'><div class='mfp-preloader'></div></div>"); 577 578 $.get(url, function(data) { 579 $('.js-loading-bg').remove(); 580 581 var content = $(data).find(selectorContent); 582 _this.openModal(content, url); 583 }); 584 }); 585 }, 586 openModal: function (content, url){ 587 var _this = this; 588 589 $(content).find('form').attr("action", url); 590 $(content).find('input[type="checkbox"], input[type="radio"], .js-select').styler(); 591 592 593 $.magnificPopup.open({ 594 items: { 595 src: "<div class='popup-content'>"+content.outerHTML()+"</div>" 596 }, 597 type: 'inline' 598 }, 0); 599 600 }, 601 602 submitForm: function(){ 603 var _this = this; 604 605 $('body').on("submit", '.js-ajax-form form', function(event){ 606 var wrapForm = $(this).closest('.js-ajax-form'); 607 608 if (!wrapForm.find('.wa-login-form-wrapper').length && !wrapForm.find('.wa-forgotpassword-form-wrapper').length) { 609 event.preventDefault(); 610 611 var url = $(this).attr("action"), 612 data = $(this).serialize(), 613 btn = $(this).find('input[type="submit"]'); 614 615 btn.hide(); 616 btn.after($('<i class="icon16 loading js-loading"></i>')); 617 618 $.post(url, data, function(data){ 619 var content = $(data).find('.js-ajax-form'); 620 if(content.length > 0){ 621 _this.openModal(content, url); 622 btn.show(); 623 $(this).find(".js-loading").remove(); 624 }else{ 625 window.location.reload(); 626 } 627 }); 628 } 629 }); 630 } 631 632}; 633 634var dropDownWrap = { 635 init: function (){ 636 var _this = this; 637 638 var selectorButton = '.js-btn-drop-down', 639 selectorWrap = '.js-drop-down-wrap', 640 selectorOuter = '.js-drop-down-outer'; 641 642 $(document).click(function(event) { 643 if((!$(event.target).closest(selectorWrap).length && !$(event.target).closest(selectorOuter).length) || $(event.target).hasClass('js-bg')) { 644 $(selectorWrap).each(function (){ 645 $(this).removeClass('show'); 646 }); 647 } 648 }); 649 650 $(selectorButton).on("click", function (){ 651 var $this = $(this), 652 wrap = $('#' + $(this).data("id")); 653 654 if(wrap.is(':visible')){ 655 wrap.removeClass('show'); 656 }else{ 657 $(selectorWrap).each(function (){ 658 $(this).removeClass('show'); 659 }); 660 _this.open($this, wrap); 661 } 662 }); 663 }, 664 open: function (btn, wrap){ 665 if(wrap.is(':visible')){ 666 wrap.animate({ opacity: 0 }, 200, function() { 667 wrap.removeClass('show'); 668 } ); 669 670 btn.removeClass('active'); 671 }else{ 672 wrap.css("padding-top", "20px"); 673 wrap.css("opacity", "0"); 674 wrap.addClass('show'); 675 wrap.animate({ paddingTop: "0" , opacity: 1}, 200); 676 677 btn.addClass('active'); 678 } 679 } 680}; 681 682var categoriesMainMenu = { 683 init: function (){ 684 var _this = this; 685 686 _this.dropDownDisclosed(); 687 _this.dropDown(); 688 _this.mobileShowSubmenu(); 689 _this.showBg(); 690 _this.headerCategoriesImages(); 691 }, 692 dropDownDisclosed: function (){ 693 var _this = this; 694 695 var item = $(".js-cat-subs-disclosed"), 696 headerCategoriesMenu = $('#header-nav-categories'), 697 isHoverDelay = headerCategoriesMenu.data("delay"), 698 isLazyImages = headerCategoriesMenu.data("lazy"), 699 isRetinaImages = headerCategoriesMenu.data("retina"); 700 701 item.hover(function(){ 702 var $this = $(this), 703 submenu = $this.find('.js-submenu').first(), 704 isSubmenuAbsolute = submenu.css("position") == 'absolute', 705 isCategoriesPositionAbsolute = headerCategoriesMenu.css("position") == 'absolute', 706 catMenuWrap = $this.closest('.js-catmenu-wrap'); 707 708 if(isLazyImages){ 709 categoriesImages.lazyImages(submenu.find('.js-cat-submenu-image'), isRetinaImages); 710 }else if(isRetinaImages){ 711 categoriesImages.retinaImages(submenu.find('.js-cat-submenu-image')); 712 } 713 if(isSubmenuAbsolute){ 714 if(submenu.length > 0){ 715 if(isHoverDelay){ 716 submenu.stop(true).delay(150).fadeIn(1, function (){ 717 var submenuWidth = submenu.outerWidth(true); 718 if(!item.hasClass("position-relative")){ 719 catMenuWrap.css("padding-right", submenuWidth + "px"); 720 if(isCategoriesPositionAbsolute){ 721 _this.calcHeight(catMenuWrap, submenu); 722 } 723 } 724 }); 725 }else{ 726 submenu.show(); 727 var submenuWidth = submenu.outerWidth(true); 728 if(!item.hasClass("position-relative")){ 729 catMenuWrap.css("padding-right", submenuWidth + "px"); 730 if(isCategoriesPositionAbsolute){ 731 _this.calcHeight(catMenuWrap, submenu); 732 } 733 } 734 } 735 } 736 } 737 }, function(){ 738 var $this = $(this), 739 submenu = $this.find('.js-submenu').first(), 740 isSubmenuAbsolute = submenu.css("position") == 'absolute', 741 catMenuWrap = $this.closest('.js-catmenu-wrap'); 742 743 if(isSubmenuAbsolute){ 744 if(isHoverDelay){ 745 submenu.stop(true).delay(150).fadeOut(1, function (){ 746 catMenuWrap.removeAttr('style'); 747 }); 748 }else{ 749 submenu.hide(); 750 catMenuWrap.removeAttr('style'); 751 } 752 753 } 754 }); 755 }, 756 dropDown: function (){ 757 var _this = this; 758 759 var item = $(".js-cat-subs-dropdown"), 760 isHoverDelay = $('#header-nav-categories').data("delay"); 761 762 item.hover(function(){ 763 var $this = $(this), 764 submenu = $this.find('.js-submenu').first(), 765 isSubmenuAbsolute = submenu.css("position") == 'absolute', 766 isCategoriesPositionAbsolute = $('#header-nav-categories').css("position") == 'absolute', 767 catMenuWrap = $this.closest('.js-catmenu-wrap'), 768 catMenuMarginRight = 0; 769 770 if(isSubmenuAbsolute){ 771 if(submenu.length){ 772 catMenuMarginRight += 258; 773 if(isHoverDelay){ 774 submenu.stop(true).delay(150).fadeIn(1); 775 }else{ 776 submenu.show(); 777 } 778 } 779 if(!item.hasClass("position-relative")) { 780 catMenuWrap.css('margin-right', catMenuMarginRight + 'px'); 781 if(isCategoriesPositionAbsolute){ 782 _this.calcHeight(catMenuWrap, submenu); 783 } 784 } 785 } 786 }, function(){ 787 var $this = $(this), 788 submenu = $this.find('.js-submenu'), 789 isSubmenuAbsolute = submenu.css("position") == 'absolute', 790 catMenuWrap = $this.closest('.js-catmenu-wrap'); 791 792 if(isSubmenuAbsolute){ 793 if(isHoverDelay){ 794 submenu.stop(true).delay(150).fadeOut(1, function(){ 795 catMenuWrap.removeAttr('style'); 796 }); 797 }else{ 798 submenu.hide(); 799 catMenuWrap.removeAttr('style'); 800 } 801 } 802 }); 803 804 var itemSub = $('.js-subcatmenu-el'); 805 itemSub.hover(function(){ 806 var $this = $(this), 807 submenu = $this.find('.js-submenu').first(), 808 isSubmenuAbsolute = submenu.css("position") == 'absolute', 809 isCategoriesPositionAbsolute = $('#header-nav-categories').css("position") == 'absolute', 810 catMenuWrap = $this.closest('.js-catmenu-wrap'), 811 catMenuMarginRight = 518; 812 813 if(isSubmenuAbsolute){ 814 if(isHoverDelay){ 815 submenu.stop(true).delay(150).fadeIn(1, function (){ 816 if (!itemSub.hasClass("position-relative")){ 817 catMenuWrap.css('margin-right', catMenuMarginRight + 'px'); 818 if(isCategoriesPositionAbsolute){ 819 _this.calcHeight(catMenuWrap, submenu); 820 } 821 } 822 }); 823 }else{ 824 submenu.show(); 825 if (!itemSub.hasClass("position-relative")){ 826 catMenuWrap.css('margin-right', catMenuMarginRight + 'px'); 827 if(isCategoriesPositionAbsolute){ 828 _this.calcHeight(catMenuWrap, submenu); 829 } 830 } 831 } 832 } 833 }, function(){ 834 var $this = $(this), 835 submenu = $this.find('.js-submenu').first(), 836 isSubmenuAbsolute = submenu.css("position") == 'absolute', 837 catMenuWrap = $this.closest('.js-catmenu-wrap'), 838 catMenuMarginRight = 258, 839 parent = $this.closest('.js-cat-subs-dropdown'); 840 841 842 if(isSubmenuAbsolute){ 843 if(isHoverDelay){ 844 submenu.stop(true).delay(150).fadeOut(1, function (){ 845 if (!itemSub.hasClass("position-relative")) { 846 catMenuWrap.css('margin-right', catMenuMarginRight + 'px'); 847 } 848 }); 849 }else{ 850 submenu.hide(); 851 if (!itemSub.hasClass("position-relative")) { 852 catMenuWrap.css('margin-right', catMenuMarginRight + 'px'); 853 } 854 } 855 } 856 }); 857 }, 858 calcHeight: function (wrap, submenuWrap){ 859 var submenuWrapHeight = submenuWrap.outerHeight(true), 860 wrapHeight = wrap.outerHeight(true); 861 862 if(submenuWrapHeight > wrapHeight){ 863 wrap.css("height", submenuWrapHeight + 'px'); 864 } 865 }, 866 mobileShowSubmenu: function (){ 867 var caret = $('.js-catmenu-el-caret'); 868 869 caret.on("click", function(){ 870 var $this = $(this), 871 parent = $this.closest('.js-cat-subs-disclosed, .js-cat-subs-dropdown, .js-subcatmenu-el'), 872 submenu = $(parent.find('.js-submenu').first()), 873 isSubmenuStatic = (submenu.css('position') != 'absolute'); 874 875 if(isSubmenuStatic){ 876 if(!submenu.is(':visible')){ 877 submenu.show(); 878 $this.addClass('open'); 879 }else{ 880 submenu.hide(); 881 $this.removeClass('open'); 882 } 883 } 884 }); 885 }, 886 showBg: function() { 887 var menuWrap = $('#header-nav-categories.desktop-show'), 888 bg = $('#header-nav-categories.desktop-show ~ .js-bg'); 889 isHoverDelay = $('#header-nav-categories').data("delay"); 890 891 if(isHoverDelay){ 892 menuWrap.hover(function () { 893 bg.stop(true).delay(150).fadeIn(1); 894 }, function () { 895 bg.stop(true).delay(100).fadeOut(1); 896 }); 897 }else{ 898 menuWrap.hover(function () { 899 bg.show(); 900 }, function () { 901 bg.hide(); 902 }); 903 } 904 }, 905 headerCategoriesImages: function (){ 906 var headerCategoriesMenu = $('#header-nav-categories'), 907 isLazyImages = headerCategoriesMenu.data("lazy"), 908 isRetinaImages = headerCategoriesMenu.data("retina"); 909 910 if(isLazyImages){ 911 categoriesImages.lazyImages(headerCategoriesMenu.find('.js-cat-menu-image'), isRetinaImages); 912 }else if(isRetinaImages){ 913 categoriesImages.retinaImages(headerCategoriesMenu.find('.js-cat-menu-image')); 914 } 915 } 916}; 917 918var mobileMenu = { 919 init: function (){ 920 var _this = this; 921 922 _this.hideShow(); 923 _this.showSubmenu(); 924 }, 925 hideShow: function(){ 926 var _this = this, 927 btnMenuOpen = $(".js-nav-btn"); 928 929 btnMenuOpen.on("click", function(){ 930 var $this = $(this), 931 menu = $('#'+$this.data('id')); 932 933 if(menu.hasClass('show')){ 934 menu.removeClass('show'); 935 $this.removeClass('show'); 936 }else{ 937 menu.addClass('show'); 938 $this.addClass('show'); 939 } 940 }); 941 }, 942 showSubmenu: function (){ 943 var _this = this, 944 btn = $('.js-nav-caret'); 945 946 btn.on("click", function(){ 947 var item = $(this).closest('.js-resp-nav-el'); 948 949 if(item.hasClass('open')){ 950 item.removeClass('open'); 951 $(this).removeClass('open'); 952 }else{ 953 item.addClass('open'); 954 $(this).addClass('open'); 955 } 956 }); 957 } 958}; 959 960var mobileSearch = { 961 init: func
961tion (){ 962 var btn = $('.js-show-header-nav-search'), 963 form = $('.js-header-nav-search'); 964 965 btn.on("click", function (){ 966 if(form.is(":visible")){ 967 form.removeClass('show'); 968 $(this).removeClass('active'); 969 }else{ 970 form.addClass('show'); 971 $(this).addClass('active'); 972 } 973 }); 974 } 975}; 976 977var fixedPanel = { 978 init: function (){ 979 var _this = this; 980 981 var content = $("#main-content"), 982 fixedPanel = $('.js-fixed'); 983 984 if(content.length && fixedPanel.length){ 985 986 _this.fixPanel(content, fixedPanel); 987 988 $(window).scroll(function() { 989 _this.fixPanel(content, fixedPanel); 990 }); 991 992 $(window).resize(function() { 993 _this.fixPanel(content, fixedPanel); 994 }); 995 } 996 }, 997 fixPanel: function (content, fixedPanel){ 998 var t = $(document).scrollTop(); 999 var contentTopX = content.offset().top; 1000 var viewp = viewport(); 1001 1002 if (t >= contentTopX || viewp.width <= 1000) { 1003 if(!fixedPanel.is(":visible")){ 1004 fixedPanel.css("padding", "3px 0"); 1005 fixedPanel.css("bottom", "-50px"); 1006 fixedPanel.addClass("show"); 1007 fixedPanel.animate({bottom: "0"}, 200); 1008 fixedPanel.animate({"padding": "0"}, 300); 1009 } 1010 } else { 1011 fixedPanel.removeClass("show"); 1012 } 1013 } 1014}; 1015 1016var subscribeForm = { 1017 init: function (){ 1018 // MAILER app email subscribe form 1019 $('#mailer-subscribe-form input.charset').val(document.charset || document.characterSet); 1020 $('#mailer-subscribe-form').submit(function() { 1021 var form = $(this); 1022 1023 var email_input = form.find('input[name="username"]'); // => input[name="email"] after check on valid email// 1024 var email_submit = form.find('.js-submit-form'); 1025 var email_agree = form.find('input[name="agree"]'); 1026 var loader = form.find('.js-subscribe-load'); 1027 var error = false; 1028 1029 email_input.removeClass('error'); 1030 email_agree.closest('.js-subscribe-agree').removeClass('error'); 1031 1032 if(email_agree.length > 0 && !email_agree.is(':checked')){ 1033 email_agree.closest('.js-subscribe-agree').addClass('error'); 1034 error = true; 1035 } 1036 if(!email_input.val()){ 1037 email_input.addClass('error'); 1038 error = true; 1039 }else{ 1040 if(!validateEmail(email_input.val())){ 1041 email_input.addClass('error'); 1042 error = true; 1043 }else{ 1044 email_input.attr('name', 'email'); 1045 } 1046 } 1047 if(error === false){ 1048 email_submit.hide(); 1049 loader.show(); 1050 $('#mailer-subscribe-error').hide(); 1051 1052 $.post(form.attr("action"), form.serialize(), function (response) { 1053 email_input.attr('name', 'username'); 1054 if(response.status == "ok"){ 1055 $('.js-subscribe-inputs').hide(); 1056 if(response.data.html){ 1057 $('#mailer-subscribe-thankyou').html(response.data.html); 1058 } 1059 $('#mailer-subscribe-thankyou').show(); 1060 $('#mailer-subscribe-error').hide(); 1061 }else{ 1062 $('#mailer-subscribe-error').show(); 1063 } 1064 email_submit.show(); 1065 loader.hide(); 1066 }); 1067 }else{ 1068 email_input.attr('name', 'username'); 1069 } 1070 1071 1072 return false; 1073 }) 1074 } 1075}; 1076 1077var versionSite = { 1078 init: function (){ 1079 var _this = this; 1080 1081 _this.switchVersion(); 1082 _this.removeLink(); 1083 }, 1084 switchVersion: function (){ 1085 $('.js-switch-version-link').on("click", function (event){ 1086 event.preventDefault(); 1087 1088 if($.cookie("is_desktop_for_mobile")){ 1089 $.cookie("is_desktop_for_mobile", "", {path: '/', expires: 5}); 1090 }else{ 1091 $.cookie("is_desktop_for_mobile", 1, {path: '/', expires: 5}); 1092 } 1093 location.reload(); 1094 }) 1095 }, 1096 removeLink: function (){ 1097 $('.js-switch-version-remove').on("click", function (event){ 1098 event.preventDefault(); 1099 1100 $.cookie("is_hide_link_version_site", 1, {path: '/', expires: 1}); 1101 $('.js-switch-version').remove(); 1102 }) 1103 } 1104}; 1105 1106var openMap = { 1107 init: function (){ 1108 var _this = this; 1109 1110 $('.js-open-map').magnificPopup({ 1111 disableOn: 700, 1112 type: 'iframe', 1113 mainClass: 'mfp-fade', 1114 removalDelay: 160, 1115 preloader: false,
1116 fixedContentPos: false 1117 }); 1118 } 1119}; 1120 1121var tags = { 1122 init: function (){ 1123 var _this = this; 1124 1125 _this.showAll(); 1126 }, 1127 showAll: function (){ 1128 var _this = this, 1129 btn = $('.js-show-tags'); 1130 1131 btn.on("click", function (){ 1132 var $this = $(this), 1133 tags = $this.closest('.js-tags').find('.js-tag'); 1134 1135 if($this.hasClass('open')){ 1136 $this.removeClass('open'); 1137 tags.addClass("hide"); 1138 }else{ 1139 $this.addClass('open'); 1140 tags.removeClass("hide"); 1141 } 1142 }); 1143 } 1144}; 1145 1146var skCallback = { 1147 init: function (){ 1148 var _this = this; 1149 1150 _this.openModal(); 1151 _this.onTriggerClose(); 1152 }, 1153 openModal: function () { 1154 var _this = this, 1155 buttons = $('.js-sk-callback-open'), 1156 block = $('.js-sk-callback-block'); 1157 1158 if (buttons.size() && block.size()) { 1159 buttons.magnificPopup({ 1160 items: [ 1161 { 1162 src: '.js-sk-callback-block', 1163 type: 'inline' 1164 } 1165 ], 1166 midClick: true, 1167 callbacks: { 1168 open: function () { 1169 _this.closeCustomModals(); 1170 block.trigger("event-open"); 1171 }, 1172 close: function () { 1173 block.trigger("event-close"); 1174 } 1175 } 1176 }); 1177 } 1178 }, 1179 closeCustomModals: function(){ 1180 $(".js-popup").hide(); 1181 $("body").removeClass("_popup-open"); 1182 }, 1183 onTriggerClose: function () { 1184 var _this = this, 1185 block = $('.js-sk-callback-block'); 1186 1187 $(block).on("run-close", function () { 1188 $(this).find(".mfp-close").click(); 1189 }); 1190 } 1191}; 1192 1193var pagePopup = { 1194 init: function (){ 1195 var _this = this; 1196 1197 _this.loadContent(); 1198 }, 1199 loadContent: function (){ 1200 var _this = this; 1201 1202 $('body').on("click", '.js-page-popup', function (event){ 1203 event.preventDefault(); 1204 1205 var $this = $(this), 1206 href = $this.attr('href'); 1207 1208 if(!href){ 1209 href = $this.data('href'); 1210 } 1211 1212 $.magnificPopup.close(); 1213 $('body').prepend("<div class='js-loading-bg mfp-bg mfp-ready'><div class='mfp-preloader'></div></div>"); 1214 1215 $.get(href + "?popup=1", function(data) { 1216 $('.js-loading-bg').remove(); 1217 var content = false; 1218 if($(data)) { 1219 if ($(data).attr("id") == 'page-popup') { 1220 content = $(data); 1221 } else if ($(data).find('#page-popup').length) { 1222 content = $(data).find('#page-popup'); 1223 } 1224 if(content){ 1225 _this.openModal(content); 1226 }else{ 1227 location.href = href; 1228 } 1229 } 1230 }); 1231 }); 1232 }, 1233 openModal: function (content){ 1234 $.magnificPopup.open({ 1235 items: { 1236 src: "<div class='popup-content popup-content--page'>"+content.outerHTML()+"</div>" 1237 }, 1238 type: 'inline' 1239 }, 0); 1240 1241 }, 1242}; 1243 1244if (!window.SkOneclick) { 1245 1246 SkOneclick = (function ($) { 1247 1248 'use strict'; 1249 1250 var SkOneclick = function (params) { 1251 1252 this.init(params); 1253 1254 1255 }; 1256 1257 SkOneclick.prototype = { 1258 1259 _config: { 1260 buttons: '.js-sk-oneclick-open', 1261 cart: '.js-sk-oneclick-open-cart', 1262 popup: '.js-sk-oneclick-popup', 1263 block: '.js-sk-oneclick-block', 1264 content: '.js-sk-oneclick-content', 1265 close: '.js-sk-oneclick-close', 1266 preload: '.js-sk-oneclick-preload' 1267 }, 1268 1269 init: function (params) { 1270 var that = this; 1271 1272 that.params = $.extend({}, that._config, params); 1273 1274 that.initElements(); 1275 1276 if (!that.elements.block.size()) { 1277 return false;
1278 } 1279 1280 that.initButtons(); 1281 1282 1283 that.initCart(); 1284 1285 that.onClose(); 1286 1287 that.onTriggerClose(); 1288 1289 that.onEventLoading(); 1290 1291 }, 1292 1293 initElements: function () { 1294 var that = this, 1295 elements = {}; 1296 1297 elements.popup = $(that.params.popup); 1298 elements.block = elements.popup.find(that.params.block); 1299 elements.content = elements.popup.find(that.params.content); 1300 elements.close = elements.popup.find(that.params.close); 1301 elements.preload = elements.block.find(that.params.preload); 1302 1303 that.elements = elements; 1304 }, 1305 1306 initButtons: function () { 1307 var that = this, 1308 elements = that.elements; 1309 1310 $("body").on("click", that.params.buttons, function(){ 1311 var button = $(this), 1312 type = button.data("type"); 1313 1314 if(typeof type == "undefined" && type != "product" && type != "cart"){ 1315 return true; 1316 } 1317 1318 elements.preload.show(); 1319 elements.popup.show(); 1320 $("body").addClass("_popup-open"); 1321 1322 var params = { 1323 form: button.closest("form"), 1324 type: "product" 1325 }; 1326 1327 if(!params.form.size()){ 1328 console.log("ФоÑма не найдена"); 1329 return false; 1330 } 1331 1332 elements.block.trigger("event-open", params); 1333 1334 }); 1335 1336 }, 1337 1338 initCart: function(){ 1339 var that = this, 1340 elements = that.elements; 1341 1342 $("body").on("click", that.params.cart, function(){ 1343 var button = $(this), 1344 type = button.data("type"); 1345 1346 if(typeof type == "undefined" && type != "product" && type != "cart"){ 1347 return true; 1348 } 1349 1350 elements.preload.show(); 1351 elements.popup.show(); 1352 $("body").addClass("_popup-open"); 1353 1354 var params = { 1355 form: button.closest("form"), 1356 type: "cart" 1357 }; 1358 1359 if(!params.form.size()){ 1360 console.log("ФоÑма не найдена"); 1361 return false; 1362 } 1363 1364 elements.block.trigger("event-open", params); 1365 1366 }); 1367 }, 1368 1369 onClose: function(){ 1370 var that = this, 1371 elements = that.elements; 1372 1373 elements.close.on("click", function(){ 1374 elements.block.trigger("event-close"); 1375 that.closePopup() 1376 }); 1377 }, 1378 1379 onTriggerClose: function () { 1380 var that = this, 1381 block = that.elements.block; 1382 1383 block.on("run-close", function () { 1384 that.closePopup() 1385 }); 1386 }, 1387 1388 closePopup: function(){ 1389 var that = this, 1390 elements = that.elements; 1391 1392 elements.popup.hide(); 1393 elements.preload.show(); 1394 elements.content.html(""); 1395 $("body").removeClass("_popup-open"); 1396 1397 }, 1398 1399 onEventLoading: function(){ 1400 var that = this; 1401 1402 that.elements.block.on("event-load", function(object, params){ 1403 that.elements.preload.hide(); 1404 }); 1405 } 1406 1407 }; 1408 1409 return SkOneclick; 1410 1411 })(jQuery); 1412 1413} 1414 1415var cart = { 1416 init: function (){ 1417 var _this = this; 1418 1419 _this.addToCart(); 1420 _this.cartDialog(); 1421 _this.selectQuantity(); 1422 _this.countQty(); 1423 }, 1424 cartDialog: function(){ 1425 var _this = this; 1426 1427 $('body').on( "click", ".js-product-card-dialog", function (){ 1428 $.magnificPopup.open({ 1429 items: { 1430 src: $(this).data('href') 1431 }, 1432 type: 'ajax', 1433 callbacks: { 1434 ajaxContentAdded: function() { 1435 this.content.find('input[type="checkbox"], input[type="radio"], .js-select').styler(); 1436 var productCard = this.content.find('#product-cart'); 1437 if(productCard.length && productCard.data('id')){ 1438 productListCustom.viewed(productCard.data('id')); 1439 } 1440 }, 1441 open: function() { 1442 $.magnificPopup.instance._onFocusIn = function(e) { 1443 if( $(e.target).closest( '#storequickorder' ) ) { 1444 return true; 1445 } 1446 $.magnificPopup.proto._onFocusIn.call(this,e); 1447 }; 1448 } 1449 } 1450 }, 0); 1451 }); 1452 }, 1453 addToCart: function (){ 1454 var _this = this; 1455 1456 $('body').on('submit', '.js-add-to-cart', function(event){ 1457 event.preventDefault(); 1458 1459 var $this = $(this), 1460 url = $this.attr('action'), 1461 data = $this.serialize(), 1462 previewCartCount = $('.js-cart-preview-count'), 1463 previewCartTotal = $('.js-cart-preview-total'), 1464 cartDialog = $('#cart-form-dialog'), 1465 btn = $this.find(".js-submit-form"); 1466 1467 1468 1469 btn.addClass("cart-loading"); 1470 $.post(url + '?html=1', data, function (response) { 1471 btn.removeClass("cart-loading"); 1472 1473 if(response.status == 'ok'){ 1474 previewCartCount.html(response.data.count); 1475 previewCartTotal.html(response.data.total); 1476 1477 if($this.data('after-action') == 'none'){ 1478 productListCustom.showAddedMsg($('.js-preview-cart')); 1479 if(cartDialog.length > 0){ 1480 $.magnificPopup.close(); 1481 } 1482 }else if($this.data('after-action') == 'popup'){ 1483 _this.popupAddCart($this); 1484 }else{ 1485 _this.animationMoveToCart($this); 1486 if(cartDialog.length > 0){ 1487 $.magnificPopup.close(); 1488 } 1489 } 1490 }else{ 1491 messages.notifyDanger(response.errors); 1492 } 1493 }, 'json'); 1494 }); 1495 }, 1496 animationMoveToCart: function (form){ 1497 var productBlock = form.closest('.js-product').find('.js-product-cart-preview'); 1498 if(productBlock.length == 0){ 1499 productBlock = form.closest('.js-product-cart-preview'); 1500 } 1501 var position = productBlock.data('position'); 1502 var productBlockCopy = $('<div></div>').append(productBlock.html());
1503 var cart_preview = $('.js-fixed .js-preview-cart'); 1504 if(!cart_preview.length || !cart_preview.is(':visible')){ 1505 cart_preview = $('.js-header-cart'); 1506 } 1507 productBlockCopy.css({ 1508 'z-index': 100, 1509 top: productBlock.offset().top, 1510 left: productBlock.offset().left, 1511 width: productBlock.width()+'px', 1512 height: productBlock.height()+'px', 1513 position: (position) ? position :'absolute', 1514 overflow: 'hidden', 1515 background: "#FFF" 1516 }).insertAfter('body').animate({ 1517 top: cart_preview.offset().top, 1518 left: cart_preview.offset().left, 1519 width: 0, 1520 height: 0, 1521 opacity: 0.7 1522 }, 650, function() { 1523 productBlockCopy.remove(); 1524 1525 productListCustom.showAddedMsg($('.js-preview-cart')); 1526 }); 1527 }, 1528 popupAddCart: function (form){ 1529 var popup = $('#popup-addcart'), 1530 productName = form.data("name"), 1531 price = form.data("price"), 1532 image = form.data("image"), 1533 quantity = 1, 1534 quantityFileld = form.find("input[name='quantity']"); 1535 1536 1537 1538 if(quantityFileld.length){ 1539 quantity = quantityFileld.val() 1540 } 1541 1542 popup.find(".js-popup-addcart-name").html(productName); 1543 popup.find(".js-popup-addcart-price").html(price); 1544 popup.find(".js-popup-addcart-count").html("(x" + quantity + ")"); 1545 if(image){ 1546 popup.find(".js-popup-addcart-image").html( "<img src='" + image + "' />"); 1547 }else{ 1548 popup.find(".js-popup-addcart-image").html(""); 1549 } 1550 1551 $.magnificPopup.open({ 1552 items: { 1553 src: popup, 1554 type: 'inline' 1555 }, 1556 callbacks: { 1557 afterClose: function (){ 1558 console.log(1); 1559 popup.find(".js-popup-addcart-name").html(""); 1560 popup.find(".js-popup-addcart-price").html(""); 1561 popup.find(".js-popup-addcart-count").html(""); 1562 popup.find(".js-popup-addcart-image").html(""); 1563 } 1564 } 1565 1566 }); 1567 $('.js-close-popup-addcart').on("click", function (){ 1568 $.magnificPopup.close(); 1569 }); 1570 }, 1571 selectQuantity: function (){ 1572 var _this = this; 1573 1574 $('body').on("click", '.js-pr-count-action', function(){ 1575 var $this = $(this), 1576 action = $this.data('action'), 1577 wrap = $this.closest('.js-pr-count'), 1578 inputQuantity = wrap.find('input'), 1579 quantity = inputQuantity.val(); 1580 1581 if(action == 'add'){ 1582 inputQuantity.val(parseInt(quantity) + 1); 1583 }else{ 1584 if(quantity > 1){ 1585 inputQuantity.val(parseInt(quantity) - 1); 1586 } 1587 } 1588 inputQuantity.change(); 1589 }); 1590 }, 1591 countQty: function (){ 1592 $('body').on("click", ".js-qty-action", function(){ 1593 var $this = $(this), 1594 wrapOut = $this.closest('.js-qty'), 1595 action = $this.data('type'), 1596 input = wrapOut.find('input'), 1597 currentQty = parseInt(input.val()); 1598 1599 if(action == "-"){ 1600 if(currentQty > 1 ){ 1601 currentQty--; 1602 }else{ 1603 currentQty = 1; 1604 } 1605 }else{ 1606 if(currentQty){ 1607 currentQty++; 1608 }else{ 1609 currentQty = 1; 1610 } 1611 } 1612 1613 input.val(currentQty); 1614 input.change(); 1615 }); 1616 } 1617 1618}; 1619 1620var messages = { 1621 1622 notifySuccess: function(text, offset){ 1623 if(!text) text = 'Sent!'; 1624 $.notify({ 1625 message: text, 1626 icon: 'fa fa-check' 1627 },{ 1628 delay: 5000, 1629 type: 'success', 1630 placement: { 1631 align: "right", 1632 from: 'bottom' 1633 } 1634 }); 1635 }, 1636 notifyRemoveElement: function(text){ 1637 if(!text) text = 'Deleted!'; 1638 $.notify({ 1639 message: text 1640 },{ 1641 delay: 5000, 1642 placement: { 1643 align: "right", 1644 from: 'bottom' 1645 } 1646 }); 1647 }, 1648 notifyDanger: function(text){ 1649 if(!text) text = 'An error has occurred!'; 1650 $.notify({ 1651 message: text, 1652 icon: 'fa fa-exclamation-circle' 1653 },{ 1654 delay: 5000, 1655 type: 'danger', 1656 placement: { 1657 align: "right", 1658 from: 'bottom' 1659 } 1660 }); 1661 } 1662 1663}; 1664 1665var specialProducts = { 1666 init: function (){ 1667 var _this = this; 1668 1669 $('.js-special-list').bxSlider({ 1670 slideWidth: 244, 1671 minSlides: 1, 1672 maxSlides: 5, 1673 slideMargin: 15, 1674 moveSlides: 1, 1675 pager: false, 1676 nextText: '', 1677 prevText: '', 1678 infiniteLoop: false, 1679 hideControlOnEnd: true 1680 1681 }); 1682 } 1683}; 1684 1685var productTile = { 1686 init: function (){ 1687 var product = $('.no-touch .js-product-tile'), timeOut; 1688 1689 product.hover(function(){ 1690 var $this = $(this), 1691 prevProduct = $this.prev(), 1692 btnActions = $this.find('.js-action'), 1693 dialog = $this.find('.js-dialog'); 1694 1695 btnActions.css({marginTop: "15px", opacity: 0}); 1696 1697 if(prevProduct.length && $this.offset().top == prevProduct.offset().top){ 1698 prevProduct.addClass('next-hover'); 1699 } 1700 1701 $this.addClass('hover'); 1702 btnActions.first().show(); 1703 btnActions.first().animate({ marginTop: "0", opacity: 1}, 300 ); 1704 timeOut = setTimeout(function(){ 1705 btnActions.last().show(); 1706 btnActions.last().animate({ marginTop: "0", opacity: 1}, 150 ); 1707 }, 150); 1708 1709 dialog.fadeIn(); 1710 1711 var img = $this.find('.js-product-preview-img'); 1712 img.animate({maxHeight: "100%", maxWidth: "100%"}, 150); 1713 1714 }, function (){ 1715 var $this = $(this), 1716 prevProduct = $this.prev(), 1717 btnActions = $this.find('.js-action'), 1718 dialog = $this.find('.js-dialog'); 1719 1720 clearTimeout(timeOut); 1721 prevProduct.removeClass('next-hover'); 1722 $this.removeClass('hover'); 1723 btnActions.first().stop(); 1724 btnActions.last().stop(); 1725 btnActions.hide(); 1726 dialog.hide(); 1727 1728 var img = $this.find('.js-product-preview-img'); 1729 img.stop(); 1730 img.removeAttr("style"); 1731 1732 }); 1733 } 1734}; 1735 1736var productListCustom = { 1737 init: function() { 1738 var _this = this; 1739 1740 _this.compare(); 1741 _this.favorites(); 1742 _this.clear(); 1743 _this.viewed(); 1744 }, 1745 viewed: function($productId){ 1746 var _this = this; 1747 1748 if($('#product-cart').length && $('#product-cart').data('id')){ 1749 _this.add('viewed_list', $('#product-cart').data('id'), 20); 1750 } 1751 }, 1752 compare: function(){ 1753 var _this = this; 1754 1755 _this.list( 1756 'shop_compare', 1757 $(".js-preview-compare"), 1758 '.js-add-to-compare', 1759 compareProductSidebar.list 1760 ); 1761 }, 1762 favorites: function(){ 1763 var _this = this; 1764 1765 _this.list( 1766 'favorites_list', 1767 $(".js-preview-favorite"), 1768 '.js-add-to-favorites' 1769 ); 1770 }, 1771 list: function (listName, listPreviewWrap, elAddToListBtn, callbackFunction){ 1772 var _this = this; 1773 1774 $("body").on('click', elAddToListBtn, function (event) { 1775 event.preventDefault(); 1776 var $this = $(this), 1777 countInList = 0, 1778 isAdded = true, 1779 countPreviewView = listPreviewWrap.find('.js-products-list-count'), 1780 linPreviewView = listPreviewWrap.find('.js-products-list-link'), 1781 productId = $(this).data('product'); 1782 1783 if (!$this.hasClass('active')) { 1784 countInList = _this.add(listName, productId); 1785 } else { 1786 countInList = _this.remove(listName, productId); 1787 isAdded = false;
1788 } 1789 var url = (countInList > 0) ? linPreviewView.attr('href').replace(/compare\/.*$/, 'compare/' + _this.get(listName) + '/') : '/compare/'; 1790 1791 linPreviewView.attr('href', url); 1792 countPreviewView.html(countInList); 1793 1794 if(isAdded){ 1795 _this.showAddedMsg(listPreviewWrap); 1796 } 1797 1798 $(elAddToListBtn + "[data-product='"+productId+"']").toggleClass('active'); 1799 1800 if(callbackFunction){ 1801 callbackFunction({that: $this, url: url, productId: productId, isAdded: isAdded}); 1802 } 1803 }); 1804 }, 1805 add: function(listName, productId, limit){ 1806 var _this = this, list = $.cookie(listName), listArr = []; 1807 1808 if (list && list != "null" && list != "0" ) { 1809 list = list.replace(",null", ""); 1810 list = list.replace(",0", ""); 1811 var listArr = list.split(','); 1812 1813 var i = $.inArray(productId + '', listArr); 1814 if (i != -1) { 1815 listArr.splice(i, 1); 1816 } 1817 } 1818 listArr.unshift(productId); 1819 1820 if(limit){ 1821 listArr.splice(limit); 1822 } 1823 1824 _this.save(listArr, listName); 1825 1826 return listArr.length; 1827 }, 1828 remove: function(listName, productId){ 1829 var _this = this, list = $.cookie(listName); 1830 1831 if (list) { 1832 list = list.split(','); 1833 } else { 1834 list = []; 1835 } 1836 var i = $.inArray(productId + '', list); 1837 if (i != -1) { 1838 list.splice(i, 1); 1839 } 1840 1841 _this.save(list, listName); 1842 1843 return list.length; 1844 }, 1845 get: function(listName){ 1846 return $.cookie(listName); 1847 }, 1848 save: function(list, listName){ 1849 if (list.length > 0) { 1850 for(var i = 0; i < list.length; i ++){ 1851 if (!parseInt(list[i])){ 1852 list.splice(i, 1); 1853 } 1854 } 1855 } 1856 if (list.length > 0) { 1857 $.cookie(listName, list.join(','), { expires: 30, path: '/'}); 1858 } else { 1859 $.cookie(listName, null, {path: '/'}); 1860 } 1861 }, 1862 clear: function (){ 1863 var _this = this, btn = $('.js-clear-pr-list'); 1864 1865 btn.on("click", function (){ 1866 var $this = $(this), 1867 list = [], 1868 listName = $this.data("list") + "_list"; 1869 1870 _this.save(list, listName); 1871 location.reload(); 1872 1873 }); 1874 }, 1875 showAddedMsg: function(listPreviewWrap){ 1876 listPreviewWrap.addClass('active'); 1877 setTimeout(function(){ 1878 listPreviewWrap.removeClass('active'); 1879 }, 3000); 1880 } 1881}; 1882
1883var compareProductSidebar = { 1884 list: function(params){ 1885 var $this = params.that, 1886 url = params.url, 1887 productId = params.productId, 1888 isAdded = params.isAdded, 1889 productsFullWrap = $('.js-compare-products-full'), 1890 productsEmptyWrap = $('.js-compare-products-empty'), 1891 productsList = $('.js-compare-products-list'), 1892 template = $('.js-compare-template'); 1893 1894 $('.js-sidebar-compare-link').attr("href", url); 1895 1896 if(!isAdded){ 1897 var product = $('.js-compare-product[data-product="'+productId+'"]'); 1898 product.remove(); 1899 }else{ 1900 if(productsList.length && $this.data('name') && template){ 1901 var addedProduct = template.clone(); 1902 addedProduct.removeClass('js-compare-template').addClass('js-compare-product'); 1903 addedProduct.attr("data-product", productId); 1904 addedProduct.find('.js-add-to-compare').attr("data-product", productId).addClass('active'); 1905 addedProduct.find('.js-compare-name').text($this.data('name')); 1906 addedProduct.find('.js-compare-name').attr("href", $this.data('url')); 1907 addedProduct.find('.js-compare-img').attr("href", $this.data('url')); 1908 if($this.data('img')){ 1909 addedProduct.find('.js-compare-img').html("<img src='"+$this.data('img')+"'>"); 1910 } 1911 template.after(addedProduct); 1912 addedProduct.show(); 1913 } 1914 } 1915 1916 if($('.js-compare-product').length){ 1917 productsEmptyWrap.hide(); 1918 productsFullWrap.show(); 1919 }else{ 1920 productsEmptyWrap.show(); 1921 productsFullWrap.hide(); 1922 } 1923 } 1924}; 1925 1926var productCarousel = { 1927 init: function (){ 1928 var _this = this; 1929 1930 var caruselList = $(".js-product-carusel"); 1931 1932 if(caruselList.length){ 1933 caruselList.each(function(){ 1934 _this.carousel($(this)); 1935 }); 1936 } 1937 }, 1938 carousel: function (carouselProducts){ 1939 var _this = this; 1940 1941 carouselProducts.removeClass("active"); 1942 carouselProducts.parent().find('.js-carusel-more').remove(); 1943 carouselProducts.addClass("product-carusel"); 1944 carouselProducts.after('<span class="carusel_more js-carusel-more"></span>'); 1945 1946 var products = carouselProducts.find('.js-product-tile'); 1947 products.removeClass('hide'); 1948 if(products.length){ 1949 var firstProduct = products.first(), 1950 firstProductOffsetTop = firstProduct.offset().top, 1951 countLine = carouselProducts.data("count-line") ? parseInt(carouselProducts.data("count-line")) : 1, 1952 indexLine = 0, 1953 prevProductOffsetTop = 0, 1954 countInLine = 0; 1955 1956 products.each(function(){ 1957 var currentProduct = $(this), 1958 currentProductOffsetTop = currentProduct.offset().top; 1959 1960 if(currentProductOffsetTop != prevProductOffsetTop){ 1961 indexLine++; 1962 } 1963 1964 if (indexLine == 1){ 1965 countInLine++; 1966 } 1967 1968 if(firstProductOffsetTop < currentProductOffsetTop && indexLine <= countLine){ 1969 firstProductOffsetTop = currentProductOffsetTop; 1970 } 1971 1972 if(firstProductOffsetTop < currentProductOffsetTop && countInLine > 2){ 1973 currentProduct.addClass("hide"); 1974 carouselProducts.addClass("active"); 1975 } 1976 prevProductOffsetTop = currentProductOffsetTop; 1977 }); 1978 _this.showElements(carouselProducts, countInLine); 1979 } 1980 }, 1981 showElements: function (carouselProducts, countInLine){ 1982 var btnShowMore = carouselProducts.parent().find('.js-carusel-more'); 1983 1984 btnShowMore.on("click", function(){ 1985 var products = carouselProducts.find('.js-product-tile'); 1986 var productsHide = carouselProducts.find('.js-product-tile.hide'); 1987 1988 var index = 0; 1989 productsHide.each(function(){ 1990 var currentProduct = $(this); 1991 1992 if (index < countInLine){ 1993 currentProduct.removeClass("hide"); 1994 currentProduct.find(".js-product-preview-img").removeAttr("height").removeAttr("width"); 1995 } 1996 1997 index++; 1998 }); 1999 2000 var currentProductsHide = carouselProducts.find('.js-product-tile.hide'); 2001 if(currentProductsHide.length){ 2002 carouselProducts.addClass("active"); 2003 }else{ 2004 carouselProducts.removeClass("active"); 2005 } 2006 2007 if (typeof $.autobadgeFrontend !== 'undefined') { 2008 $.autobadgeFrontend.reinit(); 2009 } 2010 }); 2011 } 2012}; 2013 2014var videoPopup = { 2015 init: function(){ 2016 $("body").on("click", '.js-video-popup', function(e){ 2017 e.preventDefault(); 2018 var href = $(this).data("href"); 2019 2020 if(href){ 2021 $.magnificPopup.open({ 2022 items: { 2023 src: href 2024 }, 2025 type: 'iframe', 2026 mainClass: 'mfp-fade', 2027 removalDelay: 160, 2028 preloader: false,
2029 fixedContentPos: false, 2030 iframe: { 2031 patterns: { 2032 youtube_short: { 2033 index: 'youtu.be/', 2034 id: 'youtu.be/', 2035 src: '//www.youtube.com/embed/%id%?autoplay=1' 2036 } 2037 } 2038 } 2039 }, 0); 2040 } 2041 }); 2042 }, 2043}; 2044 2045/* 2046 * ÐнÑоÑмаÑионное ÑообÑение 2047 */ 2048var infoMessage = { 2049 init: function (container) { 2050 var _this = this; 2051 2052 if(!container.length){ 2053 return false; 2054 } 2055 2056 if(_this.checkOpen(container)){ 2057 _this.runOpen(container); 2058 _this.onClose(container); 2059 } 2060 }, 2061 checkOpen: function(container){ 2062 var _this = this, 2063 id = container.data('id'); 2064 2065 if(!$.cookie("info_massage_close_" + id)){ 2066 return true; 2067 } 2068 2069 return false; 2070 }, 2071 runOpen: function(container){ 2072 var _this = this; 2073 2074 container.show(); 2075 }, 2076 onClose: function(container){ 2077 var _this = this, 2078 id = container.data('id'), 2079 close = container.find('.js-info-message-close'); 2080 2081 close.on("click", function(){ 2082 container.detach(); 2083 $.cookie("info_massage_close_" + id, 1, {path: '/', expires: 365}); 2084 }); 2085 } 2086}; 2087 2088var lazyImages = { 2089 init: function () { 2090 var _this = this; 2091 2092 $('.js-image-lazy').lazy({bind: "event"}); 2093 } 2094}; 2095 2096var productsPreviewList = { 2097 init: function () { 2098 var _this = this, 2099 productList = $('.js-preview-products'); 2100 2101 productList.each(function(){ 2102 _this.images($(this)); 2103 }); 2104 }, 2105 images: function (productList){ 2106 var _this = this, 2107 isRetina = productList.data('retina'), 2108 isLazy = productList.data('image-lazy'), 2109 productImage = productList.find(".js-product-preview-img"); 2110 2111 if(isLazy){ 2112 productImage.lazy({ 2113 afterLoad: function(element) { 2114 if(isRetina){ 2115 element.retina(); 2116 } 2117 new productTileGallery(); 2118 }, 2119 }); 2120 }else if(isRetina){ 2121 productImage.retina(); 2122 } 2123 }, 2124}; 2125 2126/* 2127 * ÐÐ¸Ð´Ð¶ÐµÑ Ð°ÐºÑÐ¸Ñ Ð² popup 2128 */ 2129var popupAdvert = { 2130 init: function (container){ 2131 var _this = this; 2132 2133 if(!container.length){ 2134 return false; 2135 } 2136 2137 if(_this.isNotTabu() || _this.checkOpen(container)){ 2138 _this.runLogic(container); 2139 } 2140 }, 2141 checkOpen: function(container){ 2142 var _this = this, 2143 id = container.data('id'); 2144 2145 if(!$.cookie("popup_advert_close_" + id)){ 2146 return true; 2147 } 2148 2149 return false; 2150 }, 2151 isNotTabu: function(){ 2152 var _this = this, 2153 is_tabu = $.cookie("popup_advert_tabu"); 2154 2155 if(typeof is_tabu === "undefined" && !is_tabu){ 2156 return true; 2157 } 2158 2159 return false 2160 }, 2161 runLogic: function(container){ 2162 var _this = this, 2163 time = parseInt(container.data("time")), 2164 tabu = parseInt(container.data("tabu")), 2165 id = container.data('id'); 2166 2167 if(!time){ 2168 time = 10; 2169 } 2170 if(!tabu){ 2171 tabu = 10; 2172 } 2173 setTimeout(function(){ 2174 $.magnificPopup.open({ 2175 items: { 2176 src: container, 2177 type: 'inline' 2178 }, 2179 callbacks: { 2180 open: function() { 2181 $.cookie("popup_advert_tabu", 1, {path: '/', expires: tabu}); 2182 $.cookie("widget_popup_advert_close_" + id, 1, {path: '/', expires: 365}); 2183 } 2184 } 2185 }); 2186 2187 }, time * 1000); 2188 } 2189}; 2190 2191/* 2192 * ÐÐ¸Ð´Ð¶ÐµÑ ÑоÑиалÑнÑе гÑÑÐ¿Ð¿Ñ 2193 */ 2194if (!window.SocialWidgets) { 2195 2196 var SocialWidgets = (function ($) { 2197 2198 'use strict'; 2199 2200 /** 2201 * ÐонÑÑÑÑкÑÐ¾Ñ Ð²Ð¸Ð´Ð¶ÐµÑа "СоÑиалÑнÑе гÑÑппÑ" 2202 * 2203 * @constructor SocialWidgets 2204 * 2205 * @param {Object} params паÑамеÑÑÑ 2206 */ 2207 var SocialWidgets = function (params) { 2208 this.init(params); 2209 }; 2210 2211 SocialWidgets.prototype = { 2212 _params: { 2213 container: ".js-social-widgets", 2214 timeAutoSwitch: 5000, 2215 autoSwitch: false 2216 }, 2217 2218 /** 2219 * ÐолÑÑение паÑамеÑÑов 2220 * 2221 * @method getParams 2222 * @return {Array} ÐбÑÐµÐºÑ Ñ Ð½Ð°ÑÑÑойками
2223 */ 2224 getParams: function () { 2225 return this._params; 2226 }, 2227 2228 /** 2229 * ÐолÑÑение паÑамеÑÑа 2230 * 2231 * @method getParam 2232 * @return {String} ÐбÑÐµÐºÑ Ñ Ð½Ð°ÑÑÑойками 2233 */ 2234 getParam: function (name) { 2235 return this._params[name]; 2236 }, 2237 /** 2238 * УÑÑановка паÑамеÑÑа 2239 * 2240 * @method setParam 2241 * 2242 * @param {String} name Ðаименование паÑамеÑÑов 2243 * @param {String} value ÐнаÑение паÑамеÑÑÑа 2244 * 2245 * @return {String} ÐбÑÐµÐºÑ Ñ Ð½Ð°ÑÑÑойками 2246 */ 2247 setParam: function (name, value) { 2248 this._params[name] = value; 2249 }, 2250 /** 2251 * ÐниÑиализиÑÑем плагин 2252 * 2253 * @method init 2254 * 2255 * @param {Object} params 2256 */ 2257 init: function (params) { 2258 var that = this; 2259 2260 that.autoTimer = null; 2261 2262 that._params = $.extend({}, that._params, params); 2263 that._params.preload = "switch"; 2264 2265 that.initElements(); 2266 2267 if(typeof vivaSocialWidgetsData === "undefined") return false; 2268 2269 that.data = vivaSocialWidgetsData; 2270 that.dataInst = vivaSocialWidgetsInst; 2271 2272 if(!that.elements.container.size()) return false; 2273 2274 that.active = Object.keys(that.elements.contentsArray)[0]; 2275 that.autoSwitch = that.elements.container.data("auto"); 2276 2277 if(parseInt(that.elements.container.data("time"))){ 2278 that._params.timeAutoSwitch = parseInt(that.elements.container.data("time")); 2279 } 2280 if(that.elements.container.data("preload")){ 2281 that._params.preload = that.elements.container.data("preload"); 2282 } 2283 that.initTabs(); 2284 2285 setTimeout(function(){ 2286 that.initAuto(); 2287 }, 3000) 2288 }, 2289 2290 /** 2291 * ÐниÑиализиÑÑем ÑлеменÑÑ 2292 * 2293 * @method initElements 2294 * 2295 */ 2296 initElements: function () { 2297 var that = this, 2298 elements = {}; 2299 2300 that.elements = elements; 2301 2302 elements.container = $(that._params.container); 2303 if(!elements.container.size()) return false; 2304 2305 elements.tabs = elements.container.find(".js-social-widgets-tab"); 2306 elements.tabsArray = {}; 2307 elements.tabs.each(function(){ 2308 elements.tabsArray[$(this).attr("data-tab")] = $(this); 2309 }); 2310 elements.contents = elements.container.find(".js-social-widgets-content"); 2311 elements.contentsArray = {}; 2312 elements.contents.each(function(){ 2313 elements.contentsArray[$(this).attr("data-content")] = $(this); 2314 }); 2315 that.elements = elements; 2316 }, 2317 /** 2318 * ÐниÑиализиÑÑем ÑÐ°Ð±Ñ Ð¿ÐµÑеклÑÑÐµÐ½Ð¸Ñ 2319 * 2320 * @method initTabs 2321 * 2322 */ 2323 initTabs: function () { 2324 2325 var that = this, 2326 elements = that.elements, 2327 $container = elements.container; 2328 2329 $container.hover( 2330 function() { 2331 that.pauseAuto(); 2332 }, function() { 2333 that.initAuto(); 2334 } 2335 ); 2336 for(var key in that.data){ 2337 if(typeof elements.contentsArray[key] === "undefined"){ 2338 continue; 2339 } 2340 if(key == "instagram"){ 2341 that.runInstagram(); 2342 }else{ 2343 elements.contentsArray[key].html(that.data[key]); 2344 } 2345 if(that._params.preload == "switch") break; 2346 } 2347 $container.find("[data-tab]").on("click", function(){ 2348 var $tab = $(this), 2349 socialCurrent = elements.tabs.filter("._active").attr("data-tab"), 2350 socialNew = $tab.attr("data-tab"); 2351 2352 if(socialCurrent != socialNew){ 2353 that.stopAuto(); 2354 that.switch(socialNew); 2355 } 2356 }); 2357 }, 2358 /** 2359 * ÐеÑеклÑÑение ÑоÑ.ÑеÑи 2360 * 2361 * @method switch 2362 * 2363 * @param {String} social 2364 * 2365 */ 2366 switch: function(social){ 2367 var that = this, 2368 elements = that.elements, 2369 $tab = elements.tabsArray[social], 2370 $content = elements.contentsArray[social]; 2371 2372 that.active = social; 2373 elements.tabs.removeClass("_active"); 2374 $tab.addClass("_active"); 2375 elements.contents.removeClass("_show"); 2376 2377 if(!$content.html()){ 2378 if(social == "instagram"){ 2379 that.runInstagram(); 2380 }else { 2381 $content.append(that.data[social]); 2382 } 2383 } 2384 $content.addClass("_show"); 2385 }, 2386 /** 2387 * ÐниÑиализиÑÑем авÑомаÑиÑеÑкое пеÑеклÑÑение 2388 * 2389 * @method initAuto 2390 * 2391 */ 2392 initAuto: function(){ 2393 var that = this, 2394 elements = that.elements, 2395 timeAuto = that.getParam("timeAutoSwitch"); 2396 2397 if(!that.autoSwitch) return false;
2398 2399 that.autoTimer = setInterval(function(){ 2400 var activeSocial = that.active, 2401 $nextElement = elements.tabsArray[activeSocial].next(".js-social-widgets-tab"); 2402 2403 if(!$nextElement.size()) 2404 $nextElement = elements.tabs.first(); 2405 2406 var socialNext = $nextElement.attr("data-tab"); 2407 that.active = socialNext; 2408 that.switch(socialNext) 2409 }, timeAuto); 2410 2411 }, 2412 /** 2413 * ÐниÑиализиÑÑем паÑÐ·Ñ Ð°Ð²ÑомаÑиÑеÑкого пеÑеклÑÑÐµÐ½Ð¸Ñ 2414 * 2415 * @method pauseAuto 2416 * 2417 */ 2418 pauseAuto: function(){ 2419 var that = this; 2420 2421 clearInterval(that.autoTimer); 2422 }, 2423 /** 2424 * ÐниÑиализиÑÑем оÑÑÐ°Ð½Ð¾Ð²ÐºÑ Ð°Ð²ÑомаÑиÑеÑкого пеÑеклÑÑÐµÐ½Ð¸Ñ 2425 * 2426 * @method pauseAuto 2427 * 2428 */ 2429 stopAuto: function(){ 2430 var that = this; 2431 2432 clearInterval(that.autoTimer); 2433 that.autoSwitch = false; 2434 }, 2435 2436 /** 2437 * ÐапÑÑк виджеÑа инÑÑагÑам 2438 * 2439 * @method runInstagram 2440 * 2441 */ 2442 runInstagram: function() { 2443 var that = this, 2444 id = "#social-widgets-content-instagram"; 2445 2446 $(id).html("<div id='list-instagram' class='list-instagram'></div>"); 2447 2448 if (typeof Instafeed !== "undefined" && that.dataInst){ 2449 var feed = new Instafeed({ 2450 get: 'user', 2451 userId: that.dataInst.userId, 2452 target: 'list-instagram', 2453 clientId: that.dataInst.clientId, 2454 accessToken: that.dataInst.accessToken, 2455 limit: that.dataInst.limit, 2456 template: '<div class="list-instagram__item"><a class="list-instagram__link" href="{{link}}" target="_blank"><img class="list-instagram__img" src="{{image}}" alt="{{caption}}" /></a></div>' 2457 }); 2458 feed.run(); 2459 } 2460 } 2461 }; 2462 return SocialWidgets; 2463 })(jQuery); 2464} 2465 2466/* 2467 * ÐлиÑоÑÐ½Ð°Ñ Ð³Ð°Ð»ÐµÑÐµÑ 2468 */ 2469if (!window.productTileGallery) { 2470 2471 productTileGallery = (function ($) { 2472 2473 var productTileGallery = function (params) { 2474 this.init(params); 2475 }; 2476 2477 productTileGallery.prototype = { 2478 _config: { 2479 images: {}, 2480 heightFixed: true 2481 }, 2482 init: function (params) { 2483 var that = this; 2484 if($("body").hasClass("touch")){ 2485 return false; 2486 } 2487 that.params = $.extend({}, that._config, params); 2488 that.runGallery(); 2489 }, 2490 runGallery: function() { 2491 var that = this; 2492 var elements = $('.js-tile-gallery'); 2493 elements.each(function (){ 2494 var element = $(this), 2495 block = element.find(".js-tile-gallery-block"), 2496 image = element.find(".js-product-preview-img"), 2497 length = element.find('.js-tile-gallery-item').length; 2498 2499 if(!image.data("src")){ 2500 image.attr("data-src", image.attr("src")) 2501 } 2502 2503 var src_default = image.data("src"); 2504 2505 if(!element.size() || !block.size() || !image.size() || length < 2 || element.hasClass("_tile-active")){ 2506 return true; 2507 } 2508 2509 element.addClass("_tile-active"); 2510 2511 block.removeAttr("style"); 2512 if(that.params.heightFixed){ 2513 block.on("mouseenter",function(){ 2514 block.css("height", block.height() + "px"); 2515 block.css("line-height", block.height() + "px"); 2516 }); 2517 } 2518 2519 element.find(".js-tile-gallery-item").on("mouseenter", function(){ 2520 var src = $(this).data("img"); 2521 $('<img>').attr('src', src).load(function () { 2522 image.attr("src", src); 2523 image.retina(); 2524 }); 2525 }); 2526 2527 block.on("mouseleave",function(){ 2528 image.attr("src", src_default); 2529 image.retina(); 2530 }); 2531 }); 2532 } 2533 }; 2534 return productTileGallery; 2535 })(jQuery); 2536} 2537 2538var categoriesImages = { 2539 init: function (){ 2540 var _this = this; 2541 2542 _this.categoriesList(); 2543 }, 2544 categoriesList: function() { 2545 var _this = this, 2546 categories = $('.js-categories-list'); 2547 2548 categories.each(function (){ 2549 var $this = $(this), 2550 isRetina = $this.data('retina'), 2551 isLazy = $this.data('lazy'), 2552 images = $this.find('.js-categories-item-image'); 2553 2554 if(isLazy){ 2555 _this.lazyImages(images, isRetina); 2556 }else if(isRetina){ 2557 _this.retinaImages(images); 2558 } 2559 }); 2560 }, 2561 lazyImages: function (images, isRetina){ 2562 var _this = this; 2563 2564 images.lazy({ 2565 onFinishedAll: function(element) { 2566 if(isRetina){ 2567 _this.retinaImages(images); 2568 } 2569 }, 2570 }); 2571 }, 2572 retinaImages: function (images){ 2573 images.each(function(){ 2574 var $this = $(this), 2575 imgUrl = $this.attr('src'); 2576 2577 if(imgUrl.indexOf("?") >= 0){ 2578 var fileExtensionWithGet = imgUrl.substring(imgUrl.lastIndexOf('.') + 1), 2579 imgUrl2x = imgUrl.replace("." + fileExtensionWithGet, "@2x." + fileExtensionWithGet); 2580 2581 $this.attr("data-at2x", imgUrl2x); 2582 } 2583 }).promise().done(function(){ 2584 images.retina(); 2585 }); 2586 } 2587}; 2588 2589var customGalleryPopup = { 2590 init: function (){ 2591 var _this = this, 2592 galleryImage = $('.js-custom-gallery'); 2593 2594 galleryImage.on("click", function(e){ 2595 e.preventDefault(); 2596 var images = [], 2597 current = $(this), 2598 currentGroup = $(this).data('group'), 2599 position = 0, 2600 galleryImages = []; 2601 2602 if(currentGroup){ 2603 galleryImages = $('.js-custom-gallery[data-group="'+currentGroup+'"]'); 2604 } 2605 2606 if(galleryImages.length > 1){ 2607 galleryImages.each(function (index) { 2608 var href = $(this).attr('href'), 2609 title = $(this).attr('title'); 2610 2611 if (href){ 2612 if(current.attr('href') == href){ 2613 position = index; 2614 } 2615 images.push({href: href, title: title}); 2616 } 2617 }); 2618 _this.openGallery(images, position); 2619 }else{ 2620 var href = current.attr('href'), 2621 title = current.attr('title'); 2622 2623 if(href){ 2624 images.push({href: href, title: title}); 2625 _this.openGallery(images); 2626 } 2627 } 2628 }); 2629 }, 2630 openGallery: function (images, position){ 2631 $.swipebox(images, { 2632 useSVG : false,
2633 hideBarsDelay: false, 2634 initialIndexOnArray: position, 2635 afterOpen: function() { 2636 $('#swipebox-overlay').addClass('opacity-black'); 2637 $('#swipebox-bottom-bar').addClass("swipebox-bottom-bar--pos-center"); 2638 $('#swipebox-arrows').addClass("swipebox-arrows--pos-center"); 2639 2640 $(document).on("scroll", closeSwipe); 2641 function closeSwipe() { 2642 var $closeButton = $("#swipebox-close"); 2643 if ($closeButton.length) { 2644 $closeButton.trigger("click"); 2645 } 2646 $(document).off("scroll", closeSwipe); 2647 } 2648 } 2649 }); 2650 } 2651}; 2652 2653var contentPopup = { 2654 init: function (){ 2655 var _this = this; 2656 2657 _this.loadPage(); 2658 _this.loadInline(); 2659 }, 2660 loadPage: function (){ 2661 var _this = this; 2662 2663 $('body').on("click", '.js-page-popup', function (event){ 2664 event.preventDefault(); 2665 2666 var $this = $(this), 2667 href = $this.attr('href'); 2668 2669 if(!href){ 2670 href = $this.data('href'); 2671 } 2672 2673 $.magnificPopup.close(); 2674 $('body').prepend("<div class='js-loading-bg mfp-bg mfp-ready'><div class='mfp-preloader'></div></div>"); 2675 2676 $.get(href + "?popup=1", function(data) { 2677 $('.js-loading-bg').remove(); 2678 var content = false, 2679 data = $("<div>").append(data); 2680 2681 if($(data)) { 2682 if ($(data).find('#page-popup').length) { 2683 content = $(data).find('#page-popup'); 2684 } 2685 if(content){ 2686 _this.openModal(content, 'page'); 2687 }else{ 2688 location.href = href; 2689 } 2690 } 2691 }); 2692 }); 2693 }, 2694 loadInline: function (){ 2695 var _this = this; 2696 2697 $('body').on("click", '.js-content-popup', function (event){ 2698 event.preventDefault(); 2699 2700 var id = $(this).data("href"); 2701 2702 if(id){ 2703 var content = $("#" + id).clone(); 2704 if(content.length){ 2705 content.removeClass("display_none"); 2706 _this.openModal(content, "custom"); 2707 } 2708 } 2709 }); 2710 }, 2711 openModal: function (content, type){ 2712 var addClass = null 2713 if(type){ 2714 addClass = " popup-content--" + type; 2715 } 2716 $.magnificPopup.open({ 2717 items: { 2718 src: "<div class='popup-content" + addClass + "'>" + content.outerHTML() + "</div>" 2719 }, 2720 type: 'inline' 2721 }, 0); 2722 2723 }, 2724}; 2725 2726$(function(){ 2727 main.init(); 2728 tabs.init(); 2729 accordionTabs.init(); 2730 form.init(); 2731 selectList.init(); 2732 menu.init(); 2733 slider.init(); 2734 photoGallery.init(); 2735 modalForm.init(); 2736 dropDownWrap.init(); 2737 categoriesMainMenu.init(); 2738 mobileMenu.init(); 2739 mobileSearch.init(); 2740 fixedPanel.init(); 2741 subscribeForm.init(); 2742 versionSite.init(); 2743 openMap.init(); 2744 tags.init(); 2745 skCallback.init(); 2746 pagePopup.init(); 2747 cart.init(); 2748 specialProducts.init(); 2749 productTile.init(); 2750 productListCustom.init(); 2751 productCarousel.init(); 2752 videoPopup.init(); 2753 lazyImages.init(); 2754 productsPreviewList.init(); 2755 infoMessage.init($('.js-info-massage')); 2756 popupAdvert.init($('.js-popup-advert')); 2757 categoriesImages.init(); 2758 customGalleryPopup.init(); 2759 contentPopup.init(); 2760 2761 new SkOneclick({ buttons: '.js-sk-oneclick-open' }); 2762 new SocialWidgets({ container: ".js-social-widgets", timeAutoSwitch: 5000 }); 2763 new productTileGallery(); 2764}); 2765 2766$.fn.elementRealWidth = function () { 2767 $clone = this.clone() 2768 .css("visibility","hidden") 2769 .appendTo($('body')); 2770 var $width = $clone.outerWidth(true); 2771 $clone.remove(); 2772 return $width; 2773}; 2774 2775jQuery.fn.outerHTML = function(s) { 2776 return s 2777 ? this.before(s).remove() 2778 : jQuery("<p>").append(this.eq(0).clone()).html(); 2779}; 2780 2781function is_touch_device() { 2782 return 'ontouchstart' in window || navigator.maxTouchPoints; 2783}; 2784 2785function viewport() { 2786 var e = window, a = 'inner'; 2787 if (!('innerWidth' in window )) { 2788 a = 'client'; 2789 e = document.documentElement || document.body; 2790 } 2791 return { width : e[ a+'Width' ] , height : e[ a+'Height' ] }; 2792} 2793 2794function validateEmail(email) { 2795 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,}))$/; 2796 return re.test(email); 2797} 2798 2799
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.