fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2012-03-13 10:23 am

[dw-free] (jquery beta) contextual hover menu fades even without user action

[commit: http://hg.dwscoalition.org/dw-free/rev/52f1f972f400]

http://bugs.dwscoalition.org/show_bug.cgi?id=4365

Stay put until the user does something, like move their mouse, at which
point dismiss after a brief period.

Patch by [personal profile] fu.

Files modified:
  • htdocs/js/jquery.ajaxtip.js
  • htdocs/js/jquery.contextualhover.js
--------------------------------------------------------------------------------
diff -r 3c01c3ea5414 -r 52f1f972f400 htdocs/js/jquery.ajaxtip.js
--- a/htdocs/js/jquery.ajaxtip.js	Tue Mar 13 08:01:14 2012 +0000
+++ b/htdocs/js/jquery.ajaxtip.js	Tue Mar 13 18:21:03 2012 +0800
@@ -1,8 +1,10 @@
 (function($) {
 $.widget("dw.ajaxtip", {
     options: {
+        namespace: undefined,
         content: undefined,
-        tooltip: { dynamic: true }
+        tooltip: { dynamic: true },
+        persist: false
     },
     _namespace: function() {
         return this.options.namespace ? "."+this.options.namespace : "";
@@ -14,6 +16,10 @@
         var tipcontainer = $("<div class='ajaxtooltip ajaxtip' style='display: none'></div>")
                         .click(function(e) {e.stopPropagation()})
 
+        if ( self.options.persist ) {
+            $(self.element).attr("type", "persistent")
+        }
+
         self.element
             .after(tipcontainer)
             .bind("ajaxresult"+ns, function(e) {
@@ -25,9 +31,12 @@
                 predelay: 0,
                 delay: 1500,
                 events: {
-                    def: "ajaxstart"+ns+", tooltipout"+ns+" ajaxresult"+ns,
-                    widget: "ajaxstart"+ns+",ajaxresult"+ns,
-                    tooltip: "mouseover,mouseleave"
+                    // just fade away after a preset period
+                    def       : "ajaxstart"+ns+", tooltipout"+ns+" ajaxresult"+ns,
+                    // persist until the user takes some action (including moving the mouse away from trigger)
+                    persistent: "ajaxstart"+ns+", tooltipout"+ns+" mouseout"+ns,
+                    widget    : "ajaxstart"+ns+", ajaxresult"+ns,
+                    tooltip   : "mouseover,mouseleave"
                 },
                 relative: true,
                 effect: "fade",
diff -r 3c01c3ea5414 -r 52f1f972f400 htdocs/js/jquery.contextualhover.js
--- a/htdocs/js/jquery.contextualhover.js	Tue Mar 13 08:01:14 2012 +0000
+++ b/htdocs/js/jquery.contextualhover.js	Tue Mar 13 18:21:03 2012 +0800
@@ -78,7 +78,7 @@
             return;
         }
 
-        trigger.ajaxtip({ namespace: "contextualpopup"})
+        trigger.ajaxtip({ namespace: "contextualpopup", persist: true })
             .ajaxtip( "load", {
                 endpoint: "ctxpopup",
                 formmethod: "GET",
--------------------------------------------------------------------------------