Skip to content
Permalink
Browse files

Removing multiple param for JsBaseEngine::get() it is not needed.

Adding get() to Mootools engine
  • Loading branch information...
markstory committed Mar 15, 2009
1 parent 6b00583 commit a9da171e8c326a838c1839097585d468d9a63db5
@@ -43,10 +43,9 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
* Create javascript selector for a CSS rule
*
* @param string $selector The selector that is targeted
* @param boolean $multiple Whether or not the selector could target more than one element.
* @return object instance of $this. Allows chained methods.
**/
function get($selector, $multiple = false) {
function get($selector) {
if ($selector == 'window' || $selector == 'document') {
$this->selection = "$(" . $selector .")";
} else {
@@ -487,10 +487,9 @@ function getCache($clear = true) {
* Create javascript selector for a CSS rule
*
* @param string $selector The selector that is targeted
* @param boolean $multiple Whether or not the selector could target more than one element.
* @return object instance of $this. Allows chained methods.
**/
function get($selector, $multiple = false) {
function get($selector) {
trigger_error(sprintf(__('%s does not have get() implemented', true), get_class($this)), E_USER_WARNING);
return $this;
}
@@ -47,11 +47,19 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
* Create javascript selector for a CSS rule
*
* @param string $selector The selector that is targeted
* @param boolean $multiple Whether or not the selector could target more than one element.
* @return object instance of $this. Allows chained methods.
**/
function get($selector, $multiple = false) {
function get($selector) {
if ($selector == 'window' || $selector == 'document') {
$this->selection = "$(" . $selector .")";
return $this;
}
if (preg_match('/^#[^\s.]+$/', $selector)) {
$this->selection = "$('" . substr($selector, 1) . "')";
return $this;
}
$this->selection = "$$('" . $selector ."')";
return $this;
}
/**
* Add an event to the script cache. Operates on the currently selected elements.
@@ -1,6 +1,6 @@
<?php
/**
* JqueryEngineTestCase
* MooEngineTestCase
*
*
*
@@ -23,7 +23,7 @@
*/
App::import('Helper', array('Html', 'Js', 'MootoolsEngine'));
class JqueryEngineHelperTestCase extends CakeTestCase {
class MooEngineHelperTestCase extends CakeTestCase {
/**
* startTest
*
@@ -46,7 +46,29 @@ function endTest() {
* @return void
**/
function testSelector() {
$result = $this->Moo->get('#content');
$this->assertEqual($result, $this->Moo);
$this->assertEqual($this->Moo->selection, "$('content')");
$result = $this->Moo->get('a .remove');
$this->assertEqual($result, $this->Moo);
$this->assertEqual($this->Moo->selection, "$$('a .remove')");
$result = $this->Moo->get('document');
$this->assertEqual($result, $this->Moo);
$this->assertEqual($this->Moo->selection, "$(document)");
$result = $this->Moo->get('window');
$this->assertEqual($result, $this->Moo);
$this->assertEqual($this->Moo->selection, "$(window)");
$result = $this->Moo->get('ul');
$this->assertEqual($result, $this->Moo);
$this->assertEqual($this->Moo->selection, "$$('ul')");
$result = $this->Moo->get('#some_long-id.class');
$this->assertEqual($result, $this->Moo);
$this->assertEqual($this->Moo->selection, "$$('#some_long-id.class')");
}
/**
* test event binding

0 comments on commit a9da171

Please sign in to comment.
You can’t perform that action at this time.