Subversion Repositories SmartDukaan

Rev

Rev 1048 | Go to most recent revision | Details | Compare with Previous | 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
     // 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
          }
4127 rajveer 25
          $('li:first',this).css("color","#333333");
26
          $('li:first',this).css("font-weight","bold");
458 rajveer 27
     });
28
 
29
     $('.slider ul li').click(function(){ 
30
          //alert($(this).index()); 
31
          $('li',this.parentNode).css("color","#0066CC");
4127 rajveer 32
          $('li',this.parentNode).css("font-weight","normal");
33
          $(this).css("color","#333333");
34
          $(this).css("font-weight","bold");
458 rajveer 35
     });
36
 
37
     $(".slider .next").click(function(){
38
          //Remove the exist selector
39
          //Set the width to the widest of either
1048 chandransh 40
          var $div =$('div',this.parentNode);
41
          var maxoffset = $('li:last',$div).width()+$('li:last',$div).offset().left - $('li:first',$div).offset().left - $div.width();
42
          var offset = Math.abs(parseInt( $('ul',$div).css('marginLeft') ));
43
          var diff = $div.width();
458 rajveer 44
 
1048 chandransh 45
          if( offset >= maxoffset ){
46
        	 return;
47
          }else if( offset + diff >= maxoffset ){
458 rajveer 48
               diff = maxoffset - offset + 20;
49
               // Hide this
50
               $(this).css('visibility','hidden');
51
          }
52
          // enable the other
53
          $('.prev', this.parentNode).css('visibility','visible');         
54
 
55
          $("ul", $(this).parent() ).animate({
56
               marginLeft: "-=" + diff
57
          },400, 'swing');
58
     });
59
 
60
     $(".slider .prev").click(function(){
61
          var offset = Math.abs(parseInt( $('ul',this.parentNode).css('marginLeft') ));
62
          var diff = $('div',this.parentNode).width();
63
          if( offset <= 0 )
64
               return;
65
          else if ( offset - diff <= 0 ){
66
               $(this).css('visibility','hidden');          
67
               diff = offset;
68
          }
69
          $('.next', this.parentNode).css('visibility','visible');
70
 
71
          $("ul",$(this).parent()).animate({
72
               marginLeft: '+='+diff
73
          },400, 'swing');
74
     });
75
});