Advertisement
Guest User

Untitled

a guest
Jun 11th, 2010
613
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * FeatureList - simple and easy creation of an interactive "Featured Items" widget
  3.  * Examples and documentation at: http://jqueryglobe.com/article/feature_list/
  4.  * Version: 1.0.0 (01/09/2009)
  5.  * Copyright (c) 2009 jQueryGlobe
  6.  * Licensed under the MIT License: http://en.wikipedia.org/wiki/MIT_License
  7.  * Requires: jQuery v1.3+
  8. */
  9. ;(function(jQuery) {
  10.     jQuery.fn.featureList = function(options) {
  11.         var tabs    = jQuery(this);
  12.         var output  = jQuery(options.output);
  13.  
  14.         new jQuery.featureList(tabs, output, options);
  15.  
  16.         return this;   
  17.     };
  18.  
  19.     jQuery.featureList = function(tabs, output, options) {
  20.         function slide(nr) {
  21.             if (typeof nr == "undefined") {
  22.                 nr = visible_item + 1;
  23.                 nr = nr >= total_items ? 0 : nr;
  24.             }
  25.  
  26.             tabs.removeClass('current').filter(":eq(" + nr + ")").addClass('current');
  27.  
  28.             output.stop(true, true).filter(":visible").fadeOut();
  29.             output.filter(":eq(" + nr + ")").fadeIn(function() {
  30.                 visible_item = nr; 
  31.             });
  32.         }
  33.  
  34.         var options         = options || {};
  35.         var total_items     = tabs.length;
  36.         var visible_item    = options.start_item || 0;
  37.  
  38.         options.pause_on_hover      = options.pause_on_hover        || true;
  39.         options.transition_interval = options.transition_interval   || 2000;
  40.  
  41.         output.hide().eq( visible_item ).show();
  42.         tabs.eq( visible_item ).addClass('current');
  43.  
  44.         tabs.mouseenter(function() {
  45.             if (jQuery(this).hasClass('current')) {
  46.                 return false;  
  47.             }
  48.  
  49.             slide( tabs.index( this) );
  50.         });
  51.  
  52.         if (options.transition_interval > 0) {
  53.             var timer = setInterval(function () {
  54.                 slide();
  55.             }, options.transition_interval);
  56.  
  57.             if (options.pause_on_hover) {
  58.                 tabs.mouseenter(function() {
  59.                     clearInterval( timer );
  60.  
  61.                 }).mouseleave(function() {
  62.                     clearInterval( timer );
  63.                     timer = setInterval(function () {
  64.                         slide();
  65.                     }, options.transition_interval);
  66.                 });
  67.             }
  68.         }
  69.     };
  70. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement