mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Adding sortables to mootools engine.
This commit is contained in:
parent
d59a704fb1
commit
9708b2dc50
2 changed files with 38 additions and 0 deletions
|
@ -40,6 +40,10 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
|
|||
'complete' => 'onComplete',
|
||||
'request' => 'onRequest',
|
||||
'error' => 'onFailure'
|
||||
),
|
||||
'sortable' => array(
|
||||
'distance' => 'snap',
|
||||
'containment' => 'constrain',
|
||||
)
|
||||
);
|
||||
/**
|
||||
|
@ -150,6 +154,9 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
|
|||
}
|
||||
/**
|
||||
* Create an new Request.
|
||||
*
|
||||
* Requires ```Request```. If you wish to use 'update' key you must have ```Request.HTML```
|
||||
* if you wish to do Json requests you will need ```JSON``` and ```Request.JSON```.
|
||||
*
|
||||
* @param mixed $url
|
||||
* @param array $options
|
||||
|
@ -180,5 +187,20 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
|
|||
$options = $this->_parseOptions($options, $callbacks);
|
||||
return "var jsRequest = new Request$type({{$options}}).send($data);";
|
||||
}
|
||||
/**
|
||||
* Create a sortable element.
|
||||
*
|
||||
* Requires both the ```Sortables``` plugin from MootoolsMore
|
||||
*
|
||||
* @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', 'complete');
|
||||
$options = $this->_parseOptions($options, $callbacks);
|
||||
return 'var mooSortable = new Sortables(' . $this->selection . ', {' . $options . '});';
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -171,5 +171,21 @@ class MooEngineHelperTestCase extends CakeTestCase {
|
|||
$expected = 'var jsRequest = new Request.JSON({method:"post", onComplete:doSuccess, onFailure:handleError, url:"/people/edit/1"}).send({"name":"jim","height":"185cm"});';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
* test sortable list generation
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testSortable() {
|
||||
$result = $this->Moo->get('#myList')->sortable(array(
|
||||
'distance' => 5,
|
||||
'containment' => 'parent',
|
||||
'start' => 'onStart',
|
||||
'complete' => 'onStop',
|
||||
'sort' => 'onSort',
|
||||
));
|
||||
$expected = 'var mooSortable = new Sortables($("myList"), {start:onStart, complete:onStop, sort:onSort, snap:5, constrain:"parent"});';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue