Permalink
Browse files

Updating mootools and prototype sortable implementation.

  • Loading branch information...
markstory committed Apr 7, 2009
1 parent c6c7630 commit 49f689a9ce9884e95d3dbefddc5027419b5d0db2
@@ -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 . '});';
}
}
?>
@@ -41,6 +41,12 @@ class PrototypeEngineHelper extends JsBaseEngineHelper {
'success' => 'onSuccess',
'complete' => 'onComplete',
'error' => 'onFailure'
+ ),
+ 'sortable' => array(
+ 'start' => 'onStart',
+ 'sort' => 'onDrag',
+ 'complete' => 'onDrop',
+ 'distance' => 'snap',
)
);
/**
@@ -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 . '});';
}
}
?>
@@ -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);
}
/**
@@ -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.