forked from sindu12jun/table-dragger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
362 lines (340 loc) · 9.92 KB
/
index.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="table-dragger, drag and sort rows or columns of table">
<meta name="author" content="sindu12jun">
<title>sindu12jun-TableDragger</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.4.1/themes/prism-tomorrow.min.css">
<style>
.btn {
border: 2px solid;
}
footer a,
footer a:hover,
.jumbotron a,
.jumbotron a:hover {
color: #cc99cd;
}
footer, .jumbotron {
margin-bottom: 0;
background: #2d2d2d;
color: #67cdcc;
}
footer {
margin-top: 1em;
padding: 1em 0;
color: #ccc;
}
.handle {
font-family: 'Glyphicons Halflings';
color: #dd5;
}
.handle:hover {
}
.handle:before {
content: "\e068";
}
.sortable-ghost {
background: #efefef;
}
section {
margin-bottom: 40px;
}
/*.tbl-header {*/
/*background-color: rgba(255, 255, 255, 0.3);*/
/*}*/
/*td, th {*/
/*background-color: #67CDCC;*/
/*padding: 15px;*/
/*text-align: left;*/
/*vertical-align: middle;*/
/*font-weight: 300;*/
/*font-size: 16px;*/
/*color: #fff;*/
/*border-bottom: solid 1px rgba(255, 255, 255, 0.1);*/
/*}*/
table {
table-layout: fixed;
width: 100%;
}
.sindu-table {
background: #34495E;
color: #fff;
overflow: hidden;
}
.sindu-table th {
padding: 16px;
color: #dd5;
}
.sindu-table td {
padding: 16px;
}
</style>
</head>
<body>
<div class="jumbotron">
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-2">
<a href="https://github.com/sindu12jun/table-dragger"><h1>table-dragger</h1></a>
<p class="lead">
Easily add drag-and-drop sorting to your table without jQuery
<a href="https://github.com/sindu12jun/table-dragger" class="btn btn-lg">View on GitHub</a>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<h2 class="page-header">Usage
<span class="small">
cells that can be lifted up was marked with icon <i class="handle"></i>
</span>
</h2>
<section>
<h4>Default <span class="small">With no options, sort columns, handler was the first row</span></h4>
<table id="default-table" class="sindu-table">
<thead>
<tr>
<th>Movie Title<i class="handle"></i></th>
<th>Genre<i class="handle"></i></th>
<th>Year<i class="handle"></i></th>
<th>Gross<i class="handle"></i></th>
</tr>
</thead>
<tr>
<td>Star Wars</td>
<td>Adventure, Sci-fi</td>
<td>1977</td>
<td>$460,935,665</td>
</tr>
<tr>
<td>Howard The Duck</td>
<td>"Comedy"</td>
<td>1986</td>
<td>$16,295,774</td>
</tr>
<tr>
<td>American Graffiti</td>
<td>Comedy, Drama</td>
<td>1973</td>
<td>$115,000,000</td>
</tr>
</table>
<pre>
<code class="language-javascript">
tableDragger(document.querySelector("#default-table"));
</code>
</pre>
</section>
<section>
<h4>Sort Rows <span class="small">Sort rows, handler was the first column</span></h4>
<table id="row-table" class="sindu-table">
<thead>
<tr>
<th>Movie Title<i class="handle"></i></th>
<th>Genre</th>
<th>Year</th>
<th>Gross</th>
</tr>
</thead>
<tr>
<td>Star Wars<i class="handle"></i></td>
<td>Adventure, Sci-fi</td>
<td>1977</td>
<td>$460,935,665</td>
</tr>
<tr>
<td>Howard The Duck<i class="handle"></i></td>
<td>"Comedy"</td>
<td>1986</td>
<td>$16,295,774</td>
</tr>
<tr>
<td>American Graffiti<i class="handle"></i></td>
<td>Comedy, Drama</td>
<td>1973</td>
<td>$115,000,000</td>
</tr>
</table>
<pre>
<code class="language-javascript">
tableDragger(document.querySelector("#row-table"), { mode: "row" });
</code>
</pre>
</section>
<section>
<h4>Handler <span class="small">Specify drag handler wherever within the table</span></h4>
<table id="handle-table" class="sindu-table">
<thead>
<tr>
<th>Movie Title <i class="handle">dragme</i></th>
<th>Genre</th>
<th>Year</th>
<th>Gross</th>
</tr>
</thead>
<tr>
<td>Star Wars</td>
<td>Adventure, Sci-fi</td>
<td>1977</td>
<td>$460,935,665</td>
</tr>
<tr>
<td>Howard The Duck</td>
<td>"Comedy"</td>
<td>1986</td>
<td>$16,295,774</td>
</tr>
<tr>
<td>American Graffiti</td>
<td>Comedy, Drama</td>
<td>1973</td>
<td>$115,000,000</td>
</tr>
</table>
<pre>
<code class="language-javascript">
tableDragger(document.querySelector("#row-table"), { dragHandler: ".handle" });
</code>
</pre>
</section>
<section>
<h4>Free <span class="small">After mousedown, move mouse horizontally or vertically, see what happens. Don't forget to specify drag handler</span>
</h4>
<table id="free-table" class="sindu-table">
<thead>
<tr>
<th>Movie Title</th>
<th>Genre</th>
<th>Year</th>
<th>Gross</th>
</tr>
</thead>
<tr>
<td>Star Wars<i class="handle">dragme</i></td>
<td>Adventure, Sci-fi</td>
<td>1977</td>
<td>$460,935,665</td>
</tr>
<tr>
<td>Howard The Duck</td>
<td>"Comedy"</td>
<td>1986</td>
<td>$16,295,774</td>
</tr>
<tr>
<td>American Graffiti</td>
<td>Comedy, Drama</td>
<td>1973</td>
<td>$115,000,000</td>
</tr>
</table>
<pre>
<code class="language-javascript">
tableDragger(document.querySelector("#row-table"), { mode: "row", onlyBody: true, dragHandler: ".handle" });
</code>
</pre>
</section>
<section>
<h4>Only Body <span class="small">Setting onlyBody to true in row mode, user can only lift rows in tBody</span>
</h4>
<table id="only-body-table" class="sindu-table">
<thead>
<tr>
<th>Movie Title</th>
<th>Genre</th>
<th>Year</th>
<th>Gross</th>
</tr>
</thead>
<tr>
<td>Star Wars<i class="handle"></i></td>
<td>Adventure, Sci-fi</td>
<td>1977</td>
<td>$460,935,665</td>
</tr>
<tr>
<td>Howard The Duck<i class="handle"></i></td>
<td>"Comedy"</td>
<td>1986</td>
<td>$16,295,774</td>
</tr>
<tr>
<td>American Graffiti<i class="handle"></i></td>
<td>Comedy, Drama</td>
<td>1973</td>
<td>$115,000,000</td>
</tr>
</table>
<pre>
<code class="language-javascript">
tableDragger(document.querySelector("#row-table"), { mode: "row", onlyBody: true });
</code>
</pre>
</section>
<section>
<h4>Event <span class="small">Add callback when event trigger, open devtool see what happens</span></h4>
<table id="event-table" class="sindu-table">
<thead>
<tr>
<th>Movie Title</th>
<th>Genre</th>
<th>Year</th>
<th>Gross</th>
</tr>
</thead>
<tr>
<td>Star Wars <i class="handle">dragme</i></td>
<td>Adventure, Sci-fi</td>
<td>1977</td>
<td>$460,935,665</td>
</tr>
<tr>
<td>Howard The Duck</td>
<td>"Comedy"</td>
<td>1986</td>
<td>$16,295,774</td>
</tr>
<tr>
<td>American Graffiti</td>
<td>Comedy, Drama</td>
<td>1973</td>
<td>$115,000,000</td>
</tr>
</table>
<pre>
<code class="language-javascript">
tableDragger(document.querySelector('#event-table'), { mode: 'free', dragHandler: '.handle', onlyBody: true })
.on('drag', () => {
console.log('drag');
})
.on('drop', (from, to, el, mode) => {
console.log(`drop ${el.nodeName} from ${from} ${mode} to ${to} ${mode}`);
})
.on('shadowMove', (from, to, el, mode) => {
console.log(`move ${el.nodeName} from ${from} ${mode} to ${to} ${mode}`);
})
.on('out', (el, mode) => {
console.log(`move out or drop ${el.nodeName} in mode ${mode}`);
});
</code>
</pre>
</section>
</div>
</div>
</div>
<footer>
<div class="container text-center">
<small>Free to Use Under The MIT License (MIT) | Created by <a href="https://github.com/sindu12jun">@sindu12jun</a>
</small>
</div>
</footer>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.4.1/prism.min.js"></script>
<script src="./build/build-docs.js"></script>
</body>
</html>