Author: nbelaevski
Date: 2007-03-16 13:16:46 -0400 (Fri, 16 Mar 2007)
New Revision: 87
Modified:
trunk/richfaces-samples/dragDropDemo/src/main/webapp/pages/index.jsp
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-dnd.js
trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js
Log:
DnD fixes and improvements:
- Fixed
http://jira.jboss.com/jira/browse/RF-3
- Drag by dragSupport is started by the first mousemove event, not mousedown
- Slight bug fixes for DnD in tree
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-03-16
15:17:50 UTC (rev 86)
+++
trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/dnd/dnd-draggable.js 2007-03-16
17:16:46 UTC (rev 87)
@@ -4,6 +4,12 @@
*/
DnD.Draggable = function() {};
+DnD.ieReleaseCapture = function() {
+ if (document.releaseCapture) {
+ document.releaseCapture();
+ }
+};
+
DnD.Draggable.prototype = {
getElement: function() {
@@ -100,11 +106,19 @@
}
// cancel out any text selections
- document.body.focus();
+ //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);
+ }
+
},
/**
*
@@ -112,7 +126,12 @@
*/
endDrag: function(event, drag) {
document.onselectstart = this.onSelectStartHandler;
+ document.ondragstart = this.onDragStartHandler;
+ if (document.releaseCapture) {
+ Event.stopObserving(document, "mousemove", DnD.ieReleaseCapture);
+ }
+
var indicator = drag.indicator;
if (indicator) {
indicator.hide();
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-03-16
15:17:50 UTC (rev 86)
+++
trunk/richfaces/drag-drop/src/main/resources/org/richfaces/renderkit/html/scripts/simple-draggable.js 2007-03-16
17:16:46 UTC (rev 87)
@@ -16,6 +16,9 @@
this.eventMouseDown = this.initDrag.bindAsEventListener(this);
+ this.listenDragBound = this.listenDrag.bindAsEventListener(this);
+ this.stopListenDragBound = this.stopListenDrag.bindAsEventListener(this);
+
Event.observe(this.id, "mousedown", this.eventMouseDown);
},
@@ -50,10 +53,31 @@
//this.dragEnter(event);
},
+ ondragend : function(event, drag) {
+ this.dragStarted = false;
+ },
+
getContentType: function() {
return this.options.dragType;
},
+ listenDrag: function(e) {
+ if (!this.dragStarted) {
+ this.startDrag(e);
+
+ Event.stopObserving(this.id, "mousemove", this.listenDragBound);
+ Event.stopObserving(this.id, "mouseup", this.stopListenDragBound);
+ this.dragStarted = true;
+ }
+ },
+
+ stopListenDrag: function(e) {
+ this.dragStarted = false;
+
+ Event.stopObserving(this.id, "mousemove", this.listenDragBound);
+ Event.stopObserving(this.id, "mouseup", this.stopListenDragBound);
+ },
+
initDrag: function(event) {
if(Event.isLeftClick(event)) {
var src = Event.element(event);
@@ -64,7 +88,10 @@
src.tagName=='BUTTON' ||
src.tagName=='TEXTAREA')) return;
- this.startDrag(event);
+ Event.stop(event);
+
+ Event.observe(this.id, "mousemove", this.listenDragBound);
+ Event.observe(this.id, "mouseup", this.stopListenDragBound);
}
}
});
\ No newline at end of file
Modified:
trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item-dnd.js
===================================================================
---
trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item-dnd.js 2007-03-16
15:17:50 UTC (rev 86)
+++
trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item-dnd.js 2007-03-16
17:16:46 UTC (rev 87)
@@ -100,6 +100,10 @@
this.dragEnter(event);
},
+ ondragend : function(event, drag) {
+ this.dragStarted = false;
+ },
+
getDraggableOptions: function() {
var attr = this.elements.icon.attributes["rich:draggableoptions"];
if (attr) {
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-03-16
15:17:50 UTC (rev 86)
+++
trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js 2007-03-16
17:16:46 UTC (rev 87)
@@ -204,6 +204,8 @@
src.tagName=='BUTTON' ||
src.tagName=='TEXTAREA')) return;
+ Event.stop(e);
+
Event.observe(this.elements.icon, "mousemove", this.listenDragBound);
Event.observe(this.elements.text, "mousemove", this.listenDragBound);
@@ -255,6 +257,12 @@
if (!this.dragStarted) {
this.initDrag(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;
}
},
Modified: trunk/richfaces-samples/dragDropDemo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/richfaces-samples/dragDropDemo/src/main/webapp/pages/index.jsp 2007-03-16
15:17:50 UTC (rev 86)
+++ trunk/richfaces-samples/dragDropDemo/src/main/webapp/pages/index.jsp 2007-03-16
17:16:46 UTC (rev 87)
@@ -3,7 +3,7 @@
<%@ taglib
uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"
%>
-<%@ taglib
uri="http://labs.jboss.com/jbossrichfaces/drag-drop"
prefix="dnd" %>
+<%@ taglib
uri="http://richfaces.ajax4jsf.org/drag-drop"
prefix="dnd" %>
<html>
<head>
@@ -189,6 +189,8 @@
<dnd:dndParam name="marker" value="testMarkerValue" />
<dnd:dndParam name="label" value="testDragValue" />
</dnd:dragSupport>
+
+ <h:graphicImage id="dragImage"
value="/images/file-manager.png" width="48" />
<f:verbatim>
dragSupport
</f:verbatim>