/** * Registers the needed assets */ public function registerAssets() { $view = $this->getView(); $value = $this->hasModel() ? Html::getAttributeValue($this->model, $this->attribute) : $this->value; $this->html5Options['value'] = $value; ColorInputAsset::register($view); if ($this->useNative) { parent::registerAssets(); return; } Html5InputAsset::register($view); $caption = 'jQuery("#' . $this->options['id'] . '")'; $input = 'jQuery("#' . $this->html5Options['id'] . '")'; $this->pluginOptions['change'] = new JsExpression("function(color){{$caption}.val(color.toString());}"); $this->registerPlugin('spectrum', $input); $js = <<<JS {$input}.spectrum('set','{$value}'); {$caption}.on('change', function(){ {$input}.spectrum('set',{$caption}.val()); }); JS; $view->registerJs($js); }
/** * Registers the needed assets */ public function registerAssets() { $view = $this->getView(); Html5InputAsset::register($view); $caption = 'jQuery("#' . $this->options['id'] . '")'; $input = 'jQuery("#' . $this->html5Options['id'] . '")'; $js = "{$caption}.change(function(){{$input}.val(this.value)});\n" . "{$input}.change(function(){{$caption}.val(this.value); {$caption}.trigger('change');});"; $view->registerJs($js); }