Skip to content
Permalink
Browse files

Adding Drag() to jquery

  • Loading branch information...
markstory committed Apr 9, 2009
1 parent 49f689a commit 0269994842561ba8497b7b07f368c4747671554c
@@ -39,6 +39,10 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
),
'sortable' => array(
'complete' => 'stop',
),
'drag' => array(
'snapGrid' => 'grid',
'container' => 'containment',
)
);
/**
@@ -167,5 +171,20 @@ function sortable($options = array()) {
$options = $this->_parseOptions($options, $callbacks);
return $this->selection . '.sortable({' . $options . '});';
}
/**
* Create a Draggable element
*
* 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.
* @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 . '});';
}
}
?>
@@ -190,7 +190,15 @@ function testSortable() {
* @return void
**/
function testDrag() {
$this->Jquery->get('#element');
$result = $this->Jquery->drag(array(
'container' => '#content',
'start' => 'onStart',
'drag' => 'onDrag',
'stop' => 'onStop',
'snapGrid' => array(10, 10),
));
$expected = '$("#element").draggable({containment:"#content", drag:onDrag, grid:[10, 10], start:onStart, stop:onStop});';
}
/**
* test drop() method

0 comments on commit 0269994

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