Esempio n. 1
0
 public function testConstructor()
 {
     $tag = new GenericTag('foo', 'bar');
     $this->assertEquals('<foo>bar</foo>', $tag->getHTML());
     $tag = new GenericTag('foo', ['bar', 'baz', 'bax']);
     $this->assertEquals('<foo>barbazbax</foo>', $tag->getHTML());
 }
Esempio n. 2
0
 /**
  * @param float $percent 0 <= percent <= 100.
  * @param string $type
  * @param string $content
  */
 public function __construct($percent, $type = self::TYPE_DEFAULT, $content = null)
 {
     if ($percent > 100) {
         $percent = 100;
     }
     if ($percent < 0) {
         $percent = 0;
     }
     $this->addClass('progress');
     if (empty($content)) {
         $content = new GenericTag('span');
         $content->addClass('sr-only');
         $content->setContent($percent . '%');
     }
     $this->content = new GenericTag('div');
     $this->content->addClass('progress-bar');
     if (!in_array($type, $this->types)) {
         $type = self::TYPE_DEFAULT;
     }
     if ($type !== self::TYPE_DEFAULT) {
         $this->content->addClass('progress-bar-' . $type);
     }
     $this->content->setAttribute('role', 'progress');
     $this->content->setAttribute('aria-valuenow', $percent);
     $this->content->setAttribute('aria-valuemin', 0);
     $this->content->setAttribute('aria-valuemax', 100);
     $this->content->setAttribute('style', 'width="' . $percent . '%"');
     parent::__construct('div', $content);
 }
Esempio n. 3
0
 /**
  * GenericTab "ul.nav-tabs" with navigation links for all tabs as content.
  * @return string
  */
 public function getTabsNavAsString()
 {
     $list = [];
     foreach ($this->tabs as $tab) {
         $a = new GenericTag('a', $tab->getTitle());
         $a->setAttribute('href', '#' . $tab->getAttribute('id'));
         $a->setAttribute('data-toggle', 'tab');
         if ($tab->isAjax()) {
             $a->setAttribute('data-src', implode('', $tab->getContent()));
         }
         $li = new GenericTag('li', $a);
         if ($this->activatedTab === $tab) {
             $li->addClass('active');
         }
         $list[] = $li;
     }
     $tabsNav = clone $this->tabsNav;
     return (string) $tabsNav->setContent($list);
 }
Esempio n. 4
0
 /**
  * @param string $content
  */
 public function __construct($content)
 {
     $this->addClass('well');
     parent::__construct('div', $content);
 }
Esempio n. 5
0
 /**
  * @param string $content
  * @param string $type Const Label::TYPE_.
  */
 public function __construct($content, $type = self::TYPE_DEFAULT)
 {
     $this->addClass('label');
     $this->changeType($type);
     parent::__construct('span', $content);
 }
Esempio n. 6
0
 /**
  * @param string $content
  */
 public function __construct($content = null)
 {
     $this->addClass('badge');
     parent::__construct('span', $content);
 }
Esempio n. 7
0
File: Tab.php Progetto: myclabs/muih
 /**
  * {@inheritdoc}
  */
 public function getContentAsString()
 {
     if ($this->isAjax()) {
         return $this->loadingText;
     }
     return parent::getContentAsString();
 }