Permalink
Browse files

Removing old JsHelperObject

  • Loading branch information...
1 parent 91edcac commit 005cc1b338f3f2e6fe4016c4701bd8a552214791 @markstory markstory committed Apr 24, 2009
Showing with 0 additions and 179 deletions.
  1. +0 −179 cake/libs/view/helpers/js.php
@@ -734,183 +734,4 @@ function _toQuerystring($parameters) {
return $out;
}
}
-
-
-class JsHelperObject {
- var $__parent = null;
-
- var $id = null;
-
- var $pattern = null;
-
- var $real = null;
-
- function __construct(&$parent) {
- if (is_object($parent)) {
- $this->setParent($parent);
- }
- }
-
- function toString() {
- return $this->__toString();
- }
-
- function __toString() {
- return $this->literal;
- }
-
- function ref($ref = null) {
- if ($ref == null) {
- foreach (array('id', 'pattern', 'real') as $ref) {
- if ($this->{$ref} !== null) {
- return $this->{$ref};
- }
- }
- } else {
- return ($this->{$ref} !== null);
- }
- return null;
- }
-
- function literal($append = null) {
- if (!empty($this->id)) {
- $data = '$("' . $this->id . '")';
- }
- if (!empty($this->pattern)) {
- $data = '$$("' . $this->pattern . '")';
- }
- if (!empty($this->real)) {
- $data = $this->real;
- }
- if (!empty($append)) {
- $data .= '.' . $append;
- }
- return $data;
- }
-
- function __call($name, $args) {
- $data = '';
-
- if (isset($this->__parent->effectMap[strtolower($name)])) {
- array_unshift($args, $this->__parent->effectMap[strtolower($name)]);
- $name = 'effect';
- }
-
- switch ($name) {
- case 'effect':
- case 'visualEffect':
-
- if (strpos($args[0], '_') || $args[0]{0} != strtoupper($args[0]{0})) {
- $args[0] = Inflector::camelize($args[0]);
- }
-
- if (strtolower($args[0]) == 'highlight') {
- $data .= 'new ';
- }
- if ($this->pattern == null) {
- $data .= 'Effect.' . $args[0] . '(' . $this->literal();
- } else {
- $data .= 'Effect.' . $args[0] . '(item';
- }
-
- if (isset($args[1]) && is_array($args[1])) {
- $data .= ', {' . $this->__options($args[1]) . '}';
- }
- $data .= ');';
-
- if ($this->pattern !== null) {
- $data = $this->each($data);
- }
- break;
- case 'remove':
- case 'toggle':
- case 'show':
- case 'hide':
- if (empty($args)) {
- $obj = 'Element';
- $params = '';
- } else {
- $obj = 'Effect';
- $params = ', "' . $args[0] . '"';
- }
-
- if ($this->pattern != null) {
- $data = $this->each($obj . ".{$name}(item);");
- } else {
- $data = $obj . ".{$name}(" . $this->literal() . ');';
- }
- break;
- case 'visible':
- $data = $this->literal() . '.visible();';
- break;
- case 'update':
- $data = $this->literal() . ".update({$args[0]});";
- break;
- case 'load':
- $data = 'new Ajax.Updater("' . $this->id . '", "' . $args[0] . '"';
- if (isset($args[1]) && is_array($args[1])) {
- $data .= ', {' . $this->__options($args[1]) . '}';
- }
- $data .= ');';
- break;
- case 'each':
- case 'all':
- case 'any':
- case 'detect':
- case 'findAll':
- if ($this->pattern != null) {
- $data = $this->__iterate($name, $args[0]);
- }
- break;
- case 'addClass':
- case 'removeClass':
- case 'hasClass':
- case 'toggleClass':
- $data = $this->literal() . ".{$name}Name(\"{$args[0]}\");";
- break;
- case 'clone':
- case 'inspect':
- case 'keys':
- case 'values':
- $data = "Object.{$name}(" . $this->literal() . ");";
- break;
- case 'extend':
- $data = "Object.extend(" . $this->literal() . ", {$args[0]});";
- break;
- case '...':
- // Handle other methods here
- // including interfaces to load other files on-the-fly
- // that add support for additional methods/replacing existing methods
- break;
- default:
- $data = $this->literal() . '.' . $name . '();';
- break;
- }
-
- if ($this->__parent->output) {
- echo $data;
- } else {
- return $data;
- }
- }
-
- function __iterate($method, $data) {
- return '$$("' . $this->pattern . '").' . $method . '(function(item) {' . $data . '});';
- }
-
- function setParent(&$parent) {
- $this->__parent =& $parent;
- }
-
- function __options($opts) {
- $options = array();
- foreach ($opts as $key => $val) {
- if (!is_int($val)) {
- $val = '"' . $val . '"';
- }
- $options[] = $key . ':' . $val;
- }
- return join(', ', $options);
- }
-}
?>

0 comments on commit 005cc1b

Please sign in to comment.