Example #1
0
 /**
  * @dataProvider provideTestToStringConsSetters
  */
 public function testToStringConsSetters($tagname, $content, $attributes, $html)
 {
     $tag1 = new HTMLTag($tagname, $content, $attributes);
     $this->assertEquals((string) $tag1, $html);
     $this->assertEquals($tag1->html(), $html);
     /* wir versuchen noch andere methoden das tag zu erstellen */
     $tag2 = new HTMLTag($tagname);
     $tag2->setContent($content);
     $tag2->setAttributes($attributes);
     $this->assertEquals((string) $tag2, $html);
     $this->assertEquals($tag2->html(), $html);
     $tag3 = fHTML::tag($tagname, $content, $attributes);
     $this->assertEquals((string) $tag3, $html);
     $this->assertEquals($tag3->html(), $html);
     $tag4 = fHTML::tag($tagname)->setContent($content)->setAttributes($attributes);
     $this->assertEquals((string) $tag4, $html);
     $this->assertEquals($tag4->html(), $html);
     $tag5 = clone $tag4;
     if (is_array($attributes)) {
         foreach ($attributes as $key => $attr) {
             $tag5->setAttribute($key, $attr);
         }
     }
     $this->assertEquals((string) $tag4, (string) $tag5);
     $this->assertEquals($tag4->html(), $html);
 }
Example #2
0
 /**
  * Gibt die Attribute des Tags zurück
  *
  * Fügt jeder Klasse des Tags einen namespace hinzu, sofern die klasse mit \Psc anfängt
  */
 public function getAttributes()
 {
     $attributes = parent::getAttributes();
     /* wir fügen den namespace hinzu wenn es nötig ist */
     if (isset($attributes['class']) && ($namespace = $this->getOption('css.namespace')) != '') {
         $attributes['class'] = array_map(array('\\Psc\\UI\\UI', 'getClass'), $attributes['class']);
     }
     return $attributes;
 }
Example #3
0
 /**
  * Fügt dem JavaScript des Tags eine weitere Funktion hinzu
  *
  * z. B. so:
  * <span id="element"></span>
  * <script type="text/javascript">$('#element').click({..})</script>
  *
  * @param Expression $code wird mit einem . an das Javascript des Selectors angehängt $code darf also am Anfang keinen . haben
  */
 public static function chain(\Psc\HTML\Tag $tag, Expression $code)
 {
     if (isset($tag->templateContent->jQueryChain)) {
         // append to previous created chain
         $tag->templateContent->jQueryChain .= sprintf("\n      .%s", $code->JS());
     } else {
         /*
          * make something like:
          *
          * require([...], function () {
          *   require([...], function (jQuery) {
          *     jQuery('selector for element')%jQueryChain%
          *   });
          * });
          */
         $tag->templateAppend("\n" . Helper::embedWithJQuery(new jsCode('    ' . self::getClassSelector($tag) . '%jQueryChain%')));
         $tag->templateContent->jQueryChain = sprintf("\n      .%s", $code->JS());
     }
     return $tag;
 }
Example #4
0
 public function __construct($content, array $attributes = array())
 {
     parent::__construct('script', $content, $attributes);
     $this->setAttribute('type', 'x-jquery-tmpl');
 }
Example #5
0
 /**
  * Missbraucht die Klasse als "Header" für eine HTML Datei
  *
  * wird dies gesetzt, endet das html bei <body> (öffnen)
  * es muss dann body und html von hand geschlossen werden
  *
  * $html = new \Psc\HTML\Page();
  * $html->setOpen();
  * print $html;
  * 
  * // hier goes the content
  * 
  * 
  * print $html->getClose();
  */
 public function setOpen()
 {
     $this->body->setOption('closeTag', FALSE);
     $this->html->setOption('closeTag', FALSE);
     return $this;
 }
Example #6
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;
 }
Example #7
0
 /**
  * Fügt hinter diesem Element ein anderes Element an
  */
 public function after(Tag $after)
 {
     $id = $after->guid();
     $this->templateAppend('%' . $id . '%');
     $this->templateContent->{$id} =& $after;
 }