Skip to content
Permalink
Browse files

Adding drop() to jquery.

Adding testcases.
Fixing doc blocks.
  • Loading branch information...
markstory committed Apr 9, 2009
1 parent 0269994 commit 646cfd7a830ec9e5dee317ce35ff6c59c820ea62
@@ -43,6 +43,10 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
'drag' => array(
'snapGrid' => 'grid',
'container' => 'containment',
),
'drop' => array(
'leave' => 'out',
'hover' => 'over'
)
);
/**
@@ -177,14 +181,29 @@ function sortable($options = array()) {
* Requires both Ui.Core and Ui.Draggable to be loaded.
*
* @param array $options Array of options for the draggable element.
* @return string Completed Draggabke script.
* @return string Completed Draggable script.
* @see JsHelper::drag() for options list.
**/
function drag($options = array()) {
$options = $this->_mapOptions('drag', $options);
$callbacks = array('start', 'drag', 'stop');
$options = $this->_parseOptions($options, $callbacks);
return $this->selection . '.draggable({' . $options . '});';
return $this->selection . '.draggable({' . $options . '});';
}
/**
* Create a Droppable element
*
* Requires both Ui.Core and Ui.Droppable to be loaded.
*
* @param array $options Array of options for the droppable element.
* @return string Completed Droppable script.
* @see JsHelper::drop() for options list.
**/
function drop($options = array()) {
$options = $this->_mapOptions('drop', $options);
$callbacks = array('activate', 'deactivate', 'over', 'out', 'drop');
$options = $this->_parseOptions($options, $callbacks);
return $this->selection . '.droppable({' . $options . '});';
}
}
?>
@@ -608,9 +608,13 @@ function drag($options = array()) {
* Create a droppable element. Allows for draggable elements to be dropped on it.
* Additional options may be supported by your library.
*
* ### Options
*
* - accept - Selector for elements this droppable will accept.
* - hoverclass - Class to add to droppable when a draggable is over.
*
* ### Event Options
*
* - drag - Elements that can be dragged into this droppable
* - drop - Event fired when an element is dropped into the drop zone.
* - hover - Event fired when a drag enters a drop zone.
* - leave - Event fired when a drag is removed from a drop zone without being dropped.
@@ -198,15 +198,24 @@ function testDrag() {
'stop' => 'onStop',
'snapGrid' => array(10, 10),
));
$expected = '$("#element").draggable({containment:"#content", drag:onDrag, grid:[10, 10], start:onStart, stop:onStop});';
$expected = '$("#element").draggable({containment:"#content", drag:onDrag, grid:[10,10], start:onStart, stop:onStop});';
$this->assertEqual($result, $expected);
}
/**
* test drop() method
*
* @return void
**/
function testDrop() {
$this->Jquery->get('#element');
$result = $this->Jquery->drop(array(
'accept' => '.items',
'hover' => 'onHover',
'leave' => 'onExit',
'drop' => 'onDrop'
));
$expected = '$("#element").droppable({accept:".items", drop:onDrop, out:onExit, over:onHover});';
$this->assertEqual($result, $expected);
}
}
?>

0 comments on commit 646cfd7

Please sign in to comment.
You can’t perform that action at this time.