/** * Widget's initialization method * @throws \CException */ public function init() { parent::init(); if ($this->route === null) { throw new \CException(\Yii::t('wheels', '"route" attribute cannot be blank')); } if ($this->noScriptText === null) { $this->noScriptText = \Yii::t('wheels', "Please enable JavaScript to use file uploader."); } $this->clientOptions = ArrayHelper::merge(array('request' => array('endpoint' => \CHtml::normalizeUrl($this->route), 'inputName' => ArrayHelper::getValue($this->options, 'name')), 'validation' => $this->getValidator(), 'messages' => array('typeError' => \Yii::t('wheels', '{file} has an invalid extension. Valid extension(s): {extensions}.'), 'sizeError' => \Yii::t('wheels', '{file} is too large, maximum file size is {sizeLimit}.'), 'minSizeError' => \Yii::t('wheels', '{file} is too small, minimum file size is {minSizeLimit}.'), 'emptyError:' => \Yii::t('wheels', '{file} is empty, please select files again without it.'), 'noFilesError' => \Yii::t('wheels', 'No files to upload.'), 'onLeave' => \Yii::t('zii', 'The files are being uploaded, if you leave now the upload will be cancelled.'))), $this->clientOptions); }
/** * Publishes and registers the necessary script files. */ protected function registerClientScript() { /* publish assets dir */ $assetsUrl = $this->getAssetsUrl('wheels.widgets.assets.highcharts'); /* @var $cs CClientScript */ $cs = \Yii::app()->getClientScript(); $cs->registerScriptFile($assetsUrl . '/js/highcharts.js'); /* register required files */ $defaultOptions = array('exporting' => array('enabled' => true)); $this->clientOptions = ArrayHelper::merge($defaultOptions, $this->clientOptions); if (isset($this->clientOptions['exporting']) && @$this->clientOptions['exporting']['enabled']) { $cs->registerScriptFile($assetsUrl . '/js/modules/exporting.js'); } if ($theme = ArrayHelper::getValue($this->clientOptions, 'theme')) { $cs->registerScriptFile($assetsUrl . '/js/themes/' . $theme . '.js'); } $options = \CJavaScript::encode($this->clientOptions); $script = "var highchart{$this->options['id']} = new Highcharts.Chart({$options});"; $cs->registerScript(md5($script), $script); }
/** * Builds the options */ protected function buildOptions() { $options = array('arrows' => $this->arrows, 'delayOut' => $this->delayOut, 'durationIn' => $this->durationIn, 'durationOut' => $this->durationOut, 'valueLabels' => $this->valueLabels, 'formatter' => $this->formatter, 'step' => $this->step, 'wheelMode' => $this->wheelMode, 'wheelSpeed' => $this->wheelSpeed, 'type' => $this->type == 'dateRange' ? null : $this->inputType); $this->clientOptions = array_filter($options); if ($this->minRange && $this->maxRange && $this->minRange < $this->maxRange) { $this->clientOptions = ArrayHelper::merge($this->clientOptions, array('range' => array('min' => $this->minRange, 'max' => $this->maxRange))); } if ($this->minValue && $this->maxValue && $this->minValue < $this->maxValue) { $this->clientOptions = ArrayHelper::merge($this->clientOptions, array('bounds' => array('min' => $this->minValue, 'max' => $this->maxValue))); } if ($this->minDefaultValue && $this->maxDefaultValue && $this->minDefaultValue < $this->maxDefaultValue) { $this->clientOptions = ArrayHelper::merge($this->clientOptions, array('defaultValues' => array('min' => $this->minDefaultValue, 'max' => $this->maxDefaultValue))); } }
/** * Builds the [[clientOptions]] of the plugin. */ protected function buildOptions() { $onChange = ArrayHelper::remove($this->clientEvents, 'onChange', 'js:$.noop'); $config = array('onChange' => $onChange, 'width' => $this->width, 'height' => $this->height, 'animated' => $this->animated, 'transitionSpeed' => $this->transitionSpeed, 'label' => array('enabled' => $this->onLabel, 'disabled' => $this->offLabel), 'style' => array()); if (!empty($this->enabledStyle)) { $config['style']['enabled'] = $this->enabledStyle; } if (!empty($this->disabledStyle)) { $config['style']['disabled'] = $this->disabledStyle; } if (!empty($this->customEnabledStyle)) { $config['style']['custom'] = array('enabled' => $this->customEnabledStyle); } if (!empty($this->customDisabledStyle)) { if (isset($config['style']['custom'])) { $config['style']['custom']['disabled'] = $this->customDisabledStyle; } else { $config['style']['custom'] = array('disabled' => $this->customDisabledStyle); } } foreach ($config as $key => $element) { if (empty($element)) { unset($config[$key]); } } $this->clientOptions = ArrayHelper::merge($this->clientOptions, $config); }