Blame view

frontend/web/js/script.js 14.7 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();
2a888c42   Виталий   sidebar menu chil...
13
      mobCatalogService();
b60a88b8   Anastasia   - main page
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
  
      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
157
              });
b60a88b8   Anastasia   - main page
158
159
160
              $(phoneInput).focusout(function () {
                  var phoneVal = $(this).val()
                  //if(phoneVal == '+38(0' || phoneVal == '+38(' || phoneVal == '+38' || phoneVal == '+3' || phoneVal == '+') {$(this).val('')}
fce22ac2   Anastasia   - visits
161
                  if(phoneVal.length <15) {$(this).val('')}
b60a88b8   Anastasia   - main page
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
              })
          }
      }
  
      function catalogMenu() {
  
          $('.mobi-menu-catalog').children('ul').children('li')
              .each(function() {
                  if ($(this)
                          .find('ul').length > 0) {
                      $(this)
                          .addClass('has-list');
                  }
              })
  
6dd77cde   Виталий   qwsedrftg
177
178
  
          $('.mobi-menu-catalog .has-list a').click(function() {
b60a88b8   Anastasia   - main page
179
180
181
182
183
184
185
186
                  if ($(this).parent().hasClass('active-menu')) {
                      $(this).parent().removeClass('active-menu');
                  } else {
                      $(this).parent().addClass('active-menu');
                  }
              })
      }
  
6dd77cde   Виталий   qwsedrftg
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
228
      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
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
      
      $(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)
      }
  
fce22ac2   Anastasia   - visits
315
      window.success = success;
b60a88b8   Anastasia   - main page
316
317
318
319
      if($(window).width() >= 768) {
          animations();
      }
      function animations() {
6dd77cde   Виталий   qwsedrftg
320
321
322
          function animBox3() {
              if($('.section-box-3').length) {
                  $('.section-box-3').addClass('anim')
b60a88b8   Anastasia   - main page
323
324
                  var scrollPos = $(window).scrollTop();
                  var windHeight = $(window).height();
6dd77cde   Виталий   qwsedrftg
325
                  var bl = $('.section-box-3');
b60a88b8   Anastasia   - main page
326
327
                  var pos = bl.offset().top;
                  if(scrollPos >= (pos - (windHeight - 200 ))) {
6dd77cde   Виталий   qwsedrftg
328
                      bl.addClass('start')
b60a88b8   Anastasia   - main page
329
                  }
6dd77cde   Виталий   qwsedrftg
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
               }
          }
  
  
      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
349
              }
c237629a   Anastasia   first commit
350
          }
6dd77cde   Виталий   qwsedrftg
351
352
      }
  
b60a88b8   Anastasia   - main page
353
  
6dd77cde   Виталий   qwsedrftg
354
355
356
357
  
  
  
      function animBox2() {
b60a88b8   Anastasia   - main page
358
359
360
361
          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
362
                  document.location.href = link;
b60a88b8   Anastasia   - main page
363
              })
6dd77cde   Виталий   qwsedrftg
364
365
366
367
368
369
370
371
372
              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
373
              }
6dd77cde   Виталий   qwsedrftg
374
375
376
           }
      }
  
b60a88b8   Anastasia   - main page
377
378
379
380
381
382
  
          $(window).scroll(function () {
              animBox3();
              animBox4();
              animBox2();
          })
c237629a   Anastasia   first commit
383
      }
b60a88b8   Anastasia   - main page
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
  
      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
402
403
404
405
406
407
      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
408
409
410
411
412
413
414
415
416
417
              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')
              }
  
          })
  
          $('body').on('click','.add-answer-forms span',function () {
              $(this).parent().parent().find('.hidden-answer-comment-form').removeClass('hidden')
c915c06e   Виталий   service
418
419
420
          })
      }
  
2a888c42   Виталий   sidebar menu chil...
421
422
423
424
425
426
      function mobCatalogService() {
          $('body').on('click','.all-catalog-mob',function () {
              $(this).parent().toggleClass('active');
          })
      }
  
b60a88b8   Anastasia   - main page
427
  
cc2da9cc   Anastasia   - question page
428
429
      $('nav').addClass('hide_');
      $('body').addClass('start-preloader');
b60a88b8   Anastasia   - main page
430
  
b60a88b8   Anastasia   - main page
431
  
b60a88b8   Anastasia   - main page
432
  
fab1487f   Anastasia   - comments
433
      $(document).on('submit', '#total_question_form, #total_comment_form', function(e) {
cc2da9cc   Anastasia   - question page
434
435
         e.preventDefault();
         var form = $(this);
fab1487f   Anastasia   - comments
436
         var id = form.attr('id');
cc2da9cc   Anastasia   - question page
437
438
439
         var url = form.attr('action');
          $.post(
              $(this).attr("action"), $(this).serialize(), function(data) {
fab1487f   Anastasia   - comments
440
                  document.getElementById(id).reset();
cc2da9cc   Anastasia   - question page
441
442
443
444
445
                  form.find('.submit-close-c-a').click();
                  $(".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
446
  
cc2da9cc   Anastasia   - question page
447
448
          });
      });
b60a88b8   Anastasia   - main page
449
450
  
  
fab1487f   Anastasia   - comments
451
  
724308f6   Anastasia   add status to price
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
  });
  
  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)
2a888c42   Виталий   sidebar menu chil...
471
472
473
474
475
  }
  
  $(window).load(function() {
      console.log('start load jquery');
  });