Assalamualaikum wr, wb
Abis nyobain bikin plugin jQuery….
Silahkan diicip http://agoesdoubleb.i-bego.com/arsip/ag … index.html
Di beri nama Agoes-ContentRotator v.01
// JavaScript Document
(function($){
$.fn.agoesCRotator = function(options){
var s = {
auto : false
, control : true
, speed : 500
, next_text : "Next"
, pref_text : "Prev"
, next_image : ""
, pref_image : ""
, next_class : "aCRnext"
, prev_class : "aCRprev"
, control_class : "aCRcontrol"
, width : 600
, height : 200
, current : 1
};
s = $.extend(options, s);
var current = 1;
return this.each(function(){
var $this = $(this);
var $kids = $this.children();
var l = $kids.length;
$this.wrap("<div class='aCRcontainer'></div>");
$this.parent().css({
"posision" : "relative"
, "width" : s.width
, "min-height" : s.height
, "overflow-x" : "hidden"
, "overflow-y" : "auto"
});
$this.addClass("aCRgerak");
$this.css({
"posision" : "relative"
, "width" : "9000px"
, "height" : s.height
, "padding" : "0px"
, "left" : "0px"
});
$this.children().css({
"posision" : "relative"
, "width" : s.width
, "height" : s.height
, "overflow" : "hidden"
, "float" : "left"
, "border" : "none"
});
if(s.control){
$this.parent().append("<div class='aCRcontrolContainer'></div>");
$this.parent().find(".aCRcontrolContainer").css({
"height" : "20px"
, "padding-left" : "50px"
});
$kids.each(function(i){
$this.parent().find(".aCRcontrolContainer").append(
"<a id='aCRcontrol"+i+"' href='#' class='"+s.control_class+"'>"+(i+1)+"</a>"
);
var $a = $this.parent().find(".aCRcontrolContainer").find("a#aCRcontrol"+i);
$a.click(function(){
$this.stop();
geser_obj(i+1);
});
}
);
};
function geser_obj(i){
var pantul = 100;
var jauh = 80;
var selisih = (i<s.current)?s.current-i : i- s.current;
if(i<s.current){
$this.animate({
"left" : "+=" + ((s.width * (selisih)) + (selisih*pantul))
}, s.speed).animate({"left":"-="+(selisih*pantul)}, (selisih*jauh));
s.current = i;
}else if(i>s.current){
$this.animate({
"left" : "-=" + ((s.width * (selisih)) + (selisih*pantul))
}, s.speed).animate({"left":"+="+(selisih*pantul)}, (selisih*jauh));
s.current = i;
}
$this.parent().find(".aCRcontrolContainer").find("a").removeClass("controlSelect");
$this.parent().find(".aCRcontrolContainer").find("a#aCRcontrol"+(i-1)).addClass("controlSelect");
};
}
);
};
})(jQuery);
Cara Pakai, siapkan sebuah div sebagai container dan di dalamnya diletakkan div lain yang akan menjadi isinya
<div id="content">
<div style="width:600px; height:300px; ">
<img src="images/Chrysanthemum.jpg" align="left" width="200" />
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div style="width:600px; height:300px; ">
<img src="images/Desert.jpg" align="left" width="200" />
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div style="width:600px; height:300px; ">
<img src="images/Hydrangeas.jpg" align="left" width="200" />
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div style="width:600px; height:300px; ">
<img src="images/Jellyfish.jpg" align="left" width="200" />
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div style="width:600px; height:300px; ">
<img src="images/Koala.jpg" align="left" width="200" />
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</div>
Untuk Pemanggilan fungsi dapat dilakukan dengan melakukan seleksi pada objek div yang menjadi container
<script>
$(function(){
$("div#content").agoesCRotator();
}
);
</script>
Masih sekedar coba2 yang ingin mengembangkan bersama
Silahkan…
Terima kasih Wassalam… 