diff --git a/Gruntfile.js b/Gruntfile.js index 545329df039..ac9fa9cb8e9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,6 +8,7 @@ var "core.js", "widget.js", "mouse.js", + "interaction.js", "draggable.js", "droppable.js", "resizable.js", diff --git a/demos/draggable/closedhand.cur b/demos/draggable/closedhand.cur new file mode 100755 index 00000000000..41aaa62a596 Binary files /dev/null and b/demos/draggable/closedhand.cur differ diff --git a/demos/draggable/constrain-movement.html b/demos/draggable/constrain-movement.html index 1dcab0213fc..e46fb7b27ba 100644 --- a/demos/draggable/constrain-movement.html +++ b/demos/draggable/constrain-movement.html @@ -7,7 +7,7 @@ - + @@ -52,7 +61,8 @@

Or to within another DOM element:

-

Constrain the movement of each draggable by defining the boundaries of the draggable area. Set the axis option to limit the draggable's path to the x- or y-axis, or use the containment option to specify a parent DOM element or a jQuery selector, like 'document.'

+

Constrain the movement of each draggable by defining the boundaries of the draggable area. The containment option allows you to specify any element to use as a containing box; you can pass any selector or the string "parent".

+

The draggable element can also be constrained with custom logic inside a drag event handler. Modifying the ui.position object's left and/or top properties will change where the element will be positioned. In this example, we're forcing the top or left to always be the same as where it started, resulting in the element being confined to a specific axis.

diff --git a/demos/draggable/cursor-style.html b/demos/draggable/cursor-style.html index 426123644c0..7a979187341 100644 --- a/demos/draggable/cursor-style.html +++ b/demos/draggable/cursor-style.html @@ -7,36 +7,65 @@ - +
-

I will always stick to the center (relative to the mouse)

+

I will always stick to the center (relative to the pointer)

-

My cursor is at left -5 and top -5

-
- -
-

My cursor position is only controlled for the 'bottom' value

+

My cursor position is always at the top

-

Position the cursor while dragging the object. By default the cursor appears in the center of the dragged object; use the cursorAt option to specify another location relative to the draggable (specify a pixel value from the top, right, bottom, and/or left). Customize the cursor's appearance by supplying the cursor option with a valid CSS cursor value: default, move, pointer, crosshair, etc.

+

The beforeStart callback allows you to position the draggable element in order to adjust where the draggable movements will be calculated from. In this example, we adjust the position to control where the element is relative to the pointer during the drag.

diff --git a/demos/draggable/default.html b/demos/draggable/default.html index 283a5964985..1676dddc9c9 100644 --- a/demos/draggable/default.html +++ b/demos/draggable/default.html @@ -7,7 +7,7 @@ - + diff --git a/demos/draggable/handle.html b/demos/draggable/handle.html index 7c3690ea6fa..d8aa57b52d6 100644 --- a/demos/draggable/handle.html +++ b/demos/draggable/handle.html @@ -7,7 +7,7 @@ - + @@ -30,11 +42,11 @@

You can drag me around…

-

…but you can't drag me by this handle.

+

…but you can't drag me by this element.

-

Allow dragging only when the cursor is over a specific part of the draggable. Use the handle option to specify the jQuery selector of an element (or group of elements) used to drag the object.

+

Allow dragging only when the cursor is over a specific part of the draggable. Use the handle option to specify the jQuery selector of an element (or group of elements) used to drag the object.

Or prevent dragging when the cursor is over a specific element (or group of elements) within the draggable. Use the cancel option to specify a jQuery selector over which to "cancel" draggable functionality.

diff --git a/demos/draggable/index.html b/demos/draggable/index.html index 93850684d67..9a63a5ff322 100644 --- a/demos/draggable/index.html +++ b/demos/draggable/index.html @@ -11,13 +11,14 @@
  • Events
  • Constrain movement
  • Delay start
  • -
  • Snap to element or grid
  • +
  • Snap to element or grid
  • Auto-scroll
  • Revert position
  • Visual feedback
  • Drag handle
  • Cursor style
  • Draggable + Sortable
  • +
  • Draggable Map
  • diff --git a/demos/draggable/map.html b/demos/draggable/map.html new file mode 100644 index 00000000000..dfead48bf91 --- /dev/null +++ b/demos/draggable/map.html @@ -0,0 +1,73 @@ + + + + + + jQuery UI Draggable - Draggable Map + + + + + + + + + + + + +
    + Map of Vienna +
    + +
    +

    Drag the map around inside the viewport. Works with touch devices. The container is kept small for the demo to work.

    +
    + + diff --git a/demos/draggable/revert.html b/demos/draggable/revert.html index 7ccccdf55dd..121aeef74ac 100644 --- a/demos/draggable/revert.html +++ b/demos/draggable/revert.html @@ -7,16 +7,29 @@ - + @@ -31,7 +44,7 @@
    -

    Return the draggable (or it's helper) to its original location when dragging stops with the boolean revert option.

    +

    The stop callback can be used to perform an action after the user finishing dragging the element. For example, if you want to return the draggable (or it's helper) to its original location when dragging stops, you can do so in the stop callback.

    diff --git a/demos/draggable/visual-feedback.html b/demos/draggable/visual-feedback.html index d90d4842c5d..28d58b57358 100644 --- a/demos/draggable/visual-feedback.html +++ b/demos/draggable/visual-feedback.html @@ -7,23 +7,21 @@ - + - + diff --git a/demos/interaction/box.html b/demos/interaction/box.html new file mode 100644 index 00000000000..ee4c98cd34d --- /dev/null +++ b/demos/interaction/box.html @@ -0,0 +1,73 @@ + + + + + jQuery UI Interaction - Box + + + + + + + + + + + +
    + +
    + +
    + + +
    +

    This demo shows how you can create a simple box-drawing (aka lasso) interaction built on top of the interaction utility (interaction.js).

    +

    Draw a box by starting in the box above using the mouse or a touch input device.

    +
    + + + diff --git a/demos/interaction/default.html b/demos/interaction/default.html new file mode 100644 index 00000000000..2b8b92bb07b --- /dev/null +++ b/demos/interaction/default.html @@ -0,0 +1,63 @@ + + + + + jQuery UI Interaction - Default functionality + + + + + + + + + + + +
    + +
    + +
    +
    Start:
    +
    0
    +
    Move:
    +
    0
    +
    Stop:
    +
    0
    +
    + +
    + + +
    +

    This demo shows a simple interaction built using the interaction utility (jquery.ui.interaction.js).

    +

    Make a down-move-up motion starting on the blue box above using the mouse or a touch input device to see the interaction events

    +
    + + + diff --git a/demos/interaction/index.html b/demos/interaction/index.html new file mode 100644 index 00000000000..4666b3b1d93 --- /dev/null +++ b/demos/interaction/index.html @@ -0,0 +1,19 @@ + + + + + jQuery UI Interaction Demo + + + + +
    +

    Examples

    + +
    + + + diff --git a/tests/unit/draggable/draggable.html b/tests/unit/draggable/draggable.html index 02977c6cc5f..1a381e314a1 100644 --- a/tests/unit/draggable/draggable.html +++ b/tests/unit/draggable/draggable.html @@ -58,6 +58,7 @@ "ui/core.js", "ui/widget.js", "ui/mouse.js", + "ui/interaction.js", "ui/resizable.js", "ui/draggable.js", "ui/droppable.js" @@ -65,6 +66,7 @@ }); + diff --git a/tests/unit/draggable/draggable_common.js b/tests/unit/draggable/draggable_common.js index 5abd09e4935..e374e20ea6e 100644 --- a/tests/unit/draggable/draggable_common.js +++ b/tests/unit/draggable/draggable_common.js @@ -1,16 +1,19 @@ TestHelpers.commonWidgetTests( "draggable", { defaults: { - appendTo: "parent", + // options + appendTo: null, + containment: null, + disabled: false, + exclude: "input,textarea,button,select", + handle: null, + helper: false, + + // backCompat options axis: false, - cancel: "input,textarea,button,select,option", - connectToSortable: false, - containment: false, + // connectToSortable: false, cursor: "auto", cursorAt: false, - disabled: false, grid: false, - handle: false, - helper: "original", opacity: false, refreshPositions: false, revert: false, @@ -24,14 +27,10 @@ TestHelpers.commonWidgetTests( "draggable", { snapTolerance: 20, stack: false, zIndex: false, - - //todo: remove the following option checks when interactions are rewritten: - addClasses: true, - delay: 0, - distance: 1, - iframeFix: false, + cancel: null, // callbacks + beforeStart: null, create: null, drag: null, start: null, diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index 7df0969b1a5..9e977b52d17 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -52,26 +52,107 @@ test( "No options, absolute", function() { TestHelpers.draggable.shouldMove( $( "#draggable2" ).draggable(), "no options, absolute" ); }); -test( "resizable handle with complex markup (#8756 / #8757)", function() { - expect( 2 ); +//TODO: re-enable when resizable is ported to interactions +// test( "resizable handle with complex markup (#8756 / #8757)", function() { +// expect( 2 ); + +// $( "#draggable1" ) +// .append( +// $("
    ") +// .addClass("ui-resizable-handle ui-resizable-w") +// .append( $("
    ") ) +// ); + +// var handle = $(".ui-resizable-w div"), +// target = $( "#draggable1" ).draggable().resizable({ handles: "all" }); + +// // todo: fix resizable so it doesn't require a mouseover +// handle.simulate("mouseover").simulate( "drag", { dx: -50 } ); +// equal( target.width(), 250, "compare width" ); + +// // todo: fix resizable so it doesn't require a mouseover +// handle.simulate("mouseover").simulate( "drag", { dx: 50 } ); +// equal( target.width(), 200, "compare width" ); +// }); + +test("_blockFrames, absolute parent", function() { + expect( 3 ); + var el = $("#draggable1").draggable(), + parent = $("
    "), + iframe = $("