-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdemo.html
159 lines (145 loc) · 3.66 KB
/
demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta content='text/html;charset=utf-8' http-equiv='Content-Type'>
<meta content='width=device-width, initial-scale=1' name='viewport'>
<link href='demo.css' rel='stylesheet' type='text/css'>
<link href='../src/draganddrop.css' rel='stylesheet' type='text/css'>
<script src='../bower_components/jquery/dist/jquery.min.js' type='text/javascript'></script>
<script src='../src/draganddrop.js' type='text/javascript'></script>
<script type='text/javascript'>
$(function() {
//grouped lists
$('ul.grouped').sortable({
group: true
});
//normal list
$('ul.normal').sortable({
autocreate: true,
update: function(evt) {
console.log(JSON.stringify($(this).sortable('serialize')));
}
});
//remaining lists
$('ul.float, ul.inline').sortable({
update: function(evt) {
console.log(JSON.stringify($(this).sortable('serialize')));
}
});
//div list
$('.list.parent').sortable({container: '.list', nodes: ':not(.list)'});
//draggable
$('.drag').draggable();
$('.draggables').draggable({delegate: 'button', placeholder: true});
$('.draghandle').draggable({handle: '.handle', placeholder: true});
$('.dragdrop').draggable({
revert: true,
placeholder: true,
droptarget: '.drop',
drop: function(evt, droptarget) {
$(this).appendTo(droptarget).draggable('destroy');
}
});
//off switch
$('.off').on('click', function() {
$('.sortable').each(function() { $(this).sortable('destroy'); });
$('.draggable').each(function() { $(this).draggable('destroy'); });
});
});
</script>
<title>Drag and Drop Demo</title>
</head>
<body>
<h2>Drag and Drop Demo</h2>
<h3>Draggables</h3>
<button class="drag">Drag me</button>
<button class="draghandle">Drag my <strong class="handle">handle</strong></button>
<button class="dragdrop">Drag and Drop me</button>
<span class="draggables">
<button>1</button>
<button>2</button>
<button>3</button>
<button>4</button>
</span>
<div class="drop"><p>Drop here</p></div>
<h3>Normal List</h3>
<ul class="normal">
<li>Item 1</li>
<li>Item 2
<ul>
<li>Item 2.1</li>
<li>Item 2.2
<ul>
<li>Item 2.2.1</li>
</ul>
</li>
</ul>
</li>
<li>Item 3
<ul>
<li>Item 3.1</li>
</ul>
</li>
</ul>
<h3>Floating LI elements</h3>
<ul class="float">
<li>
Item 1
</li>
<li>
Item 2
</li>
<li>
Item 3
</li>
<li>
Item 4
</li>
</ul>
<h3>Inline-block LI elements</h3>
<ul class="inline">
<li>
Item 1
</li>
<li>
Item 2
</li>
<li>
Item 3
</li>
<li>
Item 4
</li>
</ul>
<h3>Grouped Lists</h3>
<ul class="grouped">
<li>
Item 1
</li>
<li>
Item 2
</li>
</ul>
<ul class="grouped">
<li>
Item 1
</li>
<li>
Item 2
</li>
</ul>
<h3>List of DIVs</h3>
<div class="list parent">
<div>Child 1</div>
<div>Child 2</div>
<div>
Child 3
<div class="list">
<div>Subchild</div>
</div>
</div>
</div>
<h3>Off Switch</h3>
<button class="off">All off</button>
</body>
</html>