Example #1
0
 /**
  * Renders the progress bar
  *
  * @return string
  */
 public function render()
 {
     $string = "<div class='progress'>";
     $attributes = new Attributes($this->attributes, ['class' => "progress-bar {$this->type}", 'role' => 'progressbar', 'aria-valuenow' => "{$this->value}", 'aria-valuemin' => '0', 'aria-valuemax' => '100', 'style' => $this->value ? "width: {$this->value}%" : '']);
     if ($this->striped) {
         $attributes->addClass('progress-bar-striped');
     }
     if ($this->animated) {
         $attributes->addClass('active');
     }
     $string .= "<div {$attributes}>";
     $string .= $this->visible ? sprintf($this->visibleString, $this->value) : "<span class='sr-only'>{$this->value}% complete</span>";
     $string .= "</div>";
     $string .= "</div>";
     return $string;
 }
Example #2
0
 public function render()
 {
     $attributes = new Attributes(['class' => $this->vertical ? 'btn-group-vertical' : 'btn-group', 'data-toggle' => 'buttons']);
     if ($this->size) {
         $attributes->addClass($this->size);
     }
     $contents = $this->renderContents();
     return "<div {$attributes}>{$contents}</div>";
 }
Example #3
0
 /**
  * Renders the alert
  *
  * @return string
  */
 public function render()
 {
     $attributes = new Attributes($this->attributes, ['class' => "alert {$this->type}"]);
     if ($this->closer) {
         $attributes->addClass('alert-dismissable');
         $this->contents = "<button type='button' class='close' " . "data-dismiss='alert' aria-hidden='true'>{$this->closer}" . "</button>{$this->contents}";
     }
     return "<div {$attributes}>{$this->contents}</div>";
 }
Example #4
0
 /**
  * Renders the button
  *
  * @return string as a string
  */
 public function render()
 {
     // Set up sensible defaults
     $defaults = ['type' => 'button', 'class' => "btn {$this->type}"];
     if ($this->url) {
         // An <a> tag should not have a type attribute
         unset($defaults['type']);
     }
     $attributes = new Attributes($this->attributes, $defaults);
     // Add size and block status if needed
     if ($this->size) {
         $attributes->addClass($this->size);
     }
     if ($this->block) {
         $attributes->addClass(self::BLOCK);
     }
     // Add the icon if needed
     $value = $this->icon ? $this->getValueWithIcon() : $this->value;
     // Set disabled and url
     if ($this->disabled) {
         $attributes['disabled'] = 'disabled';
     }
     if ($this->url) {
         $attributes['href'] = $this->url;
     }
     // Create the right tag
     $tag = $this->url ? 'a' : 'button';
     return "<{$tag} {$attributes}>{$value}</{$tag}>";
 }
 /**
  * Renders the dropdown button
  *
  * @return string
  */
 public function render()
 {
     if ($this->dropup) {
         $string = "<div class='btn-group dropup'>";
     } else {
         $string = "<div class='btn-group'>";
     }
     $attributes = new Attributes($this->attributes, ['class' => "btn {$this->type} dropdown-toggle", 'data-toggle' => 'dropdown', 'type' => 'button']);
     if ($this->size) {
         $attributes->addClass($this->size);
     }
     if ($this->split) {
         $splitAttributes = new Attributes(['class' => $attributes['class'], 'type' => 'button']);
         $splitAttributes['class'] = str_replace(' dropdown-toggle', '', $splitAttributes['class']);
         $string .= "<button {$splitAttributes}>{$this->label}</button>";
         $string .= "<button {$attributes}><span class='caret'></span></button>";
     } else {
         $string .= "<button {$attributes}>{$this->label} <span class='caret'></span></button>";
     }
     $string .= "<ul class='dropdown-menu' role='menu' aria-labelledby='dLabel'>";
     $string .= $this->renderItems();
     $string .= "</ul>";
     $string .= "</div>";
     return $string;
 }
Example #6
0
 /**
  * Renders the accordion
  *
  * @return string
  */
 public function render()
 {
     if (!$this->name) {
         $this->name = Helpers::generateId($this);
     }
     $attributes = new Attributes($this->attributes, ['class' => 'panel-group', 'id' => $this->name]);
     $string = "<div {$attributes}>";
     $count = 0;
     foreach ($this->contents as $item) {
         $itemAttributes = array_key_exists('attributes', $item) ? $item['attributes'] : [];
         $itemAttributes = new Attributes($itemAttributes, ['class' => 'panel panel-default']);
         $string .= "<div {$itemAttributes}>";
         $string .= "<div class='panel-heading'>";
         $string .= "<h4 class='panel-title'>";
         $string .= "<a data-toggle='collapse' data-parent='#{$this->name}' " . "href='#{$this->name}-{$count}'>{$item['title']}</a>";
         $string .= "</h4>";
         $string .= "</div>";
         $bodyAttributes = new Attributes(['id' => "{$this->name}-{$count}", 'class' => 'panel-collapse collapse']);
         if ($this->opened == $count) {
             $bodyAttributes->addClass('in');
         }
         $string .= "<div {$bodyAttributes}>";
         $string .= "<div class='panel-body'>{$item['contents']}</div>";
         $string .= "</div>";
         $string .= "</div>";
         $count++;
     }
     $string .= "</div>";
     return $string;
 }
Example #7
0
 /**
  * Creates the content tabs
  *
  * @return array
  */
 protected function createContentTabs()
 {
     $tabs = [];
     $count = 0;
     foreach ($this->contents as $item) {
         $itemAttributes = isset($item['attributes']) ? $item['attributes'] : [];
         $attributes = new Attributes($itemAttributes, ['class' => 'tab-pane', 'id' => Helpers::slug($item['title'])]);
         if ($this->fade) {
             $attributes->addClass('fade');
         }
         if ($this->active == $count) {
             $attributes->addClass($this->fade ? 'in active' : 'active');
         }
         $tabs[] = ['content' => $item['content'], 'attributes' => $attributes];
         $count += 1;
     }
     return $tabs;
 }