Exemplo n.º 1
0
 /**
  * Creates view instance from given configuration.
  * @param array $config view configuration.
  * @return View view instance.
  */
 protected function createView(array $config)
 {
     if (!array_key_exists('className', $config)) {
         $config['className'] = View::className();
     }
     return Leaps::createObject($config);
 }
Exemplo n.º 2
0
 /**
  * Generates a hashed variable to store the plugin `clientOptions`. Helps in reusing the variable for similar
  * options passed for other widgets on the same page. The following special data attribute will also be
  * added to the input field to allow accessing the client options via javascript:
  *
  * - 'data-plugin-inputmask' will store the hashed variable storing the plugin options.
  *
  * @param View $view the view instance
  * @author [Thiago Talma](https://github.com/thiagotalma)
  */
 protected function hashPluginOptions($view)
 {
     $encOptions = empty($this->clientOptions) ? '{}' : Json::htmlEncode($this->clientOptions);
     $this->_hashVar = self::PLUGIN_NAME . '_' . hash('crc32', $encOptions);
     $this->options['data-plugin-' . self::PLUGIN_NAME] = $this->_hashVar;
     $view->registerJs("var {$this->_hashVar} = {$encOptions};\n", View::POS_HEAD);
 }