Author: abelevich
Date: 2010-11-24 13:48:24 -0500 (Wed, 24 Nov 2010)
New Revision: 20161
Added:
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-draggable.js
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-droppable.js
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-indicator.js
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-manager.js
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/indicator.ecss
sandbox/trunk/ui/drag-drop/ui/src/main/templates/
sandbox/trunk/ui/drag-drop/ui/src/main/templates/dragIndicator.template.xml
Removed:
sandbox/trunk/ui/drag-drop/ui/src/main/config/
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-dnd.js
Modified:
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DragBehavior.java
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DropBehavior.java
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragBehaviorRendererBase.java
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java
Log:
implement client behavior dnd, fix bug with indicator remove
Modified:
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DragBehavior.java
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DragBehavior.java 2010-11-24
18:45:07 UTC (rev 20160)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DragBehavior.java 2010-11-24
18:48:24 UTC (rev 20161)
@@ -23,11 +23,8 @@
package org.richfaces.component.behavior;
-import javax.faces.render.RenderKitFactory;
-
import org.ajax4jsf.component.behavior.ClientBehavior;
import org.richfaces.cdk.annotations.JsfBehavior;
-import org.richfaces.cdk.annotations.JsfBehaviorRenderer;
import org.richfaces.cdk.annotations.Tag;
import org.richfaces.cdk.annotations.TagType;
@@ -37,15 +34,40 @@
*/
@JsfBehavior(
- id = DragBehavior.BEHAVIOR_ID, renderer =
@JsfBehaviorRenderer(renderKitId=RenderKitFactory.HTML_BASIC_RENDER_KIT,
type=DropBehavior.BEHAVIOR_ID), tag = @Tag(name = "dragBehavior", handler =
"org.richfaces.view.facelets.html.CustomBehaviorHandler", type =
TagType.Facelets)
+ id = DragBehavior.BEHAVIOR_ID, tag = @Tag(name = "dragBehavior", handler =
"org.richfaces.view.facelets.html.CustomBehaviorHandler", type =
TagType.Facelets)
)
public class DragBehavior extends ClientBehavior {
public static final String BEHAVIOR_ID =
"org.richfaces.component.behavior.DragBehavior";
-
+
+ enum PropertyKeys {
+ type, indicator;
+ }
+
+
+ public void setIndicator(String indicator) {
+ getStateHelper().put(PropertyKeys.indicator, indicator);
+ }
+
+ public String getIndicator() {
+ return (String)getStateHelper().get(PropertyKeys.indicator);
+ }
+
+ public void setType(String type) {
+ getStateHelper().put(PropertyKeys.type, type);
+ }
+
+ public String getType() {
+ return (String)getStateHelper().eval(PropertyKeys.type);
+ }
+
@Override
public void setLiteralAttribute(String name, Object value) {
-
+ if(compare(PropertyKeys.type, name)) {
+ setType((String)value);
+ } else if(compare(PropertyKeys.indicator, name)){
+ setIndicator((String)value);
+ }
}
public String getEvent() {
Modified:
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DropBehavior.java
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DropBehavior.java 2010-11-24
18:45:07 UTC (rev 20160)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DropBehavior.java 2010-11-24
18:48:24 UTC (rev 20161)
@@ -23,12 +23,13 @@
package org.richfaces.component.behavior;
-import javax.faces.render.RenderKitFactory;
+import java.util.Set;
+
import org.ajax4jsf.component.behavior.ClientBehavior;
import org.richfaces.cdk.annotations.JsfBehavior;
-import org.richfaces.cdk.annotations.JsfBehaviorRenderer;
import org.richfaces.cdk.annotations.Tag;
import org.richfaces.cdk.annotations.TagType;
+import org.richfaces.renderkit.util.CoreAjaxRendererUtils;
/**
* @author abelevich
@@ -36,14 +37,29 @@
*/
@JsfBehavior(
- id = DropBehavior.BEHAVIOR_ID, renderer =
@JsfBehaviorRenderer(renderKitId=RenderKitFactory.HTML_BASIC_RENDER_KIT,
type=DropBehavior.BEHAVIOR_ID), tag = @Tag(name = "dropBehavior", handler =
"org.richfaces.view.facelets.html.CustomBehaviorHandler", type =
TagType.Facelets))
+ id = DropBehavior.BEHAVIOR_ID, tag = @Tag(name = "dropBehavior", handler =
"org.richfaces.view.facelets.html.CustomBehaviorHandler", type =
TagType.Facelets)
+)
public class DropBehavior extends ClientBehavior {
public static final String BEHAVIOR_ID =
"org.richfaces.component.behavior.DropBehavior";
+ enum PropertyKeys {
+ acceptType
+ }
+ public void setAcceptType(Set<String> acceptType) {
+ getStateHelper().put(PropertyKeys.acceptType, acceptType);
+ }
+
+ public Set<String> getAcceptType() {
+ return (Set<String>)getStateHelper().eval(PropertyKeys.acceptType);
+ }
+
@Override
public void setLiteralAttribute(String name, Object value) {
+ if(compare(PropertyKeys.acceptType, name)) {
+ setAcceptType(CoreAjaxRendererUtils.asSimpleSet(value));
+ }
}
@Override
Modified:
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragBehaviorRendererBase.java
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragBehaviorRendererBase.java 2010-11-24
18:45:07 UTC (rev 20160)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragBehaviorRendererBase.java 2010-11-24
18:48:24 UTC (rev 20161)
@@ -22,33 +22,83 @@
package org.richfaces.renderkit;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
import javax.faces.component.behavior.ClientBehavior;
import javax.faces.component.behavior.ClientBehaviorContext;
+import javax.faces.context.FacesContext;
import javax.faces.render.ClientBehaviorRenderer;
+import javax.faces.render.FacesBehaviorRenderer;
import javax.faces.render.RenderKitFactory;
-import org.richfaces.cdk.annotations.JsfBehaviorRenderer;
-import org.richfaces.component.behavior.DropBehavior;
+import org.ajax4jsf.javascript.JSFunction;
+import org.richfaces.component.behavior.DragBehavior;
+import org.richfaces.renderkit.util.RendererUtils;
/**
* @author abelevich
*
*/
-(a)JsfBehaviorRenderer(renderKitId=RenderKitFactory.HTML_BASIC_RENDER_KIT,
type=DropBehavior.BEHAVIOR_ID)
+@FacesBehaviorRenderer(rendererType = DragBehavior.BEHAVIOR_ID, renderKitId =
RenderKitFactory.HTML_BASIC_RENDER_KIT)
+
@ResourceDependencies({
@ResourceDependency(name = "jquery.js"),
- @ResourceDependency(name = "jquery-ui-core.js"),
- @ResourceDependency(name = "jquery-dnd.js"),
- @ResourceDependency(name = "richfaces.js"),
- @ResourceDependency(name = "richfaces-dnd.js")
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"jquery-ui-core.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"jquery-dnd.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"dnd-draggable.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"dnd-manager.js")
})
public class DragBehaviorRendererBase extends ClientBehaviorRenderer {
+
+ private static final RendererUtils UTILS = RendererUtils.getInstance();
+
@Override
public String getScript(ClientBehaviorContext behaviorContext, ClientBehavior
behavior) {
- return "DragBehavior encoded";
+ UIComponent parent = behaviorContext.getComponent();
+ JSFunction function = new
JSFunction("RichFaces.ui.DnDManager.draggable");
+ function.addParameter(parent.getClientId(behaviorContext.getFacesContext()));
+ function.addParameter(getOptions(behaviorContext, behavior));
+ return function.toString();
}
+
+ public Map<String, Object> getOptions(ClientBehaviorContext
clientBehaviorContext, ClientBehavior behavior) {
+ Map<String, Object> options = new HashMap<String, Object>();
+
+ if(behavior instanceof DragBehavior) {
+ DragBehavior dragBehavior = (DragBehavior)behavior;
+ options.put("indicator",
getDragIndicatorClientId(clientBehaviorContext, dragBehavior));
+ options.put("type", dragBehavior.getType());
+ }
+
+ return options;
+ }
+
+ public String getDragIndicatorClientId(ClientBehaviorContext clientBehaviorContext,
DragBehavior dragBehavior) {
+ String indicatorId = dragBehavior.getIndicator();
+
+ if(indicatorId != null) {
+ FacesContext facesContext = clientBehaviorContext.getFacesContext();
+ UIComponent clientBehaviorHolder = clientBehaviorContext.getComponent();
+ UIComponent indicator = getUtils().findComponentFor(facesContext,
clientBehaviorHolder, indicatorId);
+
+ if(indicator != null) {
+ indicatorId = indicator.getClientId(facesContext);
+ }
+
+ }
+
+ return indicatorId;
+ }
+
+ public RendererUtils getUtils() {
+ return UTILS;
+ }
+
}
Modified:
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java 2010-11-24
18:45:07 UTC (rev 20160)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java 2010-11-24
18:48:24 UTC (rev 20161)
@@ -22,30 +22,58 @@
package org.richfaces.renderkit;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
import javax.faces.component.behavior.ClientBehavior;
import javax.faces.component.behavior.ClientBehaviorContext;
import javax.faces.render.ClientBehaviorRenderer;
+import javax.faces.render.FacesBehaviorRenderer;
+import javax.faces.render.RenderKitFactory;
+import org.ajax4jsf.javascript.JSFunction;
+import org.richfaces.component.behavior.DropBehavior;
+
/**
* @author abelevich
*
*/
+
+@FacesBehaviorRenderer(rendererType = DropBehavior.BEHAVIOR_ID, renderKitId =
RenderKitFactory.HTML_BASIC_RENDER_KIT)
+
@ResourceDependencies({
@ResourceDependency(name = "jquery.js"),
- @ResourceDependency(name = "jquery-ui-core.js"),
- @ResourceDependency(name = "jquery-dnd.js"),
- @ResourceDependency(name = "richfaces.js"),
- @ResourceDependency(name = "richfaces-dnd.js")
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"jquery-ui-core.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"jquery-dnd.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"dnd-droppable.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"dnd-manager.js")
})
public class DropBehaviorRendererBase extends ClientBehaviorRenderer {
@Override
public String getScript(ClientBehaviorContext behaviorContext, ClientBehavior
behavior) {
- return "DropBehavior encoded";
+ UIComponent parent = behaviorContext.getComponent();
+ JSFunction function = new
JSFunction("RichFaces.ui.DnDManager.droppable");
+ function.addParameter(parent.getClientId(behaviorContext.getFacesContext()));
+ function.addParameter(getOptions(behaviorContext, behavior));
+ return function.toString();
}
+ public Map<String, Object> getOptions(ClientBehaviorContext behaviorContext,
ClientBehavior behavior) {
+ Map<String, Object> options = new HashMap<String, Object>();
+
+ if(behavior instanceof DropBehavior) {
+ DropBehavior dropBehavior = (DropBehavior)behavior;
+ options.put("acceptType", dropBehavior.getAcceptType());
+ }
+
+ return options;
+ }
}
Added:
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-draggable.js
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-draggable.js
(rev 0)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-draggable.js 2010-11-24
18:48:24 UTC (rev 20161)
@@ -0,0 +1,58 @@
+(function ($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ rf.ui.Draggable = function(id, options) {
+ this.dragElement = $(document.getElementById(id));
+ this.dragElement.draggable({addClasses: false});
+
+ if(options.indicator) {
+ var element = document.getElementById(options.indicator);
+ this.indicator = rf.$(options.indicator);
+ this.dragElement.draggable("option", "helper", function(){return
element});
+ } else {
+ this.dragElement.draggable("option", "helper", 'clone');
+ }
+
+ this.options = options;
+
+ this.dragElement.data('type', this.options.type);
+ this.dragElement.data('indicator', this.indicator);
+ this.dragElement.data("init", true);
+
+ this.dragElement.bind('dragstart', $.proxy(this.dragStart, this));
+ this.dragElement.bind('drag', $.proxy(this.drag, this));
+ this.dragElement.bind('dragstop', $.proxy(this.dragStop, this));
+ };
+
+ var defaultOptions = {
+ };
+
+ $.extend(rf.ui.Draggable.prototype, ( function () {
+ return {
+ dragStart: function(e, ui) {
+ if(ui.helper && this.indicator) {
+ ui.helper.show();
+ }
+ },
+
+ drag: function(e, ui) {
+ var helper = ui.helper;
+ if(this.indicator) {
+ helper.addClass(this.indicator.draggingClass());
+ }
+ },
+
+ dragStop: function(e, ui){
+ if(ui.helper && this.indicator) {
+ ui.helper.hide();
+ }
+
+ if(ui.helper[0] != this.dragElement[0]) {
+ //ugly fix to prevent remove custom indicator from DOM tree. see jQuery
draggable._clear method for details
+ ui.helper[0] = this.dragElement[0];
+ }
+ }
+ }
+ })());
+})(jQuery, window.RichFaces);
Added:
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-droppable.js
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-droppable.js
(rev 0)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-droppable.js 2010-11-24
18:48:24 UTC (rev 20161)
@@ -0,0 +1,69 @@
+(function ($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ rf.ui.Droppable = function(id, options) {
+ this.options = options;
+ this.dropElement = $(document.getElementById(id));
+
+ this.dropElement.droppable({addClasses: false});
+ this.dropElement.droppable("option", "hoverClass",
'rf-drop-hover');
+ this.dropElement.droppable("option", "activeClass",
'rf-drop-highlight');
+ this.dropElement.data("init", true);
+ this.dropElement.bind('drop', $.proxy(this.drop, this));
+ this.dropElement.bind('dropover', $.proxy(this.dropover, this));
+ this.dropElement.bind('dropout', $.proxy(this.dropout, this));
+ };
+
+ $.extend(rf.ui.Droppable.prototype, ( function () {
+ return {
+ drop: function(e, ui) {
+ var dragElement = ui.draggable;
+ var helper = ui.helper;
+ var indicator = rf.$(helper.attr("id"));
+ if(indicator) {
+ helper.removeClass(indicator.acceptClass());
+ helper.removeClass(indicator.rejectClass());
+ }
+ },
+
+ dropover: function(event, ui) {
+ var draggable = ui.draggable;
+ var helper = ui.helper;
+ var indicator = rf.$(helper.attr("id"));
+ if(indicator) {
+ if(this.accept(draggable)) {
+ helper.removeClass(indicator.rejectClass());
+ helper.addClass(indicator.acceptClass());
+ } else {
+ helper.removeClass(indicator.acceptClass());
+ helper.addClass(indicator.rejectClass());
+ }
+ }
+ },
+
+ dropout: function(event, ui) {
+ var draggable = ui.draggable;
+ var helper = ui.helper;
+ var indicator = rf.$(helper.attr("id"));
+ if(indicator) {
+ helper.removeClass(indicator.acceptClass());
+ helper.removeClass(indicator.rejectClass());
+ }
+ },
+
+ accept: function(draggable) {
+ var accept;
+ var acceptType = draggable.data("type");
+ if(acceptType) {
+ $.each(this.options.acceptType, function() {
+ accept = (acceptType == this); return !(accept);
+ });
+ }
+
+ return accept;
+ }
+ }
+ })());
+
+})(jQuery, window.RichFaces);
\ No newline at end of file
Added:
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-indicator.js
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-indicator.js
(rev 0)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-indicator.js 2010-11-24
18:48:24 UTC (rev 20161)
@@ -0,0 +1,48 @@
+(function ($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ rf.ui.DragIndicator = function(id, options) {
+ $super.constructor.call(this, id);
+ this.attachToDom(id);
+
+ this.indicator = $(document.getElementById(id));
+ this.options = options;
+ };
+
+ var defaultOptions = {
+ };
+
+ rf.BaseComponent.extend(rf.ui.DragIndicator);
+ var $super = rf.ui.DragIndicator.$super;
+
+ $.extend(rf.ui.DragIndicator.prototype, ( function () {
+ return {
+ show : function() {
+ this.indicator.show();
+ },
+
+ hide: function() {
+ this.indicator.hide();
+ },
+
+ acceptClass: function() {
+ return this.options.acceptClass;
+ },
+
+ rejectClass: function() {
+ return this.options.rejectClass;
+ },
+
+ draggingClass: function() {
+ return this.options.draggingClass;
+ },
+
+ getElement: function() {
+ return this.indicator;
+ }
+ }
+ })());
+
+})(jQuery, window.RichFaces);
+
Added:
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-manager.js
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-manager.js
(rev 0)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-manager.js 2010-11-24
18:48:24 UTC (rev 20161)
@@ -0,0 +1,27 @@
+(function ($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ rf.ui.DnDManager = rf.ui.DnDManager || {};
+
+ $.extend(rf.ui.DnDManager, ( function () {
+ var draggables = {};
+ var droppables = {};
+
+ return {
+ draggable: function(id, options) {
+ var draggable = draggables[id];
+ if(!draggable) {
+ draggables[id] = new rf.ui.Draggable(id, options);
+ }
+ },
+
+ droppable: function(id, options) {
+ var droppable = droppables[id];
+ if(!droppable) {
+ droppables[id] = new rf.ui.Droppable(id, options);
+ }
+ }
+ }
+ })());
+})(jQuery, window.RichFaces);
\ No newline at end of file
Added:
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/indicator.ecss
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/indicator.ecss
(rev 0)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/indicator.ecss 2010-11-24
18:48:24 UTC (rev 20161)
@@ -0,0 +1,30 @@
+.rf-ind{
+ height:50px;
+ width:50px;
+ border:1px dotted red;
+ background-color:blue
+}
+
+.rf-ind-acpt{
+ height:50px;
+ width:50px;
+ border:1px dotted red;
+ background-color:green;
+}
+
+.rf-ind-rejt{
+ height:50px;
+ width:50px;
+ border:1px dotted green;
+ background-color:red;
+}
+
+.rf-drp-hvr{
+}
+
+.rf-drp-hvr{
+}
+
+.rf-drp-hlight{
+}
+
Deleted:
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-dnd.js
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-dnd.js 2010-11-24
18:45:07 UTC (rev 20160)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-dnd.js 2010-11-24
18:48:24 UTC (rev 20161)
@@ -1,140 +0,0 @@
-(function ($, rf) {
-
- rf.ui = rf.ui || {};
-
- rf.ui.indicator = function(id, options) {
- this.indicator = $(document.getElementById(id));
- };
-
- var defaultOptions = {
- };
-
- $.extend(rf.ui.indicator.prototype, ( function () {
- return {
- show : function() {
- this.indicator.show();
- },
-
- hide: function() {
- this.indicator.hide();
- },
-
- getDomElement: function() {
- return this.indicator[0];
- }
- }
- })());
-
-})(jQuery, window.RichFaces);
-
-
-
-(function ($, rf) {
-
- rf.ui = rf.ui || {};
-
- rf.ui.draggable = function(id, options) {
- this.dragElement = $(document.getElementById(id));
- this.indicator = new rf.ui.indicator(options.indicator, {});
-
- this.options = options;
-
- this.dragElement.draggable({addClasses: false});
- this.dragElement.draggable("option", "helper",
$.proxy(this.indicator.getDomElement, this.indicator));
- this.dragElement.data('acceptType', this.options.acceptType);
- this.dragElement.data('indicator',
$(document.getElementById(options.indicator)));
-
- this.dragElement.bind('dragstart', $.proxy(this.dragStart, this));
- this.dragElement.bind('drag', $.proxy(this.drag, this));
- this.dragElement.bind('dragstop', $.proxy(this.dragStop, this));
- };
-
-
- var defaultOptions = {
- };
-
- $.extend(rf.ui.draggable.prototype, ( function () {
- return {
-
- dragStart: function(e, ui) {
- ui.helper.show();
- },
-
- drag: function(e, ui) {
- ui.helper.removeClass("ui-draggable-dragging")
- ui.helper.addClass("rf-ind-dragging");
- },
-
- dragStop: function(e, ui){
- ui.helper.hide();
- }
- }
- })());
-
-})(jQuery, window.RichFaces);
-
-
-
-(function ($, rf) {
-
- rf.ui = rf.ui || {};
-
- rf.ui.droppable = function(id, options) {
- this.options = options;
- this.dropElement = $(document.getElementById(id));
- this.dropElement.droppable({addClasses: false});
- this.dropElement.droppable("option", "hoverClass",
'rf-drop-hover');
- this.dropElement.droppable("option", "activeClass",
'rf-drop-highlight' );
-
- this.dropElement.bind('drop', $.proxy(this.drop, this));
- this.dropElement.bind('dropover', $.proxy(this.dropover, this));
- this.dropElement.bind('dropout', $.proxy(this.dropout, this));
- };
-
- $.extend(rf.ui.droppable.prototype, ( function () {
- return {
- drop: function(e, ui) {
- var draggable = ui.draggable;
- var indicator = draggable.data("indicator");
- indicator.removeClass("rf-accept");
- indicator.removeClass("rf-reject");
- if(this.accept(draggable)) {
- draggable.detach();
- draggable.appendTo(this.dropElement);
- }
- },
-
- dropover: function(event, ui) {
- var draggable = ui.draggable;
- var indicator = draggable.data("indicator");
- if(this.accept(draggable)) {
- indicator.removeClass("rf-reject");
- indicator.addClass("rf-accept");
- } else {
- indicator.removeClass("rf-accept");
- indicator.addClass("rf-reject");
- }
- },
-
- dropout: function(event, ui) {
- var draggable = ui.draggable;
- var indicator = draggable.data("indicator");
- indicator.removeClass("rf-accept");
- indicator.removeClass("rf-reject");
- },
-
- accept: function(draggable) {
- var accept;
- var acceptType = draggable.data("acceptType");
-
- $.each(this.options.acceptTypes, function() {
- accept = (acceptType == this);
- return !(accept);
- });
-
- return accept;
- }
- }
- })());
-
-})(jQuery, window.RichFaces);
\ No newline at end of file
Added: sandbox/trunk/ui/drag-drop/ui/src/main/templates/dragIndicator.template.xml
===================================================================
--- sandbox/trunk/ui/drag-drop/ui/src/main/templates/dragIndicator.template.xml
(rev 0)
+++ sandbox/trunk/ui/drag-drop/ui/src/main/templates/dragIndicator.template.xml 2010-11-24
18:48:24 UTC (rev 20161)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+JBoss, Home of Professional Open Source
+Copyright ${year}, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+-->
+<cdk:root
xmlns="http://jboss.org/schema/richfaces/cdk/xhtml-el"
xmlns:cdk="http://jboss.org/schema/richfaces/cdk/core"
+
xmlns:c="http://jboss.org/schema/richfaces/cdk/jstl/core"
xmlns:cc="http://jboss.org/schema/richfaces/cdk/jsf/composite"
+
xmlns:javaee="http://java.sun.com/xml/ns/javaee">
+
+ <cc:interface>
+ <cdk:class>org.richfaces.renderkit.html.DragIndicatorRenderer</cdk:class>
+ <cdk:superclass>org.richfaces.renderkit.DragIndicatorRendererBase</cdk:superclass>
+ <cdk:component-family>org.richfaces.DragIndicator</cdk:component-family>
+ <cdk:renderer-type>org.richfaces.DragIndicatorRenderer</cdk:renderer-type>
+ </cc:interface>
+
+ <cc:implementation>
+ <div id="#{clientId}" class="rf-ind
#{component.attributes['styleClass']}" style="display: none;">
+ <cdk:scriptObject name="options">
+ <cdk:scriptOption name="acceptClass"
value="#{concatClasses('rf-ind-acpt',
component.attributes['acceptClass'])}"/>
+ <cdk:scriptOption name="rejectClass"
value="#{concatClasses('rf-ind-rejt',
component.attributes['rejectClass'])}"/>
+ <cdk:scriptOption name="draggingClass"
value="#{concatClasses('rf-ind-drag',
component.attributes['draggingClass'])}"/>
+ </cdk:scriptObject>
+ <script type="text/javascript">
+ new RichFaces.ui.DragIndicator("#{clientId}", #{toScriptArgs(options)});
+ </script>
+ </div>
+ </cc:implementation>
+</cdk:root>
\ No newline at end of file