forked from johnpolacek/stacktable.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·352 lines (322 loc) · 10.1 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>stacktable.js</title>
<meta name="description" content="The responsive tables jQuery plugin for stacking tables on small screens">
<link href="css/style.css" rel="stylesheet" />
<link href='http://fonts.googleapis.com/css?family=Courgette' rel='stylesheet' type='text/css'>
<link href="stacktable.css" rel="stylesheet" />
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="wrapper">
<header>
<h1><img src="stacktable.png" class="logo" />stacktable.js</h1>
<h3>jQuery plugin for stacking tables on small screens</h3>
<div id="author">
<div class="follow-btn">
<iframe scrolling="no" frameborder="0" allowtransparency="true" src="http://platform.twitter.com/widgets/follow_button.1347008535.html#_=1347293944835&id=twitter-widget-0&lang=en&screen_name=johnpolacek&show_count=false&show_screen_name=true&size=l" class="twitter-follow-button" style="width: 169px; height: 28px; margin:1em auto;" title="Twitter Follow Button" data-twttr-rendered="true"></iframe>
</div>
<p>Made in <a href="http://chicagotechevents.com">Chicago</a> by <a href="https://twitter.com/johnpolacek" target="_blank">John Polacek</a></p>
</div>
</header>
<a href="https://github.com/johnpolacek/stacktable.js/"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
<p>The purpose of stacktable.js is to give you an easy way of converting wide tables to a format that will work better on small screens. It creates a copy of the table that is converted into a 2-column key/value format.</p>
<h2>Download</h2>
<p>Source files <a href="https://github.com/johnpolacek/stacktable.js/" target="_blank">on github</a> or <a href="https://github.com/johnpolacek/stacktable.js/zipball/master/" target="_blank">download the zip</a>.</p>
<h2>How to Use</h2>
<p>Call the plugin on a table.</p>
<h2>Simple Example <a id="run" href="#">run »</a></h2>
<pre>$('#simple-example-table').stacktable();</pre>
<table id="simple-example-table" cellspacing="0">
<tbody>
<tr align="left">
<th width="30%">Stuff</th>
<th width="12%">Rate</th>
<th width="12%">Amount</th>
<th width="12%">Points</th>
<th width="12%">Number</th>
<th width="18%">Type</th>
<th width="12%">Name</th>
</tr>
<tr>
<td>Something</td>
<td>3.375%</td>
<td>$123.12</td>
<td>1.125</td>
<td>4,000</td>
<td>Potato</td>
<td>Paul</td>
</tr>
<tr>
<td>Something Else</td>
<td>2.750%</td>
<td>$345.23</td>
<th>5</th>
<td>180</td>
<td>Spaceship</td>
<td>Skippy</td>
</tr>
<tr>
<th colspan="7" class="sub">Subgroup Header</th>
</tr>
<tr>
<td>Another Thing</td>
<td>3.375%</td>
<td>$563.12</td>
<th>222</th>
<td>60</td>
<td>Gym Shoe</td>
<td>George</td>
</tr>
<tr>
<td>Thing w/Less Stuff</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Harmonica</td>
<td>Helga</td>
</tr>
<tr>
<td>Last Thing</td>
<td></td>
<td></td>
<td></td>
<td>4</td>
<td>Meaning of Life</td>
<td></td>
</tr>
</tbody>
</table>
<h2>Responsive</h2>
<p>Use media queries to toggle the visibility of the original table and the stacktable (check out the stacktable.css example). You can pass in classes or an id to give to the stacktable. Adjust the size of your browser window to see it in action in the example below.</p>
<pre>$('#responsive-example-table').stacktable({myClass:'your-class-name'});</pre>
<table id="responsive-example-table" class="large-only" cellspacing="0">
<tbody>
<tr align="left">
<th width="30%">Stuff</th>
<th width="12%">Rate</th>
<th width="12%">Amount</th>
<th width="12%">Points</th>
<th width="12%">Number</th>
<th width="18%">Type</th>
<th width="12%">Name</th>
</tr>
<tr>
<td>Something</td>
<td>3.375%</td>
<td>$123.12</td>
<td>1.125</td>
<td>4,000</td>
<td>Potato</td>
<td>Paul</td>
</tr>
<tr>
<td>Something Else</td>
<td>2.750%</td>
<td>$345.23</td>
<td>5</td>
<td>180</td>
<td>Spaceship</td>
<td>Skippy</td>
</tr>
<tr>
<td colspan="7" class="sub">Subgroup Header</td>
</tr>
<tr>
<td>Another Thing</td>
<td>3.375%</td>
<td>$563.12</td>
<td>222</td>
<td>60</td>
<td>Gym Shoe</td>
<td>George</td>
</tr>
<tr>
<td>Thing w/Less Stuff</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Harmonica</td>
<td>Helga</td>
</tr>
<tr>
<td>Last Thing</td>
<td></td>
<td></td>
<td></td>
<td>4</td>
<td>Meaning of Life</td>
<td></td>
</tr>
</tbody>
</table>
<h2>Options</h2>
<p>
<strong>myClass:</strong> Space separated classes to add to the table.<br/>
<strong>headIndex:</strong> Use this to specify the row index of the header, in case it isn’t the first.
</p>
<h2>Card Table</h2>
<p>Card table works similarly to stack table except it breaks each row into its own table. The row tables function like cards. Any content left in tfoot is also broken into its own card, this allows for things like view all links or pagination to be easily used.</p>
<pre>$('#responsive-card-table-example').cardtable();</pre>
<table id="card-table" class="table">
<thead>
<tr>
<th width="30%">Name</th>
<th width="30%">Phone</th>
<th width="30%">Info</th>
<th width="10%">Actions</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Test
</td>
<td>
555-555-5555
</td>
<td>
I am a test
</td>
<td>
<a href="#">Edit</a>
</td>
</tr>
<tr>
<td>
Greg
</td>
<td>
555-555-5555
</td>
<td>
This is an example
</td>
<td>
<a href="#">Edit</a>
</td>
</tr>
<tr>
<td>
John
</td>
<td>
444-444-4444
</td>
<td>
Tables are cool
</td>
<td>
<a href="#">Edit</a>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="4">
<a href="#">View all</a>
</td>
</tr>
</tfoot>
</table>
<h2>StackColumns</h2>
<p>An alternative responsive design creates a copy of the table into a 2 column key/value format that preserves the columns of the original table. We call it <em>stackcolumns</em> to contrast with the default <em>stacktables</em> that preserves the lines of the original table.</p>
<pre>$('#responsive-stackcolumns-example').stackcolumns();</pre>
<table id="agenda-example">
<!-- thead not supported by stacktable yet; neither is <th> in <tbody>; but the later is working in stackcolumns.
<thead>
<tr>
<th>Time</th>
<th>Day 1</th>
<th>Day 2</th>
</tr>
</thead>
<tfoot>
<tr>
<td>night</td>
<td>rest</td>
<td>party</td>
</tr>
</tfoot> -->
<tbody>
<tr>
<th>Time</th>
<th>Day 1</th>
<th>Day 2</th>
<th>Day 3</th>
<th>Day 4</th>
</tr>
<tr>
<td>8 AM</td>
<td style="text-align:center; background:#DFD" colspan="2">breakfast</td>
<td style="text-align:center; background:#FDD" colspan="2"> ------ </td>
</tr>
<tr>
<td>10 AM</td>
<td>work</td>
<td>work</td>
<td style="text-align:center; background:#DDF" colspan="2">breakfast</td>
</tr>
<tr>
<th>12AM</th>
<td style="text-align:center; " colspan="3">lunch</td>
<td>run</td>
</tr>
<tr>
<td>1 PM</td>
<!--<td rowspan="2" style="text-align:center; background:#DDF">work <br/>& read</td> <!-- not supported by tablestack yet -->
<td>work <br/>
<td>work <br/>
<td>beach</td>
<td class="sub">lunch</td>
</tr>
<tr>
<td>4 PM</td>
<td>work <br/>
<td>beach</td>
<td>beach</td>
<td>bike</td>
</tr>
<tr>
<td>night</td>
<td>rest</td>
<td>rest</td>
<td>party</td>
<td>rest</td>
</tr>
</tbody>
</table>
<div class="footer-ad">
<a target="_blank" href="http://shareasale.com/r.cfm?b=492491&u=471107&m=45652&urllink=&afftrack="><img src="http://static.shareasale.com/image/45652/728.90.jpg" border="0" alt="Sell your Macbook for cash with gazelle" /></a>
</div>
<img src="resize.png" id="resize-graphic" />
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.min.js"><\/script>')</script> </script>
<script src="stacktable.js" type="text/javascript"></script>
<script>
$(document).on('click', '#run', function(e) {
e.preventDefault();
$('#simple-example-table').stacktable();
$(this).replaceWith('<span>ran - resize your window to see the effect</span>');
});
$('#responsive-example-table').stacktable({myClass:'your-custom-class'});
$('#card-table').cardtable();
$('#agenda-example').stackcolumns();
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2821890-9']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>