@@ -36,62 +36,62 @@ use yii\helpers\Url;
36
36
use yii\web\JsExpression;
37
37
38
38
echo Nestable::widget([
39
- 'items' => [
40
- [
41
- 'content' => '<div ><a href =" #test" >My Item</a ><span class =" handle" ></span ></div >',
42
- 'options' => ['class' => 'list-group-item'],
43
- 'listOptions' => ['class' => 'list-group'],
44
- 'items' => [
45
- [
46
- 'content' => '<div ><a href =" #testChild" >My Child Item</a ><span class =" handle" ></span ></div >',
47
- 'options' => ['class' => 'list-group-item']
48
- ]
49
- ]
50
- ],
51
- [
52
- 'content' => '<div ><a href =" #test2" >My Item 2</a ><span class =" handle" ></span ></div >',
53
- 'options' => ['class' => 'list-group-item'],
54
- 'listOptions' => ['class' => 'list-group']
55
- ]
56
- ],
39
+ 'items' => [
40
+ [
41
+ 'content' => '<div ><a href =" #test" >My Item</a ><span class =" handle" ></span ></div >',
42
+ 'options' => ['class' => 'list-group-item'],
43
+ 'listOptions' => ['class' => 'list-group'],
44
+ 'items' => [
45
+ [
46
+ 'content' => '<div ><a href =" #testChild" >My Child Item</a ><span class =" handle" ></span ></div >',
47
+ 'options' => ['class' => 'list-group-item']
48
+ ]
49
+ ]
50
+ ],
51
+ [
52
+ 'content' => '<div ><a href =" #test2" >My Item 2</a ><span class =" handle" ></span ></div >',
53
+ 'options' => ['class' => 'list-group-item'],
54
+ 'listOptions' => ['class' => 'list-group']
55
+ ]
56
+ ],
57
57
'clientOptions' => [
58
- 'expandOnHover' => 700,
59
- 'forcePlaceholderSize' => true,
60
- 'handle' => '.handle',
61
- 'isTree' => true,
62
- 'items' => 'li',
63
- 'placeholder' => 'placeholder',
64
- 'startCollapsed' => true,
65
- 'toleranceElement' => '> div',
66
- // this js event will be called on change order of list
67
- 'relocate' => new JsExpression('function (evt, ui) {
68
- var context = null;
69
- var method = \'root\';
70
- var parent = ui.item.parent(\'ul\').parent(\'.list-group-item\');
71
-
72
- if (ui.item.prev(\'.list-group-item\').length) {
73
- if (parent.length) {
74
- method = \'after\';
75
- }
76
- context = ui.item.prev(\'.list-group-item\').data(\'id\');
77
- } else if (ui.item.next(\'.list-group-item\').length) {
78
- if (parent.length) {
79
- method = \'before\';
80
- }
81
- context = ui.item.next(\'.list-group-item\').data(\'id\');
82
- } else if (parent.length) {
83
- method = \'prepend\';
84
- context = ui.item.parent(\'ul\').parent(\'.list-group-item\').data(\'id\');
85
- }
86
-
87
- jQuery.ajax({
88
- url: \''.Url::to(['site/my']).'/\' + method,
89
- data: {
90
- id: ui.item.data(\'id\'),
91
- context: context
92
- }
93
- });
94
- }')
58
+ 'expandOnHover' => 700,
59
+ 'forcePlaceholderSize' => true,
60
+ 'handle' => '.handle',
61
+ 'isTree' => true,
62
+ 'items' => 'li',
63
+ 'placeholder' => 'placeholder',
64
+ 'startCollapsed' => true,
65
+ 'toleranceElement' => '> div',
66
+ // this js event will be called on change order of list
67
+ 'relocate' => new JsExpression('function (evt, ui) {
68
+ var context = null;
69
+ var method = \'root\';
70
+ var parent = ui.item.parent(\'ul\').parent(\'.list-group-item\');
71
+
72
+ if (ui.item.prev(\'.list-group-item\').length) {
73
+ if (parent.length) {
74
+ method = \'after\';
75
+ }
76
+ context = ui.item.prev(\'.list-group-item\').data(\'id\');
77
+ } else if (ui.item.next(\'.list-group-item\').length) {
78
+ if (parent.length) {
79
+ method = \'before\';
80
+ }
81
+ context = ui.item.next(\'.list-group-item\').data(\'id\');
82
+ } else if (parent.length) {
83
+ method = \'prepend\';
84
+ context = ui.item.parent(\'ul\').parent(\'.list-group-item\').data(\'id\');
85
+ }
86
+
87
+ jQuery.ajax({
88
+ url: \''.Url::to(['site/my']).'/\' + method,
89
+ data: {
90
+ id: ui.item.data(\'id\'),
91
+ context: context
92
+ }
93
+ });
94
+ }')
95
95
]
96
96
]);
97
97
?>
@@ -108,36 +108,36 @@ use yii\web\Controller;
108
108
* This controller provides move actions
109
109
*/
110
110
class MyController extends Controller {
111
- /**
112
- * @inheritdoc
113
- */
114
- public function actions() {
115
- return [
116
- 'root' => [
117
- 'class' => 'simialbi\yii2\nestable\actions\RootAction',
118
- 'modelClass' => 'simialbi\yii2\nestable\models\ActiveRecord'
119
- ],
120
- 'after' => [
121
- 'class' => 'simialbi\yii2\nestable\actions\AfterAction',
122
- 'modelClass' => 'simialbi\yii2\nestable\models\ActiveRecord'
123
- ],
124
- 'before' => [
125
- 'class' => 'simialbi\yii2\nestable\actions\BeforeAction',
126
- 'modelClass' => 'simialbi\yii2\nestable\models\ActiveRecord'
127
- ],
128
- 'prepend' => [
129
- 'class' => 'simialbi\yii2\nestable\actions\PrependAction',
130
- 'modelClass' => 'simialbi\yii2\nestable\models\ActiveRecord'
131
- ],
132
- 'append' => [
133
- 'class' => 'simialbi\yii2\nestable\actions\AppendAction',
134
- 'modelClass' => 'simialbi\yii2\nestable\models\ActiveRecord'
135
- ]
136
- ];
137
- }
111
+ /**
112
+ * @inheritdoc
113
+ */
114
+ public function actions() {
115
+ return [
116
+ 'root' => [
117
+ 'class' => 'simialbi\yii2\nestable\actions\RootAction',
118
+ 'modelClass' => 'simialbi\yii2\nestable\models\ActiveRecord'
119
+ ],
120
+ 'after' => [
121
+ 'class' => 'simialbi\yii2\nestable\actions\AfterAction',
122
+ 'modelClass' => 'simialbi\yii2\nestable\models\ActiveRecord'
123
+ ],
124
+ 'before' => [
125
+ 'class' => 'simialbi\yii2\nestable\actions\BeforeAction',
126
+ 'modelClass' => 'simialbi\yii2\nestable\models\ActiveRecord'
127
+ ],
128
+ 'prepend' => [
129
+ 'class' => 'simialbi\yii2\nestable\actions\PrependAction',
130
+ 'modelClass' => 'simialbi\yii2\nestable\models\ActiveRecord'
131
+ ],
132
+ 'append' => [
133
+ 'class' => 'simialbi\yii2\nestable\actions\AppendAction',
134
+ 'modelClass' => 'simialbi\yii2\nestable\models\ActiveRecord'
135
+ ]
136
+ ];
137
+ }
138
138
}
139
139
```
140
140
141
141
## License
142
142
143
- ** yii2-nestable** is released under MIT license. See bundled [ LICENSE] ( LICENSE ) for details.
143
+ ** yii2-nestable** is released under MIT license. See bundled [ LICENSE] ( LICENSE ) for details.
0 commit comments