X-Git-Url: http://mop.ddnsfree.com/gitweb/?p=xynt.git;a=blobdiff_plain;f=xynt-dd.js;h=ca20b6d06524f12f0d24ca85113f513030749b41;hp=253c27431867fea63e91cc46f553bd76359dcf81;hb=4450618fd580a5491bafcc9d1238dd89e501f9cf;hpb=50efdc4b283f3cb7dadbfc032a87e85f74faa2c7 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;