[richfaces-svn-commits] JBoss Rich Faces SVN: r242 - trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue Apr 3 07:51:35 EDT 2007


Author: a.izobov
Date: 2007-04-03 07:51:34 -0400 (Tue, 03 Apr 2007)
New Revision: 242

Modified:
   trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
Log:
changing in positioning menuGroup

Modified: trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
===================================================================
--- trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js	2007-04-03 10:26:40 UTC (rev 241)
+++ trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js	2007-04-03 11:51:34 UTC (rev 242)
@@ -470,9 +470,48 @@
     var left = screenOffset[0] + scrolls.left;
     var right = left + dim.width;
     var layerdim = Element.getDimensions(this.layer);
+
+	var options = Exadel.Menu.Layers.layers[this.layer.id].options;
+	var dir = 0;
+	if (options.direction) {
+		dir = options.direction.toUpperCase().indexOf('LEFT')!=-1?1:dir;
+		dir = options.direction.toUpperCase().indexOf('RIGHT')!=-1?2:dir;
+	}
+	
     var layerLeft = right;
+    var layerTop = top;
+	
+    if (dir == 0) {
+	    if (layerLeft + layerdim.width >= windowWidth) {
+	        var invisibleRight = layerLeft + layerdim.width - windowWidth;
+	        layerLeft = left - layerdim.width;
+	    }
+	
+	    if (layerLeft < 0) {
+	        if (Math.abs(layerLeft) > invisibleRight) {
+	        	layerLeft = right;
+	        }
+	    }
+	    
+	    if (layerTop + layerdim.height >= windowHeight) {
+	    	var invisibleBottom = layerTop + layerdim.height - windowHeight;
+	    	var items = this.layer.firstChild.childNodes;
+	    	if (items.length > 0) {
+	    		var lastItem = items[items.length-1];
+    		    var layerOffset = Position.cumulativeOffset(this.layer);
+		   		var itemOffset = Position.cumulativeOffset(lastItem);
+			    layerTop = top -(itemOffset[1]-layerOffset[1]);
+			    if (layerTop < 0) {
+			    	if (Math.abs(layerTop) > invisibleBottom) layerTop = top;
+			    }
+	    	}
+	    	
+	    }
+    } else if (dir == 1) {
+        layerLeft = left - layerdim.width;
+    }
 
-    if (layerLeft + layerdim.width >= windowWidth) {
+/*    if (layerLeft + layerdim.width >= windowWidth) {
         layerLeft = left - layerdim.width + Exadel.Menu.Layers.shadowWidth;
     }
 
@@ -499,10 +538,10 @@
     
     if (layertop < 0) {
         layertop = 0;
-    }
+    } */
 
     this.layer.style.left = layerLeft + "px";
-    this.layer.style.top = layertop + "px";
+    this.layer.style.top = layerTop + "px";
 }
 /**
  * set to true when a dropdown box inside menu receives focus 
@@ -574,7 +613,7 @@
 
 	
 Exadel.Menu.Layer.prototype = {
-	initialize: function(id,delay){
+	initialize: function(id,delay, hideDelay){
 		Exadel.Menu.Layers.listl.push(id);
    		this.id = id;
    		this.layer = $(id);
@@ -747,7 +786,8 @@
 		Exadel.Menu.Layers.LMPopUpL(this.id, false);
 
 	},
-	asDropDown: function(topLevel, onEvt, offEvt){
+	asDropDown: function(topLevel, onEvt, offEvt, options){
+		this.options = options || {};
 //		if($(topLevel)){  CH-1518
 			var onmouseover = function(e){
                 if (!e) {
@@ -784,7 +824,8 @@
 //		}
 		return this;
 	},
-	asSubMenu: function(parent, refLayerName, evtName){
+	asSubMenu: function(parent, refLayerName, evtName, options){
+		this.options = options || {};
 		if(!evtName){
 			evtName = 'onmouseover';
 		}




More information about the richfaces-svn-commits mailing list