Updating Mootools engine to work seamlessly with $() and $$() type selections.

This commit is contained in:
mark_story 2009-07-27 08:45:31 -04:00
parent 7246563bae
commit cde9afb486
2 changed files with 6 additions and 7 deletions

View file

@ -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;
}

View file

@ -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")');
}