<mySearch ⁄>
<mySnippets order="rand" ⁄>
<myContacts ⁄><email ⁄>
<windows live messenger ⁄>
<myCurriculum type="pdf" ⁄>
<myBlog show="last" ⁄>
<myNews show="rand" ⁄>
<myNews type="cat" ⁄>
<myQuote order="random" ⁄>Não penses em vencer, pensa em não ser vencido.
<myPhoto order="random" ⁄>
<myAdSense ⁄>
<myVisitorsMap ⁄>
#wide_gallery{ margin: 0 auto; border: solid 15px #900; background-color: #36393D; width: 100px; height: 100px; } .loading{background: url("loader.gif") no-repeat center center;}
/** * Automatic Cycle Gallery * * @name aCycleGallery * @version 0.1 * @author pedrocorreia.net * @return Jquery */ jQuery.fn.aCycleGallery = function(settings) { //gallery settings var _settings = jQuery.extend({ imgs: [], path: "", interval: 4000 }, settings); /** * Gets the rightmost substring, with a given length, * from a String object * * @param Int Number of chars * @return String **/ String.prototype.right = function(n) { var len = this.length; return this.substring(len - n, n) || ""; }; return this.each(function() { var _numPics = _settings.imgs.length; var $gallery = $(this), _current_item = 0, _timer = null; /** * Load the next image **/ var LoadNextImage = function() { var next_img = _current_item + 1; if (next_img >= _numPics) { next_img = 0; } _current_item = next_img; var src = _settings.imgs[next_img].img, title = _settings.imgs[next_img].title; $gallery.addClass("loading"); var img = new Image(); $(img).load(function() { var self = this; $gallery .html(this) .animate({width: this.width, height: this.height}, 500, "swing", function() { $(self).fadeIn(); $gallery.removeClass("loading"); _timer = setTimeout(function() { LoadNextImage(); }, _settings.interval); } ); }).hide().attr({ "src": src, "title": title, "alt": title }); }; //end LoadNextImage /** * If we specified a common path to all of our files, * this method will update each image url */ var FillImagesArray = function() { if (_settings.path) { //we specified a path //add slash if needed _settings.path += (_settings.path.right(1) !== "/" ? "/" : ""); for (var i = 0; i < _numPics; i++) { _settings.imgs[i].img = _settings.path + _settings.imgs[i].img; } } }; //end FillImagesArray /** * AutoRun **/ var AutoRun = (function() { if (_numPics > 0) { FillImagesArray(); LoadNextImage(); } })(); //end AutoRun }); }; //jQuery.fn.aCycleGallery
$(document).ready(function() { //images object var images = [ { img: "1.png", title: "Picture 1"}, { img: "2.jpg", title: "Picture 2" }, { img: "3.jpg", title: "Picture 3" }, { img: "4.jpg", title: "Picture 4" }, { img: "5.jpg", title: "Picture 5" } ]; //start our animation $("#wide_gallery").aCycleGallery({ imgs: images, path: "images/" }); });
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Jquery Cycle Gallery</title> <meta http-equiv="Content-type" content="text/html;charset=iso-8859-1" /> <link rel="stylesheet" href="_css/style.css" /> <script type="text/javascript" src="_lib/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="_lib/jquery.a-cyclegallery.js"></script> <script type="text/javascript" src="_lib/CycleGalleryInit.js"></script> </head> <body> <div id="wide_gallery"></div> </body> </html>