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