This commit is contained in:
2020-10-06 14:27:47 +07:00
commit 586be80cf6
16613 changed files with 3274099 additions and 0 deletions

127
vendor/yiisoft/yii2-jui/Accordion.php vendored Normal file
View File

@@ -0,0 +1,127 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use yii\base\InvalidConfigException;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
/**
* Accordion renders an accordion jQuery UI widget.
*
* For example:
*
* ```php
* echo Accordion::widget([
* 'items' => [
* [
* 'header' => 'Section 1',
* 'content' => 'Mauris mauris ante, blandit et, ultrices a, suscipit eget...',
* ],
* [
* 'header' => 'Section 2',
* 'headerOptions' => ['tag' => 'h3'],
* 'content' => 'Sed non urna. Phasellus eu ligula. Vestibulum sit amet purus...',
* 'options' => ['tag' => 'div'],
* ],
* ],
* 'options' => ['tag' => 'div'],
* 'itemOptions' => ['tag' => 'div'],
* 'headerOptions' => ['tag' => 'h3'],
* 'clientOptions' => ['collapsible' => false],
* ]);
* ```
*
* @see http://api.jqueryui.com/accordion/
* @author Alexander Kochetov <creocoder@gmail.com>
* @since 2.0
*/
class Accordion extends Widget
{
/**
* @var array the HTML attributes for the widget container tag. The following special options are recognized:
*
* - tag: string, defaults to "div", the tag name of the container tag of this widget
*
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $options = [];
/**
* @var array list of collapsible items. Each item can be an array of the following structure:
*
* ~~~
* [
* 'header' => 'Item header',
* 'content' => 'Item content',
* // the HTML attributes of the item header container tag. This will overwrite "headerOptions".
* 'headerOptions' => [],
* // the HTML attributes of the item container tag. This will overwrite "itemOptions".
* 'options' => [],
* ]
* ~~~
*/
public $items = [];
/**
* @var array list of HTML attributes for the item container tags. This will be overwritten
* by the "options" set in individual [[items]]. The following special options are recognized:
*
* - tag: string, defaults to "div", the tag name of the item container tags.
*
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $itemOptions = [];
/**
* @var array list of HTML attributes for the item header container tags. This will be overwritten
* by the "headerOptions" set in individual [[items]]. The following special options are recognized:
*
* - tag: string, defaults to "h3", the tag name of the item container tags.
*
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $headerOptions = [];
/**
* Renders the widget.
*/
public function run()
{
$options = $this->options;
$tag = ArrayHelper::remove($options, 'tag', 'div');
echo Html::beginTag($tag, $options) . "\n";
echo $this->renderItems() . "\n";
echo Html::endTag($tag) . "\n";
$this->registerWidget('accordion');
}
/**
* Renders collapsible items as specified on [[items]].
* @return string the rendering result.
* @throws InvalidConfigException.
*/
protected function renderItems()
{
$items = [];
foreach ($this->items as $item) {
if (!array_key_exists('header', $item)) {
throw new InvalidConfigException("The 'header' option is required.");
}
if (!array_key_exists('content', $item)) {
throw new InvalidConfigException("The 'content' option is required.");
}
$headerOptions = array_merge($this->headerOptions, ArrayHelper::getValue($item, 'headerOptions', []));
$headerTag = ArrayHelper::remove($headerOptions, 'tag', 'h3');
$items[] = Html::tag($headerTag, $item['header'], $headerOptions);
$options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', []));
$tag = ArrayHelper::remove($options, 'tag', 'div');
$items[] = Html::tag($tag, $item['content'], $options);
}
return implode("\n", $items);
}
}

View File

@@ -0,0 +1,76 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use yii\helpers\Html;
/**
* AutoComplete renders an autocomplete jQuery UI widget.
*
* For example:
*
* ```php
* echo AutoComplete::widget([
* 'model' => $model,
* 'attribute' => 'country',
* 'clientOptions' => [
* 'source' => ['USA', 'RUS'],
* ],
* ]);
* ```
*
* The following example will use the name property instead:
*
* ```php
* echo AutoComplete::widget([
* 'name' => 'country',
* 'clientOptions' => [
* 'source' => ['USA', 'RUS'],
* ],
* ]);
* ```
*
* You can also use this widget in an [[yii\widgets\ActiveForm|ActiveForm]] using the [[yii\widgets\ActiveField::widget()|widget()]]
* method, for example like this:
*
* ```php
* <?= $form->field($model, 'from_date')->widget(\yii\jui\AutoComplete::classname(), [
* 'clientOptions' => [
* 'source' => ['USA', 'RUS'],
* ],
* ]) ?>
* ```
*
* @see http://api.jqueryui.com/autocomplete/
* @author Alexander Kochetov <creocoder@gmail.com>
* @since 2.0
*/
class AutoComplete extends InputWidget
{
/**
* @inheritdoc
*/
public function run()
{
$this->registerWidget('autocomplete');
return $this->renderWidget();
}
/**
* Renders the AutoComplete widget.
* @return string the rendering result.
*/
public function renderWidget()
{
if ($this->hasModel()) {
return Html::activeTextInput($this->model, $this->attribute, $this->options);
} else {
return Html::textInput($this->name, $this->value, $this->options);
}
}
}

78
vendor/yiisoft/yii2-jui/CHANGELOG.md vendored Normal file
View File

@@ -0,0 +1,78 @@
Yii Framework 2 jui extension Change Log
========================================
2.0.7 November 25, 2017
-----------------------
- Bug #45: Fixed missing close icon in `yii\jui\Dialog` (mtangoo)
- Bug #46: `yii\jui\Selectable` add support for `begin()`, `end()` widget methods (fdezmc)
- Enh #56: Use `jQuery` instead of `$` in generated code to avoid conflicts (samdark)
- Chg #55: `yii\jui\AutoComplete::run()` now returns output instead of echoing it (unlimix)
- Chg #72: Updated jQueryUI dependency to use `1.12.1` as minimum version (samdark)
2.0.6 July 22, 2016
-----------------------
- Bug #36: `yii\jui\Draggable` was using wrong event names (samdark)
- Bug #41: `yii\jui\Droppable` and `yii\jui\Resizable` were using wrong event names (samdark)
2.0.5 March 17, 2016
--------------------
- Bug #8607: `yii\jui\Spinner` was using wrong event names (samdark)
2.0.4 May 10, 2015
------------------
- Bug #6: When using `DatePicker` translations, asset was registered without timestamp when asset manager `$appendTimestamp` was enabled (samdark)
- Bug (CVE-2015-3397): Using `Json::htmlEncode()` for safer JSON data encoding in HTML code (samdark, Tomasz Tokarski)
2.0.3 March 01, 2015
--------------------
- Enh #7127: `name` or `model` and `attribute` are no longer required properties of `yii\jui\InputWidget` (nirvana-msu, cebe)
2.0.2 January 11, 2015
----------------------
- Enh #6570: Datepicker now uses fallback to find language files, e.g. application language is `de-DE` and the translation files does not exists, it will use `de` instead (cebe)
- Enh #6471: Datepicker will now show an empty field when value is an empty string (cebe)
2.0.1 December 07, 2014
-----------------------
- no changes in this release.
2.0.0 October 12, 2014
----------------------
- no changes in this release.
2.0.0-rc September 27, 2014
---------------------------
- Chg #1551: Jui datepicker has a new property `$dateFormat` which is used to set the clientOption `dateFormat`.
The new property does not use the datepicker formatting syntax anymore but uses the same as the `yii\i18n\Formatter`
class which is the ICU syntax for date formatting, you have to adjust all your DatePicker widgets to use
the new property instead of setting the dateFormat in the clientOptions (cebe)
2.0.0-beta April 13, 2014
-------------------------
- Bug #1550: fixed the issue that JUI input widgets did not property input IDs. (qiangxue)
- Bug #2514: Jui sortable clientEvents were not working because of wrong naming assumptions. (cebe)
- Enh #2573: Jui datepicker now uses the current application language by default. (andy5)
2.0.0-alpha, December 1, 2013
-----------------------------
- Initial release.

208
vendor/yiisoft/yii2-jui/DatePicker.php vendored Normal file
View File

@@ -0,0 +1,208 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use Yii;
use yii\base\InvalidParamException;
use yii\helpers\FormatConverter;
use yii\helpers\Html;
use yii\helpers\Json;
/**
* DatePicker renders a `datepicker` jQuery UI widget.
*
* For example to use the datepicker with a [[\yii\base\Model|model]]:
*
* ```php
* echo DatePicker::widget([
* 'model' => $model,
* 'attribute' => 'from_date',
* //'language' => 'ru',
* //'dateFormat' => 'yyyy-MM-dd',
* ]);
* ```
*
* The following example will use the name property instead:
*
* ```php
* echo DatePicker::widget([
* 'name' => 'from_date',
* 'value' => $value,
* //'language' => 'ru',
* //'dateFormat' => 'yyyy-MM-dd',
* ]);
* ```
*
* You can also use this widget in an [[\yii\widgets\ActiveForm|ActiveForm]] using the [[\yii\widgets\ActiveField::widget()|widget()]]
* method, for example like this:
*
* ```php
* <?= $form->field($model, 'from_date')->widget(\yii\jui\DatePicker::classname(), [
* //'language' => 'ru',
* //'dateFormat' => 'yyyy-MM-dd',
* ]) ?>
* ```
*
* Note that and empty string (`''`) and `null` will result in an empty text field while `0` will be
* interpreted as a UNIX timestamp and result in a date displayed as `1970-01-01`.
* It is recommended to add a
* validation filter in your model that sets the value to `null` in case when no date has been entered:
*
* ```php
* [['from_date'], 'default', 'value' => null],
* ```
*
* @see http://api.jqueryui.com/datepicker/
* @author Alexander Kochetov <creocoder@gmail.com>
* @author Carsten Brandt <mail@cebe.cc>
* @since 2.0
*/
class DatePicker extends InputWidget
{
/**
* @var string the locale ID (e.g. 'fr', 'de', 'en-GB') for the language to be used by the date picker.
* If this property is empty, then the current application language will be used.
*
* Since version 2.0.2 a fallback is used if the application language includes a locale part (e.g. `de-DE`) and the language
* file does not exist, it will fall back to using `de`.
*/
public $language;
/**
* @var boolean If true, shows the widget as an inline calendar and the input as a hidden field.
*/
public $inline = false;
/**
* @var array the HTML attributes for the container tag. This is only used when [[inline]] is true.
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $containerOptions = [];
/**
* @var string the format string to be used for formatting the date value. This option will be used
* to populate the [[clientOptions|clientOption]] `dateFormat`.
* The value can be one of "short", "medium", "long", or "full", which represents a preset format of different lengths.
*
* It can also be a custom format as specified in the [ICU manual](http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax).
* Alternatively this can be a string prefixed with `php:` representing a format that can be recognized by the
* PHP [date()](http://php.net/manual/de/function.date.php)-function.
*
* For example:
*
* ```php
* 'MM/dd/yyyy' // date in ICU format
* 'php:m/d/Y' // the same date in PHP format
* ```
*
* If not set the default value will be taken from `Yii::$app->formatter->dateFormat`.
*/
public $dateFormat;
/**
* @var string the model attribute that this widget is associated with.
* The value of the attribute will be converted using [[\yii\i18n\Formatter::asDate()|`Yii::$app->formatter->asDate()`]]
* with the [[dateFormat]] if it is not null.
*/
public $attribute;
/**
* @var string the input value.
* This value will be converted using [[\yii\i18n\Formatter::asDate()|`Yii::$app->formatter->asDate()`]]
* with the [[dateFormat]] if it is not null.
*/
public $value;
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if ($this->inline && !isset($this->containerOptions['id'])) {
$this->containerOptions['id'] = $this->options['id'] . '-container';
}
if ($this->dateFormat === null) {
$this->dateFormat = Yii::$app->formatter->dateFormat;
}
}
/**
* Renders the widget.
*/
public function run()
{
echo $this->renderWidget() . "\n";
$containerID = $this->inline ? $this->containerOptions['id'] : $this->options['id'];
$language = $this->language ? $this->language : Yii::$app->language;
if (strncmp($this->dateFormat, 'php:', 4) === 0) {
$this->clientOptions['dateFormat'] = FormatConverter::convertDatePhpToJui(substr($this->dateFormat, 4));
} else {
$this->clientOptions['dateFormat'] = FormatConverter::convertDateIcuToJui($this->dateFormat, 'date', $language);
}
if ($language !== 'en-US') {
$view = $this->getView();
$assetBundle = DatePickerLanguageAsset::register($view);
$assetBundle->language = $language;
$options = Json::htmlEncode($this->clientOptions);
$language = Html::encode($language);
$view->registerJs("jQuery('#{$containerID}').datepicker($.extend({}, $.datepicker.regional['{$language}'], $options));");
} else {
$this->registerClientOptions('datepicker', $containerID);
}
$this->registerClientEvents('datepicker', $containerID);
JuiAsset::register($this->getView());
}
/**
* Renders the DatePicker widget.
* @return string the rendering result.
*/
protected function renderWidget()
{
$contents = [];
// get formatted date value
if ($this->hasModel()) {
$value = Html::getAttributeValue($this->model, $this->attribute);
} else {
$value = $this->value;
}
if ($value !== null && $value !== '') {
// format value according to dateFormat
try {
$value = Yii::$app->formatter->asDate($value, $this->dateFormat);
} catch(InvalidParamException $e) {
// ignore exception and keep original value if it is not a valid date
}
}
$options = $this->options;
$options['value'] = $value;
if ($this->inline === false) {
// render a text input
if ($this->hasModel()) {
$contents[] = Html::activeTextInput($this->model, $this->attribute, $options);
} else {
$contents[] = Html::textInput($this->name, $value, $options);
}
} else {
// render an inline date picker with hidden input
if ($this->hasModel()) {
$contents[] = Html::activeHiddenInput($this->model, $this->attribute, $options);
} else {
$contents[] = Html::hiddenInput($this->name, $value, $options);
}
$this->clientOptions['defaultDate'] = $value;
$this->clientOptions['altField'] = '#' . $this->options['id'];
$contents[] = Html::tag('div', null, $this->containerOptions);
}
return implode("\n", $contents);
}
}

View File

@@ -0,0 +1,53 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use Yii;
use yii\web\AssetBundle;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class DatePickerLanguageAsset extends AssetBundle
{
public $sourcePath = '@bower/jquery-ui';
/**
* @var boolean whether to automatically generate the needed language js files.
* If this is true, the language js files will be determined based on the actual usage of [[DatePicker]]
* and its language settings. If this is false, you should explicitly specify the language js files via [[js]].
*/
public $autoGenerate = true;
/**
* @var string language to register translation file for
*/
public $language;
/**
* @inheritdoc
*/
public $depends = [
'yii\jui\JuiAsset',
];
/**
* @inheritdoc
*/
public function registerAssetFiles($view)
{
if ($this->autoGenerate) {
$language = $this->language;
$fallbackLanguage = substr($this->language, 0, 2);
if ($fallbackLanguage !== $this->language && !file_exists(Yii::getAlias($this->sourcePath . "/ui/i18n/datepicker-{$language}.js"))) {
$language = $fallbackLanguage;
}
$this->js[] = "ui/i18n/datepicker-$language.js";
}
parent::registerAssetFiles($view);
}
}

61
vendor/yiisoft/yii2-jui/Dialog.php vendored Normal file
View File

@@ -0,0 +1,61 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use yii\helpers\Html;
/**
* Dialog renders an dialog jQuery UI widget.
*
* For example:
*
* ```php
* Dialog::begin([
* 'clientOptions' => [
* 'modal' => true,
* ],
* ]);
*
* echo 'Dialog contents here...';
*
* Dialog::end();
* ```
*
* @see http://api.jqueryui.com/dialog/
* @author Alexander Kochetov <creocoder@gmail.com>
* @since 2.0
*/
class Dialog extends Widget
{
/**
* Initializes the widget.
*/
public function init()
{
parent::init();
echo Html::beginTag('div', $this->options) . "\n";
//Fix for closing icon (x) not showing up in dialog
$this->getView()->registerJs("
if ($.fn.button) {
var bootstrapButton = $.fn.button.noConflict();
$.fn.bootstrapBtn = bootstrapButton;
}",
\yii\web\View::POS_READY
);
}
/**
* Renders the widget.
*/
public function run()
{
echo Html::endTag('div') . "\n";
$this->registerWidget('dialog');
}
}

61
vendor/yiisoft/yii2-jui/Draggable.php vendored Normal file
View File

@@ -0,0 +1,61 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use yii\helpers\Html;
/**
* Draggable renders an draggable jQuery UI widget.
*
* For example:
*
* ```php
* Draggable::begin([
* 'clientOptions' => ['grid' => [50, 20]],
* ]);
*
* echo 'Draggable contents here...';
*
* Draggable::end();
* ```
*
* @see http://api.jqueryui.com/draggable/
* @author Alexander Kochetov <creocoder@gmail.com>
* @since 2.0
*/
class Draggable extends Widget
{
/**
* @inheritdoc
*/
protected $clientEventMap = [
'create' => 'dragcreate',
'drag' => 'drag',
'stop' => 'dragstop',
'start' => 'dragstart',
];
/**
* Initializes the widget.
*/
public function init()
{
parent::init();
echo Html::beginTag('div', $this->options) . "\n";
}
/**
* Renders the widget.
*/
public function run()
{
echo Html::endTag('div') . "\n";
$this->registerWidget('draggable');
}
}

63
vendor/yiisoft/yii2-jui/Droppable.php vendored Normal file
View File

@@ -0,0 +1,63 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use yii\helpers\Html;
/**
* Droppable renders an droppable jQuery UI widget.
*
* For example:
*
* ```php
* Droppable::begin([
* 'clientOptions' => ['accept' => '.special'],
* ]);
*
* echo 'Droppable body here...';
*
* Droppable::end();
* ```
*
* @see http://api.jqueryui.com/droppable/
* @author Alexander Kochetov <creocoder@gmail.com>
* @since 2.0
*/
class Droppable extends Widget
{
/**
* @inheritdoc
*/
protected $clientEventMap = [
'activate' => 'dropactivate',
'create' => 'dropcreate',
'deactivate' => 'dropdeactivate',
'drop' => 'drop',
'out' => 'dropout',
'over' => 'dropover',
];
/**
* Initializes the widget.
*/
public function init()
{
parent::init();
echo Html::beginTag('div', $this->options) . "\n";
}
/**
* Renders the widget.
*/
public function run()
{
echo Html::endTag('div') . "\n";
$this->registerWidget('droppable');
}
}

67
vendor/yiisoft/yii2-jui/InputWidget.php vendored Normal file
View File

@@ -0,0 +1,67 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use yii\base\Model;
use yii\helpers\Html;
/**
* InputWidget is the base class for all jQuery UI input widgets.
*
* Classes extending from this widget can be used in an [[yii\widgets\ActiveForm|ActiveForm]]
* using the [[yii\widgets\ActiveField::widget()|widget()]] method, for example like this:
*
* ```php
* <?= $form->field($model, 'from_date')->widget('WidgetClassName', [
* // configure additional widget properties here
* ]) ?>
* ```
*
* @author Alexander Kochetov <creocoder@gmail.com>
* @since 2.0
*/
class InputWidget extends Widget
{
/**
* @var Model the data model that this widget is associated with.
*/
public $model;
/**
* @var string the model attribute that this widget is associated with.
*/
public $attribute;
/**
* @var string the input name. This must be set if [[model]] and [[attribute]] are not set.
*/
public $name;
/**
* @var string the input value.
*/
public $value;
/**
* Initializes the widget.
* If you override this method, make sure you call the parent implementation first.
*/
public function init()
{
if ($this->hasModel() && !isset($this->options['id'])) {
$this->options['id'] = Html::getInputId($this->model, $this->attribute);
}
parent::init();
}
/**
* @return bool whether this widget is associated with a data model.
*/
protected function hasModel()
{
return $this->model instanceof Model && $this->attribute !== null;
}
}

28
vendor/yiisoft/yii2-jui/JuiAsset.php vendored Normal file
View File

@@ -0,0 +1,28 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class JuiAsset extends AssetBundle
{
public $sourcePath = '@bower/jquery-ui';
public $js = [
'jquery-ui.js',
];
public $css = [
'themes/smoothness/jquery-ui.css',
];
public $depends = [
'yii\web\JqueryAsset',
];
}

32
vendor/yiisoft/yii2-jui/LICENSE.md vendored Normal file
View File

@@ -0,0 +1,32 @@
The Yii framework is free software. It is released under the terms of
the following BSD License.
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Yii Software LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

26
vendor/yiisoft/yii2-jui/Makefile vendored Normal file
View File

@@ -0,0 +1,26 @@
# default versions to test against
# these can be overridden by setting the environment variables in the shell
PHP_VERSION=php-5.6.8
YII_VERSION=dev-master
# ensure all the configuration variables above are in environment of the shell commands below
export
help:
@echo "make test - run phpunit tests using a docker environment"
# @echo "make clean - stop docker and remove container"
test: docker-php
composer require "yiisoft/yii2:${YII_VERSION}" --prefer-dist
composer install --prefer-dist
docker run --rm=true -v $(shell pwd):/opt/test yiitest/php:${PHP_VERSION} phpunit --verbose --color
docker-php: dockerfiles
cd tests/docker/php && sh build.sh
dockerfiles:
test -d tests/docker || git clone https://github.com/cebe/jenkins-test-docker tests/docker
cd tests/docker && git checkout -- . && git pull
mkdir -p tests/dockerids

74
vendor/yiisoft/yii2-jui/Menu.php vendored Normal file
View File

@@ -0,0 +1,74 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use yii\helpers\Json;
/**
* Menu renders a menu jQuery UI widget.
*
* @see http://api.jqueryui.com/menu/
* @author Alexander Kochetov <creocoder@gmail.com>
* @since 2.0
*/
class Menu extends \yii\widgets\Menu
{
/**
* @var array the options for the underlying jQuery UI widget.
* Please refer to the corresponding jQuery UI widget Web page for possible options.
* For example, [this page](http://api.jqueryui.com/accordion/) shows
* how to use the "Accordion" widget and the supported options (e.g. "header").
*/
public $clientOptions = [];
/**
* @var array the event handlers for the underlying jQuery UI widget.
* Please refer to the corresponding jQuery UI widget Web page for possible events.
* For example, [this page](http://api.jqueryui.com/accordion/) shows
* how to use the "Accordion" widget and the supported events (e.g. "create").
*/
public $clientEvents = [];
/**
* Initializes the widget.
* If you override this method, make sure you call the parent implementation first.
*/
public function init()
{
parent::init();
if (!isset($this->options['id'])) {
$this->options['id'] = $this->getId();
}
}
/**
* Renders the widget.
*/
public function run()
{
parent::run();
$view = $this->getView();
JuiAsset::register($view);
$id = $this->options['id'];
if ($this->clientOptions !== false) {
$options = empty($this->clientOptions) ? '' : Json::htmlEncode($this->clientOptions);
$js = "jQuery('#$id').menu($options);";
$view->registerJs($js);
}
if (!empty($this->clientEvents)) {
$js = [];
foreach ($this->clientEvents as $event => $handler) {
$js[] = "jQuery('#$id').on('menu$event', $handler);";
}
$view->registerJs(implode("\n", $js));
}
}
}

60
vendor/yiisoft/yii2-jui/ProgressBar.php vendored Normal file
View File

@@ -0,0 +1,60 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use yii\helpers\Html;
/**
* ProgressBar renders an progressbar jQuery UI widget.
*
* For example:
*
* ```php
* echo ProgressBar::widget([
* 'clientOptions' => [
* 'value' => 75,
* ],
* ]);
* ```
*
* The following example will show the content enclosed between the [[begin()]]
* and [[end()]] calls within the widget container:
*
* ~~~php
* ProgressBar::begin([
* 'clientOptions' => ['value' => 75],
* ]);
*
* echo '<div class="progress-label">Loading...</div>';
*
* ProgressBar::end();
* ~~~
* @see http://api.jqueryui.com/progressbar/
* @author Alexander Kochetov <creocoder@gmail.com>
* @since 2.0
*/
class ProgressBar extends Widget
{
/**
* Initializes the widget.
*/
public function init()
{
parent::init();
echo Html::beginTag('div', $this->options) . "\n";
}
/**
* Renders the widget.
*/
public function run()
{
echo Html::endTag('div') . "\n";
$this->registerWidget('progressbar');
}
}

60
vendor/yiisoft/yii2-jui/README.md vendored Normal file
View File

@@ -0,0 +1,60 @@
<p align="center">
<a href="http://jqueryui.com/" target="_blank" rel="external">
<img src="https://brand.jquery.org/resources/jqueryui-mark-dark.gif" height="110px">
</a>
<h1 align="center">JUI Extension for Yii 2</h1>
<br>
</p>
This is the JQuery UI extension for [Yii framework 2.0](http://www.yiiframework.com). It encapsulates [JQuery UI widgets](http://jqueryui.com/) as Yii widgets,
and makes using JQuery UI widgets in Yii applications extremely easy.
For license information check the [LICENSE](LICENSE.md)-file.
Documentation is at [docs/guide/README.md](docs/guide/README.md).
[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-jui/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-jui)
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-jui/downloads.png)](https://packagist.org/packages/yiisoft/yii2-jui)
[![Build Status](https://travis-ci.org/yiisoft/yii2-jui.svg?branch=master)](https://travis-ci.org/yiisoft/yii2-jui)
Installation
------------
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require --prefer-dist yiisoft/yii2-jui
```
or add
```
"yiisoft/yii2-jui": "~2.0.0"
```
to the require section of your `composer.json` file.
Usage
-----
The following
single line of code in a view file would render a [JQuery UI DatePicker](http://api.jqueryui.com/datepicker/) widget:
```php
<?= yii\jui\DatePicker::widget(['name' => 'attributeName']) ?>
```
Configuring the Jquery UI options should be done using the clientOptions attribute:
```php
<?= yii\jui\DatePicker::widget(['name' => 'attributeName', 'clientOptions' => ['defaultDate' => '2014-01-01']]) ?>
```
If you want to use the JUI widget in an ActiveForm, it can be done like this:
```php
<?= $form->field($model,'attributeName')->widget(DatePicker::className(),['clientOptions' => ['defaultDate' => '2014-01-01']]) ?>
```

63
vendor/yiisoft/yii2-jui/Resizable.php vendored Normal file
View File

@@ -0,0 +1,63 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use yii\helpers\Html;
/**
* Resizable renders an resizable jQuery UI widget.
*
* For example:
*
* ```php
* Resizable::begin([
* 'clientOptions' => [
* 'grid' => [20, 10],
* ],
* ]);
*
* echo 'Resizable contents here...';
*
* Resizable::end();
* ```
*
* @see http://api.jqueryui.com/resizable/
* @author Alexander Kochetov <creocoder@gmail.com>
* @since 2.0
*/
class Resizable extends Widget
{
/**
* @inheritdoc
*/
protected $clientEventMap = [
'create' => 'resizecreate',
'resize' => 'resize',
'start' => 'resizestart',
'stop' => 'resizestop',
];
/**
* Initializes the widget.
*/
public function init()
{
parent::init();
echo Html::beginTag('div', $this->options) . "\n";
}
/**
* Renders the widget.
*/
public function run()
{
echo Html::endTag('div') . "\n";
$this->registerWidget('resizable');
}
}

186
vendor/yiisoft/yii2-jui/Selectable.php vendored Normal file
View File

@@ -0,0 +1,186 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use yii\base\InvalidConfigException;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
/**
* Selectable renders a selectable jQuery UI widget.
*
* For example:
*
* ```php
* echo Selectable::widget([
* 'items' => [
* 'Item 1',
* [
* 'content' => 'Item2',
* ],
* [
* 'content' => 'Item3',
* 'options' => [
* 'tag' => 'li',
* ],
* ],
* ],
* 'options' => [
* 'tag' => 'ul',
* ],
* 'itemOptions' => [
* 'tag' => 'li',
* ],
* 'clientOptions' => [
* 'tolerance' => 'fit',
* ],
* ]);
* ```
*
* Selectable in begin mode.
*
* ```php
* Selectable::begin([
* 'clientOptions' => [
* 'filter' => 'my-selectable-item',
* 'tolerance' => 'touch',
* ],
* ]);
* ```
* <ul>
* <li class="my-selectable-item">Item 1</li>
* <li class="my-selectable-item">Item 2</li>
* <li class="no-selectable-item">Item 3</li>
* <li class="my-selectable-item">Item 4</li>
* </ul>
* <div>
* <div>
* <div class="my-selectable-item">Another item</div>
* </div>
* </div>
*
* ```php
* Selectable::end();
* ```
*
* @see http://api.jqueryui.com/selectable/
* @author Alexander Kochetov <creocoder@gmail.com>
* @since 2.0
*/
class Selectable extends Widget
{
const MODE_DEFAULT = 'MODE_DEFAULT';
const MODE_BEGIN = 'MODE_BEGIN';
/**
* @var string the mode used to render the widget.
*/
public $mode = self::MODE_DEFAULT;
/**
* @var array the HTML attributes for the widget container tag. The following special options are recognized:
*
* - tag: string, defaults to "ul", the tag name of the container tag of this widget.
*
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $options = [];
/**
* @var array list of selectable items. Each item can be a string representing the item content
* or an array of the following structure:
*
* ~~~
* [
* 'content' => 'item content',
* // the HTML attributes of the item container tag. This will overwrite "itemOptions".
* 'options' => [],
* ]
* ~~~
*/
public $items = [];
/**
* @var array list of HTML attributes for the item container tags. This will be overwritten
* by the "options" set in individual [[items]]. The following special options are recognized:
*
* - tag: string, defaults to "li", the tag name of the item container tags.
*
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $itemOptions = [];
/**
* Begins a widget.
* This method creates an instance of the calling class setting the MODE_BEGIN mode. Any item between
* [[begin()]] and [[end()]] which match the filter attribute, will be selectable.
* It will apply the configuration
* to the created instance. A matching [[end()]] call should be called later.
* As some widgets may use output buffering, the [[end()]] call should be made in the same view
* to avoid breaking the nesting of output buffers.
* @param array $config name-value pairs that will be used to initialize the object properties
* @return static the newly created widget instance
* @see end()
*/
public static function begin($config = []) {
$config['mode'] = self::MODE_BEGIN;
parent::begin($config);
}
/**
* Initializes the widget.
*/
public function init()
{
parent::init();
if ($this->mode === self::MODE_BEGIN) {
echo Html::beginTag('div', $this->options) . "\n";
}
}
/**
* Renders the widget.
*/
public function run()
{
if ($this->mode === self::MODE_BEGIN) {
echo Html::endTag('div') . "\n";
} else {
$options = $this->options;
$tag = ArrayHelper::remove($options, 'tag', 'ul');
echo Html::beginTag($tag, $options) . "\n";
echo $this->renderItems() . "\n";
echo Html::endTag($tag) . "\n";
}
$this->registerWidget('selectable');
}
/**
* Renders selectable items as specified on [[items]].
* @return string the rendering result.
* @throws InvalidConfigException.
*/
public function renderItems()
{
$items = [];
foreach ($this->items as $item) {
$options = $this->itemOptions;
$tag = ArrayHelper::remove($options, 'tag', 'li');
if (is_array($item)) {
if (!array_key_exists('content', $item)) {
throw new InvalidConfigException("The 'content' option is required.");
}
$options = array_merge($options, ArrayHelper::getValue($item, 'options', []));
$tag = ArrayHelper::remove($options, 'tag', $tag);
$items[] = Html::tag($tag, $item['content'], $options);
} else {
$items[] = Html::tag($tag, $item, $options);
}
}
return implode("\n", $items);
}
}

50
vendor/yiisoft/yii2-jui/Slider.php vendored Normal file
View File

@@ -0,0 +1,50 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use yii\helpers\Html;
/**
* Slider renders a slider jQuery UI widget.
*
* ```php
* echo Slider::widget([
* 'clientOptions' => [
* 'min' => 1,
* 'max' => 10,
* ],
* ]);
* ```
*
* @see http://api.jqueryui.com/slider/
* @author Alexander Makarov <sam@rmcreative.ru>
* @since 2.0
*/
class Slider extends Widget
{
/**
* @inheritDoc
*/
protected $clientEventMap = [
'change' => 'slidechange',
'create' => 'slidecreate',
'slide' => 'slide',
'start' => 'slidestart',
'stop' => 'slidestop',
];
/**
* Executes the widget.
*/
public function run()
{
echo Html::tag('div', '', $this->options);
$this->registerWidget('slider');
}
}

110
vendor/yiisoft/yii2-jui/SliderInput.php vendored Normal file
View File

@@ -0,0 +1,110 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use yii\helpers\Html;
/**
* SliderInput renders a slider jQuery UI widget that writes its value into hidden input.
*
* For example,
*
* ```
* echo SliderInput::widget([
* 'model' => $model,
* 'attribute' => 'amount',
* 'clientOptions' => [
* 'min' => 1,
* 'max' => 10,
* ],
* ]);
* ```
*
* The following example will use the name property instead:
*
* ```
* echo SliderInput::widget([
* 'name' => 'amount',
* 'clientOptions' => [
* 'min' => 1,
* 'max' => 10,
* ],
* ]);
* ```
*
* You can also use this widget in an [[yii\widgets\ActiveForm|ActiveForm]] using the [[yii\widgets\ActiveField::widget()|widget()]]
* method, for example like this:
*
* ```php
* <?= $form->field($model, 'from_date')->widget(\yii\jui\SliderInput::classname(), [
* 'clientOptions' => [
* 'min' => 1,
* 'max' => 10,
* ],
* ]) ?>
* ```
*
* @see http://api.jqueryui.com/slider/
* @author Alexander Makarov <sam@rmcreative.ru>
* @since 2.0
*/
class SliderInput extends InputWidget
{
/**
* @var array the HTML attributes for the container tag.
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $containerOptions = [];
/**
* @inheritDoc
*/
protected $clientEventMap = [
'change' => 'slidechange',
'create' => 'slidecreate',
'slide' => 'slide',
'start' => 'slidestart',
'stop' => 'slidestop',
];
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (!isset($this->containerOptions['id'])) {
$this->containerOptions['id'] = $this->options['id'] . '-container';
}
}
/**
* Executes the widget.
*/
public function run()
{
echo Html::tag('div', '', $this->containerOptions);
if ($this->hasModel()) {
echo Html::activeHiddenInput($this->model, $this->attribute, $this->options);
$this->clientOptions['value'] = Html::getAttributeValue($this->model, $this->attribute);
} else {
echo Html::hiddenInput($this->name, $this->value, $this->options);
$this->clientOptions['value'] = $this->value;
}
if (!isset($this->clientEvents['slide'])) {
$this->clientEvents['slide'] = 'function (event, ui) {
jQuery("#' . $this->options['id'] . '").val(ui.value);
}';
}
$this->registerWidget('slider', $this->containerOptions['id']);
}
}

130
vendor/yiisoft/yii2-jui/Sortable.php vendored Normal file
View File

@@ -0,0 +1,130 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use yii\base\InvalidConfigException;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
/**
* Sortable renders a sortable jQuery UI widget.
*
* For example:
*
* ```php
* echo Sortable::widget([
* 'items' => [
* 'Item 1',
* ['content' => 'Item2'],
* [
* 'content' => 'Item3',
* 'options' => ['tag' => 'li'],
* ],
* ],
* 'options' => ['tag' => 'ul'],
* 'itemOptions' => ['tag' => 'li'],
* 'clientOptions' => ['cursor' => 'move'],
* ]);
* ```
*
* @see http://api.jqueryui.com/sortable/
* @author Alexander Kochetov <creocoder@gmail.com>
* @since 2.0
*/
class Sortable extends Widget
{
/**
* @var array the HTML attributes for the widget container tag. The following special options are recognized:
*
* - tag: string, defaults to "ul", the tag name of the container tag of this widget.
*
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $options = [];
/**
* @var array list of sortable items. Each item can be a string representing the item content
* or an array of the following structure:
*
* ~~~
* [
* 'content' => 'item content',
* // the HTML attributes of the item container tag. This will overwrite "itemOptions".
* 'options' => [],
* ]
* ~~~
*/
public $items = [];
/**
* @var array list of HTML attributes for the item container tags. This will be overwritten
* by the "options" set in individual [[items]]. The following special options are recognized:
*
* - tag: string, defaults to "li", the tag name of the item container tags.
*
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $itemOptions = [];
/**
* @inheritDoc
*/
protected $clientEventMap = [
'activate' => 'sortactivate',
'beforeStop' => 'sortbeforestop',
'change' => 'sortchange',
'create' => 'sortcreate',
'deactivate' => 'sortdeactivate',
'out' => 'sortout',
'over' => 'sortover',
'receive' => 'sortreceive',
'remove' => 'sortremove',
'sort' => 'sort',
'start' => 'sortstart',
'stop' => 'sortstop',
'update' => 'sortupdate',
];
/**
* Renders the widget.
*/
public function run()
{
$options = $this->options;
$tag = ArrayHelper::remove($options, 'tag', 'ul');
echo Html::beginTag($tag, $options) . "\n";
echo $this->renderItems() . "\n";
echo Html::endTag($tag) . "\n";
$this->registerWidget('sortable');
}
/**
* Renders sortable items as specified on [[items]].
* @return string the rendering result.
* @throws InvalidConfigException.
*/
public function renderItems()
{
$items = [];
foreach ($this->items as $item) {
$options = $this->itemOptions;
$tag = ArrayHelper::remove($options, 'tag', 'li');
if (is_array($item)) {
if (!isset($item['content'])) {
throw new InvalidConfigException("The 'content' option is required.");
}
$options = array_merge($options, ArrayHelper::getValue($item, 'options', []));
$tag = ArrayHelper::remove($options, 'tag', $tag);
$items[] = Html::tag($tag, $item['content'], $options);
} else {
$items[] = Html::tag($tag, $item, $options);
}
}
return implode("\n", $items);
}
}

82
vendor/yiisoft/yii2-jui/Spinner.php vendored Normal file
View File

@@ -0,0 +1,82 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use yii\helpers\Html;
/**
* Spinner renders an spinner jQuery UI widget.
*
* For example:
*
* ```php
* echo Spinner::widget([
* 'model' => $model,
* 'attribute' => 'country',
* 'clientOptions' => ['step' => 2],
* ]);
* ```
*
* The following example will use the name property instead:
*
* ```php
* echo Spinner::widget([
* 'name' => 'country',
* 'clientOptions' => ['step' => 2],
* ]);
* ```
*
* You can also use this widget in an [[yii\widgets\ActiveForm|ActiveForm]] using the [[yii\widgets\ActiveField::widget()|widget()]]
* method, for example like this:
*
* ```php
* <?= $form->field($model, 'from_date')->widget(\yii\jui\Spinner::classname(), [
* 'clientOptions' => ['step' => 2],
* ]) ?>
* ```
*
* @see http://api.jqueryui.com/spinner/
* @author Alexander Kochetov <creocoder@gmail.com>
* @since 2.0
*/
class Spinner extends InputWidget
{
/**
* @inheritDoc
*/
protected $clientEventMap = [
'spin' => 'spin',
'change' => 'spinchange',
'create' => 'spincreate',
'start' => 'spinstart',
'stop' => 'spinstop'
];
/**
* Renders the widget.
*/
public function run()
{
echo $this->renderWidget();
$this->registerWidget('spinner');
}
/**
* Renders the Spinner widget.
* @return string the rendering result.
*/
public function renderWidget()
{
if ($this->hasModel()) {
return Html::activeTextInput($this->model, $this->attribute, $this->options);
} else {
return Html::textInput($this->name, $this->value, $this->options);
}
}
}

155
vendor/yiisoft/yii2-jui/Tabs.php vendored Normal file
View File

@@ -0,0 +1,155 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use yii\base\InvalidConfigException;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
use yii\helpers\Html;
/**
* Tabs renders a tabs jQuery UI widget.
*
* For example:
*
* ```php
* echo Tabs::widget([
* 'items' => [
* [
* 'label' => 'Tab one',
* 'content' => 'Mauris mauris ante, blandit et, ultrices a, suscipit eget...',
* ],
* [
* 'label' => 'Tab two',
* 'content' => 'Sed non urna. Phasellus eu ligula. Vestibulum sit amet purus...',
* 'options' => ['tag' => 'div'],
* 'headerOptions' => ['class' => 'my-class'],
* ],
* [
* 'label' => 'Tab with custom id',
* 'content' => 'Morbi tincidunt, dui sit amet facilisis feugiat...',
* 'options' => ['id' => 'my-tab'],
* ],
* [
* 'label' => 'Ajax tab',
* 'url' => ['ajax/content'],
* ],
* ],
* 'options' => ['tag' => 'div'],
* 'itemOptions' => ['tag' => 'div'],
* 'headerOptions' => ['class' => 'my-class'],
* 'clientOptions' => ['collapsible' => false],
* ]);
* ```
*
* @see http://api.jqueryui.com/tabs/
* @author Alexander Kochetov <creocoder@gmail.com>
* @since 2.0
*/
class Tabs extends Widget
{
/**
* @var array the HTML attributes for the widget container tag. The following special options are recognized:
*
* - tag: string, defaults to "div", the tag name of the container tag of this widget.
*
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $options = [];
/**
* @var array list of tab items. Each item can be an array of the following structure:
*
* - label: string, required, specifies the header link label. When [[encodeLabels]] is true, the label
* will be HTML-encoded.
* - content: string, the content to show when corresponding tab is clicked. Can be omitted if url is specified.
* - url: mixed, mixed, optional, the url to load tab contents via AJAX. It is required if no content is specified.
* - template: string, optional, the header link template to render the header link. If none specified
* [[linkTemplate]] will be used instead.
* - options: array, optional, the HTML attributes of the header.
* - headerOptions: array, optional, the HTML attributes for the header container tag.
*/
public $items = [];
/**
* @var array list of HTML attributes for the item container tags. This will be overwritten
* by the "options" set in individual [[items]]. The following special options are recognized:
*
* - tag: string, defaults to "div", the tag name of the item container tags.
*
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $itemOptions = [];
/**
* @var array list of HTML attributes for the header container tags. This will be overwritten
* by the "headerOptions" set in individual [[items]].
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $headerOptions = [];
/**
* @var string the default header template to render the link.
*/
public $linkTemplate = '<a href="{url}">{label}</a>';
/**
* @var boolean whether the labels for header items should be HTML-encoded.
*/
public $encodeLabels = true;
/**
* Renders the widget.
*/
public function run()
{
$options = $this->options;
$tag = ArrayHelper::remove($options, 'tag', 'div');
$out = Html::beginTag($tag, $options) . "\n";
$out .= $this->renderItems() . "\n";
$out .= Html::endTag($tag) . "\n";
$this->registerWidget('tabs');
return $out;
}
/**
* Renders tab items as specified on [[items]].
* @return string the rendering result.
* @throws InvalidConfigException.
*/
protected function renderItems()
{
$headers = [];
$items = [];
foreach ($this->items as $n => $item) {
if (!isset($item['label'])) {
throw new InvalidConfigException("The 'label' option is required.");
}
if (isset($item['url'])) {
$url = Url::to($item['url']);
} else {
if (!array_key_exists('content', $item)) {
throw new InvalidConfigException("Either the 'content' or 'url' option is required.");
}
$options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', []));
$tag = ArrayHelper::remove($options, 'tag', 'div');
if (!isset($options['id'])) {
$options['id'] = $this->options['id'] . '-tab' . $n;
}
$url = '#' . $options['id'];
$items[] = Html::tag($tag, $item['content'], $options);
}
$headerOptions = array_merge($this->headerOptions, ArrayHelper::getValue($item, 'headerOptions', []));
$template = ArrayHelper::getValue($item, 'template', $this->linkTemplate);
$headers[] = Html::tag('li', strtr($template, [
'{label}' => $this->encodeLabels ? Html::encode($item['label']) : $item['label'],
'{url}' => $url,
]), $headerOptions);
}
return Html::tag('ul', implode("\n", $headers)) . "\n" . implode("\n", $items);
}
}

118
vendor/yiisoft/yii2-jui/Widget.php vendored Normal file
View File

@@ -0,0 +1,118 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use yii\helpers\Json;
/**
* \yii\jui\Widget is the base class for all jQuery UI widgets.
*
* @author Alexander Kochetov <creocoder@gmail.com>
* @since 2.0
*/
class Widget extends \yii\base\Widget
{
/**
* @var array the HTML attributes for the widget container tag.
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $options = [];
/**
* @var array the options for the underlying jQuery UI widget.
* Please refer to the corresponding jQuery UI widget Web page for possible options.
* For example, [this page](http://api.jqueryui.com/accordion/) shows
* how to use the "Accordion" widget and the supported options (e.g. "header").
*/
public $clientOptions = [];
/**
* @var array the event handlers for the underlying jQuery UI widget.
* Please refer to the corresponding jQuery UI widget Web page for possible events.
* For example, [this page](http://api.jqueryui.com/accordion/) shows
* how to use the "Accordion" widget and the supported events (e.g. "create").
* Keys are the event names and values are javascript code that is passed to the `.on()` function
* as the event handler.
*
* For example you could write the following in your widget configuration:
*
* ```php
* 'clientEvents' => [
* 'change' => 'function () { alert('event "change" occured.'); }'
* ],
* ```
*/
public $clientEvents = [];
/**
* @var array event names mapped to what should be specified in `.on()`.
* If empty, it is assumed that event passed to clientEvents is prefixed with widget name.
*/
protected $clientEventMap = [];
/**
* Initializes the widget.
* If you override this method, make sure you call the parent implementation first.
*/
public function init()
{
parent::init();
if (!isset($this->options['id'])) {
$this->options['id'] = $this->getId();
}
}
/**
* Registers a specific jQuery UI widget options
* @param string $name the name of the jQuery UI widget
* @param string $id the ID of the widget
*/
protected function registerClientOptions($name, $id)
{
if ($this->clientOptions !== false) {
$options = empty($this->clientOptions) ? '' : Json::htmlEncode($this->clientOptions);
$js = "jQuery('#$id').$name($options);";
$this->getView()->registerJs($js);
}
}
/**
* Registers a specific jQuery UI widget events
* @param string $name the name of the jQuery UI widget
* @param string $id the ID of the widget
*/
protected function registerClientEvents($name, $id)
{
if (!empty($this->clientEvents)) {
$js = [];
foreach ($this->clientEvents as $event => $handler) {
if (isset($this->clientEventMap[$event])) {
$eventName = $this->clientEventMap[$event];
} else {
$eventName = strtolower($name . $event);
}
$js[] = "jQuery('#$id').on('$eventName', $handler);";
}
$this->getView()->registerJs(implode("\n", $js));
}
}
/**
* Registers a specific jQuery UI widget asset bundle, initializes it with client options and registers related events
* @param string $name the name of the jQuery UI widget
* @param string $id the ID of the widget. If null, it will use the `id` value of [[options]].
*/
protected function registerWidget($name, $id = null)
{
if ($id === null) {
$id = $this->options['id'];
}
JuiAsset::register($this->getView());
$this->registerClientEvents($name, $id);
$this->registerClientOptions($name, $id);
}
}

40
vendor/yiisoft/yii2-jui/composer.json vendored Normal file
View File

@@ -0,0 +1,40 @@
{
"name": "yiisoft/yii2-jui",
"description": "The Jquery UI extension for the Yii framework",
"keywords": ["yii2", "Jquery UI"],
"type": "yii2-extension",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2-jui/issues",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2-jui"
},
"authors": [
{
"name": "Qiang Xue",
"email": "qiang.xue@gmail.com"
}
],
"require": {
"yiisoft/yii2": "~2.0.4",
"bower-asset/jquery-ui": "~1.12.1"
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
],
"autoload": {
"psr-4": {
"yii\\jui\\": ""
}
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
}
}