This repository was archived by the owner on Sep 8, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +49
-32
lines changed Expand file tree Collapse file tree 3 files changed +49
-32
lines changed Original file line number Diff line number Diff line change
1
+ .section {
2
+ margin-top : 30px ;
3
+ margin-bottom : 30px ;
4
+ }
5
+
1
6
.list {
7
+ border : 1px solid # 000 ;
8
+ border-radius : 15px ;
2
9
list-style : none outside none;
3
- margin : 10px 0 30px ;
10
+ margin : 10px ;
11
+ padding : 10px ;
4
12
}
5
13
6
14
.item {
7
- width : 200px ;
8
15
padding : 5px 10px ;
9
16
margin : 5px 0 ;
10
17
border : 2px solid # 444 ;
21
28
/*** Extra ***/
22
29
23
30
.logList {
24
- margin-top : 20px ;
25
- width : 250px ;
26
31
min-height : 200px ;
27
- padding : 5px 15px ;
28
32
border : 5px solid # 000 ;
29
33
border-radius : 15px ;
30
34
}
31
-
32
- .logList : before {
33
- content : 'log' ;
34
- padding : 0 5px ;
35
- position : relative;
36
- top : -1.1em ;
37
- background-color : # FFF ;
38
- }
39
-
40
- ul [ui-sortable ] {
41
- float : right;
42
- }
Original file line number Diff line number Diff line change 1
- < section ng-app ="sortableApp " ng-controller ="sortableController ">
2
- < div class ="row ">
3
- < div class ="col-md-6 ">
1
+ < section ng-app ="sortableApp ">
2
+ < h1 > Sortable items</ h1 >
3
+ < div ng-controller ="sortableController " class ="section row ">
4
+ < div class ="col-sm-offset-2 col-sm-4 ">
4
5
< ul ui-sortable ="sortableOptions " ng-model ="list " class ="list ">
5
6
< li ng-repeat ="item in list " class ="item "> {{item.text}}</ li >
6
7
</ ul >
7
8
</ div >
8
- < div class ="col-md-6 ">
9
+ < div class ="col-sm-4 ">
9
10
< ul class ="list logList ">
10
11
< li ng-repeat ="entry in sortingLog " class ="logItem "> {{entry.Text}}</ li >
11
12
</ ul >
12
13
</ div >
13
14
</ div >
14
- </ section >
15
+
16
+ < h1 > Connected items</ h1 >
17
+ < div ng-controller ="connectedController " class ="section row connectedItemsExample ">
18
+ < div class ="col-sm-offset-2 col-sm-4 ">
19
+ < ul ui-sortable ="sortableOptions " ng-model ="leftArray " class ="list ">
20
+ < li ng-repeat ="item in leftArray " class ="item "> {{item.text}}</ li >
21
+ </ ul >
22
+ </ div >
23
+ < div class ="col-sm-4 ">
24
+ < ul ui-sortable ="sortableOptions " ng-model ="rightArray " class ="list ">
25
+ < li ng-repeat ="item in rightArray " class ="item "> {{item.text}}</ li >
26
+ </ ul >
27
+ </ div >
28
+ </ div >
29
+ </ section >
Original file line number Diff line number Diff line change 1
1
2
2
var myapp = angular . module ( 'sortableApp' , [ 'ui.sortable' ] ) ;
3
3
4
- myapp . controller ( 'sortableController' , function ( $scope ) {
5
- 'use strict' ;
6
-
7
- var tmpList = [ ] ;
8
-
9
- for ( var i = 1 ; i <= 6 ; i ++ ) {
10
- tmpList . push ( {
11
- text : 'Item ' + i ,
4
+ myapp . buildArray = function ( name , size ) {
5
+ var i , array = [ ] ;
6
+ for ( i = 1 ; i <= size ; i ++ ) {
7
+ array . push ( {
8
+ text : name + ' ' + i ,
12
9
value : i
13
10
} ) ;
14
11
}
15
12
16
- $scope . list = tmpList ;
13
+ return array ;
14
+ } ;
15
+
16
+ myapp . controller ( 'sortableController' , function ( $scope ) {
17
+ 'use strict' ;
17
18
19
+ $scope . list = myapp . buildArray ( 'Item' , 5 ) ;
18
20
19
21
$scope . sortingLog = [ ] ;
20
22
@@ -28,4 +30,12 @@ myapp.controller('sortableController', function ($scope) {
28
30
$scope . sortingLog . push ( logEntry ) ;
29
31
}
30
32
} ;
31
- } ) ;
33
+ } ) ;
34
+
35
+ myapp . controller ( 'connectedController' , function ( $scope ) {
36
+ $scope . leftArray = myapp . buildArray ( 'Left' , 5 ) ;
37
+ $scope . rightArray = myapp . buildArray ( 'Right' , 7 ) ;
38
+ $scope . sortableOptions = {
39
+ connectWith : '.connectedItemsExample .list'
40
+ } ;
41
+ } ) ;
You can’t perform that action at this time.
0 commit comments