[richfaces-svn-commits] JBoss Rich Faces SVN: r287 - 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
Thu Apr 5 10:26:13 EDT 2007
Author: a.izobov
Date: 2007-04-05 10:26:13 -0400 (Thu, 05 Apr 2007)
New Revision: 287
Modified:
trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
Log:
support "jointPoint" and "direction" attributes added
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-05 14:12:53 UTC (rev 286)
+++ trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2007-04-05 14:26:13 UTC (rev 287)
@@ -237,7 +237,7 @@
this.shutdown();
this.detectWidth();
this.LMPopUp(menuName, false);
- this.setLMTO(4*this.timeoutLength);
+ this.setLMTO(4);
}
};
@@ -389,7 +389,62 @@
this.layer = $(layer);
Event.stop(e);
+ this.listPositions = function(jp, dir) {
+ var poss = new Array(new Array(2,1,4),new Array(1,2,3),new Array(4,3,2),new Array(3,4,1));
+ var list = new Array();
+ if (jp>0 && dir>0) {
+ list.push({jointPoint: jp, direction: dir });
+ } else if (jp>0 && dir==0) {
+ for(var i=0;i<3;i++) {
+ list.push({jointPoint: jp, direction: poss[jp-1][i] });
+ }
+ } else if (jp==0 && dir>0) {
+ for(var i=0;i<3;i++) {
+ list.push({jointPoint: poss[dir-1][i], direction: dir });
+ }
+ } else if (jp==0 && dir==0) {
+ list.push({jointPoint: 4, direction: 3 });
+ list.push({jointPoint: 1, direction: 2 });
+ list.push({jointPoint: 3, direction: 4 });
+ list.push({jointPoint: 2, direction: 1 });
+ }
+ return list;
+ }.bind(this);
+ this.calcPosition = function(jp, dir) {
+ var layerLeft;
+ var layerTop;
+ switch (jp) {
+ case 1:
+ layerLeft = this.left;
+ layerTop = this.top;
+ break;
+ case 2:
+ layerLeft = this.right;
+ layerTop = this.top;
+ break;
+ case 3:
+ layerLeft = this.right;
+ layerTop = this.bottom;
+ break;
+ case 4:
+ layerLeft = this.left;
+ layerTop = this.bottom;
+ break;
+ }
+ switch (dir) {
+ case 1:
+ layerLeft -= this.layerdim.width;
+ layerTop -= this.layerdim.height;
+ break;
+ case 2:
+ layerTop -= this.layerdim.height;
+ break;
+ case 4:
+ layerLeft -= this.layerdim.width;
+ }
+ return {left: layerLeft, top: layerTop};
+ }.bind(this);
this.show = function() {
Exadel.Menu.Layers.shutdown();
@@ -405,54 +460,53 @@
var dim = Element.getDimensions(this.element);
// parent element
- var top = screenOffset[1];
- var left = screenOffset[0];
- //var top = 0;
- //var left = 0;
+ this.top = screenOffset[1];
+ this.left = screenOffset[0];
- var bottom = top + dim.height;
- var right = left + dim.width;
+ this.bottom = this.top + dim.height;
+ this.right = this.left + dim.width;
- var layerdim = Element.getDimensions(this.layer);
- var layerLeft = Math.max(left,winOffset.left);
+ this.layerdim = Element.getDimensions(this.layer);
- if (layerLeft + layerdim.width - winOffset.left > windowWidth) {
- layerLeft = right - layerdim.width + Exadel.Menu.Layers.shadowWidth;
+ var options = Exadel.Menu.Layers.layers[this.layer.id].options;
+
+ var jointPoint = 0;
+ if (options.jointPoint) {
+ var sJp = options.jointPoint.toUpperCase();
+ jointPoint = sJp.indexOf('TL') != -1?1:jointPoint;
+ jointPoint = sJp.indexOf('TR') != -1?2:jointPoint;
+ jointPoint = sJp.indexOf('BR') != -1?3:jointPoint;
+ jointPoint = sJp.indexOf('BL') != -1?4:jointPoint;
}
-
- if (layerLeft + layerdim.width - winOffset.left > windowWidth) {
-// layerLeft = windowWidth - layerdim.width;
- layerLeft = windowWidth + winOffset.left - layerdim.width;
+
+ var direction = 0;
+ if (options.direction) {
+ var sDir = options.direction.toUpperCase();
+ direction = sDir.indexOf('TOP-LEFT') != -1?1:direction;
+ direction = sDir.indexOf('TOP-RIGHT') != -1?2:direction;
+ direction = sDir.indexOf('BOTTOM-RIGHT')!= -1?3:direction;
+ direction = sDir.indexOf('BOTTOM-LEFT') != -1?4:direction;
}
-
- if (layerLeft < 0) {
- layerLeft = 0;
+
+ var listPos = this.listPositions(jointPoint, direction);
+ var layerPos;
+ var foundPos = false;
+ for (var i=0;i<listPos.length;i++) {
+ layerPos = this.calcPosition(listPos[i].jointPoint, listPos[i].direction)
+ if ((layerPos.left >= winOffset.left) &&
+ (layerPos.left + this.layerdim.width - winOffset.left <= windowWidth) &&
+ (layerPos.top >= winOffset.top) &&
+ (layerPos.top + this.layerdim.height - winOffset.top <= windowHeight)) {
+ foundPos = true;
+ break;
+ }
}
-
-
-
- // calculate top of layer
- var layerTop = bottom;
-
- if ( (layerdim.height + 20) < (win.height - (bottom-winOffset.top)) ) {
- layerTop = bottom;
- } else {
- if ( (top-winOffset.top) > (layerdim.height + 20) ) {
- layerTop = top - layerdim.height;
- } else {
- layerTop = windowHeight - 20 - layerdim.height + winOffset.top;
- } // else
- } // else
-
- // fixing negative layerTop
- if (layerTop < 0) {
- layerTop = 0;
+ if (!foundPos) {
+ layerPos = this.calcPosition(listPos[0].jointPoint, listPos[0].direction)
}
-
- this.layer.style.left = layerLeft + "px";
- this.layer.style.top = layerTop + "px";
-
-
+ this.layer.style.left = layerPos.left + "px";
+ this.layer.style.top = layerPos.top + "px";
+
Exadel.Menu.Layers.LMPopUp(this.layer.id, false);
Exadel.Menu.Layers.clearLMTO();
}.bind(this);
@@ -465,7 +519,6 @@
this.event = e;
this.element = Event.findElement(e, 'div');
-// .childNodes[2].firstChild;
this.layer = $(layer);
this.show = function() {
More information about the richfaces-svn-commits
mailing list