コード例 #1
0
ファイル: Select.php プロジェクト: Vincent-X/yii2-semantic-ui
 public function init()
 {
     UI::addCssClasses($this->options, ['ui', 'dropdown']);
     if ($this->search) {
         UI::addCssClasses($this->options, [self::TYPE_SEARCH]);
     }
     if ($this->fluid) {
         UI::addCssClasses($this->options, [self::TYPE_FLUID]);
     }
     if ($this->disabled) {
         UI::addCssClasses($this->options, [self::TYPE_DISABLED]);
     }
     if ($this->compact) {
         UI::addCssClasses($this->options, [self::TYPE_COMPACT]);
     }
     if ($this->upward) {
         UI::addCssClasses($this->options, [self::TYPE_UPWARD]);
     }
     if ($this->multiple) {
         $this->options['multiple'] = true;
     }
     if ($this->type !== self::TYPE_DEFAULT) {
         UI::addCssClasses($this->options, [self::TYPE_SELECTION]);
     }
     parent::init();
 }
コード例 #2
0
ファイル: Table.php プロジェクト: Vincent-X/yii2-semantic-ui
 public function initOption()
 {
     UI::addCssClasses($this->options, ['ui']);
     if ($this->celled) {
         UI::addCssClasses($this->options, [self::TYPE_CELLED]);
     }
     if ($this->striped) {
         UI::addCssClasses($this->options, [self::TYPE_STRIPED]);
     }
     if ($this->definition) {
         UI::addCssClasses($this->options, [self::TYPE_DEFINITION]);
     }
     if ($this->very_compact) {
         UI::addCssClasses($this->options, [self::TYPE_VERY_COMPACY]);
     }
     if ($this->compact) {
         UI::addCssClasses($this->options, [self::TYPE_COMPACT]);
     }
     if ($this->fixed) {
         UI::addCssClasses($this->options, [self::TYPE_FIXED]);
     }
     if ($this->singleLine) {
         UI::addCssClasses($this->options, [self::TYPE_SINGLE_LINE]);
     }
     if ($this->basic) {
         UI::addCssClasses($this->options, [self::TYPE_BASIC]);
     }
     if ($this->collapsing) {
         UI::addCssClasses($this->options, [self::TYPE_COLLAPSING]);
     }
     if (!is_null($this->color)) {
         UI::addCssClasses($this->options, [$this->color]);
     }
     if ($this->randomColor) {
         UI::addCssClasses($this->options, [Color::random()]);
     }
     if ($this->inverted) {
         UI::addCssClasses($this->options, [self::TYPE_INVERTED]);
     }
     if ($this->selectable) {
         UI::addCssClasses($this->options, [self::TYPE_SELECTABLE]);
     }
     if ($this->padded) {
         UI::addCssClasses($this->options, [self::TYPE_PADDED]);
     }
     if ($this->stackable) {
         UI::addCssClasses($this->options, [self::TYPE_STACKABLE]);
     } else {
         UI::addCssClasses($this->options, [self::TYPE_UNSTACKABLE]);
     }
     if (!is_null($this->column)) {
         UI::addCssClasses($this->options, [$this->column, self::TYPE_COLUMN]);
     }
     if (!is_null($this->size) && $this->size === SIZE_SMALL) {
         UI::addCssClasses($this->options, [self::SIZE_SMALL]);
     } elseif (!is_null($this->size) && $this->size === SIZE_LARGE) {
         UI::addCssClasses($this->options, [self::SIZE_LARGE]);
     }
     UI::addCssClasses($this->options, ['table']);
 }
コード例 #3
0
 protected function renderFilterCellContent()
 {
     if (is_string($this->filter)) {
         return $this->filter;
     }
     $model = $this->grid->filterModel;
     if ($this->filter !== false && $model instanceof Model && $this->attribute !== null && $model->isAttributeActive($this->attribute)) {
         if ($model->hasErrors($this->attribute && $this->enableError == true)) {
             $error = Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
         } else {
             $error = '';
         }
         if (is_array($this->filter)) {
             $options = array_merge(['prompt' => ''], $this->filterDropdownOptions);
             if ($model->hasErrors($this->attribute) && $this->enableError == true) {
                 UI::addCssClasses($options, ['error']);
             }
             return Select::widget(['model' => $model, 'attribute' => $this->attribute, 'items' => $this->filter, 'options' => $options, 'search' => true]) . ' ' . $error;
         } else {
             $options = ['class' => 'fluid'];
             if ($model->hasErrors($this->attribute) && $this->enableError == true) {
                 UI::addCssClasses($options, ['error']);
             }
             return UI::inputWraper(Html::activeTextInput($model, $this->attribute, $this->filterInputOptions) . $error, $options);
         }
     } else {
         return parent::renderFilterCellContent();
     }
 }
コード例 #4
0
 public function init()
 {
     parent::init();
     UI::addCssClasses($this->options, ['ui', 'progress']);
     if ($this->percent !== null) {
         $this->clientOptions['percent'] = $this->percent;
     }
     if ($this->indicating) {
         UI::addCssClasses($this->options, [self::TYPE_INDICATING]);
     }
     if ($this->inverted) {
         UI::addCssClasses($this->options, [self::TYPE_INVERTED]);
     }
     if ($this->attached) {
         UI::addCssClasses($this->options, [$this->attached]);
     }
     if ($this->size) {
         UI::addCssClasses($this->options, [$this->size]);
     }
     if ($this->state) {
         UI::addCssClasses($this->options, [$this->state]);
     }
     if ($this->color) {
         UI::addCssClasses($this->options, [$this->color]);
     }
 }
コード例 #5
0
ファイル: Pjax.php プロジェクト: Vincent-X/yii2-semantic-ui
 public function init()
 {
     UI::addCssClasses($this->options, 'dimmable');
     if (!$this->loader) {
         $this->loader = UI::dimmer(UI::loader(), ['class' => 'active inverted']);
     }
     parent::init();
 }
コード例 #6
0
 public function renderSide($side)
 {
     $sideOptions = ['class' => 'side'];
     if ($side['active']) {
         UI::addCssClasses($sideOptions, ['active']);
     }
     return Html::tag('div', $side['content'], $sideOptions);
 }
コード例 #7
0
 public function init()
 {
     parent::init();
     $this->prepareOptions();
     if ($this->inline) {
         UI::addCssClasses($this->options, [self::TYPE_INLINE, 'fields']);
     } else {
         UI::addCssClasses($this->options, [self::TYPE_GROUPED, 'fields']);
     }
 }
コード例 #8
0
 public function renderContent($item)
 {
     $options = ArrayHelper::merge($this->contentOptions, ArrayHelper::getValue($item, 'contentOptions', []));
     $encode = ArrayHelper::getValue($options, 'encode', true);
     $content = $encode ? Html::encode($item['content']) : $item['content'];
     UI::addCssClasses($options, ['content']);
     if ($item['active']) {
         UI::addCssClasses($options, ['active']);
     }
     return Html::tag('div', $content, $options);
 }
コード例 #9
0
 public function init()
 {
     parent::init();
     if ($this->context === null) {
         throw new InvalidConfigException('"context" cannot be null.');
     }
     $this->clientOptions['context'] = $this->context;
     $this->registerPlugin('sticky');
     UI::addCssClasses($this->options, ['ui', 'sticky']);
     echo Html::beginTag('div', $this->options);
 }
コード例 #10
0
 public function init()
 {
     if ($this->size) {
         UI::addCssClasses($this->options, $this->size);
     }
     if ($this->inverted === true) {
         UI::addCssClasses($this->options, 'inverted');
     }
     if ($this->equalWidth === true) {
         UI::addCssClasses($this->options, 'equal width');
     }
     parent::init();
 }
コード例 #11
0
 protected function renderItem($item)
 {
     $item['label'] = $this->encodeLabels ? Html::encode($item['label']) : $item['label'];
     $options = ArrayHelper::getValue($item, 'options', $this->itemOptions);
     UI::addCssClasses($options, ['section']);
     if (isset($item['url'])) {
         $link = Html::a($item['label'], $item['url'], $options);
     } else {
         UI::addCssClasses($options, ['active']);
         $link = UI::div($item['label'], $options);
     }
     return $link;
 }
コード例 #12
0
 /**
  * @return string
  */
 public function renderTabs()
 {
     $items = '';
     foreach ($this->items as $item) {
         UI::addCssClasses($item['contentOptions'], ['ui', 'tab']);
         $item['contentOptions']['data-tab'] = $item['uniqueId'];
         if ($item[self::STATE_ACTIVE]) {
             UI::addCssClasses($item['contentOptions'], [self::STATE_ACTIVE]);
         }
         $items .= Html::tag('div', $item['content'], $item['contentOptions']);
     }
     return $items;
 }
コード例 #13
0
 protected function renderInput($options = [], $resultsOptions = [])
 {
     UI::addCssClasses($options, ['prompt']);
     $lines = [];
     $input = $this->hasModel() ? Html::activeTextInput($this->model, $this->attribute, $options) : Html::textInput($this->name, $this->value, $options);
     if (!empty($this->displayIcon)) {
         $lines[] = $this->renderIcon($input);
     } else {
         $lines[] = $input;
     }
     $lines[] = Html::tag('div', '', $resultsOptions);
     return implode("\n", $lines);
 }
コード例 #14
0
 public function init()
 {
     $this->registerPlugin();
     if (!empty($this->aligned)) {
         UI::addCssClasses($this->rowOptions, [$this->aligned, 'aligned']);
         UI::addCssClasses($this->headerRowOptions, [$this->aligned, 'aligned']);
         UI::addCssClasses($this->footerRowOptions, [$this->aligned, 'aligned']);
     }
     $this->pager['class'] = '\\vx\\Semantic\\Widget\\LinkPager';
     $this->sorter['class'] = '\\vx\\Semantic\\Widget\\LinkSorter';
     $this->dataColumnClass = 'vx\\Semantic\\Widget\\DataColumn';
     $this->initOption();
     parent::init();
 }
コード例 #15
0
 public function init()
 {
     parent::init();
     $this->prepareInputId();
     UI::addCssClasses($this->options, ['ui', $this->type, 'checkbox']);
     if ($this->readOnly) {
         UI::addCssClasses($this->options, [self::TYPE_READONLY]);
     }
     if ($this->disabled) {
         UI::addCssClasses($this->options, [self::TYPE_DISABLED]);
     }
     if ($this->fitted) {
         UI::addCssClasses($this->options, [self::TYPE_FITTED]);
     }
 }
コード例 #16
0
 public function init()
 {
     if ($this->inline) {
         UI::addCssClasses($this->options, ['inline']);
     }
     if ($this->disabled) {
         UI::addCssClasses($this->options, ['disabled']);
     }
     if ($this->width !== '') {
         UI::addCssClasses($this->options, [$this->width, self::WIDE]);
     }
     if ($this->readOnly) {
         $this->inputOptions['readOnly'] = true;
     }
 }
コード例 #17
0
 public function init()
 {
     parent::init();
     UI::addCssClasses($this->options, ['ui', $this->ratio, 'embed']);
     $this->options['data']['source'] = $this->source;
     $this->options['data']['id'] = $this->videoId;
     if ($this->placeholder) {
         $this->options['data']['placeholder'] = $this->placeholder;
     }
     if ($this->url) {
         $this->options['data']['url'] = $this->url;
     }
     if ($this->icon) {
         $this->options['data']['icon'] = $this->icon;
     }
 }
コード例 #18
0
 public function renderToggleButton()
 {
     $tag = ArrayHelper::remove($this->toggleButton, 'tag', 'div');
     $label = ArrayHelper::remove($this->toggleButton, 'label', Html::tag('i', '', ['class' => 'content icon']));
     UI::addCssClasses($this->toggleButton, ['ui', $this->buttonIcon, 'icon', 'button', 'fixed', 'attached']);
     if ($this->position === static::POS_LEFT) {
         $position = static::POS_RIGHT;
     } else {
         $position = static::POS_LEFT;
     }
     UI::addCssClasses($this->toggleButton, [$position]);
     $view = $this->getView();
     UIAsset::register($view);
     $view->registerJs("ui.semantic.init();");
     return Html::tag($tag, $label, $this->toggleButton);
 }
コード例 #19
0
 protected function initDefaultButtons()
 {
     if (!isset($this->button['view'])) {
         $this->buttons['view'] = function ($url, $model, $key) {
             return Html::a(UI::i('eye'), $url, ['class' => 'ui button', 'title' => Yii::t('yii', 'View'), 'data-pjax' => '0']);
         };
     }
     if (!isset($this->button['update'])) {
         $this->buttons['update'] = function ($url, $model, $key) {
             return Html::a(UI::i('pencil'), $url, ['class' => 'ui button', 'title' => Yii::t('yii', 'Update'), 'data-pjax' => '0']);
         };
     }
     if (!isset($this->button['delete'])) {
         $this->buttons['delete'] = function ($url, $model, $key) {
             return Html::a(UI::i('trash'), $url, ['class' => 'ui button', 'title' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'), 'data-method' => 'post', 'data-pjax' => '0']);
         };
     }
 }
コード例 #20
0
 public function init()
 {
     parent::init();
     UI::addCssClasses($this->options, ['ui', 'rating']);
     if ($this->max <= 0) {
         throw new InvalidConfigException("Max rating number cannot be less or equal to 0.");
     }
     if ($this->rating !== null) {
         if ($this->rating > $this->max) {
             throw new InvalidConfigException("Rating number cannot be higher than Max rating number.");
         }
         $this->options['data-rating'] = $this->rating;
     }
     $this->options['data-max-rating'] = $this->max;
     if ($this->type) {
         UI::addCssClasses($this->options, [$this->type]);
     }
     if ($this->size) {
         UI::addCssClasses($this->options, [$this->size]);
     }
 }
コード例 #21
0
 protected function renderPageButton($label, $page, $class, $disabled, $active)
 {
     $options = ['class' => $class === '' ? null : $class];
     $linkOptions = $this->linkOptions;
     $linkOptions['data-page'] = $page;
     UI::addCssClasses($linkOptions, $class);
     if ($disabled && $this->type !== 'simple') {
         UI::addCssClasses($options, $this->disabledPageCssClass);
         return Html::tag('div', Html::tag('span', $label), $options);
     } elseif ($disabled && $this->type == 'simple') {
         UI::addCssClasses($linkOptions, $this->disabledPageCssClass);
         return Html::a($label, '', $linkOptions);
     }
     if ($active) {
         UI::addCssClasses($linkOptions, $this->activePageCssClass);
     }
     return Html::a($label, $this->pagination->createUrl($page), $linkOptions);
 }
コード例 #22
0
 public function renderCloseButton()
 {
     $view = $this->getView();
     UIAsset::register($view);
     $options['id'] = $this->getId() . '-close-button';
     $js = "ui.semantic.initMessageCloseButtons('#" . $options['id'] . "','{$this->closeTransition}');";
     $view->registerJs($js);
     return UI::i('close', $options);
 }
コード例 #23
0
 protected function renderToggleButton()
 {
     if ($this->toggleButton !== false) {
         $tag = ArrayHelper::remove($this->toggleButton, 'tag', 'div');
         $label = ArrayHelper::remove($this->toggleButton, 'label', 'Show');
         if ($tag === 'button' && !isset($this->toggleButton['type'])) {
             $this->toggleButton['type'] = 'button';
         }
         if ($tag === 'div') {
             UI::addCssClasses($this->toggleButton, ['ui', 'button']);
         }
         $view = $this->getView();
         UIAsset::register($view);
         $view->registerJs('ui.semantic.init();');
         return Html::tag($tag, $label, $this->toggleButton);
     } else {
         return null;
     }
 }
コード例 #24
0
ファイル: Menu.php プロジェクト: Vincent-X/yii2-semantic-ui
 public function renderItem($item)
 {
     if (isset($item['header'])) {
         UI::addCssClasses($item['options'], ['header']);
         return Html::tag('div', $item['header'], $item['options']);
     } else {
         if (isset($item['url'])) {
             return Html::a($item['label'], Url::to($item['url']), $item['options']);
         } else {
             return Html::tag('div', $item['label'], $item['options']);
         }
     }
 }