/** * Widget's init function */ public function init() { $this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin')); if (!($style = WhHtml::popOption('style', $this->htmlOptions, ''))) { $this->htmlOptions['style'] = $style; } $width = WhHtml::getOption('width', $this->htmlOptions, '100%'); $height = WhHtml::popOption('height', $this->htmlOptions, '450px'); $this->htmlOptions['style'] = "width:{$width};height:{$height};" . $this->htmlOptions['style']; }
/** * Registers the client scripts for the button column. */ protected function registerClientScript() { $js = array(); $function = CJavaScript::encode(WhHtml::popOption('click', $this->toggleOptions, '')); $class = preg_replace('/\\s+/', '.', $this->toggleOptions['htmlOptions']['class']); $js[] = "\$(document).on('click','#{$this->grid->id} a.{$class}',{$function});"; Yii::app()->getClientScript()->registerScript(__CLASS__ . '#ReadyJS', implode("\n", $js)); }
/** * Helper method to display different input types for the different complain bootstrap forms wrapped with their * labels, help and error messages. This method is a replacement of the old 'typeRow' methods from Yii-Bootstrap * extension. Example: * <pre> * $form->row(WhHtml::INPUT_TEXT, $model, 'attribute', array('style'=>'width:125px')); * $form->row(WhHtml::INPUT_DROPDOWN, $model, 'attribute', array('a'=>'A','b'=>'B'), array()); * </pre> * @param $type * @param $model * @param $attribute * @param $data * @param array $htmlOptions * @return string * @throws CException */ public function row($type, $model, $attribute, $data = array(), $htmlOptions = array()) { if (!in_array($type, WhHtml::validInputs())) { throw new CException(Yii::t('tb', 'Unrecognized input type')); } $labelOptions = WhHtml::popOption('labelOptions', $htmlOptions, array()); $errorOptions = WhHtml::popOption('errorOptions', $htmlOptions, array()); $containerOptions = WhHtml::popOption('containerOptions', $htmlOptions, array()); $labelOptions = WhHtml::defaultOption('formType', $this->type, $labelOptions); ob_start(); // make sure it holds the class control-label if ($this->type === WhHtml::FORM_HORIZONTAL) { echo CHtml::openTag('div', WhHtml::addClassName('control-group', $containerOptions)); } // form's inline do not render labels and radio|checkbox input types render label's differently if ($this->type !== WhHtml::FORM_INLINE && !preg_match('/radio|checkbox/i', $type) && WhHtml::popOption('label', $htmlOptions, true)) { echo CHtml::activeLabel($model, $attribute, $labelOptions); } elseif (preg_match('/radio|checkbox/i', $type)) { $htmlOptions['labelOptions'] = $labelOptions; } if (WhHtml::popOption('block', $htmlOptions, false)) { $htmlOptions = WhHtml::addClassName('input-block-level', $htmlOptions); } $params = in_array($type, WhHtml::$dataInputs) ? array($model, $attribute, $data, $htmlOptions) : array($model, $attribute, $htmlOptions); $errorSpan = $this->error($model, $attribute, $errorOptions); echo $this->wrapControl(call_user_func_array('WhHtml::active' . ucfirst($type), $params), $errorSpan); /* since PHP 5.3 */ if ($this->type == WhHtml::FORM_VERTICAL && WhHtml::popOption('error', $htmlOptions, true)) { echo $errorSpan; } if ($this->type == WhHtml::FORM_HORIZONTAL) { echo '</div>'; } return ob_get_clean(); }