From 7f94811e098295566c54adbeb81e658230590f28 Mon Sep 17 00:00:00 2001 From: Jason Johnston Date: Sat, 12 May 2012 09:23:26 -0600 Subject: [PATCH] Add support for -pie-track-hover property to allow disabling of automatic :hover tracking --- sources/Element.js | 10 ++++-- tests/track-hover_track-active.html | 55 +++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 tests/track-hover_track-active.html diff --git a/sources/Element.js b/sources/Element.js index 0c3361a..648745e 100644 --- a/sources/Element.js +++ b/sources/Element.js @@ -5,6 +5,7 @@ PIE.Element = (function() { lazyInitCssProp = PIE.CSS_PREFIX + 'lazy-init', pollCssProp = PIE.CSS_PREFIX + 'poll', trackActiveCssProp = PIE.CSS_PREFIX + 'track-active', + trackHoverCssProp = PIE.CSS_PREFIX + 'track-hover', hoverClass = PIE.CLASS_PREFIX + 'hover', activeClass = PIE.CLASS_PREFIX + 'active', focusClass = PIE.CLASS_PREFIX + 'focus', @@ -78,6 +79,7 @@ PIE.Element = (function() { cs = el.currentStyle, lazy = cs.getAttribute( lazyInitCssProp ) === 'true', trackActive = cs.getAttribute( trackActiveCssProp ) !== 'false', + trackHover = cs.getAttribute( trackHoverCssProp ) !== 'false', childRenderers; // Polling for size/position changes: default to on in IE8, off otherwise, overridable by -pie-poll @@ -180,8 +182,12 @@ PIE.Element = (function() { } addListener( el, 'onresize', handleMoveOrResize ); addListener( el, 'onpropertychange', propChanged ); - addListener( el, 'onmouseenter', mouseEntered ); - addListener( el, 'onmouseleave', mouseLeft ); + if( trackHover ) { + addListener( el, 'onmouseenter', mouseEntered ); + } + if( trackHover || trackActive ) { + addListener( el, 'onmouseleave', mouseLeft ); + } if( trackActive ) { addListener( el, 'onmousedown', mousePressed ); } diff --git a/tests/track-hover_track-active.html b/tests/track-hover_track-active.html new file mode 100644 index 0000000..ddd7523 --- /dev/null +++ b/tests/track-hover_track-active.html @@ -0,0 +1,55 @@ + + + + + -pie-png-fix test + + + + + +
+ -pie-track-hover: true; +
+
+ -pie-track-hover: false; +
+ +
+ -pie-track-active: true; +
+
+ -pie-track-active: false; +
+ + + \ No newline at end of file