openstackweb/themes/openstack/javascript/jquery.ticker.js
2014-10-31 16:21:41 -03:00

48 lines
947 B
JavaScript

/* List Ticker by Alex Fish
// www.alexefish.com
//
// options:
//
// effect: fade/slide
// speed: milliseconds
*/
(function($){
$.fn.list_ticker = function(options){
var defaults = {
speed:4000,
effect:'slide'
};
var options = $.extend(defaults, options);
return this.each(function(){
var obj = $(this);
var list = obj.children();
list.not(':first').hide();
setInterval(function(){
list = obj.children();
list.not(':first').hide();
var first_li = list.eq(0)
var second_li = list.eq(1)
if(options.effect == 'slide'){
first_li.slideUp();
second_li.slideDown(function(){
first_li.remove().appendTo(obj);
});
} else if(options.effect == 'fade'){
first_li.fadeOut(function(){
second_li.fadeIn();
first_li.remove().appendTo(obj);
});
}
}, options.speed)
});
};
})(jQuery);