Permalink
Browse files

Updating Mootools engine to work seamlessly with $() and $$() type se…

…lections.
  • Loading branch information...
1 parent 7246563 commit cde9afb486fdf7c791c266f0fc08b17d558738a1 @markstory markstory committed Jul 27, 2009
View
9 cake/libs/view/helpers/mootools_engine.php
@@ -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 @@ function get($selector) {
$this->selection = '$("' . substr($selector, 1) . '")';
return $this;
}
+ $this->_multipleSelection = true;
$this->selection = '$$("' . $selector . '")';
return $this;
}
@@ -237,7 +239,7 @@ 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 . '});';
+ return $this->selection . '.makeDraggable({' . $options . '});';
}
/**
* Create a Droppable element.
@@ -271,10 +273,7 @@ function drop($options = array()) {
'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;
}
View
4 cake/tests/cases/libs/view/helpers/mootools_engine.test.php
@@ -235,7 +235,7 @@ function testDrag() {
'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 @@ function testDrop() {
'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")');
}

0 comments on commit cde9afb

Please sign in to comment.