Skip to content

Commit 2a9e46b

Browse files
committed
Initial commit
0 parents  commit 2a9e46b

11 files changed

Lines changed: 748 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

.jshintrc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"boss": true,
3+
"curly": true,
4+
"eqeqeq": true,
5+
"eqnull": true,
6+
"expr": true,
7+
"immed": true,
8+
"noarg": true,
9+
"quotmark": "double",
10+
"smarttabs": true,
11+
"trailing": true,
12+
"undef": true,
13+
"unused": true,
14+
"devel": true,
15+
"jquery": true,
16+
"globals": {
17+
"$": false,
18+
"document": false
19+
}
20+
}

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Tablelight
2+
3+
## Overview
4+
5+
Tablelight highlights cells in a table that are in a certain numerical range, allowing the user to quickly spot relevant data or significant outliers. There are two versions of Tablelight.
6+
7+
* <a href="https://codepen.io/wurstrti/pen/bMGLOw" target="_blank">View a demo of Tablelight checkbox</a>
8+
* <a href="https://codepen.io/wurstrti/pen/JvjLWQ" target="_blank">View a demo of Tablelight slider</a>
9+
10+
### Tablelight Checkbox
11+
12+
![checkbox screenshot](./docs/images/checkbox.png "Checkbox version")
13+
14+
### Tablelight Slider
15+
16+
![slider screenshot](./docs/images/slider.png "Slider version")
17+
18+
## Dependencies
19+
20+
To run tablelight, you will need the following:
21+
22+
* <a href="http://jquery.com/download/" target="_blank">jQuery</a> (minimum version 1.4.1)
23+
* <a href="http://jqueryui.com/download/" target="_blank">jQuery UI</a> (minimum version - 1.7.1)
24+
25+
## How to use
26+
27+
### Tablelight Checkbox
28+
Tablelight checkbox highlights cells based on ranges selected by checkboxes. The js and css files can be found in the /checkbox directory along with a sample html file.
29+
30+
- /checkbox/js/tablelight_checkbox.js is the main JavaScript file
31+
- /checkbox/css/tablelight_checkbox.css provides some basic default files
32+
33+
You needs a `<fieldset id="tl-ranges"></fieldset>` element in your html to hold the range checkboxes. The range values themselves are held in an object called tlRanges with the keys:
34+
35+
- tl-neg
36+
- tl-a
37+
- tl-b
38+
- tl-c
39+
- tl-d
40+
41+
The tl-neg key-value pair is used to express negative values.
42+
43+
The table holding the data needs a class "tl-table." Configuration occurs in the variable definitions in the .on handler near the top of the tablelight_checkbox.js file:
44+
45+
* tableclasser - class of the data table. Default: tl-table
46+
* highlightbg - color value for highlighted cells. Default: #214f74
47+
* highlightfont - text color for highlighted cells. Default: #fff
48+
* lowlightbg - color of the non-selected cells. Default: transparent
49+
* lowlightfont - text color of the non-selected cells. Default: #222
50+
51+
### Tablelight Slider
52+
53+
Tablelight slider highlights cells based on ranges selected by a slider interface. The js and css files can be found in the /slider directory along with a sample html file.
54+
55+
- /slider/js/tablelight_slider.js is the main JavaScript file
56+
- /slider/css/tablelight.slider.css provides some default files
57+
58+
Your webpage will need a wrapper div `<div id="tl-range"></div>` for the slider and a div `<div id="tl-slider-range"></div>` inside of it. The default range for the slider is 0 - 100. If you wish to change the min and max values for the slider, change those parameters in the $( "#tl-slider-range" ).slider( { } ) configuration.
59+
60+
61+
The table holding the data needs a class "tl-table". Configuration occurs in the variable definitions at the top of the tablelight_slider.js file:
62+
63+
*Gradient colors*
64+
* colorstarter - minimum value gradient color
65+
* colorender - maximum value gradient color
66+
* More gradients can be found at [uigradients](https://uigradients.com)
67+
* tableclasser - class of the data table. Default: tl-table
68+
* highlightbg - color value for highlighted cells. Default: #214f74
69+
* highlightfont - text color for highlighted cells. Default: #ffffff
70+
* lowlightbg - color of the non-selected cells. Default: transparent
71+
* lowlightfont - text color of the non-selected cells. Default: #222
72+
* animatespeed - speed of the highlighting animation. Default: 2000
73+
* grad - show gradient or just solid color. 1 for gradient, 0 for solid color
74+
* maxcolor - color for 100% max value color. Default: colorender
75+
76+
## Authors
77+
78+
The authors of TableLight are Mark Koyanagi, Rebecca Watkins, and Keith Wurst.
79+
80+
## Acknowledgments
81+
82+
We would like to acknowledge David Rice for the assistance and support he provided with this project.
83+
84+
85+
## License
86+
87+
The MIT License (MIT)
88+
89+
Copyright (c) 2018
90+
91+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
92+
93+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
94+
95+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.tl-uncheck{
2+
cursor: pointer;
3+
display: inline-block;
4+
margin: 10px 0px;
5+
text-decoration: underline;
6+
}
7+
8+
table.tl-table, .tl-table th, .tl-table td {
9+
10+
padding: 5px;
11+
border-spacing: 10px;
12+
border: 1px solid #000000;
13+
14+
}

checkbox/index.html

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<!doctype html>
2+
3+
<html lang="en">
4+
<head>
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta charset="utf-8">
7+
8+
<title>tablelight checkbox</title>
9+
10+
<link rel="stylesheet" href="css/tablelight.checkbox.css">
11+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js" type="text/javascript" charset="utf-8"></script><!--min 1.7.1-->
12+
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script><!--min 1.9.1-->
13+
<script src="js/tablelight.checkbox.js" type="text/javascript"></script>
14+
15+
</head>
16+
17+
<body>
18+
19+
20+
<div>
21+
<fieldset id="tl-ranges"><legend>Select your ranges:</legend></fieldset>
22+
<div class="tl-uncheck" style="cursor:pointer;display:inline-block;margin:10px 0px;" role="button">Click here to uncheck all</div>
23+
</div>
24+
25+
<table class="tl-table">
26+
<caption>Brief table description here.</caption>
27+
<thead>
28+
<tr>
29+
<th scope="col">Name</th>
30+
<th scope="col">Col 1</th>
31+
<th scope="col">Col 2</th>
32+
<th scope="col">Col 3</th>
33+
<th scope="col">Col 4</th>
34+
<th scope="col">Col 5</th>
35+
<th scope="col">Col 6</th>
36+
<th scope="col">Col 7</th>
37+
<th scope="col">Col 8</th>
38+
<th scope="col">Col 9</th>
39+
<th scope="col">Col 10</th>
40+
<th scope="col">Col 11</th>
41+
<th scope="col">Col 12</th>
42+
</tr>
43+
</thead>
44+
<tbody>
45+
<tr>
46+
<th scope="row">Jorah</th>
47+
<td>14</td>
48+
<td>17</td>
49+
<td>-8</td>
50+
<td>9</td>
51+
<td>-5</td>
52+
<td>21</td>
53+
<td>13</td>
54+
<td>32</td>
55+
<td>76</td>
56+
<td>87</td>
57+
<td>89</td>
58+
<td>76</td>
59+
</tr>
60+
<tr>
61+
<th scope="row">Gregor</th>
62+
<td>31</td>
63+
<td>73</td>
64+
<td>-2</td>
65+
<td>30</td>
66+
<td>26</td>
67+
<td>45</td>
68+
<td>69</td>
69+
<td>69</td>
70+
<td>70</td>
71+
<td>67</td>
72+
<td>71</td>
73+
<td>69</td>
74+
</tr>
75+
<tr>
76+
<th scope="row">Cersei</th>
77+
<td>27</td>
78+
<td>0</td>
79+
<td>14</td>
80+
<td>23</td>
81+
<td>22</td>
82+
<td>42</td>
83+
<td>76</td>
84+
<td>76</td>
85+
<td>86</td>
86+
<td>90</td>
87+
<td>91</td>
88+
<td>90</td>
89+
</tr>
90+
<tr>
91+
<th scope="row">Tyrion</th>
92+
<td>-19</td>
93+
<td>8</td>
94+
<td>2</td>
95+
<td>0</td>
96+
<td>-8</td>
97+
<td>15</td>
98+
<td>23</td>
99+
<td>33</td>
100+
<td>40</td>
101+
<td>45</td>
102+
<td>63</td>
103+
<td>64</td>
104+
</tr>
105+
<tr>
106+
<th scope="row">Sansa</th>
107+
<td>-61</td>
108+
<td>-58</td>
109+
<td>-8</td>
110+
<td>-59</td>
111+
<td>-33</td>
112+
<td>13</td>
113+
<td>63</td>
114+
<td>59</td>
115+
<td>61</td>
116+
<td>57</td>
117+
<td>64</td>
118+
<td>70</td>
119+
</tr>
120+
<tr>
121+
<th scope="row">Joffrey</th>
122+
<td>6</td>
123+
<td>-8</td>
124+
<td>41</td>
125+
<td>62</td>
126+
<td>64</td>
127+
<td>61</td>
128+
<td>40</td>
129+
<td>52</td>
130+
<td>54</td>
131+
<td>75</td>
132+
<td>78</td>
133+
<td>76</td>
134+
</tr>
135+
<tr>
136+
<th scope="row">Bronn</th>
137+
<td>-12</td>
138+
<td>-45</td>
139+
<td>-63</td>
140+
<td>-23</td>
141+
<td>-17</td>
142+
<td>1</td>
143+
<td>-35</td>
144+
<td>-1</td>
145+
<td>59</td>
146+
<td>41</td>
147+
<td>48</td>
148+
<td>70</td>
149+
</tr>
150+
</tbody>
151+
</table>
152+
153+
154+
155+
</body>
156+
</html>

checkbox/js/tablelight.checkbox.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Licensed under the MIT license.
2+
3+
$( function() {
4+
var tlRanges = {
5+
"tl-neg": "-100 to -1",
6+
"tl-a": "0 to 25",
7+
"tl-b": "26 to 50",
8+
"tl-c": "51 to 75",
9+
"tl-d": "76 to 100"
10+
};
11+
12+
var keys = Object.keys( tlRanges );
13+
var lastID = keys[ keys.length-1 ];
14+
15+
$.each( tlRanges, function( id,range ){
16+
if( id === lastID ){
17+
$( "#tl-ranges" ).append( "<input type='checkbox' id='"+id+"' name='ranges'><label for='"+id+"'>"+range+"</label>" );
18+
}else{
19+
$( "#tl-ranges" ).append( "<input type='checkbox' id='"+id+"' name='ranges'><label for='"+id+"'>"+range+"</label><br>" );
20+
}
21+
});//end each tlRanges
22+
23+
$( document ).on( "change", "#tl-ranges input", function() {
24+
var idme = this.id; /*checkbox that was clicked */
25+
var tableclasser = "tl-table"; /*class of the data table*/
26+
var highlightbg = "#214f74"; /*the highlighted background */
27+
var highlightfont = "#fff"; /*the highlighted font */
28+
var lowlightbg = "transparent"; /*the lowlighted background */
29+
var lowlightfont = "#222"; /*the lowlighted font */
30+
31+
var currentRange = tlRanges[ idme ].split( " to " );
32+
var numstart = parseInt( currentRange[ 0 ] );
33+
var numend = parseInt( currentRange[ 1 ] );
34+
35+
if ( document.getElementById( idme ).checked ) {
36+
$( "."+tableclasser + " td" ).each( function( i, n ) {
37+
if ( ( $( n ).text() >= numstart ) && ( $( n ).text() <= numend ) ) {
38+
$( n ).stop().animate( {backgroundColor: highlightbg, color: highlightfont}, 2000 );
39+
$( n ).addClass( "tl-touched" );
40+
$( "th", $( n ).parents( "tr" ) ).stop().animate( {backgroundColor: highlightbg, color: highlightfont}, 2000 );
41+
$( "th", $( n ).parents( "tr" ) ).addClass( "tl-touchedname" );
42+
}
43+
});
44+
} else {
45+
$( "."+tableclasser + " td" ).each( function( i, n ) {
46+
if ( ( $( n ).text() >= numstart ) && ( $( n ).text() <= numend ) ) {
47+
$( n ).removeClass( "tl-touched" );
48+
$( n ).stop().animate( {backgroundColor: lowlightbg, color: lowlightfont}, 2000 );
49+
var rowid = $( n ).closest( "tr" );
50+
if ( $( rowid ).has( "td.tl-touched" ).length > 0 ) {
51+
} else {
52+
$( "th", $( n ).parents( "tr" ) ).stop().animate( {backgroundColor: lowlightbg, color: lowlightfont}, 2000 );
53+
$( "th", $( n ).parents( "tr" ) ).removeClass( "tl-touchedname" );
54+
}
55+
} /* close if else on numstart numend */
56+
} ); /* close ( classer ).each( function( i, n ) */
57+
} /* close ( document.getElementById( idme ).checked ) */
58+
} ); /* close $( document ).on( "change", "#tlRanges input", function( ) */
59+
60+
$( ".tl-uncheck" ).click( function(){
61+
$( "#tl-ranges input" ).prop( "checked",false ).change();
62+
} );//end on uncheck click
63+
64+
} ); /* close function */

docs/images/checkbox.png

55.6 KB
Loading

docs/images/slider.png

61.9 KB
Loading

0 commit comments

Comments
 (0)