addCssClass() public static method

.
public static addCssClass ( mixed $className, array &$htmlOptions ) : array
$className mixed the class(es) to append.
$htmlOptions array the options.
return array the options.
示例#1
0
 /**
  * Renders the input file field
  */
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     TbArray::defaultValue('id', $id, $this->htmlOptions);
     TbArray::defaultValue('name', $name, $this->htmlOptions);
     TbHtml::addCssClass('bfh-selectbox', $this->wrapperOptions);
     echo CHtml::openTag('div', $this->wrapperOptions);
     if ($this->hasModel()) {
         echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
         $value = $this->model->{$this->attribute};
         $valueText = $value && isset($this->data[$value]) ? $this->data[$value] : ' ';
     } else {
         echo CHtml::hiddenField($name, $this->value, $this->htmlOptions);
         $value = $this->value;
         $valueText = $value && isset($this->data[$value]) ? $this->data[$value] : ' ';
     }
     echo CHtml::openTag('a', array('class' => 'bfh-selectbox-toggle', 'role' => 'button', 'data-toggle' => 'bfh-selectbox', 'href' => '#'));
     echo CHtml::tag('span', array('class' => 'bfh-selectbox-option ' . $this->size, 'data-option' => $value), $valueText);
     echo CHtml::tag('b', array('class' => 'caret'), ' ');
     echo CHtml::closeTag('a');
     echo CHtml::openTag('div', array('class' => 'bfh-selectbox-options'));
     if ($this->displayFilter) {
         echo '<input type="text" class="bfh-selectbox-filter">';
     }
     $items = array();
     foreach ($this->data as $key => $item) {
         $items[] = CHtml::tag('a', array('tabindex' => '-1', 'href' => '#', 'data-option' => $key), $item);
     }
     echo CHtml::tag('ul', array('role' => 'options'), '<li>' . implode('</li><li>', $items) . '</li>');
     echo CHtml::closeTag('div');
     echo CHtml::closeTag('div');
 }
示例#2
0
 /**
  * Initializes the widget
  */
 public function init()
 {
     parent::init();
     if (isset($this->itemsCssClass)) {
         TbHtml::addCssClass($this->itemsCssClass, $this->htmlOptions);
     }
 }
示例#3
0
 /**
  * Widget's initialization method
  * @throws CException
  */
 public function init()
 {
     $this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin'));
     TbHtml::addCssClass('bfh-timepicker', $this->htmlOptions);
     $this->htmlOptions['data-time'] = $this->hasModel() ? $this->model->{$this->attribute} : $this->value;
     $this->inputOptions['readonly'] = true;
 }
示例#4
0
 public function init()
 {
     parent::init();
     TbHtml::addCssClass('bfh-phone', $this->htmlOptions);
     $this->htmlOptions['data-format'] = $this->format;
     unset($this->htmlOptions['data-name'], $this->htmlOptions['data-value']);
 }
示例#5
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     Yii::import('bootstrap.behaviors.TbWidget');
     $this->attachBehavior('tbWidget', new TbWidget());
     if (!isset($this->assetPath)) {
         $this->assetPath = realpath(dirname(__FILE__) . '/../assets');
     }
     if (!$this->asDropDownList && !isset($this->pluginOptions['data'])) {
         $this->pluginOptions['data'] = $this->normalizeData($this->data);
     }
     if (isset($this->htmlOptions['placeholder'])) {
         if ($this->asDropDownList) {
             $this->htmlOptions['prompt'] = $this->htmlOptions['placeholder'];
         } else {
             $this->pluginOptions['placeholder'] = $this->htmlOptions['placeholder'];
         }
         unset($this->htmlOptions['placeholder']);
     }
     if (!$this->bindPlugin) {
         $this->htmlOptions['data-plugin'] = 'select2';
         $this->htmlOptions['data-plugin-options'] = CJSON::encode($this->pluginOptions);
     }
     if (TbArray::popValue('block', $this->htmlOptions, false)) {
         TbHtml::addCssClass('input-block-level', $this->htmlOptions);
     }
 }
示例#6
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     $this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin'));
     TbArray::defaultValue('autocomplete', 'off', $this->htmlOptions);
     TbHtml::addCssClass('grd-white', $this->htmlOptions);
     $this->initOptions();
 }
 /**
  * Renders the widget. If there are no items, nothing will be rendered.
  * TODO: Reuse TbCollapse somehow
  */
 public function run()
 {
     $itemCount = count($this->items);
     if ($itemCount === 0) {
         return;
     }
     echo CHtml::openTag('div', $this->htmlOptions);
     foreach ($this->items as $k => $item) {
         $id = __CLASS__ . '_' . $this->id . '_' . $k;
         $contentId = $id . '_content';
         $linkOptions = array('class' => 'accordion-toggle episode-toggle', 'data-content-id' => $contentId, 'data-toggle' => 'collapse', 'data-parent' => $this->id);
         // Add content-url data attributes to the link when available
         if (isset($item['contentUrl'])) {
             $linkOptions['data-content-url'] = $item['contentUrl'];
         }
         // Render the contents of the heading
         $heading = $this->render('_seasonAccordionHeading', array('linkUrl' => '#' . $id, 'linkOptions' => $linkOptions, 'season' => $item['season']), true);
         $bodyOptions = array('class' => 'accordion-body collapse', 'id' => $id);
         if ($itemCount === 1) {
             TbHtml::addCssClass('in', $bodyOptions);
         }
         echo CHtml::openTag('div', array('class' => 'accordion-group'));
         echo CHtml::tag('div', array('class' => 'accordion-heading'), $heading);
         echo CHtml::openTag('div', $bodyOptions);
         echo CHtml::tag('div', array('id' => $contentId, 'class' => 'accordion-inner'), $item['content']);
         echo CHtml::closeTag('div');
         echo CHtml::closeTag('div');
     }
     echo CHtml::closeTag('div');
 }
示例#8
0
 /**
  * Widget's initialization method
  * @throws CException
  */
 public function init()
 {
     if (!isset($this->pluginOptions['country'])) {
         throw new CException(Yii::t('zii', '$pluginOptions["country"] cannot be blank.'));
     }
     $this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin'));
     TbHtml::addCssClass('bfh-states', $this->htmlOptions);
 }
 /**
  * Renders a text field with typeahead functionality based on the specified 
  * data.
  * @param CModel $model the model
  * @param string $attribute the attribute name
  * @param string $data JavaScript-encoded array containing the data for the 
  * typeahead
  * @param array $htmlOptions options to pass to the control group
  * @return string the HTML for the input
  */
 public function typeaheadFieldControlGroup($model, $attribute, $data, $htmlOptions = array())
 {
     // Generate a unique ID for this element
     CHtml::resolveNameID($model, $attribute, $htmlOptions);
     TbHtml::addCssClass('twitter-typeahead-input', $htmlOptions);
     $id = $htmlOptions['id'];
     Yii::app()->clientScript->registerScript($id, "\n\t\t\t\$('#{$id}').typeahead({name: '{$id}',local: {$data},limit: 10});\n\t\t", CClientScript::POS_READY);
     return $this->textFieldControlGroup($model, $attribute, $htmlOptions);
 }
示例#10
0
 public function init()
 {
     parent::init();
     TbHtml::addCssClass('bfh-fonts', $this->htmlOptions);
     if (!isset($this->htmlOptions['data-font'])) {
         $this->htmlOptions['data-font'] = TbArray::popValue('data-value', $this->htmlOptions);
     }
     unset($this->htmlOptions['data-name'], $this->htmlOptions['data-value']);
 }
示例#11
0
 public function init()
 {
     if (empty($this->country) && !isset($this->pluginOptions['country'])) {
         throw new CException('"$country" cannot be empty.');
     }
     $this->pluginOptions['country'] = TbArray::getValue('country', $this->pluginOptions, $this->country);
     parent::init();
     TbHtml::addCssClass('bfh-timezones', $this->htmlOptions);
     unset($this->htmlOptions['data-name']);
 }
 /**
  * Initializes the widget
  */
 public function init()
 {
     // Generate a unique ID. We can't rely on the built-in counter in
     // CWidget::getId() because these modals may be rendered from AJAX
     // request and the counter will be zero then
     $this->id = uniqid($this->getId());
     parent::init();
     TbHtml::addCssClass('watch-modal', $this->htmlOptions);
     $this->header = Yii::t('Movies', 'Watch / Download');
 }
示例#13
0
 /**
  * Renders the typeahead field
  */
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     TbArray::defaultValue('id', $id, $this->htmlOptions);
     TbArray::defaultValue('name', $name, $this->htmlOptions);
     TbHtml::addCssClass('form-control', $this->htmlOptions);
     if ($this->hasModel()) {
         echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo CHtml::textField($this->name, $this->value, $this->htmlOptions);
     }
 }
示例#14
0
 /**
  * Widget's initialization method
  * @throws CException
  */
 public function init()
 {
     $this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin'));
     TbHtml::addCssClass('bfh-phone', $this->htmlOptions);
     $this->htmlOptions['data-format'] = $this->format;
     if ($this->readOnly) {
         $this->htmlOptions['data-number'] = $this->hasModel() ? $this->model->{$this->attribute} : $this->value;
     } else {
         $this->pluginOptions['format'] = $this->format;
         $this->pluginOptions['value'] = $this->hasModel() ? $this->model->{$this->attribute} : $this->value;
     }
 }
示例#15
0
 public function init()
 {
     if (empty($this->country)) {
         throw new CException('"$country" cannot be empty.');
     }
     $this->pluginOptions['country'] = $this->country;
     parent::init();
     TbHtml::addCssClass('bfh-states', $this->htmlOptions);
     if (!isset($this->htmlOptions['data-state'])) {
         $this->htmlOptions['data-state'] = TbArray::popValue('data-value', $this->htmlOptions);
     }
     unset($this->htmlOptions['data-name'], $this->htmlOptions['data-value']);
 }
示例#16
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     $classes = array('table');
     if (!empty($this->type)) {
         if (is_string($this->type)) {
             $this->type = explode(' ', $this->type);
         }
         foreach ($this->type as $type) {
             $classes[] = 'table-' . $type;
         }
     }
     TbHtml::addCssClass($classes, $this->htmlOptions);
 }
示例#17
0
    /**
     * Renders the gallery template
     */
    public function renderTemplate()
    {
        $options = array('id' => $this->htmlOptions['id'] . '-videocarousel', 'class' => 'blueimp-gallery blueimp-gallery-carousel');
        if ($this->displayControls) {
            TbHtml::addCssClass('blueimp-gallery-controls', $options);
        }
        echo CHtml::openTag('div', $options);
        echo '<div class="slides"></div>
		<h3 class="title"></h3>
		<a class="prev">‹</a>
		<a class="next">›</a>
		<a class="play-pause"></a>
		<ol class="indicator"></ol>';
        echo CHtml::closeTag('div');
    }
示例#18
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     $this->attachBehavior('TbWidget', new TbWidget());
     $this->copyId();
     $route = $this->controller->getRoute();
     if ($this->stacked) {
         TbHtml::addCssClass('nav-stacked', $this->htmlOptions);
     }
     if (isset($this->scrollspy)) {
         if (is_string($this->scrollspy)) {
             $this->scrollspy = array('target' => $this->scrollspy);
         }
         $this->widget('bootstrap.widgets.TbScrollspy', $this->scrollspy);
     }
     $this->items = $this->normalizeItems($this->items, $route, $hasActiveChild);
 }
示例#19
0
 public function init()
 {
     TbHtml::addCssClass('nav nav-list', $this->htmlOptions);
     TbHtml::addCssClass('submenu', $this->submenuHtmlOptions);
     foreach ($this->items as $k => $v) {
         $icon = isset($v['icon']) ? '<i class="menu-icon ' . $v['icon'] . '"></i>' : '';
         $v['label'] = $icon . '<span class="menu-text"> ' . CHtml::encode($v['label']) . ' </span><b class="arrow"></b>';
         if (!empty($v['items'])) {
             $v['label'] .= '<b class="arrow fa fa-angle-down"></b>';
         }
         $v['url'] = '#';
         TbHtml::addCssClass('dropdown-toggle', $v['linkOptions']);
         $this->items[$k] = $v;
     }
     parent::init();
 }
示例#20
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     $classes = array('table');
     if (isset($this->type) && !empty($this->type)) {
         if (is_string($this->type)) {
             $this->type = explode(' ', $this->type);
         }
         $validTypes = array(TbHtml::GRID_TYPE_BORDERED, TbHtml::GRID_TYPE_CONDENSED, TbHtml::GRID_TYPE_STRIPED, TbHtml::GRID_TYPE_HOVER);
         foreach ($this->type as $type) {
             if (in_array($type, $validTypes)) {
                 $classes[] = 'table-' . $type;
             }
         }
     }
     TbHtml::addCssClass(implode(' ', $classes), $this->htmlOptions);
 }
示例#21
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     Yii::import('bootstrap.behaviors.TbWidget');
     $this->attachBehavior('tbWidget', new TbWidget());
     if (!isset($this->assetPath)) {
         $this->assetPath = Yii::getPathOfAlias('lib.select2');
     }
     if (!$this->asDropDownList && !isset($this->pluginOptions['data'])) {
         $this->pluginOptions['data'] = $data = $this->normalizeData($this->data);
     }
     if (!$this->bindPlugin) {
         $this->htmlOptions['data-plugin'] = 'select2';
         $this->htmlOptions['data-plugin-options'] = CJSON::encode($this->pluginOptions);
     }
     if (TbArray::popValue('block', $this->htmlOptions, false)) {
         TbHtml::addCssClass('input-block-level', $this->htmlOptions);
     }
 }
示例#22
0
 /**
  * Renders the field if no selector has been provided
  */
 public function renderField()
 {
     if (null === $this->selector) {
         $options = array();
         list($name, $id) = $this->resolveNameID();
         $options['id'] = $id . '_datetimepicker';
         TbHtml::addCssClass('input-group date form_datetime', $options);
         echo TbHtml::openTag('div', $options);
         if ($this->hasModel()) {
             echo TbHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
         } else {
             echo TbHtml::textField($name, $this->value, $this->htmlOptions);
         }
         echo TbHtml::openTag('span', array('class' => 'input-group-addon'));
         echo '<i class="glyphicon glyphicon-th"' . '></i>';
         echo TbHtml::closeTag('span');
         echo TbHtml::closeTag('div');
     }
 }
示例#23
0
 /**
  * Renders the field if no selector has been provided
  */
 public function renderField()
 {
     if (null === $this->selector) {
         $options = array();
         list($name, $id) = $this->resolveNameID();
         $options['id'] = $id . '_datetimepicker';
         TbHtml::addCssClass('input-append', $options);
         echo TbHtml::openTag('div', $options);
         if ($this->hasModel()) {
             echo TbHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
         } else {
             echo TbHtml::textField($name, $this->value, $this->htmlOptions);
         }
         echo TbHtml::openTag('span', array('class' => 'add-on'));
         echo '<i data-time-icon="' . $this->iconTime . '" data-date-icon="' . $this->iconDate . '"></i>';
         echo TbHtml::closeTag('span');
         echo TbHtml::closeTag('div');
     }
 }
示例#24
0
 /**
  * Initializes the widget.
  * @throws CException
  */
 public function init()
 {
     if (!in_array($this->inputType, array('radio', 'checkbox'))) {
         throw new CException(Yii::t('zii', '"inputType" attribute must be of type "radio" or "checkbox"'));
     }
     if (!in_array($this->size, array('mini', 'small', 'large'))) {
         throw new CException(Yii::t('zii', 'Unknown value for attribute "size".'));
     }
     $this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin'));
     TbHtml::addCssClass('make-switch', $this->pluginOptions);
     TbHtml::addCssClass('switch-' . $this->size, $this->pluginOptions);
     if (!$this->animated) {
         $this->pluginOptions['data-animated'] = 'false';
     }
     $this->pluginOptions['data-on-label'] = $this->onLabel;
     $this->pluginOptions['data-off-label'] = $this->offLabel;
     $this->pluginOptions['data-text-label'] = $this->textLabel;
     $this->pluginOptions['data-on'] = $this->onColor;
     $this->pluginOptions['data-off'] = $this->offColor;
 }
示例#25
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     $this->attachBehavior('TbWidget', new TbWidget());
     $this->copyId();
     TbHtml::addCssClass('collapse', $this->htmlOptions);
     if (isset($this->parent)) {
         TbArray::defaultValue('data-parent', $this->parent, $this->htmlOptions);
     }
     if (isset($this->toggle) && $this->toggle) {
         TbHtml::addCssClass('in', $this->htmlOptions);
     }
     if (isset($this->view)) {
         $controller = $this->getController();
         if (isset($controller) && $controller->getViewFile($this->view) !== false) {
             $this->content = $this->controller->renderPartial($this->view, $this->viewData, true);
         }
     }
     echo TbHtml::openTag($this->tagName, $this->htmlOptions);
     echo $this->content;
 }
示例#26
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     if (!isset($this->url)) {
         throw new CException('You must specify an url property.');
     }
     Yii::import('bootstrap.behaviors.TbWidget');
     $this->attachBehavior('tbWidget', new TbWidget());
     if (!isset($this->assetPath)) {
         $this->assetPath = Yii::getPathOfAlias('lib.jquery-file-upload');
     }
     $this->pluginOptions['url'] = $this->url;
     if (!$this->bindPlugin) {
         $this->htmlOptions['data-plugin'] = 'fileupload';
         $this->htmlOptions['data-plugin-options'] = CJSON::encode($this->pluginOptions);
     }
     if (!isset($this->buttonOptions['class'])) {
         TbHtml::addCssClass('btn btn-primary', $this->htmlOptions);
     }
     TbHtml::addCssClass('fileinput-button', $this->buttonOptions);
 }
示例#27
0
 /**
  * Widget's initialization method
  */
 public function init()
 {
     $this->attachBehavior('TbWidget', new TbWidget());
     TbArray::defaultValue('id', $this->getId(), $this->htmlOptions);
     TbArray::defaultValue('role', 'dialog', $this->htmlOptions);
     TbArray::defaultValue('tabindex', '-1', $this->htmlOptions);
     TbHtml::addCssClass('modal hide', $this->htmlOptions);
     if ($this->fade) {
         TbHtml::addCssClass('fade', $this->htmlOptions);
     }
     if (is_array($this->footer)) {
         $this->footer = implode('&nbsp;', $this->footer);
     }
     $this->initOptions();
     $this->initEvents();
 }
示例#28
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     TbHtml::addCssClass('bfh-selectbox', $this->htmlOptions);
 }
示例#29
0
 /**
  * Displays a summary of validation errors for one or several models.
  * @param mixed $models the models whose input errors are to be displayed.
  * @param string $header a piece of HTML code that appears in front of the errors
  * @param string $footer a piece of HTML code that appears at the end of the errors
  * @param array $htmlOptions additional HTML attributes to be rendered in the container div tag.
  * @return string the error summary. Empty if no errors are found.
  */
 public function errorSummary($models, $header = null, $footer = null, $htmlOptions = array())
 {
     if (!$this->enableAjaxValidation && !$this->enableClientValidation) {
         return TbHtml::errorSummary($models, $header, $footer, $htmlOptions);
     }
     TbArray::defaultValue('id', $this->id . '_es_', $htmlOptions);
     $html = TbHtml::errorSummary($models, $header, $footer, $htmlOptions);
     if ($html === '') {
         if ($header === null) {
             $header = '<p>' . Yii::t('yii', 'Please fix the following input errors:') . '</p>';
         }
         TbHtml::addCssClass(TbHtml::$errorSummaryCss, $htmlOptions);
         TbHtml::addCssStyle('display:none', $htmlOptions);
         $html = CHtml::tag('div', $htmlOptions, $header . '<ul><li>dummy</li></ul>' . $footer);
     }
     $this->summaryID = $htmlOptions['id'];
     return $html;
 }
 /**
  * Renders the "Watch as in browser" button
  */
 private function renderWatchInBrowserButton()
 {
     // Swap the button URL for the first item link
     $buttonOptions = $this->getWatchButtonsOptions();
     $buttonOptions['class'] = 'fa fa-play';
     $buttonOptions['url'] = array('watchInBrowser', 'url' => $this->_links[0]->url);
     // Add logging
     TbHtml::addCssClass('loggable-link', $buttonOptions);
     $buttonOptions = array_merge($buttonOptions, $this->getLoggableLinkOptions());
     echo TbHtml::linkButton(Yii::t('RetrieveMediaWidget', 'Watch in browser'), $buttonOptions);
 }