PageSourceSearch

https://silavdetyah.ru/wp-content/themes/rehab/assets/js/common.js?ver=1.0.2

js silavdetyah.ru collected 2026-10-05 19:20:24 UTC 17,275 bytes, 710 lines download raw bytes

1jQuery(document).ready(function ($) {
2  var scrollWidth = window.innerWidth - document.documentElement.clientWidth;
3
4  $("img, a").on("dragstart", function (event) {
5    event.preventDefault();
6  });
7
8  $(window).on("load", function () {
9    $(".bann-item__wrap").matchHeight();
10    $(".news-item__main").matchHeight();
11    $(".serv-item__main").matchHeight();
12  });
13
14  $('[type="tel"]').mask("+7 999 999-99-99");
15
16  $(document).on("wpcf7mailsent", function (e) {
17    $.magnificPopup.open(popupArgs("#tx-popup"));
18  });
19
20  $("select[data-sendmail]").each(function () {
21    var form = $(this).closest("form"),
22      input = form.find('[name="send-mail"]');
23
24    input.val($(this).val());
25
26    $(this).change(function () {
27      input.val($(this).val());
28    });
29  });
30
31  $("select[data-input]").each(function () {
32    var form = $(this).closest("form"),
33      input = form.find('[name="' + $(this).attr("data-input") + '"]');
34
35    input.val($(this).find("option:selected").text());
36
37    $(this).change(function () {
38      input.val($(this).find("option:selected").text());
39    });
40  });
41
42  $(".js-loadmore")
43    .each(function () {
44      $(this).attr("data-text", $(this).text());
45    })
46    .click(function () {
47      var btn = $(this),
48        box = $(this).attr("data-box");
49
50      btn.prop("disabled", true).text("Загрузка...");
51
52      var data = {
53        action: "loadmore",
54        query: true_posts[box],
55        page: parseInt(current_page[box]),
56        tpl: ajax_tpl[box],
57        wrap: ajax_wrap[box],
58      };
59
60      $.ajax({
61        url: ajaxurl, // обработчик
62        data: data, // данные
63        type: "POST", // тип запроса
64        success: function (data) {
65          if (data) {
66            btn.prop("disabled", false).text(btn.attr("data-text"));
67            $("#" + box).append(data);
68            current_page[box]++; // увеличиваем номер страницы на единицу
69            if (current_page[box] == max_pages[box])
70              btn.closest(".btn-box").remove(); // если последняя страница, удаляем кнопку
71          } else {
72            btn.closest(".btn-box").remove(); // если мы дошли до последней страницы постов, скроем кнопку
73          }
74        },
75      });
76    });
77
78  // Maps
79
80  var mainMap;
81  var contactsMap;
82
83  var mapIcon = {
84    iconLayout: "default#image",
85    iconImageHref: tpl_url + "/assets/img/mark.svg",
86    iconImageSize: [33, 38],
87    iconImageOffset: [-16, -38],
88  };
89
90  function mainMapInit() {
91    mainMap = new ymaps.Map("main-map", {
92      center: [55.76730619528606, 49.099981999999954],
93      zoom: 10,
94      controls: ["fullscreenControl"],
95    });
96
97    mainMap.controls.add("zoomControl", {
98      float: "none",
99      position: {
100        top: "8px",
101        left: "8px",
102      },
103    });
104
105    myGeoObject = new ymaps.GeoObject({});
106
107    $.each(mapMarkers, function (i, value) {
108      mainMap.geoObjects.add(myGeoObject).add(
109        new ymaps.Placemark(
110          value.coord.split(","),
111          {
112            hintContent: value.address,
113          },
114          mapIcon,
115        ),
116      );
117    });
118
119    mainMap.setBounds(mainMap.geoObjects.getBounds());
120  }
121  if ($("#main-map").length > 0 && mapMarkers) ymaps.ready(mainMapInit);
122
123  function contactsMapInit() {
124    contactsMap = new ymaps.Map("contacts-map", {
125      center: mapMarkers[0].coord.split(","),
126      zoom: 14,
127      controls: ["fullscreenControl"],
128    });
129
130    contactsMap.controls.add("zoomControl", {
131      float: "none",
132      position: {
133        top: "8px",
134        left: "8px",
135      },
136    });
137
138    myGeoObject = new ymaps.GeoObject({});
139
140    $.each(mapMarkers, function (i, value) {
141      contactsMap.geoObjects.add(myGeoObject).add(
142        new ymaps.Placemark(
143          value.coord.split(","),
144          {
145            hintContent: value.address,
146          },
147          mapIcon,
148        ),
149      );
150    });
151  }
152
153  if ($("#contacts-map").length > 0 && mapMarkers) ymaps.ready(contactsMapInit);
154
155  // Maps END
156
157  // Popups
158
159  function popupArgs(src, type) {
160    console.log(type);
161    var args = {
162      type: "inline",
163      removalDelay: 500,
164      mainClass: "mfp-zoom-in",
165      tClose: "Закрыть",
166      tLoading: "Загрузка...",
167      closeMarkup:
168        '<button title="%title%" class="close-btn ic ic-close" data-popup-close></button>',
169      image: {
170        tError: '<a href="%url%">Изображение</a> не может быть загружено.',
171      },
172      callbacks: {
173        beforeOpen: function () {
174          this.container[0].classList.add("mfp-with-anim");
175        },
176        open: function () {
177          $(".menu__scroll._fixed").css("margin-right", scrollWidth);
178        },
179        close: function () {
180          $(".menu__scroll._fixed").css("margin-right", "");
181        },
182      },
183    };
184
185    if (type == "iframe" || type == "image") args["type"] = type;
186
187    if (type == "gallery") {
188      args["type"] = "image";
189      args["gallery"] = {
190        tPrev: "Назад (или нажмите влево)",
191        tNext: "Далее (или нажмите вправо)",
192        tCounter: "%curr% из %total%",
193        enabled: true,
194      };
195    } else {
196      args["items"] = {
197        src: src,
198      };
199    }
200
201    return args;
202  }
203
204  $("body").on("click", "[data-popup]", function () {
205    $.magnificPopup.open(
206      popupArgs($(this).attr("href"), $(this).attr("data-popup")),
207    );
208    return false;
209  });
210
211  $("body").on("click", "[data-popup-close]", function () {
212    $.magnificPopup.close();
213    return false;
214  });
215
216  $(".js-gallery").each(function () {
217    $(this)
218      .find("a")
219      .not("[data-popup]")
220      .magnificPopup(popupArgs(false, "gallery"));
221  });
222
223  // Popups END
224
225  $("[data-scroll]").mPageScroll2id({
226    scrollSpeed: 750,
227    offset: 70,
228    highlightClass: "active",
229    highlightByNextTarget: true,
230  });
231
232  // Menu
233
234  function fixMenu() {
235    if ($(window).scrollTop() > 0) $(".header__wrapper").addClass("_fixed");
236    else $(".header__wrapper").removeClass("_fixed");
237
238    if ($(".menu").length > 0) {
239      if ($(window).scrollTop() > $(".menu").offset().top)
240        $(".menu__scroll").addClass("_fixed");
241      else $(".menu__scroll").removeClass("_fixed");
242    }
243  }
244  $(window).on("load scroll", function () {
245    fixMenu();
246  });
247
248  function mobMenuShow() {
249    $(".mob-menu").addClass("_show");
250
251    $(".mob-menu-overlay").fadeIn(500);
252
253    $("body").css({
254      overflow: "hidden",
255      "margin-right": scrollWidth,
256    });
257  }
258
259  function mobMenuClose() {
260    $(".mob-menu").removeClass("_show");
261
262    $(".mob-menu-overlay").fadeOut(500);
263
264    setTimeout(function () {
265      $("body").css({
266        overflow: "",
267        "margin-right": "",
268      });
269    }, 500);
270  }
271
272  $(".mob-menu-show").click(function () {
273    mobMenuShow();
274  });
275
276  $(".mob-menu .close-btn, .mob-menu-overlay").click(function () {
277    mobMenuClose();
278  });
279
280  // Menu END
281
282  $(".city-item__toggle").click(function () {
283    $(this).toggleClass("active");
284    $(this).siblings(".city-item__items").slideToggle();
285  });
286
287  // Top Phones
288
289  $(".top-phones__toggle").click(function () {
290    var drop = $(this).siblings(".top-phones__drop"),
291      height;
292
293    $(this).toggleClass("active");
294
295    if (window.matchMedia("(min-width: 1200px)").matches) {
296      height = $(window).height() - drop.offset().top;
297    } else {
298      height = $(window).height() - 35 - parseInt(drop.css("margin-top"));
299    }
300
301    drop.fadeToggle(200).css("max-height", height);
302  });
303
304  $(window).on("scroll resize", function () {
305    $(".top-phones__toggle").removeClass("active");
306    $(".top-phones__drop").hide();
307  });
308
309  // Top Phones END
310
311  // Sliders
312
313  var sliderIndex = -1;
314
315  $(".main-slider").each(function () {
316    var nav = false;
317
318    if ($(this).attr("id")) {
319      nav = {
320        prevEl: '[data-nav="' + $(this).attr("id") + '"] .nav-arrow-prev',
321        nextEl: '[data-nav="' + $(this).attr("id") + '"] .nav-arrow-next',
322      };
323    } else {
324      sliderIndex++;
325      $(this).attr("id", "js-slider-" + sliderIndex);
326    }
327
328    var slider = "#" + $(this).attr("id");
329
330    new Swiper(slider, {
331      slidesPerView: 2,
332      slidesPerGroup: 2,
333      spaceBetween: 15,
334      watchSlidesProgress: true,
335      watchOverflow: true,
336      navigation: nav,
337      pagination: {
338        el: ".swiper-pagination",
339        clickable: true,
340      },
341      breakpoints: {
342        768: {
343          slidesPerView: 3,
344          slidesPerGroup: 3,
345          spaceBetween: 15,
346        },
347        992: {
348          slidesPerView: 4,
349          slidesPerGroup: 4,
350          spaceBetween: 15,
351        },
352        1200: {
353          slidesPerView: 5,
354          slidesPerGroup: 5,
355          spaceBetween: 20,
356        },
357      },
358    });
359  });
360
361  new Swiper(".bann-slider", {
362    loop: $(".bann-slider .swiper-slide").length > 1 ? true : false,
363    autoplay: {
364      delay: 4000,
365    },
366    watchSlidesProgress: true,
367    watchOverflow: true,
368    navigation: {
369      prevEl: ".nav-arrow-prev",
370      nextEl: ".nav-arrow-next",
371    },
372    pagination: {
373      el: ".swiper-pagination",
374      clickable: true,
375    },
376  });
377
378  new Swiper(".partners-slider", {
379    loop: true,
380    autoplay: {
381      delay: 3000,
382    },
383    slidesPerView: 2,
384    slidesPerGroup: 1,
385    spaceBetween: 20,
386    watchSlidesProgress: true,
387    watchOverflow: true,
388    pagination: {
389      el: ".swiper-pagination",
390      clickable: true,
391    },
392    breakpoints: {
393      576: {
394        slidesPerView: 3,
395        slidesPerGroup: 1,
396        spaceBetween: 30,
397      },
398      768: {
399        slidesPerView: 4,
400        slidesPerGroup: 2,
401        spaceBetween: 30,
402      },
403      1200: {
404        slidesPerView: 6,
405        slidesPerGroup: 2,
406        spaceBetween: 30,
407      },
408    },
409  });
410
411  new Swiper(".service__slider", {
412    spaceBetween: 15,
413    watchSlidesProgress: true,
414    watchOverflow: true,
415    navigation: {
416      prevEl: ".nav-arrow-prev",
417      nextEl: ".nav-arrow-next",
418    },
419    pagination: {
420      el: ".swiper-pagination",
421      clickable: true,
422    },
423  });
424
425  new Swiper(".serv-items-slider", {
426    slidesPerView: 2,
427    spaceBetween: 15,
428    watchSlidesProgress: true,
429    watchOverflow: true,
430    pagination: {
431      el: ".swiper-pagination",
432      clickable: true,
433    },
434    breakpoints: {
435      768: {
436        slidesPerView: 3,
437        spaceBetween: 15,
438      },
439      992: {
440        slidesPerView: 4,
441        spaceBetween: 15,
442      },
443      1200: {
444        slidesPerView: 4,
445        spaceBetween: 20,
446      },
447    },
448  });
449
450  new Swiper(".story-slider", {
451    slidesPerView: "auto",
452    spaceBetween: 20,
453    watchSlidesProgress: true,
454    watchOverflow: true,
455    pagination: {
456      el: ".swiper-pagination",
457      clickable: true,
458    },
459    breakpoints: {
460      576: {
461        slidesPerView: 2,
462        spaceBetween: 20,
463      },
464      992: {
465        slidesPerView: 3,
466        spaceBetween: 30,
467      },
468    },
469  });
470
471  new Swiper(".team-reviews__slider", {
472    slidesPerView: "auto",
473    spaceBetween: 20,
474    speed: 900,
475    navigation: {
476      prevEl: ".team-reviews__slide-btn._prev",
477      nextEl: ".team-reviews__slide-btn._next",
478    },
479    breakpoints: {
480      1320: {
481        slidesPerView: 3,
482        spaceBetween: 25,
483      },
484    },
485  });
486
487  // Sliders END
488
489  // Tabs
490
491  $(".tab-btns").each(function () {
492    var wrap = $(this),
493      tabs = wrap.find(".tab-btn"),
494      items = wrap.attr("data-items");
495
496    items = items ? $(items) : wrap.siblings(".tab-items");
497
498    if (items.length > 0)
499      tabs
500        .click(function () {
501          var i = $(this).index();
502
503          if ($(this).hasClass("active")) return false;
504
505          tabs.removeClass("active").eq(i).addClass("active");
506          items.find(".tab-item").hide().eq(i).fadeIn();
507        })
508        .eq(0)
509        .addClass("active");
510  });
511
512  $(".about-tabs .tab-btn")
513    .click(function () {
514      var i = $(this).index();
515
516      if ($(this).hasClass("active")) return false;
517
518      $(".about-tabs .tab-btn").removeClass("active").eq(i).addClass("active");
519      $(".about-item").hide().eq(i).fadeIn();
520
521      if ($("#contacts-map").length > 0 && mapMarkers) {
522        var mark = mapMarkers[i];
523        if (mark) contactsMap.setCenter(mark.coord.split(","));
524      }
525    })
526    .eq(0)
527    .addClass("active");
528
529  // Tabs END
530
531  $(".faq-item__btn").click(function () {
532    var wrap = $(this).parent().parent();
533
534    if ($(this).hasClass("active")) {
535      $(this).removeClass("active");
536      $(this).siblings(".faq-item__hidden").slideUp();
537    } else {
538      wrap.find(".faq-item__btn").removeClass("active");
539      wrap.find(".faq-item__hidden:visible").slideUp();
540
541      $(this).addClass("active");
542      $(this).siblings(".faq-item__hidden").slideDown();
543    }
544  });
545
546  if ($("body").data("pageid") == 833) {
547    $.magnificPopup.open(popupArgs("#qr-popup", null));
548  }
549
550  const ratings = document.querySelectorAll("[data-rating]");
551
552  if (ratings.length) {
553    ratings.forEach((r) => {
554      const radios = r.querySelectorAll("input[type='radio']");
555
556      radios.forEach((input) => {
557        input.addEventListener("change", () =>
558          r.setAttribute("data-rating", input.value),
559        );
560      });
561    });
562  }
563
564  Fancybox.bind("[data-fancybox]");
565
566  function overflowText() {
567    const buttons = document.querySelectorAll("[data-overflow-text-btn]");
568    const texts = document.querySelectorAll("[data-overflow-text]");
569
570    if (texts.length) {
571      texts.forEach((text) => {
572        const parent = text.closest("[data-overflow-text-parent]");
573        const btn = parent.querySelector("[data-overflow-text-btn]");
574        const lines = +text.dataset.overflowText;
575        const lineHeight = +window
576          .getComputedStyle(text)
577          .lineHeight.slice(0, -2);
578
579        const isHidden = text.clientHeight / lineHeight > lines;
580
581        if (isHidden) {
582          text.classList.add("_overflow-text");
583          btn.style.display = "block";
584        }
585      });
586
587      buttons.forEach((btn) => {
588        btn.addEventListener("click", () => {
589          const parent = btn.closest("[data-overflow-text-parent]");
590          const text = parent.querySelector("[data-overflow-text]");
591
592          text.classList.remove("_overflow-text");
593          btn.remove();
594        });
595      });
596    }
597  }
598  overflowText();
599
600  function itemsHasChildrenToggle() {
601    const menu = document.querySelector(".mob-menu__list");
602    const items = menu.querySelectorAll(".menu-item-has-children");
603
604    if (items.length) {
605      items.forEach((item) => {
606        item.addEventListener("click", () => {
607          item.classList.toggle("_active");
608        });
609      });
610    }
611  }
612
613  itemsHasChildrenToggle();
614
615  const aboutTeamSliders = document.querySelectorAll(".about__item-slider");
616
617  if (aboutTeamSliders.length) {
618    aboutTeamSliders.forEach((slider) => {
619      new Swiper(slider, {
620        spaceBetween: 20,
621        speed: 900,
622        navigation: {
623          prevEl: slider.querySelector(".about__slide-btn._prev"),
624          nextEl: slider.querySelector(".about__slide-btn._next"),
625        },
626      });
627    });
628  }
629
630  new Swiper(".s-gallery__slider", {
631    slidesPerView: "auto",
632    spaceBetween: 25,
633    speed: 900,
634    autoplay: {
635      delay: 3000,
636    },
637    navigation: {
638      prevEl: document.querySelector(".s-gallery .nav-arrow-prev"),
639      nextEl: document.querySelector(".s-gallery .nav-arrow-next"),
640    },
641  });
642
643  function popupConnectOpen() {
644    setTimeout(() => {
645      $.magnificPopup.open(popupArgs("#feed-popup", ""));
646    }, 15000);
647  }
648
649  popupConnectOpen();
650
651  function jobFile() {
652    const input = document.querySelector("#jobs-file");
653
654    if (input) {
655      const text = document
656        .querySelector(`label[for="${input.id}"]`)
657        .querySelector("span");
658
659      input.addEventListener("change", (e) => {
660        if (e.target.files[0]) {
661          text.textContent = "Файл прикреплён";
662        }
663      });
664    }
665  }
666  function handlerCookie() {
667    function deleteCookie(name) {
668      document.cookie =
669        name + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
670    }
671    function setCookie(name, value, seconds) {
672      let expires = "";
673      if (seconds) {
674        const date = new Date();
675        date.setTime(date.getTime() + seconds * 1000);
676        expires = "; expires=" + date.toUTCString();
677      }
678      document.cookie =
679        name + "=" + encodeURIComponent(value) + expires + "; path=/";
680    }
681    function getCookie(name) {
682      var matches = document.cookie.match(
683        new RegExp(
684          "(?:^|; )" +
685            name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, "\\$1") +
686            "=([^;]*)",
687        ),
688      );
689      return matches ? decodeURIComponent(matches[1]) : undefined;
690    }
691
692    const cookieBtn = document.querySelector(".b-cookie__btn");
693
694    if (cookieBtn) {
695      const cookie = document.querySelector(".b-cookie");
696
697      cookieBtn.addEventListener("click", () => {
698        setCookie("accept_cookie", "on", 86400);
699
700        cookie.classList.add("_hide");
701        setTimeout(() => {
702          cookie.remove();
703        }, 300);
704      });
705    }
706  }
707
708  handlerCookie();
709  jobFile();
710});

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.