* @since 1.0
* @see http://www.virtuosoft.eu/code/bootstrap-touchspin/
*/
class TouchSpin extends \kartik\base\InputWidget {
/**
* Initializes the widget
*
* @throw InvalidConfigException
*/
public function init() {
parent::init ();
$this->setPluginOptions ();
$this->registerAssets ();
echo $this->getInput ( 'textInput' );
}
/**
* Set the plugin options
*/
protected function setPluginOptions() {
$css = $this->disabled ? 'btn btn-default disabled' : 'btn btn-default';
$defaults = [
'buttonup_class' => $css,
'buttondown_class' => $css,
'buttonup_txt' => '',
'buttondown_txt' => ''
];
$this->pluginOptions = array_replace_recursive ( $defaults, $this->pluginOptions );
if (ArrayHelper::getValue ( $this->pluginOptions, 'verticalbuttons', false ) && empty ( $this->pluginOptions ['prefix'] )) {
Html::addCssClass ( $this->options, 'input-left-rounded' );
}
}
/**
* Registers the needed assets
*/
public function registerAssets() {
$view = $this->getView ();
TouchSpinAsset::register ( $view );
$this->registerPlugin ( 'TouchSpin' );
}
}