Skip to content

Commit

Permalink
Add highlightColor and effects bindings and AjaxOptions to AjaxSortab…
Browse files Browse the repository at this point in the history
…leList.

highlightColor will create a start effect and a endeffect that change the background color of the moved element.
  • Loading branch information
spelletier committed Jan 18, 2016
1 parent f0e52d8 commit 3ff2963
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Frameworks/Ajax/Ajax/Components/AjaxSortableList.api
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,9 @@
<validation message="'index' must be bound to a settable value">
<unsettable name="index"/>
</validation>
<binding name="highlightColor"/>
<binding name="starteffect"/>
<binding name="endeffect"/>
<binding name="reverteffect"/>
</wo>
</wodefinitions>
24 changes: 24 additions & 0 deletions Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxSortableList.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
* @binding handle if an element should only be draggable by an embedded handle, takes a class name
* @binding hoverclass
* @binding ghosting shows ghosting copy during drag, defaults to <code>false</code>
* @binding highlightColor a CSS color used to change the element background color when it is moved.
* @binding starteffect Effect, defaults to Effect.Opacity. Defines the effect
* to use when the draggable starts being dragged
* @binding reverteffect Effect, default to Effect.Move. Defines the effect to
* use when the draggable reverts back to its starting position
* @binding endeffect Effect, defaults to Effect.Opacity. Defines the effect to
* use when the draggable stops being dragged
* @binding dropOnEmpty
* @binding scroll
* @binding onChange client side method, fires on updating the sort order during drag
Expand Down Expand Up @@ -134,12 +141,29 @@ public NSDictionary createAjaxOptions() {
ajaxOptionsArray.addObject(new AjaxOption("handle", AjaxOption.STRING));
ajaxOptionsArray.addObject(new AjaxOption("hoverclass", AjaxOption.STRING));
ajaxOptionsArray.addObject(new AjaxOption("ghosting", AjaxOption.BOOLEAN));
ajaxOptionsArray.addObject(new AjaxOption("starteffect", starteffect(), AjaxOption.SCRIPT));
ajaxOptionsArray.addObject(new AjaxOption("reverteffect", AjaxOption.SCRIPT));
ajaxOptionsArray.addObject(new AjaxOption("endeffect", endeffect(), AjaxOption.SCRIPT));
ajaxOptionsArray.addObject(new AjaxOption("dropOnEmpty", AjaxOption.BOOLEAN));
ajaxOptionsArray.addObject(new AjaxOption("scroll", AjaxOption.BOOLEAN));
ajaxOptionsArray.addObject(new AjaxOption("onChange", AjaxOption.SCRIPT));
NSMutableDictionary options = AjaxOption.createAjaxOptionsDictionary(ajaxOptionsArray, this);
return options;
}

private String starteffect() {
if (hasBinding("highlightColor")) {
return "function(element){element.style.backgroundColor = '"+valueForBinding("highlightColor")+"';}";
}
return null;
}

private String endeffect() {
if (hasBinding("highlightColor")) {
return "function(element){element.style.backgroundColor = '';}";
}
return null;
}

public String onUpdate() {
StringBuilder onUpdateBuffer = new StringBuilder();
Expand Down

0 comments on commit 3ff2963

Please sign in to comment.