removed CR from end of lines of xynt-dd.js
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.com>
Wed, 7 Dec 2011 07:44:54 +0000 (08:44 +0100)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.com>
Wed, 7 Dec 2011 07:44:54 +0000 (08:44 +0100)
xynt-dd.js

index 0444a5c..f9eec36 100644 (file)
-/*\r
- *  brisk - dom-drag.js\r
- *\r
- *  Copyright (C) 2006-2011 Matteo Nastasi\r
- *                          mailto: nastasi@alternativeoutput.it \r
- *                                  matteo.nastasi@milug.org\r
- *                          web: http://www.alternativeoutput.it\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful, but\r
- * WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * General Public License for more details. You should have received a\r
- * copy of the GNU General Public License along with this program; if\r
- * not, write to the Free Software Foundation, Inc, 59 Temple Place -\r
- * Suite 330, Boston, MA 02111-1307, USA.\r
- *\r
- */\r
-\r
-/**************************************************\r
- * dom-drag.js\r
- * 09.25.2001\r
- * www.youngpup.net\r
- **************************************************\r
- * 10.28.2001 - fixed minor bug where events\r
- * sometimes fired off the handle, not the root.\r
- **************************************************/\r
-\r
-function xynt_dd(mouseup_cb, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)\r
-{\r
-    xynt_connect.call(this);\r
-\r
-    this.onmousedown   = xynt_dd.prototype.start;\r
-    this.mouseup_cb    = mouseup_cb;\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
-           this.root.style.left   = "0px";\r
-       }\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
-xynt_dd.prototype = {\r
-\r
-    obj : null,\r
-\r
-    start : function(e)\r
-    {\r
-       var o = xynt_dd.obj = this;\r
-       e = xynt_dd.prototype.fixE(e);\r
-\r
-        if (!e) \r
-            var e = window.event\r
-       // handle event\r
-       e.cancelBubble = true;\r
-       if (e.stopPropagation) \r
-            e.stopPropagation();\r
-\r
-       o.oldzidx = o.style.zIndex;\r
-       o.style.zIndex = 10;\r
-\r
-       var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);\r
-       var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );\r
-       o.root.onDragStart(x, y);\r
-\r
-       o.lastMouseX    = e.clientX;\r
-       o.lastMouseY    = e.clientY;\r
-\r
-       if (o.hmode) {\r
-           if (o.minX != null) o.minMouseX     = e.clientX - x + o.minX;\r
-           if (o.maxX != null) o.maxMouseX     = o.minMouseX + o.maxX - o.minX;\r
-       } else {\r
-           if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;\r
-           if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;\r
-       }\r
-\r
-       if (o.vmode) {\r
-           if (o.minY != null) o.minMouseY     = e.clientY - y + o.minY;\r
-           if (o.maxY != null) o.maxMouseY     = o.minMouseY + o.maxY - o.minY;\r
-       } else {\r
-           if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;\r
-           if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;\r
-       }\r
-\r
-        // console.log("assign");\r
-       document.onmousemove    = xynt_dd.prototype.drag;\r
-       document.onmouseup      = xynt_dd.prototype.end;\r
-\r
-        for(var i = 0 ; i < o.xynt_conn_ected.length ; i++) {\r
-            o.xynt_conn_ected[i].xynt_conn_update('start', o);\r
-        }\r
-\r
-       return false;\r
-    },\r
-\r
-    drag : function(e)\r
-    {\r
-        e = xynt_dd.prototype.fixE(e);\r
-       var o = xynt_dd.obj;\r
-        \r
-       var ey  = e.clientY;\r
-       var ex  = e.clientX;\r
-       var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);\r
-       var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );\r
-       var nx, ny;\r
-\r
-       if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);\r
-       if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);\r
-       if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);\r
-       if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);\r
-        \r
-       nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));\r
-       ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));\r
-\r
-       if (o.xMapper)          nx = o.xMapper(y)\r
-       else if (o.yMapper)     ny = o.yMapper(x)\r
-\r
-       xynt_dd.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";\r
-       xynt_dd.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";\r
-       xynt_dd.obj.lastMouseX  = ex;\r
-       xynt_dd.obj.lastMouseY  = ey;\r
-\r
-       xynt_dd.obj.root.onDrag(nx, ny);\r
-        \r
-        console.log("pre call it"+o.xynt_conn_ected.length);\r
-        for(var i = 0 ; i < o.xynt_conn_ected.length ; i++) {\r
-            console.log("call it");\r
-            o.xynt_conn_ected[i].xynt_conn_update('drag', o);\r
-        }\r
-        \r
-       return false;\r
-    },\r
-\r
-    end : function(e)\r
-    {\r
-       e = xynt_dd.prototype.fixE(e);\r
-       var o = xynt_dd.obj;\r
-\r
-       o.style.zIndex = o.oldzidx;\r
-       if (o.mouseup_cb != null) {\r
-           if (o.mouseup_cb(o) == 1) {\r
-               o.onmousedown = null;\r
-           }\r
-       }\r
-\r
-       document.onmousemove = null;\r
-       document.onmouseup   = null;\r
-       xynt_dd.obj.root.onDragEnd(     parseInt(xynt_dd.obj.root.style[xynt_dd.obj.hmode ? "left" : "right"]), \r
-                                       parseInt(xynt_dd.obj.root.style[xynt_dd.obj.vmode ? "top" : "bottom"]));\r
-        for(var i = 0 ; i < o.xynt_conn_ected.length ; i++) {\r
-            o.xynt_conn_ected[i].xynt_conn_update('end', o);\r
-        }\r
-\r
-       xynt_dd.obj = null;\r
-    },\r
-\r
-    fixE : function(e)\r
-    {\r
-       if (typeof e == 'undefined') e = window.event;\r
-       if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;\r
-       if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;\r
-       return e;\r
-    }\r
-};\r
-\r
+/*
+ *  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.
+ **************************************************/
+
+function xynt_dd(mouseup_cb, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
+{
+    xynt_connect.call(this);
+
+    this.onmousedown   = xynt_dd.prototype.start;
+    this.mouseup_cb    = mouseup_cb;
+
+    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)) {
+           this.root.style.left   = "0px";
+       }
+       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();
+}
+
+xynt_dd.prototype = {
+
+    obj : null,
+
+    start : function(e)
+    {
+       var o = xynt_dd.obj = this;
+       e = xynt_dd.prototype.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;
+
+       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;
+       }
+
+        // console.log("assign");
+       document.onmousemove    = xynt_dd.prototype.drag;
+       document.onmouseup      = xynt_dd.prototype.end;
+
+        for(var i = 0 ; i < o.xynt_conn_ected.length ; i++) {
+            o.xynt_conn_ected[i].xynt_conn_update('start', o);
+        }
+
+       return false;
+    },
+
+    drag : function(e)
+    {
+        e = xynt_dd.prototype.fixE(e);
+       var o = xynt_dd.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)
+
+       xynt_dd.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
+       xynt_dd.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
+       xynt_dd.obj.lastMouseX  = ex;
+       xynt_dd.obj.lastMouseY  = ey;
+
+       xynt_dd.obj.root.onDrag(nx, ny);
+        
+        console.log("pre call it"+o.xynt_conn_ected.length);
+        for(var i = 0 ; i < o.xynt_conn_ected.length ; i++) {
+            console.log("call it");
+            o.xynt_conn_ected[i].xynt_conn_update('drag', o);
+        }
+        
+       return false;
+    },
+
+    end : function(e)
+    {
+       e = xynt_dd.prototype.fixE(e);
+       var o = xynt_dd.obj;
+
+       o.style.zIndex = o.oldzidx;
+       if (o.mouseup_cb != null) {
+           if (o.mouseup_cb(o) == 1) {
+               o.onmousedown = null;
+           }
+       }
+
+       document.onmousemove = null;
+       document.onmouseup   = null;
+       xynt_dd.obj.root.onDragEnd(     parseInt(xynt_dd.obj.root.style[xynt_dd.obj.hmode ? "left" : "right"]), 
+                                       parseInt(xynt_dd.obj.root.style[xynt_dd.obj.vmode ? "top" : "bottom"]));
+        for(var i = 0 ; i < o.xynt_conn_ected.length ; i++) {
+            o.xynt_conn_ected[i].xynt_conn_update('end', o);
+        }
+
+       xynt_dd.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;
+    }
+};
+
 Extends(xynt_dd, xynt_connect);
\ No newline at end of file