mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Adding drag() to mootools.
This commit is contained in:
parent
02bb4e71f3
commit
1d5e3150a2
2 changed files with 32 additions and 2 deletions
|
@ -48,6 +48,12 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
|
|||
'sort' => 'onSort',
|
||||
'complete' => 'onComplete',
|
||||
'start' => 'onStart',
|
||||
),
|
||||
'drag' => array(
|
||||
'snapGrid' => 'snap',
|
||||
'start' => 'onStart',
|
||||
'drag' => 'onDrag',
|
||||
'stop' => 'onComplete',
|
||||
)
|
||||
);
|
||||
/**
|
||||
|
@ -193,7 +199,7 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
|
|||
/**
|
||||
* Create a sortable element.
|
||||
*
|
||||
* Requires both the ```Sortables``` plugin from MootoolsMore
|
||||
* Requires the ```Sortables``` plugin from MootoolsMore
|
||||
*
|
||||
* @param array $options Array of options for the sortable.
|
||||
* @return string Completed sortable script.
|
||||
|
@ -205,5 +211,21 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
|
|||
$options = $this->_parseOptions($options, $callbacks);
|
||||
return 'var jsSortable = new Sortables(' . $this->selection . ', {' . $options . '});';
|
||||
}
|
||||
/**
|
||||
* Create a Draggable element.
|
||||
*
|
||||
* Requires the ```Drag``` plugin from MootoolsMore
|
||||
*
|
||||
* @param array $options Array of options for the draggable.
|
||||
* @return string Completed draggable script.
|
||||
* @see JsHelper::drag() for options list.
|
||||
**/
|
||||
function drag($options = array()) {
|
||||
$options = $this->_mapOptions('drag', $options);
|
||||
$callbacks = array('onBeforeStart', 'onStart', 'onSnap', 'onDrag', 'onComplete');
|
||||
$options = $this->_parseOptions($options, $callbacks);
|
||||
return 'var jsDrag = new Drag(' . $this->selection . ', {' . $options . '});';
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -216,7 +216,15 @@ class MooEngineHelperTestCase extends CakeTestCase {
|
|||
* @return void
|
||||
**/
|
||||
function testDrag() {
|
||||
|
||||
$this->Moo->get('#drag-me');
|
||||
$result = $this->Moo->drag(array(
|
||||
'start' => 'onStart',
|
||||
'drag' => 'onDrag',
|
||||
'stop' => 'onStop',
|
||||
'snapGrid' => array(10,10)
|
||||
));
|
||||
$expected = 'var jsDrag = new Drag($("drag-me"), {onComplete:onStop, onDrag:onDrag, onStart:onStart, snap:[10,10]});';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
* test drop() method
|
||||
|
|
Loading…
Add table
Reference in a new issue