1//General scripts for Shop App * general-blog.js 2$(function() { 3 //ÐеÑемеÑÑÑ Ð±Ð»Ð¾ÐºÐ¸ в ÑÑÑ. ÑоваÑа 4 if (window.matchMedia("(max-width: 767px)").matches) { 5 // $(".pd-cart__qty").appendTo(".pd-cart__mob-qty-stock"); 6 $(".pd-cart__stock-wrapper").appendTo(".pd-cart__mob-qty-stock"); 7 $(".pd-cart__options-list").appendTo(".pd-cart__mob-qty-stock"); 8 } 9 10 //ÐеÑемеÑÑиÑÑ ÑÐ°Ð±Ñ Ð½Ð° СÑÑаниÑе ÑоваÑа 3 11 if (window.matchMedia("(min-width: 1281px)").matches) { 12 // $('.item-pg_3 .item-tabs').appendTo('.pd-cart'); 13 } 14 15 //Reinitializing item tabs flexmenu 16 if (window.matchMedia("(min-width: 1250px)").matches) { 17 if (".item-pg_3 .pd-cart .item-tabs__list_js".length) { 18 $(".item-tabs__list_js").flexMenu({ 19 linkText: "...", 20 cutoff: 0 21 }); 22 } 23 } 24 25 //ÐеÑемеÑÑиÑÑ Ð±Ð»Ð¾Ðº инÑоÑмаÑии на СÑÑаниÑе ÑоваÑа 3 26 if (window.matchMedia("(max-width: 1249px)").matches) { 27 $(".store-info") 28 .insertAfter(".item-pg__product") 29 .wrap("<div class='item-pg__tab-store-info'></div>"); 30 31 $(".pd-descr .pd-tabs") 32 .insertAfter(".item-pg__product") 33 .wrap("<div class='item-pg__pd-delivery-payment'></div>"); 34 } 35}); 36 37//Item page tabs menu * item-tabs-flexmenu.js 38(function() { 39 /* 40 Used plugin - https://github.com/352Media/flexMenu 41 But I modified source code to fit my needs. 42 Uses flexmenu.js & _flexmenu.scss & _item-tabs.scss(my custom styles on)file 43 */ 44 45 // if (window.matchMedia('(min-width: 768px)').matches) { 46 $(".item-tabs__list_js").flexMenu({ 47 linkText: "...", 48 cutoff: 1 49 }); 50 // } 51 52 //Just to store uuidv4 ids 53 var ids = []; 54 55 $(".item-tabs__list_js .item-tabs__menu-i").each(function() { 56 var $this = $(this); 57 58 //uuidv4() - generates random IDs. I used them to get and show 59 //appropriate content on tab menu item selecting 60 $this.attr("data-id", uuidv4()); 61 ids.push($this.data("id")); 62 }); 63 64 $(".item-tabs__content-i").each(function(i, v) { 65 $(v).attr("data-id", ids.shift()); 66 }); 67 68 //Item tabs toggle content 69 $(".item-tabs__menu-i").on("click", function(e) { 70 e.preventDefault(); 71 var item = $(this), 72 contentItem = $(".item-tabs__content-i"), 73 itemId = item.data("id"); 74 75 contentItem.each(function(i, v) { 76 var $this = $(v), 77 contentId = $this.data("id"); 78 79 if (contentId === itemId) { 80 $this 81 .add(item) 82 .addClass("active") 83 .siblings() 84 .removeClass("active"); 85 86 if (item.closest(".flexMenu-popup").length || $(".flexMenu-viewMore").hasClass("active")) { 87 $(".item-tabs__list > li").removeClass("active"); 88 } 89 if (window.matchMedia("(max-width: 767px)").matches) { 90 $("body").trigger("click"); 91 } 92 } 93 }); 94 95 // return false; 96 }); 97})(); 98 99//Subcat slider * subcat-elements.js 100(function() { 101 if (window.matchMedia("(max-width: 767px)").matches) { 102 //Preventing init of slider in mobile version 103 $(".subcat-slider__container").removeClass("swiper-container"); 104 $(".subcat-slider__wrapper").removeClass("swiper-wrapper"); 105 $(".subcat-slider .sub-cat").removeClass("swiper-slide"); 106 107 //Show expand all subcategories button in mobile 108 var subcat = $(".subcat-wrapper"), 109 MIN_ITEM_COUNT = 5, 110 toggleBtn = $(".subcat-wrapper__mob-qty-toggle"); 111 112 if (subcat.length) { 113 // subcat.each(function(i,v){ 114 var itemsCount = subcat.find(".subcat-wrapper__item").length; 115 116 if (itemsCount < MIN_ITEM_COUNT) { 117 toggleBtn.hide(); 118 } 119 120 toggleBtn.on("click", function(e) { 121 var $this = $(this); 122 e.preventDefault(); 123 124 $this.closest(subcat).toggleClass("show-items"); 125 $this.toggleClass("active"); 126 127 if ($this.hasClass("active")) $this.find("span").text($this.data("hide")); 128 else $this.find("span").text($this.data("show")); 129 }); 130 // }); 131 } 132 } 133 134 //Subcategories slider 135 if (window.matchMedia("(min-width: 768px)").matches) { 136 var subCatSwiper = new Swiper(".subcat-slider__container", { 137 slidesPerView: "auto", 138 // spaceBetween: 30, 139 navigation: { 140 nextEl: ".subcat-slider .slider-ar:last-child", 141 prevEl: ".subcat-slider .slider-ar:first-child" 142 }, 143 watchOverflow: true, 144 freeMode: true, 145 breakpoints: { 146 1281: { 147 spaceBetween: 30 148 }, 149 768: { 150 spaceBetween: 20 151 } 152 } 153 }); 154 } 155})(); 156 157//СкÑипÑÑ Ð² ÐаÑалоге * catalog-elements.js 158(function() { 159 //СоÑÑиÑовка в каÑалоге в мобилÑном веÑÑии 160 if (window.matchMedia("(max-width: 767px)").matches) { 161 $(".catalog-pg").on("click", ".option-p__sort-col_left", function() { 162 $(this) 163 .find(".option-p__sort-toggle") 164 .toggleClass("active"); 165 }); 166 167 $(".catalog-pg").on("click", ".option-p__qty", function() { 168 var $this = $(this); 169 $this 170 // .find(".option-p__sort-toggle") 171 .toggleClass("active"); 172 173 $(document).bind("click.wrapper", function(e) { 174 if ($(e.target).closest($this).length == 0) { 175 // $("body").removeClass("is-overlayed"); 176 // $(".site-header__cat-btn").removeClass("active"); 177 $this.removeClass("active"); 178 $(document).unbind("click.wrapper"); 179 } 180 }); 181 }); 182 } 183 // ÐниÑиализаÑÐ¸Ñ UI SLIDER 184 $(".range-slider__caret").slider({ 185 range: true, 186 min: 0, 187 max: 500, 188 values: [75, 300] 189 }); 190 191 $(".filter-wr__header").on("click", function() { 192 $(this) 193 .toggleClass("active") 194 .next() 195 .slideToggle(); 196 }); 197 198 // Mobile filter 199 (function() { 200 // check touch support 201 if ("ontouchstart" in window) { 202 var click = "touchstart"; 203 } else { 204 var click = "click"; 205 } 206 207 $(document).on("click", ".catalog-pg__toggle-panel", function(e) { 208 e.preventDefault(); 209 var $this = $(this); 210 var btnDataValue = $this.data("sidebar-btn"); 211 212 var sidebar; 213 $(".catalog-pg__outer-wrapper").each(function(key, value) { 214 var $wrapper = $(value); 215 var $wrapperDataValue = $(value).data("sidebar"); 216 217 if (btnDataValue === $wrapperDataValue) { 218 sidebar = $wrapper; 219 } 220 }); 221 222 sidebar 223 .addClass("opened", 100) 224 .promise() 225 .done(function() { 226 $(".catalog-pg .bg-overlay").fadeIn(300); 227 // $("body, html").addClass("freeze"); 228 }); 229 }); 230 231 $(".catalog-pg__sidebar-header-close, .bg-overlay").on("click", function(e) { 232 e.preventDefault(); 233 $(".catalog-pg__outer-wrapper") 234 .removeClass("opened") 235 .promise() 236 .done(function() { 237 $(".bg-overlay").fadeOut(300);
238 $("body, html").removeClass("freeze"); 239 }); 240 }); 241 })(); 242})(); 243 244// СкÑÐ¸Ð¿Ñ "ÐоказаÑÑ ÐµÑе каÑалоге ÑилÑÑÑ" * catalog-filter-options-toggle.js 245(function() { 246 var showMoreItems = { 247 container: $(".filter-options_more") || null, 248 249 init: function() { 250 this.initialShow(); 251 this.eventListener(); 252 }, 253 254 initialShow: function() { 255 this.container.each(function(i, v) { 256 var $v = $(v), 257 x = parseInt($v.data("qty")); 258 259 $v.find("li:lt(" + x + ")").show(); 260 }); 261 }, 262 263 eventListener: function() { 264 $(".filter-options__qty-toggle").on("click", this.toggleItemsQty); 265 }, 266 267 toggleItemsQty: function(e) { 268 e.preventDefault(); 269 e.stopPropagation(); 270 var $this = $(this), 271 container = $this.closest(showMoreItems.container); 272 273 //Ðокажем вÑе 274 if (!$this.hasClass("is-shows-all")) { 275 var x = parseInt(container.find("li").size()); 276 277 container.find("li:lt(" + x + ")").fadeIn(); 278 $this.addClass("is-shows-all"); 279 $this.find("span").html($this.data("hide")); 280 } else { 281 //ÐеÑнем как бÑло 282 x = parseInt(container.data("qty") - 1); 283 284 container.find("li:gt(" + x + ")").fadeOut(); 285 $this.removeClass("is-shows-all"); 286 $this.find("span").html($this.data("show")); 287 } 288 } 289 }; 290 showMoreItems.init(); 291})(); 292 293/*---------Sliders in Shop App * slider-inits-shop.js 294============================================*/ 295 296(function() { 297 //Item page Main Photo thumbnails in Desktop of Item page 1 298 if (window.matchMedia("(min-width: 1250px)").matches) { 299 var itemThumbsSlider1Desk = new Swiper(".b-row-ip:not(.b-row-ip_3) .pd-image__thumbs-slider", { 300 direction: "vertical", 301 slidesPerView: "auto", 302 spaceBetween: 20, 303 watchOverflow: true, 304 navigation: { 305 prevEl: ".b-row-ip:not(.b-row-ip_3) .thumb-nav_left", 306 nextEl: ".b-row-ip:not(.b-row-ip_3) .thumb-nav_right" 307 } 308 }); 309 var itemThumbsSlider3Desk = new Swiper(".b-row-ip_3 .pd-image__thumbs-slider", { 310 slidesPerView: "auto", 311 spaceBetween: 15, 312 navigation: { 313 prevEl: ".b-row-ip_3 .thumb-nav_left", 314 nextEl: ".b-row-ip_3 .thumb-nav_right" 315 } 316 }); 317 } 318 //Item page Main Photo thumbnails in Adaptive version of Item page 1 319 if (window.matchMedia("(max-width: 1249px)").matches) { 320 var itemThumbsSlider1Adap = new Swiper(".pd-image__thumbs-slider", { 321 spaceBetween: 20, 322 watchOverflow: true, 323 navigation: { 324 prevEl: ".b-row-ip .thumb-nav_left", 325 nextEl: ".b-row-ip .thumb-nav_right" 326 }, 327 breakpoints: { 328 // when window width is <= 480px 329 // 1280: { 330 768: { 331 // slidesPerView: 4, 332 slidesPerView: "auto", 333 spaceBetween: 14 334 }, 335 // when window width is <= 320px 336 320: { 337 spaceBetween: 12, 338 slidesPerView: "auto" 339 } 340 } 341 }); 342 } 343 344 $(".pd-image__thumbs-slider").on("click", ".swiper-slide", function() { 345 var $this = $(this); 346 $this.siblings().removeClass("swiper-slide-active"); 347 $this.addClass("swiper-slide-active"); 348 }); 349 350 if ($(".pd-image__thumbs-slider-nav .swiper-button-disabled").length == 2) { 351 $(".pd-image__thumbs-slider-nav").hide(); 352 $(".pd-image__thumbs").addClass("no-nav"); 353 } 354 355 //HOme columns mobile slider 356 if (window.matchMedia("(max-width: 767px)").matches) { 357 var Columnitems = new Swiper(".home-column", { 358 slidesPerView: 2, 359 spaceBetween: 10, 360 watchOverflow: true, 361 navigation: { 362 prevEl: ".home-column .items-slider__nav-left", 363 nextEl: ".home-column .items-slider__nav-right" 364 }, 365 wrapperClass: "home-column__list", 366 slideClass: "home-column__item" 367 }); 368 } 369 370 //Home blog mobile slider 371 if (window.matchMedia("(max-width: 767px)").matches) { 372 var BlogItems = new Swiper(".home-blog_wide", { 373 navigation: { 374 prevEl: ".home-pg__section_blog .items-slider__nav-left", 375 nextEl: ".home-pg__section_blog .items-slider__nav-right" 376 }, 377 wrapperClass: "home-blog__inner", 378 slideClass: "home-blog__item" 379 }); 380 } 381 382 //Home brands mobile slider 383 if (window.matchMedia("(max-width: 767px)").matches) { 384 var BlogItems = new Swiper(".home-brands", { 385 slidesPerView: 3, 386 spaceBetween: 10, 387 watchOverflow: true, 388 navigation: { 389 prevEl: ".home-pg__section_brands .items-slider__nav-left", 390 nextEl: ".home-pg__section_brands .items-slider__nav-right" 391 }, 392 wrapperClass: "home-brands__inner", 393 slideClass: "home-brands__item" 394 }); 395 } 396 397 // Creating instances of home promo categories item sliders with one ititialization script 398 //Otherwise we have to creating tens of such init scripts 399 //This universal init which suits most of item sliders 400 $(".home-promo-catgs__sl-wr").each(function(key, item) { 401 //Uniqui name 402 var sliderIdName = "sliderColored" + key; 403 404 //Setting id to slider element 405 this.id = sliderIdName; 406 407 //Getting name with hash 408 var sliderId = "#" + sliderIdName; 409 var sliderSelector = $(sliderId); 410 //Setting unique id to parent block 411 $(this) 412 .closest(".home-promo-catgs") 413 .attr("id", "items-" + sliderIdName); 414 415 //Getting id of parent block 416 var sliderParentElId = 417 "#" + 418 $(this) 419 .closest(".home-promo-catgs") 420 .attr("id"); 421 if ($(".col-1-of-5").length) { 422 var sliderIdName = new Swiper(sliderId, { 423 slidesPerView: "auto", 424 spaceBetween: 28, 425 slidesPerGroup: 3, 426 watchOverflow: true, 427 navigation: { 428 prevEl: sliderParentElId + " .items-slider__nav-left", 429 nextEl: sliderParentElId + " .items-slider__nav-right" 430 }, 431 breakpoints: { 432 // 1281: { 433 1250: { 434 spaceBetween: 28, 435 slidesPerGroup: 4 436 }, 437 768: { 438 spaceBetween: 28, 439 slidesPerGroup: 3 440 }, 441 320: { 442 slidesPerView: 2, 443 spaceBetween: 10, 444 slidesPerGroup: 2 445 } 446 } 447 }); 448 } else { 449 var sliderIdName = new Swiper(sliderId, { 450 slidesPerView: "auto", 451 spaceBetween: 32, 452 slidesPerGroup: 5, 453 watchOverflow: true, 454 navigation: { 455 prevEl: sliderParentElId + " .items-slider__nav-left", 456 nextEl: sliderParentElId + " .items-slider__nav-right" 457 }, 458 breakpoints: { 459 // 1281: { 460 1250: { 461 spaceBetween: 28, 462 slidesPerGroup: 4 463 }, 464 768: { 465 spaceBetween: 28, 466 slidesPerGroup: 3 467 }, 468 320: { 469 slidesPerView: 2, 470 spaceBetween: 10, 471 slidesPerGroup: 2 472 } 473 } 474 }); 475 } 476 }); 477 478 $(".home-promo-catgs").each(function() { 479 var $this = $(this); 480 481 if ($this.find(".slider-arrows .swiper-button-disabled").length == 2) { 482 $this.find(".slider-arrows").hide(); 483 } 484 }); 485 486 //Home photos slider 487 var HomePhotos = new Swiper(".home-fdb-photos_slider", { 488 slidesPerView: 4, 489 // spaceBetween: 30, 490 slidesPerGroup: 4, 491 watchOverflow: true, 492 navigation: { 493 prevEl: ".home-pg__section_feedback-gal .items-slider__nav-left", 494 nextEl: ".home-pg__section_feedback-gal .items-slider__nav-right" 495 }, 496 breakpoints: { 497 // 1281: { 498 1250: { 499 spaceBetween: 30 500 }, 501 768: { 502 spaceBetween: 20 503 }, 504 320: { 505 slidesPerView: 2, 506 spaceBetween: 10, 507 slidesPerGroup: 2 508 } 509 } 510 }); 511 512 //Home subcategories 513 var HomeSubcats = new Swiper(".home-subcat-slider", { 514 slidesPerView: "auto", 515 516 slidesPerGroup: 8, 517 watchOverflow: true, 518 navigation: { 519 prevEl: ".home-pg__section_subcat-6 .items-slider__nav-left", 520 nextEl: ".home-pg__section_subcat-6 .items-slider__nav-right" 521 }, 522 breakpoints: { 523 // 1281: { 524 1250: { 525 spaceBetween: 30 526 }, 527 768: { 528 spaceBetween: 22 529 }, 530 320: { 531 spaceBetween: 10, 532 slidesPerGroup: 2 533 } 534 } 535 }); 536 537 // Slider init for promo categories 1 538 539 $(".promo-1-items").each(function(key, item) { 540 //Unique name 541 var sliderIdName = "sliderPromCat1" + key; 542 543 //Setting id to slider element 544 this.id = sliderIdName; 545 546 //Getting name with hash 547 var sliderId = "#" + sliderIdName; 548 549 //Setting unique id to parent block 550 $(this) 551 .closest(".prom-cat-1") 552 .attr("id", "items-" + sliderIdName); 553 554 //Getting id of parent block 555 var sliderParentElId = 556 "#" + 557 $(this) 558 .closest(".prom-cat-1") 559 .attr("id"); 560 //If there is sidebar 561 if ($(".col-1-of-5").length) { 562 var sliderIdName = new Swiper(sliderId, { 563 slidesPerView: "auto", 564 // spaceBetween: 30, 565 slidesPerGroup: 3, 566 watchOverflow: true, 567 navigation: { 568 prevEl: sliderParentElId + " .items-slider__nav-left", 569 nextEl: sliderParentElId + " .items-slider__nav-right" 570 }, 571 breakpoints: { 572 // 1281: { 573 1250: { 574 spaceBetween: 30 575 }, 576 1024: { 577 slidesPerGroup: 3 578 }, 579 768: { 580 slidesPerGroup: 2 581 }, 582 320: { 583 spaceBetween: 10, 584 slidesPerGroup: 1 585 } 586 } 587 }); 588 } else { 589 var sliderIdName = new Swiper(sliderId, { 590 slidesPerView: "auto", 591 // spaceBetween: 30, 592 slidesPerGroup: 4, 593 watchOverflow: true, 594 navigation: { 595 prevEl: sliderParentElId + " .items-slider__nav-left", 596 nextEl: sliderParentElId + " .items-slider__nav-right" 597 }, 598 breakpoints: { 599 // 1281: { 600 1250: { 601 spaceBetween: 30 602 }, 603 1024: { 604 slidesPerGroup: 3 605 }, 606 768: { 607 slidesPerGroup: 2 608 }, 609 320: { 610 spaceBetween: 10, 611 slidesPerGroup: 1 612 } 613 } 614 }); 615 } 616 }); 617 //Removing nav buttons if less slides 618 $(".prom-cat-1").each(function() { 619 var $this = $(this); 620 621 if ($this.find(".items-slider__arrow .swiper-button-disabled").length == 2) { 622 $this.find(".items-slider__arrow").hide(); 623 } 624 }); 625 626 //Home feedbacks slider 627 var HomeFeedbacks = new Swiper(".home-pg__section_feedbacks .home-g_slider", { 628 slidesPerView: "auto", 629 // spaceBetween: 30, 630 slidesPerGroup: 3, 631 watchOverflow: true, 632 navigation: { 633 prevEl: ".home-pg__section_feedbacks .items-slider__nav-left", 634 nextEl: ".home-pg__section_feedbacks .items-slider__nav-right" 635 }, 636 breakpoints: { 637 // 1281: { 638 1250: { 639 slidesPerGroup: 3 640 }, 641 768: { 642 // spaceBetween: 20 643 slidesPerGroup: 2 644 }, 645 320: { 646 slidesPerView: 1, 647 spaceBetween: 0, 648 slidesPerGroup: 1 649 } 650 } 651 }); 652 653 //Home customer feedbacks slider 654 var HomeCustFeedbacks = new Swiper(".home-pg__section_cust-feedbacks .home-g_slider", { 655 slidesPerView: "auto", 656 // slidesPerGroup: 4, 657 watchOverflow: true, 658 navigation: { 659 prevEl: ".home-pg__section_cust-feedbacks .items-slider__nav-left", 660 nextEl: ".home-pg__section_cust-feedbacks .items-slider__nav-right" 661 }, 662 breakpoints: { 663 // 1281: { 664 1250: { 665 slidesPerGroup: 4 666 }, 667 768: { 668 slidesPerGroup: 3 669 }, 670 320: { 671 slidesPerView: 1, 672 spaceBetween: 0, 673 slidesPerGroup: 1 674 } 675 } 676 }); 677})(); 678 679/// 680//Item page image gallery 681 682// var galleryThumbs = new Swiper(".gallery-thumbs", { 683// spaceBetween: 10, 684// slidesPerView: 4, 685// freeMode: true, 686// watchSlidesVisibility: true, 687// watchSlidesProgress: true 688// });
689// var galleryTop = new Swiper(".gallery-top", { 690// spaceBetween: 10, 691// navigation: { 692// nextEl: ".swiper-button-next", 693// prevEl: ".swiper-button-prev" 694// }, 695// thumbs: { 696// swiper: galleryThumbs 697// } 698// }); 699 700// $("#product-core-image").on("click", function() { 701// var photoIndex = 1; 702 703// var $this = $(this); 704 705// // debugger; 706// $(".pd-image-gallery__photo-wrapper .swiper-slide").each(function(i, v) { 707// if ($this.data("startindex") === $(v).data("startindex")) { 708// photoIndex = i; 709// } 710// }); 711// console.log("photoIndex", photoIndex); 712 713// $.magnificPopup.open({ 714// items: { 715// src: "#ip-gallery", // can be a HTML string, jQuery object, or CSS selector 716// type: "inline" 717// }, 718// closeBtnInside: true, 719// removalDelay: 300, 720// mainClass: "mfp-zoom-in", 721// callbacks: { 722// beforeOpen: function() {}, 723// open: function() { 724// //ÐобавлÑем ÐºÐ½Ð¾Ð¿ÐºÑ Ð¥ Ð´Ð»Ñ Ð·Ð°ÐºÑÑÑÐ¸Ñ Ð¿Ð¾Ð¿Ð¾Ð¿Ð° 725// $("<a></a>", { 726// text: "ÐакÑÑÑ Ð¿Ð¾Ð¿Ð°Ð¿", 727// href: "#" 728// }) 729// .addClass("b-popup__close ds-hide") 730// .prependTo(".mfp-container") 731// .on("click", function() { 732// $.magnificPopup.close(); 733// }); 734 735// $(".mfp-content").addClass("b-popup-container b-popup-container_gallery"); 736 737// var galleryThumbs = new Swiper(".gallery-thumbs", { 738// spaceBetween: 10, 739// slidesPerView: 4, 740// watchSlidesVisibility: true, 741// watchSlidesProgress: true, 742// initialSlide: photoIndex, 743// on: { 744// init: function() { 745// var activeSlide = $(this.slides[photoIndex]); 746 747// setTimeout(function() { 748// activeSlide 749// .addClass("swiper-slide-active swiper-slide-thumb-active") 750// .siblings() 751// .removeClass("swiper-slide-active swiper-slide-thumb-active"); 752// }, 0); 753// } 754// } 755// }); 756// var galleryTop = new Swiper(".gallery-top", { 757// spaceBetween: 10, 758// initialSlide: photoIndex, 759// navigation: { 760// prevEl: ".pd-image-gallery__left", 761// nextEl: ".pd-image-gallery__right" 762// }, 763// thumbs: { 764// swiper: galleryThumbs 765// } 766// }); 767// }, 768// close: function() {} 769// } 770// }); 771// }); 772 773/*---------Characteristics in Item page * pd-chars.js 774============================================*/ 775(function() { 776 $(".pd-chars__show-all").on("click", function(e) { 777 $(".item-tabs__menu-i_chars").trigger("click"); 778 }); 779})(); 780 781//Item page cart tabs * pd-cart-tabs.js 782(function() { 783 $(".pd-tabs").on("click", ".pd-tabs__tab-menu-item", function(e) { 784 e.preventDefault(); 785 var self = $(this), 786 index = self.index(); 787 788 self 789 .addClass("active") 790 .siblings(".pd-tabs__tab-menu-item") 791 .removeClass("active"); 792 793 var tab = self 794 .closest(".pd-tabs") 795 .find(".pd-tabs__tab-content-item") 796 .eq(index); 797 798 tab 799 .fadeIn(150) 800 .siblings(".pd-tabs__tab-content-item") 801 .hide(); 802 803 return false; 804 }); 805})(); 806 807//Sticking price into bottom * ip-mobile-price-waypoints.js 808$(function() { 809 if (window.matchMedia("(max-width: 767px)").matches) { 810 if ($(".pd-cart__processing-wrapper").length) { 811 var stickyPrice = new Waypoint.Sticky({ 812 element: $(".pd-cart__processing-wrapper")[0] 813 }); 814 } 815 816 $pricePanel = $(".pd-cart__processing-wrapper"); 817 var ipMobileCart = new Waypoint({ 818 element: document.querySelector(".site-footer"), 819 handler: function(direction) { 820 if (direction === "down") { 821 $pricePanel.removeClass("stuck"); 822 } else if (direction === "up") { 823 $pricePanel.addClass("stuck"); 824 } 825 }, 826 offset: 600 827 // context: document.body 828 }); 829 } 830 831 if (window.matchMedia("(max-width: 1249px)").matches) { 832 if ($(".item-page .site-header__main").length) { 833 var stickyHeader = new Waypoint.Sticky({ 834 element: $(".site-header__main")[0] 835 }); 836 } 837 838 if ($(".item-tabs__menu").length) { 839 var stickyTabs = new Waypoint.Sticky({ 840 element: $(".item-tabs__menu")[0] 841 }); 842 } 843 } 844}); 845 846//Home page Slider tabs * home-slider-tabs.js 847(function() {
848 $(".home-tab-sliders").on("click", ".home-tab-sliders__menu .section-title", function(e) { 849 e.preventDefault(); 850 var self = $(this), 851 index = self.index(); 852 853 self 854 .addClass("active") 855 .siblings(".section-title") 856 .removeClass("active"); 857 858 var tab = self 859 .closest(".home-tab-sliders") 860 .find(".home-tab-sliders__content-item") 861 .eq(index); 862 863 tab 864 .fadeIn(150, function() { 865 $(this).addClass("active"); 866 }) 867 .siblings(".home-tab-sliders__content-item") 868 .removeClass("active") 869 .hide(); 870 871 // return false; 872 873 // 874 if ($(".items-slider__body").length) { 875 // Creating instances of all item sliders with one ititialization script 876 //Otherwise we have to creating tens of such init scripts 877 //This universal init which suits most of item sliders 878 879 $(".items-slider__body:not(.items-slider__body_cart-cross)").each(function(key, item) { 880 //Uniqui name 881 var sliderIdName = "sliderItems" + key; 882 883 //Setting id to slider element 884 this.id = sliderIdName; 885 886 //Getting name with hash 887 var sliderId = "#" + sliderIdName; 888 889 //Setting unique id to parent block 890 $(this) 891 .closest(".items-slider") 892 .attr("id", "items-" + sliderIdName); 893 894 //Getting id of parent block 895 var sliderParentElId = 896 "#" + 897 $(this) 898 .closest(".items-slider") 899 .attr("id"); 900 901 var sliderIdName = new Swiper(sliderId, { 902 slidesPerView: "auto", 903 // spaceBetween: 30, 904 slidesPerGroup: 5, 905 watchOverflow: true, 906 navigation: { 907 prevEl: sliderParentElId + " .items-slider__nav-left", 908 nextEl: sliderParentElId + " .items-slider__nav-right" 909 }, 910 breakpoints: { 911 1281: { 912 spaceBetween: 30 913 }, 914 768: { 915 spaceBetween: 28, 916 slidesPerGroup: 3 917 }, 918 320: { 919 // slidesPerView: 2, 920 spaceBetween: 10, 921 slidesPerGroup: 1 922 } 923 } 924 }); 925 }); 926 927 $(".items-slider").each(function() { 928 var $this = $(this); 929 930 if ($this.find(".items-slider__arrow .swiper-button-disabled").length == 2) { 931 $this.find(".items-slider__arrow").hide(); 932 } 933 }); 934 } 935 // $(".items-slider__body").each(function(key, item) { 936 // //Uniqui name 937 // var sliderIdName = "sliderItems" + key; 938 939 // //Setting id to slider element 940 // this.id = sliderIdName; 941 942 // //Getting name with hash 943 // var sliderId = "#" + sliderIdName; 944 945 // //Setting unique id to parent block 946 // $(this) 947 // .closest(".items-slider") 948 // .attr("id", "items-" + sliderIdName); 949 950 // //Getting id of parent block 951 // var sliderParentElId = 952 // "#" + 953 // $(this) 954 // .closest(".items-slider") 955 // .attr("id"); 956 957 // var sliderIdName = new Swiper(sliderId, { 958 // slidesPerView: "auto", 959 // // spaceBetween: 30, 960 // slidesPerGroup: 5, 961 // navigation: { 962 // prevEl: sliderParentElId + " .items-slider__nav-left", 963 // nextEl: sliderParentElId + " .items-slider__nav-right" 964 // }, 965 // breakpoints: { 966 // 1281: { 967 // spaceBetween: 30 968 // }, 969 // 1280: { 970 // // spaceBetween: 28, 971 // slidesPerGroup: 3 972 // }, 973 // 767: { 974 // // slidesPerView: 1, 975 // spaceBetween: 10, 976 // slidesPerGroup: 1 977 // }, 978 // 320: { 979 // // slidesPerView: 1, 980 // spaceBetween: 10, 981 // slidesPerGroup: 1 982 // } 983 // } 984 // }); 985 // }); 986 // 987 }); 988})(); 989 990//* promo-cat-flexmenu.js 991$(function() { 992 $(".prom-flx-menu__list").flexMenu({ 993 linkText: "...", 994 popupClass: "menu-univ-popup univ-dropd", 995 cutoff: 0, 996 linkTitle: "" 997 }); 998}); 999 1000//Home faq * home-faq.js 1001(function() { 1002 $(".home-faq").on("click", ".home-faq__item", function() { 1003 var $this = $(this), 1004 $currentDt = $this.find(".home-faq__content"), 1005 $items = $this.siblings(), 1006 $otherDt = $items.find(".home-faq__content"); 1007 1008 if ($otherDt.is(":visible")) { 1009 $items.removeClass("active"); 1010 $otherDt.slideUp(); 1011 } 1012 $this.toggleClass("active"); 1013 $currentDt.slideToggle(); 1014 }); 1015})(); 1016 1017var updateHeaderCart = (function($) { 1018 $(document).ready(function() { 1019 updateHeaderCart = function(data) { 1020 if (data["count"] > 0) { 1021 $(".js-minicart-count").html(data["count"]); 1022 $(".js-minicart-total").html(data["total"]); 1023 $(".js-minicart-status") 1024 .removeClass("is-empty") 1025 .addClass("not-empty"); 1026 $(".js-minicart-flystatus").removeClass("is-empty"); 1027 $(".js-flycart-status").removeClass("empty"); 1028 } else { 1029 $(".js-minicart-status") 1030 .removeClass("not-empty") 1031 .addClass("is-empty"); 1032 $(".js-minicart-flystatus").addClass("is-empty"); 1033 $(".js-flycart-status").addClass("empty"); 1034 } 1035 if ("items" in data) { 1036 var html = ""; 1037 var image = ""; 1038 for (var i = 0; i < data["items"].length; ++i) { 1039 image = data["items"][i]["image_url"]; 1040 image = !image || image.charAt(image.length - 1) == "." ? $(".js-minicart-wrapper").data("dummyimg") : image; 1041 html += 1042 '<li class="minicart__item" data-id="' + 1043 data["items"][i]["id"] + 1044 '">' + 1045 ' <div class="mini-item">' + 1046 ' <a class="mini-item__image" href="' + 1047 data["items"][i]["frontend_url"] + 1048 '">' + 1049 ' <img src="' + 1050 image + 1051 '" />' + 1052 " </a>" + 1053 ' <div class="mini-item__content"><a class="mini-item__name" href="' + 1054 data["items"][i]["frontend_url"] + 1055 '">' + 1056 data["items"][i]["name"] + 1057 "</a>" + 1058 ' <div class="mini-item__price-list">' + 1059 ' <div class="mini-item__price mini-item__price_regl">' + 1060 " <span>" + 1061 data["items"][i]["price"] + 1062 "</span>" + 1063 " <span>x</span>" + 1064 " <span>" + 1065 data["items"][i]["quantity"] + 1066 "</span>" + 1067 " </div>" + 1068 " </div>"; 1069 if (data["items"][i]["services"].length) { 1070 html += ' <div class="mini-item__extra">'; 1071 for (var j = 0; j < data["items"][i]["services"].length; ++j) { 1072 html += 1073 '<div class="mini-item__extra-item">' + 1074 " <span>+ " + 1075 data["items"][i]["services"][j]["name"] + 1076 "</span>" + 1077 " <strong> " + 1078 data["items"][i]["services"][j]["price"] + 1079 "</strong>" + 1080 " <span> x</span>" + 1081 " <span>" + 1082 data["items"][i]["services"][j]["quantity"] + 1083 "</span>" + 1084 " </div>"; 1085 } 1086 html += " </div>"; 1087 } 1088 html += 1089 "</div>" + 1090 " </div>" + 1091 ' <div class="minicart__delete">' + 1092 ' <button class="close-x">' + 1093 ' <svg class="icon cent-icon" width="8" height="8">' + 1094 ' <use xlink:href="#arrow-x"></use>' + 1095 " </svg>" + 1096 " </button>" + 1097 " </div>" + 1098 "</li>"; 1099 } 1100 $(".js-minicart-wrapper .minicart__list").html(html); 1101 } 1102 }; 1103 1104 return updateHeaderCart; 1105 }); 1106})(jQuery); 1107 1108(function() { 1109 // Promos countdown 1110 if ($.fn.countdown) { 1111 $(".countdown__timer").each(function() { 1112 var $this = $(this); 1113 var id = $this.attr("id") || "promo-timer__countdown" + ("" + Math.random()).slice(2); 1114 $this.attr("id", id); 1115 var date = $this.data("end").replace(/-/g, "/"); 1116 $this.countdown( 1117 { 1118 date: date, 1119 format: "on" 1120 }, 1121 function() { 1122 // callback function 1123 } 1124 ); 1125 }); 1126 } 1127 1128 //PRODUCT FILTERING 1129 var f = function() {
1130 var ajax_form_callback = function(f) { 1131 var fields = f.serializeArray(); 1132 var params = []; 1133 for (var i = 0; i < fields.length; i++) { 1134 if (fields[i].value !== "") { 1135 params.push(fields[i].name + "=" + fields[i].value); 1136 } 1137 } 1138 var url = "?" + params.join("&"); 1139 $(".catalog-pg__items").addClass("loading"); 1140 $.get(url + "&_=_", function(html) { 1141 var tmp = $("<div></div>").html(html); 1142 $(".catalog-pg__content").html(tmp.find(".catalog-pg__content").html()); 1143 $(".catalog-pg__items").removeClass("loading"); 1144 if (!!(history.pushState && history.state !== undefined)) { 1145 window.history.pushState({}, "", url); 1146 } 1147 if (lazyLoadInstance) { 1148 lazyLoadInstance.update(); 1149 } 1150 var tooltips = document.querySelectorAll(".has-tooltip"), 1151 tooltipText; 1152 1153 Array.prototype.forEach.call(tooltips, function(tooltip) { 1154 if (tooltip.classList.contains("active") && !tooltip.classList.contains("pd-color")) { 1155 tooltipText = tooltip.getAttribute("data-active"); 1156 } else { 1157 tooltipText = tooltip.getAttribute("data-title"); 1158 } 1159 1160 if (!tooltip.classList.contains("is-init")) { 1161 tooltip.classList.add("is-init"); 1162 1163 tooltipSpan = document.createElement("span"); 1164 1165 tooltipSpan.className = "b-tooltip"; 1166 tooltipSpan.innerHTML = tooltipText; 1167 tooltip.appendChild(tooltipSpan); 1168 } else { 1169 return; 1170 } 1171 }); 1172 }); 1173 }; 1174 1175 $(".catalog-pg__filter-v input").change(function() { 1176 ajax_form_callback($(this).closest("form")); 1177 }); 1178 $(".catalog-pg__filter-v").submit(function() { 1179 ajax_form_callback($(this)); 1180 return false; 1181 }); 1182 1183 $(".catalog-pg__filter-v .range-slider").each(function() { 1184 if (!$(this).find(".range-slider__caret").length) { 1185 $(this).append('<div class="range-slider__caret"></div>'); 1186 } else { 1187 return; 1188 } 1189 var min = $(this).find(".filter-range__min"); 1190 var max = $(this).find(".filter-range__max"); 1191 var min_value = parseFloat(min.attr("placeholder")); 1192 var max_value = parseFloat(max.attr("placeholder")); 1193 var step = 1; 1194 var slider = $(this).find(".range-slider__caret"); 1195 if (slider.data("step")) { 1196 step = parseFloat(slider.data("step")); 1197 } else { 1198 var diff = max_value - min_value; 1199 if (Math.round(min_value) != min_value || Math.round(max_value) != max_value) { 1200 step = diff / 10; 1201 var tmp = 0; 1202 while (step < 1) { 1203 step *= 10; 1204 tmp += 1; 1205 } 1206 step = Math.pow(10, -tmp); 1207 tmp = Math.round(100000 * Math.abs(Math.round(min_value) - min_value)) / 100000; 1208 if (tmp && tmp < step) { 1209 step = tmp; 1210 } 1211 tmp = Math.round(100000 * Math.abs(Math.round(max_value) - max_value)) / 100000; 1212 if (tmp && tmp < step) { 1213 step = tmp; 1214 } 1215 } 1216 } 1217 slider.slider({ 1218 range: true, 1219 min: parseFloat(min.attr("placeholder")), 1220 max: parseFloat(max.attr("placeholder")), 1221 step: step, 1222 values: [ 1223 parseFloat(min.val().length ? min.val() : min.attr("placeholder")), 1224 parseFloat(max.val().length ? max.val() : max.attr("placeholder")) 1225 ], 1226 slide: function(event, ui) { 1227 var v = ui.values[0] == $(this).slider("option", "min") ? "" : ui.values[0]; 1228 min.val(v); 1229 v = ui.values[1] == $(this).slider("option", "max") ? "" : ui.values[1]; 1230 max.val(v); 1231 }, 1232 stop: function(event, ui) { 1233 min.change(); 1234 } 1235 }); 1236 min.add(max).change(function() { 1237 var v_min = min.val() === "" ? slider.slider("option", "min") : parseFloat(min.val()); 1238 var v_max = max.val() === "" ? slider.slider("option", "max") : parseFloat(max.val()); 1239 if (v_max >= v_min) { 1240 slider.slider("option", "values", [v_min, v_max]); 1241 } 1242 }); 1243 }); 1244 }; 1245 f(); 1246 1247 //ADD TO CART 1248 $(document).on("click", "form.addtocart a.js-addtocart-submit", function(e) { 1249 e.preventDefault(); 1250 $(this) 1251 .closest("form") 1252 .trigger("submit"); 1253 }); 1254 $(document).on("submit", "form.addtocart", function() { 1255 var f = $(this); 1256 f.find("button:submit, input:submit") 1257 .addClass("is-adding-cart") 1258 .attr("disabled", "disabled"); 1259 f.closest(".pd-equal-item").addClass("is-loading"); 1260 f.find(".side-item").addClass("is-loading"); 1261 if (f.data("url")) { 1262 $.get(f.data("url"), function(html) { 1263 $("#extend-purchase .b-popup-it-opt__content").html(html); 1264 $("#extend-purchase .b-popup-it-opt__title").html(f.data("title")); 1265 if (typeof jQuery.fn.stylizeInput === "function") { 1266 $("#extend-purchase input[type=checkbox],#extend-purchase input[type=radio]").stylizeInput(); 1267 } 1268 var tooltips = document.querySelectorAll(".has-tooltip"), 1269 tooltipText; 1270 1271 Array.prototype.forEach.call(tooltips, function(tooltip) { 1272 if (tooltip.classList.contains("active") && !tooltip.classList.contains("pd-color")) { 1273 tooltipText = tooltip.getAttribute("data-active"); 1274 } else { 1275 tooltipText = tooltip.getAttribute("data-title"); 1276 } 1277 1278 if (!tooltip.classList.contains("is-init")) { 1279 tooltip.classList.add("is-init"); 1280 1281 tooltipSpan = document.createElement("span"); 1282 1283 tooltipSpan.className = "b-tooltip"; 1284 tooltipSpan.innerHTML = tooltipText; 1285 tooltip.appendChild(tooltipSpan); 1286 } else { 1287 return; 1288 } 1289 }); 1290 $.magnificPopup.open({ 1291 items: { 1292 src: "#extend-purchase" 1293 }, 1294 type: "inline", 1295 removalDelay: 0, 1296 mainClass: "mfp-zoom-in", 1297 callbacks: { 1298 beforeOpen: function() { 1299 this.wrap.removeAttr("tabindex") 1300 }, 1301 open: function() { 1302 $("<a></a>", { text: "Close", href: "#" }) 1303 .addClass("b-popup__close ds-hide") 1304 .prependTo(".mfp-container") 1305 .on("click", function() { 1306 $.magnificPopup.close(); 1307 });
1308 }, 1309 close: function() { 1310 $(".b-popup__close").remove(); 1311 } 1312 } 1313 }); 1314 f.find("button:submit, input:submit") 1315 .removeClass("is-adding-cart") 1316 .removeAttr("disabled"); 1317 f.closest(".pd-equal-item").removeClass("is-loading"); 1318 f.find(".side-item").removeClass("is-loading"); 1319 $(".cart-popup__close").click(function() { 1320 $.magnificPopup.close(); 1321 return false; 1322 }); 1323 }); 1324 return false; 1325 } 1326 var _p_title = f.data("title"), 1327 _p_price = f.data("price"), 1328 _p_oldprice = f.data("oldprice"), 1329 _p_image = f.data("image"), 1330 _p_qty = f.find(".qty__inner input").val(); 1331 $.post( 1332 f.attr("action") + "?items=1&html=1", 1333 f.serialize(), 1334 function(response) { 1335 f.find("button:submit, input:submit") 1336 .removeClass("is-adding-cart") 1337 .removeAttr("disabled"); 1338 f.closest(".pd-equal-item").removeClass("is-loading"); 1339 f.find(".side-item").removeClass("is-loading"); 1340 if (response.status == "ok") { 1341 $("#added-to-cart .js-item__title").html(_p_title); 1342 $("#added-to-cart .b-popup-cart__price-new").html(_p_price); 1343 if (_p_oldprice.length > 0) $("#added-to-cart .b-popup-cart__price-old").html(_p_oldprice); 1344 else 1345 $("#added-to-cart .b-popup-cart__price-old") 1346 .html("") 1347 .hide(); 1348 $("#added-to-cart .b-popup-cart__image img").attr("src", _p_image); 1349 if (parseInt(_p_qty) > 1) 1350 $("#added-to-cart .js-item__quantity") 1351 .show() 1352 .find("span") 1353 .html(_p_qty); 1354 else $("#added-to-cart .js-item__quantity").hide(); 1355 // Update cart counters 1356 updateHeaderCart(response.data); 1357 // construct popup 1358 if ($(".b-popup_cart-1").length) { 1359 // big popup 1360 $.magnificPopup.open({ 1361 items: { 1362 src: "#added-to-cart" 1363 }, 1364 type: "inline", 1365 removalDelay: 300, 1366 mainClass: "mfp-zoom-in", 1367 callbacks: { 1368 open: function() { 1369 $("<a></a>", { text: "Close", href: "#" }) 1370 .addClass("b-popup__close ds-hide") 1371 .prependTo(".mfp-container") 1372 .on("click", function() { 1373 $.magnificPopup.close(); 1374 }); 1375 $(".mfp-content").addClass("b-popup-container b-popup-container_default"); 1376 }, 1377 close: function() { 1378 $(".b-popup__close").remove(); 1379 } 1380 } 1381 }); 1382 } else if ($(".b-popup_cart-2").length) { 1383 // fixed top popup 1384 if (typeof _balance_added_to_cart_timer == "number") clearInterval(_balance_added_to_cart_timer); 1385 1386 $(".b-popup_cart-2").addClass("is-shown"); 1387 var countNum = parseInt($(".b-popup-cart__notif .countdown").data("ttl")); 1388 if (countNum <= 0) countNum = 5; 1389 1390 $(".b-popup-cart__notif .countdown").html(countNum); 1391 1392 _balance_added_to_cart_timer = setInterval(function() { 1393 if (countNum === 0) { 1394 $(".b-popup_cart-2").removeClass("is-shown"); 1395 clearInterval(_balance_added_to_cart_timer); 1396 } else { 1397 countNum--; 1398 $(".b-popup-cart__notif .countdown").html(countNum); 1399 } 1400 }, 1000); 1401 $(".b-popup-cart__close-btn").on("click", function() { 1402 $(".b-popup_cart-2").removeClass("is-shown"); 1403 clearInterval(_balance_added_to_cart_timer); 1404 }); 1405 } 1406 } else if (response.status == "fail") { 1407 alert(response.errors); 1408 } 1409 }, 1410 "json" 1411 ); 1412 return false; 1413 }); 1414 1415 // Compare add/remove 1416 $(document).on("click", ".btn-compare", function(e) { 1417 e.preventDefault(); 1418 var product = $(this).data("product"); 1419 var compare = $.cookie("shop_compare"); 1420 $.cookie("shop_compare", compare, { expires: 30, path: "/" }); 1421 if (!$(this).hasClass("active")) { 1422 // add 1423 var tooltip_text = $(this).data("active"); 1424 if (compare) { 1425 var i = $.inArray(product + "", compare.split(",")); 1426 } else { 1427 var i = -1; 1428 } 1429 if (i == -1) { 1430 if (compare) { 1431 compare += "," + product; 1432 } else { 1433 compare = "" + product; 1434 } 1435 } 1436 if (compare.split(",").length > 1) { 1437 var url = $(this) 1438 .data("url") 1439 .replace(/compare\/.*$/, "compare/" + compare + "/"); 1440 } else { 1441 var url = "javascript:void(0);"; 1442 } 1443 // update counters 1444 var compare_count = compare.split(",").length; 1445 $.cookie("shop_compare", compare, { expires: 30, path: "/" }); 1446 $(".btn-compare-" + product).addClass("active"); 1447 // show popup 1448 if (compare_count > 1 && $("#compare-popup").length) { 1449 $("#compare-popup .compare-popup-count").html("(" + compare_count + ")"); 1450 $("#compare-popup .js-compare-link").attr("href", url); 1451 $("#compare-popup .js-compare-popup-productimg").attr("src", $(this).data("product_image")); 1452 $("#compare-popup .js-compare-popup-productname").html($(this).data("product_name"));
1453 $("#compare-popup .js-compare-popup-productlink").attr("href", $(this).data("product_url")); 1454 if (typeof _balance_added_to_compare_timer == "number") clearInterval(_balance_added_to_compare_timer); 1455 1456 $("#compare-popup").addClass("is-shown"); 1457 var countNum = parseInt($("#compare-popup").data("ttl")); 1458 if (countNum <= 0) countNum = 5; 1459 1460 _balance_added_to_compare_timer = setInterval(function() { 1461 if (countNum === 0) { 1462 $("#compare-popup").removeClass("is-shown"); 1463 clearInterval(_balance_added_to_compare_timer); 1464 } else { 1465 countNum--; 1466 //$(".b-popup-cart__notif .countdown").html(countNum); 1467 } 1468 }, 1000); 1469 $("#compare-popup .popup-compare__close-btn").on("click", function() { 1470 $("#compare-popup").removeClass("is-shown"); 1471 clearInterval(_balance_added_to_compare_timer); 1472 }); 1473 } 1474 } else { 1475 if (typeof _balance_added_to_compare_timer == "number") { 1476 clearInterval(_balance_added_to_compare_timer); 1477 $("#compare-popup").removeClass("is-shown"); 1478 } 1479 var tooltip_text = $(this).data("title"); 1480 if (compare) { 1481 compare = compare.split(","); 1482 } else { 1483 compare = []; 1484 } 1485 var i = $.inArray(product + "", compare); 1486 if (i != -1) { 1487 compare.splice(i, 1); 1488 } 1489 if (compare.length > 1) { 1490 var url = $(this) 1491 .data("url") 1492 .replace(/compare\/.*$/, "compare/" + compare + "/"); 1493 $.cookie("shop_compare", compare.join(","), { expires: 30, path: "/" }); 1494 } else if (compare.length == 1) { 1495 var url = "javascript:void(0);"; 1496 $.cookie("shop_compare", compare.join(","), { expires: 30, path: "/" }); 1497 } else { 1498 $.cookie("shop_compare", null, { expires: 0, path: "/" }); 1499 } 1500 var compare_count = compare.length; 1501 $(".btn-compare-" + product).removeClass("active"); 1502 } 1503 $(this) 1504 .find(".b-tooltip") 1505 .text(tooltip_text); 1506 $(".js-compare-count").html(compare_count); 1507 if (compare_count > 1) { 1508 $(".js-compare-status").addClass("not-empty"); 1509 } else { 1510 $(".js-compare-status").removeClass("not-empty"); 1511 } 1512 $(".js-compare-link").attr("href", url); 1513 }); 1514 // Favorite add/remove 1515 $(document).on("click", ".btn-fav", function(e) { 1516 e.preventDefault(); 1517 var product = $(this).data("product"); 1518 var fav = $.cookie("shop_favorite"); 1519 $.cookie("shop_favorite", fav, { expires: 30, path: "/" }); 1520 if (!$(this).hasClass("active")) { 1521 // add 1522 var tooltip_text = $(this).data("active"); 1523 if (fav) { 1524 var i = $.inArray(product + "", fav.split(",")); 1525 } else { 1526 var i = -1; 1527 } 1528 if (i == -1) { 1529 if (fav) { 1530 fav += "," + product; 1531 } else { 1532 fav = "" + product; 1533 } 1534 } 1535 var wishlist_count = fav.split(",").length; 1536 $.cookie("shop_favorite", fav, { expires: 30, path: "/" }); 1537 $(".btn-fav-" + product).addClass("active"); 1538 } else { 1539 var tooltip_text = $(this).data("title"); 1540 if (fav) { 1541 fav = fav.split(","); 1542 } else { 1543 fav = []; 1544 } 1545 var i = $.inArray(product + "", fav); 1546 if (i != -1) { 1547 fav.splice(i, 1); 1548 } 1549 if (fav) { 1550 $.cookie("shop_favorite", fav.join(","), { expires: 30, path: "/" }); 1551 } else { 1552 $.cookie("shop_favorite", null); 1553 } 1554 var wishlist_count = fav.length; 1555 $(".btn-fav-" + product).removeClass("active"); 1556 } 1557 if (wishlist_count > 0) { 1558 $(".js-wishlist-status").addClass("not-empty"); 1559 } else { 1560 $(".js-wishlist-status").removeClass("not-empty"); 1561 } 1562 $(".js-wishlist-count").html(wishlist_count); 1563 $(this) 1564 .find(".b-tooltip") 1565 .text(tooltip_text); 1566 }); 1567 // Changing products view mode 1568 $(document).on("click", ".option-p__item-type", function(e) { 1569 e.preventDefault(); 1570 var url = window.location.href; 1571 var _theme_products_view_mode = $(this).data("type"); 1572 $.cookie("_theme_products_view_mode", _theme_products_view_mode, { expires: 30, path: "/" }); 1573 $(".option-p__item-type.active").removeClass("active"); 1574 $(this).addClass("active"); 1575 //$(window).lazyLoad && $(window).lazyLoad('sleep'); 1576 $(".catalog-pg__items").addClass("loading"); 1577 $.get(url, function(html) { 1578 var tmp = $("<div></div>").html(html); 1579 $(".catalog-pg__content").html(tmp.find(".catalog-pg__content").html()); 1580 $(".catalog-pg__items").removeClass("loading"); 1581 if (lazyLoadInstance) {
1582 lazyLoadInstance.update(); 1583 } 1584 var tooltips = document.querySelectorAll(".has-tooltip"), 1585 tooltipText; 1586 1587 Array.prototype.forEach.call(tooltips, function(tooltip) { 1588 if (tooltip.classList.contains("active") && !tooltip.classList.contains("pd-color")) { 1589 tooltipText = tooltip.getAttribute("data-active"); 1590 } else { 1591 tooltipText = tooltip.getAttribute("data-title"); 1592 } 1593 1594 if (!tooltip.classList.contains("is-init")) { 1595 tooltip.classList.add("is-init"); 1596 1597 tooltipSpan = document.createElement("span"); 1598 1599 tooltipSpan.className = "b-tooltip"; 1600 tooltipSpan.innerHTML = tooltipText; 1601 tooltip.appendChild(tooltipSpan); 1602 } else { 1603 return; 1604 } 1605 }); 1606 }); 1607 }); 1608 // Quickview 1609 $(document).on("click", ".btn-quickview", function(e) { 1610 e.preventDefault(); 1611 var b = $(this); 1612 b.closest(".item-c, .item-list-c, .item-line-c").addClass("is-loading"); 1613 if (b.data("url")) { 1614 $.get(b.data("url"), function(html) { 1615 var tmp = $("<div></div>").html(html); 1616 $("#quickview-popup .item-pg").html(tmp.find(".item-pg").html()); 1617 if (lazyLoadInstance) { 1618 lazyLoadInstance.update(); 1619 } 1620 if (typeof jQuery.fn.stylizeInput === "function") { 1621 $("#quickview-popup input[type=checkbox],#quickview-popup input[type=radio]").stylizeInput(); 1622 } 1623 var tooltips = document.querySelectorAll(".has-tooltip"), 1624 tooltipText; 1625 1626 Array.prototype.forEach.call(tooltips, function(tooltip) { 1627 if (tooltip.classList.contains("active") && !tooltip.classList.contains("pd-color")) { 1628 tooltipText = tooltip.getAttribute("data-active"); 1629 } else { 1630 tooltipText = tooltip.getAttribute("data-title"); 1631 } 1632 1633 if (!tooltip.classList.contains("is-init")) { 1634 tooltip.classList.add("is-init"); 1635 1636 tooltipSpan = document.createElement("span"); 1637 1638 tooltipSpan.className = "b-tooltip"; 1639 tooltipSpan.innerHTML = tooltipText; 1640 tooltip.appendChild(tooltipSpan); 1641 } else { 1642 return; 1643 } 1644 }); 1645 $.magnificPopup.open({ 1646 items: { 1647 src: "#quickview-popup" 1648 }, 1649 type: "inline", 1650 removalDelay: 300, 1651 mainClass: "mfp-zoom-in", 1652 callbacks: { 1653 open: function() { 1654 $("<a></a>", { text: "Close", href: "#" }) 1655 .addClass("b-popup__close ds-hide") 1656 .prependTo(".mfp-container") 1657 .on("click", function() { 1658 $.magnificPopup.close(); 1659 });
1660 $(".mfp-content").addClass("b-popup-container b-popup-container_fastview"); 1661 }, 1662 close: function() { 1663 $(".b-popup__close").remove(); 1664 } 1665 } 1666 }); 1667 b.closest(".item-c, .item-list-c, .item-line-c").removeClass("is-loading"); 1668 }); 1669 } 1670 }); 1671 1672 /* 1673 //РеализаÑÐ¸Ñ Ð¾Ð´Ð¸Ð½Ð°ÐºÐ¾Ð²Ñй вÑÑоÑÑ Ð±Ð»Ð¾ÐºÐ¾Ð² в каÑÑоÑÐºÐ°Ñ ÑоваÑа 1674 if (window.matchMedia("(min-width: 768px)").matches) { 1675 if ($(".item-c_equal").length) { 1676 var inline = 0; 1677 var offsettop = 0; 1678 $(".item-c_equal").each(function(){ 1679 if(inline == 0) { 1680 offsettop = $(this).offset().top; 1681 } 1682 if($(this).offset().top > offsettop) 1683 return false; 1684 inline++; 1685 }); 1686 var total = $(".item-c_equal").closest(".ui-items").length; 1687 var equalPerLine = function(from,to,inline,total){ 1688 console.log("from:"+from+"; to:"+to+"; inline:"+inline+"; total:"+total); 1689 var rows = [{descr:0,chars:0}]; 1690 for(i=from;i<=to;++i) { 1691 if(rows[0].descr < $(".item-c_equal").closest(".ui-items").find(".ui-items__item:nth-child("+i+") .item-c__short-descr").height()) 1692 rows[0].descr = $(".item-c_equal").closest(".ui-items").find(".ui-items__item:nth-child("+i+") .item-c__short-descr").height(); 1693 if(rows[0].chars < $(".item-c_equal").closest(".ui-items").find(".ui-items__item:nth-child("+i+") .item-c__chars").height()) 1694 rows[0].chars = $(".item-c_equal").closest(".ui-items").find(".ui-items__item:nth-child("+i+") .item-c__chars").height(); 1695 } 1696 for(i=from;i<=to;++i) { 1697 $(".item-c_equal").closest(".ui-items").find(".ui-items__item:nth-child("+i+") .item-c__short-descr").height(rows[0].descr); 1698 $(".item-c_equal").closest(".ui-items").find(".ui-items__item:nth-child("+i+") .item-c__chars").height(rows[0].chars); 1699 } 1700 if(from < total) 1701 equalPerLine((to + 1),(to + inline),inline,total); 1702 }; 1703 equalPerLine(1,inline,inline,10); 1704 } 1705 } 1706 */ 1707 1708 $(document).on("click", ".qty__btn_decr, .qty__btn_incr", function(e) { 1709 e.preventDefault(); 1710 var input = $(this) 1711 .closest(".qty__inner") 1712 .find("input"); 1713 if ($(this).hasClass("qty__btn_decr")) var new_val = parseInt(input.val()) - 1; 1714 else if ($(this).hasClass("qty__btn_incr")) var new_val = parseInt(input.val()) + 1; 1715 if (new_val <= 0) new_val = 1; 1716 $(this) 1717 .closest(".qty__inner") 1718 .find("input") 1719 .val(new_val) 1720 .trigger("change"); 1721 }); 1722 1723 // Viewed products TODO:re 1724 if ($("body").data("viewed")) { 1725 var product = $("body").data("viewed"); 1726 var balance_viewed = $.cookie("balance_viewed"); 1727 $.cookie("balance_viewed", balance_viewed, { expires: 30, path: "/" }); 1728 if (balance_viewed) { 1729 var i = $.inArray(product + "", balance_viewed.split(",")); 1730 } else { 1731 var i = -1; 1732 } 1733 if (i == -1) { 1734 if (balance_viewed) { 1735 balance_viewed += "," + product; 1736 } else { 1737 balance_viewed = "" + product; 1738 } 1739 } 1740 $.cookie("balance_viewed", balance_viewed, { expires: 30, path: "/" }); 1741 } 1742 $(document).on("click", ".clear-viewed-history", function(e) { 1743 e.preventDefault(); 1744 $.cookie("balance_viewed", null); 1745 $(".viewed-history-wrapper").remove(); 1746 }); 1747 1748 $(document).on("click", ".catalog-pg__options .drop-list__link", function(e) { 1749 e.preventDefault(); 1750 $.cookie("products_per_page", $(this).text(), { expires: 30, path: "/" }); 1751 var url = window.location.search.replace(/(page=)(\w+)/g, "page=1"); 1752 $(".catalog-pg__items").addClass("loading"); 1753 $.get(url, function(html) { 1754 var tmp = $("<div></div>").html(html); 1755 $(".catalog-pg__content").html(tmp.find(".catalog-pg__content").html()); 1756 $(".catalog-pg__items").removeClass("loading"); 1757 if (!!(history.pushState && history.state !== undefined)) { 1758 window.history.pushState({}, "", url); 1759 } 1760 if (lazyLoadInstance) { 1761 lazyLoadInstance.update(); 1762 } 1763 var tooltips = document.querySelectorAll(".has-tooltip"), 1764 tooltipText; 1765 1766 Array.prototype.forEach.call(tooltips, function(tooltip) { 1767 if (tooltip.classList.contains("active") && !tooltip.classList.contains("pd-color")) { 1768 tooltipText = tooltip.getAttribute("data-active"); 1769 } else { 1770 tooltipText = tooltip.getAttribute("data-title"); 1771 } 1772 1773 if (!tooltip.classList.contains("is-init")) { 1774 tooltip.classList.add("is-init"); 1775 1776 tooltipSpan = document.createElement("span"); 1777 1778 tooltipSpan.className = "b-tooltip"; 1779 tooltipSpan.innerHTML = tooltipText; 1780 tooltip.appendChild(tooltipSpan); 1781 } else { 1782 return; 1783 } 1784 }); 1785 }); 1786 }); 1787})();
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.