Commit a25d5cb088091ea6d37b6466068d25a639ec6f74
1 parent
6e9e7b94
add google analytics event trigger
Showing
1 changed file
with
322 additions
and
312 deletions
Show diff stats
frontend/web/js/script.js
1 | -$(document).ready(function() { | |
2 | - footerBottom(); | |
3 | - scrollUp(); | |
4 | - modalForms(); | |
5 | - openMobMenuNew(); | |
6 | - closeMobMenu(); | |
7 | - phoneMask('#feedback-phone'); | |
8 | - phoneMask("input[name='Feedback[phone]']"); | |
9 | - anchor(); | |
10 | - fixedHeader(); | |
11 | - callMobile(); | |
12 | - | |
13 | - function callMobile() { //new | |
14 | - $('.btn_call').click(function() { | |
15 | - if($(this).hasClass('close')) { | |
16 | - mobOverlayRemove(); | |
17 | - closeCallMobileHide(); | |
18 | - $('.btn_call') .removeClass('close'); | |
19 | - | |
20 | - } else { | |
21 | - $('.btn_call').addClass('close'); | |
22 | - | |
23 | - mobOverlayAdd(); | |
24 | - | |
25 | - $('.call-mobile-wr').addClass('visible'); | |
26 | - setTimeout( | |
27 | - function() { | |
28 | - $('.call-mobile-wr').addClass('open') | |
29 | - }, 20 | |
30 | - ) | |
31 | - } | |
32 | - | |
33 | - }) | |
34 | - } | |
35 | - | |
36 | - function closeCallMobileHide() { | |
37 | - $('.call-mobile-wr').removeClass('visible') | |
38 | - setTimeout(function () { | |
39 | - $('.call-mobile-wr').removeClass('open') | |
40 | - },200) | |
41 | - } | |
42 | - | |
43 | - function phoneMask(phoneInput2) { | |
44 | - var phoneInput = phoneInput2; | |
45 | - | |
46 | - if($('body').find(phoneInput).length>0){ | |
47 | - $(phoneInput).mask('+38(000)000-00-00',{placeholder:'+38(0__)___-__-__'}); | |
48 | - $(phoneInput).focus(function () { | |
49 | - if(($(this).val())== '') {$(this).val('+38(0')} | |
50 | - }) | |
51 | - $(phoneInput).focusout(function () { | |
52 | - var phoneVal = $(this).val() | |
53 | - //if(phoneVal == '+38(0' || phoneVal == '+38(' || phoneVal == '+38' || phoneVal == '+3' || phoneVal == '+') {$(this).val('')} | |
54 | - if(phoneVal.length <17) {$(this).val('')} | |
55 | - }) | |
56 | - } | |
57 | - } | |
58 | - | |
59 | - | |
60 | - | |
61 | - function footerBottom(){ | |
62 | - var heightHeader = document.getElementById('header_').offsetHeight | |
63 | - var heightFooter = document.getElementById('footer_').offsetHeight | |
64 | - var windowHeight = window.innerHeight | |
65 | - document.getElementById('content_').style.minHeight = windowHeight-heightHeader-heightFooter+'px'; | |
66 | - } | |
67 | - | |
68 | - function mobOverlayAdd() { | |
69 | - if($('body').find('.mob-overlay').length > 0) { | |
70 | - } else { | |
71 | - $('body').append('<div class="mob-overlay"></div>') | |
72 | - } | |
73 | - $('.mob-overlay').fadeIn(300); | |
74 | - } | |
75 | - | |
76 | - function mobOverlayRemove() { | |
77 | - $('.mob-overlay').fadeOut(300); | |
78 | - $('body').removeClass('show-block-mobile'); | |
79 | - setTimeout(function () { | |
80 | - $('body').removeClass('body-fixed'); | |
81 | - },510) | |
82 | - | |
83 | - } | |
84 | - | |
85 | - function openMobMenuNew() { | |
86 | - $('.menu_mob').click(function () { | |
87 | - mobOverlayAdd() | |
88 | - $('body').addClass('body-fixed show-block-mobile'); | |
89 | - | |
90 | - | |
91 | - }) | |
92 | - } | |
93 | - | |
94 | - | |
95 | - | |
96 | - function closeMobMenu() { | |
97 | - $('body').on('click','.mob-overlay',function () { | |
98 | - mobOverlayRemove(); | |
99 | - }) | |
100 | - | |
101 | - $('.close-mobile-menu').click(function () { | |
102 | - mobOverlayRemove(); | |
103 | - }) | |
104 | - } | |
105 | - function scrollUp() { | |
106 | - $('.btn_up').click(function () { | |
107 | - $('body, html').animate({scrollTop:0}, 500); | |
108 | - }) | |
109 | - btnScroll() | |
110 | - function btnScroll() { | |
111 | - btnScrollPos() | |
112 | - function btnScrollPos() { | |
113 | - | |
114 | - var containerPos = $('#content_ .container').offset().left | |
115 | - // console.log($('.container').offset().left) | |
116 | - $('.btn_up').css({right:containerPos}) | |
117 | - } | |
118 | - | |
119 | - btnScrollShowHide() | |
120 | - function btnScrollShowHide() { | |
121 | - var windowHeight = $(window).height() | |
122 | - | |
123 | - if($(this).scrollTop() < windowHeight) | |
124 | - { | |
125 | - $('.btn_up').removeClass('visible') | |
126 | - } else { | |
127 | - $('.btn_up').addClass('visible') | |
128 | - } | |
129 | - var scrpos = $(this).scrollTop() | |
130 | - var documentHeight = $(document).height() | |
131 | - var fHe = ($('.section-box-footer').height())-39 | |
132 | - var fPos = $('.section-box-footer').offset().top | |
133 | - var docFooterHeight = documentHeight-fHe-windowHeight | |
134 | - | |
135 | - if(($(this).scrollTop())>=docFooterHeight){ | |
136 | - $('.btn_up').css({bottom:(fHe+16)-((documentHeight-scrpos)-($(window).height()))}) | |
137 | - } else { | |
138 | - $('.btn_up').css({bottom:16}) | |
139 | - } | |
140 | - } | |
141 | - | |
142 | - $(window).resize(function () { | |
143 | - btnScrollPos() | |
144 | - btnScrollShowHide() | |
145 | - }) | |
146 | - | |
147 | - $(window).scroll(function () { | |
148 | - btnScrollShowHide() | |
149 | - }) | |
150 | - | |
151 | - | |
152 | - $('.btn_scroll').click(function () { | |
153 | - $('body,html').animate( { scrollTop: 0 }, 500 ); | |
154 | - }) | |
155 | - | |
156 | - } | |
157 | - } | |
158 | - | |
159 | - function anchor() { | |
160 | - $('body').on('click','.menu-header ul li a',function () { | |
161 | - var anchor = $(this).data('anchor'); | |
162 | - var scrollPos = $('.' + anchor).offset().top; | |
163 | - $('body, html').animate({scrollTop:scrollPos},600); | |
164 | - | |
165 | - }) | |
166 | - } | |
167 | - | |
168 | - function fixedHeader() { | |
169 | - if($(window).scrollTop()>=1) { | |
170 | - $('body').addClass('fixed-header') | |
171 | - } else { | |
172 | - $('body').removeClass('fixed-header') | |
173 | - } | |
174 | - } | |
175 | - | |
176 | - | |
177 | - | |
178 | - | |
179 | - | |
180 | - | |
181 | - | |
182 | - | |
183 | - | |
184 | - | |
185 | - | |
186 | - | |
187 | - | |
188 | - | |
189 | - | |
190 | - | |
191 | - | |
192 | - | |
193 | - | |
194 | - | |
195 | - | |
196 | - | |
197 | - | |
198 | - | |
199 | - | |
200 | - | |
201 | - | |
202 | - | |
203 | - | |
204 | - | |
205 | - | |
206 | - | |
207 | - | |
208 | - | |
209 | - | |
210 | - | |
211 | - $(window).resize(function () { | |
212 | - // heightSliderCol(); | |
213 | - footerBottom(); | |
214 | - // if(window.innerWidth>=992){ | |
215 | - // mobOverlayRemove() | |
216 | - // $('#menu-mob-hidden').removeClass('visible') | |
217 | - // setTimeout(function () { | |
218 | - // $('#menu-mob-hidden').removeClass('opens') | |
219 | - // },200) | |
220 | - // $('body').removeClass('off-scroll') | |
221 | - // $('body').removeClass('hidden_scroll-y') | |
222 | - // $('.mob_filters_wr').attr('style','') | |
223 | - // } | |
224 | - }) | |
225 | - | |
226 | - $(window).scroll(function () { | |
227 | - fixedHeader(); | |
228 | - }) | |
229 | - | |
230 | - function modalForms() { | |
231 | - $('body').on('click','.modal-link', function (e) { | |
232 | - | |
233 | - e.preventDefault(); | |
234 | - e.stopPropagation(); | |
235 | - | |
236 | - | |
237 | - mobOverlayRemove() | |
238 | - $('#menu-mob-hidden').removeClass('visible') | |
239 | - setTimeout(function () { | |
240 | - $('#menu-mob-hidden').removeClass('opens') | |
241 | - },200) | |
242 | - $('body').removeClass('off-scroll') | |
243 | - | |
244 | - mobOverlayRemove() | |
245 | - // closeCallMobileHide() | |
246 | - $('.btn_call').removeClass('close') | |
247 | - $('.call-mobile-wr').removeClass('open') | |
248 | - $('body').removeClass('off-scroll') | |
249 | - | |
250 | - | |
251 | - var idForm = $(this).data('form'); | |
252 | - | |
253 | - | |
254 | - var pos = ($(window).scrollTop()) + 30; | |
255 | - if($(this).hasClass('fixed-modal')){ | |
256 | - pos = 30; | |
257 | - $('#'+idForm).css({position:'fixed'}) | |
258 | - } | |
259 | - if($(this).hasClass('pos-top')){ | |
260 | - pos = 30; | |
261 | - } | |
262 | - $('#overlay').removeClass('overlay_cloned'); | |
263 | - $('#overlay').fadeIn(400, | |
264 | - function(){ | |
265 | - $('#'+idForm) | |
266 | - .css('display', 'block') | |
267 | - .animate({opacity: 1, top: pos}, 200); | |
268 | - }); | |
269 | - }) | |
270 | - } | |
271 | - | |
272 | - closeForms(); | |
273 | - function closeForms() { | |
274 | - $('#modal_close, #overlay').click( function(){ | |
275 | - $('.forms_, .basket_modal').animate({opacity: 0, top: '0'}, 200,function(){ | |
276 | - $(this).css('display', 'none'); | |
277 | - $(this).prev("#overlay").css('display', 'none'); | |
278 | - $('#overlay').fadeOut(400); | |
279 | - }); | |
280 | - $('#success_form').animate({opacity: 0, top: '0'}, 200,function(){ | |
281 | - $(this).css('display', 'none'); | |
282 | - $(this).prev("#overlay").css('display', 'none'); | |
283 | - $(this).css({top:'50%'}); | |
284 | - }); | |
285 | - $('#success_form.error_form').animate({opacity: 0, top: '0'}, 200,function(){ | |
286 | - $(this).css('display', 'none'); | |
287 | - $(this).prev("#overlay").css('display', 'none'); | |
288 | - $(this).css({top:'50%'}); | |
289 | - }); | |
290 | - }); | |
291 | - } | |
292 | - //после удачной отправки формы запускать success() | |
293 | - // success() | |
294 | - function success() { | |
295 | - var pos = ($(window).scrollTop()) + 30; | |
296 | - $('.forms_').animate({opacity: 0, top: '0'}, 200,function(){ | |
297 | - $(this).css('display', 'none'); | |
298 | - }); | |
299 | - setTimeout(function () { | |
300 | - $('#overlay').fadeIn(400); | |
301 | - $('#success_form').css('display', 'block').animate({opacity: 1, top: pos}, 700); | |
302 | - },400) | |
303 | - } | |
304 | - | |
305 | - $('body').on('click','.cokeis-close',function () { | |
306 | - $('.cookie-modal').addClass('hide-bl'); | |
307 | - var date = new Date(new Date().getTime() + 48 * 60 * 60 * 1000); | |
308 | - document.cookie = "sowCookieModal=1; path=/; expires=" + date.toUTCString(); | |
309 | - }) | |
310 | - | |
311 | - | |
312 | - | |
1 | +$(document).ready(function() { | |
2 | + footerBottom(); | |
3 | + scrollUp(); | |
4 | + modalForms(); | |
5 | + openMobMenuNew(); | |
6 | + closeMobMenu(); | |
7 | + phoneMask('#feedback-phone'); | |
8 | + phoneMask("input[name='Feedback[phone]']"); | |
9 | + anchor(); | |
10 | + fixedHeader(); | |
11 | + callMobile(); | |
12 | + | |
13 | + function callMobile() { //new | |
14 | + $('.btn_call').click(function() { | |
15 | + if($(this).hasClass('close')) { | |
16 | + mobOverlayRemove(); | |
17 | + closeCallMobileHide(); | |
18 | + $('.btn_call') .removeClass('close'); | |
19 | + | |
20 | + } else { | |
21 | + $('.btn_call').addClass('close'); | |
22 | + | |
23 | + mobOverlayAdd(); | |
24 | + | |
25 | + $('.call-mobile-wr').addClass('visible'); | |
26 | + setTimeout( | |
27 | + function() { | |
28 | + $('.call-mobile-wr').addClass('open') | |
29 | + }, 20 | |
30 | + ) | |
31 | + } | |
32 | + | |
33 | + }) | |
34 | + } | |
35 | + | |
36 | + function closeCallMobileHide() { | |
37 | + $('.call-mobile-wr').removeClass('visible') | |
38 | + setTimeout(function () { | |
39 | + $('.call-mobile-wr').removeClass('open') | |
40 | + },200) | |
41 | + } | |
42 | + | |
43 | + function phoneMask(phoneInput2) { | |
44 | + var phoneInput = phoneInput2; | |
45 | + | |
46 | + if($('body').find(phoneInput).length>0){ | |
47 | + $(phoneInput).mask('+38(000)000-00-00',{placeholder:'+38(0__)___-__-__'}); | |
48 | + $(phoneInput).focus(function () { | |
49 | + if(($(this).val())== '') {$(this).val('+38(0')} | |
50 | + }) | |
51 | + $(phoneInput).focusout(function () { | |
52 | + var phoneVal = $(this).val() | |
53 | + //if(phoneVal == '+38(0' || phoneVal == '+38(' || phoneVal == '+38' || phoneVal == '+3' || phoneVal == '+') {$(this).val('')} | |
54 | + if(phoneVal.length <17) {$(this).val('')} | |
55 | + }) | |
56 | + } | |
57 | + } | |
58 | + | |
59 | + | |
60 | + | |
61 | + function footerBottom(){ | |
62 | + var heightHeader = document.getElementById('header_').offsetHeight | |
63 | + var heightFooter = document.getElementById('footer_').offsetHeight | |
64 | + var windowHeight = window.innerHeight | |
65 | + document.getElementById('content_').style.minHeight = windowHeight-heightHeader-heightFooter+'px'; | |
66 | + } | |
67 | + | |
68 | + function mobOverlayAdd() { | |
69 | + if($('body').find('.mob-overlay').length > 0) { | |
70 | + } else { | |
71 | + $('body').append('<div class="mob-overlay"></div>') | |
72 | + } | |
73 | + $('.mob-overlay').fadeIn(300); | |
74 | + } | |
75 | + | |
76 | + function mobOverlayRemove() { | |
77 | + $('.mob-overlay').fadeOut(300); | |
78 | + $('body').removeClass('show-block-mobile'); | |
79 | + setTimeout(function () { | |
80 | + $('body').removeClass('body-fixed'); | |
81 | + },510) | |
82 | + | |
83 | + } | |
84 | + | |
85 | + function openMobMenuNew() { | |
86 | + $('.menu_mob').click(function () { | |
87 | + mobOverlayAdd() | |
88 | + $('body').addClass('body-fixed show-block-mobile'); | |
89 | + | |
90 | + | |
91 | + }) | |
92 | + } | |
93 | + | |
94 | + | |
95 | + | |
96 | + function closeMobMenu() { | |
97 | + $('body').on('click','.mob-overlay',function () { | |
98 | + mobOverlayRemove(); | |
99 | + }) | |
100 | + | |
101 | + $('.close-mobile-menu').click(function () { | |
102 | + mobOverlayRemove(); | |
103 | + }) | |
104 | + } | |
105 | + function scrollUp() { | |
106 | + $('.btn_up').click(function () { | |
107 | + $('body, html').animate({scrollTop:0}, 500); | |
108 | + }) | |
109 | + btnScroll() | |
110 | + function btnScroll() { | |
111 | + btnScrollPos() | |
112 | + function btnScrollPos() { | |
113 | + | |
114 | + var containerPos = $('#content_ .container').offset().left | |
115 | + // console.log($('.container').offset().left) | |
116 | + $('.btn_up').css({right:containerPos}) | |
117 | + } | |
118 | + | |
119 | + btnScrollShowHide() | |
120 | + function btnScrollShowHide() { | |
121 | + var windowHeight = $(window).height() | |
122 | + | |
123 | + if($(this).scrollTop() < windowHeight) | |
124 | + { | |
125 | + $('.btn_up').removeClass('visible') | |
126 | + } else { | |
127 | + $('.btn_up').addClass('visible') | |
128 | + } | |
129 | + var scrpos = $(this).scrollTop() | |
130 | + var documentHeight = $(document).height() | |
131 | + var fHe = ($('.section-box-footer').height())-39 | |
132 | + var fPos = $('.section-box-footer').offset().top | |
133 | + var docFooterHeight = documentHeight-fHe-windowHeight | |
134 | + | |
135 | + if(($(this).scrollTop())>=docFooterHeight){ | |
136 | + $('.btn_up').css({bottom:(fHe+16)-((documentHeight-scrpos)-($(window).height()))}) | |
137 | + } else { | |
138 | + $('.btn_up').css({bottom:16}) | |
139 | + } | |
140 | + } | |
141 | + | |
142 | + $(window).resize(function () { | |
143 | + btnScrollPos() | |
144 | + btnScrollShowHide() | |
145 | + }) | |
146 | + | |
147 | + $(window).scroll(function () { | |
148 | + btnScrollShowHide() | |
149 | + }) | |
150 | + | |
151 | + | |
152 | + $('.btn_scroll').click(function () { | |
153 | + $('body,html').animate( { scrollTop: 0 }, 500 ); | |
154 | + }) | |
155 | + | |
156 | + } | |
157 | + } | |
158 | + | |
159 | + function anchor() { | |
160 | + $('body').on('click','.menu-header ul li a',function () { | |
161 | + var anchor = $(this).data('anchor'); | |
162 | + var scrollPos = $('.' + anchor).offset().top; | |
163 | + $('body, html').animate({scrollTop:scrollPos},600); | |
164 | + | |
165 | + }) | |
166 | + } | |
167 | + | |
168 | + function fixedHeader() { | |
169 | + if($(window).scrollTop()>=1) { | |
170 | + $('body').addClass('fixed-header') | |
171 | + } else { | |
172 | + $('body').removeClass('fixed-header') | |
173 | + } | |
174 | + } | |
175 | + | |
176 | + | |
177 | + | |
178 | + | |
179 | + | |
180 | + | |
181 | + | |
182 | + | |
183 | + | |
184 | + | |
185 | + | |
186 | + | |
187 | + | |
188 | + | |
189 | + | |
190 | + | |
191 | + | |
192 | + | |
193 | + | |
194 | + | |
195 | + | |
196 | + | |
197 | + | |
198 | + | |
199 | + | |
200 | + | |
201 | + | |
202 | + | |
203 | + | |
204 | + | |
205 | + | |
206 | + | |
207 | + | |
208 | + | |
209 | + | |
210 | + | |
211 | + $(window).resize(function () { | |
212 | + // heightSliderCol(); | |
213 | + footerBottom(); | |
214 | + // if(window.innerWidth>=992){ | |
215 | + // mobOverlayRemove() | |
216 | + // $('#menu-mob-hidden').removeClass('visible') | |
217 | + // setTimeout(function () { | |
218 | + // $('#menu-mob-hidden').removeClass('opens') | |
219 | + // },200) | |
220 | + // $('body').removeClass('off-scroll') | |
221 | + // $('body').removeClass('hidden_scroll-y') | |
222 | + // $('.mob_filters_wr').attr('style','') | |
223 | + // } | |
224 | + }) | |
225 | + | |
226 | + $(window).scroll(function () { | |
227 | + fixedHeader(); | |
228 | + }) | |
229 | + | |
230 | + function modalForms() { | |
231 | + $('body').on('click','.modal-link', function (e) { | |
232 | + | |
233 | + e.preventDefault(); | |
234 | + e.stopPropagation(); | |
235 | + | |
236 | + | |
237 | + mobOverlayRemove() | |
238 | + $('#menu-mob-hidden').removeClass('visible') | |
239 | + setTimeout(function () { | |
240 | + $('#menu-mob-hidden').removeClass('opens') | |
241 | + },200) | |
242 | + $('body').removeClass('off-scroll') | |
243 | + | |
244 | + mobOverlayRemove() | |
245 | + // closeCallMobileHide() | |
246 | + $('.btn_call').removeClass('close') | |
247 | + $('.call-mobile-wr').removeClass('open') | |
248 | + $('body').removeClass('off-scroll') | |
249 | + | |
250 | + | |
251 | + var idForm = $(this).data('form'); | |
252 | + | |
253 | + | |
254 | + var pos = ($(window).scrollTop()) + 30; | |
255 | + if($(this).hasClass('fixed-modal')){ | |
256 | + pos = 30; | |
257 | + $('#'+idForm).css({position:'fixed'}) | |
258 | + } | |
259 | + if($(this).hasClass('pos-top')){ | |
260 | + pos = 30; | |
261 | + } | |
262 | + $('#overlay').removeClass('overlay_cloned'); | |
263 | + $('#overlay').fadeIn(400, | |
264 | + function(){ | |
265 | + $('#'+idForm) | |
266 | + .css('display', 'block') | |
267 | + .animate({opacity: 1, top: pos}, 200); | |
268 | + }); | |
269 | + }) | |
270 | + } | |
271 | + | |
272 | + closeForms(); | |
273 | + function closeForms() { | |
274 | + $('#modal_close, #overlay').click( function(){ | |
275 | + $('.forms_, .basket_modal').animate({opacity: 0, top: '0'}, 200,function(){ | |
276 | + $(this).css('display', 'none'); | |
277 | + $(this).prev("#overlay").css('display', 'none'); | |
278 | + $('#overlay').fadeOut(400); | |
279 | + }); | |
280 | + $('#success_form').animate({opacity: 0, top: '0'}, 200,function(){ | |
281 | + $(this).css('display', 'none'); | |
282 | + $(this).prev("#overlay").css('display', 'none'); | |
283 | + $(this).css({top:'50%'}); | |
284 | + }); | |
285 | + $('#success_form.error_form').animate({opacity: 0, top: '0'}, 200,function(){ | |
286 | + $(this).css('display', 'none'); | |
287 | + $(this).prev("#overlay").css('display', 'none'); | |
288 | + $(this).css({top:'50%'}); | |
289 | + }); | |
290 | + }); | |
291 | + } | |
292 | + //после удачной отправки формы запускать success() | |
293 | + // success() | |
294 | + function success() { | |
295 | + var pos = ($(window).scrollTop()) + 30; | |
296 | + $('.forms_').animate({opacity: 0, top: '0'}, 200,function(){ | |
297 | + $(this).css('display', 'none'); | |
298 | + }); | |
299 | + setTimeout(function () { | |
300 | + $('#overlay').fadeIn(400); | |
301 | + $('#success_form').css('display', 'block').animate({opacity: 1, top: pos}, 700); | |
302 | + },400) | |
303 | + } | |
304 | + | |
305 | + $('body').on('click','.cokeis-close',function () { | |
306 | + $('.cookie-modal').addClass('hide-bl'); | |
307 | + var date = new Date(new Date().getTime() + 48 * 60 * 60 * 1000); | |
308 | + document.cookie = "sowCookieModal=1; path=/; expires=" + date.toUTCString(); | |
309 | + }) | |
310 | + | |
311 | + | |
312 | + | |
313 | + | |
314 | + //Клик по кнопке Позвонить на мобильном | |
315 | + $('div.btn_call').on('click',function () { | |
316 | + | |
317 | + gtag('event', 'send', { | |
318 | + 'event_category': 'click call' | |
319 | + }); | |
320 | + }); | |
321 | + | |
322 | + | |
313 | 323 | }) |
314 | 324 | \ No newline at end of file | ... | ... |