Blame view

frontend/web/js/script.js 31.4 KB
e97db116   Timur Kastemirov   index page
1
2
3
4
5
6
7
8
9
10
11
12
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
  $(document).ready(function(){
      //var basket = new ArtboxBasket();
      footerBottom();
      slidersItemsPositionFix();
      callMobile();
      openMobMenu();
      closeCallMobileHide();
      closeMobMenu();
      addArrowMobMenuAndOpen();
      modalForms();
      popularRequest();
      hoverMainMenu();
      seoTxt();
      scrollUp();
      headerPhonesAndMap();
      disabledTagsCatalog();
      sortList();
      pagination();
      filters();
       priceSlider();
      priceSliderFixInputTxt();
      menuAllPage();
      filtersShowMobil();
      searchShow();
      openCardParams();
      openComments();
      checkedFilter();
      phoneMask();
      blogListTags();
      scrollToCommentsWrite();
      basketTabs();
      basketHiddenRadio();
  
      footerBottom();
      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() {
          $('body').append('<div class="mob-overlay visible-xs visible-sm"></div>')
      }
      function mobOverlayRemove() {
          $('.mob-overlay').remove()
      }
  
      function openMobMenu() {
          $('.menu_mob').click(function () {
              mobOverlayAdd()
              $('body').addClass('off-scroll')
              $('#menu-mob-hidden').addClass('opens')
              setTimeout(function () {
                  $('#menu-mob-hidden').addClass('visible')
              },10)
5dd435a4   Timur Kastemirov   first commit
57
          })
e97db116   Timur Kastemirov   index page
58
      }
5dd435a4   Timur Kastemirov   first commit
59
  
e97db116   Timur Kastemirov   index page
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
      function closeCallMobileHide() {
          $('.call-mobile-wr').removeClass('visible')
          setTimeout(function () {
              $('.call-mobile-wr').removeClass('open')
          },200)
      }
  
      function closeMobMenu() {
          $('body').on('click','.mob-overlay',function () {
              mobOverlayRemove()
              if($('#menu-mob-hidden').hasClass('visible')) {
                  $('#menu-mob-hidden').removeClass('visible')
                  setTimeout(function () {
                      $('#menu-mob-hidden').removeClass('opens')
                  },200)
                  $('body').removeClass('off-scroll')
              }
              if($('.btn_call').hasClass('close')) {
                  $('.btn_call').removeClass('close')
                  closeCallMobileHide()
              }
5dd435a4   Timur Kastemirov   first commit
81
  
5dd435a4   Timur Kastemirov   first commit
82
          })
e97db116   Timur Kastemirov   index page
83
84
85
86
87
88
89
90
91
92
          $('.close-menu-mob .close_mob').click(function () {
              mobOverlayRemove()
              $('#menu-mob-hidden').removeClass('visible')
              setTimeout(function () {
                  $('#menu-mob-hidden').removeClass('opens')
              },200)
              $('body').removeClass('off-scroll')
              $('#menu-mob-hidden ul li.has_ul').removeClass('open')
          })
      }
5dd435a4   Timur Kastemirov   first commit
93
  
e97db116   Timur Kastemirov   index page
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
      function addArrowMobMenuAndOpen() {
          $('#menu-mob-hidden ul li').each(function () {
              if($(this).find('ul').length>0){
                  $(this).addClass('has_ul')
                  $(this).parent().addClass('sub_m')
                  $('#menu-mob-hidden>ul').removeClass('sub_m').addClass('sub_m-first');
              }
          })
  
  
          
              $('body').on('click','#menu-mob-hidden ul li.has_ul a',function () {
                  if($(this).parent().parent().hasClass('sub_m')){  //если li элемент вложженый
                      if($(this).parent().hasClass('open')){
                          $(this).parent().removeClass('open')
                      } else {
                          $('.sub_m').find('.has_ul').removeClass('open')
                          $(this).parent().addClass('open')
                      }
5dd435a4   Timur Kastemirov   first commit
113
                  }
e97db116   Timur Kastemirov   index page
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
  
                  if($(this).parent().parent().hasClass('sub_m-first')) {  //если ли родительский открываем/закрываем
                      if($(this).parent().hasClass('open')) {
                          $(this).parent().removeClass('open')
                          $(this).parent().find('.open').removeClass('open')
                      } else {
                          $(this).parent().addClass('open')
                      }
  
                  }
  
          })
  
  
  
5dd435a4   Timur Kastemirov   first commit
129
130
      }
  
e97db116   Timur Kastemirov   index page
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
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
  
      
      var scrollPos = 0;
      var posY = 0;
      scrollItemsPos()
      function scrollItemsPos() {
        scrollPos = $(this).scrollTop()
          // console.log(scrollPos)
      }
  
      $(window).scroll(function () {
          scrollItemsPos()
          $('.items_.cloned').css({top:posY-scrollPos})
      })
  
  
  
      function slidersItemsPositionFix() {
          $('.items_.clone').remove()
  
          $('.sliders .items_').mouseover(function () {
              $('.items_.clone').remove()
              $('#overlay').addClass('overlay_cloned')
              if(($(window).width())>=768) {
  
                  var width = $(this).width();
                  var posX = $(this).offset().left;
                  posY = $(this).offset().top;
                  var this_ = $(this);
                  this_.clone().appendTo('body').addClass('cloned no-transition').css({
                      width:width + 29.5,
                      top:posY - scrollPos,
                      left:posX
                  })
              }
          })
  
          $('#overlay').hover(function () {
              $('.items_.cloned').remove();
              $(this).removeClass('overlay_cloned')
          }, function () {
              //console.log('leave hover')
          })
      }
  
  
  
  
      window.onresize = function () {
          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')
              $('.mob_filters_wr').attr('style','')
          }
          hoverMainMenu()
      }
  
  
  
      function callMobile() {
          $('.btn_call').click(function() {
  
              if(!($(this).hasClass('close'))){
                  $('.btn_call').addClass('close')
                  mobOverlayAdd()
  
                  $('.call-mobile-wr').addClass('visible')
                  setTimeout(
                      function() {
                          $('.call-mobile-wr').addClass('open')
                      }, 20
                  )
5dd435a4   Timur Kastemirov   first commit
209
              } else {
e97db116   Timur Kastemirov   index page
210
211
212
213
214
215
                  mobOverlayRemove()
                  closeCallMobileHide()
                  $('.btn_call')
                      .removeClass('close')
                  $('.call-mobile-wr')
                      .removeClass('open')
5dd435a4   Timur Kastemirov   first commit
216
                  $('body')
e97db116   Timur Kastemirov   index page
217
                      .removeClass('off-scroll')
5dd435a4   Timur Kastemirov   first commit
218
              }
5dd435a4   Timur Kastemirov   first commit
219
  
e97db116   Timur Kastemirov   index page
220
221
222
223
224
225
226
227
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
          })
  
      }
  
  
  
  
      function popularRequest() {
          $('.popular-requests span, .popular-requests a').click(function () {
              var thisRequest = $(this).html();
              $(this).parent().parent().find('form input').val(thisRequest);
              $(this).parent().parent().find('form').submit();
          })
      }
      
      function hoverMainMenu() {
          if(window.innerWidth>=992){
              var widthMenu = ($('.section-box-content .container').width())-($('.section-box-content .main-menu').width());
              $('.main-menu').addClass('full');
              $('.main-menu ul li ul').css({width:widthMenu});
          }
          $('.section-box-content .main-menu ul li').each(function () {
              if($(this).find('ul').length<=0){
                  $(this).addClass('not-list')
              }
          })
  
      }
  
      function seoTxt() {
          var txt1 = $('.all_seo_text').data('show');
          var txt2 = $('.all_seo_text').data('hide');
          $('.all_seo_text').click(function (e) {
              e.preventDefault()
              $('.seo-text').toggleClass('show')
              $(this).toggleClass('show')
              if($(this).hasClass('show')) {
                  $(this).html(txt2)
              } else {
                  $(this).html(txt1);
              }
          })
      }
  
      function scrollUp() {
          $('.btn_up').click(function () {
              $('body, html').animate({scrollTop:0}, 500);
          })
          btnScroll()
          function btnScroll() {
              btnScrollPos()
              function btnScrollPos() {
                  var containerPos = $('.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')
5dd435a4   Timur Kastemirov   first commit
285
                  }
e97db116   Timur Kastemirov   index page
286
287
288
289
290
                  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
5dd435a4   Timur Kastemirov   first commit
291
  
e97db116   Timur Kastemirov   index page
292
293
294
295
                  if(($(this).scrollTop())>=docFooterHeight){
                      $('.btn_up').css({bottom:(fHe+16)-((documentHeight-scrpos)-($(window).height()))})
                  } else  {
                      $('.btn_up').css({bottom:16})
5dd435a4   Timur Kastemirov   first commit
296
                  }
e97db116   Timur Kastemirov   index page
297
              }
5dd435a4   Timur Kastemirov   first commit
298
  
e97db116   Timur Kastemirov   index page
299
300
301
302
              $(window).resize(function () {
                  btnScrollPos()
                  btnScrollShowHide()
              })
5dd435a4   Timur Kastemirov   first commit
303
  
e97db116   Timur Kastemirov   index page
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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
              $(window).scroll(function () {
                  btnScrollShowHide()
              })
  
  
              $('.btn_scroll').click(function () {
                  $('body,html').animate( { scrollTop: 0 }, 500 );
              })
  
          }
      }
  
      function headerPhonesAndMap() {
  
  
          $('.cities-wr .s_').click(function () {
              var thisCity = $(this).html()
              var thisPhones = $(this).next().html()
              if(!($(this).parents('.cities-wr').hasClass('cities-wr-map'))){
                  $('.header-phones p').remove()
                  $('.header-phones').append(thisPhones)
  
              } else { //блок с картой
                  
                  $('.adress-map span').remove()
                  $('.adress-map').append(thisPhones)
  
                  var thisDataLat = $(this).data('lat')//определяем координаты lat
                  var thisDataLng = $(this).data('lng')//определяем координаты lng
  
                  var magaz = $(this).next().find('span');
  
                  function initialize() {
                      var start_position  = new google.maps.LatLng(thisDataLat, thisDataLng);
                      var styles = [{
                          stylers: [
                              { saturation: -100 }
                          ]
                      }];
                      var settings = {
                          styles: styles,
                          zoom: 12,
                          scrollwheel: false,
                          center: start_position,
                          mapTypeControl: true,
                          mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
                          navigationControl: false,
                          navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
                          scaleControl: true,
                          streetViewControl: true,
                          rotateControl: true,
                          zoomControl: true,
                          mapTypeId: google.maps.MapTypeId.ROADMAP
                      };
                      var map = new google.maps.Map(document.getElementById("map_canvas"), settings);
5dd435a4   Timur Kastemirov   first commit
359
  
e97db116   Timur Kastemirov   index page
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
  
                      var image1 = new google.maps.MarkerImage('images/markers/marker-we-1.png',
                          new google.maps.Size(34, 48),
                          new google.maps.Point(0,0),
                          new google.maps.Point(16, 35)
                      );
  
                      var markers = [];
  
                      magaz.each(function () {
                          var newLat = $(this).data('lat');//определяем координаты lat
                          var newLng = $(this).data('lng');//определяем координаты lng
  
                          var newName =  $(this).text();//title
  
  
  
                          var marker = new google.maps.Marker({
                              position: new google.maps.LatLng(newLat, newLng),
                              map: map,
                              title: newName,
                              icon: image1
                          });
                          markers.push(marker);
                      })
  
                      var clusterStyles = [
                          {
                              url: 'images/markers/clasters.png',
                              height: 36,
                              width: 36
                          }
                      ];
                      markerClusterer = new MarkerClusterer(map, markers,
                          {
                              maxZoom: 10,
                              gridSize: 100,
                              styles: clusterStyles
                          });
                  }
  
                  if($(window).width()>=768){
                      initialize()
                  }
                  $(window).resize(function () {
                      if($(window).width()>=768){
                          initialize()
5dd435a4   Timur Kastemirov   first commit
407
                      }
e97db116   Timur Kastemirov   index page
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
                  })
  
              }
  
              $(this).parents('.cities-wr').find('.addCity i').html(thisCity)
              $(this).parents('.cities-wr').find('.hidden_shops').css({display:'none'})
              $(this).parents('.cities-wr').find('.hidden_shops ul li').removeClass('active')
              $(this).parent().addClass('active')
             
          })
  
          $('body').on('click','.adress-map span',function () {
  
              var thisDataLat = $(this).data('lat')//определяем координаты lat
              var thisDataLng = $(this).data('lng')//определяем координаты lng
              var newName =  $(this).text();//название
  
              function initialize() {
                  var start_position  = new google.maps.LatLng(thisDataLat, thisDataLng);
                  var styles = [{
                      stylers: [
                          { saturation: -100 }
                      ]
                  }];
                  var settings = {
                      styles: styles,
                      zoom: 16,
                      scrollwheel: false,
                      center: start_position,
                      mapTypeControl: true,
                      mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
                      navigationControl: false,
                      navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
                      scaleControl: true,
                      streetViewControl: true,
                      rotateControl: true,
                      zoomControl: true,
                      mapTypeId: google.maps.MapTypeId.ROADMAP
                  };
                  var map = new google.maps.Map(document.getElementById("map_canvas"), settings);
  
  
                  var image1 = new google.maps.MarkerImage('images/markers/marker-we-1.png',
                      new google.maps.Size(34, 48),
                      new google.maps.Point(0,0),
                      new google.maps.Point(16, 35)
                  );
  
  
                  var marker = new google.maps.Marker({
                      position: new google.maps.LatLng(thisDataLat, thisDataLng),
                      map: map,
                      title: newName,
                      icon: image1
5dd435a4   Timur Kastemirov   first commit
462
                  });
e97db116   Timur Kastemirov   index page
463
464
  
  
5dd435a4   Timur Kastemirov   first commit
465
              }
5dd435a4   Timur Kastemirov   first commit
466
  
e97db116   Timur Kastemirov   index page
467
468
469
470
471
472
              if($(window).width()>=768){
                  initialize()
              }
              $(window).resize(function () {
                  if($(window).width()>=768){
                      initialize()
5dd435a4   Timur Kastemirov   first commit
473
474
                  }
              })
5dd435a4   Timur Kastemirov   first commit
475
  
e97db116   Timur Kastemirov   index page
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
          })
      }
      
      function disabledTagsCatalog() {
          $('body').on('click','.tags-catalog .disabled',function (e) {
              e.preventDefault();
          })
      }
  
      function sortList() {
          $('.sort-cat>a').click(function (e) {
              if($(this).hasClass('category-sort')){
                  e.preventDefault();
                  $('.sort-cat').toggleClass('active')
              }
          })
  
          $('.sort-cat ul li a').click(function () {
              $('.category-sort').html($(this).text())
              $('.sort-cat ul li a').removeClass('desc')
              $(this).addClass('desc')
          })
  
          var timeoutSort
          $('.sort-cat').hover(function () {
              clearTimeout(timeoutSort)
          },function () {
              timeoutSort = setTimeout(function () {
                  $('.sort-cat').removeClass('active')
              },320)
  
          })
      }
  
      function pagination() {
          $('body').on('click','.pagination li.active',function (e) {
              e.preventDefault();
          })
      }
  
  
      function filters() {
          //удаляем выбранне фильтра(серые кнопки)
          $('body').on('click','.wrapp_clear-link a',function () {
              var thisParents = $(this).parent().parent();
              $(this).remove();
              if($('.wrapp_clear-link a').length<=0){
                  thisParents.remove();
              }
          })
  
  
          $('body').on('click','.buttonsSort a.active',function (e) {
5dd435a4   Timur Kastemirov   first commit
529
              e.preventDefault();
e97db116   Timur Kastemirov   index page
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
          })
  
          //открываем/скрываем все фильтра
          $('.close_filter').click(function () {
              var desiredBlock = $(this).parents('.input-blocks');
              desiredBlock.toggleClass('hide_filter');
              desiredBlock.find('.s_c_h').removeClass('visible_s_c_h');
              desiredBlock.find('.more_six-btn span').removeClass('show_all');
          })
  
          //открываем/скрываем группу фильтров(6 штук)
          $('.more_six-btn span').click(function () {
              var desiredBlock = $(this).parents('.more_six').find('.s_c_h');
              desiredBlock.toggleClass('visible_s_c_h');
              $(this).toggleClass('show_all');
          })
      }
  
      function priceSlider(){
  
          var $price_interval = $('#price_interval');
          var $filter_prices_min = $('#filter-prices-min');
          var $filter_prices_max = $('#filter-prices-max');
  
  
          if($price_interval.length){
  
              var block = $('#price_block');
              var link = block.data('url');
              var min = block.data('min');
              var max = block.data('max');
              var from = block.data('from');
              var to = block.data('to');
  
  
              $price_interval.ionRangeSlider({
                  type: 'double',
                  min: min,
                  max: max,
                  from: from,
                  to: to,
                  grid: false,
                  hide_min_max: true,
                  hide_from_to: true,
                  onChange: function (e) {
                      $filter_prices_min.val(e.from);
                      $filter_prices_max.val(e.to)
5dd435a4   Timur Kastemirov   first commit
577
                  },
e97db116   Timur Kastemirov   index page
578
579
                  onFinish: function(e) {
  
5dd435a4   Timur Kastemirov   first commit
580
581
                  }
              });
5dd435a4   Timur Kastemirov   first commit
582
  
e97db116   Timur Kastemirov   index page
583
584
585
586
587
              $('#btn_ok span').click(function () {
                  var from = $filter_prices_min.val();
                  var to = $filter_prices_max.val();
                  $.pjax({url: link.replace('{from}', from).replace('{to}', to), container: "#list-container",timeout:5000, scrollTo: 0})
              });
5dd435a4   Timur Kastemirov   first commit
588
  
e97db116   Timur Kastemirov   index page
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
              var slider = $price_interval.data("ionRangeSlider");
  
              $filter_prices_min.change(function () {
                  var newVal = $(this).val();
                  slider.update({
                      from: newVal
                  });
              });
  
              $filter_prices_max.change(function () {
                  var newVal = $(this).val();
                  slider.update({
                      to: newVal
                  });
              })
  
  
          }
      }
      
      function priceSliderFixInputTxt() {
          $('.price_inputs input').keypress(function(e) {
              if (!(e.which==8 ||(e.which>47 && e.which<58))) return false;
5dd435a4   Timur Kastemirov   first commit
612
          });
e97db116   Timur Kastemirov   index page
613
614
615
616
617
618
619
620
621
622
623
624
          $('.price_inputs input').focusout(function () {
              var thisVal = +($(this).val());
              var thisMin = +($(this).attr('min'));
              var thisMax = +($(this).attr('max'));
                if(thisVal<thisMin) {
                    $(this).val(thisMin);
                }
                  if(thisVal>thisMax) {
                    $(this).val(thisMax);
                }
          })
  
5dd435a4   Timur Kastemirov   first commit
625
  
e97db116   Timur Kastemirov   index page
626
627
628
629
630
631
632
633
634
635
636
637
      }
  
      function  menuAllPage() {
          $('.arrow-catalog').click(function () {
              $(this).toggleClass('active')
              if($(this).hasClass('active')){
                  $('.menu_all_page').addClass('show_menu_all')
                  setTimeout(function () {
                      $('.menu_all_page').addClass('opacity_off')
                  },100)
              } else {
                  $('.menu_all_page').removeClass('show_menu_all opacity_off')
5dd435a4   Timur Kastemirov   first commit
638
              }
e97db116   Timur Kastemirov   index page
639
640
641
642
643
644
645
646
647
          })
          var timeoutMenu
          $('.menu_all_page').hover(function () {
              clearTimeout(timeoutMenu)
          },function () {
              timeoutMenu = setTimeout(function () {
                  $('.menu_all_page').removeClass('show_menu_all opacity_off')
                  $('.arrow-catalog').removeClass('active')
              },320)
5dd435a4   Timur Kastemirov   first commit
648
  
e97db116   Timur Kastemirov   index page
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
          })
      }
      
      function filtersShowMobil() {
          $('.filter_mobile_').click(function () {
              $('.mob_filters_wr').animate({left:0,opacity:1},300)
              $('body').addClass('hidden_scroll-y')
          })
  
          $('.close_mob_filters').click(function () {
              $('body').removeClass('hidden_scroll-y')
              $('.mob_filters_wr').animate({left:'-100%',opacity:0},300)
          })
      }
  
      function searchShow() {
          $('.search-btn-menu-mob').click(function (e) {
              e.preventDefault()
             $('.search-header-wr').addClass('show_search')
          })
          $('.close_search').click(function () {
              $('.search-header-wr').removeClass('show_search')
          })
      }
  
      function openCardParams() {
          $('.p_wrapp').click(function () {
              var windWidth = $(window).width();
              if(windWidth<768){
                  if(($(this).hasClass('open_p'))){
                      $(this).removeClass('open_p')
                  } else {
                      $('.p_wrapp').removeClass('open_p')
                      $(this).addClass('open_p')
                  }
5dd435a4   Timur Kastemirov   first commit
684
              }
e97db116   Timur Kastemirov   index page
685
686
687
688
          })
          $(window).resize(function () {
              if($(window).width()>=768) {
                  $('.p_wrapp').removeClass('open_p')
5dd435a4   Timur Kastemirov   first commit
689
              }
e97db116   Timur Kastemirov   index page
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
          })
      }
  
      function  openComments() {
          var linkComments = '#comments';
          var commentsAnchor = $('.comments_anchor');
  
          function scrollComments() {
              var timeScrollComments = 850;
              if($(window).width()>=768) {
                  $('body, html').animate({scrollTop:(commentsAnchor.offset().top)-38}, timeScrollComments);
              } else {
                  $('.p_wrapp').removeClass('open_p')
                  $('.comments_anchor').addClass('open_p')
                  $('body, html').animate({scrollTop:(commentsAnchor.offset().top)-3}, timeScrollComments);
5dd435a4   Timur Kastemirov   first commit
705
              }
e97db116   Timur Kastemirov   index page
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
  
          }
  
          if(window.location.hash == linkComments){
              scrollComments()
          }
  
          $('.card_code_wr .cat_comments-link').click(function () {
              scrollComments()
          })
      }
      
      function checkedFilter() {
          $('.sidebar_checks a').click(function () {
              $(this).parent().addClass('checked')
          })
      }
  
      function scrollToCommentsWrite() {
              $('.write_comments span').click(function () {
                  var pos = $(this).parents('.comments-wr-blog').find('#commentmodel-username');
                  pos.focus();
                  $('body, html').animate({scrollTop:(pos.offset().top)-30}, 500);
              })
      }
  
      function phoneMask() {
          var phoneInput = '.phones_mask input'
  
          if($('body').find(phoneInput).length>0){
              $(phoneInput).mask('+38(000)000-00-00',{placeholder:'+38(000)000-00-00'});
              $(phoneInput).focus(function () {
                  if(($(this).val())== '') {$(this).val('+38(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 blogListTags() {
          $('.blog-cat-tags-title').click(function () {
              var tagsParents = $(this).parents('.blog-cat-tags-wr.hidden-mob');
              if(tagsParents.hasClass('active')){
                  tagsParents.removeClass('active')
              } else  {
                  tagsParents.addClass('active')
5dd435a4   Timur Kastemirov   first commit
755
              }
e97db116   Timur Kastemirov   index page
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
          })
      }
      
      function basketTabs() {
          $('.basket-tabs_list-wr ul li').click(function (e) {
              e.preventDefault();
              var indexbasketTabs = $(this).index()
              $('.basket-tabs_list-wr ul li').removeClass('active');
              $(this).addClass('active');
              var mobTabsBasket = $('.tabs_basket-mobile');
              mobTabsBasket.removeClass('active-mobile')
              $(mobTabsBasket[indexbasketTabs]).addClass('active-mobile')
          })
          $('.btn_mobil_show_desk').click(function (e) {
              e.preventDefault();
              var indexbasketTabsMob = $(this).parent().index();
              $('.btn_mobil_show_desk').parent().removeClass('active-mobile');
              $(this).parent().addClass('active-mobile');
              var mobTabsBasket = $('.basket-tabs_list-wr ul li')
              mobTabsBasket.removeClass('active')
              $(mobTabsBasket[indexbasketTabsMob]).addClass('active')
          })
  
          if(($(window).width())<768) {
              $('.tabs_basket-mobile').removeClass("active-mobile");
          }
      }
      
      function basketHiddenRadio() {
          $('.delivery-wrapper .radio_custom input[type="radio"], .payment-wrapper .radio_custom input[type="radio"]').click(function () {
              if($(this).parents('.delivery-wrapper').hasClass('delivery-wrapper')){
  
                  if($(this).parents('.hidden_form_radio').length){
                      $('.delivery-wrapper .hidden_form_radio .visible_hidden_radio').removeClass('visible_hidden_radio');
                      $('.delivery-wrapper .hidden_form_radio .visible_hidden_radio-child').removeClass('visible_hidden_radio-child');
                      $(this).parent().addClass('visible_hidden_radio-child')
                  } else {
                      $('.delivery-wrapper .visible_hidden_radio').removeClass('visible_hidden_radio');
                      $(this).parent().addClass('visible_hidden_radio')
                  }
  
5dd435a4   Timur Kastemirov   first commit
797
              } else {
e97db116   Timur Kastemirov   index page
798
799
800
801
802
803
                  if($(this).parents('.hidden_form_radio').length){
                      $('.payment-wrapper .hidden_form_radio .visible_hidden_radio').removeClass('visible_hidden_radio');
                      $(this).parent().addClass('visible_hidden_radio-child')
                  } else {
                      $('.payment-wrapper .visible_hidden_radio').removeClass('visible_hidden_radio');
                      $(this).parent().addClass('visible_hidden_radio')
5dd435a4   Timur Kastemirov   first commit
804
                  }
e97db116   Timur Kastemirov   index page
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
  
              }
  
              //$(this).parent().addClass('visible_hidden_radio')
  
          })
      }
  
      function modalForms() {
          $('body').on('click','.modal-link', function (e) {
              e.preventDefault();
  
  
              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;
5dd435a4   Timur Kastemirov   first commit
839
              }
e97db116   Timur Kastemirov   index page
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
              $('#overlay').removeClass('overlay_cloned');
              $('#overlay').fadeIn(400,
                  function(){
                      $('#'+idForm)
                          .css('display', 'block')
                          .animate({opacity: 1, top: pos}, 200);
                  });
          })
      }
  
      $(document).on('click', '.remove_ico', confirmRemove);
      $(document).on('click', '.remove_confirm a', removeBasket);
      $(document).on('click', '.quantity-wr span', changeBasket);
      $(document).on('change', '.quantity-wr input', setBasket);
      $(document).on('keypress', '.quantity-wr input', setControl);
  
  
       $(document).on('click', '.btn_buy_basket', addBasket);
  
      function addBasket() {
          $.post("basket-modal.html", function (data) {
              $(".basket_modal").empty().append(data);
5dd435a4   Timur Kastemirov   first commit
862
          });
e97db116   Timur Kastemirov   index page
863
      }
5dd435a4   Timur Kastemirov   first commit
864
  
5dd435a4   Timur Kastemirov   first commit
865
  
e97db116   Timur Kastemirov   index page
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
      $(document).on('click', '.basket-modal-bg #modal_close, #modal_close-2, #overlay', closeHideBasket);
  
      function confirmRemove(e) {
          e.preventDefault();
          $(this)
              .parent()
              .addClass('confirm');
      }
  
      function removeBasket(e) {
          e.preventDefault();
          if ($(this).hasClass('remove-yes')) {
              var variant = $(this).parents('tr.variant_tr').data('variant');
              //удаление ячейки "tr" в корзине
              basket.remove(variant);
              $(this).parents('.confirm').parent().remove()
          } else {
5dd435a4   Timur Kastemirov   first commit
883
              $(this)
e97db116   Timur Kastemirov   index page
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
                  .parents('.confirm').removeClass('confirm')
          }
      }
  
      function changeBasket(e) {
          e.preventDefault();
          var variant = $(this).parents('tr.variant_tr').data('variant');
          var input = $(this).parent().find('input');
          var oldVal = input.val();
          if ($(this).hasClass('minus')) {
              if (oldVal > 1) {
                  basket.add(variant, -1);
              }
          } else {
              basket.add(variant, 1);
          }
      }
      
      function setBasket(e) {
          e.preventDefault();
          var variant = $(this).parents('tr.variant_tr').data('variant');
          var count = $(this).val();
          basket.set(variant, count);
      }
  
      function setControl(e) {
          if (e.which == 13) {
5dd435a4   Timur Kastemirov   first commit
911
              $(this)
e97db116   Timur Kastemirov   index page
912
                  .trigger('change');
5dd435a4   Timur Kastemirov   first commit
913
              return false;
e97db116   Timur Kastemirov   index page
914
915
916
917
918
919
920
921
922
923
          } else if (!(e.which == 8 || (e.which > 47 && e.which < 58))) {
              return false;
          }
      }
  
      function closeHideBasket() {
          $('#overlay').fadeOut(400);
          $('.basket_modal').animate({opacity: 0, top: '0'}, 200,function(){
              $(this).css('display', 'none');
              $('#overlay').fadeOut(400);
5dd435a4   Timur Kastemirov   first commit
924
          });
e97db116   Timur Kastemirov   index page
925
      }
5dd435a4   Timur Kastemirov   first commit
926
  
e97db116   Timur Kastemirov   index page
927
928
929
930
931
932
      closeForms();
      function closeForms() {
          $('#modal_close, #overlay').click( function(){
              $('.forms_, .basket_modal').animate({opacity: 0, top: '0'}, 200,function(){
                  $(this).css('display', 'none');
                  $('#overlay').fadeOut(400);
5dd435a4   Timur Kastemirov   first commit
933
              });
e97db116   Timur Kastemirov   index page
934
935
936
              $('#success_form').animate({opacity: 0, top: '0'}, 200,function(){
                  $(this).css('display', 'none');
                  $(this).css({top:'50%'});
5dd435a4   Timur Kastemirov   first commit
937
              });
5dd435a4   Timur Kastemirov   first commit
938
          });
e97db116   Timur Kastemirov   index page
939
940
941
942
943
944
945
      }
      //после удачной отправки формы запускать success()
      // success()
      function success() {
          var pos = ($(window).scrollTop()) + 30;
          $('.forms_').animate({opacity: 0, top: '0'}, 200,function(){
              $(this).css('display', 'none');
5dd435a4   Timur Kastemirov   first commit
946
          });
e97db116   Timur Kastemirov   index page
947
948
949
950
951
952
953
954
955
956
957
          setTimeout(function () {
              $('#overlay').fadeIn(400);
              $('#success_form').css('display', 'block').animate({opacity: 1, top: pos}, 700);
          },400)
      }
  
  
  
      
  
  
5dd435a4   Timur Kastemirov   first commit
958
  });
e97db116   Timur Kastemirov   index page