mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Removing multiple param for JsBaseEngine::get() it is not needed.
Adding get() to Mootools engine
This commit is contained in:
parent
6b0058308e
commit
a9da171e8c
4 changed files with 38 additions and 10 deletions
|
@ -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 @@ class JsBaseEngineHelper extends AppHelper {
|
|||
* 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 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
|
|||
* @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
|
||||
|
|
Loading…
Add table
Reference in a new issue