org.odlabs.wiquery.ui.resizable
Class ResizableAjaxBehavior

java.lang.Object
  extended by org.apache.wicket.behavior.Behavior
      extended by org.apache.wicket.behavior.AbstractAjaxBehavior
          extended by org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
              extended by org.odlabs.wiquery.core.behavior.WiQueryAbstractAjaxBehavior
                  extended by org.odlabs.wiquery.ui.resizable.ResizableAjaxBehavior
All Implemented Interfaces:
Serializable, org.apache.wicket.behavior.IBehaviorListener, org.apache.wicket.IClusterable, org.apache.wicket.IComponentAwareEventSink, org.apache.wicket.IRequestListener, org.apache.wicket.markup.html.IComponentAwareHeaderContributor, IWiQueryPlugin

public abstract class ResizableAjaxBehavior
extends WiQueryAbstractAjaxBehavior

$Id: ResizableAjaxBehavior

Sets the attached component resizable. When the resized of the component is done, onResize(int, int, AjaxRequestTarget) is called with Ajax.

This behavior contains a ResizableBehavior which is used to control the options of the resizable, including all the options and event of the behavior. Example:

 ResizableAjaxBehavior resizable = new ResizableAjaxBehavior() {
                public void onResize(int height, int width, AjaxRequestTarget ajaxRequestTarget) {
                        ...
                }
 }
 ResizableBehavior rb = resizable.getResizableBehavior();
 rb.setAnimeDuration(new ResizableAnimeDuration(500));
 rb.setGhost(true);
 add(resizable);
 

Since:
1.0
Author:
Julien Roche
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
INDICATOR
 
Fields inherited from interface org.apache.wicket.behavior.IBehaviorListener
INTERFACE
 
Constructor Summary
ResizableAjaxBehavior()
          Default constructor
 
Method Summary
 JsStatement destroy()
          Method to destroy This will return the element back to its pre-init state.
 void destroy(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
          Method to destroy within the ajax request
 JsStatement disable()
          Method to disable
 void disable(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
          Method to disable within the ajax request
 JsStatement enable()
          Method to enable
 void enable(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
          Method to enable within the ajax request
 ResizableAlsoResize getAlsoResizeComplex()
           
 ResizableAnimeDuration getAnimateDuration()
           
 String getAnimateEasing()
           
 ResizableAspectRatio getAspectRatio()
           
protected  CharSequence getCallbackScript()
          We override super method to add height and width parameters to the URL.
 String getCancel()
           
 ResizableContainment getContainment()
           
 int getDelay()
           
 int getDistance()
           
 ICollectionItemOptions getGrid()
           
 ResizableHandles getHandles()
           
 String getHelper()
           
 int getMaxHeight()
          Returns the component's max height.
 int getMaxWidth()
          Returns the component's max width.
 int getMinHeight()
          Returns the component's min height.
 int getMinWidth()
          Returns the component's max width.
 ResizableBehavior getResizableBehavior()
           
 boolean isAnimate()
           
 boolean isAutoHide()
           
 boolean isDisabled()
           
 boolean isGhost()
           
protected  void onBind()
           
 void onResize(org.apache.wicket.ajax.AjaxRequestTarget target)
          For framework internal use only.
abstract  void onResize(int height, int width, org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
          onResize is triggered at the end of a resize operation.
protected  void respond(org.apache.wicket.ajax.AjaxRequestTarget target)
          onDrop is called back when the drop event has been fired.
 ResizableAjaxBehavior setAlsoResize(ResizableAlsoResize alsoResize)
          Resize these elements synchronous when resizing.
 ResizableAjaxBehavior setAnimate(boolean animate)
          Animates to the final size after resizing.
 ResizableAjaxBehavior setAnimateDuration(ResizableAnimeDuration animeDuration)
          Sets the duration time for animating, in milliseconds.
 ResizableAjaxBehavior setAnimateEasing(String easing)
          Sets the easing effect for animating.
 ResizableAjaxBehavior setAspectRatio(ResizableAspectRatio aspectRatio)
          If set to true, resizing is constrained by the original aspect ratio.
 ResizableAjaxBehavior setAutoHide(boolean autoHide)
          If set to true, automatically hides the handles except when the mouse hovers over the element.
 ResizableAjaxBehavior setCancel(String cancel)
          Prevents resizing if you start on elements matching the selector.
 ResizableAjaxBehavior setContainment(ResizableContainment containment)
          Sets the constrains resizing to within the bounds of the specified element.
 ResizableAjaxBehavior setDelay(int delay)
          Sets the tolerance, in milliseconds, for when resizing should start.
 ResizableAjaxBehavior setDisabled(boolean disabled)
          Disables (true) or enables (false) the resizable.
 ResizableAjaxBehavior setDistance(int distance)
          Sets the tolerance, in pixels, for when resizing should start.
 ResizableAjaxBehavior setGhost(boolean ghost)
          Set to true, a semi-transparent helper element is shown for resizing.
 ResizableAjaxBehavior setGrid(int x, int y)
          Snaps the resizing element to a grid, every x and y pixels.
 ResizableAjaxBehavior setHandles(ResizableHandles handles)
          If specified as a string, should be a comma-split list of any of the following: 'n, e, s, w, ne, se, sw, nw, all'.
 ResizableAjaxBehavior setHelper(String helper)
          Sets the css class that will be added to a proxy element to outline the resize during the drag of the resize handle.
 ResizableAjaxBehavior setMaxHeight(int maxHeight)
          Sets the component's max height.
 ResizableAjaxBehavior setMaxWidth(int maxWidth)
          Sets the window's max width.
 ResizableAjaxBehavior setMinHeight(int minHeight)
          Sets the component's min height.
 ResizableAjaxBehavior setMinWidth(int minWidth)
          Sets the component's min width.
 JsStatement statement()
          Returns the main JsStatement used to create the plugin.
 JsStatement widget()
          Method to returns the .ui-resizable element
 void widget(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
          Method to returns the .ui-resizable element within the ajax request
 
Methods inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
findIndicatorId, generateCallbackScript, getAjaxCallDecorator, getChannel, getChannelName, getFailureScript, getPreconditionScript, getSuccessScript, onRequest, renderHead, throttleScript
 
Methods inherited from class org.apache.wicket.behavior.AbstractAjaxBehavior
afterRender, bind, getCallbackUrl, getComponent, getStatelessHint, onComponentRendered, onComponentTag, onComponentTag
 
Methods inherited from class org.apache.wicket.behavior.Behavior
beforeRender, canCallListenerInterface, canCallListenerInterface, detach, isEnabled, isTemporary, onConfigure, onEvent, onException, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResizableAjaxBehavior

public ResizableAjaxBehavior()
Default constructor

Method Detail

getResizableBehavior

public ResizableBehavior getResizableBehavior()
Returns:
the standard resizable JavaScript behavior

onBind

protected void onBind()
Overrides:
onBind in class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior

onResize

public final void onResize(org.apache.wicket.ajax.AjaxRequestTarget target)
For framework internal use only.


onResize

public abstract void onResize(int height,
                              int width,
                              org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
onResize is triggered at the end of a resize operation.

Parameters:
height - Height of the resized Component
width - Width of the resized Component
ajaxRequestTarget - the Ajax target

respond

protected void respond(org.apache.wicket.ajax.AjaxRequestTarget target)
onDrop is called back when the drop event has been fired.

Specified by:
respond in class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
Parameters:
target - the Ajax target

statement

public JsStatement statement()
Description copied from interface: IWiQueryPlugin
Returns the main JsStatement used to create the plugin.

Specified by:
statement in interface IWiQueryPlugin
Specified by:
statement in class WiQueryAbstractAjaxBehavior
Returns:
The JsStatement corresponding to this component.

getCallbackScript

protected CharSequence getCallbackScript()
We override super method to add height and width parameters to the URL. Otherwise we use standard AbstractDefaultAjaxBehavior machinery to generate script: what way all the logic regarding IAjaxCallDecorator or indicatorId will be added to the generated script. This makes resizable AJAX behavior compatible with standard Wicket's AJAX call-backs.

Overrides:
getCallbackScript in class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
See Also:
AbstractAjaxBehavior.getCallbackUrl()

setAlsoResize

public ResizableAjaxBehavior setAlsoResize(ResizableAlsoResize alsoResize)
Resize these elements synchronous when resizing.

Parameters:
alsoResize -
Returns:
instance of the current behavior

getAlsoResizeComplex

public ResizableAlsoResize getAlsoResizeComplex()
Returns:
the alsoResize option

setAnimate

public ResizableAjaxBehavior setAnimate(boolean animate)
Animates to the final size after resizing.

Parameters:
animate -
Returns:
instance of the current behavior

isAnimate

public boolean isAnimate()
Returns:
the animate option

setAnimateDuration

public ResizableAjaxBehavior setAnimateDuration(ResizableAnimeDuration animeDuration)
Sets the duration time for animating, in milliseconds. Other possible values: 'slow', 'normal', 'fast'.

Returns:
instance of the current behavior

getAnimateDuration

public ResizableAnimeDuration getAnimateDuration()
Returns:
the animeDuration option

setAnimateEasing

public ResizableAjaxBehavior setAnimateEasing(String easing)
Sets the easing effect for animating.

Parameters:
easing -
Returns:
instance of the current behavior

getAnimateEasing

public String getAnimateEasing()
Returns:
the animateEasing option

setAspectRatio

public ResizableAjaxBehavior setAspectRatio(ResizableAspectRatio aspectRatio)
If set to true, resizing is constrained by the original aspect ratio. Otherwise a custom aspect ratio can be specified, such as 9 / 16, or 0.5.

Parameters:
aspectRatio -
Returns:
instance of the current behavior

getAspectRatio

public ResizableAspectRatio getAspectRatio()
Returns:
the aspectRatio option

setAutoHide

public ResizableAjaxBehavior setAutoHide(boolean autoHide)
If set to true, automatically hides the handles except when the mouse hovers over the element.

Parameters:
autoHide -
Returns:
instance of the current behavior

isAutoHide

public boolean isAutoHide()
Returns:
the autoHide option

setCancel

public ResizableAjaxBehavior setCancel(String cancel)
Prevents resizing if you start on elements matching the selector.

Parameters:
cancel -
Returns:
instance of the current behavior

getCancel

public String getCancel()
Returns:
the cancel option

setContainment

public ResizableAjaxBehavior setContainment(ResizableContainment containment)
Sets the constrains resizing to within the bounds of the specified element. Possible values: 'parent', 'document', a DOMElement, or a Selector.

Parameters:
containment -
Returns:
instance of the current behavior

getContainment

public ResizableContainment getContainment()
Returns:
the containment option

setDelay

public ResizableAjaxBehavior setDelay(int delay)
Sets the tolerance, in milliseconds, for when resizing should start. If specified, resizing will not start until after mouse is moved beyond duration. This can help prevent unintended resizing when clicking on an element.

Parameters:
delay -
Returns:
instance of the current behavior

getDelay

public int getDelay()
Returns:
the distance option

setDistance

public ResizableAjaxBehavior setDistance(int distance)
Sets the tolerance, in pixels, for when resizing should start. If specified, resizing will not start until after mouse is moved beyond distance. This can help prevent unintended resizing when clicking on an element.

Parameters:
distance -
Returns:
instance of the current behavior

getDistance

public int getDistance()
Returns:
the distance option

setDisabled

public ResizableAjaxBehavior setDisabled(boolean disabled)
Disables (true) or enables (false) the resizable. Can be set when initialising (first creating) the resizable.

Parameters:
disabled -
Returns:
instance of the current behavior

isDisabled

public boolean isDisabled()
Returns:
the disabled option

setGhost

public ResizableAjaxBehavior setGhost(boolean ghost)
Set to true, a semi-transparent helper element is shown for resizing.

Parameters:
ghost -
Returns:
instance of the current behavior

isGhost

public boolean isGhost()
Returns:
the ghost option

setGrid

public ResizableAjaxBehavior setGrid(int x,
                                     int y)
Snaps the resizing element to a grid, every x and y pixels. Array values: [x, y] Array values: [x, y]

Parameters:
x -
y -
Returns:
instance of the current behavior

getGrid

public ICollectionItemOptions getGrid()
Returns:
the grid option value

setHandles

public ResizableAjaxBehavior setHandles(ResizableHandles handles)
If specified as a string, should be a comma-split list of any of the following: 'n, e, s, w, ne, se, sw, nw, all'. The necessary handles will be auto-generated by the plugin. If specified as an object, the following keys are supported: { n, e, s, w, ne, se, sw, nw }. The value of any specified should be a jQuery selector matching the child element of the resizable to use as that handle. If the handle is not a child of the resizable, you can pass in the DOMElement or a valid jQuery object directly.

Parameters:
handles -
Returns:
instance of the current behavior

getHandles

public ResizableHandles getHandles()
Returns:
the handles option

setHelper

public ResizableAjaxBehavior setHelper(String helper)
Sets the css class that will be added to a proxy element to outline the resize during the drag of the resize handle. Once the resize is complete, the original element is sized.

Parameters:
helper -
Returns:
instance of the current behavior

getHelper

public String getHelper()
Returns:
the helper option

setMaxHeight

public ResizableAjaxBehavior setMaxHeight(int maxHeight)
Sets the component's max height.

Returns:
instance of the current behavior

getMaxHeight

public int getMaxHeight()
Returns the component's max height.


setMaxWidth

public ResizableAjaxBehavior setMaxWidth(int maxWidth)
Sets the window's max width.

Returns:
instance of the current behavior

getMaxWidth

public int getMaxWidth()
Returns the component's max width.


setMinHeight

public ResizableAjaxBehavior setMinHeight(int minHeight)
Sets the component's min height.

Returns:
instance of the current behavior

getMinHeight

public int getMinHeight()
Returns the component's min height.


setMinWidth

public ResizableAjaxBehavior setMinWidth(int minWidth)
Sets the component's min width.

Returns:
instance of the current behavior

getMinWidth

public int getMinWidth()
Returns the component's max width.


destroy

public JsStatement destroy()
Method to destroy This will return the element back to its pre-init state.

Returns:
the associated JsStatement

destroy

public void destroy(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
Method to destroy within the ajax request

Parameters:
ajaxRequestTarget -

disable

public JsStatement disable()
Method to disable

Returns:
the associated JsStatement

disable

public void disable(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
Method to disable within the ajax request

Parameters:
ajaxRequestTarget -

enable

public JsStatement enable()
Method to enable

Returns:
the associated JsStatement

enable

public void enable(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
Method to enable within the ajax request

Parameters:
ajaxRequestTarget -

widget

public JsStatement widget()
Method to returns the .ui-resizable element

Returns:
the associated JsStatement

widget

public void widget(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
Method to returns the .ui-resizable element within the ajax request

Parameters:
ajaxRequestTarget -


Copyright © 2012. All Rights Reserved.