/** * @param mixed $value nicht umgewandelt * z.B. NULL */ public function writeValue($value, Type $type) { if ($value === NULL) { return 'undefined'; } return jsHelper::convertValue($value); }
/** * Fügt dem Tag jquery Data hinzu */ public static function data(Tag $tag, $name, $data) { $js = sprintf("data(%s, %s)", JSHelper::convertString($name), JSHelper::convertValue($data)); $tag->chain(new Code($js)); return $tag; }
/** * @deprecated lieber new JooseSnippet benutzen */ protected function createConstructCode($jooseClass, array $params, $toCode = TRUE, $nested = FALSE) { $constructCode = array(); if (!$nested) { $constructCode[] = ' var j = new ' . $jooseClass . '({'; } else { $constructCode[] = ' new ' . $jooseClass . '({'; } if (count($params) > 0) { foreach ($params as $key => $value) { if ($value === self::SELF_SELECTOR) { $value = $this->getJooseSelector(); } $constructCode[] = sprintf(" '%s': %s,", $key, jsHelper::convertValue($value)); // quotion wegen reserved words wie "delete" } $constructCode[] = mb_substr(array_pop($constructCode), 0, -1); // cutoff last , } $constructCode[] = ' })' . ($nested ? '' : ';'); if (!$nested && isset($this->registerToMain)) { $constructCode[] = sprintf(' main.register(j, %s);', jsHelper::convertValue($this->registerToMain)); } return $toCode ? \Psc\JS\Code::fromCode($constructCode) : $constructCode; }