| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta charset="utf-8"> |
| 5 |
<title>jQuery tablesorter 2.0 - Table Reflow Widget (beta)</title> |
| 6 |
|
| 7 |
|
| 8 |
<link rel="stylesheet" href="css/jq.css"> |
| 9 |
|
| 10 |
|
| 11 |
<script src="js/jquery-latest.min.js"></script> |
| 12 |
|
| 13 |
|
| 14 |
<link rel="stylesheet" href="../css/theme.blue.css"> |
| 15 |
<script src="../js/jquery.tablesorter.js"></script> |
| 16 |
<script src="../js/jquery.tablesorter.widgets.js"></script> |
| 17 |
<script src="../js/widgets/widget-reflow.js"></script> |
| 18 |
|
| 19 |
<style> |
| 20 |
/* REQUIRED CSS: change your reflow breakpoint here (35em below) */ |
| 21 |
@media ( max-width: 35em ) { |
| 22 |
.ui-table-reflow td, |
| 23 |
.ui-table-reflow th { |
| 24 |
-webkit-box-sizing: border-box; |
| 25 |
-moz-box-sizing: border-box; |
| 26 |
box-sizing: border-box; |
| 27 |
float: right; |
| 28 |
/* if not using the stickyHeaders widget (not the css3 version) |
| 29 |
* the "!important" flag, and "height: auto" can be removed */ |
| 30 |
width: 100% !important; |
| 31 |
height: auto !important; |
| 32 |
} |
| 33 |
/* reflow widget */ |
| 34 |
.ui-table-reflow tbody td[data-title]:before { |
| 35 |
color: #469; |
| 36 |
font-size: .9em; |
| 37 |
content: attr(data-title); |
| 38 |
float: left; |
| 39 |
width: 50%; |
| 40 |
white-space: pre-wrap; |
| 41 |
text-align: bottom; |
| 42 |
display: inline-block; |
| 43 |
} |
| 44 |
/* allow toggle of thead */ |
| 45 |
thead.hide-header { |
| 46 |
display: none; |
| 47 |
} |
| 48 |
} |
| 49 |
.ui-table-reflow .ui-table-cell-label { |
| 50 |
display: none; |
| 51 |
} |
| 52 |
</style> |
| 53 |
<script>$(function() { |
| 54 |
|
| 55 |
// simple reflow widget (table with 1 header row) |
| 56 |
$("#table1").tablesorter({ |
| 57 |
theme: 'blue', |
| 58 |
widgets: ['zebra', 'reflow'], |
| 59 |
widgetOptions : { |
| 60 |
// class name added to make it responsive (class name within media query) |
| 61 |
reflow_className : 'ui-table-reflow', |
| 62 |
// header attribute containing modified header name |
| 63 |
reflow_headerAttrib : 'data-name', |
| 64 |
// data attribute added to each tbody cell |
| 65 |
// it contains the header cell text, visible upon reflow |
| 66 |
reflow_dataAttrib : 'data-title' |
| 67 |
} |
| 68 |
}); |
| 69 |
|
| 70 |
});</script> |
| 71 |
</head> |
| 72 |
<body> |
| 73 |
|
| 74 |
<table id="table1"> |
| 75 |
<thead> |
| 76 |
<tr> |
| 77 |
<th>Rank</th> |
| 78 |
<th>Age</th> |
| 79 |
<th>Total</th> |
| 80 |
<th>Discount</th> |
| 81 |
<th>Date</th> |
| 82 |
</tr> |
| 83 |
</thead> |
| 84 |
<tbody> |
| 85 |
<tr><td>1</td><td>25</td><td>$5.95</td><td>22%</td><td>Jun 26, 2013 7:22 AM</td></tr> |
| 86 |
<tr><td>11</td><td>12</td><td>$82.99</td><td>5%</td><td>Aug 21, 2013 12:21 PM</td></tr> |
| 87 |
<tr><td>12</td><td>51</td><td>$99.29</td><td>18%</td><td>Oct 13, 2013 1:15 PM</td></tr> |
| 88 |
<tr><td>51</td><td>28</td><td>$9.99</td><td>20%</td><td>Jul 6, 2013 8:14 AM</td></tr> |
| 89 |
<tr><td>21</td><td>33</td><td>$19.99</td><td>25%</td><td>Dec 10, 2012 5:14 AM</td></tr> |
| 90 |
<tr><td>013</td><td>18</td><td>$65.89</td><td>45%</td><td>Jan 12, 2013 11:14 AM</td></tr> |
| 91 |
<tr><td>005</td><td>45</td><td>$153.19</td><td>45%</td><td>Jan 18, 2014 9:12 AM</td></tr> |
| 92 |
<tr><td>10</td><td>3</td><td>$5.29</td><td>4%</td><td>Jan 8, 2013 5:11 PM</td></tr> |
| 93 |
<tr><td>16</td><td>24</td><td>$14.19</td><td>14%</td><td>Jan 14, 2014 11:23 AM</td></tr> |
| 94 |
<tr><td>66</td><td>22</td><td>$13.19</td><td>11%</td><td>Jan 18, 2013 9:12 AM</td></tr> |
| 95 |
<tr><td>100</td><td>18</td><td>$55.20</td><td>15%</td><td>Feb 12, 2013 7:23 PM</td></tr> |
| 96 |
<tr><td>55</td><td>65</td><td>$123.00</td><td>32%</td><td>Jan 20, 2014 1:12 PM</td></tr> |
| 97 |
<tr><td>9</td><td>25</td><td>$22.09</td><td>17%</td><td>Jun 11, 2013 10:55 AM</td></tr> |
| 98 |
<tr><td>13</td><td>12</td><td>$19.99</td><td>18%</td><td>Jan 20, 2014 7:45 PM</td></tr> |
| 99 |
<tr><td>73</td><td>58</td><td>$129.19</td><td>39%</td><td>Jan 20, 2014 10:11 AM</td></tr> |
| 100 |
</tbody> |
| 101 |
</table> |
| 102 |
|
| 103 |
</body> |
| 104 |
</html> |