Commit 3d264874f8d03370e8eec8ce2df0794248a2e4d3
1 parent
bb21d1ccb2
Exists in
master
and in
1 other branch
Обновление
Showing 1 changed file with 1 additions and 0 deletions Inline Diff
public/js/script45.js
1 | let scripts = function () { | 1 | let scripts = function () { |
2 | 2 | ||
3 | $('.js-toggle').on('click', function () { | 3 | $('.js-toggle').on('click', function () { |
4 | $(this).toggleClass('active'); | 4 | $(this).toggleClass('active'); |
5 | }); | 5 | }); |
6 | $('.js-parent-toggle').on('click', function () { | 6 | $('.js-parent-toggle').on('click', function () { |
7 | $(this).parent().toggleClass('active'); | 7 | $(this).parent().toggleClass('active'); |
8 | }); | 8 | }); |
9 | $('.js-parent-remove').on('click', function () { | 9 | $('.js-parent-remove').on('click', function () { |
10 | $(this).parent().remove(); | 10 | $(this).parent().remove(); |
11 | }); | 11 | }); |
12 | $('.js-menu-toggle').on('click', function () { | 12 | $('.js-menu-toggle').on('click', function () { |
13 | window.scrollTo(0, 0); | 13 | window.scrollTo(0, 0); |
14 | $('#body').toggleClass('menu-is-actived'); | 14 | $('#body').toggleClass('menu-is-actived'); |
15 | }); | 15 | }); |
16 | $('.js-cookies-close').on('click', function () { | 16 | $('.js-cookies-close').on('click', function () { |
17 | $('#body').removeClass('cookies-is-actived'); | 17 | $('#body').removeClass('cookies-is-actived'); |
18 | }); | 18 | }); |
19 | $('.js-works-edit').on('click', function () { | 19 | $('.js-works-edit').on('click', function () { |
20 | $(this).parent().parent().parent().addClass('active'); | 20 | $(this).parent().parent().parent().addClass('active'); |
21 | }); | 21 | }); |
22 | $('.js-works-remove').on('click', function () { | 22 | $('.js-works-remove').on('click', function () { |
23 | $(this).parent().parent().parent().parent().remove(); | 23 | $(this).parent().parent().parent().parent().remove(); |
24 | }); | 24 | }); |
25 | 25 | ||
26 | $('[data-tab]').on('click', function () { | 26 | $('[data-tab]').on('click', function () { |
27 | $('[data-tab]').removeClass('active'); | 27 | $('[data-tab]').removeClass('active'); |
28 | $('[data-body]').removeClass('showed'); | 28 | $('[data-body]').removeClass('showed'); |
29 | $(this).addClass('active'); | 29 | $(this).addClass('active'); |
30 | var id = $(this).data('tab'); | 30 | var id = $(this).data('tab'); |
31 | $('[data-body=' + id + ']').addClass('showed'); | 31 | $('[data-body=' + id + ']').addClass('showed'); |
32 | }); | 32 | }); |
33 | 33 | ||
34 | $('.js-password-show').on('click', function () { | 34 | $('.js-password-show').on('click', function () { |
35 | $(this).parent().addClass('active'); | 35 | $(this).parent().addClass('active'); |
36 | $(this).parent().parent().find('input').attr('type', 'text'); | 36 | $(this).parent().parent().find('input').attr('type', 'text'); |
37 | }); | 37 | }); |
38 | 38 | ||
39 | $('.js-password-hide').on('click', function () { | 39 | $('.js-password-hide').on('click', function () { |
40 | $(this).parent().removeClass('active'); | 40 | $(this).parent().removeClass('active'); |
41 | $(this).parent().parent().find('input').attr('type', 'password'); | 41 | $(this).parent().parent().find('input').attr('type', 'password'); |
42 | }); | 42 | }); |
43 | 43 | ||
44 | let checkScrollTop = function () { | 44 | let checkScrollTop = function () { |
45 | if ($(document).scrollTop() == 0) { | 45 | if ($(document).scrollTop() == 0) { |
46 | $('#body').removeClass('begin'); | 46 | $('#body').removeClass('begin'); |
47 | } else { | 47 | } else { |
48 | $('#body').addClass('begin'); | 48 | $('#body').addClass('begin'); |
49 | } | 49 | } |
50 | } | 50 | } |
51 | checkScrollTop(); | 51 | checkScrollTop(); |
52 | $(document).on('scroll', function () { | 52 | $(document).on('scroll', function () { |
53 | checkScrollTop(); | 53 | checkScrollTop(); |
54 | }); | 54 | }); |
55 | 55 | ||
56 | let closeAll = function () { | 56 | let closeAll = function () { |
57 | $('.js-toggle').removeClass('active'); | 57 | $('.js-toggle').removeClass('active'); |
58 | $('.js-parent-toggle').parent().removeClass('active'); | 58 | $('.js-parent-toggle').parent().removeClass('active'); |
59 | $('#body').removeClass('menu-is-actived'); | 59 | $('#body').removeClass('menu-is-actived'); |
60 | $('#body').removeClass('cookies-is-actived'); | 60 | $('#body').removeClass('cookies-is-actived'); |
61 | } | 61 | } |
62 | 62 | ||
63 | $(document).keyup(function (e) { | 63 | $(document).keyup(function (e) { |
64 | if (e.key === "Escape") { | 64 | if (e.key === "Escape") { |
65 | closeAll(); | 65 | closeAll(); |
66 | } | 66 | } |
67 | }); | 67 | }); |
68 | 68 | ||
69 | $('.js-scroll-to').bind('click', function (e) { | 69 | $('.js-scroll-to').bind('click', function (e) { |
70 | let anchor = $(this); | 70 | let anchor = $(this); |
71 | $('html,body').stop().animate({ | 71 | $('html,body').stop().animate({ |
72 | scrollTop: $(anchor.attr('href')).offset().top | 72 | scrollTop: $(anchor.attr('href')).offset().top |
73 | }, 300); | 73 | }, 300); |
74 | e.preventDefault(); | 74 | e.preventDefault(); |
75 | }); | 75 | }); |
76 | 76 | ||
77 | if ($('[type=tel]').is('[type=tel]')) { | 77 | if ($('[type=tel]').is('[type=tel]')) { |
78 | $('[type=tel]').mask('+7 (999) 999-99-99'); | 78 | $('[type=tel]').mask('+7 (999) 999-99-99'); |
79 | } | 79 | } |
80 | 80 | ||
81 | if ($('.js-select2').is('.js-select2')) { | 81 | if ($('.js-select2').is('.js-select2')) { |
82 | $('.js-select2').select2(); | 82 | $('.js-select2').select2(); |
83 | } | 83 | } |
84 | 84 | ||
85 | const starRating = document.querySelectorAll(".js-stars"); | 85 | const starRating = document.querySelectorAll(".js-stars"); |
86 | if (starRating.length) { | 86 | if (starRating.length) { |
87 | starRating.forEach(item => { | 87 | starRating.forEach(item => { |
88 | new StarRating(item); | 88 | new StarRating(item); |
89 | }); | 89 | }); |
90 | } | 90 | } |
91 | 91 | ||
92 | // cookies | 92 | // cookies |
93 | const cookieItems = document.querySelectorAll(".js-ck"); | 93 | const cookieItems = document.querySelectorAll(".js-ck"); |
94 | if (cookieItems.length) { | 94 | if (cookieItems.length) { |
95 | console.log('Work with cokomi'); | 95 | console.log('Work with cokomi'); |
96 | cookieItems.forEach(item => { | 96 | cookieItems.forEach(item => { |
97 | let id = item.dataset.id; | 97 | let id = item.dataset.id; |
98 | let like = item.querySelector(".like"); | 98 | let like = item.querySelector(".like"); |
99 | let checkLike = function () { | 99 | let checkLike = function () { |
100 | if (like.classList.contains("active")) { | 100 | if (like.classList.contains("active")) { |
101 | Cookies.set(id, id); | 101 | Cookies.set(id, id); |
102 | } else { | 102 | } else { |
103 | Cookies.remove(id); | 103 | Cookies.remove(id); |
104 | } | 104 | } |
105 | } | 105 | } |
106 | like.addEventListener("click", () => { | 106 | like.addEventListener("click", () => { |
107 | checkLike(); | 107 | checkLike(); |
108 | }); | 108 | }); |
109 | if (Cookies.get(id) == id) { | 109 | if (Cookies.get(id) == id) { |
110 | like.classList.add("active"); | 110 | like.classList.add("active"); |
111 | } | 111 | } |
112 | }); | 112 | }); |
113 | } | 113 | } |
114 | console.log(Cookies.get()); | 114 | console.log(Cookies.get()); |
115 | 115 | ||
116 | |||
116 | }; | 117 | }; |
117 | 118 | ||
118 | let swipers = function () { | 119 | let swipers = function () { |
119 | 120 | ||
120 | if ($('.js-employer-swiper').is('.js-employer-swiper')) { | 121 | if ($('.js-employer-swiper').is('.js-employer-swiper')) { |
121 | let slider = new Swiper('.js-employer-swiper', { | 122 | let slider = new Swiper('.js-employer-swiper', { |
122 | autoplay: { | 123 | autoplay: { |
123 | delay: 5000, | 124 | delay: 5000, |
124 | }, | 125 | }, |
125 | pagination: { | 126 | pagination: { |
126 | el: '.swiper-pagination', | 127 | el: '.swiper-pagination', |
127 | clickable: true | 128 | clickable: true |
128 | }, | 129 | }, |
129 | breakpoints: { | 130 | breakpoints: { |
130 | 768: { | 131 | 768: { |
131 | slidesPerView: 2, | 132 | slidesPerView: 2, |
132 | }, | 133 | }, |
133 | 992: { | 134 | 992: { |
134 | slidesPerView: 3, | 135 | slidesPerView: 3, |
135 | }, | 136 | }, |
136 | 1280: { | 137 | 1280: { |
137 | slidesPerView: 4, | 138 | slidesPerView: 4, |
138 | }, | 139 | }, |
139 | } | 140 | } |
140 | }); | 141 | }); |
141 | } | 142 | } |
142 | 143 | ||
143 | if ($('.js-news-swiper').is('.js-news-swiper')) { | 144 | if ($('.js-news-swiper').is('.js-news-swiper')) { |
144 | let slider = new Swiper('.js-news-swiper', { | 145 | let slider = new Swiper('.js-news-swiper', { |
145 | spaceBetween: 20, | 146 | spaceBetween: 20, |
146 | pagination: { | 147 | pagination: { |
147 | el: '.swiper-pagination', | 148 | el: '.swiper-pagination', |
148 | clickable: true | 149 | clickable: true |
149 | }, | 150 | }, |
150 | navigation: { | 151 | navigation: { |
151 | prevEl: '.js-news-swiper-button-prev', | 152 | prevEl: '.js-news-swiper-button-prev', |
152 | nextEl: '.js-news-swiper-button-next', | 153 | nextEl: '.js-news-swiper-button-next', |
153 | }, | 154 | }, |
154 | breakpoints: { | 155 | breakpoints: { |
155 | 768: { | 156 | 768: { |
156 | slidesPerView: 2, | 157 | slidesPerView: 2, |
157 | }, | 158 | }, |
158 | 992: { | 159 | 992: { |
159 | slidesPerView: 3, | 160 | slidesPerView: 3, |
160 | }, | 161 | }, |
161 | } | 162 | } |
162 | }); | 163 | }); |
163 | } | 164 | } |
164 | 165 | ||
165 | }; | 166 | }; |
166 | 167 | ||
167 | document.addEventListener("DOMContentLoaded", () => { | 168 | document.addEventListener("DOMContentLoaded", () => { |
168 | scripts(); | 169 | scripts(); |
169 | swipers(); | 170 | swipers(); |
170 | }); | 171 | }); |
171 | 172 | ||
172 | $(window).resize(function () { | 173 | $(window).resize(function () { |
173 | swipers(); | 174 | swipers(); |
174 | }); | 175 | }); |
175 | 176 |