Skip to content

Commit b95d149

Browse files
Advanced Demo to demonstrate new features
1 parent a5dabdb commit b95d149

File tree

6 files changed

+142
-0
lines changed

6 files changed

+142
-0
lines changed

demo/advanced/advanced-frame.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<h1>Demo: Advanced Features</h1>
2+
3+
<div class="alert alert-success">
4+
TODO
5+
</div>
6+
7+
<div class="advancedDemo row">
8+
<div ng-repeat="containers in model" class="col-md-4">
9+
<div class="dropzone box box-yellow" ng-include="'advanced/advanced.html'"></div>
10+
</div>
11+
</div>
12+
13+
<div view-source="advanced"></div>
14+
15+
<h2>Generated Model</h2>
16+
<pre>{{modelAsJson}}</pre>

demo/advanced/advanced.css

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/***************************** Required styles *****************************/
2+
3+
/**
4+
* For the correct positioning of the placeholder element, the dnd-list and
5+
* it's children must have position: relative
6+
*/
7+
.advancedDemo ul[dnd-list],
8+
.advancedDemo ul[dnd-list] > li {
9+
position: relative;
10+
}
11+
12+
/***************************** Dropzone Styling *****************************/
13+
14+
/**
15+
* The dnd-list should always have a min-height,
16+
* otherwise you can't drop to it once it's empty
17+
*/
18+
.advancedDemo .dropzone ul[dnd-list] {
19+
min-height: 42px;
20+
margin: 0px;
21+
padding-left: 0px;
22+
}
23+
24+
/**
25+
* The dnd-lists's child elements currently MUST have
26+
* position: relative. Otherwise we can not determine
27+
* whether the mouse pointer is in the upper or lower
28+
* half of the element we are dragging over. In other
29+
* browsers we can use event.offsetY for this.
30+
*/
31+
.advancedDemo .dropzone li {
32+
background-color: #fff;
33+
border: 1px solid #ddd;
34+
display: block;
35+
padding: 0px;
36+
}
37+
38+
/**
39+
* Reduce opacity of elements during the drag operation. This allows the user
40+
* to see where he is dropping his element, even if the element is huge. The
41+
* .dndDragging class is automatically set during the drag operation.
42+
*/
43+
.advancedDemo .dropzone .dndDragging {
44+
opacity: 0.7;
45+
}
46+
47+
/**
48+
* The dndDraggingSource class will be applied to the source element of a drag
49+
* operation. It makes sense to hide it to give the user the feeling that he's
50+
* actually moving it. Note that the source element has also .dndDragging class.
51+
*/
52+
.advancedDemo .dropzone .dndDraggingSource {
53+
display: none;
54+
}
55+
56+
/**
57+
* An element with .dndPlaceholder class will be added as child of the dnd-list
58+
* while the user is dragging over it.
59+
*/
60+
.advancedDemo .dropzone .dndPlaceholder {
61+
background-color: #ddd;
62+
min-height: 42px;
63+
display: block;
64+
position: relative;
65+
}
66+
67+
/***************************** Element type specific styles *****************************/
68+
69+
.advancedDemo .dropzone .item {
70+
padding: 10px 15px;
71+
}
72+
73+
.advancedDemo .dropzone .container-element {
74+
margin: 10px;
75+
}

demo/advanced/advanced.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<h3>Dropzone {{$index + 1}}</h3>
2+
<ul dnd-list="containers" dnd-allowed-types="['containerType']">
3+
<li ng-repeat="items in containers"
4+
dnd-draggable="items"
5+
dnd-type="'containerType'"
6+
dnd-moved="containers.splice($index, 1)">
7+
<div class="container-element box box-blue">
8+
<h3>Container</h3>
9+
<ul dnd-list="items" dnd-allowed-types="['itemType']">
10+
<li ng-repeat="item in items"
11+
dnd-draggable="item"
12+
dnd-type="'itemType'"
13+
dnd-moved="items.splice($index, 1)">
14+
<div class="item">{{item}}</div>
15+
</li>
16+
</ul>
17+
<div class="clearfix"></div>
18+
</div>
19+
</li>
20+
</ul>

demo/advanced/advanced.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* The controller doesn't do much more than setting the initial data model
3+
*/
4+
angular.module("demo").controller("AdvancedDemoController", function($scope) {
5+
6+
$scope.model = [
7+
[
8+
['Item 1', 'Item 2', 'Item 3'],
9+
['Item 4', 'Item 5', 'Item 6']
10+
],
11+
[
12+
['Item 7', 'Item 8', 'Item 9'],
13+
['Item 10', 'Item 11', 'Item 12']
14+
],
15+
[
16+
['Item 13', 'Item 14', 'Item 15'],
17+
['Item 16', 'Item 17', 'Item 18']
18+
]];
19+
20+
$scope.$watch('model', function(model) {
21+
$scope.modelAsJson = angular.toJson(model, true);
22+
}, true);
23+
24+
});

demo/framework/demo-framework.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ angular.module("demo", ["ngRoute", "dndLists"])
1313
templateUrl: 'types/types-frame.html',
1414
controller: 'TypesDemoController'
1515
})
16+
.when('/advanced', {
17+
templateUrl: 'advanced/advanced-frame.html',
18+
controller: 'AdvancedDemoController'
19+
})
1620
.otherwise({redirectTo: '/nested'});
1721
})
1822

@@ -26,6 +30,7 @@ angular.module("demo", ["ngRoute", "dndLists"])
2630
{label: "Nested Containers", href: "#/nested"},
2731
{label: "Simple Demo", href: "#/simple"},
2832
{label: "Item Types", href: "#/types"},
33+
{label: "Advanced Demo", href: "#/advanced"},
2934
{label: "Github", href: "https://github.com/marceljuenemann/angular-drag-and-drop-lists"}
3035
];
3136

demo/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<link rel="stylesheet" type="text/css" href="simple/simple.css" />
2020
<link rel="stylesheet" type="text/css" href="nested/nested.css" />
2121
<link rel="stylesheet" type="text/css" href="types/types.css" />
22+
<link rel="stylesheet" type="text/css" href="advanced/advanced.css" />
2223

2324
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-route.min.js"></script>
2425
<script src="framework/vendor/prism.js"></script>
@@ -27,6 +28,7 @@
2728
<script src="simple/simple.js"></script>
2829
<script src="nested/nested.js"></script>
2930
<script src="types/types.js"></script>
31+
<script src="advanced/advanced.js"></script>
3032

3133
</head>
3234
<body ng-app="demo">

0 commit comments

Comments
 (0)