You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/09/24 12:12:53 UTC

svn commit: r1000792 - /myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js

Author: lofwyr
Date: Fri Sep 24 10:12:52 2010
New Revision: 1000792

URL: http://svn.apache.org/viewvc?rev=1000792&view=rev
Log:
TOBAGO-832
 - fix menu position at the edge of the window

Modified:
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js?rev=1000792&r1=1000791&r2=1000792&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js Fri Sep 24 10:12:52 2010
@@ -129,15 +129,26 @@ function xxx_tobagoMenuOpen(event) {
   // open sub menu
   if (sub.size() > 0) {
     // compute position
+    // XXX Todo: "compute position" is not perfect! Should be enhanced, especially for sub menus.
+    // XXX The problem is, when the menu opens at the edge of the visual window.
+    var left;
+    var top;
     if (li.hasClass('tobago-menu-markup-top')) {
       // is top menu
-      sub.css('left', li.offset().left);
-      sub.css('top', li.offset().top + li.outerHeight());
+      left = li.offset().left;
+      top = li.offset().top + li.outerHeight();
+      // fix menu position, when it is outside of the current page
+      var page = jQuery(".tobago-page-content:first");
+      left = Math.max(0, Math.min(left, page.outerWidth() - sub.outerWidth()));
+      top = Math.max(0, Math.min(top, page.outerHeight() - sub.outerHeight()));
     } else {
       // is sub menu
-      sub.css('left', li.position().left + li.outerWidth());
-      sub.css('top', li.position().top - 1); // 1 = border-top
+      left = li.position().left + li.outerWidth();
+      top = li.position().top - 1; // 1 = border-top
+      // XXX todo: fix sub menu position, when it is outside of the page
     }
+    sub.css('left', left);
+    sub.css('top', top);
 
     // show
     sub.css('visibility', 'visible');