| 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 |
<script src="js/jquery-latest.min.js"></script> |
| 9 |
|
| 10 |
|
| 11 |
<link class="ui-theme" rel="stylesheet" href="css/jquery-ui.min.css"> |
| 12 |
<script src="js/jquery-ui.min.js"></script> |
| 13 |
<link rel="stylesheet" href="css/bootstrap-v3.min.css"> |
| 14 |
<script src="js/bootstrap.min.js"></script> |
| 15 |
<link rel="stylesheet" href="css/jq.css"> |
| 16 |
<link href="css/prettify.css" rel="stylesheet"> |
| 17 |
<script src="js/prettify.js"></script> |
| 18 |
<script src="js/docs.js"></script> |
| 19 |
|
| 20 |
|
| 21 |
<link rel="stylesheet" href="../css/theme.blue.css"> |
| 22 |
<script src="../js/jquery.tablesorter.js"></script> |
| 23 |
<script src="../js/jquery.tablesorter.widgets.js"></script> |
| 24 |
|
| 25 |
<style> |
| 26 |
/* override bootstrap link colors */ |
| 27 |
.ui-widget-content a { |
| 28 |
color: #428BCA; |
| 29 |
} |
| 30 |
.ui-widget-content a:hover { |
| 31 |
text-decoration: underline; |
| 32 |
} |
| 33 |
/*** column selector custom css only popup ***/ |
| 34 |
.columnSelectorWrapper { |
| 35 |
position: relative; |
| 36 |
margin: 10px 0; |
| 37 |
display: inline-block; |
| 38 |
} |
| 39 |
.columnSelector, .hidden { |
| 40 |
display: none; |
| 41 |
} |
| 42 |
.columnSelectorButton { |
| 43 |
background: #99bfe6; |
| 44 |
border: #888 1px solid; |
| 45 |
color: #111; |
| 46 |
border-radius: 5px; |
| 47 |
padding: 5px; |
| 48 |
} |
| 49 |
#colSelect1:checked + label { |
| 50 |
background: #5797d7; |
| 51 |
border-color: #555; |
| 52 |
} |
| 53 |
#colSelect1:checked ~ #columnSelector { |
| 54 |
display: block; |
| 55 |
} |
| 56 |
.columnSelector { |
| 57 |
width: 120px; |
| 58 |
position: absolute; |
| 59 |
top: 30px; |
| 60 |
padding: 10px; |
| 61 |
background: #fff; |
| 62 |
border: #99bfe6 1px solid; |
| 63 |
border-radius: 5px; |
| 64 |
} |
| 65 |
.columnSelector label { |
| 66 |
display: block; |
| 67 |
} |
| 68 |
.columnSelector label:nth-child(1) { |
| 69 |
border-bottom: #99bfe6 solid 1px; |
| 70 |
margin-bottom: 5px; |
| 71 |
} |
| 72 |
.columnSelector input { |
| 73 |
margin-right: 5px; |
| 74 |
} |
| 75 |
.columnSelector .disabled { |
| 76 |
color: #ddd; |
| 77 |
} |
| 78 |
.frame-wrapper { |
| 79 |
max-width: 98%; |
| 80 |
height: 250px; |
| 81 |
} |
| 82 |
iframe { |
| 83 |
width: 100%; |
| 84 |
height: 100%; |
| 85 |
} |
| 86 |
</style> |
| 87 |
<script src="../js/widgets/widget-columnSelector.js"></script> |
| 88 |
|
| 89 |
<style> |
| 90 |
/* REQUIRED CSS: change your reflow breakpoint here (35em below) */ |
| 91 |
@media ( max-width: 35em ) { |
| 92 |
.ui-table-reflow td, |
| 93 |
.ui-table-reflow th { |
| 94 |
-webkit-box-sizing: border-box; |
| 95 |
-moz-box-sizing: border-box; |
| 96 |
box-sizing: border-box; |
| 97 |
float: right; |
| 98 |
/* if not using the stickyHeaders widget (not the css3 version) |
| 99 |
* the "!important" flag, and "height: auto" can be removed */ |
| 100 |
width: 100% !important; |
| 101 |
height: auto !important; |
| 102 |
} |
| 103 |
/* reflow widget */ |
| 104 |
.ui-table-reflow tbody td[data-title]:before { |
| 105 |
color: #469; |
| 106 |
font-size: .9em; |
| 107 |
content: attr(data-title); |
| 108 |
float: left; |
| 109 |
width: 50%; |
| 110 |
white-space: pre-wrap; |
| 111 |
text-align: bottom; |
| 112 |
display: inline-block; |
| 113 |
} |
| 114 |
/* reflow2 widget */ |
| 115 |
table.ui-table-reflow .ui-table-cell-label.ui-table-cell-label-top { |
| 116 |
display: block; |
| 117 |
padding: .4em 0; |
| 118 |
margin: .4em 0; |
| 119 |
text-transform: uppercase; |
| 120 |
font-size: .9em; |
| 121 |
font-weight: 400; |
| 122 |
} |
| 123 |
table.ui-table-reflow .ui-table-cell-label { |
| 124 |
padding: .4em; |
| 125 |
min-width: 30%; |
| 126 |
display: inline-block; |
| 127 |
margin: -.4em 1em -.4em -.4em; |
| 128 |
} |
| 129 |
/* allow toggle of thead */ |
| 130 |
thead.hide-header { |
| 131 |
display: none; |
| 132 |
} |
| 133 |
} |
| 134 |
.ui-table-reflow .ui-table-cell-label { |
| 135 |
display: none; |
| 136 |
} |
| 137 |
</style> |
| 138 |
<script src="../js/widgets/widget-reflow.js"></script> |
| 139 |
<script> |
| 140 |
$(function() { |
| 141 |
$('#table1').resizable({ |
| 142 |
handles : 'e' |
| 143 |
}); |
| 144 |
}); |
| 145 |
</script> |
| 146 |
<script id="js">$(function() { |
| 147 |
|
| 148 |
// simple reflow widget (table with 1 header row) |
| 149 |
$("#table1").tablesorter({ |
| 150 |
theme: 'blue', |
| 151 |
widgets: ['zebra', 'reflow'], |
| 152 |
widgetOptions : { |
| 153 |
// class name added to make it responsive (class name within media query) |
| 154 |
reflow_className : 'ui-table-reflow', |
| 155 |
// header attribute containing modified header name |
| 156 |
reflow_headerAttrib : 'data-name', |
| 157 |
// data attribute added to each tbody cell |
| 158 |
// it contains the header cell text, visible upon reflow |
| 159 |
reflow_dataAttrib : 'data-title' |
| 160 |
} |
| 161 |
}); |
| 162 |
|
| 163 |
// simple reflow widget + columnSelector & stickyHeaders widgets |
| 164 |
$("#table2").tablesorter({ |
| 165 |
theme: 'blue', |
| 166 |
widgets: ['zebra', 'reflow', 'columnSelector', 'stickyHeaders'], |
| 167 |
widgetOptions : { |
| 168 |
// target the column selector markup |
| 169 |
columnSelector_container : $('#columnSelector'), |
| 170 |
// data attribute containing column name to use in the selector container |
| 171 |
// make it use the same as reflow_headerAttrib |
| 172 |
columnSelector_name : 'data-name', |
| 173 |
|
| 174 |
// header attribute containing modified header name |
| 175 |
reflow_headerAttrib : 'data-name' |
| 176 |
} |
| 177 |
}); |
| 178 |
|
| 179 |
// reflow2 widget (table with multiple header rows) |
| 180 |
$("#table3").tablesorter({ |
| 181 |
theme: 'blue', |
| 182 |
widgets: ['zebra', 'reflow2'], |
| 183 |
widgetOptions: { |
| 184 |
// class name added to make it responsive (class name within media query) |
| 185 |
reflow2_className : 'ui-table-reflow', |
| 186 |
// ignore header cell content with this class name |
| 187 |
reflow2_classIgnore : 'ui-table-reflow-ignore', |
| 188 |
// header attribute containing modified header name |
| 189 |
reflow2_headerAttrib : 'data-name', |
| 190 |
// class name applied to thead labels |
| 191 |
reflow2_labelClass : 'ui-table-cell-label', |
| 192 |
// class name applied to first row thead label |
| 193 |
reflow2_labelTop : 'ui-table-cell-label-top' |
| 194 |
} |
| 195 |
}); |
| 196 |
|
| 197 |
});</script> |
| 198 |
</head> |
| 199 |
<body> |
| 200 |
|
| 201 |
|
| 202 |
<div class="columnSelectorWrapper"> |
| 203 |
<input id="colSelect1" type="checkbox" class="hidden"> |
| 204 |
<label class="columnSelectorButton" for="colSelect1">Column</label> |
| 205 |
<div id="columnSelector" class="columnSelector"> |
| 206 |
|
| 207 |
</div> |
| 208 |
</div> (When "Auto" is set, the table becomes responsive; resize the browser window to see it work) |
| 209 |
|
| 210 |
<table id="table2"> |
| 211 |
<thead> |
| 212 |
<tr> |
| 213 |
<th data-priority="critical">Name</th> |
| 214 |
<th data-priority="critical">Major</th> |
| 215 |
<th data-priority="6" data-name="Gender">Sex</th> |
| 216 |
<th data-priority="4">English</th> |
| 217 |
<th data-priority="5">Japanese</th> |
| 218 |
<th data-priority="3">Calculus</th> |
| 219 |
<th data-priority="2">Geometry</th> |
| 220 |
</tr> |
| 221 |
</thead> |
| 222 |
<tfoot> |
| 223 |
<tr><th>Name</th><th>Major</th><th>Sex</th><th>English</th><th>Japanese</th><th>Calculus</th><th>Geometry</th></tr> |
| 224 |
</tfoot> |
| 225 |
<tbody> |
| 226 |
<tr><td>Student03</td><td>Languages</td><td>female</td><td>85</td><td>95</td><td>80</td><td>85</td></tr> |
| 227 |
<tr><td>Student04</td><td>Languages</td><td>male</td><td>60</td><td>55</td><td>100</td><td>100</td></tr> |
| 228 |
<tr><td>Student05</td><td>Languages</td><td>female</td><td>68</td><td>80</td><td>95</td><td>80</td></tr> |
| 229 |
<tr><td>Student12</td><td>Mathematics</td><td>female</td><td>100</td><td>75</td><td>70</td><td>85</td></tr> |
| 230 |
<tr><td>Student13</td><td>Languages</td><td>female</td><td>100</td><td>80</td><td>100</td><td>90</td></tr> |
| 231 |
<tr><td>Student14</td><td>Languages</td><td>female</td><td>50</td><td>45</td><td>55</td><td>90</td></tr> |
| 232 |
<tr><td>Student15</td><td>Languages</td><td>male</td><td>95</td><td>35</td><td>100</td><td>90</td></tr> |
| 233 |
<tr><td>Student16</td><td>Languages</td><td>female</td><td>100</td><td>50</td><td>30</td><td>70</td></tr> |
| 234 |
<tr><td>Student17</td><td>Languages</td><td>female</td><td>80</td><td>100</td><td>55</td><td>65</td></tr> |
| 235 |
<tr><td>Student18</td><td>Mathematics</td><td>male</td><td>30</td><td>49</td><td>55</td><td>75</td></tr> |
| 236 |
<tr><td>Student19</td><td>Languages</td><td>male</td><td>68</td><td>90</td><td>88</td><td>70</td></tr> |
| 237 |
<tr><td>Student20</td><td>Mathematics</td><td>male</td><td>40</td><td>45</td><td>40</td><td>80</td></tr> |
| 238 |
<tr><td>Student01</td><td>Languages</td><td>male</td><td>80</td><td>70</td><td>75</td><td>80</td></tr> |
| 239 |
<tr><td>Student02</td><td>Mathematics</td><td>male</td><td>90</td><td>88</td><td>100</td><td>90</td></tr> |
| 240 |
<tr><td>Student06</td><td>Mathematics</td><td>male</td><td>100</td><td>99</td><td>100</td><td>90</td></tr> |
| 241 |
<tr><td>Student07</td><td>Mathematics</td><td>male</td><td>85</td><td>68</td><td>90</td><td>90</td></tr> |
| 242 |
<tr><td>Student08</td><td>Languages</td><td>male</td><td>100</td><td>90</td><td>90</td><td>85</td></tr> |
| 243 |
<tr><td>Student09</td><td>Mathematics</td><td>male</td><td>80</td><td>50</td><td>65</td><td>75</td></tr> |
| 244 |
<tr><td>Student10</td><td>Languages</td><td>male</td><td>85</td><td>100</td><td>100</td><td>90</td></tr> |
| 245 |
<tr><td>Student11</td><td>Languages</td><td>male</td><td>86</td><td>85</td><td>100</td><td>100</td></tr> |
| 246 |
</tbody> |
| 247 |
</table> |
| 248 |
|
| 249 |
</body> |
| 250 |
</html> |