Advertisement
Guest User

Untitled

a guest
Jun 27th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. jQuery.fn.extend({
  2. ps_header_captions: function ( options ) {
  3.  
  4. var defaults = {
  5. container : '.ps-header-captions',
  6. caption_tag : 'span',
  7. start_caption : 1,
  8. delay : 5000,
  9. speed : 'slow'
  10. };
  11.  
  12. var settings = $.extend( {}, defaults, options );
  13.  
  14. var _arr_captions = [];
  15. var _prev_index = settings.start_caption - 1;
  16. var _this = $(settings.container);
  17. var _captions = _this.find(settings.caption_tag);
  18. var _num_captions = _captions.length;
  19.  
  20. // loop through captions and hide
  21. // --
  22. _captions.each(function() {
  23. _arr_captions.push($(this));
  24. $(this).hide();
  25. });
  26. _this.css('display', 'inline-block');
  27. _arr_captions[0].fadeIn(settings.speed);
  28.  
  29. // set timeout
  30. // --
  31. setInterval(function(){
  32. _arr_captions[_prev_index].hide();
  33. _arr_captions[settings.start_caption].fadeIn();
  34. _prev_index = settings.start_caption;
  35. settings.start_caption = (settings.start_caption + 1) % _num_captions;
  36. }, settings.delay);
  37.  
  38. return;
  39. }
  40.  
  41. });
  42.  
  43. $('.ps-header-captions').ps_header_captions({
  44. delay: 5000,
  45. caption_tag: 'span',
  46. speed: 'slow'
  47. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement