Skip to content

Commit

Permalink
Updating mootools and prototype sortable implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Apr 7, 2009
1 parent c6c7630 commit 49f689a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/mootools_engine.php
Expand Up @@ -203,7 +203,7 @@ function sortable($options = array()) {
$options = $this->_mapOptions('sortable', $options);
$callbacks = array('onStart', 'onSort', 'onComplete');
$options = $this->_parseOptions($options, $callbacks);
return 'var mooSortable = new Sortables(' . $this->selection . ', {' . $options . '});';
return 'var jsSortable = new Sortables(' . $this->selection . ', {' . $options . '});';
}
}
?>
11 changes: 10 additions & 1 deletion cake/libs/view/helpers/prototype_engine.php
Expand Up @@ -41,6 +41,12 @@ class PrototypeEngineHelper extends JsBaseEngineHelper {
'success' => 'onSuccess',
'complete' => 'onComplete',
'error' => 'onFailure'
),
'sortable' => array(
'start' => 'onStart',
'sort' => 'onDrag',
'complete' => 'onDrop',
'distance' => 'snap',
)
);
/**
Expand Down Expand Up @@ -189,7 +195,10 @@ function request($url, $options = array()) {
* @see JsHelper::sortable() for options list.
**/
function sortable($options = array()) {

$options = $this->_mapOptions('sortable', $options);
$callbacks = array('onStart', 'change', 'onDrag', 'onDrop');
$options = $this->_parseOptions($options, $callbacks);
return 'var jsSortable = Sortable.create(' . $this->selection . ', {' . $options . '});';
}
}
?>
Expand Up @@ -207,7 +207,7 @@ function testSortable() {
'complete' => 'onStop',
'sort' => 'onSort',
));
$expected = 'var mooSortable = new Sortables($("myList"), {constrain:"parent", onComplete:onStop, onSort:onSort, onStart:onStart, snap:5});';
$expected = 'var jsSortable = new Sortables($("myList"), {constrain:"parent", onComplete:onStop, onSort:onSort, onStart:onStart, snap:5});';
$this->assertEqual($result, $expected);
}
/**
Expand Down
10 changes: 9 additions & 1 deletion cake/tests/cases/libs/view/helpers/prototype_engine.test.php
Expand Up @@ -215,7 +215,15 @@ function testRequest() {
* @return void
**/
function testSortable() {

$this->Proto->get('#myList');
$result = $this->Proto->sortable(array(
'distance' => 5,
'start' => 'onStart',
'complete' => 'onComplete',
'sort' => 'onSort',
));
$expected = 'var jsSortable = Sortable.create($("myList"), {onDrag:onSort, onDrop:onComplete, onStart:onStart, snap:5});';
$this->assertEqual($result, $expected);
}
}
?>

0 comments on commit 49f689a

Please sign in to comment.