<commit_before><?php
/**
 * @link http://www.yii-ui.com/
 * @copyright Copyright (c) <NAME>, Yii UI, 2016
 * @license http://www.yii-ui.com/license/
 */

namespace yiiui\rubaxasortable;

use yii\base\InvalidConfigException;
use yii\base\Widget;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Json;

/**
 * Create reorderable drag-and-drop lists for modern browsers and touch devices.
 *
 * For example:
 *
 * ```php
 * echo Sortable::widget([
 *     'items' => [
 *         'Item 1',
 *         ['content' => 'Item2'],
 *         [
 *             'content' => 'Item3',
 *             'options' => ['class' => 'text-danger'],
 *         ],
 *     ],
 *     'containerOptions' => ['class' => 'list-group'],
 *     'itemOptions' => ['class' => 'list-group-item'],
 *     'clientOptions' => ['animation' => 0],
 * ]);
 * ```
 *
 * @see https://github.com/RubaXa/Sortable
 * @author <NAME> <<EMAIL>>
 * @since 1.0.0
 */
class Sortable extends Widget
{
    /**
     * @var string the tag name for the container element.
     */
    public $containerElement = 'ul';

    /**
     * @var array the HTML attributes for the container tag.
     * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
     */
    public $containerOptions = [];

    /**
     * @var string the tag name for the item element. This will be overwritten
     * by the "element" set in individual [[items]].
     */
    public $itemElement = 'li';

    /**
     * @var array the HTML attributes for the item tag. This will be overwritten
     * by the "options" set in individual [[items]].
     *
     * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
     */
    public $itemOptions = [];

    /**
     * @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 tag. This will overwrite "itemOptions".
     *     'options' => [],
     *     // the tag name for the item element. This will overwrite "itemElement".
     *     'element' => 'li',
     *     // add handle to the item. This will overwrite "addHandle".
     *     'addHandle' => true,
     *     // the handle label. This will overwrite "handleLabel".
     *     'handleLabel' => '::',
     *     // the tag name for the handle element. This will overwrite "handleElement".
     *     'handleElement' => 'span',
     *     // the HTML attributes for the handle tag. This will overwrite "handleOptions".
     *     'handleOptions' => []
     * ]
     * ~~~
     */
    public $items = [];

    /**
     * @var string the handle label, this is not HTML encoded. This will be overwritten
     * by the "handleLabel" set in individual [[items]].
     */
    public $handleLabel = '::';

    /**
     * @var bool add handle to each item. This will be overwritten
     * by the "addHandle" set in individual [[items]].
     */
    public $addHandle = false;

    /**
     * @var string the tag name for the handle element. This will be overwritten
     * by the "handleElement" set in individual [[items]].
     */
    public $handleElement = 'span';

    /**
     * @var array the HTML attributes for the handle tag.
     * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
     */
    public $handleOptions = [];

    /**
     * @var array the options for the underlying RubaXa Sortable widget.
     * Please refer to the RubaXa Sortable Documentation for possible options.
     * @see https://github.com/RubaXa/Sortable#options
     */
    public $clientOptions = [];

    /**
     * @var array the event handlers for the underlying sortable widget.
     *
     * For example you could write the following in your widget configuration:
     *
     * ```php
     * 'clientEvents' => [
     *     'move' => 'function () { alert("element has been moved"); }'
     * ],
     * ```
     * @see https://github.com/RubaXa/Sortable#options
     */
    public $clientEvents = [];

    /**
     * @var array List of available events
     * @see https://github.com/RubaXa/Sortable#options
     */
    private $_availableClientEvents = ['choose', 'start', 'end', 'add', 'update', 'sort', 'remove', 'filter', 'move', 'clone'];

    /***
     * @inheritDoc
     */
    public function run()
    {
        $id = $this->containerOptions['id'];

        $this->initClientOptions();

        echo Html::beginTag($this->containerElement, $this->containerOptions);
        echo $this->renderItems();<commit_msg>Autogenerate id when no id has been passed<commit_after><?php
/**
 * @link http://www.yii-ui.com/
 * @copyright Copyright (c) <NAME>, Yii UI, 2016
 * @license http://www.yii-ui.com/license/
 */

namespace yiiui\rubaxasortable;

use yii\base\InvalidConfigException;
use yii\base\Widget;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Json;

/**
 * Create reorderable drag-and-drop lists for modern browsers and touch devices.
 *
 * For example:
 *
 * ```php
 * echo Sortable::widget([
 *     'items' => [
 *         'Item 1',
 *         ['content' => 'Item2'],
 *         [
 *             'content' => 'Item3',
 *             'options' => ['class' => 'text-danger'],
 *         ],
 *     ],
 *     'containerOptions' => ['class' => 'list-group'],
 *     'itemOptions' => ['class' => 'list-group-item'],
 *     'clientOptions' => ['animation' => 0],
 * ]);
 * ```
 *
 * @see https://github.com/RubaXa/Sortable
 * @author <NAME> <<EMAIL>>
 * @since 1.0.0
 */
class Sortable extends Widget
{
    /***
     * @inheritDoc
     */
    public static $autoIdPrefix = 'YIIUIRS';

    /**
     * @var string the tag name for the container element.
     */
    public $containerElement = 'ul';

    /**
     * @var array the HTML attributes for the container tag.
     * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
     */
    public $containerOptions = [];

    /**
     * @var string the tag name for the item element. This will be overwritten
     * by the "element" set in individual [[items]].
     */
    public $itemElement = 'li';

    /**
     * @var array the HTML attributes for the item tag. This will be overwritten
     * by the "options" set in individual [[items]].
     *
     * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
     */
    public $itemOptions = [];

    /**
     * @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 tag. This will overwrite "itemOptions".
     *     'options' => [],
     *     // the tag name for the item element. This will overwrite "itemElement".
     *     'element' => 'li',
     *     // add handle to the item. This will overwrite "addHandle".
     *     'addHandle' => true,
     *     // the handle label. This will overwrite "handleLabel".
     *     'handleLabel' => '::',
     *     // the tag name for the handle element. This will overwrite "handleElement".
     *     'handleElement' => 'span',
     *     // the HTML attributes for the handle tag. This will overwrite "handleOptions".
     *     'handleOptions' => []
     * ]
     * ~~~
     */
    public $items = [];

    /**
     * @var string the handle label, this is not HTML encoded. This will be overwritten
     * by the "handleLabel" set in individual [[items]].
     */
    public $handleLabel = '::';

    /**
     * @var bool add handle to each item. This will be overwritten
     * by the "addHandle" set in individual [[items]].
     */
    public $addHandle = false;

    /**
     * @var string the tag name for the handle element. This will be overwritten
     * by the "handleElement" set in individual [[items]].
     */
    public $handleElement = 'span';

    /**
     * @var array the HTML attributes for the handle tag.
     * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
     */
    public $handleOptions = [];

    /**
     * @var array the options for the underlying RubaXa Sortable widget.
     * Please refer to the RubaXa Sortable Documentation for possible options.
     * @see https://github.com/RubaXa/Sortable#options
     */
    public $clientOptions = [];

    /**
     * @var array the event handlers for the underlying sortable widget.
     *
     * For example you could write the following in your widget configuration:
     *
     * ```php
     * 'clientEvents' => [
     *     'move' => 'function () { alert("element has been moved"); }'
     * ],
     * ```
     * @see https://github.com/RubaXa/Sortable#options
     */
    public $clientEvents = [];

    /**
     * @var array List of available events
     * @see https://github.com/RubaXa/Sortable#options
     */
    private $_availableClientEvents = ['choose', 'start', 'end', 'add', 'update', 'sort', 'remove', 'filter', 'move', 'clone'];

    /***
     * @inheritDoc
     */
    public function run()
    {
        if (empty($this->containerOptions['id'])) {
            $this->containerOptions['id'] = $this->getId();
        }

        $id = $this->containerOptions['id'];

        $this->initClientOptions();

        echo Html::beginTag($this->containerElement, $this->containerOptions);
        echo $this->renderItems();
{'fraction_non_alphanumeric': 0.14608150470219436, 'fraction_numerical': 0.0022988505747126436, 'mean_word_length': 2.3406631762652705, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 64, 'https://': 8, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4171409', 'n_tokens_mistral': 2827, 'n_tokens_neox': 2785, 'n_words': 877}