Esempio n. 1
0
 /**
  * Set no padding
  */
 private function _setNoPadding()
 {
     if ($this->noPadding !== null) {
         Html::addCssClass($this->bodyOptions, 'no-padding');
     }
 }
Esempio n. 2
0
 /**
  * See [[checkbox()]] for details
  */
 public static function checkboxSmart($name, $checked = false, $options = [])
 {
     $options['checked'] = (bool) $checked;
     $value = array_key_exists('value', $options) ? $options['value'] : '1';
     if (isset($options['uncheck'])) {
         // add a hidden field so that if the checkbox is not selected, it still submits a value
         $hidden = static::hiddenInput($name, $options['uncheck']);
         unset($options['uncheck']);
     } else {
         $hidden = '';
     }
     if (isset($options['label'])) {
         $label = $options['label'];
         $labelOptions = isset($options['labelOptions']) ? $options['labelOptions'] : [];
         unset($options['label'], $options['labelOptions']);
         $iconOptions = ArrayHelper::remove($options, 'iconOptions', []);
         $iconTag = ArrayHelper::remove($iconOptions, 'tag', 'i');
         $content = static::label(static::input('checkbox', $name, $value, $options) . Html::tag($iconTag, null, $iconOptions) . $label, null, $labelOptions);
         return $hidden . $content;
     } else {
         return $hidden . static::input('checkbox', $name, $value, $options);
     }
 }
Esempio n. 3
0
 public function renderSubItems($items)
 {
     $lines = [];
     foreach ($items as $i => $item) {
         if (isset($item['visible']) && !$item['visible']) {
             unset($items[$i]);
             continue;
         }
         if (is_string($item)) {
             $lines[] = $item;
             continue;
         }
         if (!isset($item['label'])) {
             throw new InvalidConfigException("The 'label' option is required.");
         }
         $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
         $label = $encodeLabel ? Html::encode($item['label']) : $item['label'];
         $label = isset($item['icon']) ? $item['icon'] . ' ' . $label : $label;
         $label = isset($item['badge']) ? $label . ' ' . $item['badge'] : $label;
         $options = ArrayHelper::getValue($item, 'options', []);
         $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
         $content = Html::a($label, ArrayHelper::getValue($item, 'url', '#'), $linkOptions);
         if (!empty($item['items'])) {
             $content .= $this->renderSubItems($item['items']);
         }
         $lines[] = Html::tag('li', $content, $options);
     }
     return Html::tag('ul', implode("\n", $lines));
 }
Esempio n. 4
0
 /**
  * Create date picker
  * @param array $options
  * @return $this
  */
 public function datepicker($options = [])
 {
     $view = $this->form->getView();
     if (array_key_exists('id', $options)) {
         $id = $options['id'];
     } else {
         $id = Html::getInputId($this->model, $this->attribute);
     }
     $jsParams = Json::encode($options);
     $view->registerJs("jQuery('#{$id}').datepicker({$jsParams});");
     return $this;
 }
Esempio n. 5
0
 public function testBeginEndIcon()
 {
     ob_start();
     $jarvis = Jarvis::begin(['id' => 'begin-end', 'icon' => 'its not print']);
     echo '<p>Body</p>';
     $jarvis->beginIcon();
     echo Html::icon(Html::ICON_FA_BELL_SLASH);
     $jarvis->endIcon();
     Jarvis::end();
     $content = ob_get_clean();
     $str = '<div id="begin-end" class="jarviswidget">' . '<header>' . '<span class="widget-icon"><i class="fa fa-bell-slash"></i></span>' . '</header>' . '<div>' . '<div class="widget-body"><p>Body</p></div>' . '</div>' . '</div>';
     $this->assertEquals($content, $str);
 }