mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Adding sortable to jQuery engine.
This commit is contained in:
parent
dfe6fe1c0c
commit
d59a704fb1
2 changed files with 35 additions and 0 deletions
|
@ -37,6 +37,9 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
|
|||
'type' => 'dataType',
|
||||
'complete' => 'success',
|
||||
'request' => 'beforeSend',
|
||||
),
|
||||
'sortable' => array(
|
||||
'complete' => 'stop',
|
||||
)
|
||||
);
|
||||
/**
|
||||
|
@ -142,5 +145,21 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
|
|||
$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 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
|
|||
$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);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue