Permalink
Browse files

Make -pie-watch-ancestors track :hover changes

  • Loading branch information...
1 parent d5ccdd6 commit 57bb3f130f2c33fbe8f3fbad967506306865b110 Jason Johnston committed Jun 7, 2010
Showing with 9 additions and 3 deletions.
  1. +8 −2 sources/event_handlers.js
  2. +1 −1 sources/htc_open.txt
View
@@ -63,15 +63,17 @@ function propChanged() {
* hover styles to non-link elements.
*/
function mouseEntered() {
- element.className += ' ' + PIE.CLASS_PREFIX + 'hover';
+ var el = event.srcElement;
+ el.className += ' ' + PIE.CLASS_PREFIX + 'hover';
//must delay this because the mouseleave event fires before the :hover styles are added.
setTimeout( propChanged, 0 );
}
/**
* Handle mouseleave events
*/
function mouseLeft() {
- element.className = element.className.replace( new RegExp( '\\b' + PIE.CLASS_PREFIX + 'hover\\b', 'g' ), '' );
+ var el = event.srcElement;
+ el.className = el.className.replace( new RegExp( '\\b' + PIE.CLASS_PREFIX + 'hover\\b', 'g' ), '' );
//must delay this because the mouseleave event fires before the :hover styles are removed.
setTimeout( propChanged, 0 );
}
@@ -110,6 +112,8 @@ function cleanup() {
if( ancestors ) {
for( i = 0, len = ancestors.length; i < len; i++ ) {
ancestors[i].detachEvent( 'onpropertychange', ancestorPropChanged );
+ ancestors[i].detachEvent( 'onmouseenter', mouseEntered );
+ ancestors[i].detachEvent( 'onmouseleave', mouseLeft );
}
ancestors = null;
}
@@ -133,6 +137,8 @@ function initAncestorPropChangeListeners() {
while( a && ( watch === 'NaN' || i++ < watch ) ) {
ancestors.push( a );
a.attachEvent( 'onpropertychange', ancestorPropChanged );
+ a.attachEvent( 'onmouseenter', mouseEntered );
+ a.attachEvent( 'onmouseleave', mouseLeft );
a = a.parentNode;
}
}
View
@@ -9,7 +9,7 @@ Licensed for use under the Apache License, Version 2.0
<PUBLIC:ATTACH EVENT="onmove" FOR="element" ONEVENT="update()" />
<PUBLIC:ATTACH EVENT="onpropertychange" FOR="element" ONEVENT="propChanged()" />
<PUBLIC:ATTACH EVENT="onmouseenter" FOR="element" ONEVENT="mouseEntered()" />
- <PUBLIC:ATTACH EVENT="onmouseout" FOR="element" ONEVENT="mouseLeft()" />
+ <PUBLIC:ATTACH EVENT="onmouseleave" FOR="element" ONEVENT="mouseLeft()" />
<PUBLIC:ATTACH EVENT="oncontentready" FOR="element" ONEVENT="init()" />
<PUBLIC:ATTACH EVENT="ondetach" FOR="element" ONEVENT="cleanup()" />

0 comments on commit 57bb3f1

Please sign in to comment.