public function run()
 {
     $this->clientOptions['treeViewId'] = $this->treeViewId;
     $this->registerWidget();
     \yii\helpers\Html::addCssClass($this->options, 'execut-tree-filter-input');
     $inputOptions = $this->inputOptions;
     Html::addCssClass($inputOptions, 'form-control');
     $inputOptions['autocomplete'] = 'off';
     echo $this->_renderContainer(Html::input('text', 'search', null, $inputOptions) . '<span class="close" title="Clear search results">×</span>');
 }
Ejemplo n.º 2
0
 /**
  * Generates the button dropdown.
  * @return string the rendering result.
  */
 protected function renderButton()
 {
     // Html::addCssClass($this->options, ['widget' => 'btn']);
     $label = $this->label;
     $options = $this->options;
     if (!isset($options['href'])) {
         $options['href'] = '#';
     }
     Html::addCssClass($options, ['toggle' => 'dropdown-toggle']);
     $options['data-toggle'] = 'dropdown';
     return Html::tag($this->tagName, $label, $options) . "\n";
 }
Ejemplo n.º 3
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     parent::run();
     // TODO: Change the autogenerated stub
     if (!empty($this->country)) {
         $class = 'flag-icon flag-icon-' . $this->country;
         Html::addCssClass($this->options, $class);
         if ($this->squared) {
             Html::addCssClass($this->options, 'flag-icon-squared');
         }
         $this->register();
         echo Html::beginTag('span', $this->options);
         echo Html::endTag('span');
     }
 }
Ejemplo n.º 4
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     foreach ($this->items as &$item) {
         // icon ?
         if (isset($item['icon'])) {
             $icon = FA::icon($item['icon'] . ' fw');
             $item['label'] = trim($icon . ' ' . ArrayHelper::getValue($item, 'label', ''));
             $item['encode'] = false;
             unset($item['icon']);
         }
         // active ?
         if (isset($item['active'])) {
             $active = $item['active'];
             if ($active instanceof \Closure) {
                 $active = call_user_func($active, $this->getView()->getContext());
             }
             if ($active) {
                 Html::addCssClass($item['options'], 'active');
             }
             unset($item['active']);
         }
     }
     return parent::run();
 }
 /**
  * @inheritdoc
  */
 public function run()
 {
     //register assets
     $this->registerPlugin('button');
     AjaxToggleButtonAsset::register($this->getView());
     //prepare ajax params
     $params = [];
     foreach ($this->model->primaryKey() as $pkCol) {
         $params[$pkCol] = $this->model->{$pkCol};
     }
     Html::addCssClass($this->options, 'widget-ajax-button');
     $this->options['data']['current-value'] = $this->model->{$this->booleanAttribute};
     $this->options['data']['pjax'] = 0;
     $this->options['data']['boolean-format'] = $this->booleanFormat;
     $this->options['data']['ajax-params'] = $params;
     $this->options['data']['ajax-method'] = $this->ajaxMethod;
     return Html::a($this->createLabel(), $this->ajaxUrl, $this->options);
 }
Ejemplo n.º 6
0
 /**
  * Check to see if a child item is active optionally activating the parent.
  * @param array $items @see items
  * @param boolean $active should the parent be active too
  * @return array @see items
  */
 protected function isChildActive($items, &$active)
 {
     foreach ($items as $i => $child) {
         if (ArrayHelper::remove($items[$i], 'active', false) || $this->isItemActive($child)) {
             Html::addCssClass($items[$i]['options'], 'active');
             if ($this->activateParents) {
                 $active = true;
             }
         }
     }
     return $items;
 }
Ejemplo n.º 7
0
 public function addClass($class)
 {
     BaseHtml::addCssClass($this->options, $class);
     return $this;
 }
Ejemplo n.º 8
0
 /**
  * Creates a squared flag icon
  * @return self
  */
 public function square()
 {
     Html::addCssClass($this->options, 'flag-icon-squared');
     return $this;
 }
Ejemplo n.º 9
0
 protected function getFilterError()
 {
     $model = $this->grid->filterModel;
     if ($model->hasErrors($this->attribute)) {
         Html::addCssClass($this->filterOptions, 'has-error');
         return ' ' . Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
     } else {
         return '';
     }
 }
Ejemplo n.º 10
0
 /**
  * Return statistic content
  * @return string
  */
 public function renderStatisticContent()
 {
     $content = '';
     if (!empty($this->statisticColumns) && is_array($this->statisticColumns)) {
         $numberColumn = count($this->statisticColumns);
         foreach ($this->statisticColumns as $column) {
             $header = ArrayHelper::getValue($column, 'header', 'Orders');
             $time = ArrayHelper::getValue($column, 'time', 'Annual');
             $percent = ArrayHelper::getValue($column, 'percent', '85%');
             $totalStatistic = ArrayHelper::getValue($column, 'totalStatistic', '40 886,200');
             $smallHeader = ArrayHelper::getValue($column, 'smallHeader', 'New orders');
             // Options element in statistic
             $headerOptions = ArrayHelper::getValue($column, 'headerOptions', []);
             $timeOptions = ArrayHelper::getValue($column, 'timeOptions', []);
             $percentOptions = ArrayHelper::getValue($column, 'percentOptions', []);
             $totalStatisticOptions = ArrayHelper::getValue($column, 'totalStatisticOptions', []);
             $smallHeaderOptions = ArrayHelper::getValue($column, 'smallHeaderOptions', []);
             // Replace input
             if ($header !== false) {
                 Html::addCssClass($headerOptions, '');
                 $header = Html::tag('h5', $header, $headerOptions);
             }
             if ($time !== false) {
                 if (empty($timeOptions['class'])) {
                     $timeOptions['class'] = 'label-success';
                 }
                 Html::addCssClass($timeOptions, 'label pull-right');
                 $time = Html::tag('span', $time, $timeOptions);
             }
             if ($percent !== false) {
                 Html::addCssClass($percentOptions, 'stat-percent font-bold text-success');
                 $percent = Html::tag('div', $percent . ' <i class="fa fa-bolt"></i>', $percentOptions);
             }
             if ($totalStatistic !== false) {
                 Html::addCssClass($totalStatisticOptions, 'no-margins');
                 $totalStatistic = Html::tag('h1', $totalStatistic, $totalStatisticOptions);
             }
             if ($smallHeader !== false) {
                 Html::addCssClass($smallHeaderOptions, '');
                 $smallHeader = Html::tag('small', $smallHeader, $smallHeaderOptions);
             }
             $statistic = strtr($this->statisticTemplate, ['{header}' => $header, '{time}' => $time, '{totalStatistic}' => $totalStatistic, '{percent}' => $percent, '{smallHeader}' => $smallHeader]);
             $content .= Html::tag('div', $statistic, ['class' => 'col-lg-' . round(12 / $numberColumn)]);
         }
     }
     return $content;
 }
Ejemplo n.º 11
0
 /**
  * Renders menu items.
  *
  * @param array $items the menu items to be rendered
  * @param array $options the container HTML attributes
  * @return string the rendering result.
  * @throws InvalidConfigException if the label option is not specified in one of the items.
  */
 protected function renderItems($items, $options = [])
 {
     $lines = [];
     foreach ($items as $i => $item) {
         if (isset($item['visible']) && !$item['visible']) {
             unset($items[$i]);
             continue;
         }
         if (is_string($item)) {
             $lines[] = $item;
             continue;
         }
         if (!array_key_exists('label', $item)) {
             throw new InvalidConfigException("The 'label' option is required.");
         }
         $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
         $label = $encodeLabel ? Html::encode($item['label']) : $item['label'];
         $itemOptions = ArrayHelper::getValue($item, 'options', []);
         $icon = ArrayHelper::getValue($item, 'icon', '');
         $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
         $linkOptions['tabindex'] = '-1';
         $url = array_key_exists('url', $item) ? $item['url'] : null;
         if (!empty($icon)) {
             $icon = Html::tag('i', '', ['class' => $icon]);
         }
         if (empty($item['items'])) {
             if ($url === null) {
                 $content = $label;
                 Html::addCssClass($itemOptions, 'dropdown-header');
             } else {
                 $content = Html::a($icon . $label, $url, $linkOptions);
             }
         } else {
             $submenuOptions = $options;
             unset($submenuOptions['id']);
             $content = Html::a($label, $url === null ? '#' : $url, $linkOptions) . $this->renderItems($item['items'], $submenuOptions);
             Html::addCssClass($itemOptions, 'dropdown-submenu');
         }
         $lines[] = Html::tag('li', $content, $itemOptions);
     }
     return Html::tag('ul', implode("\n", $lines), $options);
 }
Ejemplo n.º 12
0
 /**
  * Initializes the widget options.
  * This method sets the default values for various options.
  */
 protected function initOptions()
 {
     Html::addCssClass($this->options, ['alert', 'fade', 'in']);
     if ($this->closeButton !== false) {
         $this->closeButton = array_merge(['data-dismiss' => 'alert', 'aria-hidden' => 'true', 'class' => 'close'], $this->closeButton);
     }
 }
Ejemplo n.º 13
0
 /**
  * Renders single item.
  * @param array $item item configuration.
  * @return string rendered HTML
  */
 protected function renderItem($item)
 {
     if (isset($item[0])) {
         $url = $item;
         $options = [];
     } else {
         $url = $item['url'];
         $options = $item;
         unset($options['url']);
     }
     // label :
     if (isset($options['label'])) {
         $label = $options['label'];
         unset($options['label']);
     } else {
         $label = $this->detectLabel($url);
     }
     if (isset($options['encode'])) {
         $encodeLabel = $options['encode'];
         unset($options['encode']);
     } else {
         $encodeLabel = $this->encodeLabels;
     }
     if ($encodeLabel) {
         $label = Html::encode($label);
     }
     // icon :
     if (isset($options['icon'])) {
         $icon = $options['icon'];
         unset($options['icon']);
     } else {
         $icon = $this->detectIcon($url);
     }
     if ($icon) {
         $label = Html::icon($icon) . ' ' . $label;
     }
     // CSS class :
     if (isset($options['class'])) {
         Html::addCssClass($options, ['widget' => 'btn']);
     } else {
         $options['class'] = ['btn', $this->detectClass($url)];
     }
     if (!isset($options['data'])) {
         $options['data'] = $this->detectData($url);
     }
     return Html::a($label, $url, $options);
 }
Ejemplo n.º 14
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     //register assets
     $this->registerPlugin('button');
     AjaxToggleButtonAsset::register($this->getView());
     //prepare ajax params
     $params = [];
     foreach ($this->model->primaryKey() as $pkCol) {
         $params[$pkCol] = $this->model->{$pkCol};
     }
     Html::addCssClass($this->options, 'widget-ajax-button');
     if ($this->model->{$this->booleanAttribute}) {
         Html::removeCssClass($this->options, $this->buttonClassOff);
         Html::addCssClass($this->options, $this->buttonClassOn);
     } else {
         Html::removeCssClass($this->options, $this->buttonClassOn);
         Html::addCssClass($this->options, $this->buttonClassOff);
     }
     $this->options['data']['current-value'] = $this->model->{$this->booleanAttribute};
     $this->options['data']['pjax'] = 0;
     $this->options['data']['boolean-format'] = $this->booleanFormat;
     $this->options['data']['ajax-params'] = $params;
     $this->options['data']['ajax-method'] = $this->ajaxMethod;
     $this->options['data']['event-success'] = $this->jsEventSuccess;
     $this->options['data']['event-error'] = $this->jsEventError;
     $this->options['data']['class-on'] = $this->buttonClassOn;
     $this->options['data']['class-off'] = $this->buttonClassOff;
     return Html::a($this->createLabel(), $this->ajaxUrl, $this->options);
 }
Ejemplo n.º 15
0
 /**
  * @return self
  */
 public function icon()
 {
     Html::removeCssClass($this->options, self::BTN_BLOCK);
     Html::removeCssClass($this->options, self::BTN_SOCIAL);
     Html::addCssClass($this->options, self::BTN_SOCIAL_ICON);
     $this->caption = $this->serviceIcon;
     return $this;
 }
Ejemplo n.º 16
0
 /**
  * Generates the button dropdown.
  *
  * @return string the rendering result.
  */
 protected function renderButton()
 {
     $button = '';
     $splitButton = '';
     if (is_string($this->button)) {
         $button = $this->button;
     } else {
         $options = isset($this->button['options']) ? $this->button['options'] : [];
         if (empty($this->splitButton)) {
             $options['data-toggle'] = 'dropdown';
             Html::addCssClass($options, ['toggle' => 'dropdown-toggle']);
         } else {
             Html::addCssClass($options, ['widget' => 'btn', 'class' => 'split-button']);
         }
         $label = isset($this->button['label']) ? $this->button['label'] : null;
         $button = Button::widget(['label' => (isset($this->button['encodeLabel']) && $this->button['encodeLabel'] ? Html::encode($label) : $label) . '  <span class="caret"></span>', 'encodeLabel' => false, 'options' => $options, 'view' => $this->getView()]);
     }
     if (!empty($this->splitButton)) {
         if (is_string($this->splitButton)) {
             $splitButton = $this->splitButton;
         } else {
             $options = isset($this->splitButton['options']) ? $this->splitButton['options'] : [];
             Html::addCssClass($options, ['widget' => 'btn']);
             $options['data-toggle'] = 'dropdown';
             Html::addCssClass($options, ['toggle' => 'dropdown-toggle', 'class' => 'split-toggle']);
             $splitButton = Button::widget(['label' => isset($this->splitButton['label']) ? $this->splitButton['label'] : '<span class="caret"></span>', 'encodeLabel' => false, 'options' => $options, 'view' => $this->getView()]);
         }
     }
     return $splitButton . "\n" . $button;
 }
Ejemplo n.º 17
0
 /**
  * Adds the Font Awesome 'fa-fw' class for fixed width
  * @return self
  */
 public function fixedWidth()
 {
     Html::addCssClass($this->options, 'fa-fw');
     return $this;
 }
Ejemplo n.º 18
0
 /**
  * Renders a widget's item.
  * @param string|array $item the item to render.
  * @return string the rendering result.
  * @throws InvalidConfigException
  */
 public function renderItems()
 {
     $items = [];
     foreach ($this->items as $i => $item) {
         if (isset($item['visible']) && !$item['visible']) {
             continue;
         }
         $items[] = $this->renderItem($item);
     }
     /**
      * Customized widget for MetisMenu navigation dropdowns to not flicker on page load
      * by precomputing if the menu should be open or not. Portions were added below to
      * add the 'collapse' css class if there is an item active within the submenu.
      */
     // Begin custom code
     $hasActive = false;
     foreach ($this->items as $i => $child) {
         if ($this->isItemActive($child)) {
             $hasActive = true;
             break;
         }
     }
     if (!$hasActive) {
         Html::addCssClass($this->options, 'collapse');
     }
     // End custom code
     return Html::tag('ul', implode("\n", $items), $this->options);
 }
Ejemplo n.º 19
0
 /**
  * @param string $class
  * @param bool $condition
  * @param string|bool $throw
  * @return \rmrevin\yii\fontawesome\component\Icon
  * @throws \yii\base\InvalidConfigException
  * @codeCoverageIgnore
  */
 public function addCssClass($class, $condition = true, $throw = false)
 {
     if ($condition === false) {
         if (!empty($throw)) {
             $message = !is_string($throw) ? 'Condition is false' : $throw;
             throw new \yii\base\InvalidConfigException($message);
         }
     } else {
         Html::addCssClass($this->options, $class);
     }
     return $this;
 }