Created
August 22, 2010 09:51
-
-
Save arian/543599 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cleaned up version of Elements.MultiHighlight.js - http://github.com/subhaze/mootools-elements-multihighlight/blob/master/Source/Elements.MultiHighlight.js | |
/* | |
- No need for the this.each | |
- mouseoverVals and mouseoutVals are no object values of another object anymore (better minification) | |
- Set the mouseoverVals and mouseoutVals in the mouseenter event (the properties might change after the first call) | |
if (backgroundColor || foregroundColor){ ... to if (!backgroundColor && !foregroundColor) return this; | |
- applied MooTools coding style | |
*/ | |
/* | |
--- | |
name: Elements.multiHighlight | |
description: | |
license: MIT-style | |
requires: | |
- Core/Elements | |
- Core/Fx.Morph | |
provides: Elements.multiHighlight | |
authors: [Michael Russell] | |
... | |
*/ | |
Elements.implement({ | |
multiHighlight: function(backgroundColor, foregroundColor, morphProps){ | |
var mouseoverVals = {}, mouseoutVals = {}; | |
if (!backgroundColor && !foregroundColor) return this; | |
if (morphProps) this.set('morph', morphProps); | |
this.addEvents({ | |
'mouseenter': function(e){ | |
if (backgroundColor){ | |
mouseoutVals['background-color'] = elem.getStyle('background-color') != 'transparent' ? | |
elem.getStyle('background-color') : '#fff'; | |
mouseoverVals['background-color'] = backgroundColor; | |
} | |
if (foregroundColor){ | |
mouseoutVals['color'] = elem.getStyle('color'); | |
mouseoverVals['color'] = foregroundColor; | |
} | |
e.target.morph(mouseoverVals); | |
}, | |
'mouseleave': function(e){ | |
e.target.morph(mouseoutVals); | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment