Skip to content
Permalink
Browse files

Adding sortable to jQuery engine.

  • Loading branch information...
markstory committed Mar 28, 2009
1 parent dfe6fe1 commit d59a704fb1903ea56a833e1de358253d2331cf52
@@ -37,6 +37,9 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
'type' => 'dataType',
'complete' => 'success',
'request' => 'beforeSend',
),
'sortable' => array(
'complete' => 'stop',
)
);
/**
@@ -142,5 +145,21 @@ function request($url, $options = array()) {
$options = $this->_parseOptions($options, $callbacks);
return '$.ajax({' . $options .'});';
}
/**
* Create a sortable element.
*
* Requires both Ui.Core and Ui.Sortables to be loaded.
*
* @param array $options Array of options for the sortable.
* @return string Completed sortable script.
* @see JsHelper::sortable() for options list.
**/
function sortable($options = array()) {
$options = $this->_mapOptions('sortable', $options);
$callbacks = array('start', 'sort', 'change', 'beforeStop', 'stop', 'update', 'receive', 'remove',
'over', 'out', 'activate', 'deactivate');
$options = $this->_parseOptions($options, $callbacks);
return $this->selection . '.sortable({' . $options . '});';
}
}
?>
@@ -154,5 +154,21 @@ function testRequest() {
$expected = '$.ajax({method:"post", error:handleError, data:"name=jim&height=185cm", dataType:"json", success:doSuccess, url:"/people/edit/1"});';
$this->assertEqual($result, $expected);
}
/**
* test sortable list generation
*
* @return void
**/
function testSortable() {
$result = $this->Jquery->get('#myList')->sortable(array(
'distance' => 5,
'containment' => 'parent',
'start' => 'onStart',
'complete' => 'onStop',
'sort' => 'onSort',
));
$expected = '$("#myList").sortable({distance:5, containment:"parent", start:onStart, sort:onSort, stop:onStop});';
$this->assertEqual($result, $expected);
}
}
?>

0 comments on commit d59a704

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