Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

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