当前位置: 首页>>代码示例>>PHP>>正文


PHP Html::addCssStyle方法代码示例

本文整理汇总了PHP中yii\helpers\Html::addCssStyle方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::addCssStyle方法的具体用法?PHP Html::addCssStyle怎么用?PHP Html::addCssStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\helpers\Html的用法示例。


在下文中一共展示了Html::addCssStyle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renderItems

 /**
  * Renders menu items.
  * @param  array                  $items the menu items to be rendered
  * @return string                 the rendering result.
  * @throws InvalidConfigException if the label option is not specified in one of the items.
  */
 protected function renderItems($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['title'])) {
             throw new InvalidConfigException("The 'title' option is required.");
         }
         $title = $this->encode ? Html::encode($item['title']) : $item['title'];
         $titleOptions = ArrayHelper::getValue($item, 'titleOptions', []);
         Html::addCssClass($titleOptions, 'list-group-item-heading');
         $titleCode = Html::tag('h4', $title, $titleOptions);
         $description = $this->encode ? Html::encode($item['description']) : $item['description'];
         $descriptionOptions = ArrayHelper::getValue($item, 'descriptionOptions', []);
         Html::addCssClass($descriptionOptions, 'list-group-item-text');
         $descriptionCode = Html::tag('p', $description, $descriptionOptions);
         $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
         Html::addCssClass($linkOptions, 'list-group-item');
         Html::addCssStyle($linkOptions, 'word-wrap: break-word');
         if (isset($item['active']) && $item['active']) {
             Html::addCssClass($linkOptions, 'active');
         }
         $linkOptions['tabindex'] = '-1';
         $lines[] = Html::a($titleCode . "\n" . $descriptionCode, ArrayHelper::getValue($item, 'url', '#'), $linkOptions);
     }
     return Html::tag('div', implode("\n", $lines), $this->options);
 }
开发者ID:yii2ApplicationCollect,项目名称:dotplant2,代码行数:40,代码来源:ListGroup.php

示例2: render

 public function render($type)
 {
     $image = $this->image;
     if (!$image) {
         $image = $this->desktop->assetsUrl . '/images/icon_application.png';
     } else {
         if (\yii\helpers\Url::isRelative($image) && $this->desktop->iconPath) {
             $image = rtrim($this->desktop->iconPath, '/') . '/' . $image;
         }
     }
     $attributes = ['src' => $image];
     $styles = [];
     switch ($type) {
         case self::DISPLAY_MENU:
             $styles = ['height' => '16px', 'position' => 'relative', 'top' => '-2px'];
             break;
         case self::DISPLAY_DOCK:
             $styles = ['height' => '16px'];
             break;
         case self::DISPLAY_TITLEBAR:
             $styles = ['float' => 'left', 'margin' => '4px 5px 0 0', 'height' => '20px'];
             break;
         case self::DISPLAY_DESKTOP:
             $styles = ['height' => '32px'];
             break;
     }
     Html::addCssStyle($attributes, $styles);
     return Html::img($attributes['src'], $attributes);
 }
开发者ID:bedezign,项目名称:yii2-desktop,代码行数:29,代码来源:Icon.php

示例3: init

 /**
  * Initializes the widget.
  * This method will register the bootstrap asset bundle. If you override this method,
  * make sure you call the parent implementation first.
  */
 public function init()
 {
     parent::init();
     if (!isset($this->options['id'])) {
         $this->options['id'] = $this->getId();
     }
     if (empty($this->leafLet) || !$this->leafLet instanceof LeafLet) {
         throw new InvalidConfigException("'leafLet' attribute cannot be empty and should be of type LeafLet component.");
     }
     if (is_numeric($this->height)) {
         $this->height .= 'px';
     }
     Html::addCssStyle($this->options, ['height' => $this->height], false);
 }
开发者ID:2amigos,项目名称:yii2-leaflet-extension,代码行数:19,代码来源:Map.php

示例4: run

    /**
     * @inheritdoc
     */
    public function run()
    {
        $width = null;
        if ($this->thumbsEnabled) {
            $filename = $this->behavior->getThumbFilePath($this->attribute, $this->thumbProfileName);
        } else {
            $filename = $this->behavior->getUploadedFilePath($this->attribute);
        }
        if (is_readable($filename)) {
            list($width) = getimagesize($filename);
        } else {
            Yii::warning("Unable to read file: '{$filename}' referenced by '{$this->attribute}' in model {$this->model->className()}");
            if (empty($this->previewOptions['style'])) {
                $this->previewOptions['style'] = '';
            }
            $this->previewOptions['style'] .= ';display: none;';
        }
        $previewOptions = ArrayHelper::merge(['id' => $this->id . '-thumb', 'width' => $width], $this->previewOptions);
        if (empty($previewOptions['class'])) {
            $previewOptions['class'] = '';
        }
        $previewOptions['class'] .= ' img-responsive img-thumbnail';
        if (isset($this->model->attributeLabels()[$this->attribute]) and !isset($previewOptions['alt'])) {
            $previewOptions['alt'] = $this->model->attributeLabels()[$this->attribute];
        }
        if ($this->thumbsEnabled) {
            $url = $this->behavior->getThumbFileUrl($this->attribute, $this->thumbProfileName);
        } else {
            $url = $this->behavior->getImageFileUrl($this->attribute);
        }
        Html::addCssStyle($previewOptions, "background-image: url({$url})");
        $image = Html::tag('div', '', $previewOptions);
        $fileInput = Html::activeFileInput($this->model, $this->attribute, ['id' => $this->id . '-input'] + $this->options);
        echo $this->render('index', compact('image', 'fileInput'));
        $this->getView()->registerJs(";(function(\$){\n    var widget = \$('#{$this->id}');\n    var fileInput = widget.find('input[type=file]');\n    var preview = \$('#{$previewOptions['id']}');\n    var button = fileInput.closest('.image-up-input-button');\n\n    fileInput.on('change', function() {\n        var selectedFile = this.files[0];\n\n        if (selectedFile) {\n            var reader = new FileReader();\n            reader.readAsDataURL(selectedFile);\n            reader.onload = function (e) {\n                preview.css('background-image', 'url(' +  e.target.result + ')');\n            }\n\n            preview.show();\n        }\n    });\n\n})(jQuery);");
        $this->getView()->registerCss(<<<CSS
#{$previewOptions['id']} {
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
}
CSS
);
    }
开发者ID:hector-del-rio,项目名称:yii2-image-up,代码行数:47,代码来源:ImageUp.php

示例5: renderTextInput

 private function renderTextInput()
 {
     if ($this->state() !== self::STATE_TEXT) {
         Html::addCssStyle($this->textInputOptions, 'display:none');
     }
     return Html::textInput(null, $this->inputValue(self::STATE_TEXT), $this->textInputOptions);
 }
开发者ID:tsyrya,项目名称:mybriop,代码行数:7,代码来源:ComboWidget.php

示例6: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $this->_msgCat = 'kvcolor';
     if (!isset($this->type)) {
         $this->type = $this->useNative ? 'color' : 'text';
     }
     $this->width = '60px';
     $this->initI18N(__DIR__);
     if (empty($this->html5Container['id'])) {
         $this->html5Container['id'] = $this->options['id'] . '-cont';
     }
     if ($this->type === 'text') {
         Html::addCssStyle($this->html5Options, 'display:none');
         if ($this->pluginLoading) {
             Html::addCssClass($this->html5Container, 'kv-center-loading');
         }
     }
     $this->html5Options['value'] = $this->hasModel() ? Html::getAttributeValue($this->model, $this->attribute) : $this->value;
     if (substr($this->language, 0, 2) !== 'en') {
         $this->_defaultOptions += ['cancelText' => Yii::t('kvcolor', 'cancel'), 'chooseText' => Yii::t('kvcolor', 'choose'), 'clearText' => Yii::t('kvcolor', 'Clear Color Selection'), 'noColorSelectedText' => Yii::t('kvcolor', 'No Color Selected'), 'togglePaletteMoreText' => Yii::t('kvcolor', 'more'), 'togglePaletteLessText' => Yii::t('kvcolor', 'less')];
     }
     Html::addCssClass($this->containerOptions, 'spectrum-group');
     Html::addCssClass($this->html5Options, 'spectrum-source');
     Html::addCssClass($this->options, 'spectrum-input');
     if (!$this->useNative) {
         Html::addCssClass($this->html5Container, 'input-group-sp');
         $this->pluginOptions = array_replace_recursive($this->_defaultOptions, $this->pluginOptions);
     }
     $this->initInput();
     $this->registerColorInput();
 }
开发者ID:ICHydro,项目名称:anaconda,代码行数:34,代码来源:ColorInput.php

示例7: init

 public function init()
 {
     parent::init();
     foreach (['url', 'srcNode'] as $property) {
         if ($this->pluginOptions[$property] === null) {
             throw new InvalidConfigException("The \"{$property}\" property must be set to \"pluginOptions\".");
         }
     }
     Html::addCssStyle($this->itemOptions, ['display' => 'none']);
 }
开发者ID:hdushku,项目名称:yii2-gridify-view,代码行数:10,代码来源:GridifyView.php

示例8: init

 public function init()
 {
     parent::init();
     if ($this->pageSizeMargin) {
         Html::addCssStyle($this->pageSizeOptions, $this->pageSizeMargin);
     }
     if ($this->customPageWidth) {
         Html::addCssStyle($this->customPageOptions, 'width:' . $this->customPageWidth . 'px;');
     }
     if ($this->customPageMargin) {
         Html::addCssStyle($this->customPageOptions, $this->customPageMargin);
     }
 }
开发者ID:tqsq2005,项目名称:Yii2adv,代码行数:13,代码来源:LinkPager.php

示例9: run

 public function run()
 {
     if (!array_key_exists('id', $this->options)) {
         $this->options['id'] = $this->getId();
     }
     if (!is_null($this->width)) {
         Html::addCssStyle($this->options, 'width:' . $this->width);
     }
     if (!is_null($this->height)) {
         Html::addCssStyle($this->options, 'height:' . $this->height);
     }
     echo Html::tag('div', '', $this->options);
     $this->registerChart();
 }
开发者ID:softcommerce,项目名称:yii2-flot,代码行数:14,代码来源:Chart.php

示例10: init

 public function init()
 {
     $this->options['id'] = $this->getId();
     if (!$this->settings['name']) {
         $this->settings['name'] = $this->options['id'];
     }
     if (empty($this->settings['panels'] && is_array($this->panels))) {
         $this->settings['panels'] = $this->panels;
     }
     if (is_null($this->locale) && \Yii::$app->language != 'en-US') {
         $this->locale = strtolower(\Yii::$app->language);
     }
     Html::addCssStyle();
     parent::init();
 }
开发者ID:fourteenmeister,项目名称:yii2-w2ui,代码行数:15,代码来源:w2uiLayout.php

示例11: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     AceEditorAsset::register($this->getView());
     $editor_id = $this->getId();
     $editor_var = 'aceeditor_' . $editor_id;
     $this->getView()->registerJs("var {$editor_var} = ace.edit(\"{$editor_id}\")");
     $this->getView()->registerJs("{$editor_var}.setTheme(\"ace/theme/{$this->theme}\")");
     $this->getView()->registerJs("{$editor_var}.getSession().setMode(\"ace/mode/{$this->mode}\")");
     $textarea_var = 'acetextarea_' . $editor_id;
     $this->getView()->registerJs("\n            var {$textarea_var} = \$('#{$this->options['id']}').hide();\n            {$editor_var}.getSession().setValue({$textarea_var}.val());\n            {$editor_var}.getSession().on('change', function(){\n                {$textarea_var}.val({$editor_var}.getSession().getValue());\n            });\n        ");
     Html::addCssStyle($this->options, 'display: none');
     $this->containerOptions['id'] = $editor_id;
     $this->getView()->registerCss("#{$editor_id}{position:relative}");
 }
开发者ID:trntv,项目名称:yii2-aceeditor,代码行数:18,代码来源:AceEditor.php

示例12: init

    /**
     * Initializes the widget.
     */
    public function init()
    {
        parent::init();
        $style = <<<EOF
    @media screen and (max-width: 767px) {
        .row-offcanvas {
            position: relative;
            -webkit-transition: all 0.25s ease-out;
            -moz-transition: all 0.25s ease-out;
            transition: all 0.25s ease-out;
        }

        .row-offcanvas-right
        .sidebar-offcanvas {
            right: -50%; /* 6 columns */
        }

        .row-offcanvas-left
        .sidebar-offcanvas {
            left: -50%; /* 6 columns */
        }

        .row-offcanvas-right.active {
            right: 50%; /* 6 columns */
        }

        .row-offcanvas-left.active {
            left: 50%; /* 6 columns */
        }

        .sidebar-offcanvas {
            position: absolute;
            top: 0;
            width: 50%; /* 6 columns */
        }
    }
EOF;
        Html::addCssStyle($options, $style);
    }
开发者ID:NikDevPHP,项目名称:yii2-blog,代码行数:42,代码来源:Sidebar.php

示例13: run

 public function run()
 {
     $this->registerJs();
     Html::addCssClass($this->options, 'ui progress');
     $this->options['data-percent'] = $this->percent;
     if ($this->active) {
         Html::addCssClass($this->options, 'active');
     }
     if ($this->indicating) {
         Html::addCssClass($this->options, 'indicating');
     }
     if ($this->autoHide && !$this->percent) {
         Html::addCssStyle($this->options, 'display: none');
     }
     $body = Html::beginTag('div', ['class' => 'bar']);
     $body .= Html::tag('div', $this->progressLabel, ['class' => 'progress']);
     $body .= Html::endTag('div');
     $body .= Html::tag('div', $this->label, ['class' => 'label']);
     if ($this->ajax) {
         $this->registerAjax();
     }
     echo Html::tag('div', $body, $this->options);
 }
开发者ID:he11d0g,项目名称:yii2-nuts,代码行数:23,代码来源:Progress.php

示例14: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     if ($this->empty !== false) {
         // Empty item must be first.
         $items = $this->items;
         $this->items = ['' => is_string($this->empty) ? $this->empty : Yii::t('app', 'None')] + $items;
     }
     if ($this->fullWidth) {
         Html::addCssStyle($this->options, 'width: 100%');
     }
     if ($this->hideSearch) {
         $this->clientOptions['minimumResultsForSearch'] = 'Infinity';
     }
     if ($this->multiple) {
         $this->options['multiple'] = true;
     }
     $this->registerClientScript();
     if ($this->hasModel()) {
         return Html::activeDropDownList($this->model, $this->attribute, $this->items, $this->options);
     } else {
         return Html::dropDownList($this->name, $this->value, $this->items, $this->options);
     }
 }
开发者ID:skoro,项目名称:yii2-admin-template,代码行数:26,代码来源:Select2.php

示例15: render

 public function render($type)
 {
     // Obviously we need the bootstrap assets for this
     \yii\bootstrap\BootstrapPluginAsset::register($this->desktop->view);
     $glyph = $this->image;
     if (!$glyph) {
         $glyph = 'folder-open';
     }
     $attributes = ['class' => "glyphicon glyphicon-{$glyph}"];
     $styles = [];
     switch ($type) {
         case self::DISPLAY_DOCK:
             $styles = ['position' => 'relative', 'top' => '3px', 'font-size' => '16px', 'padding-right' => '5px'];
             break;
         case self::DISPLAY_TITLEBAR:
             $styles = ['float' => 'left', 'margin' => '4px 8px 0 0', 'font-size' => '20px'];
             break;
         case self::DISPLAY_DESKTOP:
             $styles = ['font-size' => '32px'];
             break;
     }
     Html::addCssStyle($attributes, $styles);
     return Html::tag('span', '', $attributes);
 }
开发者ID:bedezign,项目名称:yii2-desktop,代码行数:24,代码来源:GlyphIcon.php


注:本文中的yii\helpers\Html::addCssStyle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。