Beispiel #1
1
 public function run()
 {
     echo Html::beginTag('img', $this->options);
     $this->options['src'] = ArrayHelper::remove($this->options, 'data-src');
     Html::removeCssClass($this->options, 'lazy');
     echo '<noscript>' . Html::beginTag('img', $this->options) . '</noscript>';
 }
 /**
  * Renders switcher
  * @see http://materializecss.com/forms.html#switches
  * @param array $options
  * @param array $flags
  * @return $this
  */
 public function switcher($options = [], $flags = null)
 {
     parent::checkbox($options, false);
     if ($flags === null) {
         $label = Html::encode($this->model->getAttributeLabel(Html::getAttributeName($this->attribute)));
         $labelParts = explode(',', $label);
         $flags = count($labelParts) >= 2 ? $labelParts : null;
     }
     if ($flags) {
         Html::removeCssClass($this->options, 'input-field');
         Html::addCssClass($this->options, 'switch');
         $labelContent = $flags[0] . $this->parts['{input}'] . Html::tag('span', '', ['class' => 'lever']) . $flags[1];
         $this->parts['{input}'] = Html::label($labelContent, Html::getInputId($this->model, $this->attribute));
     }
     return $this;
 }
 /**
  * @inheritdoc
  * @throws InvalidConfigException
  */
 public function init()
 {
     if (!class_exists($this->dropdownClass)) {
         throw new InvalidConfigException("The dropdownClass '{$this->dropdownClass}' does not exist or is not accessible.");
     }
     parent::init();
     Html::removeCssClass($this->options, 'nav');
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     $cssClass = @$this->options['class'];
     parent::init();
     // significant order
     if ($cssClass != $this->options['class']) {
         \yii\helpers\Html::removeCssClass($this->options, 'nav');
     }
     $this->items = Item::find()->select(['*', 'parent_id' => '(IF(pid=1,"",pid))', 'name' => 'title'])->where(['visible' => true])->andWhere(['<>', 'pid', ''])->indexBy('id')->orderBy(['rank' => SORT_ASC])->asArray()->all();
 }
Beispiel #5
0
 /**
  * @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'];
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     Html::addCssClass($this->containerOptions, 'input-group date');
     Html::addCssClass($this->options, 'form-control');
     $this->options['readonly'] = 'readonly';
     if ($this->size !== null) {
         $size = 'input-' . $this->size;
         Html::addCssClass($this->options, $size);
         Html::addCssClass($this->containerOptions, $size);
     }
     if ($this->inline) {
         $this->clientOptions['linkField'] = $this->options['id'];
         Html::removeCssClass($this->containerOptions, 'date');
         Html::removeCssClass($this->containerOptions, 'input-group');
         Html::addCssClass($this->options, 'text-center');
     }
 }
 public function init()
 {
     parent::init();
     Html::removeCssClass($this->options, 'dropdown-menu');
     Html::addCssClass($this->options, 'treeview-menu');
 }
Beispiel #8
0
 public function testRemoveCssClass()
 {
     $options = ['class' => 'test test2 test3'];
     Html::removeCssClass($options, 'test2');
     $this->assertEquals(['class' => 'test test3'], $options);
     Html::removeCssClass($options, 'test2');
     $this->assertEquals(['class' => 'test test3'], $options);
     Html::removeCssClass($options, 'test');
     $this->assertEquals(['class' => 'test3'], $options);
     Html::removeCssClass($options, 'test3');
     $this->assertEquals([], $options);
 }
Beispiel #9
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     Html::removeCssClass($this->options, ['widget' => 'nav']);
     Html::addCssClass($this->options, ['navlist' => $this->warpClass]);
 }
Beispiel #10
0
 /**
  * Removes css class from the icon
  * @param string $class
  * @return $this
  */
 public function rc($class)
 {
     Html::removeCssClass($this->options, $class);
     return $this;
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     $this->_view = $this->grid->getView();
     if ($this->mergeHeader && !isset($this->vAlign)) {
         $this->vAlign = GridView::ALIGN_MIDDLE;
     }
     if ($this->grid->bootstrap === false) {
         Html::removeCssClass($this->filterInputOptions, 'form-control');
     }
     $this->parseFormat();
     $this->parseVisibility();
     $this->checkValidFilters();
     parent::init();
     $this->setPageRows();
     $this->initGrouping();
 }
Beispiel #12
0
 * +------------------------------------------------------------------------------
 * @Description
 * +------------------------------------------------------------------------------
 * @filename index.php 
 * @encoding UTF-8
 * @author xingcuntian<*****@*****.**>
 * @datetime 2015-07-03 11:02:40
 * @version 1.0
 * +------------------------------------------------------------------------------
 */
echo Html::tag('p', Html::encode('username'), ['class' => 'username']);
echo Html::tag('div', Html::encode("dddddddddddddddddd"), ['class' => 'div', 'id' => 'div']);
$options = ['class' => 'btn btn-default'];
$type = 'success';
if ($type === 'success') {
    Html::removeCssClass($options, 'btn-default');
    Html::addCssClass($options, 'btn-success');
}
echo Html::tag('div', 'sdsdsd dddd', $options);
$id = 2;
$option = [['id' => 1, 'name' => 'one'], ['id' => 2, 'name' => 'two'], ['id' => 3, 'name' => 'three'], ['id' => 4, 'name' => 'four']];
$post = ['title' => 'this is title', 'name' => 'this is name', 'child' => [1000, 200]];
echo Html::getInputName($model, 'username');
echo Html::getAttributeValue($model, 'username');
echo Html::tag('hr');
echo Html::getInputId($model, 'username');
echo Html::tag('hr');
?>

<?php 
echo Html::style('.username{color:red;font-size:8px;}');
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     Html::removeCssClass($this->options, 'nav');
     Html::addCssClass($this->options, 'sidebar-menu');
 }
Beispiel #14
0
 /**
  * Renders an input tag.
  *
  * @param string $type the input type (e.g. 'text', 'password')
  * @param array $options the tag options in terms of name-value pairs. These will be rendered as
  * the attributes of the resulting tag. The values will be HTML-encoded using [[Html::encode()]].
  * @return ActiveField object
  */
 public function input($type, $options = [])
 {
     $this->initPlaceholder($options);
     if ($type == 'range' || $type == 'color') {
         Html::removeCssClass($this->inputOptions, 'form-control');
     }
     $options = array_merge($this->inputOptions, $options);
     $this->parts['{input}'] = Html::activeInput($type, $this->model, $this->attribute, $options);
     return $this;
 }
Beispiel #15
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     Html::removeCssClass($this->options, ['nav', $this->navType]);
     Html::addCssClass($this->options, 'nav-tabs-custom');
 }
 /**
  * Applies the alignment to the options of a certain grid part
  * @param array $options the grid part options
  * @param integer $alignment the alignment constant (@see AdvancedDataColumn::TEXT_%alignment)
  * @throws InvalidConfigException in case of an unknown alignment value
  */
 private function applyTextAlignmentToOptions(&$options, $alignment)
 {
     //catch illegal values
     if (!in_array($alignment, self::$LEGAL_ALIGNMENTS)) {
         throw new InvalidConfigException(sprintf('Illegal text alignment value for %s!', self::className()));
     }
     //strip already applied classes classes
     foreach (self::$CSS_CLASSES as $cssClass) {
         Html::removeCssClass($options, $cssClass);
     }
     //apply actual css class
     switch ($alignment) {
         case null:
         case self::TEXT_LEFT:
             if ($this->textAlignLeftClass == null) {
                 break;
             }
             Html::addCssClass($options, $this->textAlignLeftClass);
             break;
         case self::TEXT_CENTER:
             if ($this->textAlignCenterClass == null) {
                 break;
             }
             Html::addCssClass($options, $this->textAlignCenterClass);
             break;
         case self::TEXT_RIGHT:
             if ($this->textAlignRightClass == null) {
                 break;
             }
             Html::addCssClass($options, $this->textAlignRightClass);
             break;
     }
 }