public function init() { parent::init(); if (!isset($this->deleteButtonOptions)) { $this->deleteButtonOptions = ['class' => 'delete-button pull-right glyphicon glyphicon-trash', 'title' => Yii::t('yii', 'Delete'), 'aria-label' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'), 'data-method' => 'post', 'data-pjax' => '0']; } }
public function registerAssets() { Sortable::widget(); $models = \skeeks\cms\models\Tree::find()->where(["id" => $this->_getSelectedIds()])->all(); $options = Json::encode(['selected' => $models]); Asset::register($this->getView()); $this->getView()->registerJs(<<<JS (function(window, sx, \$, _) { sx.createNamespace('classes', sx); sx.classes.Tree = sx.classes.Component.extend({ _init: function() { var self = this; if (sx.Window.openerWidget()) { this._parentWidget = sx.Window.openerWidget(); } }, _onDomReady: function() { \$(".sx-tree ul").find("ul").sortable( { out: function( event, ui ) { var Jul = \$(ui.item).closest("ul"); var newSort = []; Jul.children("li").each(function(i, element) { newSort.push(\$(this).data("id")); }); var blocker = sx.block(Jul); var ajax = sx.ajax.preparePostQuery( "resort", { "ids" : newSort, "changeId" : \$(ui.item).data("id") } ); new sx.classes.AjaxHandlerNoLoader(ajax); //отключение глобального загрузчика new sx.classes.AjaxHandlerNotify(ajax, { 'error': "Изменения не сохранились", 'success': "Изменения сохранены", }); //отключение глобального загрузчика ajax.onError(function(e, data) { sx.notify.info("Подождите сейчас страница будет перезагружена"); _.delay(function() { window.location.reload(); }, 2000); }) .onSuccess(function(e, data) { blocker.unblock(); }) .execute(); } }); var self = this; \$('.sx-controll-btn-select').on('click', function() { self._parentWidget.trigger('selected', { 'selected': self.get('selected') }); window.close(); return false; }); \$('.add-tree-child').on('click', function() { var jNode = \$(this); sx.prompt("Введите название нового раздела", { 'yes' : function(e, result) { var blocker = sx.block(jNode); var ajax = sx.ajax.preparePostQuery( "new-children", { "pid" : jNode.data('id'), "Tree" : {"name" : result}, "no_redirect": true } ); new sx.classes.AjaxHandlerNoLoader(ajax); //отключение глобального загрузчика new sx.classes.AjaxHandlerNotify(ajax, { 'error': "Не удалось добавить новый раздел", 'success': "Новый раздел добавлен" }); //отключение глобального загрузчика ajax.onError(function(e, data) { \$.pjax.reload('#sx-pjax-tree', {}); /*sx.notify.info("Подождите сейчас страница будет перезагружена"); _.delay(function() { window.location.reload(); }, 2000);*/ }) .onSuccess(function(e, data) { blocker.unblock(); \$.pjax.reload('#sx-pjax-tree', {}); /*sx.notify.info("Подождите сейчас страница будет перезагружена"); _.delay(function() { window.location.reload(); }, 2000);*/ }) .execute(); } }); return false; }); \$('.show-at-site').on('click', function() { window.open(\$(this).attr('href')); return false; }); }, select: function(id, link) { var selected = []; \$("input[type='checkbox']:checked").each(function() { selected.push(\$(this).val()); }); this.trigger("select", { 'selected': selected, 'select': id }); _.delay(function() { \$(".sx-tree").append(); \$("<a>", { 'href':link, 'style':'display:none;' }).append("test").appendTo(\$(".sx-tree")).click(); //window.location.href = link; }, 100); }, selectSingle: function(id) { this.trigger("selectSingle", { 'id': id }); }, setSingle: function(id) { console.log('setSingle' + id); var Jelement = \$(".sx-tree .sx-readio[value='" + id + "']"); if (!Jelement.is(":checked")) { Jelement.click(); }; }, }); sx.Tree = new sx.classes.Tree({$options}); })(window, sx, sx.\$, sx._); JS ); $this->getView()->registerCss(<<<CSS .sx-tree { margin-left: 15px; } .sx-tree ul { padding-left: 0px; } .sx-tree ul li.sx-tree-node { list-style-type: none; padding-left: 15px; margin: 2px 0px; } .sx-tree ul li .sx-tree-type { display: none; padding-top: 2px; padding-left: 20px; font-size: 11px; } .sx-tree ul li:hover>.row .sx-tree-type { display: block; } .sx-tree ul li.sx-tree-node .sx-controll-act { margin-left: 5px; } .sx-tree ul li.sx-tree-node.open {} .sx-tree ul li.sx-tree-node.active {} .sx-tree ul li.sx-tree-node .row { margin: 0 !important; } .sx-tree ul li.sx-tree-node .sx-node-open-close { float: left; width: 23px; margin-left: -23px; } .sx-tree ul li.sx-tree-node .sx-node-open-close > a { font-size: 6px; color: #000000; background: white; padding: 2px 4px; margin-top: 2px; } .btn-tree-node-controll { font-size: 8px; } .sx-tree ul li.sx-tree-node .sx-controll-node { width: 80px; float: left; margin-left: 10px; padding-top: 2px; } .sx-tree ul li.sx-tree-node .sx-controll-node > .dropdown button { font-size: 6px; color: #000000; background: white; padding: 2px 4px; } .sx-tree ul li.sx-tree-node .sx-label-node { float: left; padding-left: 23px; } .sx-tree ul li.sx-tree-node .sx-label-node > a { font-size: 12px; font-weight: bold; color: #000000; } /** * Запись неактивна **/ .sx-tree ul li.sx-tree-node .sx-label-node.status-N > a { color: silver; } CSS ); }
/* $this->widget('zii.widgets.jui.CJuiSortable', array( 'id' => 'sortcategory', 'items' => $items, 'htmlOptions' => array('style' => 'list-style:none;;margin-top:1px'), 'theme' => $this->module->juiTheme, 'options' => array( 'delay' => '100', 'update' => 'js:function(){Sort(this,"' . $this->createAbsoluteUrl('setting/ajaxSort') . '");}', ), ));*/ echo Sortable::widget(['clientEvents' => ['update' => 'function( event, ui ) { var arr = new Array(); $(".ui-sortable-handle table").each(function() { arr.push( $(this).data("id")); }); Sort(this,"' . \Yii::$app->urlManager->createAbsoluteUrl(['forum/setting/ajaxsort']) . '"); }'], 'clientOptions' => ['cursor' => 'move'], 'id' => 'sortcategory', 'itemOptions' => ['tag' => 'li'], 'items' => $items, 'options' => ['delay' => '100']]); ?> </div> </div> <?php // @depricated 2.5.0 Kept for Referance /* $this->beginWidget('zii.widgets.jui.CJuiDialog',array( 'id' => 'dlgEditForum', 'theme' => $this->module->juiTheme, 'options' => array(
/** * Executes the widget. */ public function run() { if ($this->hasModel()) { $hiddenInput = Html::activeHiddenInput($this->model, $this->attribute); $inputId = Html::getInputId($this->model, $this->attribute); } else { $hiddenInput = Html::textInput($this->name, $this->name); $inputId = $this->name; } $items = []; usort($this->items, function ($a, $b) { $aKey = array_search($a['name'], $this->_checked); $bKey = array_search($b['name'], $this->_checked); if ($aKey == $bKey) { return 0; } return $aKey > $bKey ? 1 : -1; }); Html::addCssClass($this->itemOptions, 'btn btn-xs default'); foreach ($this->items as $item) { $checkbox = Html::checkbox($item['name'], in_array($item['name'], $this->_checked)); $items[] = Html::tag('span', $checkbox . ' ' . $item['label'], $this->itemOptions); } echo Html::beginTag('div', $this->options); echo Sortable::widget(['items' => $items, 'options' => ['tag' => 'div'], 'itemOptions' => ['tag' => 'span'], 'clientOptions' => ['cursor' => 'move', 'start' => new JsExpression('function(e, ui){ ui.placeholder.height(ui.item.height()); ui.placeholder.width(ui.item.width()); }'), 'update' => new JsExpression("function(e, ui){\n var values = \$.map(\$('#{$this->options['id']} input:checkbox:checked'),\n function(item){ return \$(item).attr('name')});\n \$('#{$inputId}').val(values.join('{$this->separator}'));\n }")]]); echo $hiddenInput; echo Html::endTag('div'); $this->registerJs($inputId); }
} ?> <div class="row category"> <div class="col-md-10"> <span class="header2"><?php echo Html::encode($data->name); ?> </span> <p><?php echo Html::encode($data->subtitle); ?> </p> </div> <div class="col-md-2 pad5-top"> <?php echo Html::button(YBoard::t('yboard', 'Edit Category'), ['class' => 'btn btn-warning btn-xs', 'onclick' => 'editCategory(' . $data->id . ',"' . YBoard::t('yboard', 'Edit category') . '", "' . \Yii::$app->urlmanager->createAbsoluteUrl(Yii::$app->controller->module->id . '/setting/get-forum') . '")']); ?> </div> </div> <div class="row"> <div class="col-md-12"> <?php echo \yii\jui\Sortable::widget(['id' => 'sortfrm' . $data->id, 'items' => $forumitems, 'options' => ['style' => 'list-style:none; margin-top:1px', 'class' => 'forum-item'], 'clientOptions' => ['delay' => '100', 'update' => new JsExpression('function(){Sort(this,"' . \Yii::$app->urlmanager->createAbsoluteUrl(Yii::$app->controller->module->id . '/setting/ajax-sort') . '");}')]]); ?> </div> </div>
use yii\helpers\Html; use yii\jui\Sortable; use yii\bootstrap\ActiveForm; $this->registerCss("\n\t.jquery-sortable li {\n\t\tlist-style: none;\n\t}\n\t.jquery-sortable {\n\t\tlist-style-type: none;\n\t\tmargin: 0;\n\t\tpadding: 0;\n\t}\n\n\t.jquery-sortable li {\n\t\tmargin: 0 3px 3px 3px;\n\t\tpadding: 4px;\n\t\tpadding-left: 24px;\n\t\theight: 30px;\n\t}\n\n\t.jquery-sortable li span {\n\t\tposition: absolute;\n\t\tmargin-left: -20px;\n\t}\n"); ?> <?php if (sizeof($items) > 0) { ?> <?php $Form = ActiveForm::begin(); ?> <?php echo Sortable::widget(['items' => $items, 'options' => ['tag' => 'ul', 'class' => 'jquery-sortable'], 'itemOptions' => ['tag' => 'li', 'class' => 'ui-state-default']]); ?> <div class="form-group"> <?php echo Html::submitButton($button, ['class' => 'btn btn-primary center-block']); ?> </div> <?php ActiveForm::end(); } else { ?> <div class="alert alert-info" role="alert"> <?php echo $empty; ?>
<?php \yii\widgets\ActiveForm::end(); ?> </div><!-- form --> <div class="spacer"></div> <div class="row"> <div class="sortable"> <?php $items = []; foreach ($category as $data) { $forum = YBoardForum::find()->sortedScope()->forumScope()->andWhere(['cat_id' => $data->id])->all(); if ($data !== null) { $items['cat_' . $data->id] = $this->render('_category', ['data' => $data, 'forum' => $forum], true); } } echo Sortable::widget(['id' => 'sortcategory', 'items' => $items, 'options' => ['style' => 'list-style:none; margin-top:1px'], 'clientOptions' => ['delay' => '100', 'update' => new JsExpression('function(){Sort(this,"' . \Yii::$app->urlManager->createAbsoluteUrl('setting/ajax-sort') . '");}')]]); ?> </div> </div> <div class="spacer"></div> </div> <?php \yii\jui\Dialog::begin(['id' => 'dlgEditForum', 'clientOptions' => ['title' => 'Edit', 'autoOpen' => false, 'modal' => true, 'width' => 400, 'height' => 400, 'show' => 'fade', 'buttons' => [YBoard::t('yboard', 'Delete') => new JsExpression('function(){ deleteForum("' . Yii::$app->urlManager->createAbsoluteUrl(Yii::$app->controller->module->id . '/setting/delete-forum') . '"); }'), YBoard::t('yboard', 'Save') => new JsExpression('function(){ saveForum("' . Yii::$app->urlManager->createAbsoluteUrl(Yii::$app->controller->module->id . '/setting/save-forum') . '"); }'), YBoard::t('yboard', 'Cancel') => new JsExpression('function(){ $(this).dialog("close"); }')]]]); echo $this->render('_editForum', ['model' => $model]); \yii\jui\Dialog::end();
<div class="col-lg-12 col-md-12"> <div class="col-lg-6 col-md-6"> <?php foreach ($generator->getColumnNames() as $field) { $itemsField[] = ['content' => $field, 'options' => ['id' => $field]]; } ?> <?php echo Html::tag('label', Yii::t('giiamos', 'Elenco campi')); ?> <?php echo Sortable::widget(['id' => 'tabs-fields', 'options' => ['tag' => 'div', 'class' => 'elenco-campi sortable-area'], 'clientOptions' => ['cursor' => 'move', 'connectWith' => '.sortable-area', 'class' => 'sortable-area'], 'items' => $itemsField, 'itemOptions' => ['class' => 'sortable-item']]); ?> </div> <div class="col-lg-6 col-md-6"> <?php $tableContent = '<tr><th>Tabs</th><th>Campi della form</th></tr>'; ?> <?php echo Html::tag('table', $tableContent, ['id' => 'giiamos-table', 'class' => 'giiamos-table table table-bordered table-striped']); ?> </div> <div class="clearfix"></div>
echo $form->field($model, $attribute)->fileInput(['multiple' => 1]); ?> <?php echo Html::submitButton(Yii::t('magic', 'Upload'), ['class' => 'btn btn-success']); ?> <?php ActiveForm::end(); ?> </div> </div> <?php $form = ActiveForm::begin(['action' => ['/cp/magic/manage/update'], 'options' => ['id' => 'magic_form_update', 'data-pjax' => 1]]); ?> <div class="panel panel-default"> <div class="panel-heading"><?php echo Yii::t('magic', 'Uploaded files'); ?> </div> <div class="panel-body"> <?php echo Sortable::widget(['items' => $list, 'options' => ['id' => 'magic_sortable', 'tag' => 'div', 'class' => 'row', 'style' => 'margin-top: 20px;'], 'itemOptions' => ['tag' => 'div', 'class' => 'col-sm-6 col-md-4'], 'clientOptions' => ['cursor' => 'move', 'beforeStop' => new JsExpression("\n function (event, ui) {\n jQuery(ui.item.parent()).sortable('option', 'disabled', true);\n\n jQuery(ui.item.parent()).find('div.caption').each(function (index, el) {\n jQuery(el).find('input[type=hidden]').val(index + 1);\n });\n\n jQuery.ajax({\n 'type': 'post',\n 'url': '{$url}',\n 'dataType': 'html',\n 'data': jQuery(this).closest('form').serialize()\n }).done(function () {\n jQuery(ui.item.parent()).sortable('option', 'disabled', false);\n });\n }")]]); ?> </div> </div> <?php ActiveForm::end(); ?> <?php Pjax::end();
); ?> <div class="col-md-12"> <? $widget = \skeeks\cms\widgets\tree\CmsTreeWidget::begin([ "models" => $models, "viewNodeContentFile" => '@skeeks/cms/views/admin-tree/_tree-node', 'pjaxClass' => \skeeks\cms\modules\admin\widgets\Pjax::class, 'pjaxOptions' => [ 'blockPjaxContainer' => false, 'blockContainer' => '.sx-panel', ] ]); ?> <? \yii\jui\Sortable::widget(); $options = \yii\helpers\Json::encode([ 'id' => $widget->id, 'pjaxid' => $widget->pjax->id, 'backendNewChild' => \skeeks\cms\helpers\UrlHelper::construct(['/cms/admin-tree/new-children'])->enableAdmin()->toString(), 'backendResort' => \skeeks\cms\helpers\UrlHelper::construct(['/cms/admin-tree/resort'])->enableAdmin()->toString() ]); $this->registerJs(<<<JS (function(window, sx, $, _) { sx.createNamespace('classes.tree.admin', sx); sx.classes.tree.admin.CmsTreeWidget = sx.classes.Component.extend({
public function registerSortableJs() { $pjaxId = ''; if (property_exists($this, 'pjax')) { $pjax = $this->pjax; if ($pjax && $pjax instanceof Pjax) { $pjaxId = $pjax->id; } } if ($this->sortable) { Sortable::widget(); $options = $this->sortableOptions; $options['pjaxId'] = $pjaxId; $sortableOptions = Json::encode($options); $this->view->registerCss(<<<Css table.sx-sortable tbody>tr { cursor: move; } Css ); $this->view->registerJs(<<<JS (function(sx, \$, _) { sx.classes.TableSortable = sx.classes.Widget.extend({ _init: function() {}, _onDomReady: function() { var self = this; this.Jtable = this.getWrapper().find('table'); this.Jtable.addClass('sx-sortable'); \$('tbody', this.Jtable).sortable({ out: function( event, ui ) { var Jtbody = \$(ui.item).closest("tbody"); var newSort = []; Jtbody.children("tr").each(function(i, element) { newSort.push(\$(this).data("key")); }); var blocker = sx.block(self.getWrapper()); var ajax = sx.ajax.preparePostQuery( self.get('backend'), { "keys" : newSort, "changeKey" : \$(ui.item).data("key") } ); new sx.classes.AjaxHandlerNoLoader(ajax); //отключение глобального загрузчика new sx.classes.AjaxHandlerNotifyErrors(ajax, { 'error': "Изменения не сохранились", 'success': "Изменения сохранены", }); //отключение глобального загрузчика ajax.onError(function(e, data) { if (self.get('pjaxId')) { \$.pjax.reload(\$("#" + self.get('pjaxId')), {}); } blocker.unblock(); //sx.notify.info("Подождите сейчас страница будет перезагружена"); _.delay(function() { //window.location.reload(); //blocker.unblock(); }, 2000); }) .onSuccess(function(e, data) { if (self.get('pjaxId')) { \$.pjax.reload(\$("#" + self.get('pjaxId')), {}); } var response = data.response; if (response.success === false) { sx.notify.error(response.message); } else { sx.notify.success(response.message); } blocker.unblock(); }) .execute(); } }); }, _onWindowReady: function() {} }); new sx.classes.TableSortable('#{$this->id}', {$sortableOptions}); })(sx, sx.\$, sx._); JS ); } }
*/ echo Html::a(Yii::t('BbiiModule.bbii', 'Edit'), \Yii::$app->urlManager->createAbsoluteUrl(['forum/setting/updateforum', 'id' => $data->id])); ?> </td> </tr> <tr> <td class = "header4"> <?php echo Html::encode($data->subtitle); ?> </td> </tr> </tbody> <tr> <td colspan = "2"> <?php /*$this->widget('zii.widgets.jui.CJuiSortable', array( 'id' => 'sortfrm' . $data->id, 'items' => $forumitems, 'htmlOptions' => array('style' => 'list-style:none;margin-top:1px;padding-right:0;'), 'theme' => $this->module->juiTheme, 'options' => array( 'delay' => '100', 'update' => 'js:function(){Sort(this,"' . \Yii::$app->urlManager->createAbsoluteUrl('setting/ajaxSort') . '");}', ), ));*/ echo Sortable::widget(['clientOptions' => ['cursor' => 'move'], 'id' => 'sortfrm' . $data->id, 'itemOptions' => ['tag' => 'li'], 'items' => $forumitems, 'options' => array('delay' => '100', 'update' => 'js:function(){Sort(this,"' . \Yii::$app->urlManager->createAbsoluteUrl('setting/ajaxSort') . '");}')]); ?> </td> </tr> </table>
public function run() { echo Html::tag('div', '', ['class' => 'response']); parent::run(); }
$options = ['id' => 'ticketwidget_' . $ticket->id, 'tag' => 'div', 'class' => 'ticket-widget']; $columnItems[] = ['content' => $content, 'options' => $options]; } // create the column as a sortable widget container // -------------------------------------------------------- // Read the serialized list of Column Ids and create for it // a comma separated list of the ID's with COLUMN_ID_PREFIX prepended to the ID if (trim($column->receiver) != '') { $connectedColumns = explode(',', $column->receiver); $prefix = '#' . COLUMN_ID_PREFIX; $separator = ', #' . COLUMN_ID_PREFIX; $connectedColumns = $prefix . implode($separator, $connectedColumns); } else { $connectedColumns = ''; } echo Sortable::widget(['items' => $columnItems, 'options' => ['id' => COLUMN_ID_PREFIX . $column->id, 'tag' => 'div', 'class' => 'board-column'], 'clientOptions' => ['cursor' => 'move', 'connectWith' => $connectedColumns], 'clientEvents' => ['activate' => 'function (event, ui) { showColumnReceiver(event, ui, this); }', 'deactivate' => 'function (event, ui) { hideColumnReceiver(event, ui, this); }', 'receive' => 'function (event, ui) { columnTicketOrder(event, ui, this); }', 'update' => 'function (event, ui) { if (!ui.sender && this === ui.item.parent()[0]) { columnTicketOrder(event, ui, this); } }']]); ?> </div>