/** * Registers plugin options by storing it in a hashed javascript variable. * * @param View $view The View object */ protected function registerOptions($view) { $view->registerJs("var {$this->_hashVar} = {$this->_encodedOptions};\n", $view::POS_HEAD); }
/** * Generates a hashed variable to store the plugin 'clientOptions' and `maskOptions`. * 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) { /* MaskedInput */ $encOptions = empty($this->maskOptions) ? '{}' : Json::htmlEncode($this->maskOptions); $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); }