/** * 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() { 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)); }
/** * 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); }
/** * Displays the first validation error for a model attribute. * @param CModel $model the data model * @param string $attribute the attribute name * @param array $htmlOptions additional HTML attributes to be rendered in the container div tag. * @param boolean $enableAjaxValidation whether to enable AJAX validation for the specified attribute. * @param boolean $enableClientValidation whether to enable client-side validation for the specified attribute. * @return string the validation result (error display or success message). */ public function error($model, $attribute, $htmlOptions = array(), $enableAjaxValidation = true, $enableClientValidation = true) { if (!$this->enableAjaxValidation) { $enableAjaxValidation = false; } if (!$this->enableClientValidation) { $enableClientValidation = false; } if (!$enableAjaxValidation && !$enableClientValidation) { return TbHtml::error($model, $attribute, $htmlOptions); } $id = CHtml::activeId($model, $attribute); $inputID = TbArray::getValue('inputID', $htmlOptions, $id); unset($htmlOptions['inputID']); TbArray::defaultValue('id', $inputID . '_em_', $htmlOptions); $option = array('id' => $id, 'inputID' => $inputID, 'errorID' => $htmlOptions['id'], 'model' => get_class($model), 'name' => $attribute, 'enableAjaxValidation' => $enableAjaxValidation, 'inputContainer' => 'div.control-group'); $optionNames = array('validationDelay', 'validateOnChange', 'validateOnType', 'hideErrorMessage', 'inputContainer', 'errorCssClass', 'successCssClass', 'validatingCssClass', 'beforeValidateAttribute', 'afterValidateAttribute'); foreach ($optionNames as $name) { if (isset($htmlOptions[$name])) { $option[$name] = TbArray::popValue($name, $htmlOptions); } } if ($model instanceof CActiveRecord && !$model->isNewRecord) { $option['status'] = 1; } if ($enableClientValidation) { $validators = TbArray::getValue('clientValidation', $htmlOptions, array()); $attributeName = $attribute; if (($pos = strrpos($attribute, ']')) !== false && $pos !== strlen($attribute) - 1) { $attributeName = substr($attribute, $pos + 1); } foreach ($model->getValidators($attributeName) as $validator) { if ($validator->enableClientValidation) { if (($js = $validator->clientValidateAttribute($model, $attributeName)) != '') { $validators[] = $js; } } } if ($validators !== array()) { $option['clientValidation'] = "js:function(value, messages, attribute) {\n" . implode("\n", $validators) . "\n}"; } } $html = TbHtml::error($model, $attribute, $htmlOptions); if ($html === '') { $htmlOptions['type'] = $this->helpType; TbHtml::addCssStyle('display:none', $htmlOptions); $html = TbHtml::help('', $htmlOptions); } $this->attributes[$inputID] = $option; return $html; }
/** * 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 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 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 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 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 required client script for finuploader */ public function registerClientScript() { /* 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 = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId()); $this->getApi()->registerPlugin('fineUploader', $selector, CMap::mergeArray($this->defaultOptions, $this->pluginOptions)); $this->getApi()->registerEvents($selector, $this->events); }
/** * 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); }
/** * 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); }
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); }
/** * 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); }
/** * * Registers required css js files */ public function registerClientScript() { /* publish assets dir */ $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'; $assetsUrl = $this->getAssetsUrl($path); /* register required moment.js */ $this->getYiiWheels()->registerAssetJs('moment.min.js'); /* @var $cs CClientScript */ $cs = Yii::app()->getClientScript(); $cs->registerCssFile($assetsUrl . '/css/bootstrap-datetimepicker.min.css'); $cs->registerScriptFile($assetsUrl . '/js/bootstrap-datetimepicker.min.js', CClientScript::POS_END); if (isset($this->pluginOptions['language'])) { $cs->registerScriptFile($assetsUrl . '/js/locales/bootstrap-datetimepicker.' . $this->pluginOptions['language'] . '.js', CClientScript::POS_END); } /* initialize plugin */ /* initialize plugin */ $selector = null === $this->selector ? '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId()) . '_datetimepicker' : $this->selector; $this->getApi()->registerPlugin('datetimepicker', $selector, $this->pluginOptions); if ($this->events) { $this->getApi()->registerEvents($selector, $this->events); } }
/** * Generates an image carousel. * @param array $items the item configurations. * @param array $htmlOptions additional HTML attributes. * @return string the generated carousel. */ public static function carousel(array $items, $htmlOptions = array()) { if (!empty($items)) { $id = TbArray::getValue('id', $htmlOptions, parent::ID_PREFIX . parent::$count++); TbArray::defaultValue('id', $id, $htmlOptions); $selector = '#' . $id; self::addCssClass('carousel', $htmlOptions); if (TbArray::popValue('slide', $htmlOptions, true)) { self::addCssClass('slide', $htmlOptions); } $interval = TbArray::popValue('data-interval', $htmlOptions); if ($interval) { $htmlOptions['data-interval'] = $interval; } $pause = TbArray::popValue('data-pause', $htmlOptions); if ($pause) { $htmlOptions['data-pause'] = $pause; } $indicatorOptions = TbArray::popValue('indicatorOptions', $htmlOptions, array()); $innerOptions = TbArray::popValue('innerOptions', $htmlOptions, array()); self::addCssClass('carousel-inner', $innerOptions); $prevOptions = TbArray::popValue('prevOptions', $htmlOptions, array()); $prevLabel = TbArray::popValue('label', $prevOptions, '‹'); $nextOptions = TbArray::popValue('nextOptions', $htmlOptions, array()); $nextLabel = TbArray::popValue('label', $nextOptions, '›'); $hidePrevAndNext = TbArray::popValue('hidePrevAndNext', $htmlOptions, false); $output = self::openTag('div', $htmlOptions); $output .= self::carouselIndicators($selector, count($items), $indicatorOptions); $output .= self::openTag('div', $innerOptions); foreach ($items as $i => $itemOptions) { if (isset($itemOptions['visible']) && $itemOptions['visible'] === false) { continue; } if ($i === 0) { // first item should be active self::addCssClass('active', $itemOptions); } $content = TbArray::popValue('content', $itemOptions, ''); $image = TbArray::popValue('image', $itemOptions, ''); $imageOptions = TbArray::popValue('imageOptions', $itemOptions, array()); $imageAlt = TbArray::popValue('alt', $imageOptions, ''); if (!empty($image)) { $content = parent::image($image, $imageAlt, $imageOptions); } $label = TbArray::popValue('label', $itemOptions); $caption = TbArray::popValue('caption', $itemOptions); $output .= self::carouselItem($content, $label, $caption, $itemOptions); } $output .= '</div>'; if (!$hidePrevAndNext) { $output .= self::carouselPrevLink($prevLabel, $selector, $prevOptions); $output .= self::carouselNextLink($nextLabel, $selector, $nextOptions); } $output .= '</div>'; return $output; } return ''; }
/** * 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'); if (isset($this->pluginOptions['flags']) && $this->pluginOptions['flags'] == true) { $cs->registerCssFile($assetsUrl . '/css/bootstrap-formhelpers-countries.flags.css'); } /* map available locales into iso-code */ $locale = array('US' => 'en_US', 'DE' => 'de_DE', 'ES' => 'es_ES', 'IT' => 'it_IT', 'BR' => 'pt_BR', 'CN' => 'zh_CN', 'TW' => 'zh_TW'); /* register translation file according to chosen locale, fallback 'US' */ if (isset($this->pluginOptions['country']) && isset($locale[$this->pluginOptions['country']])) { $cs->registerScriptFile($assetsUrl . '/js/lang/' . $locale[$this->pluginOptions['country']] . '/bootstrap-formhelpers-countries.' . $locale[$this->pluginOptions['country']] . '.js'); } else { $cs->registerScriptFile($assetsUrl . '/js/lang/en_US/bootstrap-formhelpers-countries.en_US.js'); } $cs->registerScriptFile($assetsUrl . '/js/bootstrap-formhelpers-countries.js'); $cs->registerScriptFile($assetsUrl . '/js/bootstrap-formhelpers-countries.js'); /* initialize plugin */ if (!$this->useHelperSelectBox) { $selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId()); $this->getApi()->registerPlugin('bfhcountries', $selector, $this->pluginOptions); } }
/** * Registers client scripts */ protected function registerClientScript() { $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'; $assetsUrl = $this->getAssetsUrl($path); /* @var $cs CClientScript */ $cs = Yii::app()->clientScript; $cs->registerCoreScript('jquery'); $cs->registerCssFile($assetsUrl . '/css/bootstrap-toggle-buttons.css'); $cs->registerScriptFile($assetsUrl . '/js/jquery.toggle.buttons.js'); /* initialize plugin */ $selector = '#wrapper-' . TbArray::getValue('id', $this->htmlOptions, $this->getId()); $this->getApi()->registerPlugin('toggleButtons', $selector, $this->getConfiguration(), CClientScript::POS_READY); }
/** * Register required scripts. */ public function registerClientScript() { /** @var TbApi $api */ $selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId()); $this->registerPlugin(TbApi::PLUGIN_TYPEAHEAD, $selector, $this->pluginOptions); }
/** * Processes the options for a input row. * @param CModel $model the data model. * @param string $attribute the attribute name. * @param array $options the options. * @return array the processed options. */ protected function processControlGroupOptions($model, $attribute, $options) { $errorOptions = TbArray::popValue('errorOptions', $options, array()); $enableAjaxValidation = TbArray::popValue('enableAjaxValidation', $errorOptions, true); $enableClientValidation = TbArray::popValue('enableClientValidation', $errorOptions, true); $errorOptions['type'] = $this->helpType; $error = $this->error($model, $attribute, $errorOptions, $enableAjaxValidation, $enableClientValidation); // kind of a hack for ajax forms but this works for now. if (!empty($error) && strpos($error, 'display:none') === false) { $options['color'] = TbHtml::INPUT_COLOR_ERROR; } if (!$this->hideInlineErrors) { $options['error'] = $error; } $helpOptions = TbArray::popValue('helpOptions', $options, array()); $helpOptions['type'] = $this->helpType; $options['helpOptions'] = $helpOptions; if (!TbArray::getValue('formLayout', $options, false)) { $options['formLayout'] = $this->layout; } $options['labelWidthClass'] = TbArray::getValue('labelWidthClass', $options, $this->labelWidthClass); $options['controlWidthClass'] = TbArray::getValue('controlWidthClass', $options, $this->controlWidthClass); return $options; }
/** * * Registers required css js files */ public function registerClientScript() { /* publish assets dir */ $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'; $assetsUrl = $this->getAssetsUrl($path); /* register required moment.js */ $this->getYiiWheels()->registerAssetJs('moment-with-locales.js'); /* @var $cs CClientScript */ $cs = Yii::app()->getClientScript(); $cs->registerCssFile($assetsUrl . '/css/daterangepicker.css'); $cs->registerScriptFile($assetsUrl . '/js/daterangepicker.js', CClientScript::POS_END); /* initialize plugin */ $selector = null === $this->selector ? '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId()) : $this->selector; $callback = $this->callback instanceof CJavaScriptExpression ? $this->callback : ($this->callback === null ? '' : new CJavaScriptExpression($this->callback)); $cs->registerScript(__CLASS__ . '#' . $this->getId(), '$("' . $selector . '").daterangepicker(' . CJavaScript::encode($this->pluginOptions) . ($callback ? ', ' . CJavaScript::encode($callback) : '') . ');'); }
/** * Publishes and registers the necessary script files. */ protected 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/highcharts.js'); /* register required files */ $defaultOptions = array('exporting' => array('enabled' => true)); $this->pluginOptions = CMap::mergeArray($defaultOptions, $this->pluginOptions); if (isset($this->pluginOptions['exporting']) && @$this->pluginOptions['exporting']['enabled']) { $cs->registerScriptFile($assetsUrl . '/js/modules/exporting.js'); } if ($theme = TbArray::getValue('theme', $this->pluginOptions)) { $cs->registerScriptFile($assetsUrl . '/js/themes/' . $theme . '.js'); } $options = CJavaScript::encode($this->pluginOptions); $cs->registerScript(__CLASS__ . '#' . $this->getId(), "var highchart{$this->getId()} = new Highcharts.Chart({$options});"); }
/** * 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); $id = TbArray::getValue('id', $this->htmlOptions); /* @var $cs CClientScript */ $cs = Yii::app()->getClientScript(); $min = $this->debugMode ? '.min' : ''; $cs->registerCssFile($assetsUrl . '/css/bootstrap-switch.css'); $cs->registerScriptFile($assetsUrl . '/js/bootstrap-switch' . $min . '.js', CClientScript::POS_END); $selector = '#' . $id; $this->getApi()->registerPlugin('bootstrapSwitch', $selector); $this->getApi()->registerEvents($selector, $this->events); }
/** * Registers required client script for bootstrap ace editor. */ 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/ace.js', CClientScript::POS_END); $id = TbArray::getValue('id', $this->htmlOptions, $this->getId()); /* Global value that will hold the editor */ $cs->registerScript(uniqid(__CLASS__ . '#' . $id, true), 'var ' . $id . ';', CClientScript::POS_HEAD); ob_start(); /* initialize plugin */ $selector = TbArray::getValue('id', $this->htmlOptions, $this->getId()); echo $selector . '= ace.edit("' . $id . '");' . PHP_EOL; echo $selector . '.setTheme("ace/theme/' . $this->theme . '");' . PHP_EOL; echo $selector . '.getSession().setMode(' . (is_array($this->mode) ? CJavaScript::encode($this->mode) : '"ace/mode/' . $this->mode . '"') . ');' . PHP_EOL; echo $selector . '.setValue($("#' . $this->htmlOptions['textareaId'] . '").val());' . PHP_EOL; echo $selector . '.getSession().on("change", function(){ var theVal = ' . $selector . '.getSession().getValue(); $("#' . $this->htmlOptions['textareaId'] . '").val(theVal); });'; if (!empty($this->events) && is_array($this->events)) { foreach ($this->events as $name => $handler) { $handler = $handler instanceof CJavaScriptExpression ? $handler : new CJavaScriptExpression($handler); echo $id . ".getSession().on('{$name}', {$handler});" . PHP_EOL; } } if (!empty($this->pluginOptions)) { echo $selector . '.setOptions(' . CJavaScript::encode($this->pluginOptions) . ')'; } $cs->registerScript(uniqid(__CLASS__ . '#ReadyJS' . $id, true), ob_get_clean()); }
/** * Renders the data cell content. * This method renders the view, update and toggle buttons in the data cell. * @param integer $row the row number (zero-based) * @param mixed $data the data associated with the row */ protected function renderDataCellContent($row, $data) { $checked = CHtml::value($data, $this->name); $toggleOptions = $this->toggleOptions; $toggleOptions['icon'] = $checked === null ? $this->emptyIcon : ($checked ? $this->checkedIcon : $this->uncheckedIcon); $toggleOptions['url'] = isset($toggleOptions['url']) ? $this->evaluateExpression($toggleOptions['url'], array('data' => $data, 'row' => $row)) : '#'; if (!$this->displayText) { $htmlOptions = TbArray::getValue('htmlOptions', $this->toggleOptions, array()); $htmlOptions['title'] = $this->getButtonLabel($checked); $htmlOptions['rel'] = 'tooltip'; echo CHtml::link(TbHtml::icon($toggleOptions['icon']), $toggleOptions['url'], $htmlOptions); } else { echo TbHtml::button($this->getButtonLabel($checked), $toggleOptions); } }
/** * 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() . ';'); }
/** * Normalizes the tab configuration. * @param array $tabs a reference to the tabs tab configuration. */ protected function normalizeTabs($tabs) { $controller = $this->getController(); if (isset($controller)) { foreach ($tabs as &$tabOptions) { $items = TbArray::getValue('items', $tabOptions, array()); if (!empty($items)) { $tabOptions['items'] = $this->normalizeTabs($items); } else { if (isset($tabOptions['view'])) { $view = TbArray::popValue('view', $tabOptions); if ($controller->getViewFile($view) !== false) { $tabOptions['content'] = $controller->renderPartial($view, $this->viewData, true); } } } } } return $tabs; }