jquery.opacityrollover.js 920 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * jQuery Opacity Rollover plugin
  3. *
  4. * Copyright (c) 2009 Trent Foley (http://trentacular.com)
  5. * Licensed under the MIT License:
  6. * http://www.opensource.org/licenses/mit-license.php
  7. */
  8. ;(function($) {
  9. var defaults = {
  10. mouseOutOpacity: 0.67,
  11. mouseOverOpacity: 1.0,
  12. fadeSpeed: 'fast',
  13. exemptionSelector: '.selected'
  14. };
  15. $.fn.opacityrollover = function(settings) {
  16. // Initialize the effect
  17. $.extend(this, defaults, settings);
  18. var config = this;
  19. function fadeTo(element, opacity) {
  20. var $target = $(element);
  21. if (config.exemptionSelector)
  22. $target = $target.not(config.exemptionSelector);
  23. $target.fadeTo(config.fadeSpeed, opacity);
  24. }
  25. this.css('opacity', this.mouseOutOpacity)
  26. .hover(
  27. function () {
  28. fadeTo(this, config.mouseOverOpacity);
  29. },
  30. function () {
  31. fadeTo(this, config.mouseOutOpacity);
  32. });
  33. return this;
  34. };
  35. })(jQuery);