├── ActiveField.php ├── ActiveForm.php ├── AjaxButton.php ├── Alert.php ├── Article.php ├── Badge.php ├── Breadcrumbs.php ├── Button.php ├── ButtonGroup.php ├── Close.php ├── DescriptionList.php ├── Dropdown.php ├── Icon.php ├── Modal.php ├── Nav.php ├── NavBar.php ├── OffCanvas.php ├── OverflowBox.php ├── Overlay.php ├── Panel.php ├── Progress.php ├── README.md ├── ScrollSpy.php ├── ScrollableBox.php ├── SmoothScroll.php ├── StandardList.php ├── SubNav.php ├── Switcher.php ├── Thumbnail.php ├── Toggle.php ├── UIkitAlmostFlatAsset.php ├── UIkitAsset.php ├── UIkitGradientAsset.php ├── UIkitPluginAsset.php ├── Widget.php ├── addons ├── AccordionAsset.php ├── AutoCompleteAsset.php ├── DatePickerAsset.php ├── Dotnav.php ├── FormSelectAsset.php ├── HtmlEditorAsset.php ├── LightBoxAsset.php ├── NestableAsset.php ├── NotifyAsset.php ├── SliderAsset.php ├── SlidesetAsset.php ├── SortableAsset.php ├── Sticky.php ├── StickyAsset.php ├── TooltipAsset.php └── UploadAsset.php └── composer.json /ActiveField.php: -------------------------------------------------------------------------------- 1 | 'horizontal']) 59 | * 60 | * // Form field without label 61 | * echo $form->field($model, 'demo', [ 62 | * 'inputOptions' => [ 63 | * 'placeholder' => $model->getAttributeLabel('demo'), 64 | * ], 65 | * ])->label(false); 66 | * 67 | * // Inline radio list 68 | * echo $form->field($model, 'demo')->inline()->radioList($items); 69 | * 70 | * // Control sizing in horizontal mode 71 | * echo $form->field($model, 'demo', [ 72 | * 'horizontalCssClasses' => [ 73 | * 'wrapper' => 'col-sm-2', 74 | * ] 75 | * ]); 76 | * 77 | * // With 'default' layout you would use 'template' to size a specific field: 78 | * // echo $form->field($model, 'demo', [ 79 | * // 'template' => '{label}
{input}{error}{hint}
' 80 | * // ]); 81 | * 82 | * // Input group 83 | * echo $form->field($model, 'demo', [ 84 | * 'inputTemplate' => '
@{input}
', 85 | * ]); 86 | * 87 | * ActiveForm::end(); 88 | * ``` 89 | * 90 | * @see \yii\bootstrap\ActiveForm 91 | * @see http://getbootstrap.com/css/#forms 92 | * 93 | * @author Michael Härtl 94 | * @since 2.0 95 | */ 96 | class ActiveField extends \yii\widgets\ActiveField 97 | { 98 | /** 99 | * @var array the default options for the help tags. The parameter passed to [[help()]] will be 100 | * merged with this property when rendering the help tag. 101 | * The following special options are recognized: 102 | * 103 | * - tag: the tag name of the container element. Defaults to "i". 104 | * 105 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. 106 | */ 107 | public $helpOptions = ['class' => 'uk-icon-question-circle uk-text-muted', 'data' => ['uk-tooltip' => ["cls" => 'help', "offset" => 10]]]; 108 | 109 | /** 110 | * @var bool whether to render [[checkboxList()]] and [[radioList()]] inline. 111 | */ 112 | public $inline = false; 113 | /** 114 | * @var string|null optional template to render the `{input}` placeholder content 115 | */ 116 | public $inputTemplate; 117 | /** 118 | * @var array options for the wrapper tag, used in the `{beginWrapper}` placeholder 119 | */ 120 | public $wrapperOptions = []; 121 | 122 | public $options = ['class' => 'uk-form-row']; 123 | public $labelOptions = ['class' => 'uk-form-label']; 124 | 125 | /** 126 | * @var null|array CSS grid classes for horizontal layout. This must be an array with these keys: 127 | * - 'offset' the offset grid class to append to the wrapper if no label is rendered 128 | * - 'label' the label grid class 129 | * - 'wrapper' the wrapper grid class 130 | * - 'error' the error grid class 131 | * - 'hint' the hint grid class 132 | */ 133 | public $horizontalCssClasses; 134 | /** 135 | * @var string the template for checkboxes in default layout 136 | */ 137 | public $checkboxTemplate = "
\n{beginLabel}\n{input}\n{labelTitle}\n{endLabel}\n{error}\n{hint}\n
"; 138 | /** 139 | * @var string the template for radios in default layout 140 | */ 141 | public $radioTemplate = "
\n{beginLabel}\n{input}\n{labelTitle}\n{endLabel}\n{error}\n{hint}\n
"; 142 | /** 143 | * @var string the template for checkboxes in horizontal layout 144 | */ 145 | public $horizontalCheckboxTemplate = "{beginWrapper}\n
\n{beginLabel}\n{input}\n{labelTitle}\n{endLabel}\n
\n{error}\n{endWrapper}\n{hint}"; 146 | /** 147 | * @var string the template for radio buttons in horizontal layout 148 | */ 149 | public $horizontalRadioTemplate = "{beginWrapper}\n
\n{beginLabel}\n{input}\n{labelTitle}\n{endLabel}\n
\n{error}\n{endWrapper}\n{hint}"; 150 | /** 151 | * @var string the template for inline checkboxLists 152 | */ 153 | public $inlineCheckboxListTemplate = "{label}\n{beginWrapper}\n{input}\n{error}\n{endWrapper}\n{hint}"; 154 | /** 155 | * @var string the template for inline radioLists 156 | */ 157 | public $inlineRadioListTemplate = "{label}\n{beginWrapper}\n{input}\n{error}\n{endWrapper}\n{hint}"; 158 | /** 159 | * @var bool whether to render the error. Default is `true` except for layout `inline`. 160 | */ 161 | public $enableError = true; 162 | /** 163 | * @var bool whether to render the label. Default is `true`. 164 | */ 165 | public $enableLabel = true; 166 | 167 | 168 | /** 169 | * @inheritdoc 170 | */ 171 | public function __construct($config = []) 172 | { 173 | /* 174 | $layoutConfig = $this->createLayoutConfig($config); 175 | $config = ArrayHelper::merge($layoutConfig, $config); 176 | */ 177 | 178 | return parent::__construct($config); 179 | } 180 | 181 | /** 182 | * @inheritdoc 183 | */ 184 | public function render($content = null) 185 | { 186 | if ($content === null) { 187 | Html::addCssClass($this->options, 'uk-form-row'); 188 | 189 | if (!isset($this->parts['{beginWrapper}'])) { 190 | $options = $this->wrapperOptions; 191 | $tag = ArrayHelper::remove($options, 'tag', 'div'); 192 | $this->parts['{beginWrapper}'] = Html::beginTag($tag, $options); 193 | $this->parts['{endWrapper}'] = Html::endTag($tag); 194 | } 195 | if ($this->enableLabel === false) { 196 | $this->parts['{label}'] = ''; 197 | $this->parts['{beginLabel}'] = ''; 198 | $this->parts['{labelTitle}'] = ''; 199 | $this->parts['{endLabel}'] = ''; 200 | } elseif (!isset($this->parts['{beginLabel}'])) { 201 | $this->renderLabelParts(); 202 | } 203 | if ($this->enableError === false) { 204 | $this->parts['{error}'] = ''; 205 | } 206 | if ($this->inputTemplate) { 207 | $input = isset($this->parts['{input}']) ? 208 | $this->parts['{input}'] : Html::activeTextInput($this->model, $this->attribute, $this->inputOptions); 209 | $this->parts['{input}'] = strtr($this->inputTemplate, ['{input}' => $input]); 210 | } 211 | } 212 | return parent::render($content); 213 | } 214 | 215 | /** 216 | * @inheritdoc 217 | */ 218 | public function checkbox($options = [], $enclosedByLabel = true) 219 | { 220 | /* 221 | if ($enclosedByLabel) { 222 | if (!isset($options['template'])) { 223 | $this->template = $this->form->layout === 'horizontal' ? 224 | $this->horizontalCheckboxTemplate : $this->checkboxTemplate; 225 | } else { 226 | $this->template = $options['template']; 227 | unset($options['template']); 228 | } 229 | if ($this->form->layout === 'horizontal') { 230 | Html::addCssClass($this->wrapperOptions, $this->horizontalCssClasses['offset']); 231 | } 232 | $this->labelOptions['class'] = null; 233 | } 234 | */ 235 | 236 | return parent::checkbox($options, false); 237 | } 238 | 239 | /** 240 | * @inheritdoc 241 | */ 242 | public function radio($options = [], $enclosedByLabel = true) 243 | { 244 | if ($enclosedByLabel) { 245 | if (!isset($options['template'])) { 246 | $this->template = $this->form->layout === 'horizontal' ? 247 | $this->horizontalRadioTemplate : $this->radioTemplate; 248 | } else { 249 | $this->template = $options['template']; 250 | unset($options['template']); 251 | } 252 | if ($this->form->layout === 'horizontal') { 253 | Html::addCssClass($this->wrapperOptions, $this->horizontalCssClasses['offset']); 254 | } 255 | $this->labelOptions['class'] = null; 256 | } 257 | 258 | return parent::radio($options, false); 259 | } 260 | 261 | /** 262 | * @inheritdoc 263 | */ 264 | public function checkboxList($items, $options = []) 265 | { 266 | if ($this->inline) { 267 | if (!isset($options['template'])) { 268 | $this->template = $this->inlineCheckboxListTemplate; 269 | } else { 270 | $this->template = $options['template']; 271 | unset($options['template']); 272 | } 273 | if (!isset($options['itemOptions'])) { 274 | $options['itemOptions'] = [ 275 | 'labelOptions' => ['class' => 'checkbox-inline'], 276 | ]; 277 | } 278 | } elseif (!isset($options['item'])) { 279 | $options['item'] = function ($index, $label, $name, $checked, $value) { 280 | return '
' . Html::checkbox($name, $checked, ['label' => $label, 'value' => $value]) . '
'; 281 | }; 282 | } 283 | parent::checkboxList($items, $options); 284 | return $this; 285 | } 286 | 287 | /** 288 | * @inheritdoc 289 | */ 290 | public function radioList($items, $options = []) 291 | { 292 | if ($this->inline) { 293 | if (!isset($options['template'])) { 294 | $this->template = $this->inlineRadioListTemplate; 295 | } else { 296 | $this->template = $options['template']; 297 | unset($options['template']); 298 | } 299 | if (!isset($options['itemOptions'])) { 300 | $options['itemOptions'] = [ 301 | 'labelOptions' => ['class' => 'radio-inline'], 302 | ]; 303 | } 304 | } elseif (!isset($options['item'])) { 305 | $options['item'] = function ($index, $label, $name, $checked, $value) { 306 | return '
' . Html::radio($name, $checked, ['label' => $label, 'value' => $value]) . '
'; 307 | }; 308 | } 309 | parent::radioList($items, $options); 310 | return $this; 311 | } 312 | 313 | /** 314 | * @inheritdoc 315 | */ 316 | public function label($label = null, $options = []) 317 | { 318 | if (is_bool($label)) { 319 | $this->enableLabel = $label; 320 | if ($label === false && $this->form->layout === 'horizontal') { 321 | Html::addCssClass($this->wrapperOptions, $this->horizontalCssClasses['offset']); 322 | } 323 | } else { 324 | $this->enableLabel = true; 325 | $this->renderLabelParts($label, $options); 326 | 327 | if (isset($this->parts['{help}'])) { 328 | if ($label !== null) { 329 | $options['label'] = $label; 330 | } 331 | else { 332 | $attribute = Html::getAttributeName($this->attribute); 333 | $options['label'] = Html::encode($this->model->getAttributeLabel($attribute)); 334 | } 335 | 336 | $label = null; 337 | $options['label'] .= ' ' . $this->parts['{help}']; 338 | } 339 | parent::label($label, $options); 340 | } 341 | return $this; 342 | } 343 | 344 | /** 345 | * @param bool $value whether to render a inline list 346 | * @return static the field object itself 347 | * Make sure you call this method before [[checkboxList()]] or [[radioList()]] to have any effect. 348 | */ 349 | public function inline($value = true) 350 | { 351 | $this->inline = (bool)$value; 352 | return $this; 353 | } 354 | 355 | /** 356 | * @param array $instanceConfig the configuration passed to this instance's constructor 357 | * @return array the layout specific default configuration for this instance 358 | */ 359 | protected function createLayoutConfig($instanceConfig) 360 | { 361 | $config = [ 362 | 'hintOptions' => [ 363 | 'tag' => 'p', 364 | 'class' => 'help-block', 365 | ], 366 | 'errorOptions' => [ 367 | 'tag' => 'p', 368 | 'class' => 'help-block help-block-error', 369 | ], 370 | 'inputOptions' => [ 371 | 'class' => 'form-control', 372 | ], 373 | ]; 374 | 375 | $layout = $instanceConfig['form']->layout; 376 | 377 | if ($layout === 'horizontal') { 378 | #$config['template'] = "{label}\n{beginWrapper}\n{input}\n{error}\n{endWrapper}\n{hint}"; 379 | $config['template'] = "{label}\n{input}\n{error}\n{hint}"; 380 | $cssClasses = [ 381 | 'offset' => 'col-sm-offset-3', 382 | 'label' => 'col-sm-3', 383 | 'wrapper' => 'uk-form-row', 384 | 'error' => '', 385 | 'hint' => 'col-sm-3', 386 | ]; 387 | if (isset($instanceConfig['horizontalCssClasses'])) { 388 | $cssClasses = ArrayHelper::merge($cssClasses, $instanceConfig['horizontalCssClasses']); 389 | } 390 | $config['horizontalCssClasses'] = $cssClasses; 391 | $config['wrapperOptions'] = ['class' => $cssClasses['wrapper']]; 392 | $config['labelOptions'] = ['class' => 'control-label ' . $cssClasses['label']]; 393 | $config['labelOptions'] = ['class' => 'uk-form-label ' . $cssClasses['label']]; 394 | $config['errorOptions'] = ['class' => 'help-block help-block-error ' . $cssClasses['error']]; 395 | $config['hintOptions'] = ['class' => 'help-block ' . $cssClasses['hint']]; 396 | } elseif ($layout === 'inline') { 397 | $config['labelOptions'] = ['class' => 'sr-only']; 398 | $config['enableError'] = false; 399 | } 400 | 401 | return $config; 402 | } 403 | 404 | /** 405 | * @param string|null $label the label or null to use model label 406 | * @param array $options the tag options 407 | */ 408 | protected function renderLabelParts($label = null, $options = []) 409 | { 410 | $options = array_merge($this->labelOptions, $options); 411 | if ($label === null) { 412 | if (isset($options['label'])) { 413 | $label = $options['label']; 414 | unset($options['label']); 415 | } else { 416 | $attribute = Html::getAttributeName($this->attribute); 417 | $label = Html::encode($this->model->getAttributeLabel($attribute)); 418 | } 419 | } 420 | 421 | $this->parts['{beginLabel}'] = Html::beginTag('label', $options); 422 | $this->parts['{endLabel}'] = Html::endTag('label'); 423 | $this->parts['{labelTitle}'] = $label; 424 | } 425 | 426 | /** 427 | * Renders the help tag. 428 | * @param string $content the help content. It will NOT be HTML-encoded. 429 | * @param array $options the tag options in terms of name-value pairs. These will be rendered as 430 | * the attributes of the help tag. The values will be HTML-encoded using [[Html::encode()]]. 431 | * 432 | * The following options are specially handled: 433 | * 434 | * - tag: this specifies the tag name. If not set, "i" will be used. 435 | * 436 | * @return static the field object itself 437 | */ 438 | public function help($content, $options = []) 439 | { 440 | if ($content === null) { 441 | $this->helpOptions['data']['uk-tooltip']['selector'] = '#tooltip_' . Html::getInputId($this->model, $this->attribute); 442 | } 443 | else 444 | $options['title'] = $content; 445 | 446 | $options = array_merge_recursive($this->helpOptions, $options); 447 | $tag = ArrayHelper::remove($options, 'tag', 'i'); 448 | $this->parts['{help}'] = Html::tag($tag, '', $options); 449 | 450 | /** 451 | * Regenerate label field. 452 | */ 453 | return self::label(ArrayHelper::getValue($this->parts, '{labelTitle}')); 454 | } 455 | 456 | public function help_content_id($options = []) 457 | { 458 | return $this->help(null, $options); 459 | } 460 | 461 | /** 462 | * Returns the JS options for the field. 463 | * @return array the JS options 464 | */ 465 | public function getClientOptions() 466 | { 467 | return parent::getClientOptions(); 468 | } 469 | } 470 | -------------------------------------------------------------------------------- /ActiveForm.php: -------------------------------------------------------------------------------- 1 | 'horizontal']) 24 | * ``` 25 | * 26 | * This will set default values for the [[yii\bootstrap\ActiveField|ActiveField]] 27 | * to render horizontal form fields. In particular the [[yii\bootstrap\ActiveField::template|template]] 28 | * is set to `{label} {beginWrapper} {input} {error} {endWrapper} {hint}` and the 29 | * [[yii\bootstrap\ActiveField::horizontalCssClasses|horizontalCssClasses]] are set to: 30 | * 31 | * ```php 32 | * [ 33 | * 'offset' => 'col-sm-offset-3', 34 | * 'label' => 'col-sm-3', 35 | * 'wrapper' => 'col-sm-6', 36 | * 'error' => '', 37 | * 'hint' => 'col-sm-3', 38 | * ] 39 | * ``` 40 | * 41 | * To get a different column layout in horizontal mode you can modify those options 42 | * through [[fieldConfig]]: 43 | * 44 | * ```php 45 | * $form = ActiveForm::begin([ 46 | * 'layout' => 'horizontal', 47 | * 'fieldConfig' => [ 48 | * 'template' => "{label}\n{beginWrapper}\n{input}\n{hint}\n{error}\n{endWrapper}", 49 | * 'horizontalCssClasses' => [ 50 | * 'label' => 'col-sm-4', 51 | * 'offset' => 'col-sm-offset-4', 52 | * 'wrapper' => 'col-sm-8', 53 | * 'error' => '', 54 | * 'hint' => '', 55 | * ], 56 | * ], 57 | * ]); 58 | * ``` 59 | * 60 | * @see \intelligent\uikit\ActiveField for details on the [[fieldConfig]] options 61 | * @see http://getuikit.com/docs/form.html 62 | * 63 | * @author Demchenko Vjacheslav 64 | * @since 2.0 65 | */ 66 | class ActiveForm extends \yii\widgets\ActiveForm 67 | { 68 | /** 69 | * @var array HTML attributes for the form tag. Default is `['class' => 'uk-form']`. 70 | */ 71 | public $options = ['class' => 'uk-form']; 72 | 73 | public $fieldClass = 'intelligent\uikit\ActiveField'; 74 | 75 | /** 76 | * @var string the form layout. Either 'default', 'horizontal' or 'stacked'. 77 | */ 78 | public $layout = 'default'; 79 | 80 | /** 81 | * @inheritdoc 82 | */ 83 | public function init() 84 | { 85 | if (!in_array($this->layout, ['default', 'horizontal', 'stacked'])) { 86 | throw new InvalidConfigException('Invalid layout type: ' . $this->layout); 87 | } 88 | 89 | Html::addCssClass($this->options, 'uk-form'); 90 | 91 | if ($this->layout !== 'default') { 92 | Html::addCssClass($this->options, 'uk-form-' . $this->layout); 93 | 94 | if ($this->layout == 'horizontal') { 95 | $this->fieldConfig['template'] = "{label}\n
{input}\n{error}\n{hint}\n
\n"; 96 | } 97 | else { 98 | $this->fieldConfig['template'] = "{label}\n
{input}\n{error}\n{hint}\n
\n"; 99 | } 100 | } 101 | 102 | if (!isset($this->fieldConfig['labelOptions'])) { 103 | $this->fieldConfig['labelOptions'] = ['class' => 'uk-form-label']; 104 | } 105 | 106 | if (!isset($this->fieldConfig['options'])) { 107 | $this->fieldConfig['options'] = ['class' => 'uk-form-row']; 108 | } 109 | 110 | if (!isset($this->fieldConfig['errorOptions'])) { 111 | $this->fieldConfig['errorOptions'] = ['class' => 'uk-form-help-block']; 112 | } 113 | 114 | if (!isset($this->fieldConfig['inputOptions'])) { 115 | $this->fieldConfig['inputOptions'] = ['class' => 'uk-form-large uk-width-1-1']; 116 | } 117 | parent::init(); 118 | } 119 | 120 | /** 121 | * @inheritdoc 122 | */ 123 | public function errorSummary($models, $options = []) 124 | { 125 | Html::addCssClass($options, $this->errorSummaryCssClass); 126 | $options['encode'] = $this->encodeErrorSummary; 127 | 128 | $header = isset($options['header']) ? $options['header'] : '

' . Yii::t('yii', 'Please fix the following errors:') . '

'; 129 | $footer = isset($options['footer']) ? $options['footer'] : ''; 130 | $encode = !isset($options['encode']) || $options['encode'] !== false; 131 | unset($options['header'], $options['footer'], $options['encode']); 132 | 133 | $lines = []; 134 | if (!is_array($models)) { 135 | $models = [$models]; 136 | } 137 | foreach ($models as $model) { 138 | /* @var $model Model */ 139 | foreach ($model->getFirstErrors() as $name => $error) { 140 | $lines[] = [ 141 | 'error' => ($encode ? Html::encode($error) : $error), 142 | 'name' => $name, 143 | 'model' => $model 144 | ]; 145 | } 146 | } 147 | 148 | if (empty($lines)) { 149 | // still render the placeholder for client-side validation use 150 | $content = ""; 151 | $options['style'] = isset($options['style']) ? rtrim($options['style'], ';') . '; display:none' : 'display:none'; 152 | } else { 153 | //$content = ""; 154 | $content = ""; 157 | } 158 | return Html::tag('div', $header . $content . $footer, $options); 159 | 160 | //return Html::errorSummary($models, $options); 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /AjaxButton.php: -------------------------------------------------------------------------------- 1 | 15 | * 'country_code', 17 | * 'data' => Country::getAllCountries(), 18 | * 'options' => [ 19 | * 'id' => 'country_select', 20 | * 'multiple' => false, 21 | * 'placeholder' => 'Select country...', 22 | * 'class' => 'uk-width-medium-7-10' 23 | * ] 24 | * ]);?> 25 | * 26 | * 'Проверить', 28 | * 'ajaxOptions'=> 29 | * [ 30 | * 'type'=>'POST', 31 | * 'url'=>'country/getinfo', 32 | * 'cache' => false, 33 | * 'success' => new \yii\web\JsExpression('function(html){ 34 | * $("#output").html(html); 35 | * }'), 36 | * ], 37 | * 'options' => ['type' => 'submit'], 38 | * ]); 39 | * AjaxButton::end();?> 40 | * 41 | * 42 | * ``` 43 | * 44 | * @author Oleg Martemjanov 45 | * @since 2.0 46 | */ 47 | 48 | class AjaxButton extends Button 49 | { 50 | public $ajaxOptions = []; 51 | 52 | public function run() 53 | { 54 | parent::run(); 55 | 56 | if (!empty($this->ajaxOptions)) 57 | $this->registerAjaxScript(); 58 | } 59 | 60 | protected function registerAjaxScript() 61 | { 62 | $view = $this->getView(); 63 | 64 | if(!isset($this->ajaxOptions['data']) && isset($this->ajaxOptions['type'])) 65 | $this->ajaxOptions['data'] = new \yii\web\JsExpression('$(this).parents("form").serialize()'); 66 | 67 | $this->ajaxOptions= Json::encode($this->ajaxOptions); 68 | $view->registerJs("$( '#".$this->options['id']."' ).click(function() { 69 | $.ajax(". $this->ajaxOptions ."); 70 | return false; 71 | });"); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /Alert.php: -------------------------------------------------------------------------------- 1 | [ 16 | * 'class' => 'alert-info', 17 | * ], 18 | * 'body' => 'Say hello...', 19 | * ]); 20 | * ``` 21 | * 22 | * The following example will show the content enclosed between the [[begin()]] 23 | * and [[end()]] calls within the alert box: 24 | * 25 | * ```php 26 | * Alert::begin([ 27 | * 'options' => [ 28 | * 'class' => 'alert-warning', 29 | * ], 30 | * ]); 31 | * 32 | * echo 'Say hello...'; 33 | * 34 | * Alert::end(); 35 | * ``` 36 | * 37 | * @author Oleg Martemjanov 38 | * @since 2.0 39 | * 40 | */ 41 | class Alert extends Widget 42 | { 43 | /** 44 | * @var string the body content in the alert component. Note that anything between 45 | * the [[begin()]] and [[end()]] calls of the Alert widget will also be treated 46 | * as the body content, and will be rendered before this. 47 | */ 48 | public $body; 49 | /** 50 | * @var array the options for rendering the close button tag. 51 | * The close button is displayed in the header of the modal window. Clicking 52 | * on the button will hide the modal window. If this is null, no close button will be rendered. 53 | * 54 | * The following special options are supported: 55 | * 56 | * - tag: string, the tag name of the button. Defaults to 'button'. 57 | * - label: string, the label of the button. Defaults to '×'. 58 | * 59 | * The rest of the options will be rendered as the HTML attributes of the button tag. 60 | * Please refer to the [Alert documentation](http://getbootstrap.com/components/#alerts) 61 | * for the supported HTML attributes. 62 | */ 63 | public $closeButton = []; 64 | 65 | /** 66 | * Initializes the widget. 67 | */ 68 | public function init() 69 | { 70 | parent::init(); 71 | 72 | $this->initOptions(); 73 | 74 | echo Html::beginTag('div', $this->options) . "\n"; 75 | echo $this->renderBodyBegin() . "\n"; 76 | } 77 | 78 | /** 79 | * Renders the widget. 80 | */ 81 | public function run() 82 | { 83 | echo "\n" . $this->renderBodyEnd(); 84 | echo "\n" . Html::endTag('div'); 85 | 86 | $this->registerAsset(); 87 | } 88 | 89 | /** 90 | * Renders the close button if any before rendering the content. 91 | * @return string the rendering result 92 | */ 93 | protected function renderBodyBegin() 94 | { 95 | return $this->renderCloseButton(); 96 | } 97 | 98 | /** 99 | * Renders the alert body (if any). 100 | * @return string the rendering result 101 | */ 102 | protected function renderBodyEnd() 103 | { 104 | return $this->body . "\n"; 105 | } 106 | 107 | /** 108 | * Renders the close button. 109 | * @return string the rendering result 110 | */ 111 | protected function renderCloseButton() 112 | { 113 | if ($this->closeButton !== null) { 114 | $tag = ArrayHelper::remove($this->closeButton, 'tag', 'a'); 115 | $label = ArrayHelper::remove($this->closeButton, 'label', ''); 116 | 117 | if ($tag === 'button' && !isset($this->closeButton['type'])) { 118 | $this->closeButton['type'] = 'button'; 119 | } 120 | 121 | if ($tag === 'a' && !isset($this->closeButton['href'])) { 122 | $this->closeButton['href'] = ''; 123 | } 124 | 125 | return Html::tag($tag, $label, $this->closeButton); 126 | } else { 127 | return null; 128 | } 129 | } 130 | 131 | /** 132 | * Initializes the widget options. 133 | * This method sets the default values for various options. 134 | */ 135 | protected function initOptions() 136 | { 137 | Html::addCssClass($this->options, 'uk-alert'); 138 | $this->options['data-uk-alert'] = ''; 139 | 140 | if ($this->closeButton !== null) { 141 | $this->closeButton = array_merge([ 142 | 'class' => 'uk-alert-close uk-close', 143 | ], $this->closeButton); 144 | } 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /Article.php: -------------------------------------------------------------------------------- 1 | [ 16 | * 'class' => 'uk-panel uk-panel-box', 17 | * ], 18 | * 'body' => '

Say hello...

', 19 | * ]); 20 | * ``` 21 | * 22 | * The following example will show the content enclosed between the [[begin()]] 23 | * and [[end()]] calls within the alert box: 24 | * 25 | * ```php 26 | * Article::begin([ 27 | * 'title' => 'First Article', 28 | * 'meta' => '09 May 2014', 29 | * 'lead' => 'This is my first article', 30 | * 'options' => ['class' => 'uk-panel uk-panel-box'] 31 | * ]); 32 | * 33 | * echo '

Say hello...

'; 34 | * 35 | * Article::end(); 36 | * ``` 37 | * 38 | * @author Oleg Martemjanov 39 | * @since 2.0 40 | * 41 | */ 42 | class Article extends Widget 43 | { 44 | 45 | 46 | /** 47 | * @var string the title of the article. 48 | */ 49 | public $title; 50 | 51 | /** 52 | * @var string the meta data of the article. 53 | */ 54 | public $meta; 55 | 56 | /** 57 | * @var string the lead of the article. 58 | */ 59 | public $lead; 60 | 61 | /** 62 | * @var string the body content in the article component. Note that anything between 63 | * the [[begin()]] and [[end()]] calls of the Article widget will also be treated 64 | * as the body content, and will be rendered before this. 65 | */ 66 | public $body; 67 | 68 | /** 69 | * Initializes the widget. 70 | */ 71 | public function init() 72 | { 73 | parent::init(); 74 | 75 | $this->initOptions(); 76 | 77 | echo Html::beginTag('article', $this->options) . "\n"; 78 | echo $this->renderTitle() . "\n"; 79 | echo $this->renderMeta() . "\n"; 80 | echo $this->renderLead() . "\n"; 81 | } 82 | 83 | /** 84 | * Renders the widget. 85 | */ 86 | public function run() 87 | { 88 | echo "\n" . $this->renderBody(); 89 | echo "\n" . Html::endTag('article'); 90 | 91 | $this->registerAsset(); 92 | } 93 | 94 | /** 95 | * Renders the title of the article. 96 | * @return string the rendering result 97 | */ 98 | protected function renderTitle() 99 | { 100 | if ($this->title !== null) { 101 | return Html::tag('h1', $this->title, ['class' => 'uk-article-title']); 102 | } else { 103 | return null; 104 | } 105 | } 106 | 107 | /** 108 | * Renders the meta data. 109 | * @return string the rendering result 110 | */ 111 | protected function renderMeta() 112 | { 113 | if ($this->meta !== null) { 114 | return Html::tag('p', $this->meta, ['class' => 'uk-article-meta']); 115 | } else { 116 | return null; 117 | } 118 | } 119 | 120 | /** 121 | * Renders the lead data. 122 | * @return string the rendering result 123 | */ 124 | protected function renderLead() 125 | { 126 | if ($this->lead !== null) { 127 | return Html::tag('p', $this->lead, ['class' => 'uk-article-lead']); 128 | } else { 129 | return null; 130 | } 131 | } 132 | 133 | /** 134 | * Renders the article body (if any). 135 | * @return string the rendering result 136 | */ 137 | protected function renderBody() 138 | { 139 | return $this->body . "\n"; 140 | } 141 | 142 | /** 143 | * Initializes the widget options. 144 | * This method sets the default values for various options. 145 | */ 146 | protected function initOptions() 147 | { 148 | Html::addCssClass($this->options, 'uk-article'); 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /Badge.php: -------------------------------------------------------------------------------- 1 | [ 16 | * 'class' => 'uk-badge-success', 17 | * ], 18 | * 'body' => 'Say hello...', 19 | * ]); 20 | * ``` 21 | * 22 | * The following example will show the content enclosed between the [[begin()]] 23 | * and [[end()]] calls within the Badge box: 24 | * 25 | * ```php 26 | * Badge::begin([ 27 | * 'isNotification' => true, 28 | * 'options' => [ 29 | * 'class' => 'uk-badge-success', 30 | * ], 31 | * ]); 32 | * 33 | * echo 'Say hello...'; 34 | * 35 | * Badge::end(); 36 | * ``` 37 | * 38 | * @author Oleg Martemjanov 39 | * @since 2.0 40 | * 41 | */ 42 | class Badge extends Widget 43 | { 44 | /** 45 | * @var string the body content in the Badge component. Note that anything between 46 | * the [[begin()]] and [[end()]] calls of the Badge widget will also be treated 47 | * as the body content, and will be rendered before this. 48 | */ 49 | public $body; 50 | 51 | /** 52 | * @var boolean use the notification type of the Badge component. 53 | */ 54 | public $isNotification = false; 55 | 56 | /** 57 | * Initializes the widget. 58 | */ 59 | public function init() 60 | { 61 | parent::init(); 62 | 63 | $this->initOptions(); 64 | 65 | echo Html::beginTag('div', $this->options) . "\n"; 66 | } 67 | 68 | /** 69 | * Renders the widget. 70 | */ 71 | public function run() 72 | { 73 | echo "\n" . $this->body; 74 | echo "\n" . Html::endTag('div'); 75 | 76 | $this->registerAsset(); 77 | } 78 | 79 | /** 80 | * Initializes the widget options. 81 | * This method sets the default values for various options. 82 | */ 83 | protected function initOptions() 84 | { 85 | Html::addCssClass($this->options, 'uk-badge'); 86 | 87 | if($this->isNotification) 88 | Html::addCssClass($this->options, 'uk-badge-notification'); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Breadcrumbs.php: -------------------------------------------------------------------------------- 1 | [ 21 | * ['label' => 'Sample Post', 'url' => ['post/edit', 'id' => 1]], 22 | * 'Edit', 23 | * ], 24 | * ]); 25 | * ~~~ 26 | * 27 | * Because breadcrumbs usually appears in nearly every page of a website, you may consider placing it in a layout view. 28 | * You can use a view parameter (e.g. `$this->params['breadcrumbs']`) to configure the links in different 29 | * views. In the layout view, you assign this view parameter to the [[links]] property like the following: 30 | * 31 | * ~~~ 32 | * // $this is the view object currently being used 33 | * echo Breadcrumbs::widget([ 34 | * 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], 35 | * ]); 36 | * ~~~ 37 | * 38 | * @see http://www.getuikit.com/docs/breadcrumb.html 39 | * @author Nikolay Kostyurin 40 | * @since 2.0 41 | */ 42 | class Breadcrumbs extends \yii\widgets\Breadcrumbs 43 | { 44 | /** 45 | * @var string the name of the breadcrumb container tag. 46 | */ 47 | public $tag = 'ul'; 48 | /** 49 | * @var array the HTML attributes for the breadcrumb container tag. 50 | */ 51 | public $options = ['class' => 'uk-breadcrumb']; 52 | /** 53 | * @var boolean whether to HTML-encode the link labels. 54 | */ 55 | public $encodeLabels = true; 56 | /** 57 | * @var string the first hyperlink in the breadcrumbs (called home link). 58 | * If this property is not set, it will default to a link pointing to [[\yii\web\Application::homeUrl]] 59 | * with the label 'Home'. If this property is false, the home link will not be rendered. 60 | */ 61 | public $homeLink; 62 | /** 63 | * @var array list of links to appear in the breadcrumbs. If this property is empty, 64 | * the widget will not render anything. Each array element represents a single link in the breadcrumbs 65 | * with the following structure: 66 | * 67 | * ~~~ 68 | * [ 69 | * 'label' => 'label of the link', // required 70 | * 'url' => 'url of the link', // optional, will be processed by Html::url() 71 | * ] 72 | * ~~~ 73 | * 74 | * If a link is active, you only need to specify its "label", and instead of writing `['label' => $label]`, 75 | * you should simply use `$label`. 76 | */ 77 | public $links = []; 78 | /** 79 | * @var string the template used to render each inactive item in the breadcrumbs. The token `{link}` 80 | * will be replaced with the actual HTML link for each inactive item. 81 | */ 82 | public $itemTemplate = "
  • {link}
  • \n"; 83 | /** 84 | * @var string the template used to render each active item in the breadcrumbs. The token `{link}` 85 | * will be replaced with the actual HTML link for each active item. 86 | */ 87 | public $activeItemTemplate = "
  • {link}
  • \n"; 88 | 89 | /** 90 | * Renders a single breadcrumb item. 91 | * @param array $link the link to be rendered. It must contain the "label" element. The "url" element is optional. 92 | * @param string $template the template to be used to rendered the link. The token "{link}" will be replaced by the link. 93 | * @return string the rendering result 94 | * @throws InvalidConfigException if `$link` does not have "label" element. 95 | */ 96 | protected function renderItem($link, $template) 97 | { 98 | if (isset($link['label'])) { 99 | $label = $this->encodeLabels ? Html::encode($link['label']) : $link['label']; 100 | } else { 101 | throw new InvalidConfigException('The "label" element is required for each link.'); 102 | } 103 | if (isset($link['url'])) { 104 | return strtr($template, ['{link}' => Html::a($label, $link['url'])]); 105 | } else { 106 | return strtr($template, ['{link}' => Html::tag('span', $label)]); 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /Button.php: -------------------------------------------------------------------------------- 1 | 'Action', 16 | * 'options' => ['class' => 'uk-button-primary'], 17 | * ]); 18 | * ``` 19 | * 20 | * @see http://www.getuikit.com/docs/button.html 21 | * @author Nikolay Kostyurin 22 | * @since 2.0 23 | */ 24 | class Button extends Widget 25 | { 26 | /** 27 | * @var string the tag to use to render the button 28 | */ 29 | public $tagName = 'button'; 30 | /** 31 | * @var string the button label 32 | */ 33 | public $label = 'Button'; 34 | /** 35 | * @var boolean whether the label should be HTML-encoded. 36 | */ 37 | public $encodeLabel = true; 38 | 39 | /** 40 | * Initializes the widget. 41 | * If you override this method, make sure you call the parent implementation first. 42 | */ 43 | public function init() 44 | { 45 | parent::init(); 46 | $this->clientOptions = false; 47 | Html::addCssClass($this->options, 'uk-button'); 48 | } 49 | 50 | /** 51 | * Renders the widget. 52 | */ 53 | public function run() 54 | { 55 | echo Html::tag($this->tagName, $this->encodeLabel ? Html::encode($this->label) : $this->label, $this->options); 56 | 57 | $this->registerAsset(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /ButtonGroup.php: -------------------------------------------------------------------------------- 1 | ['class' => 'uk-margin-top'], 17 | * ]); ?> 18 | * 'south-america']), ['class' => 'uk-button uk-button-primary'] ) ?> 19 | * 'africa']), ['class' => 'uk-button uk-button-primary'] ) ?> 20 | * 'australia']), ['class' => 'uk-button uk-button-primary'] ) ?> 21 | * 22 | * ``` 23 | * 24 | * @see http://www.getuikit.com/docs/button.html 25 | * 26 | * @author Oleg Martemjanov 27 | * @since 2.0 28 | */ 29 | class ButtonGroup extends Widget 30 | { 31 | /** 32 | * @var bool toggle between a group of buttons like a checkbox. 33 | */ 34 | public $checkboxButtons = false; 35 | 36 | /** 37 | * @var bool toggle between a group of buttons, like radio buttons. 38 | */ 39 | public $radioButtons = false; 40 | 41 | /** 42 | * Initializes the widget. 43 | */ 44 | public function init() 45 | { 46 | parent::init(); 47 | 48 | Html::addCssClass($this->options, 'uk-button-group'); 49 | 50 | if ($this->checkboxButtons) 51 | $this->options = array_merge(['data-uk-button-checkbox' => ''], $this->options); 52 | 53 | if ($this->radioButtons) 54 | if ($this->checkboxButtons) 55 | throw new InvalidConfigException("Options 'checkboxButtons' and 'radioButtons' cannot be used at the same time."); 56 | else 57 | $this->options = array_merge(['data-uk-button-radio' => ''], $this->options); 58 | 59 | echo Html::beginTag('div', $this->options) . "\n"; 60 | } 61 | 62 | /** 63 | * Renders the widget. 64 | */ 65 | public function run() 66 | { 67 | echo Html::endTag('div'); 68 | $this->registerAsset(); 69 | } 70 | 71 | 72 | } 73 | -------------------------------------------------------------------------------- /Close.php: -------------------------------------------------------------------------------- 1 | 'button']); 13 | * ]); 14 | * ``` 15 | * @see http://www.getuikit.com/docs/close.html 16 | * @author Oleg Martemjanov 17 | * @since 2.0 18 | */ 19 | class Close extends Widget 20 | { 21 | 22 | /** 23 | * @var string the tag to be used. an or