[richfaces-svn-commits] JBoss Rich Faces SVN: r532 - in trunk/richfaces: drag-drop/src/main/resources/org/richfaces/renderkit/html/scripts and 1 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Tue Apr 24 13:46:45 EDT 2007
Author: nbelaevski
Date: 2007-04-24 13:46:45 -0400 (Tue, 24 Apr 2007)
New Revision: 532
Modified:
trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/dnd/dnd-draggable.js
trunk/richfaces/drag-drop/src/main/resources/org/richfaces/renderkit/html/scripts/simple-draggable.js
trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js
Log:
http://jira.jboss.com/jira/browse/RF-75 fixed
Modified: trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/dnd/dnd-draggable.js
===================================================================
--- trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/dnd/dnd-draggable.js 2007-04-24 17:46:15 UTC (rev 531)
+++ trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/dnd/dnd-draggable.js 2007-04-24 17:46:45 UTC (rev 532)
@@ -80,54 +80,80 @@
},
startDrag : function(event) {
- var type = this.getContentType();
+ var contentType = this.getContentType();
- if (type) {
-
- var indicator = this.getIndicator();
- var drag = new DnD.Drag(this, indicator, type);
-
- if (indicator.id.indexOf("_rfDefaultDragIndicator") != -1) {
- var target = drag.source.getElement();
- var offSets = Position.cumulativeOffset(target);
- indicator.indicatorWidth = Element.getWidth(target);
- indicator.indicatorHeight = Element.getHeight(target);
- indicator.position(offSets[0], offSets[1]);
- indicator.removalX = Event.pointerX(event) - offSets[0];
- indicator.removalY = Event.pointerY(event) - offSets[1];
+ if (contentType) {
+ if (typeof this.lastDragX == "undefined" || typeof this.lastDragY == "undefined") {
+ this.lastDragX = Event.pointerX(event);
+ this.lastDragY = Event.pointerY(event);
+
+ // prevent text selection in IE
+ this.onSelectStartHandler = document.onselectstart;
+ this.onDragStartHandler = document.ondragstart;
+
+ document.onselectstart = function () { return false; };
+ document.ondragstart = function () { DnD.ieReleaseCapture(); return false; };
+
+ if (document.releaseCapture) {
+ Event.observe(document, "mousemove", DnD.ieReleaseCapture);
+ }
+
+ return false;
+ } else {
+ var x = Event.pointerX(event);
+ var y = Event.pointerY(event);
+
+ if ((Math.abs(this.lastDragX - x) + Math.abs(this.lastDragY - y)) > 3) {
+ this.updateDrag(event);
+
+ return true;
+ }
+
+ return false;
}
+ } else {
+ return true;
+ }
+ },
+
+ updateDrag : function(event) {
+ var type = this.getContentType();
+ var indicator = this.getIndicator();
+ var drag = new DnD.Drag(this, indicator, type);
- DnD.startDrag(drag);
- DnD.updateDrag(event);
- this.ondragstart(event, drag);
- if (indicator) {
- indicator.show();
- }
+ if (indicator.id.indexOf("_rfDefaultDragIndicator") != -1) {
+ var target = drag.source.getElement();
+ var offSets = Position.cumulativeOffset(target);
+ indicator.indicatorWidth = Element.getWidth(target);
+ indicator.indicatorHeight = Element.getHeight(target);
+ indicator.position(offSets[0], offSets[1]);
+ indicator.removalX = Event.pointerX(event) - offSets[0];
+ indicator.removalY = Event.pointerY(event) - offSets[1];
+ }
+
+ DnD.startDrag(drag);
+ DnD.updateDrag(event);
+ this.ondragstart(event, drag);
+ if (indicator) {
+ indicator.show();
+ }
- if( this.options && this.options.ondragstart) {
- this.options.ondragstart();
- }
+ if( this.options && this.options.ondragstart) {
+ this.options.ondragstart();
+ }
// cancel out any text selections
//document.body.focus();
- // prevent text selection in IE
- this.onSelectStartHandler = document.onselectstart;
- this.onDragStartHandler = document.ondragstart;
-
- document.onselectstart = function () { return false; };
- document.ondragstart = function () { DnD.ieReleaseCapture(); return false; };
-
- if (document.releaseCapture) {
- Event.observe(document, "mousemove", DnD.ieReleaseCapture);
- }
- }
},
/**
*
* @param {DnD.Drag} drag
*/
endDrag: function(event, drag) {
+ this.lastDragX = undefined;
+ this.lastDragY = undefined;
+
document.onselectstart = this.onSelectStartHandler;
document.ondragstart = this.onDragStartHandler;
@@ -139,6 +165,7 @@
if (indicator) {
indicator.hide();
}
+
this.ondragend(event, drag);
if( this.options && this.options.ondragend) {
Modified: trunk/richfaces/drag-drop/src/main/resources/org/richfaces/renderkit/html/scripts/simple-draggable.js
===================================================================
--- trunk/richfaces/drag-drop/src/main/resources/org/richfaces/renderkit/html/scripts/simple-draggable.js 2007-04-24 17:46:15 UTC (rev 531)
+++ trunk/richfaces/drag-drop/src/main/resources/org/richfaces/renderkit/html/scripts/simple-draggable.js 2007-04-24 17:46:45 UTC (rev 532)
@@ -57,17 +57,15 @@
},
listenDrag: function(e) {
- if (!this.dragStarted) {
- this.startDrag(e);
-
+ if (this.startDrag(e)) {
Event.stopObserving(this.id, "mousemove", this.listenDragBound);
Event.stopObserving(this.id, "mouseup", this.stopListenDragBound);
- this.dragStarted = true;
+ //this.dragStarted = true;
}
},
stopListenDrag: function(e) {
- this.dragStarted = false;
+ //this.dragStarted = false;
Event.stopObserving(this.id, "mousemove", this.listenDragBound);
Event.stopObserving(this.id, "mouseup", this.stopListenDragBound);
Modified: trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js
===================================================================
--- trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js 2007-04-24 17:46:15 UTC (rev 531)
+++ trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js 2007-04-24 17:46:45 UTC (rev 532)
@@ -283,16 +283,12 @@
},
listenDrag: function(e) {
- if (!this.dragStarted) {
- this.initDrag(e);
-
+ if (this.startDrag(e)) {
Event.stopObserving(this.elements.icon, "mousemove", this.listenDragBound);
Event.stopObserving(this.elements.text, "mousemove", this.listenDragBound);
Event.stopObserving(this.elements.icon, "mouseup", this.stopListenDragBound);
Event.stopObserving(this.elements.text, "mouseup", this.stopListenDragBound);
-
- this.dragStarted = true;
}
},
@@ -301,16 +297,10 @@
this.fireSelectEvent();
}
- this.dragStarted = false;
-
Event.stopObserving(this.elements.icon, "mousemove", this.listenDragBound);
Event.stopObserving(this.elements.text, "mousemove", this.listenDragBound);
Event.stopObserving(this.elements.icon, "mouseup", this.stopListenDragBound);
Event.stopObserving(this.elements.text, "mouseup", this.stopListenDragBound);
- },
-
- initDrag: function(event) {
- this.startDrag(event);
}
}
More information about the richfaces-svn-commits
mailing list