Blame view

frontend/web/js/script.js 11.5 KB
cc658b4c   Yarik   Big commit
1
2
3
4
  function showForm()

  {

      $('#overlay').fadeIn(

          400, function()

d8c1a2e0   Yarik   Big commit artbox
5
          {

cc658b4c   Yarik   Big commit
6
7
8
9
10
11
12
13
14
15
16
17
              $('#modal_form-2')

              .css('display', 'block')

              .animate(

                  {

                      opacity : 1,

                      top : '80px'

                  }, 200

              );

          }

      );

      $(".scrollbar_").mCustomScrollbar();

  }

d8c1a2e0   Yarik   Big commit artbox
18
  

cc658b4c   Yarik   Big commit
19
20
21
22
23
24
25
26
27
28
  function hideForm()

  {

      $('#modal_form, #modal_form-2, #success-form').animate(

          {

              opacity : 0,

              top : 20

          }, 200, function()

          {

              $(this).css('display', 'none');

              $('#overlay').fadeOut(400);

d8c1a2e0   Yarik   Big commit artbox
29
          }

cc658b4c   Yarik   Big commit
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
      );

  }

  $(

      function()

      {

          footer();

          search();

          phonesTab();

          openMobMenu();

          closeMobMenu();

          openSubMenuMob();

          homeSlider();

          hoverCatList();

          expandAllCatList();

  //        loadCollection();

          tabs();

          var basket = new ArtboxBasket();

          if(device.mobile())

d8c1a2e0   Yarik   Big commit artbox
48
          {

cc658b4c   Yarik   Big commit
49
50
51
52
              deviceCheck();

          } else if(device.tablet())

          {

              deviceCheck();

d8c1a2e0   Yarik   Big commit artbox
53
          }

cc658b4c   Yarik   Big commit
54
          $('.gall-1').lightGallery();

d8c1a2e0   Yarik   Big commit artbox
55
  

cc658b4c   Yarik   Big commit
56
          var width = $(window).width();

d8c1a2e0   Yarik   Big commit artbox
57
  

cc658b4c   Yarik   Big commit
58
          function deviceCheck()

d8c1a2e0   Yarik   Big commit artbox
59
          {

cc658b4c   Yarik   Big commit
60
61
62
63
              var meta = document.createElement('meta');

              meta.name = "viewport";

              meta.content = "width=device-width";

              document.getElementsByTagName('head')[0].appendChild(meta);

d8c1a2e0   Yarik   Big commit artbox
64
          }

d8c1a2e0   Yarik   Big commit artbox
65
  

cc658b4c   Yarik   Big commit
66
          function footer()

d8c1a2e0   Yarik   Big commit artbox
67
          {

cc658b4c   Yarik   Big commit
68
69
70
71
              footerBottom();

              resizeFooterBottom();

  

              function footerBottom()

d8c1a2e0   Yarik   Big commit artbox
72
              {

cc658b4c   Yarik   Big commit
73
74
75
76
77
                  var heightHeader = $('.section-box-header').height();

                  var heightFooter = $('.section-box-footer').height();

                  var windowHeight = $(window).height();

                  $('.section-box-content>.container.shadow').css({minHeight : windowHeight - heightHeader - heightFooter - 3})

              }

d8c1a2e0   Yarik   Big commit artbox
78
  

cc658b4c   Yarik   Big commit
79
80
81
82
83
84
85
86
87
              function resizeFooterBottom()

              {

                  $(window).resize(

                      function()

                      {

                          footerBottom();

                      }

                  )

              }

d8c1a2e0   Yarik   Big commit artbox
88
          }

d8c1a2e0   Yarik   Big commit artbox
89
  

cc658b4c   Yarik   Big commit
90
          function mobOverlayAdd()

d8c1a2e0   Yarik   Big commit artbox
91
          {

cc658b4c   Yarik   Big commit
92
              $('body').append('<div class="mob-overlay"></div>')

d8c1a2e0   Yarik   Big commit artbox
93
          }

d8c1a2e0   Yarik   Big commit artbox
94
  

cc658b4c   Yarik   Big commit
95
          function mobOverlayRemove()

d8c1a2e0   Yarik   Big commit artbox
96
          {

cc658b4c   Yarik   Big commit
97
              $('.mob-overlay').remove()

d8c1a2e0   Yarik   Big commit artbox
98
          }

d8c1a2e0   Yarik   Big commit artbox
99
  

cc658b4c   Yarik   Big commit
100
          function search()

d8c1a2e0   Yarik   Big commit artbox
101
          {

cc658b4c   Yarik   Big commit
102
103
104
105
106
107
108
109
110
111
112
113
114
              $('.search-btn').click(

                  function()

                  {

  

                      $('.hidden-search').addClass('vis')

  

                  }

              );

              $('.close-search-btn').click(

                  function()

                  {

                      $('.hidden-search').removeClass('vis')

                  }

d8c1a2e0   Yarik   Big commit artbox
115
              )

d8c1a2e0   Yarik   Big commit artbox
116
117
  

          }

cc658b4c   Yarik   Big commit
118
119
  

          function phonesTab()

d8c1a2e0   Yarik   Big commit artbox
120
          {

cc658b4c   Yarik   Big commit
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
              $('.phones-table-wr').click(

                  function()

                  {

                      $(this).toggleClass('vis-phone')

                  }

              );

  

              var timerPhone;

              $('.phones-table-wr').hover(

                  function()

                  {

                      clearTimeout(timerPhone)

                  }, function()

                  {

                      timerPhone = setTimeout(

                          function()

                          {

                              $('.phones-table-wr').removeClass('vis-phone')

                          }, 320

                      )

  

                  }

              )

  

d8c1a2e0   Yarik   Big commit artbox
145
          }

d8c1a2e0   Yarik   Big commit artbox
146
  

cc658b4c   Yarik   Big commit
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
          function openMobMenu()

          {

              $('.menu_mob').click(

                  function()

                  {

                      mobOverlayAdd()

                      $('body').addClass('off-scroll')

                      $('.xs-sm-menu').addClass('open')

                      setTimeout(

                          function()

                          {

                              $('.xs-sm-menu').addClass('visible')

                          }, 10

                      )

                  }

              )

          }

d8c1a2e0   Yarik   Big commit artbox
164
  

cc658b4c   Yarik   Big commit
165
          function openSubMenuMob()

d8c1a2e0   Yarik   Big commit artbox
166
          {

cc658b4c   Yarik   Big commit
167
168
169
170
171
172
173
174
175
176
177
178
              $('.xs-sm-menu ul.main-menu li a').click(

                  function(e)

                  {

                      var checkSubMEnu = $(this).parent().find('ul')

                      if(checkSubMEnu.length > 0)

                      {

                          e.preventDefault();

                          $(this).parent().toggleClass('show-sub-menu')

                      }

                  }

              )

          }

d8c1a2e0   Yarik   Big commit artbox
179
  

cc658b4c   Yarik   Big commit
180
          function closeMobMenu()

d8c1a2e0   Yarik   Big commit artbox
181
          {

cc658b4c   Yarik   Big commit
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
209
210
211
212
213
214
215
216
217
218
              $('body').on(

                  'click', '.mob-overlay', function()

                  {

                      mobOverlayRemove()

                      if($('.xs-sm-menu').hasClass('visible'))

                      {

                          $('.xs-sm-menu').removeClass('visible')

                          setTimeout(

                              function()

                              {

                                  $('.xs-sm-menu').removeClass('open')

                              }, 200

                          )

                          $('body').removeClass('off-scroll')

                      }

                      $('.xs-sm-menu .show-sub-menu').removeClass('show-sub-menu')

  

                  }

              )

              $('.close-menu-mob').click(

                  function()

                  {

                      mobOverlayRemove()

                      $('.xs-sm-menu').removeClass('visible')

                      setTimeout(

                          function()

                          {

                              $('.xs-sm-menu').removeClass('open')

                          }, 200

                      )

                      $('body').removeClass('off-scroll')

                      $('.xs-sm-menu .show-sub-menu').removeClass('show-sub-menu')

                  }

              )

          }

  

          function homeSlider()

d8c1a2e0   Yarik   Big commit artbox
219
          {

cc658b4c   Yarik   Big commit
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
              var slideA = $('.slider-img a')

              var numA = slideA.length

  

              setInterval(

                  function()

                  {

                      var activeNumA = $('.slider-img a.active-slide').index() + 1;

  

                      if(activeNumA < numA)

                      {

                          $('.slider-img a').removeClass('active-slide')

                          $(slideA[activeNumA]).addClass('active-slide')

                      } else

                      {

                          $('.slider-img a').removeClass('active-slide')

                          $(slideA[0]).addClass('active-slide')

                      }

                  }, 4000

              )

d8c1a2e0   Yarik   Big commit artbox
239
          }

d8c1a2e0   Yarik   Big commit artbox
240
  

cc658b4c   Yarik   Big commit
241
          function hoverCatList()

d8c1a2e0   Yarik   Big commit artbox
242
          {

cc658b4c   Yarik   Big commit
243
244
245
246
247
248
249
250
251
252
              $('.cat-list-wr').hover(

                  function()

                  {

                      $(this).addClass('hover')

                  }, function()

                  {

                      $(this).removeClass('hover')

                  }

              )

          }

d8c1a2e0   Yarik   Big commit artbox
253
  

cc658b4c   Yarik   Big commit
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
          function expandAllCatList()

          {

              $('.expand_brands').click(

                  function()

                  {

                      var oldTxt = 'развернуть';

                      var newTxt = 'свернуть';

  

                      if($(this).parents('.cat-list-wr').hasClass('expand'))

                      {

                          $('.cat-list-wr').removeClass('expand');

                          $(this).find('p').html(oldTxt);

                      } else

                      {

                          $('.cat-list-wr').removeClass('expand');

                          $('.expand_brands').find('p').html(oldTxt);

                          $(this).parents('.cat-list-wr').addClass('expand');

  

                          $(this).find('p').html(newTxt);

                      }

  

                  }

              );

d8c1a2e0   Yarik   Big commit artbox
277
          }

36d1807a   Yarik   Big commit.
278
  

cc658b4c   Yarik   Big commit
279
280
281
282
283
284
285
286
287
          function removeLoadCollection()

          {

              $('.load_collection').animate(

                  {opacity : 0}, 500, function()

                  {

                      $('.load_collection').remove();

                  }

              )

          }

36d1807a   Yarik   Big commit.
288
  

cc658b4c   Yarik   Big commit
289
290
291
292
          function loadCollection()

          {

              $('body').append('<div class="load_collection"><div></div></div>');

          }

36d1807a   Yarik   Big commit.
293
  

cc658b4c   Yarik   Big commit
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
          function tabs()

          {

              var tabsLi = $('.collect-tabs ul li')

              var tabsContent = $('.tabs-content')

              tabsContent.css({display : 'none'});

              $(tabsContent[0]).css({display : 'block'});

              $(tabsLi[0]).addClass('active-tab');

              tabsLi.click(

                  function()

                  {

                      tabsLi.removeClass('active-tab');

                      $(this).addClass('active-tab');

                      var thisIndex = $(this).index();

                      tabsContent.css({display : 'none'});

                      $(tabsContent[thisIndex]).css({display : 'block'});

                  }

              )

          }

36d1807a   Yarik   Big commit.
312
  

cc658b4c   Yarik   Big commit
313
314
315
          $(document).on('pjax:send', function()

          {

              loadCollection();

36d1807a   Yarik   Big commit.
316
          });

36d1807a   Yarik   Big commit.
317
  

cc658b4c   Yarik   Big commit
318
319
320
          $(document).on('pjax:complete', function()

          {

              removeLoadCollection();

36d1807a   Yarik   Big commit.
321
          });

36d1807a   Yarik   Big commit.
322
  

cc658b4c   Yarik   Big commit
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
          $(document).on(

              'click', '.question-form', function(e)

              {

                  e.preventDefault();

                  showForm();

              }

          );

  

          $(document).on(

              'click', '.to_order', function(e)

              {

                  e.preventDefault();

                  var product_variant_id = $(this).data('id');

                  basket.add(product_variant_id);

              }

          );

  

          $(document).on(

22a7589f   Alexey Boroda   -CSS and JS fixes
341
              'click', '._more_, #close-form, #overlay', function()

cc658b4c   Yarik   Big commit
342
343
344
345
              {

                  hideForm();

              }

          );

36d1807a   Yarik   Big commit.
346
  

cc658b4c   Yarik   Big commit
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
          $(document).on(

              'submit', '#basket_form', function(e)

              {

                  e.preventDefault();

                  hideForm();

                  $.post(

                      '/order/make', $(this).serialize(), function(data)

                      {

                          basket.updateModal(data.message, false);

                          basket.init(false, true);

                          window.setTimeout(showForm, 1000);

                      }

                  );

              }

          );

  

          $(document).on(

              'click', '.form-product-wr .remove_', function()

              {

                  var product_variant_id = $(this).data('id');

                  basket.remove(product_variant_id);

98f4fd01   Yarik   Layout fix
368
369
                  var container = $(this).parents('table');

                  var scroller = $(this).parents('.form-product-wr');

cc658b4c   Yarik   Big commit
370
                  var tr = $(this).parents('tr').first().remove();

98f4fd01   Yarik   Layout fix
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
                  if($(container).find('tr').length === 1) {

                      $(scroller).removeClass('product_2');

                      $(scroller).removeClass('product_0');

                      $(scroller).addClass('product_1');

                  } else if($(container).find('tr').length === 2) {

                      $(scroller).removeClass('product_1');

                      $(scroller).removeClass('product_0');

                      $(scroller).addClass('product_2');

                  } else if($(container).find('tr').length === 0) {

                      $(scroller).removeClass('product_1');

                      $(scroller).removeClass('product_2');

                      $(scroller).addClass('product_0');

                  } else {

                      $(scroller).removeClass('product_2');

                      $(scroller).removeClass('product_1');

                      $(scroller).removeClass('product_0');

                  }

cc658b4c   Yarik   Big commit
388
389
              }

          );

d8c1a2e0   Yarik   Big commit artbox
390
      }

d8c1a2e0   Yarik   Big commit artbox
391
392
393
394
395
  );