Updating mootools and prototype sortable implementation.

This commit is contained in:
mark_story 2009-04-06 21:56:20 -04:00
parent c6c7630d8f
commit 49f689a9ce
4 changed files with 21 additions and 4 deletions

View file

@ -203,7 +203,7 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
$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 . '});';
}
}
?>

View file

@ -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 @@ class PrototypeEngineHelper extends JsBaseEngineHelper {
* @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 . '});';
}
}
?>

View file

@ -207,7 +207,7 @@ class MooEngineHelperTestCase extends CakeTestCase {
'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);
}
/**

View file

@ -215,7 +215,15 @@ class PrototypeEngineHelperTestCase extends CakeTestCase {
* @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);
}
}
?>