From 871b91b471434aef56e421888bae1146dd74c990 Mon Sep 17 00:00:00 2001 From: "ctrlaltca@gmail.com" <> Date: Thu, 2 Feb 2012 14:20:09 +0000 Subject: Added some dirty js code to get dropcontainer-relative offset for onDrop events of draggable controls --- .../source/prado/activecontrols/dragdrop.js | 28 ++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'framework') diff --git a/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js b/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js index 107269f2..efec6a69 100755 --- a/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js @@ -22,12 +22,36 @@ Object.extend(Prado.WebUI.DropContainer.prototype, { var elementId=dragElement.id.replace(/clone_/,""); var req = new Prado.CallbackRequest(this.options.EventTarget, this.options); + var curleft = curtop = 0; + var obj = dropElement; + if (obj.offsetParent) { + curleft = obj.offsetLeft + curtop = obj.offsetTop + while (obj = obj.offsetParent) { + curleft += obj.offsetLeft + curtop += obj.offsetTop + } + } + var scrOfX = 0, scrOfY = 0; + if( typeof( window.pageYOffset ) == 'number' ) { + //Netscape compliant + scrOfY = window.pageYOffset; + scrOfX = window.pageXOffset; + } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { + //DOM compliant + scrOfY = document.body.scrollTop; + scrOfX = document.body.scrollLeft; + } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { + //IE6 standards compliant mode + scrOfY = document.documentElement.scrollTop; + scrOfX = document.documentElement.scrollLeft; + } req.setCallbackParameter({ DragElementID : elementId, ScreenX : event.screenX, ScreenY : event.screenY, - OffsetX : event.offsetX, - OffsetY : event.offsetY, + OffsetX : event.offsetX || event.clientX - curleft + scrOfX, + OffsetY : event.offsetY || event.clientY - curtop + scrOfY, ClientX : event.clientX, ClientY : event.clientY, AltKey : event.altKey, -- cgit v1.2.3