mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Updating Mootools engine to work seamlessly with $() and $$() type selections.
This commit is contained in:
parent
7246563bae
commit
cde9afb486
2 changed files with 6 additions and 7 deletions
|
@ -73,6 +73,7 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
|
|||
* @return object instance of $this. Allows chained methods.
|
||||
**/
|
||||
function get($selector) {
|
||||
$this->_multipleSelection = false;
|
||||
if ($selector == 'window' || $selector == 'document') {
|
||||
$this->selection = "$(" . $selector .")";
|
||||
return $this;
|
||||
|
@ -81,6 +82,7 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
|
|||
$this->selection = '$("' . substr($selector, 1) . '")';
|
||||
return $this;
|
||||
}
|
||||
$this->_multipleSelection = true;
|
||||
$this->selection = '$$("' . $selector . '")';
|
||||
return $this;
|
||||
}
|
||||
|
@ -237,7 +239,7 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
|
|||
$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 . '});';
|
||||
return $this->selection . '.makeDraggable({' . $options . '});';
|
||||
}
|
||||
/**
|
||||
* Create a Droppable element.
|
||||
|
@ -271,10 +273,7 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
|
|||
'onLeave', 'onEnter', 'droppables');
|
||||
|
||||
$optionString = $this->_parseOptions($options, $callbacks);
|
||||
if (!empty($optionString)) {
|
||||
$optionString = ', {' . $optionString . '}';
|
||||
}
|
||||
$out = 'var jsDrop = new Drag.Move(' . $this->selection . $optionString . ');';
|
||||
$out = $this->selection . '.makeDraggable({' . $optionString . '});';
|
||||
$this->selection = $options['droppables'];
|
||||
return $out;
|
||||
}
|
||||
|
|
|
@ -235,7 +235,7 @@ class MooEngineHelperTestCase extends CakeTestCase {
|
|||
'stop' => 'onStop',
|
||||
'snapGrid' => array(10,10)
|
||||
));
|
||||
$expected = 'var jsDrag = new Drag($("drag-me"), {onComplete:onStop, onDrag:onDrag, onStart:onStart, snap:[10,10]});';
|
||||
$expected = '$("drag-me").makeDraggable({onComplete:onStop, onDrag:onDrag, onStart:onStart, snap:[10,10]});';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
|
@ -258,7 +258,7 @@ class MooEngineHelperTestCase extends CakeTestCase {
|
|||
'hover' => 'onHover',
|
||||
'drag' => '#my-drag'
|
||||
));
|
||||
$expected = 'var jsDrop = new Drag.Move($("my-drag"), {droppables:$("drop-me"), onDrop:onDrop, onEnter:onHover, onLeave:onLeave});';
|
||||
$expected = '$("my-drag").makeDraggable({droppables:$("drop-me"), onDrop:onDrop, onEnter:onHover, onLeave:onLeave});';
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->assertEqual($this->Moo->selection, '$("drop-me")');
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue