From 4450618fd580a5491bafcc9d1238dd89e501f9cf Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Mon, 21 Nov 2011 09:43:27 +0100 Subject: [PATCH] classified dd and finalized multi-inheritance --- Doc/xynt_notes.txt | 6 ++ mplanner.html | 16 ++--- prova.html | 48 +++---------- test_dd.html | 175 +++++++++++++++++++++++++++++++++++++++++++++ xynt-base.js | 49 +++++++++++++ xynt-connect.js | 9 +++ xynt-dd.js | 114 ++++++++++++++--------------- 7 files changed, 315 insertions(+), 102 deletions(-) create mode 100644 Doc/xynt_notes.txt create mode 100644 test_dd.html create mode 100644 xynt-base.js create mode 100644 xynt-connect.js diff --git a/Doc/xynt_notes.txt b/Doc/xynt_notes.txt new file mode 100644 index 0000000..119d552 --- /dev/null +++ b/Doc/xynt_notes.txt @@ -0,0 +1,6 @@ +xynt_dom_el: if an object had a part that must be showed into the DOM the + root element is assigned to this pre-definited class variable. + +xynt_sup_cl: array of all super classes of the current class + +xynt_sup: array of all super classes prototypes of the current class diff --git a/mplanner.html b/mplanner.html index ed5e605..a68fbe6 100644 --- a/mplanner.html +++ b/mplanner.html @@ -43,15 +43,15 @@ function dropr4() window.onload = function () { // window.setTimeout(exchange, 2000); - Drag.init($('t1'), dropr1, $('t1'), -1600, 1600, 10,10); - Drag.init($('t2'), dropr2, $('t2'), -1600, 1600, 10,10); - Drag.init($('t3'), dropr1, $('t3'), -1600, 1600, 10,10); - Drag.init($('t4'), dropr2, $('t4'), -1600, 1600, 10,10); + Drag.call($('t1'), dropr1, -1600, 1600, 10,10); + Drag.call($('t2'), dropr2, -1600, 1600, 10,10); + Drag.call($('t3'), dropr1, -1600, 1600, 10,10); + Drag.call($('t4'), dropr2, -1600, 1600, 10,10); - Drag.init($('r1'), dropr1, $('r1'), 0,0, -900,900); - Drag.init($('r2'), dropr2, $('r2'), 0,0, -900,900); - Drag.init($('r3'), dropr3, $('r3'), 0,0, -900,900); - Drag.init($('r4'), dropr4, $('r4'), 0,0, -900,900); + Drag.call($('r1'), dropr1, 0,0, -900,900); + Drag.call($('r2'), dropr2, 0,0, -900,900); + Drag.call($('r3'), dropr3, 0,0, -900,900); + Drag.call($('r4'), dropr4, 0,0, -900,900); l = new tasks_link($('board'), $('t1'), $('t2'), "ss"); l = new tasks_link($('board'), $('t3'), $('t4'), "ss"); diff --git a/prova.html b/prova.html index ccac74a..1355d8f 100644 --- a/prova.html +++ b/prova.html @@ -1,10 +1,19 @@ + + + + + + + + + + +
+ +
+ +
+ + diff --git a/xynt-base.js b/xynt-base.js new file mode 100644 index 0000000..80c9249 --- /dev/null +++ b/xynt-base.js @@ -0,0 +1,49 @@ +function Extends(sub) +{ + var proto; + thinF = function(){}; + inh = new thinF(); + inh.xynt_sup = []; + inh.xynt_sup_cl = []; + + console.log("INIZIO EXT"); + + var multi = function(sub, super, is_last) + { + var proto = super.prototype; + + for (var f in proto) { + if (f == "xynt_sup" || f == "xynt_sup_cl") + continue; + + console.log("LOOP: "+f); + if( f != "constructor" && typeof(proto[f]) == "function" && !is_last){ + console.log("M_FU: "+proto['name']+" F: "+f); + // sub[f] = proto[f]; + sub[f] = function(){ + console.log("INFU PR: " + proto['name'] + " FUNC: "+f+" THIS: " + this); + return proto[f].apply(this,arguments); + } + } + else { + console.log("M_PR: "+proto.name+" A: "+f+" FUN: "+proto[f]); + sub[f] = proto[f]; + } + } + } + + for( var i=1; i < arguments.length ; i++){ + multi(inh, arguments[i], false); + inh.xynt_sup.push(arguments[i].prototype); + inh.xynt_sup_cl.push(arguments[i]); + } + + multi(inh, sub, true); + inh.super = function(cl, method) { + return this.xynt_sup_cl[cl].method.apply(this,arguments); + } + sub.prototype = inh; + + console.log(sub.prototype.xynt_sup); + console.log(sub.prototype.xynt_sup_cl); +} diff --git a/xynt-connect.js b/xynt-connect.js new file mode 100644 index 0000000..e07a940 --- /dev/null +++ b/xynt-connect.js @@ -0,0 +1,9 @@ +function xynt_connect_init(obj) +{ + obj.xynt_conn__connected = new Array(); +} + +function xynt_connect_impl(obj) +{ + +} \ No newline at end of file diff --git a/xynt-dd.js b/xynt-dd.js index 253c274..ca20b6d 100644 --- a/xynt-dd.js +++ b/xynt-dd.js @@ -30,65 +30,67 @@ * 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.connect = function(conn) - { - this.parentNode.connected[this.parentNode.connected.length] = conn; - } - - 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")); +function Drag(mouseup_cb, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper) +{ + console.log("xx"+this); + this.onmousedown = Drag.prototype.start; + this.mouseup_cb = mouseup_cb; + this.connect = function(conn) + { + this.parentNode.connected[this.parentNode.connected.length] = conn; + } + + this.connected = new Array(); + /* alert("agnulla"+this.style.left); */ + + this.hmode = bSwapHorzRef ? false : true ; + this.vmode = bSwapVertRef ? false : true ; + + this.root = this.xynt_dom_el && this.xynt_dom_el != null ? this.xynt_dom_el : this ; + + if (this.hmode && isNaN(parseInt(this.root.style.left ))) { + var res = parseInt(getStyle(o, "left", "left")); if (isNaN(res)) { - o.root.style.top = "0px"; - } - else { - o.root.style.top = res; + this.root.style.left = "0px"; } - } - 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; + else { + this.root.style.left = res; + } + } + if (this.vmode && isNaN(parseInt(this.root.style.top ))) { + var res = parseInt(getStyle(o, "top", "top")); + if (isNaN(res)) { + this.root.style.top = "0px"; + } + else { + this.root.style.top = res; + } + } + if (!this.hmode && isNaN(parseInt(this.root.style.right ))) this.root.style.right = "0px"; + if (!this.vmode && isNaN(parseInt(this.root.style.bottom))) this.root.style.bottom = "0px"; + + this.minX = typeof minX != 'undefined' ? minX : null; + this.minY = typeof minY != 'undefined' ? minY : null; + this.maxX = typeof maxX != 'undefined' ? maxX : null; + this.maxY = typeof maxY != 'undefined' ? maxY : null; + + this.xMapper = fXMapper ? fXMapper : null; + this.yMapper = fYMapper ? fYMapper : null; + + this.root.onDragStart = new Function(); + this.root.onDragEnd = new Function(); + this.root.onDrag = new Function(); +} + +Drag.prototype = { - o.root.onDragStart = new Function(); - o.root.onDragEnd = new Function(); - o.root.onDrag = new Function(); - }, + obj : null, start : function(e) { + console.log("Drag.start"); var o = Drag.obj = this; - e = Drag.fixE(e); + e = Drag.prototype.fixE(e); if (!e) var e = window.event @@ -125,8 +127,8 @@ var Drag = { if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y; } - document.onmousemove = Drag.drag; - document.onmouseup = Drag.end; + document.onmousemove = Drag.prototype.drag; + document.onmouseup = Drag.prototype.end; for(var i = 0 ; i < o.connected.length ; i++) { o.connected[i].update('start', o); @@ -137,7 +139,7 @@ var Drag = { drag : function(e) { - e = Drag.fixE(e); + e = Drag.prototype.fixE(e); var o = Drag.obj; var ey = e.clientY; @@ -173,7 +175,7 @@ var Drag = { end : function(e) { - e = Drag.fixE(e); + e = Drag.prototype.fixE(e); var o = Drag.obj; o.style.zIndex = o.oldzidx; -- 2.17.1