Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
458 rajveer 1
$(document).ready(function(){
2
 
3
	$(".vt").click( function(){
4
        $('.slider').each(function(){
5
             if($('li:last',this).width()+$('li:last',this).offset().left-$('li:first',this).offset().left<$('div',this).width()){
6
                  // enable the buttons
7
                  $('button',this).css('display','inline');
8
                  $('button.next',this).css('visibility','hidden');
9
             }
10
        });
11
    });
12
 
13
 
14
     // Enable or leave the keys
15
     $('.slider').each(function(){
16
          if($('li:last',this).width()+$('li:last',this).offset().left-$('li:first',this).offset().left>$('div',this).width()){
17
               // enable the buttons
18
               $('button',this).css('display','inline');
19
               $('button.prev',this).css('visibility','hidden');
20
          }
21
          if($('li:last',this).width()+$('li:last',this).offset().left-$('li:first',this).offset().left<$('div',this).width()){
22
               // enable the buttons
23
               $('button',this).css('display','inline');
24
               $('button.next',this).css('visibility','hidden');
25
          }
475 binay 26
          $('li:first',this).css("color","#999");
458 rajveer 27
     });
28
 
29
     $('.slider ul li').click(function(){ 
30
          //alert($(this).index()); 
31
          $('li',this.parentNode).css("color","#0066CC");
32
          $(this).css("color","#999");
33
     });
34
 
35
     $(".slider .next").click(function(){
36
          //Remove the exist selector
37
          //Set the width to the widest of either
38
          var $div =$('div',this.parentNode)
39
          ,maxoffset = $('li:last',$div).width()+$('li:last',$div).offset().left - $('li:first',$div).offset().left - $div.width()
40
          ,offset = Math.abs(parseInt( $('ul',$div).css('marginLeft') ))
41
          ,diff = $div.width();
42
 
43
          if( offset >= maxoffset )
44
               return;
45
          else if ( offset + diff >= maxoffset ){
46
               diff = maxoffset - offset + 20;
47
               // Hide this
48
               $(this).css('visibility','hidden');
49
          }
50
          // enable the other
51
          $('.prev', this.parentNode).css('visibility','visible');         
52
 
53
          $("ul", $(this).parent() ).animate({
54
               marginLeft: "-=" + diff
55
          },400, 'swing');
56
     });
57
 
58
     $(".slider .prev").click(function(){
59
          var offset = Math.abs(parseInt( $('ul',this.parentNode).css('marginLeft') ));
60
          var diff = $('div',this.parentNode).width();
61
          if( offset <= 0 )
62
               return;
63
          else if ( offset - diff <= 0 ){
64
               $(this).css('visibility','hidden');          
65
               diff = offset;
66
          }
67
          $('.next', this.parentNode).css('visibility','visible');
68
 
69
          $("ul",$(this).parent()).animate({
70
               marginLeft: '+='+diff
71
          },400, 'swing');
72
     });
73
});