コード例 #1
0
ファイル: Checkbox.php プロジェクト: 2amigos/yii2-semantic-ui
 /**
  * @inheritdoc
  * @throws \yii\base\InvalidConfigException
  */
 public function init()
 {
     parent::init();
     if ($this->label === null) {
         $this->label = $this->hasModel() ? $this->model->getAttributeLabel($this->attribute) : ArrayHelper::getValue($this->options, 'label', false);
     }
     Html::removeCssClass($this->options, 'ui');
     Ui::addCssClasses($this->wrapperOptions, ['ui', 'checkbox']);
     $this->wrapperOptions['id'] = $this->options['id'] . '-wrapper';
     $this->selector = $this->selector ?: '#' . $this->wrapperOptions['id'];
 }
コード例 #2
0
ファイル: Message.php プロジェクト: 2amigos/yii2-semantic-ui
 /**
  * Initializes the widget options
  */
 public function initOptions()
 {
     Ui::addCssClasses($this->options, ['ui', 'message']);
     if (!empty($this->header) && isset($this->header['options'])) {
         Ui::addCssClass($this->header['options'], 'header');
     }
     if (isset($this->icon)) {
         Ui::addCssClass($this->options, 'icon');
     }
 }
コード例 #3
0
ファイル: Element.php プロジェクト: 2amigos/yii2-semantic-ui
 /**
  * Generates step element @see http://semantic-ui.com/elements/step.html
  *
  * @param array $items the configuration of the steps. The configuration options may include:
  * - tag, string, optional, the layer tag. Defaults to 'div'
  * - icon, string, optional, the icon to display on the step
  * - title, string, optional, the title of the step
  * - description, string, optional, the description of the step
  * @param array $options the tag options in terms of name-value pairs
  *
  * @return string the generated step tag
  */
 public static function steps($items, $options = [])
 {
     $steps = array_map(function ($item) {
         $icon = ArrayHelper::remove($item, 'icon', '');
         $title = ArrayHelper::remove($item, 'title', '');
         $description = ArrayHelper::remove($item, 'description');
         if (!empty($title)) {
             $title = Ui::tag('div', $title, ['class' => 'title']);
         }
         if (!empty($description)) {
             $description = Ui::tag('div', $description, ['class' => 'description']);
         }
         if (!empty($icon)) {
             $icon = static::icon($icon);
             $content = Ui::tag('div', $title . $description, ['class' => 'content']);
         } else {
             $content = $title . $description;
         }
         return static::step($icon . $content, $item);
     }, $items);
     Ui::addCssClasses($options, ['ui', 'steps']);
     return Ui::tag('div', implode("\n", $steps), $options);
 }
コード例 #4
0
ファイル: Shape.php プロジェクト: 2amigos/yii2-semantic-ui
 /**
  * Renders the configured sides
  *
  * @param array $sides @see $sides
  *
  * @return string the generated shape sides
  * @throws InvalidConfigException
  */
 protected function renderSides($sides)
 {
     $lines = [];
     $lines[] = Html::beginTag('div', $this->sidesOptions);
     foreach ($sides as $side) {
         if (!array_key_exists('content', $side)) {
             throw new InvalidConfigException("The 'content' option is required per sides");
         }
         $options = ArrayHelper::getValue($side, 'options', []);
         Ui::addCssClass($options, 'side');
         $active = ArrayHelper::getValue($side, 'active', false);
         if ($active === true) {
             Ui::addCssClass($options, 'active');
         }
         $lines[] = Html::tag('div', $side['content'], $options);
     }
     $lines[] = Html::endTag('div');
     return implode("\n", $lines);
 }