User:Shizhen Wang/self.js

From OpenWetWare

Jump to: navigation, search

Note - After saving, you may have to bypass your browser's cache to see the changes. Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh); Konqueror: click Reload or press F5; Opera: clear the cache in Tools → Preferences; Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

/*photos.js*****************/
 
jQuery(function($){
		    if ($(".photos").length > 0) {
		        var defaultOpts = { interval: 5000, fadeInTime: 300, fadeOutTime: 200 };
		        var _bodies = $("ul.photos li");
		        var _count = _bodies.length;
		        var _current = 0;
		        var _intervalID = null;
		        var stop = function () { window.clearInterval(_intervalID); };
		        var slide = function (opts) {
		            if (opts) {
		                _current = opts.current || 0;
		            } else {
		                _current = (_current >= (_count - 1)) ? 0 : (++_current);
		            };
		            _bodies.filter(":visible").fadeOut(defaultOpts.fadeOutTime, function () {
		                _bodies.eq(_current).fadeIn(defaultOpts.fadeInTime);
		                _bodies.removeClass("curr").eq(_current).addClass("curr");
		            });
		        };
		        var go = function () {
		            stop();
		            _intervalID = window.setInterval(function () { slide(); }, defaultOpts.interval);
		        };
		         _bodies.hover(stop, go);
		        go();
		    }
});
Personal tools