Blame view

frontend/web/js/firstSlider.js 2.25 KB
eb56e5f2   Administrator   first commit
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
57
58
59
60
61
62
63
64
65
66
  $(document).ready(function(){

      firstSlider();

      function firstSlider() {

          var set_time = 8000;

  

          function line_animation() {

              $('.slide-ul li.active_n .time-bloks-line').animate({width:'100%'}, set_time, function() {

                  $(this).css({width:0});

              });

          }

  

          line_animation();

  

          function for_interval() {

              var slide_active =  $('.slide-ul').find('li.active_n');

              slide_active.removeClass('active_n');

              slide_active.next().addClass('active_n');

              var lengs = $('.slide-ul li').index($('li.active_n'));

  

              if (lengs == -1){

                  $('.slide-ul li:first-child').addClass('active_n')

              }

              var img_bg = $('.slide-ul li.active_n').find('img');

              img_bg = img_bg.attr('src').split('/');

              img_bg = img_bg[img_bg.length - 1];

              if (device.mobile() || device.tablet()){

  

                  $('.slider-bg').attr('style', 'background-image: url("images/slider/big-' + img_bg + '")');

              } else  {

                  $('.slider-bg').attr('style', 'background-image: url("images/slider/big-' + img_bg + '")');

              }

  

  

              line_animation();

  

          }

          var stop_interval = setInterval(function(){

              for_interval()

          },set_time);

  

          $('.slide-ul li').click(function(){

              $('.slide-ul li.active_n .time-bloks-line').stop().css({width:0});

              $('.slide-ul li').removeClass('active_n');

              $(this).addClass('active_n');

              var img_bg = $('.slide-ul li.active_n').find('img');

              img_bg = img_bg.attr('src').split('/');

              img_bg = img_bg[img_bg.length - 1];

              if (device.mobile() || device.tablet()){

  

                  $('.slider-bg').attr('style', 'background-image: url("images/slider/big-' + img_bg + '")');

              } else  {

                  $('.slider-bg').attr('style', 'background-image: url("images/slider/big-' + img_bg + '")');

              }

              clearInterval(stop_interval);

              stop_interval = setInterval(function(){

                  for_interval()

              },set_time);

  

              line_animation();

          });

      }

  });