Beispiel #1
0
 /**
  * @param mixed $value nicht umgewandelt
  * z.B. NULL
  */
 public function writeValue($value, Type $type)
 {
     if ($value === NULL) {
         return 'undefined';
     }
     return jsHelper::convertValue($value);
 }
Beispiel #2
0
 /**
  *
  * 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;
 }
Beispiel #3
0
 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;
 }
Beispiel #4
0
 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 . ')');
 }
Beispiel #5
0
 public function JSON()
 {
     return \Psc\JS\Helper::reformatJSON(json_encode($this->exportJSON()));
 }
Beispiel #6
0
 public function html()
 {
     return Helper::embed($this->JS());
 }
Beispiel #7
0
 /**
  * @return Psc\HTML\Tag
  */
 public function loadConditionalJS($url, $condition)
 {
     $this->head->content[$url] = '<!--[if ' . $condition . ']>' . ($script = js::load($url)) . '<![endif]-->';
     return $script;
 }
Beispiel #8
0
 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));
     }
 }
Beispiel #9
0
 /**
  * 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;
 }
Beispiel #10
0
 /**
  * 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;
 }
Beispiel #11
0
 /**
  * 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);
 }
Beispiel #12
0
 protected function findInJSComponent($selector)
 {
     return $this->jsExpr(self::JS_COMPONENT . sprintf(".find(%s)", \Psc\JS\Helper::convertString($selector)));
 }