/** * 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); } }
/** * 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'); }
/** * 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); echo CHtml::openTag('div', $this->htmlOptions); echo CHtml::openTag('div', array('class' => 'input-prepend bfh-timepicker-toggle', 'data-toggle' => 'bfh-timepicker')); echo CHtml::tag('span', array('class' => 'add-on'), TbHtml::icon(TbHtml::ICON_TIME)); if ($this->hasModel()) { echo CHtml::activeTextField($this->model, $this->attribute, $this->inputOptions); } else { echo CHtml::textField($name, $this->value, $this->inputOptions); } echo CHtml::closeTag('div'); echo '<div class="bfh-timepicker-popover"> <table class="table"> <tbody> <tr> <td class="hour"> <a class="next" href="#"><i class="icon-chevron-up"></i></a><br> <input type="text" class="input-mini" readonly><br> <a class="previous" href="#"><i class="icon-chevron-down"></i></a> </td> <td class="separator">:</td> <td class="minute"> <a class="next" href="#"><i class="icon-chevron-up"></i></a><br> <input type="text" class="input-mini" readonly><br> <a class="previous" href="#"><i class="icon-chevron-down"></i></a> </td> </tr> </tbody> </table> </div>'; echo CHtml::closeTag('div'); }
/** * Initializes the widget. */ public function init() { $this->attachBehavior('TbWidget', new TbWidget()); $this->copyId(); if (isset($this->size)) { TbArray::defaultValue('size', $this->size, $this->htmlOptions); } }
/** * Widget's initialization method */ public function init() { $this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin')); $this->htmlOptions['id'] = TbArray::getValue('id', $this->htmlOptions, $this->getId()); if (!$this->selector) { $this->selector = '#' . TbArray::getValue('id', $this->htmlOptions); } }
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']); }
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']); }
public function testMerge() { $a = array('this' => 'is', 'array' => 'a'); $b = array('is' => 'this', 'b' => 'array'); $array = TbArray::merge($a, $b); $this->assertEquals('is', TbArray::getValue('this', $array)); $this->assertEquals('a', TbArray::getValue('array', $array)); $this->assertEquals('this', TbArray::getValue('is', $array)); $this->assertEquals('array', TbArray::getValue('b', $array)); }
public function renderField() { list($name, $id) = $this->resolveNameID(); TbArray::defaultValue('id', $id, $this->htmlOptions); TbArray::defaultValue('name', $name, $this->htmlOptions); if ($this->hasModel()) { echo TbHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } else { echo TbHtml::textField($name, $this->value, $this->htmlOptions); } }
/** * Renders links */ public function renderLinks() { echo CHtml::openTag('div', $this->htmlOptions); foreach ($this->items as $item) { $url = TbArray::getValue('url', $item, '#'); $src = TbArray::getValue('src', $item, '#'); $options = TbArray::getValue('options', $item); echo CHtml::link(CHtml::image($src), $url, $options); } echo CHtml::closeTag('div'); }
/** * Registers required client script for maskmoney plugin. */ public function registerClientScript() { /* publish assets dir */ $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'; $assetsUrl = $this->getAssetsUrl($path); /* @var $cs CClientScript */ $cs = Yii::app()->getClientScript(); $cs->registerScriptFile($assetsUrl . '/js/jquery.maskmoney.js'); /* initialize plugin */ $selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId()); $this->getApi()->registerPlugin('maskMoney', $selector, $this->pluginOptions); }
/** * Initializes the widget. */ public function init() { TbArray::defaultValue('successClass', 'success', $this->pluginOptions); TbArray::defaultValue('errorClass', 'error', $this->pluginOptions); if (!isset($this->assetPath)) { $this->assetPath = Yii::getPathOfAlias('vendor.guillaumepotier.parsleyjs.dist'); } if (!$this->bindPlugin) { $this->htmlOptions['data-plugin'] = 'parsley'; $this->htmlOptions['data-plugin-options'] = CJSON::encode($this->pluginOptions); } parent::init(); }
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']); }
/** * Registers required client script for bootstrap typeahead. It is not used through bootstrap->registerPlugin * in order to attach events if any */ public function registerClientScript() { /* publish assets dir */ $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'; $assetsUrl = $this->getAssetsUrl($path); /* @var $cs CClientScript */ $cs = Yii::app()->getClientScript(); $min = $this->debugMode ? '.min' : ''; $cs->registerCssFile($assetsUrl . '/css/typeahead' . $min . '.css'); $cs->registerScriptFile($assetsUrl . '/js/typeahead' . $min . '.js', CClientScript::POS_END); /* initialize plugin */ $selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId()); $this->getApi()->registerPlugin('typeahead', $selector, $this->pluginOptions); }
/** * Registers required client script for jquery mask plugin. It doesn't use bootstrap->registerPlugin. */ public function registerClientScript() { /* publish assets dir */ $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'; $assetsUrl = $this->getAssetsUrl($path); /* @var $cs CClientScript */ $cs = Yii::app()->getClientScript(); $cs->registerScriptFile($assetsUrl . '/js/jquery.mask.js'); /* initialize plugin */ $selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId()); $options = !empty($this->pluginOptions) ? CJavaScript::encode($this->pluginOptions) : '{}'; $script = "jQuery('{$selector}').mask('{$this->mask}',{$options});"; Yii::app()->clientScript->registerScript(uniqid(__CLASS__ . '#', true), $script, CClientScript::POS_END); }
/** * Registers required client script for bootstrap multiselect. It is not used through bootstrap->registerPlugin * in order to attach events if any */ public function registerClientScript() { /* publish assets dir */ $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'; $assetsUrl = $this->getAssetsUrl($path); /* @var $cs CClientScript */ $cs = Yii::app()->getClientScript(); $cs->registerCssFile($assetsUrl . '/css/bootstrap-multiselect.css'); $cs->registerScriptFile($assetsUrl . '/js/bootstrap-multiselect.js'); /* initialize plugin */ $selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId()); $this->getApi()->registerPlugin('multiselect', $selector, $this->pluginOptions); $this->getApi()->registerEvents($selector, $this->events); }
/** * Registers required client script for sparklines */ public function registerClientScript() { /* publish assets dir */ $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'; $assetsUrl = $this->getAssetsUrl($path); /* @var $cs CClientScript */ $cs = Yii::app()->getClientScript(); $script = $this->debugMode ? 'jquery.sparkline.js' : 'jquery.sparkline.min.js'; $cs->registerScriptFile($assetsUrl . '/js/' . $script); /* initialize plugin */ $selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId()); $data = CJavaScript::encode($this->data); $options = CJavaScript::encode($this->pluginOptions); $cs->registerScript(__CLASS__ . '#' . $selector, "jQuery('{$selector}').sparkline({$data}, {$options});"); }
/** * Registers client script */ public function registerClientScript() { /* publish assets dir */ $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'; $assetsUrl = $this->getAssetsUrl($path); /* @var $cs CClientScript */ $cs = Yii::app()->getClientScript(); $cs->registerCssFile($assetsUrl . '/css/jquery.fileupload-ui.css'); $cs->registerScriptFile($assetsUrl . '/js/vendor/jquery.ui.widget.js'); $cs->registerScriptFile($assetsUrl . '/js/jquery.iframe-transport.js'); $cs->registerScriptFile($assetsUrl . '/js/jquery.fileupload.js'); /* initialize plugin */ $selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId()); $this->getApi()->registerPlugin('fileupload', $selector, $this->pluginOptions); }
/** * Registers client script */ public function registerClientScript() { /* publish assets dir */ $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'; $assetsUrl = $this->getAssetsUrl($path); /* @var $cs CClientScript */ $cs = Yii::app()->getClientScript(); $cs->registerCssFile($assetsUrl . '/css/bootstrap-formhelpers.css'); $cs->registerScriptFile($assetsUrl . '/js/bootstrap-formhelpers-timezones.codes.js'); $cs->registerScriptFile($assetsUrl . '/js/bootstrap-formhelpers-timezones.js'); /* initialize plugin */ if (!$this->useHelperSelectBox) { $selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId()); $this->getApi()->registerPlugin('bfhtimezones', $selector, $this->pluginOptions); } }
/** * Registers required client script for bootstrap select2. It is not used through bootstrap->registerPlugin * in order to attach events if any */ public function registerClientScript() { /* publish assets dir */ $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'; $assetsUrl = $this->getAssetsUrl($path); /* @var $cs CClientScript */ $cs = Yii::app()->getClientScript(); $cs->registerCssFile($assetsUrl . '/css/select2.css'); $cs->registerScriptFile($assetsUrl . '/js/select2.js'); if ($this->language) { $cs->registerScriptFile($assetsUrl . '/js/locale/select2_locale_' . $this->language . '.js', CClientScript::POS_END); } /* initialize plugin */ $selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId()); $this->getApi()->registerPlugin('select2', $selector, $this->pluginOptions, CClientScript::POS_READY); $this->getApi()->registerEvents($selector, $this->events, CClientScript::POS_READY); }
/** * 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); } }
/** * 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; }
/** * @inheritdoc */ public function init() { parent::init(); if (!$this->hasModel() && $this->name === null) { throw new CException("Either 'name', or 'model' and 'attribute' properties must be specified."); } if (!isset($this->htmlOptions['id'])) { $this->htmlOptions['id'] = $this->hasModel() ? CHtml::activeId($this->model, $this->attribute) : $this->getId(); } $this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin')); $this->htmlOptions = TbArray::merge($this->asDataAttributes($this->pluginOptions), $this->htmlOptions); $this->pluginOptions = false; if ($this->hasModel()) { $this->htmlOptions['data-name'] = CHtml::activeId($this->model, $this->attribute); $this->htmlOptions['data-value'] = CHtml::value($this->model, $this->attribute); } else { $this->htmlOptions['data-name'] = $this->name; $this->htmlOptions['data-value'] = $this->value; } }
/** * Registers required client script for bootstrap select2. It is not used through bootstrap->registerPlugin * in order to attach events if any */ public function registerClientScript() { /* publish assets dir */ $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'; $assetsUrl = $this->getAssetsUrl($path); /* @var $cs CClientScript */ $cs = Yii::app()->getClientScript(); $script = $this->debugMode ? 'redactor.js' : 'redactor.min.js'; $cs->registerCssFile($assetsUrl . '/css/redactor.css'); $cs->registerScriptFile($assetsUrl . '/js/' . $script, CClientScript::POS_END); /* register language */ $language = TbArray::getValue('lang', $this->pluginOptions); if (!empty($language) && $language != 'en') { $cs->registerScriptFile($assetsUrl . '/js/langs/' . $language . '.js', CClientScript::POS_END); } /* register plugins (if any) */ $this->registerPlugins($assetsUrl); /* initialize plugin */ $selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId()); $this->getApi()->registerPlugin('redactor', $selector, $this->pluginOptions); }
/** * 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); echo CHtml::openTag('div', $this->htmlOptions); echo CHtml::openTag('div', array('class' => 'input-prepend bfh-datepicker-toggle', 'data-toggle' => 'bfh-datepicker')); echo CHtml::tag('span', array('class' => 'add-on'), TbHtml::icon(TbHtml::ICON_CALENDAR)); if ($this->hasModel()) { echo CHtml::activeTextField($this->model, $this->attribute, $this->inputOptions); } else { echo CHtml::textField($name, $this->value, $this->inputOptions); } echo CHtml::closeTag('div'); echo '<div class="bfh-datepicker-calendar"> <table class="calendar table table-bordered"> <thead> <tr class="months-header"> <th class="month" colspan="4"> <a class="previous" href="#"><i class="icon-chevron-left"></i></a> <span></span> <a class="next" href="#"><i class="icon-chevron-right"></i></a> </th> <th class="year" colspan="3"> <a class="previous" href="#"><i class="icon-chevron-left"></i></a> <span></span> <a class="next" href="#"><i class="icon-chevron-right"></i></a> </th> </tr> <tr class="days-header"> </tr> </thead> <tbody> </tbody> </table> </div>'; echo CHtml::closeTag('div'); }
/** * Runs the widget. */ public function run() { /* @var $user CWebUser */ $user = Yii::app()->getUser(); if (count($user->getFlashes(false)) == 0) { return; } echo TbHtml::openTag('div', $this->htmlOptions); foreach ($this->alerts as $color => $alert) { if (isset($alert['visible']) && !$alert['visible']) { continue; } if ($user->hasFlash($color)) { $htmlOptions = TbArray::popValue('htmlOptions', $alert, array()); TbArray::defaultValue('closeText', $this->closeText, $htmlOptions); TbArray::defaultValue('block', $this->block, $htmlOptions); TbArray::defaultValue('fade', $this->fade, $htmlOptions); echo TbHtml::alert($color, $user->getFlash($color), $htmlOptions); } } echo '</div>'; $this->registerEvents("#{$this->htmlOptions['id']} > .alert", $this->events); }
/** * Register required script files * @param string $id */ public function registerClientScript($id) { /* publish assets dir */ $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'; $assetsUrl = $this->getAssetsUrl($path); /* @var $cs CClientScript */ $cs = Yii::app()->getClientScript(); $cs->registerCssFile($assetsUrl . '/css/bootstrap-wysihtml5.css'); if (isset($this->pluginOptions['color'])) { $cs->registerCssFile($assetsUrl . '/css/wysiwyg-color.css'); } $cs->registerScriptFile($assetsUrl . '/js/wysihtml5-0.3.0.js'); $cs->registerScriptFile($assetsUrl . '/js/bootstrap-wysihtml5.js'); if (in_array(@$this->pluginOptions['locale'], array('de-DE', 'es-ES', 'fr', 'fr-NL', 'pt-BR', 'sv-SE'))) { $cs->registerScriptFile($assetsUrl . '/js/locale/bootstrap-wysihtml5.' . $this->pluginOptions['locale'] . '.js'); } elseif (in_array($this->lang, array('de-DE', 'es-ES', 'fr', 'fr-NL', 'pt-BR', 'sv-SE'))) { $cs->registerScriptFile($assetsUrl . '/js/locale/bootstrap-wysihtml5.' . $this->lang . '.js'); $this->pluginOptions['locale'] = $this->lang; } $this->normalizeStylesheetsProperty(); /* initialize plugin */ $selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId()); $this->getApi()->registerPlugin('wysihtml5', $selector, $this->pluginOptions); }
public function registerClientScript() { //DebugBreak(); //publish assets dir $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'; $assetsUrl = $this->getAssetsUrl($path); //@var $cs CClientScript $cs = Yii::app()->getClientScript(); $script = YII_DEBUG ? 'jquery.fineuploader-3.2.js' : 'jquery.fineuploader-3.2.min.js'; $cs->registerCssFile($assetsUrl . '/css/fineuploader.css'); $cs->registerScriptFile($assetsUrl . '/js/' . $script); // initialize plugin //$selector = '#' . TbHtml::getOption('id', $this->htmlOptions, $this->getId()); //old version $selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId()); //new version //<!-- different method for widget registration $options = CMap::mergeArray($this->defaultOptions, $this->pluginOptions); $options = CMap::mergeArray(array('element' => 'js:$("' . $selector . '")[0]'), $options); $options = !empty($options) ? CJavaScript::encode($options) : ''; $script = "\n \$(document).ready(function() {\n var uniqueId = '" . $this->uniqueId . "';\n var fileNum = " . $this->photoCount . ";\n var photoCount = " . $this->photoCount . ";\n var photoCountMax = " . $this->photoCountMax . ";\n var maxSortOrder = " . $this->maxSortOrder . ";\n var portfolioType = " . $this->portfolioType . ";\n var uploader_" . $this->uniqueId . " = new qq.FineUploader(" . $options . ");\n \n \$('{$selector} .triggerUpload').click(function() {\n uploader_" . $this->uniqueId . ".uploadStoredFiles();\n });\n\n if (photoCountMax > 0) { \n if (photoCount >= photoCountMax) {\n \$('{$selector} #btnSelectFiles').attr('disabled', 'disabled');\n \$('{$selector} #btnSelectFiles input').attr('disabled', 'disabled');\n } \n //else {\n // uploader_" . $this->uniqueId . ".itemLimit = photoCountMax - photoCount;\n //}\n }\n \n \$('{$selector} .delete-uploaded').live('click', function() {\n \$(this).parent().parent().remove();\n --photoCount;\n if (photoCountMax > 0 && photoCount < photoCountMax) {\n \$('{$selector} #btnSelectFiles').removeAttr('disabled');\n \$('{$selector} #btnSelectFiles input').removeAttr('disabled');\n }\n });\n });"; // --> Yii::app()->clientScript->registerScript(uniqid(__CLASS__ . '#', true), $script, CClientScript::POS_END); $this->getApi()->registerEvents($selector, $this->events); }
/** * Renders a link button. * @param string $id the ID of the button * @param array $button the button configuration which may contain 'label', 'url', 'imageUrl' and 'options' elements. * @param integer $row the row number (zero-based) * @param mixed $data the data object associated with the row */ protected function renderButton($id, $button, $row, $data) { if (isset($button['visible']) && !$this->evaluateExpression($button['visible'], array('row' => $row, 'data' => $data))) { return; } $url = TbArray::popValue('url', $button); if ($url !== '#') { $url = $this->evaluateExpression($url, array('data' => $data, 'row' => $row)); } $imageUrl = TbArray::popValue('imageUrl', $button, false); $label = TbArray::popValue('label', $button, $id); $options = TbArray::popValue('options', $button, array()); TbArray::defaultValue('title', $label, $options); TbArray::defaultValue('rel', 'tooltip', $options); if ($icon = TbArray::popValue('icon', $button, false)) { echo CHtml::link(TbHtml::icon($icon), $url, $options); } else { if ($imageUrl && is_string($imageUrl)) { echo CHtml::link(CHtml::image($imageUrl, $label), $url, $options); } else { echo CHtml::link($label, $url, $options); } } }
/** * Registers required files and initialization script */ public function registerClientScript() { /* publish assets dir */ $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'; $assetsUrl = $this->getAssetsUrl($path); $id = TbArray::getValue('id', $this->htmlOptions, $this->getId()); $jsFile = !empty($this->scales) ? 'jQAllRangeSliders-withRuler-min.js' : 'jQAllRangeSliders-min.js'; /* @var $cs CClientScript */ $cs = Yii::app()->getClientScript(); $cs->registerCoreScript('jquery'); $cs->registerCoreScript('jquery.ui'); $this->getYiiWheels()->registerAssetJs('jquery.mousewheel.min.js', CClientScript::POS_HEAD); $cs->registerCssFile($assetsUrl . '/css/' . $this->theme . '.css'); $cs->registerScriptFile($assetsUrl . '/js/' . $jsFile); $options = !empty($this->options) ? CJavaScript::encode($this->options) : ''; $inputValSet = "\$('#{$id}').val(data.values.min+','+data.values.max);"; //inserting trigger if (isset($this->events['valuesChanged'])) { $orig = $this->events['valuesChanged']; if (strpos($orig, 'js:') === 0) { $orig = substr($orig, 3); } $orig = "\n({$orig}).apply(this, arguments);"; } else { $orig = ''; } $this->events['valuesChanged'] = "js: function(id, data) {\n\t\t\t{$inputValSet} {$orig}\n\t\t}"; ob_start(); echo "jQuery('#slider_{$id}').{$this->type}Slider({$options})"; foreach ($this->events as $event => $handler) { echo ".on('{$event}', " . CJavaScript::encode($handler) . ")"; } $cs->registerScript(__CLASS__ . '#' . $this->getId(), ob_get_clean() . ';'); }