From 0306e71dc1b093adfe745948419154c248619b59 Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Fri, 11 Nov 2011 09:15:15 +0100 Subject: [PATCH] first commit --- commons.js | 89 +++++++++++++++++++++ img/arrow_do.png | Bin 0 -> 250 bytes img/arrow_le.png | Bin 0 -> 233 bytes img/arrow_ri.png | Bin 0 -> 249 bytes img/arrow_up.png | Bin 0 -> 237 bytes mplanner.html | 72 +++++++++++++++++ xynt-dd.js | 200 +++++++++++++++++++++++++++++++++++++++++++++++ xynt-link.js | 90 +++++++++++++++++++++ 8 files changed, 451 insertions(+) create mode 100644 commons.js create mode 100644 img/arrow_do.png create mode 100644 img/arrow_le.png create mode 100644 img/arrow_ri.png create mode 100644 img/arrow_up.png create mode 100644 mplanner.html create mode 100644 xynt-dd.js create mode 100644 xynt-link.js diff --git a/commons.js b/commons.js new file mode 100644 index 0000000..f3ea07c --- /dev/null +++ b/commons.js @@ -0,0 +1,89 @@ + function $(id) { return document.getElementById(id); } + + /* replacement of setInterval on IE */ +(function(){ + /*if not IE, do nothing*/ + if(!document.uniqueID){return;}; + + /*Copy the default setInterval behavior*/ + var nativeSetInterval = window.setInterval; + window.setInterval = function(fn,ms) { + var param = []; + if(arguments.length <= 2) { + return nativeSetInterval(fn,ms); + } + else { + for(var i=2;i_E)Q!3HEdXMMW?q!^2X+?^QKos)S9rMq>1fP(BLp1!W^x4F65b=lYd)tm|xk}PqJC~?lu z%}vcKVQ?-=O)N=GQ7F$W$xv|j^bH7a0aXcewJIL!*qxqzT%zjz m{;HCkA8Hq~bUE*29F@DDD_U5>w0r|is literal 0 HcmV?d00001 diff --git a/img/arrow_le.png b/img/arrow_le.png new file mode 100644 index 0000000000000000000000000000000000000000..c910177a66286c48a035751e623172ac84ce6629 GIT binary patch literal 233 zcmeAS@N?(olHy`uVBq!ia0vp^tU%1p!3HD`EN_1Yq!^2X+?^QKos)S9rMq>1fP(BLp1!W^x4F65b>&V^YYYVnNtU=qlsM<- z=BDPAFgO>bCYGe8D3oWGWGJ|M`UZqI@`(c#xp=xbhHzZZJ-d;&!9alJV5PI48}AX5 z7x`^rFFF}!9`R79Tzr|Wdg0`m@7H`3wC2-U+TA5AeNFQ0{FMq5cI?{IepX_yeR)5B U@UuwcexP{_p00i_>zopr0DF5%=>Px# literal 0 HcmV?d00001 diff --git a/img/arrow_ri.png b/img/arrow_ri.png new file mode 100644 index 0000000000000000000000000000000000000000..9506d7acca39aef0a5a0539c807681e9a9ea49ea GIT binary patch literal 249 zcmeAS@N?(olHy`uVBq!ia0vp^tU%1p!3HD`EN_1Yq!^2X+?^QKos)S9rMq>1fP(BLp1!W^x4GGcR5(xWN&Ep6k}PqJC~?lu z%}vcKVQ?-=O)N=GQ7F$W$xv|j^bH7a2Q!ee$Trbiw?KgbvE7F&vr0w!`vP7 mB5XH2Xg7bBE&p*31E0b=(dk^1Ti*c9XYh3Ob6Mw<&;$T-(^3Nf literal 0 HcmV?d00001 diff --git a/img/arrow_up.png b/img/arrow_up.png new file mode 100644 index 0000000000000000000000000000000000000000..a3bb57140c5534aa27d013961cbcec89c24fe9dd GIT binary patch literal 237 zcmeAS@N?(olHy`uVBq!ia0vp^>_E)Q!3HEdXMMW?q!^2X+?^QKos)S9rMq>1fP(BLp1!W^x4F65b#<5>FI)u*NtU=qlsM<- z=BDPAFgO>bCYGe8D3oWGWGJ|M`UZqI@`(c#d3d@whHzZ>J+qOw!9c+I;&hWKZ=6mR zoivJUom8u#lp)iZo%6arcH-;3hr1`O`{&SoT`cBWBe%5NoE_P31Qjf=-ENaLE=b$X Y@Ag9AtB=8?CZL%Np00i_>zopr0Q7}TTmS$7 literal 0 HcmV?d00001 diff --git a/mplanner.html b/mplanner.html new file mode 100644 index 0000000..2fc0ef3 --- /dev/null +++ b/mplanner.html @@ -0,0 +1,72 @@ + + + + + + + + + + +
+
+
+
+ +
+
+ +
+ + + + + + +
+ + + +
+ + diff --git a/xynt-dd.js b/xynt-dd.js new file mode 100644 index 0000000..b07fbe1 --- /dev/null +++ b/xynt-dd.js @@ -0,0 +1,200 @@ +/* + * brisk - dom-drag.js + * + * Copyright (C) 2006-2011 Matteo Nastasi + * mailto: nastasi@alternativeoutput.it + * matteo.nastasi@milug.org + * web: http://www.alternativeoutput.it + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. You should have received a + * copy of the GNU General Public License along with this program; if + * not, write to the Free Software Foundation, Inc, 59 Temple Place - + * Suite 330, Boston, MA 02111-1307, USA. + * + */ + +/************************************************** + * dom-drag.js + * 09.25.2001 + * www.youngpup.net + ************************************************** + * 10.28.2001 - fixed minor bug where events + * sometimes fired off the handle, not the root. + **************************************************/ + +var Drag = { + + obj : null, + + init : function(o, mouseup_cb, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper) + { + o.onmousedown = Drag.start; + o.mouseup_cb = mouseup_cb; + o.connected = new Array(); + /* alert("agnulla"+o.style.left); */ + + o.hmode = bSwapHorzRef ? false : true ; + o.vmode = bSwapVertRef ? false : true ; + + o.root = oRoot && oRoot != null ? oRoot : o ; + + if (o.hmode && isNaN(parseInt(o.root.style.left ))) { + var res = parseInt(getStyle(o, "left", "left")); + if (isNaN(res)) { + o.root.style.left = "0px"; + } + else { + o.root.style.left = res; + } + } + if (o.vmode && isNaN(parseInt(o.root.style.top ))) { + var res = parseInt(getStyle(o, "top", "top")); + if (isNaN(res)) { + o.root.style.top = "0px"; + } + else { + o.root.style.top = res; + } + } + if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right = "0px"; + if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px"; + + o.minX = typeof minX != 'undefined' ? minX : null; + o.minY = typeof minY != 'undefined' ? minY : null; + o.maxX = typeof maxX != 'undefined' ? maxX : null; + o.maxY = typeof maxY != 'undefined' ? maxY : null; + + o.xMapper = fXMapper ? fXMapper : null; + o.yMapper = fYMapper ? fYMapper : null; + + o.root.onDragStart = new Function(); + o.root.onDragEnd = new Function(); + o.root.onDrag = new Function(); + }, + + start : function(e) + { + var o = Drag.obj = this; + e = Drag.fixE(e); + + if (!e) + var e = window.event + // handle event + e.cancelBubble = true; + if (e.stopPropagation) + e.stopPropagation(); + + o.oldzidx = o.style.zIndex; + o.style.zIndex = 10; + + // alert("start"); + + var y = parseInt(o.vmode ? o.root.style.top : o.root.style.bottom); + var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right ); + o.root.onDragStart(x, y); + + o.lastMouseX = e.clientX; + o.lastMouseY = e.clientY; + + if (o.hmode) { + if (o.minX != null) o.minMouseX = e.clientX - x + o.minX; + if (o.maxX != null) o.maxMouseX = o.minMouseX + o.maxX - o.minX; + } else { + if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x; + if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x; + } + + if (o.vmode) { + if (o.minY != null) o.minMouseY = e.clientY - y + o.minY; + if (o.maxY != null) o.maxMouseY = o.minMouseY + o.maxY - o.minY; + } else { + if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y; + if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y; + } + + document.onmousemove = Drag.drag; + document.onmouseup = Drag.end; + + for(var i = 0 ; i < o.connected.length ; i++) { + o.connected[i].update('start', o); + } + + return false; + }, + + drag : function(e) + { + e = Drag.fixE(e); + var o = Drag.obj; + + var ey = e.clientY; + var ex = e.clientX; + var y = parseInt(o.vmode ? o.root.style.top : o.root.style.bottom); + var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right ); + var nx, ny; + + if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX); + if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX); + if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY); + if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY); + + nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1)); + ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1)); + + if (o.xMapper) nx = o.xMapper(y) + else if (o.yMapper) ny = o.yMapper(x) + + Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px"; + Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px"; + Drag.obj.lastMouseX = ex; + Drag.obj.lastMouseY = ey; + + Drag.obj.root.onDrag(nx, ny); + + for(var i = 0 ; i < o.connected.length ; i++) { + o.connected[i].update('drag', o); + } + + return false; + }, + + end : function(e) + { + e = Drag.fixE(e); + var o = Drag.obj; + + o.style.zIndex = o.oldzidx; + // alert("END"); + if (o.mouseup_cb != null) { + if (o.mouseup_cb(o) == 1) { + o.onmousedown = null; + } + } + + document.onmousemove = null; + document.onmouseup = null; + Drag.obj.root.onDragEnd( parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), + parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"])); + for(var i = 0 ; i < o.connected.length ; i++) { + o.connected[i].update('end', o); + } + + Drag.obj = null; + }, + + 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; + } +}; diff --git a/xynt-link.js b/xynt-link.js new file mode 100644 index 0000000..da15cbe --- /dev/null +++ b/xynt-link.js @@ -0,0 +1,90 @@ +function tasks_link(o, anc, a, b, type) { + var cur; + this.o = o; + this.anc = anc; + this.beg = document.createElement("div"); + this.end = document.createElement("div"); + this.arr = document.createElement("img"); + this.arr.style.position = "absolute"; + o.appendChild(this.arr); + for (var i = 0 ; i < 2 ; i++) { + cur = i == 0 ? this.beg : this.end; + cur.style.width = '5px'; + cur.style.height = '5px'; + cur.style.backgroundColor = 'gray'; + cur.style.visibility = 'inherit'; + cur.style.zIndex = 20; + cur.style.position = 'absolute'; + o.appendChild(cur); + // alert("gugu"); + } + + this.a = a; + this.b = b; + this.type = type; + + if (typeof(a.connected) != 'object') + return null; + + if (typeof(b.connected) != 'object') + return null; + + for (var i = 0 ; i < 2 ; i++) { + cur = (i == 0 ? a : b); + cur.connected[cur.connected.length++] = this; + for( ; cur.parentNode != null && cur.parentNode != anc ; cur = cur.parentNode) { + cur.parentNode.connected[cur.parentNode.connected.length++] = this; + } + } + this.update() +} + +tasks_link.prototype = { + a: null, + b: null, + type: null, + + update: function(method, obj) + { + /* + if (method == 'end') { + if (this.o.style.visibility == 'visible') + this.o.style.visibility = 'hidden'; + else + this.o.style.visibility = 'visible'; + } + */ + + // FIXME you need to user the width of the border instead of +2 + this.beg.style.left = (parseInt(this.a.style.left) + parseInt(this.a.style.width) + 2 + parseInt(this.a.parentNode.style.left))+"px"; + this.beg.style.top = (parseInt(this.a.style.top) + parseInt(((parseInt(this.a.style.height) + 2) / 2)) + parseInt(this.a.parentNode.style.top))+"px"; + this.beg.style.width = (parseInt(this.b.style.left) - (parseInt(this.a.style.left) + 2 + parseInt(this.b.style.width) + 2)+ parseInt(this.b.parentNode.style.left) + 5)+"px"; + this.beg.style.height = "1px"; + + this.end.style.left = (parseInt(this.beg.style.left) + parseInt(this.beg.style.width))+"px"; + this.arr.style.left = (parseInt(this.end.style.left) - 3)+"px"; + /* this.end.style.left = (parseInt(this.b.style.left) + parseInt(this.b.parentNode.style.left))+"px"; + this.end.style.top = (parseInt(this.b.style.top) + parseInt(this.b.parentNode.style.top))+"px"; */ + endpty = parseInt(this.b.style.top) + parseInt(this.b.parentNode.style.top)+10; + this.end.style.width = "1px"; + + if (parseInt(this.beg.style.top) < endpty) { + this.end.style.top = this.beg.style.top; + this.end.style.height = (parseInt(this.b.style.top) + parseInt(this.b.parentNode.style.top) - ((parseInt(this.a.style.top) + parseInt(this.a.parentNode.style.top))) ) - 11 +"px"; + this.arr.style.top = (parseInt(this.end.style.top) + parseInt(this.end.style.height) - 5)+"px"; + this.arr.src = "img/arrow_do.png"; + } + else { + this.end.style.top = (parseInt(this.b.style.top) + parseInt(this.b.parentNode.style.top) + 23)+"px"; + this.end.style.height = (parseInt(this.a.style.top) + parseInt(this.a.parentNode.style.top) - ((parseInt(this.b.style.top) + parseInt(this.b.parentNode.style.top))) ) - 11 +"px"; + + this.arr.style.top = this.end.style.top; + this.arr.src = "img/arrow_up.png"; + } + + + this.o.style.visibility = "visible"; + + console.log("met: " + method + " obj: " + (obj == this.a ? "Obj A" : (obj == this.b ? "Obj B" : "Other")) ); + } +} -- 2.17.1