Blame view

frontend/web/js/script.js 13.5 KB
b60a88b8   Anastasia   - main page
1
2
3
4
5
6
7
8
9
10
  $(document).ready(function() {
  
      footerBottom();
      scrollUp();
      callMobile();
      modalForms();
      openMobMenuNew();
      closeMobMenu();
      phoneMask();
      catalogMenu();
6dd77cde   Виталий   qwsedrftg
11
      serviceTables();
c915c06e   Виталий   service
12
      formsService();
b60a88b8   Anastasia   - main page
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
  
      function footerBottom(){
          var heightHeader = document.getElementById('header_').offsetHeight
          var heightFooter = document.getElementById('footer_').offsetHeight
          var windowHeight = window.innerHeight
          document.getElementById('content_').style.minHeight = windowHeight-heightHeader-heightFooter+'px';
      }
  
      function mobOverlayAdd() {
          if($('body').find('.mob-overlay').length > 0) {
          } else {
              $('body').append('<div class="mob-overlay"></div>')
          }
          $('.mob-overlay').fadeIn(300);
      }
  
      function mobOverlayRemove() {
          $('.mob-overlay').fadeOut(300);
          $('body').removeClass('show-block-mobile');
          setTimeout(function () {
              $('body').removeClass('body-fixed');
          },510)
  
      }
  
      function openMobMenuNew() {
          $('.menu_mob').click(function () {
              mobOverlayAdd()
              $('body').addClass('body-fixed show-block-mobile');
  
  
          })
      }
  
      function closeCallMobileHide() {
          $('.call-mobile-wr').removeClass('visible')
          setTimeout(function () {
              $('.call-mobile-wr').removeClass('open')
          },200)
      }
  
      function closeMobMenu() {
          $('body').on('click','.mob-overlay',function () {
              mobOverlayRemove();
          })
  
          $('.close-mobile-menu').click(function () {
              mobOverlayRemove();
          })
      }
  
  
      function scrollUp() {
          $('.btn_up').click(function () {
              $('body, html').animate({scrollTop:0}, 500);
          })
          btnScroll()
          function btnScroll() {
              btnScrollPos()
              function btnScrollPos() {
  
                  var containerPos = $('#content_ .container').offset().left
                  // console.log($('.container').offset().left)
                  $('.btn_up').css({right:containerPos})
              }
  
              btnScrollShowHide()
              function btnScrollShowHide() {
                  var windowHeight = $(window).height()
  
                  if($(this).scrollTop() < windowHeight)
                  {
                      $('.btn_up').removeClass('visible')
                  } else {
                      $('.btn_up').addClass('visible')
                  }
                  var scrpos = $(this).scrollTop()
                  var documentHeight = $(document).height()
                  var fHe = ($('.section-box-footer').height())-39
                  var fPos = $('.section-box-footer').offset().top
                  var docFooterHeight = documentHeight-fHe-windowHeight
  
                  if(($(this).scrollTop())>=docFooterHeight){
                      $('.btn_up').css({bottom:(fHe+16)-((documentHeight-scrpos)-($(window).height()))})
                  } else  {
                      $('.btn_up').css({bottom:16})
                  }
              }
  
              $(window).resize(function () {
                  btnScrollPos()
                  btnScrollShowHide()
              })
  
              $(window).scroll(function () {
                  btnScrollShowHide()
              })
  
  
              $('.btn_scroll').click(function () {
                  $('body,html').animate( { scrollTop: 0 }, 500 );
              })
  
          }
      }
  
      function callMobile() { //new
          $('.btn_call').click(function() {
              $('.btn_call').addClass('close');
              $('.btn_call_close').addClass('visible');
              mobOverlayAdd();
  
              $('.call-mobile-wr').addClass('visible');
              setTimeout(
                  function() {
                      $('.call-mobile-wr').addClass('open')
                  }, 20
              )
          })
  
          $('.btn_call_close').click(function () {
              $(this).removeClass('visible');
              mobOverlayRemove();
              closeCallMobileHide();
              $('.btn_call') .removeClass('close');
              $('.call-mobile-wr').removeClass('open');
              $('body').removeClass('off-scroll');
          })
  
      }
      
  
  
      function phoneMask() {
          var phoneInput = '.phones_mask input'
  
          if($('body').find('.phones_mask').find('input').length>0){
              $(phoneInput).mask('(000) 000-00-00',{placeholder:'(0__)___-__-__'});
              $(phoneInput).focus(function () {
  
                  var text = $(this).val();
                  $(this).val(text);
                  if(($(this).val())== '') {$(this).val('(0')}
              })
              $(phoneInput).focusout(function () {
                  var phoneVal = $(this).val()
                  //if(phoneVal == '+38(0' || phoneVal == '+38(' || phoneVal == '+38' || phoneVal == '+3' || phoneVal == '+') {$(this).val('')}
                  if(phoneVal.length <17) {$(this).val('')}
              })
          }
      }
  
      function catalogMenu() {
  
          $('.mobi-menu-catalog').children('ul').children('li')
              .each(function() {
                  if ($(this)
                          .find('ul').length > 0) {
                      $(this)
                          .addClass('has-list');
                  }
              })
  
6dd77cde   Виталий   qwsedrftg
176
177
  
          $('.mobi-menu-catalog .has-list a').click(function() {
b60a88b8   Anastasia   - main page
178
179
180
181
182
183
184
185
                  if ($(this).parent().hasClass('active-menu')) {
                      $(this).parent().removeClass('active-menu');
                  } else {
                      $(this).parent().addClass('active-menu');
                  }
              })
      }
  
6dd77cde   Виталий   qwsedrftg
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
      function serviceTables() {
          var status = true;
          $('body').on('click','.service-title',function () {
              var this_ = $(this);
              if(status) {
                  status = false;
                  var height = 0;
                  var maxHeight = +(this_.parent().parent().find('table').height() + this_.parent().parent().height());
                  this_.parent().parent().toggleClass('active')
                  if(this_.parent().parent().hasClass('active')) {
  
                      var interval = setInterval(function () {
                          if(height<=maxHeight) {
                              height =  height+15;
                              this_.parent().parent().css({height: height + 'px'});
  
                          } else {
                              this_.parent().parent().css({height: maxHeight + 1 + 'px'});
                              clearInterval(interval);
                              status = true;
                          }
                      },1)
  
  
                  } else {
                      var newHeight = this_.parent().parent().height();
                      var interval2 = setInterval(function () {
                          if(newHeight>=1) {
                              newHeight =  newHeight-20;
                              this_.parent().parent().css({height: newHeight + 'px'})
  
                          } else {
                              clearInterval(interval2);
                              this_.parent().parent().css({height:  this_.height() + 1 + 'px'});
                              status = true;
                          }
                      },1)
                  }
              }
         })
      }
  
b60a88b8   Anastasia   - main page
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
      
      $(window).resize(function () {
          // heightSliderCol();
          footerBottom();
          if(window.innerWidth>=992){
              mobOverlayRemove()
              $('#menu-mob-hidden').removeClass('visible')
              setTimeout(function () {
                  $('#menu-mob-hidden').removeClass('opens')
              },200)
              $('body').removeClass('off-scroll')
              $('body').removeClass('hidden_scroll-y')
  
          }
      })
  
      function modalForms() {
          $('body').on('click','.modal-link', function (e) {
  
              e.preventDefault();
              e.stopPropagation();
  
  
              mobOverlayRemove()
              $('#menu-mob-hidden').removeClass('visible')
              setTimeout(function () {
                  $('#menu-mob-hidden').removeClass('opens')
              },200)
              $('body').removeClass('off-scroll')
  
              mobOverlayRemove()
              closeCallMobileHide()
              $('.btn_call').removeClass('close')
              $('.call-mobile-wr').removeClass('open')
              $('body').removeClass('off-scroll')
  
  
              var idForm = $(this).data('form');
  
  
              var pos = ($(window).scrollTop()) + 30;
              if($(this).hasClass('fixed-modal')){
                  pos = 30;
                  $('#'+idForm).css({position:'fixed'})
              }
              if($(this).hasClass('pos-top')){
                  pos = 30;
              }
              $('#overlay').removeClass('overlay_cloned');
              $('#overlay').fadeIn(400,
                  function(){
                      $('#'+idForm)
                          .css('display', 'block')
                          .animate({opacity: 1, top: pos}, 200);
                  });
          })
      }
  
      closeForms();
      function closeForms() {
          $('#modal_close, #overlay').click( function(){
              $('.forms_, .basket_modal').animate({opacity: 0, top: '0'}, 200,function(){
                  $(this).css('display', 'none');
                  $(this).prev("#overlay").css('display', 'none');
                  $('#overlay').fadeOut(400);
              });
              $('#success_form').animate({opacity: 0, top: '0'}, 200,function(){
                  $(this).css('display', 'none');
                  $(this).prev("#overlay").css('display', 'none');
                  $(this).css({top:'50%'});
              });
          });
      }
      //после удачной отправки формы запускать success()
      // success()
      function success() {
          var pos = ($(window).scrollTop()) + 30;
          $('.forms_').animate({opacity: 0, top: '0'}, 200,function(){
              $(this).css('display', 'none');
          });
          setTimeout(function () {
              $('#overlay').fadeIn(400);
              $('#success_form').css('display', 'block').animate({opacity: 1, top: pos}, 700);
          },400)
      }
  
  
      if($(window).width() >= 768) {
          animations();
      }
      function animations() {
6dd77cde   Виталий   qwsedrftg
319
320
321
          function animBox3() {
              if($('.section-box-3').length) {
                  $('.section-box-3').addClass('anim')
b60a88b8   Anastasia   - main page
322
323
                  var scrollPos = $(window).scrollTop();
                  var windHeight = $(window).height();
6dd77cde   Виталий   qwsedrftg
324
                  var bl = $('.section-box-3');
b60a88b8   Anastasia   - main page
325
326
                  var pos = bl.offset().top;
                  if(scrollPos >= (pos - (windHeight - 200 ))) {
6dd77cde   Виталий   qwsedrftg
327
                      bl.addClass('start')
b60a88b8   Anastasia   - main page
328
                  }
6dd77cde   Виталий   qwsedrftg
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
               }
          }
  
  
      function animBox4() {
          if($('.section-box-4').length) {
              $('.section-box-4').addClass('anim')
              var scrollPos = $(window).scrollTop();
              var windHeight = $(window).height();
              var bl = $('.section-box-4');
              var pos = bl.offset().top;
              if (scrollPos >= (pos - (windHeight - 200 ))) {
                  bl.addClass('start');
                  setTimeout(function () {
                      bl.addClass('start2');
                  }, 1100)
                  setTimeout(function () {
                      bl.addClass('start3');
                  }, 1100 + 2500)
b60a88b8   Anastasia   - main page
348
              }
c237629a   Anastasia   first commit
349
          }
6dd77cde   Виталий   qwsedrftg
350
351
      }
  
b60a88b8   Anastasia   - main page
352
  
6dd77cde   Виталий   qwsedrftg
353
354
355
356
  
  
  
      function animBox2() {
b60a88b8   Anastasia   - main page
357
358
359
360
          if($('.section-box-2').length) {
              $('.section-box-2').addClass('anim');
              $('.categories-home .img').click(function () {
                  var link = $(this).parent().find('.categories-home-links-title a').attr('href');
6dd77cde   Виталий   qwsedrftg
361
                  document.location.href = link;
b60a88b8   Anastasia   - main page
362
              })
6dd77cde   Виталий   qwsedrftg
363
364
365
366
367
368
369
370
371
              var scrollPos = $(window).scrollTop();
              var windHeight = $(window).height();
              var bl = $('.section-box-2');
              var pos = bl.offset().top;
              if(scrollPos >= (pos - (windHeight - 200 ))) {
                  bl.addClass('start');
                  setTimeout(function () {
                      bl.addClass('start2');
                  },1100)
b60a88b8   Anastasia   - main page
372
              }
6dd77cde   Виталий   qwsedrftg
373
374
375
           }
      }
  
b60a88b8   Anastasia   - main page
376
377
378
379
380
381
  
          $(window).scroll(function () {
              animBox3();
              animBox4();
              animBox2();
          })
c237629a   Anastasia   first commit
382
      }
b60a88b8   Anastasia   - main page
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
  
      showTextHome()
      function showTextHome() {
          $('.show-txt-mo span').click(function () {
              if($(this).parent().hasClass('hide-status')){
                  $('.for-hidden-mob').removeClass('status-hide');
                  $(this).parent().removeClass('hide-status');
                  var text =  $(this).parent().data('langhide');
                  $(this).find('b').html(text);
              } else {
                  $('.for-hidden-mob').addClass('status-hide');
                  $(this).parent().addClass('hide-status');
                  var text =  $(this).parent().data('langshow');
                  $(this).find('b').html(text);
              }
          })
      }
  
c915c06e   Виталий   service
401
402
403
404
405
406
407
408
409
410
      function formsService() {
          $('body').on('click','.service-c-a-btns span',function () {
              $(this).parent().parent().find('.hidden-form-c-a-wr').removeClass('hidden')
          })
  
          $('body').on('click','.submit-close-c-a span',function () {
              $(this).parents('.hidden-form-c-a-wr').addClass('hidden')
          })
      }
  
b60a88b8   Anastasia   - main page
411
  
ebde7ea6   Anastasia   - forms
412
413
      $('nav').addClass('hide_');
      $('body').addClass('start-preloader');
b60a88b8   Anastasia   - main page
414
415
416
417
418
419
420
421
422
423
  
      window.onload = function () {
          //
          // $('body').addClass('end-preloader')
          // $('nav').addClass('start')
          // $('body').addClass('disabled-preloader')
  
          //альтернативный с задержкой выключения
          setTimeout(function () {
              $('body').addClass('end-preloader')
ebde7ea6   Anastasia   - forms
424
          },2700);
b60a88b8   Anastasia   - main page
425
426
  
          setTimeout(function () {
ebde7ea6   Anastasia   - forms
427
428
429
430
              console.log('start');
              $('nav').addClass('start');
              $('body').addClass('disabled-preloader');
  
b60a88b8   Anastasia   - main page
431
432
433
434
435
436
          },2700 + 2000)
      }
  
  
  
  
ebde7ea6   Anastasia   - forms
437
  });