Blame view

frontend/web/js/script.js 15.6 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
146
147
148
149
150
151
152
153
154
155
156
157
158
  
      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')}
fce22ac2   Anastasia   - visits
159
              });
b60a88b8   Anastasia   - main page
160
161
162
              $(phoneInput).focusout(function () {
                  var phoneVal = $(this).val()
                  //if(phoneVal == '+38(0' || phoneVal == '+38(' || phoneVal == '+38' || phoneVal == '+3' || phoneVal == '+') {$(this).val('')}
fce22ac2   Anastasia   - visits
163
                  if(phoneVal.length <15) {$(this).val('')}
b60a88b8   Anastasia   - main page
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
              })
          }
      }
  
      function catalogMenu() {
  
          $('.mobi-menu-catalog').children('ul').children('li')
              .each(function() {
                  if ($(this)
                          .find('ul').length > 0) {
                      $(this)
                          .addClass('has-list');
                  }
              })
  
6dd77cde   Виталий   qwsedrftg
179
180
  
          $('.mobi-menu-catalog .has-list a').click(function() {
b60a88b8   Anastasia   - main page
181
182
183
184
185
186
187
188
                  if ($(this).parent().hasClass('active-menu')) {
                      $(this).parent().removeClass('active-menu');
                  } else {
                      $(this).parent().addClass('active-menu');
                  }
              })
      }
  
6dd77cde   Виталий   qwsedrftg
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
228
229
230
      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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
      
      $(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...
245
246
247
248
249
250
251
252
253
254
255
256
  
          if(window.innerWidth <= 767) {
              $('.for-hidden-mob').mCustomScrollbar("destroy");
          } else {
              $('.for-hidden-mob').mCustomScrollbar(
                  {
                      autoHideScrollbar: true,
                      theme: 'minimal'
                  }
              );
          }
  
b60a88b8   Anastasia   - main page
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
326
327
328
      })
  
      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...
329
330
331
332
333
      $('body, html').animate({scrollTop:0},20,function () {
  
      });
  
  
fce22ac2   Anastasia   - visits
334
      window.success = success;
b60a88b8   Anastasia   - main page
335
336
      if($(window).width() >= 768) {
          animations();
9b901264   Виталий   blog/contacts/pac...
337
  
b60a88b8   Anastasia   - main page
338
339
      }
      function animations() {
9b901264   Виталий   blog/contacts/pac...
340
  
6dd77cde   Виталий   qwsedrftg
341
342
343
          function animBox3() {
              if($('.section-box-3').length) {
                  $('.section-box-3').addClass('anim')
b60a88b8   Anastasia   - main page
344
345
                  var scrollPos = $(window).scrollTop();
                  var windHeight = $(window).height();
6dd77cde   Виталий   qwsedrftg
346
                  var bl = $('.section-box-3');
b60a88b8   Anastasia   - main page
347
348
                  var pos = bl.offset().top;
                  if(scrollPos >= (pos - (windHeight - 200 ))) {
6dd77cde   Виталий   qwsedrftg
349
                      bl.addClass('start')
b60a88b8   Anastasia   - main page
350
                  }
6dd77cde   Виталий   qwsedrftg
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
               }
          }
  
  
      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
370
              }
c237629a   Anastasia   first commit
371
          }
6dd77cde   Виталий   qwsedrftg
372
373
      }
  
b60a88b8   Anastasia   - main page
374
  
6dd77cde   Виталий   qwsedrftg
375
376
377
378
  
  
  
      function animBox2() {
b60a88b8   Anastasia   - main page
379
380
381
382
          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
383
                  document.location.href = link;
b60a88b8   Anastasia   - main page
384
              })
6dd77cde   Виталий   qwsedrftg
385
386
387
388
389
390
391
392
393
              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
394
              }
6dd77cde   Виталий   qwsedrftg
395
396
397
           }
      }
  
b60a88b8   Anastasia   - main page
398
  
9b901264   Виталий   blog/contacts/pac...
399
400
401
402
          animBox3();
          animBox4();
          animBox2();
  
b60a88b8   Anastasia   - main page
403
404
405
406
407
          $(window).scroll(function () {
              animBox3();
              animBox4();
              animBox2();
          })
c237629a   Anastasia   first commit
408
      }
b60a88b8   Anastasia   - main page
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
  
      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
427
428
429
430
431
432
      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
433
434
435
436
437
438
              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
439
          });
31b3e056   Виталий   page answer
440
441
442
  
          $('body').on('click','.add-answer-forms span',function () {
              $(this).parent().parent().find('.hidden-answer-comment-form').removeClass('hidden')
c915c06e   Виталий   service
443
444
445
          })
      }
  
2a888c42   Виталий   sidebar menu chil...
446
447
448
449
450
451
      function mobCatalogService() {
          $('body').on('click','.all-catalog-mob',function () {
              $(this).parent().toggleClass('active');
          })
      }
  
b60a88b8   Anastasia   - main page
452
  
cc2da9cc   Anastasia   - question page
453
454
      $('nav').addClass('hide_');
      $('body').addClass('start-preloader');
b60a88b8   Anastasia   - main page
455
  
b60a88b8   Anastasia   - main page
456
  
b60a88b8   Anastasia   - main page
457
  
fab1487f   Anastasia   - comments
458
      $(document).on('submit', '#total_question_form, #total_comment_form', function(e) {
cc2da9cc   Anastasia   - question page
459
460
         e.preventDefault();
         var form = $(this);
fab1487f   Anastasia   - comments
461
         var id = form.attr('id');
cc2da9cc   Anastasia   - question page
462
463
464
         var url = form.attr('action');
          $.post(
              $(this).attr("action"), $(this).serialize(), function(data) {
fab1487f   Anastasia   - comments
465
                  document.getElementById(id).reset();
97b60eab   Anastasia   - comment form
466
                  form.find('.submit-close-c-a span').click();
cc2da9cc   Anastasia   - question page
467
468
469
470
                  $(".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
471
  
cc2da9cc   Anastasia   - question page
472
473
          });
      });
b60a88b8   Anastasia   - main page
474
  
df88ecc9   Anastasia   - index package
475
476
477
478
479
480
481
482
      $(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
483
  
724308f6   Anastasia   add status to price
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
  });
  
  window.onload = function () {
      console.log('start onload');
      //
      // $('body').addClass('end-preloader')
      // $('nav').addClass('start')
      // $('body').addClass('disabled-preloader')
  
      //альтернативный с задержкой выключения
      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...
503
504
505
506
507
508
509
510
511
512
  
  
      if($(window).width() > 767) {
          $('.for-hidden-mob').mCustomScrollbar(
              {
                  autoHideScrollbar: true,
                  theme: 'minimal'
              }
          );
      }
2a888c42   Виталий   sidebar menu chil...
513
514
515
516
  }
  
  $(window).load(function() {
      console.log('start load jquery');
dcd4af1c   Виталий   blog/contacts/pac...
517
  
df88ecc9   Anastasia   - index package
518
  });