Blame view

frontend/web/js/script.js 16.1 KB
b60a88b8   Anastasia   - main page
1
2
  $(document).ready(function() {
  
9b901264   Виталий   blog/contacts/pac...
3
4
  
  
b60a88b8   Anastasia   - main page
5
6
7
8
9
10
11
12
      footerBottom();
      scrollUp();
      callMobile();
      modalForms();
      openMobMenuNew();
      closeMobMenu();
      phoneMask();
      catalogMenu();
6dd77cde   Виталий   qwsedrftg
13
      serviceTables();
c915c06e   Виталий   service
14
      formsService();
2a888c42   Виталий   sidebar menu chil...
15
      mobCatalogService();
b60a88b8   Anastasia   - main page
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
  
      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');
          })
  
      }
845cd527   Anastasia   - phones mask
146
  
b60a88b8   Anastasia   - main page
147
148
149
150
151
  
  
      function phoneMask() {
          var phoneInput = '.phones_mask input'
  
845cd527   Anastasia   - phones mask
152
          if($('body').find(phoneInput).length>0){
b33dfbc5   Виталий   new callback form
153
              $(phoneInput).mask('+38(000)000-00-00',{placeholder:'+38(0__)___-__-__'});
b60a88b8   Anastasia   - main page
154
              $(phoneInput).focus(function () {
845cd527   Anastasia   - phones mask
155
156
                  if(($(this).val())== '') {$(this).val('+38(0')}
              })
b60a88b8   Anastasia   - main page
157
158
159
              $(phoneInput).focusout(function () {
                  var phoneVal = $(this).val()
                  //if(phoneVal == '+38(0' || phoneVal == '+38(' || phoneVal == '+38' || phoneVal == '+3' || phoneVal == '+') {$(this).val('')}
845cd527   Anastasia   - phones mask
160
                  if(phoneVal.length <17) {$(this).val('')}
b60a88b8   Anastasia   - main page
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
              })
          }
      }
  
      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
      
      $(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')
  
          }
dcd4af1c   Виталий   blog/contacts/pac...
242
243
244
245
246
247
248
249
250
251
252
253
  
          if(window.innerWidth <= 767) {
              $('.for-hidden-mob').mCustomScrollbar("destroy");
          } else {
              $('.for-hidden-mob').mCustomScrollbar(
                  {
                      autoHideScrollbar: true,
                      theme: 'minimal'
                  }
              );
          }
  
b60a88b8   Anastasia   - main page
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
319
320
321
322
323
324
325
      })
  
      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)
      }
  
9b901264   Виталий   blog/contacts/pac...
326
327
328
329
330
      $('body, html').animate({scrollTop:0},20,function () {
  
      });
  
  
fce22ac2   Anastasia   - visits
331
      window.success = success;
b60a88b8   Anastasia   - main page
332
333
      if($(window).width() >= 768) {
          animations();
9b901264   Виталий   blog/contacts/pac...
334
  
b60a88b8   Anastasia   - main page
335
336
      }
      function animations() {
9b901264   Виталий   blog/contacts/pac...
337
  
6dd77cde   Виталий   qwsedrftg
338
339
340
          function animBox3() {
              if($('.section-box-3').length) {
                  $('.section-box-3').addClass('anim')
b60a88b8   Anastasia   - main page
341
342
                  var scrollPos = $(window).scrollTop();
                  var windHeight = $(window).height();
6dd77cde   Виталий   qwsedrftg
343
                  var bl = $('.section-box-3');
b60a88b8   Anastasia   - main page
344
345
                  var pos = bl.offset().top;
                  if(scrollPos >= (pos - (windHeight - 200 ))) {
6dd77cde   Виталий   qwsedrftg
346
                      bl.addClass('start')
b60a88b8   Anastasia   - main page
347
                  }
6dd77cde   Виталий   qwsedrftg
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
               }
          }
  
  
      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
367
              }
c237629a   Anastasia   first commit
368
          }
6dd77cde   Виталий   qwsedrftg
369
370
      }
  
b60a88b8   Anastasia   - main page
371
  
6dd77cde   Виталий   qwsedrftg
372
373
374
375
  
  
  
      function animBox2() {
b60a88b8   Anastasia   - main page
376
377
378
379
          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
380
                  document.location.href = link;
889ab655   Anastasia   datalayer push
381
              });
6dd77cde   Виталий   qwsedrftg
382
383
384
385
386
387
388
389
390
              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
391
              }
6dd77cde   Виталий   qwsedrftg
392
393
394
           }
      }
  
b60a88b8   Anastasia   - main page
395
  
9b901264   Виталий   blog/contacts/pac...
396
397
398
399
          animBox3();
          animBox4();
          animBox2();
  
b60a88b8   Anastasia   - main page
400
401
402
403
404
          $(window).scroll(function () {
              animBox3();
              animBox4();
              animBox2();
          })
c237629a   Anastasia   first commit
405
      }
b60a88b8   Anastasia   - main page
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
  
      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
424
425
426
427
428
429
      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 () {
31b3e056   Виталий   page answer
430
431
432
433
434
435
              if($(this).parent().hasClass('submit-close-c-a-page')){
                  $(this).parents('.hidden-answer-comment-form').addClass('hidden')
              } else {
                  $(this).parents('.hidden-form-c-a-wr').addClass('hidden')
              }
  
39392f19   Anastasia   - visit form
436
          });
31b3e056   Виталий   page answer
437
438
439
  
          $('body').on('click','.add-answer-forms span',function () {
              $(this).parent().parent().find('.hidden-answer-comment-form').removeClass('hidden')
c915c06e   Виталий   service
440
441
442
          })
      }
  
2a888c42   Виталий   sidebar menu chil...
443
444
445
446
447
448
      function mobCatalogService() {
          $('body').on('click','.all-catalog-mob',function () {
              $(this).parent().toggleClass('active');
          })
      }
  
b60a88b8   Anastasia   - main page
449
  
36308a03   Виталий   big update
450
451
      // $('nav').addClass('hide_');
      // $('body').addClass('start-preloader');
b60a88b8   Anastasia   - main page
452
  
b60a88b8   Anastasia   - main page
453
  
b60a88b8   Anastasia   - main page
454
  
fab1487f   Anastasia   - comments
455
      $(document).on('submit', '#total_question_form, #total_comment_form', function(e) {
cc2da9cc   Anastasia   - question page
456
457
         e.preventDefault();
         var form = $(this);
fab1487f   Anastasia   - comments
458
         var id = form.attr('id');
cc2da9cc   Anastasia   - question page
459
         var url = form.attr('action');
889ab655   Anastasia   datalayer push
460
461
462
463
464
465
466
         if (id == 'total_question_form'){
             dataLayer.push({'event': 'formsend_question'});
             console.log('formsend_question');
         }else{
             dataLayer.push({'event': 'formsend_review'});
             console.log('formsend_review');
         }
cc2da9cc   Anastasia   - question page
467
468
          $.post(
              $(this).attr("action"), $(this).serialize(), function(data) {
fab1487f   Anastasia   - comments
469
                  document.getElementById(id).reset();
97b60eab   Anastasia   - comment form
470
                  form.find('.submit-close-c-a span').click();
cc2da9cc   Anastasia   - question page
471
472
473
474
                  $(".add-answer-forms").after("<p class='success-message'>"+data.message+"</p>");
                  var dat = form.data('yiiActiveForm');
                  dat.validate = false;
              }).fail(function(){
b60a88b8   Anastasia   - main page
475
  
cc2da9cc   Anastasia   - question page
476
477
          });
      });
b60a88b8   Anastasia   - main page
478
  
df88ecc9   Anastasia   - index package
479
480
481
482
483
484
485
486
      $(document).on('change', '#blog-categories', function(e) {
          var value = $(this).val();
          if (value !== ''){
              window.location.href = value;
          }else{
              window.location.href = 'blog/index';
          }
      });
fab1487f   Anastasia   - comments
487
  
10ec2a3b   Anastasia   feedback
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
      $(document).on('submit', '#callback-form', function(e) {
          e.preventDefault();
          e.stopImmediatePropagation();
          $.post($(this)
              .attr("action"), $(this)
              .serialize(), function(data) {
              document.getElementById("callback-form")
                      .reset();
              var data_ = $("#callback-form")
                  .data('yiiActiveForm');
              data.validated = false;
              success()
          })
           .fail();
      });
724308f6   Anastasia   add status to price
503
  });
10ec2a3b   Anastasia   feedback
504
505
  
  
03ffbf5b   Anastasia   asset autocompress
506
507
508
  jQuery.fn.load = function(callback) {
    $(window).on("load", callback)
  };
724308f6   Anastasia   add status to price
509
510
  
  window.onload = function () {
36308a03   Виталий   big update
511
512
513
514
515
      // console.log('start onload');
      //
      //  $('body').addClass('end-preloader')
      //  $('nav').addClass('start')
      //  $('body').addClass('disabled-preloader')
724308f6   Anastasia   add status to price
516
517
  
      //альтернативный с задержкой выключения
8c6a2fd6   Anastasia   - delete preloader
518
519
520
521
522
523
524
525
526
  //    setTimeout(function () {
  //        $('body').addClass('end-preloader')
  //    },2700);
  //
  //    setTimeout(function () {
  //        console.log('start');
  //        $('nav').addClass('start');
  //        $('body').addClass('disabled-preloader')
  //    },2700 + 2000);
dcd4af1c   Виталий   blog/contacts/pac...
527
528
  
  
03ffbf5b   Anastasia   asset autocompress
529
  };
df88ecc9   Anastasia   - index package