classified dd and finalized multi-inheritance
authorMatteo Nastasi <matteo.nastasi@lucinilucini.com>
Mon, 21 Nov 2011 08:43:27 +0000 (09:43 +0100)
committerMatteo Nastasi <matteo.nastasi@lucinilucini.com>
Mon, 21 Nov 2011 08:43:49 +0000 (09:43 +0100)
Doc/xynt_notes.txt [new file with mode: 0644]
mplanner.html
prova.html
test_dd.html [new file with mode: 0644]
xynt-base.js [new file with mode: 0644]
xynt-connect.js [new file with mode: 0644]
xynt-dd.js

diff --git a/Doc/xynt_notes.txt b/Doc/xynt_notes.txt
new file mode 100644 (file)
index 0000000..119d552
--- /dev/null
@@ -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 
index ed5e605..a68fbe6 100644 (file)
@@ -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");
index ccac74a..1355d8f 100644 (file)
@@ -1,10 +1,19 @@
 <html>
 <head>
 <script type="text/javascript" src="commons.js"></script>
+<script type="text/javascript" src="xynt-base.js"></script>
 <script type="text/javascript" src="xynt-dd.js"></script>
 <script type="text/javascript" src="xynt-link.js"></script>
 <script type="text/javascript">
 
+var a = new Array("a", "b", "c", "d");
+a.delete_element(0);
+                 
+console.log(a);
+
+exit;
+
+
 function Adamo() {
     this.name = "adamo";
 }
@@ -127,6 +136,7 @@ Summo.prototype = {
     name: "Summo",
     s_attr: null,
 
+
     c_func: function()
     {
          console.log("c_func overwrited");
@@ -143,44 +153,6 @@ Summo.prototype = {
 
 Extends(Summo, A, B, C);
 
-function Extends(sub)
-{
-    var supers = [];
-
-    thinF = function(){};
-    inh = new thinF();
-
-    console.log("INIZIO EXT");
-
-    var multi = function(sub, super, is_last)
-    {
-        var proto = super.prototype;
-
-        for (var f in proto) {
-            console.log("LOOP: "+f);
-            if( f != "constructor" && typeof(proto[f]) == "function" && !is_last){
-                console.log("PR: "+proto['name']+"  F: "+f);
-                // sub[f] = proto[f];
-                sub[f] = function(){
-                    console.log("INFU PR: " + proto['name'] + " FUNC: "+f);
-                    return proto[f].apply(this,arguments);
-                }
-            }
-            else {
-                console.log("PR: "+proto.name+"  A: "+f+" FUN: "+proto[f]);
-                sub[f] = proto[f];
-            }
-        }
-    }
-
-    for( var i=1; i < arguments.length ; i++){
-        console.log("INIZIO LOOP");
-        multi(inh, arguments[i], false);
-        supers.push(arguments[i].prototype);
-    }
-    multi(inh, sub, true);
-    sub.prototype = inh;
-}
 
 s_ist = new Summo();
 s_ist.s_func();
diff --git a/test_dd.html b/test_dd.html
new file mode 100644 (file)
index 0000000..2b879ae
--- /dev/null
@@ -0,0 +1,175 @@
+<html>
+<head>
+<script type="text/javascript" src="commons.js"></script>
+<script type="text/javascript" src="xynt-base.js"></script>
+<script type="text/javascript" src="xynt-dd.js"></script>
+<script type="text/javascript" src="xynt-link.js"></script>
+<script type="text/javascript">
+  function dropt1()
+  {
+    ; //alert("t1");
+  }
+  window.onload = function() {
+    console.log("HT"+$('t1'));
+    Drag.call($('t1'), dropt1, -1600, 1600, 10,10);
+  }
+</script>
+<!--
+<script type="text/javascript">
+
+function Adamo() {
+    this.name = "adamo";
+}
+
+Adamo.prototype = {
+    alupa: null,
+
+    pname: function()
+    {
+        console.log("NAME: "+this.name);
+    }
+}
+
+function Caino() {
+    this.super.constructor.call(this);
+    this.nname = "caino";
+}
+
+Caino.prototype = {
+    gojira: null,
+
+    pname2: function()
+    {
+        console.log("NAME:  "+this.name);
+        console.log("NNAME: "+this.nname);
+    }
+}
+
+function Extends_simple(sub, super)
+{
+    var thinF = function(){};
+    thinF.prototype = super.prototype;
+    var tmp = new thinF();
+
+    for( var f in sub.prototype) {
+        tmp[f] = sub.prototype[f];
+        tmp['constructor'] = sub;
+    }
+    if( super.prototype.constructor == Object.prototype.constructor ){
+        super.prototype.constructor = super;
+    }
+    tmp['super'] = super.prototype;
+    sub.prototype = tmp;
+}
+
+Extends_simple(Caino, Adamo);
+
+var c = new Caino();
+
+console.log("A "+c.alupa);
+console.log("G "+c.gojira);
+console.log("U "+c.unko);
+
+c.pname();
+c.pname2();
+
+function PreA() {
+    this.a_din = "adamo";
+}
+
+PreA.prototype = {
+    a_attr: "a attr content",
+    name: "PreA",
+
+    a_func: function()
+    {
+        console.log("A_NAME: "+this.a_din);
+        console.log("A_ATTR: "+this.a_attr);
+    }
+}
+
+function A() {
+    PreA.call(this);
+}
+A.prototype = {
+    name: "A"
+}
+Extends(A, PreA);
+
+function B() {
+    this.b_din = "bonobo";
+}
+
+B.prototype = {
+    name: "B",
+    b_attr: "b attr content",
+
+    b_func: function()
+    {
+        console.log("B_NAME: "+this.b_din);
+        console.log("B_ATTR: "+this.b_attr);
+    }
+}
+
+function C() {
+    this.c_din = "canuca";
+}
+
+C.prototype = {
+    name: "C",
+    c_attr: "c attr content",
+
+    c_func: function()
+    {
+        console.log("C_NAME: "+this.c_din);
+        console.log("C_ATTR: "+this.c_attr);
+    }
+}
+
+
+function Summo() {
+    this.s_name = "caino";
+    A.call(this);
+    B.call(this);
+    C.call(this);
+
+}
+
+Summo.prototype = {
+    name: "Summo",
+    s_attr: null,
+
+
+    c_func: function()
+    {
+         console.log("c_func overwrited");
+    },
+
+    s_func: function()
+    {
+         this.a_func();
+         this.b_func();
+         this.c_func();
+         console.log("name: "+this.name);
+    }
+}
+
+Extends(Summo, A, B, C);
+
+
+s_ist = new Summo();
+s_ist.s_func();
+
+</script>
+-->
+
+</head>
+<body>
+<!-- task:begin -->
+<div id="board" style="width: 1600; height: 800px; background-color: #f0f0f0; border: 1px solid black; position: relative;">
+
+  <div id="t1" style="z-index: 1; left: 10px; top: 10px; width: 100px; height: 21px; border: 1px solid gray; background-color: #c0c0ff; position: absolute;"></div>
+  
+</div>
+</body>
+</html>
diff --git a/xynt-base.js b/xynt-base.js
new file mode 100644 (file)
index 0000000..80c9249
--- /dev/null
@@ -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 (file)
index 0000000..e07a940
--- /dev/null
@@ -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
index 253c274..ca20b6d 100644 (file)
  * sometimes fired off the handle, not the root.\r
  **************************************************/\r
 \r
-var Drag = {\r
-\r
-       obj : null,\r
-\r
-       init : function(o, mouseup_cb, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)\r
-       {\r
-           o.onmousedown   = Drag.start;\r
-           o.mouseup_cb    = mouseup_cb;\r
-            o.connect       = function(conn)\r
-            {\r
-                this.parentNode.connected[this.parentNode.connected.length] = conn;\r
-            }\r
-\r
-            o.connected     = new Array();\r
-               /*              alert("agnulla"+o.style.left); */\r
-\r
-               o.hmode                 = bSwapHorzRef ? false : true ;\r
-               o.vmode                 = bSwapVertRef ? false : true ;\r
-\r
-               o.root = oRoot && oRoot != null ? oRoot : o ;\r
-\r
-               if (o.hmode && isNaN(parseInt(o.root.style.left  ))) {\r
-                    var res = parseInt(getStyle(o, "left", "left"));\r
-                   if (isNaN(res)) {\r
-                       o.root.style.left   = "0px";\r
-                   }\r
-                   else {\r
-                       o.root.style.left   = res;\r
-                   }\r
-               }\r
-               if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) {\r
-                    var res = parseInt(getStyle(o, "top", "top"));\r
+function Drag(mouseup_cb, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)\r
+{\r
+    console.log("xx"+this);\r
+    this.onmousedown   = Drag.prototype.start;\r
+    this.mouseup_cb    = mouseup_cb;\r
+    this.connect       = function(conn)\r
+    {\r
+        this.parentNode.connected[this.parentNode.connected.length] = conn;\r
+    }\r
+    \r
+    this.connected     = new Array();\r
+    /*                 alert("agnulla"+this.style.left); */\r
+    \r
+    this.hmode                 = bSwapHorzRef ? false : true ;\r
+    this.vmode                 = bSwapVertRef ? false : true ;\r
+    \r
+    this.root = this.xynt_dom_el && this.xynt_dom_el != null ? this.xynt_dom_el : this ;\r
+    \r
+    if (this.hmode && isNaN(parseInt(this.root.style.left  ))) {\r
+        var res = parseInt(getStyle(o, "left", "left"));\r
                    if (isNaN(res)) {\r
-                       o.root.style.top   = "0px";\r
-                   }\r
-                   else {\r
-                       o.root.style.top   = res;\r
+                       this.root.style.left   = "0px";\r
                    }\r
-               }\r
-               if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";\r
-               if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";\r
-\r
-               o.minX  = typeof minX != 'undefined' ? minX : null;\r
-               o.minY  = typeof minY != 'undefined' ? minY : null;\r
-               o.maxX  = typeof maxX != 'undefined' ? maxX : null;\r
-               o.maxY  = typeof maxY != 'undefined' ? maxY : null;\r
-\r
-               o.xMapper = fXMapper ? fXMapper : null;\r
-               o.yMapper = fYMapper ? fYMapper : null;\r
+       else {\r
+           this.root.style.left   = res;\r
+       }\r
+    }\r
+    if (this.vmode  && isNaN(parseInt(this.root.style.top   ))) {\r
+        var res = parseInt(getStyle(o, "top", "top"));\r
+       if (isNaN(res)) {\r
+           this.root.style.top   = "0px";\r
+       }\r
+       else {\r
+           this.root.style.top   = res;\r
+       }\r
+    }\r
+    if (!this.hmode && isNaN(parseInt(this.root.style.right ))) this.root.style.right  = "0px";\r
+    if (!this.vmode && isNaN(parseInt(this.root.style.bottom))) this.root.style.bottom = "0px";\r
+    \r
+    this.minX  = typeof minX != 'undefined' ? minX : null;\r
+    this.minY  = typeof minY != 'undefined' ? minY : null;\r
+    this.maxX  = typeof maxX != 'undefined' ? maxX : null;\r
+    this.maxY  = typeof maxY != 'undefined' ? maxY : null;\r
+    \r
+    this.xMapper = fXMapper ? fXMapper : null;\r
+    this.yMapper = fYMapper ? fYMapper : null;\r
+    \r
+    this.root.onDragStart      = new Function();\r
+    this.root.onDragEnd        = new Function();\r
+    this.root.onDrag           = new Function();\r
+}\r
+\r
+Drag.prototype = {\r
 \r
-               o.root.onDragStart      = new Function();\r
-               o.root.onDragEnd        = new Function();\r
-               o.root.onDrag           = new Function();\r
-       },\r
+       obj : null,\r
 \r
        start : function(e)\r
        {\r
+            console.log("Drag.start");\r
                var o = Drag.obj = this;\r
-               e = Drag.fixE(e);\r
+               e = Drag.prototype.fixE(e);\r
 \r
                if (!e) \r
                    var e = window.event\r
@@ -125,8 +127,8 @@ var Drag = {
                        if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;\r
                }\r
 \r
-               document.onmousemove    = Drag.drag;\r
-               document.onmouseup      = Drag.end;\r
+               document.onmousemove    = Drag.prototype.drag;\r
+               document.onmouseup      = Drag.prototype.end;\r
 \r
             for(var i = 0 ; i < o.connected.length ; i++) {\r
                 o.connected[i].update('start', o);\r
@@ -137,7 +139,7 @@ var Drag = {
 \r
        drag : function(e)\r
        {\r
-               e = Drag.fixE(e);\r
+               e = Drag.prototype.fixE(e);\r
                var o = Drag.obj;\r
 \r
                var ey  = e.clientY;\r
@@ -173,7 +175,7 @@ var Drag = {
 \r
        end : function(e)\r
        {\r
-               e = Drag.fixE(e);\r
+               e = Drag.prototype.fixE(e);\r
                var o = Drag.obj;\r
 \r
                o.style.zIndex = o.oldzidx;\r