Author: Lars Michelsen <[email protected]>
Date: Wed Mar 2 21:00:37 2011 +0100
Committer: Lars Michelsen <[email protected]>
Commit-Date: Wed Mar 2 21:00:37 2011 +0100
Relative positioned object can now be set to absolute positions when dropping
an object with the SHIFT key pressed
---
share/frontend/nagvis-js/js/NagVisObject.js | 38 ++++++++++++++++++++
.../frontend/nagvis-js/js/NagVisStatefulObject.js | 5 ++-
share/frontend/nagvis-js/js/nagvis.js | 3 ++
3 files changed, 45 insertions(+), 1 deletions(-)
diff --git a/share/frontend/nagvis-js/js/NagVisObject.js
b/share/frontend/nagvis-js/js/NagVisObject.js
index fe736f9..fa29745 100644
--- a/share/frontend/nagvis-js/js/NagVisObject.js
+++ b/share/frontend/nagvis-js/js/NagVisObject.js
@@ -442,6 +442,44 @@ var NagVisObject = Base.extend({
return l;
},
+ // Transform the current coords to absolute coords when relative
+ makeAbsoluteCoords: function(num) {
+ var x = num === -1 ? this.conf.x : this.conf.x.split(',')[num];
+ var y = num === -1 ? this.conf.y : this.conf.y.split(',')[num];
+
+ // Skip when already absolute
+ if(!isRelativeCoord(x) && !isRelativeCoord(y))
+ return;
+
+ // Get parent object ids
+ var xParent = this.getCoordParent(this.conf.x, num);
+ var yParent = this.getCoordParent(this.conf.y, num);
+
+ if(xParent == yParent) {
+ getMapObjByDomObjId(xParent).delChild(this);
+ } else {
+ getMapObjByDomObjId(xParent).delChild(this);
+ getMapObjByDomObjId(yParent).delChild(this);
+ }
+
+ // FIXME: Maybe the parent object is also a line. Then -1 is
not correct
+ // But it is not coded to attach relative objects to
lines. So it is no big
+ // deal to leave this as it is.
+ if(num === -1) {
+ this.conf.x = this.parseCoord(this.conf.x, 'x');
+ this.conf.y = this.parseCoord(this.conf.y, 'y');
+ } else {
+ var old = this.conf.x.split(',');
+ old[num] = this.parseCoord(this.conf.x, 'x');
+ this.conf.x = old.join(',');
+
+ old = this.conf.y.split(',');
+ old[num] = this.parseCoord(this.conf.y, 'y');
+ this.conf.y = old.join(',');
+ old = null;
+ }
+ },
+
// Transform the current coords to relative
// coords to the given object
makeRelativeCoords: function(oParent, num) {
diff --git a/share/frontend/nagvis-js/js/NagVisStatefulObject.js
b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
index 10cf5e7..524dd4e 100644
--- a/share/frontend/nagvis-js/js/NagVisStatefulObject.js
+++ b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
@@ -1032,7 +1032,10 @@ var NagVisStatefulObject = NagVisObject.extend({
// Make relative when oParent set and not already relative
if(isset(oParent))
- jsObj.makeRelativeCoords(oParent, anchorId);
+ if(oParent !== false)
+ jsObj.makeRelativeCoords(oParent, anchorId);
+ else
+ jsObj.makeAbsoluteCoords(anchorId);
saveObjectAfterAnchorAction(obj);
diff --git a/share/frontend/nagvis-js/js/nagvis.js
b/share/frontend/nagvis-js/js/nagvis.js
index 80e6567..4a502f5 100644
--- a/share/frontend/nagvis-js/js/nagvis.js
+++ b/share/frontend/nagvis-js/js/nagvis.js
@@ -1237,6 +1237,9 @@ function dragStop(event, handler) {
oParent.highlight(false);
}
+ if(event.shiftKey)
+ oParent = false;
+
handler(draggingObject, oParent);
oParent = null;
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins