Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
petrock committed Apr 30, 2018
0 parents commit 2a9e46b
Show file tree
Hide file tree
Showing 11 changed files with 748 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
20 changes: 20 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"boss": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"expr": true,
"immed": true,
"noarg": true,
"quotmark": "double",
"smarttabs": true,
"trailing": true,
"undef": true,
"unused": true,
"devel": true,
"jquery": true,
"globals": {
"$": false,
"document": false
}
}
95 changes: 95 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Tablelight

## Overview

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.

* <a href="https://codepen.io/wurstrti/pen/bMGLOw" target="_blank">View a demo of Tablelight checkbox</a>
* <a href="https://codepen.io/wurstrti/pen/JvjLWQ" target="_blank">View a demo of Tablelight slider</a>

### Tablelight Checkbox

![checkbox screenshot](./docs/images/checkbox.png "Checkbox version")

### Tablelight Slider

![slider screenshot](./docs/images/slider.png "Slider version")

## Dependencies

To run tablelight, you will need the following:

* <a href="http://jquery.com/download/" target="_blank">jQuery</a> (minimum version 1.4.1)
* <a href="http://jqueryui.com/download/" target="_blank">jQuery UI</a> (minimum version - 1.7.1)

## How to use

### Tablelight Checkbox
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.

- /checkbox/js/tablelight_checkbox.js is the main JavaScript file
- /checkbox/css/tablelight_checkbox.css provides some basic default files

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:

- tl-neg
- tl-a
- tl-b
- tl-c
- tl-d

The tl-neg key-value pair is used to express negative values.

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:

* tableclasser - class of the data table. Default: tl-table
* highlightbg - color value for highlighted cells. Default: #214f74
* highlightfont - text color for highlighted cells. Default: #fff
* lowlightbg - color of the non-selected cells. Default: transparent
* lowlightfont - text color of the non-selected cells. Default: #222

### Tablelight Slider

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.

- /slider/js/tablelight_slider.js is the main JavaScript file
- /slider/css/tablelight.slider.css provides some default files

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.


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:

*Gradient colors*
* colorstarter - minimum value gradient color
* colorender - maximum value gradient color
* More gradients can be found at [uigradients](https://uigradients.com)
* tableclasser - class of the data table. Default: tl-table
* highlightbg - color value for highlighted cells. Default: #214f74
* highlightfont - text color for highlighted cells. Default: #ffffff
* lowlightbg - color of the non-selected cells. Default: transparent
* lowlightfont - text color of the non-selected cells. Default: #222
* animatespeed - speed of the highlighting animation. Default: 2000
* grad - show gradient or just solid color. 1 for gradient, 0 for solid color
* maxcolor - color for 100% max value color. Default: colorender

## Authors

The authors of TableLight are Mark Koyanagi, Rebecca Watkins, and Keith Wurst.

## Acknowledgments

We would like to acknowledge David Rice for the assistance and support he provided with this project.


## License

The MIT License (MIT)

Copyright (c) 2018

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:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

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.
14 changes: 14 additions & 0 deletions checkbox/css/tablelight.checkbox.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.tl-uncheck{
cursor: pointer;
display: inline-block;
margin: 10px 0px;
text-decoration: underline;
}

table.tl-table, .tl-table th, .tl-table td {

padding: 5px;
border-spacing: 10px;
border: 1px solid #000000;

}
156 changes: 156 additions & 0 deletions checkbox/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<!doctype html>

<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="utf-8">

<title>tablelight checkbox</title>

<link rel="stylesheet" href="css/tablelight.checkbox.css">
<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-->
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script><!--min 1.9.1-->
<script src="js/tablelight.checkbox.js" type="text/javascript"></script>

</head>

<body>


<div>
<fieldset id="tl-ranges"><legend>Select your ranges:</legend></fieldset>
<div class="tl-uncheck" style="cursor:pointer;display:inline-block;margin:10px 0px;" role="button">Click here to uncheck all</div>
</div>

<table class="tl-table">
<caption>Brief table description here.</caption>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Col 1</th>
<th scope="col">Col 2</th>
<th scope="col">Col 3</th>
<th scope="col">Col 4</th>
<th scope="col">Col 5</th>
<th scope="col">Col 6</th>
<th scope="col">Col 7</th>
<th scope="col">Col 8</th>
<th scope="col">Col 9</th>
<th scope="col">Col 10</th>
<th scope="col">Col 11</th>
<th scope="col">Col 12</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Jorah</th>
<td>14</td>
<td>17</td>
<td>-8</td>
<td>9</td>
<td>-5</td>
<td>21</td>
<td>13</td>
<td>32</td>
<td>76</td>
<td>87</td>
<td>89</td>
<td>76</td>
</tr>
<tr>
<th scope="row">Gregor</th>
<td>31</td>
<td>73</td>
<td>-2</td>
<td>30</td>
<td>26</td>
<td>45</td>
<td>69</td>
<td>69</td>
<td>70</td>
<td>67</td>
<td>71</td>
<td>69</td>
</tr>
<tr>
<th scope="row">Cersei</th>
<td>27</td>
<td>0</td>
<td>14</td>
<td>23</td>
<td>22</td>
<td>42</td>
<td>76</td>
<td>76</td>
<td>86</td>
<td>90</td>
<td>91</td>
<td>90</td>
</tr>
<tr>
<th scope="row">Tyrion</th>
<td>-19</td>
<td>8</td>
<td>2</td>
<td>0</td>
<td>-8</td>
<td>15</td>
<td>23</td>
<td>33</td>
<td>40</td>
<td>45</td>
<td>63</td>
<td>64</td>
</tr>
<tr>
<th scope="row">Sansa</th>
<td>-61</td>
<td>-58</td>
<td>-8</td>
<td>-59</td>
<td>-33</td>
<td>13</td>
<td>63</td>
<td>59</td>
<td>61</td>
<td>57</td>
<td>64</td>
<td>70</td>
</tr>
<tr>
<th scope="row">Joffrey</th>
<td>6</td>
<td>-8</td>
<td>41</td>
<td>62</td>
<td>64</td>
<td>61</td>
<td>40</td>
<td>52</td>
<td>54</td>
<td>75</td>
<td>78</td>
<td>76</td>
</tr>
<tr>
<th scope="row">Bronn</th>
<td>-12</td>
<td>-45</td>
<td>-63</td>
<td>-23</td>
<td>-17</td>
<td>1</td>
<td>-35</td>
<td>-1</td>
<td>59</td>
<td>41</td>
<td>48</td>
<td>70</td>
</tr>
</tbody>
</table>



</body>
</html>
64 changes: 64 additions & 0 deletions checkbox/js/tablelight.checkbox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Licensed under the MIT license.

$( function() {
var tlRanges = {
"tl-neg": "-100 to -1",
"tl-a": "0 to 25",
"tl-b": "26 to 50",
"tl-c": "51 to 75",
"tl-d": "76 to 100"
};

var keys = Object.keys( tlRanges );
var lastID = keys[ keys.length-1 ];

$.each( tlRanges, function( id,range ){
if( id === lastID ){
$( "#tl-ranges" ).append( "<input type='checkbox' id='"+id+"' name='ranges'><label for='"+id+"'>"+range+"</label>" );
}else{
$( "#tl-ranges" ).append( "<input type='checkbox' id='"+id+"' name='ranges'><label for='"+id+"'>"+range+"</label><br>" );
}
});//end each tlRanges

$( document ).on( "change", "#tl-ranges input", function() {
var idme = this.id; /*checkbox that was clicked */
var tableclasser = "tl-table"; /*class of the data table*/
var highlightbg = "#214f74"; /*the highlighted background */
var highlightfont = "#fff"; /*the highlighted font */
var lowlightbg = "transparent"; /*the lowlighted background */
var lowlightfont = "#222"; /*the lowlighted font */

var currentRange = tlRanges[ idme ].split( " to " );
var numstart = parseInt( currentRange[ 0 ] );
var numend = parseInt( currentRange[ 1 ] );

if ( document.getElementById( idme ).checked ) {
$( "."+tableclasser + " td" ).each( function( i, n ) {
if ( ( $( n ).text() >= numstart ) && ( $( n ).text() <= numend ) ) {
$( n ).stop().animate( {backgroundColor: highlightbg, color: highlightfont}, 2000 );
$( n ).addClass( "tl-touched" );
$( "th", $( n ).parents( "tr" ) ).stop().animate( {backgroundColor: highlightbg, color: highlightfont}, 2000 );
$( "th", $( n ).parents( "tr" ) ).addClass( "tl-touchedname" );
}
});
} else {
$( "."+tableclasser + " td" ).each( function( i, n ) {
if ( ( $( n ).text() >= numstart ) && ( $( n ).text() <= numend ) ) {
$( n ).removeClass( "tl-touched" );
$( n ).stop().animate( {backgroundColor: lowlightbg, color: lowlightfont}, 2000 );
var rowid = $( n ).closest( "tr" );
if ( $( rowid ).has( "td.tl-touched" ).length > 0 ) {
} else {
$( "th", $( n ).parents( "tr" ) ).stop().animate( {backgroundColor: lowlightbg, color: lowlightfont}, 2000 );
$( "th", $( n ).parents( "tr" ) ).removeClass( "tl-touchedname" );
}
} /* close if else on numstart numend */
} ); /* close ( classer ).each( function( i, n ) */
} /* close ( document.getElementById( idme ).checked ) */
} ); /* close $( document ).on( "change", "#tlRanges input", function( ) */

$( ".tl-uncheck" ).click( function(){
$( "#tl-ranges input" ).prop( "checked",false ).change();
} );//end on uncheck click

} ); /* close function */
Binary file added docs/images/checkbox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/slider.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2a9e46b

Please sign in to comment.