/** * @param mixed $value nicht umgewandelt * z.B. NULL */ public function writeValue($value, Type $type) { if ($value === NULL) { return 'undefined'; } return jsHelper::convertValue($value); }
/** * * gibt einen Array mit HTML Tags zurück die Script-Tags sind und jeweils ein JS File laden * @return HTMLTag[] */ public function getHTML() { $html = array(); foreach ($this->enqueued as $alias) { $html[] = js::load($this->url . $this->files[$alias]['name'])->setOption('br.closeTag', FALSE); } return $html; }
public function getHTML() { $html = array(); $html[] = Helper::load($this->requirejsSource)->setAttribute('data-main', $this->main)->setOption('br.closeTag', FALSE); foreach ($this->enqueued as $alias) { $html[] = Helper::load($this->files[$alias]['name'])->setOption('br.closeTag', FALSE); } return $html; }
public static function onWindowLoad($jsCode) { if ($jsCode instanceof \Psc\JS\Lambda) { $c = $jsCode->JS(); } elseif ($jsCode instanceof \Psc\JS\Expression) { $c = 'function() { ' . $jsCode->JS() . ' }'; } else { $c = 'function() { ' . (string) $jsCode . ' }'; } return Helper::embed('jQuery(window).load(' . $c . ')'); }
public function JSON() { return \Psc\JS\Helper::reformatJSON(json_encode($this->exportJSON())); }
public function html() { return Helper::embed($this->JS()); }
/** * @return Psc\HTML\Tag */ public function loadConditionalJS($url, $condition) { $this->head->content[$url] = '<!--[if ' . $condition . ']>' . ($script = js::load($url)) . '<![endif]-->'; return $script; }
protected function createJSONResponse($body) { if ($body instanceof \Psc\JS\JSON) { return $this->createResponse($body->JSON()); } elseif (is_array($body) || is_object($body) && $body instanceof \stdClass) { return $this->createResponse($this->prettyPrintJSON ? \Psc\JS\Helper::reformatJSON(json_encode($body)) : json_encode($body)); } elseif ($body instanceof \Psc\Data\Exportable) { $body = $body->export(); return $this->createResponse($this->prettyPrintJSON ? \Psc\JS\Helper::reformatJSON(json_encode($body)) : json_encode($body)); } }
/** * 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; }
/** * Wählt den Index aus, der direkt nach dem Laden der Seite geladen werden soll * * dies initialisiert das widget auch auf Javascript-Basis */ public function select($index) { $this->init(); $this->select = $index; $this->html->getTemplateContent()->select = jsHelper::embed(jsHelper::bootLoad(array('app/main'), array('main'), sprintf("var tabs = main.getTabs(), tab = tabs.tab({index: %d});\n tabs.select(tab);", $this->select))); return $this; }
/** * Use this selector for widgets created with jooseSnippet */ protected function widgetSelector(\Psc\HTML\Tag $tag = NULL, $subSelector = NULL) { $jQuery = \Psc\JS\jQuery::getClassSelector($tag ?: $this->html); if (isset($subSelector)) { $jQuery .= sprintf(".find(%s)", \Psc\JS\Helper::convertString($subSelector)); } return $this->jsExpr($jQuery); }
protected function findInJSComponent($selector) { return $this->jsExpr(self::JS_COMPONENT . sprintf(".find(%s)", \Psc\JS\Helper::convertString($selector))); }