コード例 #1
0
ファイル: Nav.php プロジェクト: cobisja/boothelp
 /**
  * Process the Nav's options.
  *
  * @param array $options Nav's options.
  * @return array Nav's options processed.
  */
 private function nav_options($options = [])
 {
     $this->append_class($options, 'nav');
     if (Base::get_navbar_id()) {
         $this->append_class($options, 'navbar-nav');
     } else {
         if (isset($options['as'])) {
             $as = 'single' === $options['as'] ? '' : 'nav-' . $options['as'];
             unset($options['as']);
         } else {
             $as = 'nav-tabs';
         }
         $this->append_class($options, $as);
         if (isset($options['layout'])) {
             $this->append_class($options, "nav-{$options['layout']}");
             unset($options['layout']);
         }
     }
     return $options;
 }
コード例 #2
0
ファイル: Dropdown.php プロジェクト: cobisja/boothelp
 /**
  * Initializes the Dropdown instance.
  *
  * @param string $caption Dropdown caption.
  * @param array $options options to build the Dropdown.
  * @param closure $block closure to build the Dropdown content.
  */
 public function __construct($caption, $options = [], $block = null)
 {
     if (is_callable($options)) {
         $block = $options;
         $options = [];
     }
     $options['id'] = isset($options['id']) ? $options['id'] : 'label-dropdown-' . (string) mt_rand(1, pow(10, 10));
     $options['caption'] = $caption . Base::SPACE;
     $options['div_class'] = $this->dropdown_div_class($options);
     $options['button_class'] = $this->dropdown_button_class($options);
     $options['list_class'] = $this->dropdown_list_class($options);
     Base::set_dropdown_link(true);
     $yield = is_callable($block) ? call_user_func($block) : null;
     //        $dropdown = isset($options['split']) && $options['split'] ? $this->build_split_dropdown($options, $yield) : $this->build_standard_dropdown($options, $yield);
     if (isset($options['into_navbar']) && $options['into_navbar'] || '' !== Base::get_navbar_id()) {
         $dropdown = $this->build_standard_dropdown_into_navbar($options, $yield);
     } elseif (isset($options['into_nav']) && $options['into_nav'] || Base::get_nav_link()) {
         $dropdown = $this->build_standard_dropdown_into_nav($options, $yield);
     } else {
         $dropdown = isset($options['split']) && $options['split'] ? $this->build_split_dropdown($options, $yield) : $this->build_standard_dropdown($options, $yield);
     }
     Base::set_dropdown_link(false);
     $this->set_html_object($dropdown->get_html_object());
 }
コード例 #3
0
ファイル: Button.php プロジェクト: cobisja/boothelp
 /**
  * Sets the different Button classes.
  *
  * @param array $options Button's options.
  * @return string html class for the button.
  */
 private function btn_class(&$options = [])
 {
     $base_options = ['context' => null, 'size' => '', 'layout' => null];
     $valid_contexts = ['primary', 'success', 'info', 'warning', 'danger', 'link'];
     $this->set_options($base_options, $options);
     $context = $this->context_for($options['context'], ['valid' => $valid_contexts]);
     $size = null;
     switch ($options['size']) {
         case 'lg':
         case 'large':
             $size = 'btn-lg';
             break;
         case 'sm':
         case 'small':
             $size = 'btn-sm';
             break;
         case 'xs':
         case 'extra_small':
             $size = 'btn-xs';
             break;
     }
     $layout = $options['layout'] === 'block' ? 'btn-block' : null;
     $navbar_btn_class = '' !== Base::get_navbar_id() ? 'navbar-btn' : null;
     unset($options['context']);
     unset($options['size']);
     unset($options['layout']);
     return join(Base::SPACE, array_filter(['btn', "btn-{$context}", $size, $layout, $navbar_btn_class], 'strlen'));
 }
コード例 #4
0
ファイル: Horizontal.php プロジェクト: cobisja/boothelp
 /**
  * Build the Horizontal object.
  *
  * @param array $options options to build the Horizontal object.
  * @param closure $block Closure to build the Horizontal object.
  * @return ContentTag instance of ContenTag that represents the Horizontal object.
  */
 private function build_horizontal($options = [], $block = null)
 {
     $this->append_class($options, 'collapse navbar-collapse');
     $options['id'] = Base::get_navbar_id();
     return new ContentTag('div', $options, $block);
 }
コード例 #5
0
ファイル: Vertical.php プロジェクト: cobisja/boothelp
 /**
  * Builds the toggle button that shows up when resizing browser.
  *
  * @param arrray $options options to build the toggle button.
  * @return mixed Html that represents the toggle button.
  */
 private function toggle_button($options = [])
 {
     $options['type'] = 'button';
     $options['class'] = 'navbar-toggle';
     $options['data-toggle'] = 'collapse';
     $options['data-target'] = '#' . Base::get_navbar_id();
     return (new ContentTag('button', $options, function () {
         return [$this->toggle_text(), $this->toggle_bar(), $this->toggle_bar(), $this->toggle_bar()];
     }))->get_html_object();
 }