| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta charset="utf-8"> |
| 5 |
<title>jQuery tablesorter 2.0 - CSS Column & Row Highlights</title> |
| 6 |
|
| 7 |
|
| 8 |
<script src="js/jquery-latest.min.js"></script> |
| 9 |
|
| 10 |
|
| 11 |
<link rel="stylesheet" href="css/jq.css"> |
| 12 |
<link href="css/prettify.css" rel="stylesheet"> |
| 13 |
<script src="js/prettify.js"></script> |
| 14 |
<script src="js/docs.js"></script> |
| 15 |
|
| 16 |
|
| 17 |
<link rel="stylesheet" href="../css/theme.blue.css"> |
| 18 |
<script src="../js/jquery.tablesorter.js"></script> |
| 19 |
|
| 20 |
<style> |
| 21 |
html { |
| 22 |
box-sizing: border-box; |
| 23 |
} |
| 24 |
*, *:before, *:after { |
| 25 |
box-sizing: inherit; |
| 26 |
} |
| 27 |
.block { |
| 28 |
width: 33.3%; |
| 29 |
float: left; |
| 30 |
padding: 10px; |
| 31 |
} |
| 32 |
@media all and (max-width: 1300px) { |
| 33 |
.block { width: 50%; } |
| 34 |
} |
| 35 |
@media all and (max-width: 900px) { |
| 36 |
.block { float: none; width: 100%; } |
| 37 |
} |
| 38 |
.hover-hl { color: #990; } |
| 39 |
.focus-hl { color: #3aa3c5; } |
| 40 |
</style> |
| 41 |
<style id="css">/* TABLE BACKGROUND color (match the original theme) */ |
| 42 |
table.hover-highlight td:before, |
| 43 |
table.focus-highlight td:before { |
| 44 |
background: #fff; |
| 45 |
} |
| 46 |
|
| 47 |
/* ODD ZEBRA STRIPE color (needs zebra widget) */ |
| 48 |
.hover-highlight .odd td:before, .hover-highlight .odd th:before, |
| 49 |
.focus-highlight .odd td:before, .focus-highlight .odd th:before { |
| 50 |
background: #ebf2fa; |
| 51 |
} |
| 52 |
/* EVEN ZEBRA STRIPE color (needs zebra widget) */ |
| 53 |
.hover-highlight .even td:before, .hover-highlight .even th:before, |
| 54 |
.focus-highlight .even td:before, .focus-highlight .even th:before { |
| 55 |
background-color: #fff; |
| 56 |
} |
| 57 |
|
| 58 |
/* FOCUS ROW highlight color (touch devices) */ |
| 59 |
.focus-highlight td:focus::before, .focus-highlight th:focus::before { |
| 60 |
background-color: lightblue; |
| 61 |
} |
| 62 |
/* FOCUS COLUMN highlight color (touch devices) */ |
| 63 |
.focus-highlight td:focus::after, .focus-highlight th:focus::after { |
| 64 |
background-color: lightblue; |
| 65 |
} |
| 66 |
/* FOCUS CELL highlight color */ |
| 67 |
.focus-highlight th:focus, .focus-highlight td:focus, |
| 68 |
.focus-highlight .even th:focus, .focus-highlight .even td:focus, |
| 69 |
.focus-highlight .odd th:focus, .focus-highlight .odd td:focus { |
| 70 |
background-color: #d9d9d9; |
| 71 |
color: #333; |
| 72 |
} |
| 73 |
|
| 74 |
/* HOVER ROW highlight colors */ |
| 75 |
table.hover-highlight tbody > tr:hover > td, /* override tablesorter theme row hover */ |
| 76 |
table.hover-highlight tbody > tr.odd:hover > td, |
| 77 |
table.hover-highlight tbody > tr.even:hover > td { |
| 78 |
background-color: #ffa; |
| 79 |
} |
| 80 |
/* HOVER COLUMN highlight colors */ |
| 81 |
.hover-highlight tbody tr td:hover::after, |
| 82 |
.hover-highlight tbody tr th:hover::after { |
| 83 |
background-color: #ffa; |
| 84 |
} |
| 85 |
|
| 86 |
/* ************************************************* */ |
| 87 |
/* **** No need to modify the definitions below **** */ |
| 88 |
/* ************************************************* */ |
| 89 |
.focus-highlight td:focus::after, .focus-highlight th:focus::after, |
| 90 |
.hover-highlight td:hover::after, .hover-highlight th:hover::after { |
| 91 |
content: ''; |
| 92 |
position: absolute; |
| 93 |
width: 100%; |
| 94 |
height: 999em; |
| 95 |
left: 0; |
| 96 |
top: -555em; |
| 97 |
z-index: -1; |
| 98 |
} |
| 99 |
.focus-highlight td:focus::before, .focus-highlight th:focus::before { |
| 100 |
content: ''; |
| 101 |
position: absolute; |
| 102 |
width: 999em; |
| 103 |
height: 100%; |
| 104 |
left: -555em; |
| 105 |
top: 0; |
| 106 |
z-index: -2; |
| 107 |
} |
| 108 |
/* required styles */ |
| 109 |
.hover-highlight, |
| 110 |
.focus-highlight { |
| 111 |
overflow: hidden; |
| 112 |
} |
| 113 |
.hover-highlight td, .hover-highlight th, |
| 114 |
.focus-highlight td, .focus-highlight th { |
| 115 |
position: relative; |
| 116 |
outline: 0; |
| 117 |
} |
| 118 |
/* override the tablesorter theme styling */ |
| 119 |
table.hover-highlight, table.hover-highlight tbody > tr > td, |
| 120 |
table.focus-highlight, table.focus-highlight tbody > tr > td, |
| 121 |
/* override zebra styling */ |
| 122 |
table.hover-highlight tbody tr.even > th, |
| 123 |
table.hover-highlight tbody tr.even > td, |
| 124 |
table.hover-highlight tbody tr.odd > th, |
| 125 |
table.hover-highlight tbody tr.odd > td, |
| 126 |
table.focus-highlight tbody tr.even > th, |
| 127 |
table.focus-highlight tbody tr.even > td, |
| 128 |
table.focus-highlight tbody tr.odd > th, |
| 129 |
table.focus-highlight tbody tr.odd > td { |
| 130 |
background: transparent; |
| 131 |
} |
| 132 |
/* table background positioned under the highlight */ |
| 133 |
table.hover-highlight td:before, |
| 134 |
table.focus-highlight td:before { |
| 135 |
content: ''; |
| 136 |
position: absolute; |
| 137 |
width: 100%; |
| 138 |
height: 100%; |
| 139 |
left: 0; |
| 140 |
top: 0; |
| 141 |
z-index: -3; |
| 142 |
}</style> |
| 143 |
|
| 144 |
<script id="js">$(function() { |
| 145 |
// call the tablesorter plugin |
| 146 |
$("table").tablesorter({ |
| 147 |
theme: 'blue' |
| 148 |
}); |
| 149 |
|
| 150 |
// Make table cell focusable |
| 151 |
// http://css-tricks.com/simple-css-row-column-highlighting/ |
| 152 |
if ( $('.focus-highlight').length ) { |
| 153 |
$('.focus-highlight').find('td, th') |
| 154 |
.attr('tabindex', '1') |
| 155 |
// add touch device support |
| 156 |
.on('touchstart', function() { |
| 157 |
$(this).focus(); |
| 158 |
}); |
| 159 |
} |
| 160 |
|
| 161 |
});</script> |
| 162 |
</head> |
| 163 |
<body> |
| 164 |
<div id="banner"> |
| 165 |
<h1>table<em>sorter</em></h1> |
| 166 |
<h2>CSS Column & Row Highlights</h2> |
| 167 |
<h3>Flexible client-side table sorting</h3> |
| 168 |
<a href="index.html">Back to documentation</a> |
| 169 |
</div> |
| 170 |
<div id="main"> |
| 171 |
|
| 172 |
<p class="tip"> |
| 173 |
<em>NOTE!</em> |
| 174 |
</p> |
| 175 |
<ul> |
| 176 |
<li>The css in this demo only works with <a href="http://caniuse.com/#feat=css-gencontent">modern browsers</a> (IE9+).</li> |
| 177 |
<li>This css is originally from this <a href="http://css-tricks.com/simple-css-row-column-highlighting/">CSS-Tricks</a> article; it has been modified to work with tablesorter themes.</li> |
| 178 |
<li> |
| 179 |
It does not work properly on cells with <code>rowspan</code> or <code>colspan</code> within the <code>tbody</code> (I am referring to info-only tbodies, since tablesorter does not yet support sorting with these spans); if you do need a script to highlight spanned columns & rows, then take a look at the <a href="https://github.com/gajus/wholly">wholly</a> plugin. |
| 180 |
<p></p> |
| 181 |
</li> |
| 182 |
<li>To add <strong class="hover-hl">Hover</strong> Highlighting: |
| 183 |
<ul> |
| 184 |
<li>Add a class name of <code>"<span class="hover-hl">hover-highlight</span>"</code> to the <code>table</code> to enable hover row and column highlighting.</li> |
| 185 |
<li>Include the CSS shown on this page.</li> |
| 186 |
<li>If needed, modify the table background color & zebra striping row colors.</li> |
| 187 |
<li>Modify the hover highlight row and/or column color definitions as desired (they can be different colors).</li> |
| 188 |
</ul> |
| 189 |
<p></p> |
| 190 |
</li> |
| 191 |
<li>To add <strong class="focus-hl">Focus</strong> Highlighting: |
| 192 |
<ul> |
| 193 |
<li>Add a class name of <code>"<span class="focus-hl">focus-highlight</span>"</code> to the <code>table</code> to enable focused cell with row and column highlighting.</li> |
| 194 |
<li>Click on a table cell in the demo below to see the highlight; only <em>one element</em>, per page, can be active at a time.</li> |
| 195 |
<li>Include the CSS and the extra javascript shown on this page to make table cells focusable.</li> |
| 196 |
<li>If needed, modify the table background color & zebra striping row colors.</li> |
| 197 |
<li>Modify the focus highlight row and/or column color definitions as desired (they can be different colors).</li> |
| 198 |
</ul> |
| 199 |
</li> |
| 200 |
</ul> |
| 201 |
|
| 202 |
<h1>Demo</h1> |
| 203 |
<div id="demo"> |
| 204 |
|
| 205 |
<div class="block"> |
| 206 |
<h1><span class="hover-hl">Hover</span> + <span class="focus-hl">Focus</span> Highlight</h1> |
| 207 |
<table class="tablesorter hover-highlight focus-highlight"> |
| 208 |
<thead> |
| 209 |
<tr><th>Account #</th><th>First Name</th><th>Last Name</th><th>Age</th><th>Total</th><th>Discount</th><th>Diff</th></tr> |
| 210 |
</thead> |
| 211 |
<tbody> |
| 212 |
<tr><td>A43</td><td>Peter</td><td>Parker</td><td>28</td><td>9.99</td><td>20.3%</td><td>+3</td></tr> |
| 213 |
<tr><td>A255</td><td>John</td><td>Hood</td><td>33</td><td>19.99</td><td>25.1%</td><td>-7</td></tr> |
| 214 |
<tr><td>A33</td><td>Clark</td><td>Kent</td><td>18</td><td>2.89</td><td>44.2%</td><td>-15</td></tr> |
| 215 |
<tr><td>A1</td><td>Bruce</td><td>Almighty</td><td>45</td><td>153.19</td><td>44%</td><td>+19</td></tr> |
| 216 |
<tr><td>A102</td><td>Bruce</td><td>Evans</td><td>56</td><td>$153.19</td><td>23%</td><td>+9</td></tr> |
| 217 |
<tr><td>A256</td><td>John</td><td>Clark</td><td>44</td><td>($19.89)</td><td>25.1%</td><td>(5)</td></tr> |
| 218 |
<tr><td>A23</td><td>Elvis</td><td>Presley</td><td>24</td><td>($9.99)</td><td>50%</td><td>(22)</td></tr> |
| 219 |
<tr><td>A10</td><td>Frank</td><td>Carter</td><td>40</td><td>-12.99</td><td>20%</td><td>(6)</td></tr> |
| 220 |
</tbody> |
| 221 |
</table> |
| 222 |
</div> |
| 223 |
|
| 224 |
<div class="block"> |
| 225 |
<h1><span class="hover-hl">Hover</span> Highlight Only</h1> |
| 226 |
<table class="tablesorter hover-highlight"> |
| 227 |
<thead> |
| 228 |
<tr><th>Account #</th><th>First Name</th><th>Last Name</th><th>Age</th><th>Total</th><th>Discount</th><th>Diff</th></tr> |
| 229 |
</thead> |
| 230 |
<tbody> |
| 231 |
<tr><td>A43</td><td>Peter</td><td>Parker</td><td>28</td><td>9.99</td><td>20.3%</td><td>+3</td></tr> |
| 232 |
<tr><td>A255</td><td>John</td><td>Hood</td><td>33</td><td>19.99</td><td>25.1%</td><td>-7</td></tr> |
| 233 |
<tr><td>A33</td><td>Clark</td><td>Kent</td><td>18</td><td>2.89</td><td>44.2%</td><td>-15</td></tr> |
| 234 |
<tr><td>A1</td><td>Bruce</td><td>Almighty</td><td>45</td><td>153.19</td><td>44%</td><td>+19</td></tr> |
| 235 |
<tr><td>A102</td><td>Bruce</td><td>Evans</td><td>56</td><td>$153.19</td><td>23%</td><td>+9</td></tr> |
| 236 |
<tr><td>A256</td><td>John</td><td>Clark</td><td>44</td><td>($19.89)</td><td>25.1%</td><td>(5)</td></tr> |
| 237 |
<tr><td>A23</td><td>Elvis</td><td>Presley</td><td>24</td><td>($9.99)</td><td>50%</td><td>(22)</td></tr> |
| 238 |
<tr><td>A10</td><td>Frank</td><td>Carter</td><td>40</td><td>-12.99</td><td>20%</td><td>(6)</td></tr> |
| 239 |
</tbody> |
| 240 |
</table> |
| 241 |
</div> |
| 242 |
|
| 243 |
<div class="block"> |
| 244 |
<h1><span class="focus-hl">Focus</span> Highlight Only <small>(click on a tbody cell)</small></h1> |
| 245 |
<table class="tablesorter focus-highlight"> |
| 246 |
<thead> |
| 247 |
<tr><th>Account #</th><th>First Name</th><th>Last Name</th><th>Age</th><th>Total</th><th>Discount</th><th>Diff</th></tr> |
| 248 |
</thead> |
| 249 |
<tbody> |
| 250 |
<tr><td>A43</td><td>Peter</td><td>Parker</td><td>28</td><td>9.99</td><td>20.3%</td><td>+3</td></tr> |
| 251 |
<tr><td>A255</td><td>John</td><td>Hood</td><td>33</td><td>19.99</td><td>25.1%</td><td>-7</td></tr> |
| 252 |
<tr><td>A33</td><td>Clark</td><td>Kent</td><td>18</td><td>2.89</td><td>44.2%</td><td>-15</td></tr> |
| 253 |
<tr><td>A1</td><td>Bruce</td><td>Almighty</td><td>45</td><td>153.19</td><td>44%</td><td>+19</td></tr> |
| 254 |
<tr><td>A102</td><td>Bruce</td><td>Evans</td><td>56</td><td>$153.19</td><td>23%</td><td>+9</td></tr> |
| 255 |
<tr><td>A256</td><td>John</td><td>Clark</td><td>44</td><td>($19.89)</td><td>25.1%</td><td>(5)</td></tr> |
| 256 |
<tr><td>A23</td><td>Elvis</td><td>Presley</td><td>24</td><td>($9.99)</td><td>50%</td><td>(22)</td></tr> |
| 257 |
<tr><td>A10</td><td>Frank</td><td>Carter</td><td>40</td><td>-12.99</td><td>20%</td><td>(6)</td></tr> |
| 258 |
</tbody> |
| 259 |
</table> |
| 260 |
</div> |
| 261 |
|
| 262 |
<div class="block"> |
| 263 |
<h1>Zebra + <span class="hover-hl">Hover</span> + <span class="focus-hl">Focus</span> Highlight</h1> |
| 264 |
<table class="tablesorter hover-highlight focus-highlight widget-zebra"> |
| 265 |
<thead> |
| 266 |
<tr><th>Account #</th><th>First Name</th><th>Last Name</th><th>Age</th><th>Total</th><th>Discount</th><th>Diff</th></tr> |
| 267 |
</thead> |
| 268 |
<tbody> |
| 269 |
<tr><td>A43</td><td>Peter</td><td>Parker</td><td>28</td><td>9.99</td><td>20.3%</td><td>+3</td></tr> |
| 270 |
<tr><td>A255</td><td>John</td><td>Hood</td><td>33</td><td>19.99</td><td>25.1%</td><td>-7</td></tr> |
| 271 |
<tr><td>A33</td><td>Clark</td><td>Kent</td><td>18</td><td>2.89</td><td>44.2%</td><td>-15</td></tr> |
| 272 |
<tr><td>A1</td><td>Bruce</td><td>Almighty</td><td>45</td><td>153.19</td><td>44%</td><td>+19</td></tr> |
| 273 |
<tr><td>A102</td><td>Bruce</td><td>Evans</td><td>56</td><td>$153.19</td><td>23%</td><td>+9</td></tr> |
| 274 |
<tr><td>A256</td><td>John</td><td>Clark</td><td>44</td><td>($19.89)</td><td>25.1%</td><td>(5)</td></tr> |
| 275 |
<tr><td>A23</td><td>Elvis</td><td>Presley</td><td>24</td><td>($9.99)</td><td>50%</td><td>(22)</td></tr> |
| 276 |
<tr><td>A10</td><td>Frank</td><td>Carter</td><td>40</td><td>-12.99</td><td>20%</td><td>(6)</td></tr> |
| 277 |
</tbody> |
| 278 |
</table> |
| 279 |
</div> |
| 280 |
|
| 281 |
<div class="block"> |
| 282 |
<h1>Zebra + <span class="hover-hl">Hover</span> Highlight Only</h1> |
| 283 |
<table class="tablesorter hover-highlight widget-zebra"> |
| 284 |
<thead> |
| 285 |
<tr><th>Account #</th><th>First Name</th><th>Last Name</th><th>Age</th><th>Total</th><th>Discount</th><th>Diff</th></tr> |
| 286 |
</thead> |
| 287 |
<tbody> |
| 288 |
<tr><td>A43</td><td>Peter</td><td>Parker</td><td>28</td><td>9.99</td><td>20.3%</td><td>+3</td></tr> |
| 289 |
<tr><td>A255</td><td>John</td><td>Hood</td><td>33</td><td>19.99</td><td>25.1%</td><td>-7</td></tr> |
| 290 |
<tr><td>A33</td><td>Clark</td><td>Kent</td><td>18</td><td>2.89</td><td>44.2%</td><td>-15</td></tr> |
| 291 |
<tr><td>A1</td><td>Bruce</td><td>Almighty</td><td>45</td><td>153.19</td><td>44%</td><td>+19</td></tr> |
| 292 |
<tr><td>A102</td><td>Bruce</td><td>Evans</td><td>56</td><td>$153.19</td><td>23%</td><td>+9</td></tr> |
| 293 |
<tr><td>A256</td><td>John</td><td>Clark</td><td>44</td><td>($19.89)</td><td>25.1%</td><td>(5)</td></tr> |
| 294 |
<tr><td>A23</td><td>Elvis</td><td>Presley</td><td>24</td><td>($9.99)</td><td>50%</td><td>(22)</td></tr> |
| 295 |
<tr><td>A10</td><td>Frank</td><td>Carter</td><td>40</td><td>-12.99</td><td>20%</td><td>(6)</td></tr> |
| 296 |
</tbody> |
| 297 |
</table> |
| 298 |
</div> |
| 299 |
|
| 300 |
<div class="block"> |
| 301 |
<h1>Zebra + <span class="focus-hl">Focus</span> Highlight Only <small>(click on a tbody cell)</small></h1> |
| 302 |
<table class="tablesorter focus-highlight widget-zebra"> |
| 303 |
<thead> |
| 304 |
<tr><th>Account #</th><th>First Name</th><th>Last Name</th><th>Age</th><th>Total</th><th>Discount</th><th>Diff</th></tr> |
| 305 |
</thead> |
| 306 |
<tbody> |
| 307 |
<tr><td>A43</td><td>Peter</td><td>Parker</td><td>28</td><td>9.99</td><td>20.3%</td><td>+3</td></tr> |
| 308 |
<tr><td>A255</td><td>John</td><td>Hood</td><td>33</td><td>19.99</td><td>25.1%</td><td>-7</td></tr> |
| 309 |
<tr><td>A33</td><td>Clark</td><td>Kent</td><td>18</td><td>2.89</td><td>44.2%</td><td>-15</td></tr> |
| 310 |
<tr><td>A1</td><td>Bruce</td><td>Almighty</td><td>45</td><td>153.19</td><td>44%</td><td>+19</td></tr> |
| 311 |
<tr><td>A102</td><td>Bruce</td><td>Evans</td><td>56</td><td>$153.19</td><td>23%</td><td>+9</td></tr> |
| 312 |
<tr><td>A256</td><td>John</td><td>Clark</td><td>44</td><td>($19.89)</td><td>25.1%</td><td>(5)</td></tr> |
| 313 |
<tr><td>A23</td><td>Elvis</td><td>Presley</td><td>24</td><td>($9.99)</td><td>50%</td><td>(22)</td></tr> |
| 314 |
<tr><td>A10</td><td>Frank</td><td>Carter</td><td>40</td><td>-12.99</td><td>20%</td><td>(6)</td></tr> |
| 315 |
</tbody> |
| 316 |
</table> |
| 317 |
</div> |
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
</div> |
| 322 |
<br class="clear"/> |
| 323 |
|
| 324 |
<h1>Page Header</h1> |
| 325 |
<div> |
| 326 |
<pre class="prettyprint lang-html"><!-- Add any theme; the css for highlighting may need modification |
| 327 |
to match the selected theme, if it isn't the "blue" theme --> |
| 328 |
<link href="css/theme.blue.css" rel="stylesheet"> |
| 329 |
<script src="js/jquery.min.js"></script> |
| 330 |
<script src="js/jquery.tablesorter.js"></script></pre> |
| 331 |
</div> |
| 332 |
|
| 333 |
<h1>CSS</h1> |
| 334 |
<div id="css"> |
| 335 |
<pre class="prettyprint lang-css"></pre> |
| 336 |
</div> |
| 337 |
<h1>Javascript</h1> |
| 338 |
<div id="javascript"> |
| 339 |
<pre class="prettyprint lang-javascript"></pre> |
| 340 |
</div> |
| 341 |
|
| 342 |
</div> |
| 343 |
|
| 344 |
<script> |
| 345 |
/* highlight hover & focus selectors in the syntax highlighted code */ |
| 346 |
$(window).on('load', function() { |
| 347 |
setTimeout(function() { |
| 348 |
// css |
| 349 |
$('.pln:contains(highlight)').each(function() { |
| 350 |
var $this = $(this), |
| 351 |
$prev = $this.prev().prev(), |
| 352 |
text = $prev.text() || '', |
| 353 |
type = /hover/.test(text) ? 'hover-hl' : /focus/.test(text) ? 'focus-hl' : ''; |
| 354 |
if (type) { |
| 355 |
$this.html(function(i,h) { |
| 356 |
return h.replace('highlight', '<span>highlight</span>'); |
| 357 |
}); |
| 358 |
// "highlight".. "-" .... "hover"/"focus" ... "." |
| 359 |
$this.find('span').add( $prev ).add( $this.prev() ).add( $prev.prev() ).addClass(type); |
| 360 |
} |
| 361 |
}); |
| 362 |
// js |
| 363 |
$('.str:contains(focus-highlight)').addClass('focus-hl'); |
| 364 |
}, 500); |
| 365 |
}); |
| 366 |
</script> |
| 367 |
|
| 368 |
|
| 369 |
</body> |
| 370 |
</html> |