fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-06-17 07:52 am

[dw-free] Parts of the contextual hover menu may spill over the edge of the screen

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

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

Recalculate the hover menu's position every time its displayed or redrawn.

Patch by [personal profile] fu.

Files modified:
  • htdocs/js/jquery.ajaxtip.js
  • htdocs/js/jquery.contextualhover.js
--------------------------------------------------------------------------------
diff -r 534cacaf25cf -r d37771f3da27 htdocs/js/jquery.ajaxtip.js
--- a/htdocs/js/jquery.ajaxtip.js	Fri Jun 17 15:47:05 2011 +0800
+++ b/htdocs/js/jquery.ajaxtip.js	Fri Jun 17 15:52:46 2011 +0800
@@ -44,7 +44,10 @@
                     }
 
                     tip.css({position: "absolute", top: "", left: ""})
-                        .position({ my: "left top", at: "left bottom", of: self.element, collision: "fit"})
+                    self._reposition( tip );
+                },
+                onShow: function(e) {
+                    self._reposition( this.getTip() );
                 }
             },  self.options.tooltip));
     },
@@ -52,6 +55,9 @@
         if(this.options.content)
             this.element.data("tooltip").show()
     },
+    _reposition: function( tip ) {
+        tip.position({ my: "left top", at: "left bottom", of: this.element, collision: "fit"})
+    },
     _endpointurl : function( action ) {
         // if we are on a journal subdomain then our url will be
         // /journalname/__rpc_action instead of /__rpc_action
@@ -91,7 +97,10 @@
             dataType: "json",
             complete: function() {
                 var tip = self.element.data("tooltip");
-                if ( tip ) tip.inprogress = false;
+                if ( tip ) {
+                    tip.inprogress = false;
+                    self._reposition( tip.getTip() );
+                }
             },
             success: opts.success,
             error: opts.error ? opts.error : function( jqxhr, status, error ) {
diff -r 534cacaf25cf -r d37771f3da27 htdocs/js/jquery.contextualhover.js
--- a/htdocs/js/jquery.contextualhover.js	Fri Jun 17 15:47:05 2011 +0800
+++ b/htdocs/js/jquery.contextualhover.js	Fri Jun 17 15:52:46 2011 +0800
@@ -122,8 +122,6 @@
         this.element.ajaxtip("cancel");
     }
 
-    this.element.ajaxtip("show")
-
     var $inner = $("<div class='Inner'></div>");
     var $content = $("<div class='Content'></div>");
 
@@ -319,10 +317,11 @@
 
     $content.append($("<div class='ljclear'>&nbsp;</div>"));
 
+    this.element.ajaxtip("show")
     this.element
         .ajaxtip("widget")
             .removeClass("ajaxresult ajaxtooltip").addClass("ContextualPopup")
-            .empty().append($inner)
+            .empty().append($inner);
 },
 
 _changeRelation: function(info, action, link, e) {
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org