Example #1
0
 /**
  * 
  * @param mixed $content
  * @param mixed $options
  * @return \PhpBootstrap\Html\Tag
  */
 public function createItem($content, $options = null)
 {
     if (is_array($content)) {
         $options = $content;
         $content = isset($options['content']) ? $options['content'] : '';
     }
     $href = isset($options['href']) ? $options['href'] : '#';
     unset($options['href']);
     $active = isset($options['active']) && $options['active'];
     unset($options['active']);
     $disabled = isset($options['disabled']) && $options['disabled'];
     unset($options['disabled']);
     $link = new Link($content, $href);
     $li = new Tag('li', $link, $options);
     if ($active) {
         $li->addClass('active');
     }
     if ($disabled) {
         $li->addClass('disabled');
     }
     return $li;
 }
Example #2
0
 /**
  * 
  * @param string $device xs|sm|md|lg|print
  * @param string $type   block|inline|inline-block|print
  * @return \PhpBootstrap\Html\Form\Element
  */
 public function setVisibility($device, $type = 'block')
 {
     if (!in_array($device, array('xs', 'sm', 'md', 'lg', 'print'))) {
         return $this;
     }
     if (!in_array($type, array('block', 'inline', 'inline-block', 'hidden'))) {
         return $this;
     }
     $classes = $this->tag->getClass();
     foreach ($classes as $class) {
         if (strstr($class, "visible-{$device}") || $class == "hidden-{$device}") {
             $this->tag->removeClass($class);
         }
     }
     if ($type == 'hidden') {
         $this->tag->addClass("hidden-{$device}");
     } else {
         $this->tag->addClass("visible-{$device}-{$type}");
     }
     return $this;
 }
Example #3
0
 public function addItem($item, $description = null, $title = null, $active = false)
 {
     if (is_array($item)) {
         if (isset($item['description'])) {
             $description = $item['description'];
         }
         if (isset($item['title'])) {
             $title = $item['title'];
         }
         if (isset($item['active']) && $item['active']) {
             $active = true;
         }
         if (isset($item['img'])) {
             $item = $item['img'];
         }
     }
     if ($item instanceof Img) {
         $img = $item;
     } elseif (is_string($item)) {
         $img = new Img($item);
     }
     $div = new Tag('div', $img, ['class' => 'item']);
     if ($active) {
         $div->addClass('active');
     }
     if ($title || $description) {
         $caption = new Tag('div', '', ['class' => 'carousel-caption']);
         if ($title) {
             $caption->append(new Tag('h3', $title));
         }
         if ($description) {
             $caption->append(new Tag('p', $description));
         }
         $div->append($caption);
     }
     $this->inner->append($div);
     $indicatorOptions = $active ? ['class' => 'active'] : null;
     $this->indicators->addItem('', $indicatorOptions);
     return $this;
 }