Author: tan_pham_dinh
Date: 2009-12-24 06:30:23 -0500 (Thu, 24 Dec 2009)
New Revision: 1142
Modified:
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/core/DragDrop.js
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/core/DragDrop2.js
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIDashboard.js
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIDashboardUtil.js
Log:
GTNPORTAL-376: Change somethings in DragDrop and structre of UIDashboard for consistency
JS implementing way
Modified: portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/core/DragDrop.js
===================================================================
---
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/core/DragDrop.js 2009-12-24
10:09:43 UTC (rev 1141)
+++
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/core/DragDrop.js 2009-12-24
11:30:23 UTC (rev 1142)
@@ -156,7 +156,7 @@
if(foundTarget == null) {
foundTarget = ele ;
} else {
- if(this.isAncestor(foundTarget, ele)) {
+ if(eXo.core.DOMUtil.hasAncestor(ele, foundTarget)) {
foundTarget = ele ;
}
}
@@ -166,16 +166,6 @@
return foundTarget ;
} ;
-DragDrop.prototype.isAncestor = function(ancestor , child) {
- var parent = child.parentNode ;
- while(parent != null) {
- if(parent == ancestor) return true ;
- var tmp = parent.parentNode ;
- parent = tmp ;
- }
- return false ;
-} ;
-
DragDrop.prototype.isIn = function(x, y, component) {
var componentLeft = eXo.core.Browser.findPosX(component);
var componentRight = componentLeft + component.offsetWidth ;
@@ -183,15 +173,6 @@
var componentBottom = componentTop + component.offsetHeight ;
var isOver = false ;
- var uiWorkspaceContainer = document.getElementById("UIWorkspaceContainer") ;
- if ((uiWorkspaceContainer && uiWorkspaceContainer.style.display !=
"none") && eXo.core.Browser.isIE7()) {
- if(eXo.core.I18n.isLT()) componentRight = componentRight -
uiWorkspaceContainer.clientWidth ;
- }
-
- if(eXo.core.Browser.getBrowserType() == "ie") {
- componentLeft = componentLeft / 2 ;
- }
-
if((componentLeft < x) && (x < componentRight)) {
if((componentTop < y) && (y < componentBottom)) {
isOver = true ;
Modified: portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/core/DragDrop2.js
===================================================================
---
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/core/DragDrop2.js 2009-12-24
10:09:43 UTC (rev 1141)
+++
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/core/DragDrop2.js 2009-12-24
11:30:23 UTC (rev 1142)
@@ -18,10 +18,10 @@
*/
var count = 1 ;
-eXo.core.DragDrop2 = {
- obj : null,
+function DragDrop2() {
+ var obj = null;
- init : function(o, oRoot) {
+ DragDrop2.prototype.init = function(o, oRoot) {
o.onmousedown = eXo.core.DragDrop2.start;
o.root = oRoot && oRoot != null ? oRoot : o ;
@@ -32,14 +32,14 @@
o.root.onDragStart = new Function();
o.root.onDragEnd = new Function();
o.root.onDrag = new Function();
- },
+ };
- start : function(e) {
+ DragDrop2.prototype.start = function(e) {
if (!e) e = window.event;
if(((e.which) && (e.which == 2 || e.which == 3)) || ((e.button) &&
(e.button == 2))) {
return;
}
- var o = eXo.core.DragDrop2.obj = this;
+ var o = obj = this;
e = eXo.core.DragDrop2.fixE(e);
var y = parseInt(eXo.core.DOMUtil.getStyle(o.root,"top"));
var x = parseInt(eXo.core.DOMUtil.getStyle(o.root,"left"));
@@ -51,11 +51,11 @@
document.onmouseup = eXo.core.DragDrop2.end;
document.onmouseout = eXo.core.DragDrop2.cancel;
return false;
- },
+ };
- drag : function(e) {
+ DragDrop2.prototype.drag = function(e) {
e = eXo.core.DragDrop2.fixE(e);
- var o = eXo.core.DragDrop2.obj;
+ var o = obj;
var ey = eXo.core.Browser.findMouseYInPage(e);
var ex = eXo.core.Browser.findMouseXInPage(e);
var y = parseInt(eXo.core.DOMUtil.getStyle(o.root, "top"));
@@ -64,34 +64,35 @@
var nx, ny;
nx = x + (ex - o.lastMouseX);
ny = y + (ey - o.lastMouseY);
- eXo.core.DragDrop2.obj.root.style["left"] = nx + "px";
- eXo.core.DragDrop2.obj.root.style["top"] = ny + "px";
- eXo.core.DragDrop2.obj.lastMouseX = ex;
- eXo.core.DragDrop2.obj.lastMouseY = ey;
+ obj.root.style["left"] = nx + "px";
+ obj.root.style["top"] = ny + "px";
+ obj.lastMouseX = ex;
+ obj.lastMouseY = ey;
- eXo.core.DragDrop2.obj.root.onDrag(nx, ny, ex, ey, e);
+ obj.root.onDrag(nx, ny, ex, ey, e);
return false;
- },
+ };
- end : function(e) {
+ DragDrop2.prototype.end = function(e) {
e = eXo.core.DragDrop2.fixE(e);
document.onmousemove = null;
document.onmouseup = null;
document.onmouseout = null;
- eXo.core.DragDrop2.obj.root.onDragEnd(
parseInt(eXo.core.DragDrop2.obj.root.style["left"]),
- parseInt(eXo.core.DragDrop2.obj.root.style["top"]), e.clientX, e.clientY);
- eXo.core.DragDrop2.obj = null;
- },
+ obj.root.onDragEnd( parseInt(obj.root.style["left"]),
+ parseInt(obj.root.style["top"]), e.clientX, e.clientY);
+ obj = null;
+ };
- cancel : function(e) {
- if(eXo.core.DragDrop2.obj.root.onCancel) eXo.core.DragDrop2.obj.root.onCancel(e);
- },
+ DragDrop2.prototype.cancel = function(e) {
+ if(obj.root.onCancel) obj.root.onCancel(e);
+ };
- fixE : function(e) {
+ DragDrop2.prototype.fixE = function(e) {
if (typeof e == 'undefined') e = window.event;
if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
return e;
- }
-
-};
\ No newline at end of file
+ };
+};
+
+eXo.core.DragDrop2 = new DragDrop2();
\ No newline at end of file
Modified:
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js
===================================================================
---
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js 2009-12-24
10:09:43 UTC (rev 1141)
+++
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js 2009-12-24
11:30:23 UTC (rev 1142)
@@ -39,6 +39,9 @@
var Browser = eXo.core.Browser ;
var DragDrop = eXo.core.DragDrop ;
var Mouse = eXo.core.Mouse;
+
+ var previewBlock = null;
+ var previewTD = null;
/**
* This function is called after the DragDrop object is initialized
*/
@@ -50,7 +53,6 @@
this.origDragObjectStyle.copyProperties(properties, dragObject.style) ;
var isComponent = !!DOMUtil.findFirstDescendantByClass(dragObject, "div",
"UIComponentBlock");
- dragObject.isComponent = isComponent;
var uiWorkingWS = document.getElementById("UIWorkingWorkspace");
PortalDragDrop.positionRootObj = isComponent ? uiWorkingWS :
@@ -58,8 +60,6 @@
var originalDragObjectTop = Browser.findPosYInContainer(dragObject,
PortalDragDrop.positionRootObj);
var originalDragObjectLeft = Browser.findPosXInContainer(dragObject,
PortalDragDrop.positionRootObj);
- var originalMousePositionY = Mouse.mouseyInPage;
- var originalMousePositionX = Mouse.mousexInPage;
PortalDragDrop.deltaYDragObjectAndMouse = Browser.findMouseRelativeY(dragObject, e);
PortalDragDrop.deltaXDragObjectAndMouse = Browser.findMouseRelativeX(dragObject, e);
if(!isComponent) {
@@ -75,25 +75,28 @@
if(!isComponent) {
var cloneObject = dragObject.cloneNode(true) ;
dragObject.parentNode.insertBefore(cloneObject, dragObject) ;
-
- dndEvent.dragObject = cloneObject ;
-
- cloneObject.style.position = "absolute" ;
- if(eXo.core.I18n.isLT()) cloneObject.style.left = originalDragObjectLeft +
"px" ;
- else cloneObject.style.right = (PortalDragDrop.positionRootObj.offsetWidth -
originalDragObjectLeft - dragObject.offsetWidth) + "px" ;
-
- cloneObject.style.top = originalDragObjectTop + "px" ;
cloneObject.style.opacity = 0.5 ;
cloneObject.style.filter = "alpha(opacity=50)" ;
cloneObject.style.width = PortalDragDrop.backupDragObjectWidth + "px" ;
- cloneObject.isComponent = false;
+ dndEvent.dragObject = cloneObject ;
+ } else {
+ previewBlock = PortalDragDrop.createPreview();
+ dragObject.parentNode.insertBefore(previewBlock, dragObject);
+ dragObject.style.width = "300px";
+ var componentBlock = eXo.core.DOMUtil.findFirstDescendantByClass(dragObject,
"div", "UIComponentBlock") ;
+ var editBlock = eXo.core.DOMUtil.findFirstChildByClass(componentBlock,
"div", "EDITION-BLOCK");
+ if(editBlock) {
+ var newLayer = eXo.core.DOMUtil.findFirstDescendantByClass(editBlock,
"div", "NewLayer");
+ if(newLayer) newLayer.style.width = "300px";
+ }
}
+ dragObject.isComponent = isComponent;
- //fix bug ie in RTL
-// if(eXo.core.I18n.isRT() && Browser.isIE6() &&
DOMUtil.findFirstDescendantByClass(dragObject, "div",
"CONTROL-BLOCK")) {
-// dragObject.style.right = parseInt(dragObject.style.right)
-// + document.getElementById("UIControlWorkspace").offsetWidth +
"px" ;
-// }
+ dragObject = dndEvent.dragObject;
+ dragObject.style.position = "absolute" ;
+ if(eXo.core.I18n.isLT()) dragObject.style.left = originalDragObjectLeft +
"px" ;
+ else dragObject.style.right = (PortalDragDrop.positionRootObj.offsetWidth -
originalDragObjectLeft - dragObject.offsetWidth) + "px" ;
+ dragObject.style.top = originalDragObjectTop + "px" ;
eXo.portal.isInDragging = true;
}
@@ -101,146 +104,118 @@
DragDrop.dragCallback = function(dndEvent) {
var dragObject = dndEvent.dragObject ;
/* Control Scroll */
- eXo.portal.PortalDragDrop.scrollOnDrag(dragObject, dndEvent) ;
- if(dndEvent.foundTargetObject && dndEvent.lastFoundTargetObject) {
- /*Check and asign UIPage to uiComponentLayout when DND on UIPage*/
- var uiComponentLayout ;
- if(dndEvent.foundTargetObject.className == "UIPage") {
- uiComponentLayout = DOMUtil.findFirstDescendantByClass(dndEvent.foundTargetObject,
"div", "VIEW-PAGE");
- } else if(dndEvent.foundTargetObject.className == "UIPortal") {
- if(eXo.portal.portalMode%2) uiComponentLayout =
DOMUtil.findFirstDescendantByClass(dndEvent.foundTargetObject, "div",
"LAYOUT-PORTAL") ;
- else uiComponentLayout =
DOMUtil.findFirstDescendantByClass(dndEvent.foundTargetObject, "div",
"VIEW-PORTAL");
- } else {
- var foundUIComponent = new
eXo.portal.UIPortalComponent(dndEvent.foundTargetObject) ;
- if(eXo.portal.portalMode%2) uiComponentLayout = foundUIComponent.getLayoutBlock()
;
- else uiComponentLayout = foundUIComponent.getViewBlock();
- uiComponentLayout.style.height = "auto";
- }
+ eXo.portal.PortalDragDrop.scrollOnDrag(dndEvent) ;
+ if(!dndEvent.foundTargetObject) return;
+ var uiComponentLayout ;
+ if(dndEvent.foundTargetObject.className == "UIPage") {
+ uiComponentLayout = DOMUtil.findFirstDescendantByClass(dndEvent.foundTargetObject,
"div", "VIEW-PAGE");
+ } else if(dndEvent.foundTargetObject.className == "UIPortal") {
+ if(eXo.portal.portalMode%2) uiComponentLayout =
DOMUtil.findFirstDescendantByClass(dndEvent.foundTargetObject, "div",
"LAYOUT-PORTAL") ;
+ else uiComponentLayout =
DOMUtil.findFirstDescendantByClass(dndEvent.foundTargetObject, "div",
"VIEW-PORTAL");
+ } else {
+ var foundUIComponent = new eXo.portal.UIPortalComponent(dndEvent.foundTargetObject)
;
+ if(eXo.portal.portalMode%2) uiComponentLayout = foundUIComponent.getLayoutBlock()
;
+ else uiComponentLayout = foundUIComponent.getViewBlock();
+ uiComponentLayout.style.height = "auto";
+ }
+
+ dndEvent.foundTargetObject.uiComponentLayoutType = uiComponentLayout ;
+ var componentIdElement = DOMUtil.getChildrenByTagName(uiComponentLayout,
"div")[0] ;
+ var layoutTypeElement = DOMUtil.getChildrenByTagName(componentIdElement,
"div")[0] ;
+ eXo.portal.PortalDragDrop.layoutTypeElementNode = layoutTypeElement ;
+
+ if(previewBlock == null) previewBlock = eXo.portal.PortalDragDrop.createPreview();
+ if(previewTD || document.getElementById("PreviewTDBlock")) {
+ if(!previewTD) previewTD = document.getElementById("PreviewTDBlock");
+ if(previewTD.parentNode) previewTD.parentNode.removeChild(previewTD);
+ previewTD = null;
+ }
+
+ if(layoutTypeElement != null && !DOMUtil.hasClass(layoutTypeElement,
"UITableColumnContainer")) {
+ /* ===============================CASE ROW LAYOUT================================
*/
+ var rowContainer = DOMUtil.findFirstDescendantByClass(uiComponentLayout,
"div", "UIRowContainer") ;
+ var childRowContainer = DOMUtil.getChildrenByTagName(rowContainer, "div")
;
- try {
- if(eXo.portal.PortalDragDrop.backupLastFoundTarget) {
- var lastFoundUIComponent = new
eXo.portal.UIPortalComponent(eXo.portal.PortalDragDrop.backupLastFoundTarget);
-
- var lastFoundComponentLayout = lastFoundUIComponent.getLayoutBlock();
- if((DOMUtil.hasClass(lastFoundComponentLayout, "LAYOUT-CONTAINER") ||
DOMUtil.hasClass(lastFoundComponentLayout, "VIEW-CONTAINER"))
- && (lastFoundComponentLayout.offsetHeight < 30)) {
- if (DOMUtil.findFirstDescendantByClass(lastFoundComponentLayout,
"div", "UIContainer") == null) {
- lastFoundComponentLayout.style.height = "60px" ;
- }
- }
- }
- } catch(err) {
- //window.status = err.toString() ;
+ var listComponent = new Array() ;
+ for(var i = 0; i < childRowContainer.length; i++) {
+ if((childRowContainer[i].className != "DragAndDropPreview") &&
(childRowContainer[i] != dragObject)) {
+ listComponent.push(childRowContainer[i]) ;
+ }
}
-
-
/*################################################################################*/
- dndEvent.foundTargetObject.uiComponentLayoutType = uiComponentLayout ;
+ dndEvent.foundTargetObject.listComponentInTarget = listComponent ;
+ var insertPosition = eXo.portal.PortalDragDrop.findInsertPosition(listComponent,
dragObject, "row") ;
+ dndEvent.foundTargetObject.foundIndex = insertPosition ;
- var componentIdElement = DOMUtil.getChildrenByTagName(uiComponentLayout,
"div")[0] ;
- var layoutTypeElement = DOMUtil.getChildrenByTagName(componentIdElement,
"div")[0] ;
- eXo.portal.PortalDragDrop.layoutTypeElementNode = layoutTypeElement ;
+ /* Insert preview block */
+ if(insertPosition >= 0) {
+ rowContainer.insertBefore(previewBlock, listComponent[insertPosition]) ;
+ } else {
+ rowContainer.appendChild(previewBlock) ;
+ }
+ } else {
+ /* ===============================CASE COLUMN
LAYOUT================================ */
+ var columnContainer = DOMUtil.findFirstDescendantByClass(uiComponentLayout,
"table", "UITableColumnContainer") ;
+ var trContainer = DOMUtil.findFirstDescendantByClass(uiComponentLayout,
"tr", "TRContainer") ;
+ var tdElementList = DOMUtil.getChildrenByTagName(trContainer, "td") ;
- if(layoutTypeElement != null && !DOMUtil.hasClass(layoutTypeElement,
"UITableColumnContainer")) {
- /* ===============================CASE ROW LAYOUT================================
*/
- var rowContainer = DOMUtil.findFirstDescendantByClass(uiComponentLayout,
"div", "UIRowContainer") ;
- var childRowContainer = DOMUtil.getChildrenByTagName(rowContainer,
"div") ;
-
- var listComponent = new Array() ;
- for(var i = 0; i < childRowContainer.length; i++) {
- if((childRowContainer[i].className != "DragAndDropPreview")
&& (childRowContainer[i] != dragObject)) {
- listComponent.push(childRowContainer[i]) ;
+ var listComponent = new Array() ;
+ for(var i = 0; i < tdElementList.length; i++) {
+ if(DOMUtil.hasAncestor(previewBlock, uiComponentLayout)) {
+ var td = tdElementList[i];
+ if((td != previewBlock.parentNode) && (td != dragObject.parentNode)) {
+ listComponent.push(td) ;
+ } else if(td == dragObject.parentNode) {
+ td.style.width = "0px";
}
- }
-
- dndEvent.foundTargetObject.listComponentInTarget = listComponent ;
- /*Set properties for drag object */
-
- var insertPosition = eXo.portal.PortalDragDrop.findInsertPosition(listComponent,
dragObject, "row") ;
-
-// if(dndEvent.foundTargetObject == dndEvent.lastFoundTargetObject &&
-// dndEvent.lastFoundTargetObject.foundIndex == insertPosition) {
-// return ;
-// }
- dndEvent.foundTargetObject.foundIndex = insertPosition ;
-
- /*Undo preview */
- if(dndEvent.lastFoundTargetObject != null) {
- eXo.portal.PortalDragDrop.backupLastFoundTarget =
dndEvent.lastFoundTargetObject ;
- eXo.portal.PortalDragDrop.undoPreview(dndEvent) ;
- }
-
- /* Insert preview block */
- if(insertPosition >= 0) {
-
rowContainer.insertBefore(eXo.portal.PortalDragDrop.createPreview("row"),
listComponent[insertPosition]) ;
} else {
-
rowContainer.appendChild(eXo.portal.PortalDragDrop.createPreview("row")) ;
- }
-
- eXo.portal.PortalDragDrop.setDragObjectProperties(dragObject, childRowContainer,
"row", dndEvent.backupMouseEvent) ;
+ listComponent.push(tdElementList[i]) ;
+ }
+ }
+
+ dndEvent.foundTargetObject.listComponentInTarget = listComponent ;
+ var insertPosition = eXo.portal.PortalDragDrop.findInsertPosition(listComponent,
dragObject, "column") ;
+ dndEvent.foundTargetObject.foundIndex = insertPosition ;
+
+ /* Insert preview block */
+ var tdBlock = document.createElement("td");
+ tdBlock.id = tdBlock.className = "PreviewTDBlock";
+ tdBlock.appendChild(previewBlock);
+ previewTD = tdBlock;
+ if(insertPosition >= 0) {
+ trContainer.insertBefore(previewTD, listComponent[insertPosition]) ;
} else {
- /* ===============================CASE COLUMN
LAYOUT================================ */
- var columnContainer = DOMUtil.findFirstDescendantByClass(uiComponentLayout,
"table", "UITableColumnContainer") ;
- var trContainer = DOMUtil.findFirstDescendantByClass(uiComponentLayout,
"tr", "TRContainer") ;
- var tdElementList = DOMUtil.getChildrenByTagName(trContainer, "td") ;
-
- var listComponent = new Array() ;
- for(var i = 0; i < tdElementList.length; i++) {
- if(DOMUtil.hasDescendantClass(uiComponentLayout,
"DragAndDropPreview")) {
- var previewBlock = DOMUtil.findFirstDescendantByClass(trContainer,
"div", "DragAndDropPreview") ;
- if((tdElementList[i] != previewBlock.parentNode) && (tdElementList[i]
!= dragObject.parentNode)) {
- listComponent.push(tdElementList[i]) ;
- }
- } else {
- listComponent.push(tdElementList[i]) ;
- }
- }
-
- dndEvent.foundTargetObject.listComponentInTarget = listComponent ;
- /*Find Insert Position */
- var insertPosition = eXo.portal.PortalDragDrop.findInsertPosition(listComponent,
dragObject, "column") ;
-
- if(dndEvent.foundTargetObject == dndEvent.lastFoundTargetObject &&
- dndEvent.lastFoundTargetObject.foundIndex == insertPosition) {
- return ;
- }
-
- dndEvent.foundTargetObject.foundIndex = insertPosition ;
- /*Undo preview */
- if(dndEvent.lastFoundTargetObject != null) {
- eXo.portal.PortalDragDrop.undoPreview(dndEvent) ;
- }
-
- /* Insert preview block */
- eXo.portal.PortalDragDrop.tdInserted = document.createElement('td') ;
- eXo.portal.PortalDragDrop.tdInserted
.appendChild(eXo.portal.PortalDragDrop.createPreview("column")) ;
- if(insertPosition >= 0) {
- trContainer.insertBefore(eXo.portal.PortalDragDrop.tdInserted,
listComponent[insertPosition]) ;
- } else {
- trContainer.appendChild(eXo.portal.PortalDragDrop.tdInserted) ;
- }
- /*Set properties for drag object */
- eXo.portal.PortalDragDrop.setDragObjectProperties(dragObject, tdElementList,
"column", dndEvent.backupMouseEvent) ;
+ trContainer.appendChild(previewTD) ;
}
- }
+ }
} ;
DragDrop.dropCallback = function(dndEvent) {
this.origDragObjectStyle.setProperties(dndEvent.dragObject.style, false) ;
- if(dndEvent.foundTargetObject != null) {
+ if(dndEvent.foundTargetObject != null || (dndEvent.backupMouseEvent &&
dndEvent.backupMouseEvent.keyCode != 27)) {
eXo.portal.PortalDragDrop.doDropCallback(dndEvent) ;
} else {
if(!dndEvent.dragObject.isComponent) {
dndEvent.dragObject.parentNode.removeChild(dndEvent.dragObject) ;
}
+ if(dndEvent.dragObject.parentNode.tagName.toLowerCase() == "td") {
+ dndEvent.dragObject.parentNode.style.width = "auto";
+ }
// fix bug WEBOS-196
- var srcElement = dndEvent.dragObject ;
- srcElement.style.width = "auto" ;
-
- eXo.portal.PortalDragDrop.removeNullPreview();
+ dndEvent.dragObject.style.width = "auto" ;
}
+ if(dndEvent.dragObject.isComponent) {
+ var componentBlock = eXo.core.DOMUtil.findFirstDescendantByClass(dndEvent.dragObject,
"div", "UIComponentBlock") ;
+ var editBlock = eXo.core.DOMUtil.findFirstChildByClass(componentBlock,
"div", "EDITION-BLOCK");
+ if(editBlock) editBlock.style.display = "none";
+ }
+
+ if(previewBlock) previewBlock.parentNode.removeChild(previewBlock);
+ if(previewTD) previewTD.parentNode.removeChild(previewTD);
+ previewBlock = previewTD = null;
+
eXo.portal.isInDragging = false;
eXo.portal.UIPortal.changeComposerSaveButton();
};
@@ -268,23 +243,15 @@
};
PortalDragDrop.prototype.doDropCallback = function(dndEvent) {
- if(!dndEvent.lastFoundTargetObject) {
- dndEvent.lastFoundTargetObject = eXo.portal.PortalDragDrop.backupLastFoundTarget ;
- }
-
- eXo.portal.PortalDragDrop.undoPreview(dndEvent) ;
-
var srcElement = dndEvent.dragObject ;
-
- var targetElement = dndEvent.foundTargetObject ;
+ var targetElement = dndEvent.foundTargetObject;
var newComponent = false;
- if(eXo.core.DOMUtil.hasDescendantClass(srcElement, "DragControlArea")
&& (targetElement.foundIndex != null)) {
-// alert("My Test: " + eXo.portal.PortalDragDrop.layoutTypeElementNode);
+ if(srcElement.isComponent && (targetElement.foundIndex != null)) {
if(eXo.portal.PortalDragDrop.layoutTypeElementNode != null) {
eXo.portal.PortalDragDrop.divRowContainerAddChild(srcElement, targetElement,
targetElement.foundIndex) ;
} else {
-// alert("Table is OK");
+ eXo.portal.PortalDragDrop.parentDragObject.style.width = "auto";
eXo.portal.PortalDragDrop.tableColumnContainerAddChild(srcElement, targetElement,
targetElement.foundIndex) ;
}
}
@@ -330,7 +297,7 @@
return dropableTargets ;
};
-PortalDragDrop.prototype.scrollOnDrag = function(dragObject, dndEvent) {
+PortalDragDrop.prototype.scrollOnDrag = function(dndEvent) {
var workspaceHeight =
document.getElementById("UIWorkingWorkspace").offsetHeight;
var browserHeight = eXo.core.Browser.getBrowserHeight() ;
if(workspaceHeight <= browserHeight) return;
@@ -347,8 +314,6 @@
};
PortalDragDrop.prototype.findInsertPosition = function(components, dragObject, layout) {
- var dragObjectX = eXo.core.Browser.findPosX(dragObject) ;
-
if(layout == "row") {
for(var i = 0; i < components.length; i++) {
var componentTop = eXo.core.Browser.findPosY(components[i]) ;
@@ -361,6 +326,7 @@
return -1 ;
} else {
+ var dragObjectX = eXo.core.Browser.findPosX(dragObject) ;
for(var i = 0; i < components.length; i++) {
var componentInTD = eXo.core.DOMUtil.getChildrenByTagName(components[i]
,"div")[0] ;
var componentX = eXo.core.Browser.findPosX(components[i]) ;
@@ -372,117 +338,13 @@
}
};
-PortalDragDrop.prototype.setDragObjectProperties = function(dragObject, listComponent,
layout, e) {
- var uiPage = eXo.core.DOMUtil.findAncestorByClass(dragObject, "UIPage");
-
- /* IE's Bug: It always double when set position, margin-left for
- * UIWorkingWorkspace is problem.
- * If WorkingWorkspace is setted a width, that bug disappear
- * but the layout on IE has breakdown!!!
- * */
- dragObject.style.top =
(eXo.core.Browser.findMouseRelativeY(eXo.portal.PortalDragDrop.positionRootObj, e) -
- eXo.portal.PortalDragDrop.deltaYDragObjectAndMouse) + "px";
- var componentBlock = eXo.core.DOMUtil.findFirstDescendantByClass(dragObject,
"div", "UIComponentBlock") ;
- if(!componentBlock) {
- if(eXo.core.I18n.isLT()) dragObject.style.left =
(eXo.core.Browser.findMouseRelativeX(dragObject.offsetParent, e) -
- eXo.portal.PortalDragDrop.deltaXDragObjectAndMouse) +
"px" ;
- } else {
- var uiWorkingWS = document.getElementById("UIWorkingWorkspace");
- if(eXo.core.I18n.isLT()) dragObject.style.left =
(eXo.core.Browser.findMouseRelativeX(uiWorkingWS, e) -
- eXo.portal.PortalDragDrop.deltaXDragObjectAndMouse) +
"px" ;
- var editBlock = eXo.core.DOMUtil.findFirstChildByClass(componentBlock,
"div", "EDITION-BLOCK");
- if(editBlock) {
- var newLayer = eXo.core.DOMUtil.findFirstDescendantByClass(editBlock,
"div", "NewLayer");
- if(newLayer) newLayer.style.width = "300px";
- }
- }
- dragObject.style.width = "300px" ;
- dragObject.style.position = "absolute" ;
-};
-
PortalDragDrop.prototype.createPreview = function(layoutType) {
-
- var previewBlock = document.createElement("div") ;
- var components = eXo.core.DragDrop.dndEvent.foundTargetObject.listComponentInTarget ;
-
- previewBlock.className = "DragAndDropPreview" ;
- previewBlock.id = "DragAndDropPreview" ;
-
- if((layoutType == "column") && (components.length > 0)) {
- var offsetWidthTR = components[0].parentNode.offsetWidth ;
- var widthComponent = 0 ;
-
- if(eXo.core.DOMUtil.findAncestorByClass(eXo.portal.PortalDragDrop.parentDragObject,
"TRContainer") != null) {
- widthComponent = Math.round(offsetWidthTR / (components.length)) - 1 ;
- } else {
- widthComponent = Math.round(offsetWidthTR / (components.length + 1)) - 1 ;
- }
-
- eXo.portal.PortalDragDrop.tdInserted.style.width = widthComponent + "px" ;
-
- for(var i = 0 ; i < components.length; i++) {
- if(components[i] == eXo.portal.PortalDragDrop.parentDragObject) {
- components[i].style.width = "0px" ;
- } else {
- components[i].style.width = widthComponent + "px" ;
- }
- }
-
- eXo.portal.PortalDragDrop.widthComponentInTarget = widthComponent ;
- }
- return previewBlock ;
+ var previewBlock = document.createElement("div") ;
+ previewBlock.className = "DragAndDropPreview" ;
+ previewBlock.id = "DragAndDropPreview" ;
+ return previewBlock;
};
-PortalDragDrop.prototype.removeNullPreview = function() {
- var dropObject = document.getElementById("DragAndDropPreview") ;
- if (dropObject && dropObject.innerHTML == "") {
- dropObject.parentNode.removeChild(dropObject);
- }
-}
-
-PortalDragDrop.prototype.undoPreview = function(dndEvent) {
- var DOMUtil = eXo.core.DOMUtil ;
- var uiComponentLayout ;
- try{
- if(dndEvent.lastFoundTargetObject.className == "UIPage") {
- uiComponentLayout = DOMUtil.findFirstDescendantByClass(dndEvent.foundTargetObject,
"div", "VIEW-PAGE");
- } else if(dndEvent.lastFoundTargetObject.className == "UIPortal") {
- if(eXo.portal.portalMode%2) uiComponentLayout =
DOMUtil.findFirstDescendantByClass(dndEvent.lastFoundTargetObject, "div",
"LAYOUT-PORTAL");
- else uiComponentLayout =
DOMUtil.findFirstDescendantByClass(dndEvent.lastFoundTargetObject, "div",
"VIEW-PORTAL");
- } else {
- var foundUIComponent = new
eXo.portal.UIPortalComponent(dndEvent.lastFoundTargetObject) ;
- if(eXo.portal.portalMode%2) uiComponentLayout = foundUIComponent.getLayoutBlock() ;
- else uiComponentLayout = foundUIComponent.getViewBlock();
- }
- }catch(e) {}
- var componentIdElement = DOMUtil.getChildrenByTagName(uiComponentLayout
,"div")[0] ;
- var layoutTypeElement = DOMUtil.getChildrenByTagName(componentIdElement
,"div")[0] ;
-
- var dropHere = document.getElementById("DragAndDropPreview") ;
-
- var dragObject = dndEvent.dragObject ;
-
- if(dropHere != null) {
- if(layoutTypeElement != null) {
- dropHere.parentNode.removeChild(dropHere) ;
- } else {
- var tableLayoutElement = DOMUtil.getChildrenByTagName(componentIdElement
,"table")[0] ;
- var trContainer = DOMUtil.findFirstDescendantByClass(tableLayoutElement,
"tr", "TRContainer") ;
-
- trContainer.removeChild(dropHere.parentNode) ;
- childTRContainer = DOMUtil.getChildrenByTagName(trContainer, "td") ;
-
- for(var i = 0; i < childTRContainer.length; i++) {
- if(childTRContainer[i] == eXo.portal.PortalDragDrop.parentDragObject) {
- childTRContainer[i].style.width = "0px" ;
- }
- }
-
- }
- }
- dragObject.style.border = "none" ;
-};
-
PortalDragDrop.prototype.divRowContainerAddChild = function(insertBlock, targetElement,
insertPosition) {
var listComponent = eXo.core.DragDrop.dndEvent.foundTargetObject.listComponentInTarget
;
var uiRowContainer = eXo.core.DOMUtil.findFirstDescendantByClass(targetElement,
"div", "UIRowContainer") ;
@@ -493,23 +355,16 @@
} else {
uiRowContainer.appendChild(insertBlock) ;
}
-
- if(eXo.portal.PortalDragDrop.parentDragObject.parentNode.className ==
"TRContainer") {
-
eXo.portal.PortalDragDrop.parentDragObject.parentNode.removeChild(eXo.portal.PortalDragDrop.parentDragObject)
;
- }
};
PortalDragDrop.prototype.tableColumnContainerAddChild = function(insertBlock,
targetElement, insertPosition) {
var listComponent = eXo.core.DragDrop.dndEvent.foundTargetObject.listComponentInTarget
;
var DOMUtil = eXo.core.DOMUtil ;
var trContainer = DOMUtil.findFirstDescendantByClass(targetElement, "tr",
"TRContainer") ;
- var tdInserted = document.createElement('td') ;
- var checkTRContainerInsertBlock = DOMUtil.findAncestorByClass(insertBlock,
"TRContainer") ;
-
- tdInserted.style.width = eXo.portal.PortalDragDrop.widthComponentInTarget +
"px" ;
-
+ var tdInserted = document.createElement('td') ;
tdInserted.appendChild(insertBlock) ;
+
if(insertPosition >= 0) {
trContainer.insertBefore(tdInserted, listComponent[insertPosition]) ;
} else {
@@ -518,9 +373,9 @@
insertBlock.style.width = "auto" ;
- if(checkTRContainerInsertBlock) {
- trContainer.removeChild(eXo.portal.PortalDragDrop.parentDragObject) ;
+ if(eXo.portal.PortalDragDrop.parentDragObject.tagName.toLowerCase() == "td")
{
+ DOMUtil.removeElement(eXo.portal.PortalDragDrop.parentDragObject) ;
}
};
-eXo.portal.PortalDragDrop = new PortalDragDrop() ;
+eXo.portal.PortalDragDrop = new PortalDragDrop() ;
\ No newline at end of file
Modified:
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIDashboard.js
===================================================================
---
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIDashboard.js 2009-12-24
10:09:43 UTC (rev 1141)
+++
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIDashboard.js 2009-12-24
11:30:23 UTC (rev 1142)
@@ -17,17 +17,17 @@
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
-eXo.webui.UIDashboard = {
+function UIDashboard() {
- currCol : null,
- targetObj : null,
+ var currCol = null;
+ var targetObj = null;
- init : function (dragItem, dragObj) {
+ UIDashboard.prototype.init = function (dragItem, dragObj) {
- eXo.core.DragDrop2.init(dragItem, dragObj) ;
+ var DOMUtil = eXo.core.DOMUtil;
+ eXo.core.DragDrop2.init(dragItem, dragObj);
dragObj.onDragStart = function(x, y, lastMouseX, lastMouseY, e) {
- var DOMUtil = eXo.core.DOMUtil;
var uiDashboard = eXo.webui.UIDashboard ;
var portletFragment = DOMUtil.findAncestorByClass(dragObj,
"PORTLET-FRAGMENT");
if(!portletFragment) return;
@@ -56,20 +56,16 @@
temp = temp.parentNode;
}
-// var slideBar = document.getElementById("ControlWorkspaceSlidebar");
-// if(slideBar!=null && slideBar.style.display!="none" &&
eXo.core.Browser.getBrowserType()=="ie")
-// x -= slideBar.offsetWidth;
-
var uiTarget = null;
if(!DOMUtil.hasClass(dragObj, "SelectItem")) {
uiTarget = uiDashboard.createTarget(ggwidth, 0);
dragObj.parentNode.insertBefore(uiTarget, dragObj.nextSibling);
- uiDashboard.currCol = eXo.webui.UIDashboardUtil.findColIndexInDashboard(dragObj);
+ currCol = eXo.webui.UIDashboardUtil.findColIndexInDashboard(dragObj);
}else{
var dragCopyObj = dragObj.cloneNode(true);
DOMUtil.addClass(dragCopyObj, "CopyObj");
dragObj.parentNode.insertBefore(dragCopyObj, dragObj);
- uiDashboard.targetObj = null;
+ targetObj = null;
}
dragObj.style.width = ggwidth +"px";
@@ -96,15 +92,14 @@
eXo.webui.UIDashboardUtil.setPositionInContainer(uiWorkingWS, dragObj, x, y);
if(uiTarget!=null) {
uiTarget.style.height = ggheight +"px";
- uiDashboard.targetObj = uiTarget;
+ targetObj = uiTarget;
}
}
dragObj.onDrag = function(nx, ny, ex, ey, e) {
- var DOMUtil = eXo.core.DOMUtil;
- var uiTarget = eXo.webui.UIDashboard.targetObj;
+ var uiTarget = targetObj;
var portletFragment = DOMUtil.findAncestorByClass(dragObj,
"PORTLET-FRAGMENT");
if(!portletFragment) return;
@@ -116,18 +111,17 @@
if(eXo.webui.UIDashboardUtil.isIn(ex, ey, dashboardCont)) {
if(!uiTarget) {
uiTarget = eXo.webui.UIDashboard.createTargetOfAnObject(dragObj);
- eXo.webui.UIDashboard.targetObj = uiTarget;
+ targetObj = uiTarget;
}
- var uiCol = eXo.webui.UIDashboard.currCol ;
+ var uiCol = currCol ;
if(!uiCol) {
if(!cols) cols = DOMUtil.findDescendantsByClass(dashboardCont, "div",
"UIColumn");
for(var i=0; i<cols.length; i++) {
var uiColLeft = eXo.webui.UIDashboardUtil.findPosX(cols[i]) -
dashboardCont.scrollLeft;
if(uiColLeft<ex && ex<uiColLeft+cols[i].offsetWidth) {
- uiCol = cols[i];
- eXo.webui.UIDashboard.currCol = uiCol;
+ currCol = uiCol = cols[i];
break;
}
}
@@ -170,7 +164,7 @@
for(var i=0; i<cols.length; i++) {
var uiColLeft = eXo.webui.UIDashboardUtil.findPosX(cols[i]) -
dashboardCont.scrollLeft;
if(uiColLeft<ex && ex<uiColLeft+cols[i].offsetWidth) {
- eXo.webui.UIDashboard.currCol = cols[i];
+ currCol = cols[i];
break;
}
}
@@ -179,7 +173,7 @@
//prevent dragging gadget object out of DashboardContainer
if(uiTarget!=null && DOMUtil.hasClass(dragObj, "SelectItem")) {
uiTarget.parentNode.removeChild(uiTarget);
- eXo.webui.UIDashboard.targetObj = uiTarget = null;
+ targetObj = uiTarget = null;
}
}
}
@@ -187,26 +181,25 @@
dragObj.onDragEnd = function(x, y, clientX, clientY) {
- var uiDashboard = eXo.webui.UIDashboard;
var uiDashboardUtil = eXo.webui.UIDashboardUtil;
- var portletFragment = eXo.core.DOMUtil.findAncestorByClass(dragObj,
"PORTLET-FRAGMENT");
+ var portletFragment = DOMUtil.findAncestorByClass(dragObj,
"PORTLET-FRAGMENT");
if(!portletFragment) return;
- var masks = eXo.core.DOMUtil.findDescendantsByClass(portletFragment, "div",
"UIMask");
+ var masks = DOMUtil.findDescendantsByClass(portletFragment, "div",
"UIMask");
for(var i=0; i<masks.length; i++) {
eXo.core.Browser.setOpacity(masks[i], 100);
masks[i].style.display = "none";
}
- var uiTarget = uiDashboard.targetObj;
+ var uiTarget = targetObj;
if(uiTarget && !uiTarget.parentNode) {
uiTarget = null;
}
dragObj.style.position = "static";
- eXo.core.DOMUtil.removeClass(dragObj,"Dragging");
+ DOMUtil.removeClass(dragObj,"Dragging");
- var dragCopyObj = eXo.core.DOMUtil.findFirstDescendantByClass(portletFragment,
"div", "CopyObj");
+ var dragCopyObj = DOMUtil.findFirstDescendantByClass(portletFragment, "div",
"CopyObj");
if(dragCopyObj) {
dragCopyObj.parentNode.replaceChild(dragObj, dragCopyObj);
dragObj.style.width = "auto";
@@ -218,7 +211,7 @@
var row = uiDashboardUtil.findRowIndexInDashboard(uiTarget);
var compId = portletFragment.parentNode.id;
- if(eXo.core.DOMUtil.hasClass(dragObj, "SelectItem")) {
+ if(DOMUtil.hasClass(dragObj, "SelectItem")) {
var params = [
{name: "colIndex", value: col},
{name: "rowIndex", value: row},
@@ -245,12 +238,12 @@
}
}
- uiTarget = eXo.core.DOMUtil.findFirstDescendantByClass(portletFragment,
"div", "UITarget");
+ uiTarget = DOMUtil.findFirstDescendantByClass(portletFragment, "div",
"UITarget");
while (uiTarget) {
- eXo.core.DOMUtil.removeElement(uiTarget);
+ DOMUtil.removeElement(uiTarget);
uiTarget = eXo.core.DOMUtil.findFirstDescendantByClass(portletFragment,
"div", "UITarget");
}
- uiDashboard.targetObj = uiDashboard.currCol = uiDashboard.compId = null;
+ targetObj = currCol = null;
}
@@ -259,9 +252,9 @@
eXo.core.DragDrop2.end(e);
}
}
- },
+ };
- onLoad : function(windowId, canEdit) {
+ UIDashboard.prototype.onLoad = function(windowId, canEdit) {
var portletWindow = document.getElementById(windowId);
if(!portletWindow) return;
@@ -299,9 +292,9 @@
eXo.webui.UIDashboard.initHeight(windowId) ;
setTimeout("eXo.webui.UIDashboard.initDragDrop('" + windowId +
"'," + canEdit + ");", 300) ;
- },
+ };
- initDragDrop : function(windowId, canEdit) {
+ UIDashboard.prototype.initDragDrop = function(windowId, canEdit) {
var DOMUtil = eXo.core.DOMUtil ;
var portletWindow = document.getElementById(windowId) ;
var gadgetControls = DOMUtil.findDescendantsByClass(portletWindow, "div",
"GadgetControl");
@@ -328,9 +321,9 @@
}
}
}
- },
+ };
- initHeight : function(windowId) {
+ UIDashboard.prototype.initHeight = function(windowId) {
var DOMUtil = eXo.core.DOMUtil;
var portletWindow, uiWindow ;
if(typeof(windowId) != "string") {
@@ -390,26 +383,26 @@
}
}
}
- },
+ };
- createTarget : function(width, height) {
+ UIDashboard.prototype.createTarget = function(width, height) {
var uiTarget = document.createElement("div");
uiTarget.id = "UITarget";
uiTarget.className = "UITarget";
uiTarget.style.width = width + "px";
uiTarget.style.height = height + "px";
return uiTarget;
- },
+ };
- createTargetOfAnObject : function(obj) {
+ UIDashboard.prototype.createTargetOfAnObject = function(obj) {
var uiTarget = document.createElement("div");
uiTarget.id = "UITarget";
uiTarget.className = "UITarget";
uiTarget.style.height = obj.offsetHeight + "px";
return uiTarget;
- },
+ };
- showHideSelectContainer : function(event) {
+ UIDashboard.prototype.showHideSelectContainer = function(event) {
if(!event) event = window.event;
var DOMUtil = eXo.core.DOMUtil;
var comp = eXo.core.Browser.getEventSource(event);
@@ -433,9 +426,9 @@
var url = eXo.webui.UIDashboardUtil.createRequest(portletFragment.parentNode.id,
"SetShowSelectContainer", params);
ajaxGet(url);
}
- },
+ };
- onTabClick : function(clickElement, normalStyle, selectedType) {
+ UIDashboard.prototype.onTabClick = function(clickElement, normalStyle, selectedType) {
var DOMUtil = eXo.core.DOMUtil;
var category = DOMUtil.findAncestorByClass(clickElement, "GadgetCategory");
var categoryContent = DOMUtil.findFirstChildByClass(category, "div",
"ItemsContainer");
@@ -454,27 +447,27 @@
DOMUtil.findFirstChildByClass(category, "div",
"GadgetTab").className = "GadgetTab " + normalStyle;
categoryContent.style.display = "none";
}
- },
+ };
- enableContainer : function(elemt) {
+ UIDashboard.prototype.enableContainer = function(elemt) {
var DOMUtil = eXo.core.DOMUtil;
if(DOMUtil.hasClass(elemt, "DisableContainer")) {
DOMUtil.replaceClass(elemt, " DisableContainer", "");
}
var arrow = DOMUtil.findFirstChildByClass(elemt, "div", "Arrow");
if(DOMUtil.hasClass(arrow, "DisableArrowIcon"))
DOMUtil.replaceClass(arrow," DisableArrowIcon", "");
- },
+ };
- disableContainer : function(elemt) {
+ UIDashboard.prototype.disableContainer = function(elemt) {
var DOMUtil = eXo.core.DOMUtil;
if(!DOMUtil.hasClass(elemt, "DisableContainer")) {
DOMUtil.addClass(elemt, "DisableContainer");
}
var arrow = DOMUtil.findFirstChildByClass(elemt, "div", "Arrow");
if(!DOMUtil.hasClass(arrow, "DisableArrowIcon"))
DOMUtil.addClass(arrow," DisableArrowIcon");
- },
+ };
- scrollOnDrag : function(dragObj) {
+ UIDashboard.prototype.scrollOnDrag = function(dragObj) {
var DOMUtil = eXo.core.DOMUtil;
var dashboardUtil = eXo.webui.UIDashboardUtil;
var uiDashboard = DOMUtil.findAncestorByClass(dragObj, "UIDashboard");
@@ -511,6 +504,7 @@
} else {
if(objTop < 0 && deltaY > 0) gadgetContainer.scrollTop -= 5;
}
- }
-
-}
+ };
+};
+
+eXo.webui.UIDashboard = new UIDashboard();
\ No newline at end of file
Modified:
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIDashboardUtil.js
===================================================================
---
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIDashboardUtil.js 2009-12-24
10:09:43 UTC (rev 1141)
+++
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIDashboardUtil.js 2009-12-24
11:30:23 UTC (rev 1142)
@@ -17,9 +17,9 @@
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
-eXo.webui.UIDashboardUtil = {
+function UIDashboardUtil() {
- findPosX : function(obj) {
+ UIDashboardUtil.prototype.findPosX = function(obj) {
var curleft = 0;
var uiWorkspaceContainer = document.getElementById("UIWorkspaceContainer");
var uiWorkingWorkspace = document.getElementById("UIWorkingWorkspace");
@@ -38,18 +38,18 @@
obj = obj.offsetParent ;
}
return curleft ;
- } ,
+ };
- findPosY : function(obj) {
+ UIDashboardUtil.prototype.findPosY = function(obj) {
var curtop = 0 ;
while (obj) {
curtop += obj.offsetTop ;
obj = obj.offsetParent ;
}
return curtop ;
- } ,
+ };
- findMouseRelativeX : function (object, e){
+ UIDashboardUtil.prototype.findMouseRelativeX = function (object, e){
var posx = -1 ;
var posXObject = eXo.webui.UIDashboardUtil.findPosX(object) ;
if (!e) e = window.event ;
@@ -59,9 +59,9 @@
posx = e.clientX + document.body.scrollLeft - posXObject ;
}
return posx ;
- },
+ };
- findMouseRelativeY : function(object, e) {
+ UIDashboardUtil.prototype.findMouseRelativeY = function(object, e) {
var posy = -1 ;
var posYObject = eXo.webui.UIDashboardUtil.findPosY(object) ;
if (!e) e = window.event ;
@@ -76,21 +76,21 @@
}
}
return posy ;
- },
+ };
- findPosXInContainer : function(obj, container) {
+ UIDashboardUtil.prototype.findPosXInContainer = function(obj, container) {
var objX = eXo.webui.UIDashboardUtil.findPosX(obj) ;
var containerX = eXo.webui.UIDashboardUtil.findPosX(container) ;
return (objX - containerX) ;
- },
+ };
- findPosYInContainer : function(obj, container) {
+ UIDashboardUtil.prototype.findPosYInContainer = function(obj, container) {
var objY = eXo.webui.UIDashboardUtil.findPosY(obj) ;
var containerY = eXo.webui.UIDashboardUtil.findPosY(container) ;
return (objY - containerY) ;
- },
+ };
- setPositionInContainer : function(container, component, posX, posY) {
+ UIDashboardUtil.prototype.setPositionInContainer = function(container, component, posX,
posY) {
var offsetX = component.offsetLeft ;
var offsetY = component.offsetTop ;
@@ -102,9 +102,9 @@
component.style.left = deltaX + "px" ;
component.style.top = deltaY + "px" ;
- },
+ };
- isIn : function(x, y, component) {
+ UIDashboardUtil.prototype.isIn = function(x, y, component) {
var componentLeft = eXo.webui.UIDashboardUtil.findPosX(component);
var componentRight = componentLeft + component.offsetWidth ;
var componentTop = eXo.webui.UIDashboardUtil.findPosY(component) ;
@@ -118,9 +118,9 @@
}
return isOver ;
- },
+ };
- findColIndexInDashboard : function(dragObj){
+ UIDashboardUtil.prototype.findColIndexInDashboard = function(dragObj){
var col = dragObj.parentNode;
if(col==null) return null;
var dashboardContainer = eXo.core.DOMUtil.findAncestorByClass(col,
"DashboardContainer");
@@ -130,16 +130,16 @@
return i;
}
}
- },
+ };
- findRowIndexInDashboard : function(dragObj){
+ UIDashboardUtil.prototype.findRowIndexInDashboard = function(dragObj){
var modules = eXo.core.DOMUtil.getChildrenByTagName(dragObj.parentNode,
"div");
for(var i=0; i<modules.length; i++){
if(modules[i].id == dragObj.id) return i;
}
- },
+ };
- createRequest : function(componentId, action, params){
+ UIDashboardUtil.prototype.createRequest = function(componentId, action, params){
var url = eXo.env.server.portalBaseURL;
url += '?portal:componentId=' + componentId +
'&portal:type=action&uicomponent=UIDashboard&op=' + action ;
@@ -151,5 +151,7 @@
}
}
return url;
- }
-}
\ No newline at end of file
+ };
+};
+
+eXo.webui.UIDashboardUtil = new UIDashboardUtil();
\ No newline at end of file