示例#1
0
    /**
     *
     * 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;
        }
        \kartik\base\Html5InputAsset::register($view);
        $caption = 'jQuery("#' . $this->options['id'] . '")';
        $input = 'jQuery("#' . $this->html5Options['id'] . '")';
        $this->pluginOptions['change'] = new JsExpression("function(color){\n            _.delay(function()\n            {\n                {$caption}.val(color." . $this->saveValueAs . "());\n            }, 500);\n        }");
        $this->registerPlugin('spectrum', $input);
        $js = <<<JS
{$input}.spectrum('set','{$value}');
{$caption}.on('change', function(){
    {$input}.spectrum('set',{$caption}.val());
});
JS;
        $view->registerJs($js);
    }
示例#2
0
 /**
  * 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}.on('change',function(){{$input}.val(this.value)});\n" . "{$input}.on('input change',function(e){{$caption}.val(this.value);if(e.type=='change'){{$caption}.trigger('change');}});";
     $this->registerWidgetJs($js);
 }
示例#3
0
 /**
  * Registers the needed assets
  */
 public function registerColorInput()
 {
     $view = $this->getView();
     ColorInputAsset::register($view);
     if ($this->useNative) {
         return;
     }
     if ($this->showDefaultPalette) {
         $palette = Json::encode($this->_defaultPalette);
         $this->_paletteVar = 'kvPalette_' . hash('crc32', $palette);
         $view->registerJs("var {$this->_paletteVar}={$palette};", View::POS_HEAD);
         $this->pluginOptions['palette'] = new JsExpression($this->_paletteVar);
     }
     Html5InputAsset::register($view);
     $input = 'jQuery("#' . $this->html5Options['id'] . '")';
     $el = 'jQuery("#' . $this->options['id'] . '")';
     $cont = 'jQuery("#' . $this->html5Container['id'] . '")';
     $doneJs = "function(){{$input}.spectrum('set',{$el}.val());{$cont}.removeClass('kv-center-loading');}";
     $this->registerPlugin($this->pluginName, $input, $doneJs);
 }
示例#4
0
 /**
  * Registers the needed assets for [[Html5Input]] widget.
  */
 public function registerAssets()
 {
     $view = $this->getView();
     Html5InputAsset::register($view);
     $idCap = '#' . $this->options['id'];
     $idInp = '#' . $this->html5Options['id'];
     $this->registerWidgetJs("kvInitHtml5('{$idCap}','{$idInp}');");
 }
示例#5
0
 /**
  * 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);
 }