Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery.fn.extend({
- ps_header_captions: function ( options ) {
- var defaults = {
- container : '.ps-header-captions',
- caption_tag : 'span',
- start_caption : 1,
- delay : 5000,
- speed : 'slow'
- };
- var settings = $.extend( {}, defaults, options );
- var _arr_captions = [];
- var _prev_index = settings.start_caption - 1;
- var _this = $(settings.container);
- var _captions = _this.find(settings.caption_tag);
- var _num_captions = _captions.length;
- // loop through captions and hide
- // --
- _captions.each(function() {
- _arr_captions.push($(this));
- $(this).hide();
- });
- _this.css('display', 'inline-block');
- _arr_captions[0].fadeIn(settings.speed);
- // set timeout
- // --
- setInterval(function(){
- _arr_captions[_prev_index].hide();
- _arr_captions[settings.start_caption].fadeIn();
- _prev_index = settings.start_caption;
- settings.start_caption = (settings.start_caption + 1) % _num_captions;
- }, settings.delay);
- return;
- }
- });
- $('.ps-header-captions').ps_header_captions({
- delay: 5000,
- caption_tag: 'span',
- speed: 'slow'
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement