[extensions-web] Update version of tipsy to my fork, which correctly handles center tips



commit c80ea64e1428fcaba38cd2a2d04d876edf4865f7
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Dec 12 17:34:44 2011 -0500

    Update version of tipsy to my fork, which correctly handles center tips

 sweettooth/static/js/jquery.tipsy.js |   33 +++++++++++++++++++++++++++++++--
 1 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/sweettooth/static/js/jquery.tipsy.js b/sweettooth/static/js/jquery.tipsy.js
index 89112b6..ef4fcbf 100644
--- a/sweettooth/static/js/jquery.tipsy.js
+++ b/sweettooth/static/js/jquery.tipsy.js
@@ -145,8 +145,33 @@
             return tipsy;
         }
         
-        function enter() {
+        // When we have center gravity, we don't want to show/hide
+        // the tip when the user hovers over it. Detect whether
+        // the user moved from the element to the tip (on mouseleave)
+        // or whether/ the user moved from the tip to the element (on
+        // mouseenter).
+        function centerGravityMagic(e, tipsy) {
+            if (options.gravity !== 'c')
+                return false;
+
+            if (e.relatedTarget === null)
+                return false;
+
+            if (e.relatedTarget === tipsy.tip()[0])
+                return true;
+
+            if (tipsy.tip().has(e.relatedTarget).length)
+                return true;
+
+            return false;
+        }
+
+        function enter(e) {
             var tipsy = get(this);
+
+            if (centerGravityMagic(e, tipsy))
+                return false;
+
             tipsy.hoverState = 'in';
             if (options.delayIn == 0) {
                 tipsy.show();
@@ -156,8 +181,12 @@
             }
         };
         
-        function leave() {
+        function leave(e) {
             var tipsy = get(this);
+
+            if (centerGravityMagic(e, tipsy))
+                return false;
+
             tipsy.hoverState = 'out';
             if (options.delayOut == 0) {
                 tipsy.hide();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]