mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Add select2 Filter formatter code & cleanup
This commit is contained in:
parent
fb4b97d0de
commit
afc3ec1563
@ -1,230 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery plugin: Tablesorter 2.0 - External Filters + select2</title>
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
|
||||
|
||||
<!-- Demo stuff -->
|
||||
<link class="ui-theme" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/cupertino/jquery-ui.css">
|
||||
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
|
||||
<link rel="stylesheet" href="../docs/css/jq.css">
|
||||
<link href="../docs/css/prettify.css" rel="stylesheet">
|
||||
<script src="../docs/js/prettify.js"></script>
|
||||
<script src="../docs/js/docs.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="select2.css">
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.0/select2.min.js"></script>
|
||||
<style>
|
||||
.tablesorter-filter-row td button {
|
||||
background-color: red;
|
||||
color: white;
|
||||
border: #555 1px solid;
|
||||
}
|
||||
#external_controls input {
|
||||
width: 150px;
|
||||
margin-left: 5px;
|
||||
}
|
||||
.selector {
|
||||
width: 200px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- Tablesorter: required -->
|
||||
<link rel="stylesheet" href="../css/theme.jui.css">
|
||||
<script src="../js/jquery.tablesorter.js"></script>
|
||||
<script src="../js/jquery.tablesorter.widgets.js"></script>
|
||||
|
||||
<script id="js">$(function(){
|
||||
|
||||
var $t = $('table')
|
||||
.on('filterInit', function () {
|
||||
|
||||
var filters,
|
||||
select2Column = 0,
|
||||
select2TagColumn = 1,
|
||||
$t = $(this),
|
||||
$filterCells = $t.find('.tablesorter-filter-row').children(),
|
||||
$ext = $('#external_controls'),
|
||||
$extCells = $ext.find('td'),
|
||||
startSearch = function(){
|
||||
filters = [];
|
||||
$extCells.each(function(i){
|
||||
var v,
|
||||
$this = $(this),
|
||||
$item = $this.find('select, input');
|
||||
// specific method for select2
|
||||
if (i === select2Column) {
|
||||
v = '/(' + ($this.find('.selector').select2('val') || []).join('$|') + '$)/';
|
||||
} else if(i === select2TagColumn){
|
||||
v = '/(' + ($this.find('.selectorTag').select2('val') || []).join('|') + ')/';
|
||||
}
|
||||
if (i !== select2Column) {
|
||||
// search for numbers > value
|
||||
// v = '>=' + $item.val();
|
||||
}
|
||||
filters[i] = v || $item.val() || '';
|
||||
});
|
||||
// start search
|
||||
$.tablesorter.setFilters($t, filters, true);
|
||||
};
|
||||
|
||||
// hide filter row completely
|
||||
$t.find('.tablesorter-filter-row').hide();
|
||||
|
||||
// clone original select and turn it into a select2
|
||||
// doing it this way because we can let the filter widget do most of the work
|
||||
$filterCells.eq(select2Column)
|
||||
.find('select')
|
||||
.attr('multiple', 'multiple')
|
||||
.addClass('selector')
|
||||
.appendTo( $ext.find('.select2') );
|
||||
// replace select with an input
|
||||
$filterCells.eq(select2Column).html('<input type="search" class="tablesorter-filter">');
|
||||
|
||||
// removed first option (it's just a placeholder)
|
||||
$ext.find('.selector').find('option:first').remove();
|
||||
// set up select2 input
|
||||
$ext.find('.selector').select2({
|
||||
placeholder : 'AlphaNumeric'
|
||||
});
|
||||
|
||||
|
||||
// /******* Select2 Tag Cloud ********/
|
||||
// as with above AlphaNumeric filter get the option values from original select
|
||||
var optionValues = [];
|
||||
$filterCells.eq(select2TagColumn).find('select option').each(function() {
|
||||
optionValues.push($(this).text());
|
||||
});
|
||||
|
||||
// removed first option (it's just a placeholder)
|
||||
optionValues = optionValues.slice(1);
|
||||
|
||||
//Create a new hidden input for select2 tag cloud and append it to its external filter cell
|
||||
var $selectInput = $('<input type="hidden" class="selectorTag" style="width:200px"/>')
|
||||
.appendTo( $ext.find('.select2tag') );
|
||||
|
||||
//Replace the original select filter with a search input
|
||||
$filterCells.eq(select2TagColumn).html('<input type="search" class="tablesorter-filter">');
|
||||
|
||||
// set up select2 tag cloud input
|
||||
$selectInput.select2({
|
||||
tags : optionValues,
|
||||
tokenSeparators : [","],
|
||||
placeholder : 'AlphaNumeric Tag'
|
||||
});
|
||||
|
||||
// turn off built-in filter-select
|
||||
$t.find('.filter-select').removeClass('filter-select') // turn off filter select
|
||||
this.config.widgetOptions.filter_functions[select2Column] = null;
|
||||
this.config.widgetOptions.filter_functions[select2TagColumn] = null;
|
||||
|
||||
// input changes trigger a new search
|
||||
$ext.find('select, input').on('change', function () {
|
||||
startSearch();
|
||||
});
|
||||
|
||||
})
|
||||
.tablesorter({
|
||||
theme: 'jui',
|
||||
headerTemplate: '{content}{icon}',
|
||||
widgets: ['zebra', 'uitheme', 'filter']
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="banner">
|
||||
<h1>table<em>sorter</em></h1>
|
||||
<h2>External Filters + select2</h2>
|
||||
<h3>Flexible client-side table sorting</h3>
|
||||
<a href="index.html">Back to documentation</a>
|
||||
</div>
|
||||
<div id="main">
|
||||
|
||||
<p class="tip">
|
||||
<em>NOTE!</em>
|
||||
<ul>
|
||||
<li>External filter using <a href="http://ivaynberg.github.io/select2/">Select2</a> plugin.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h1>Demo</h1>
|
||||
<br>
|
||||
|
||||
<table id="external_controls">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="select2">filters: </td>
|
||||
<td class="select2tag"></td>
|
||||
<td>
|
||||
<input type="search" placeholder="num" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="search" placeholder="anim" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="search" placeholder="sites" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="tablesorter">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="filter-select">AlphaNumeric</th>
|
||||
<th class="filter-select">AlphaNumeric Tag</th>
|
||||
<th>Numeric</th>
|
||||
<th>Animals</th>
|
||||
<th>Sites</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><td>abc 123</td><td>abc 123</td><td>10</td><td>Koala</td><td>http://www.google.com</td></tr>
|
||||
<tr><td>abc 1</td><td>abc 1</td><td>34</td><td>Ox</td><td>http://www.yahoo.com</td></tr>
|
||||
<tr><td>abc 9</td><td>abc 9</td><td>10</td><td>Girafee</td><td>http://www.facebook.com</td></tr>
|
||||
<tr><td>zyx 24</td><td>zyx 24</td><td>67</td><td>Bison</td><td>http://www.whitehouse.gov/</td></tr>
|
||||
<tr><td>abc 11</td><td>abc 11</td><td>3</td><td>Chimp</td><td>http://www.ucla.edu/</td></tr>
|
||||
<tr><td>abc 2</td><td>abc 2</td><td>56</td><td>Elephant</td><td>http://www.wikipedia.org/</td></tr>
|
||||
<tr><td>abc 9</td><td>abc 9</td><td>75</td><td>Lion</td><td>http://www.nytimes.com/</td></tr>
|
||||
<tr><td>abc 10</td><td>abc 10</td><td>87</td><td>Zebra</td><td>http://www.google.com</td></tr>
|
||||
<tr><td>zyx 1</td><td>zyx 1</td><td>99</td><td>Koala</td><td>http://www.mit.edu/</td></tr>
|
||||
<tr><td>zyx 12</td><td>zyx 12</td><td>0</td><td>Llama</td><td>http://www.nasa.gov/</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h1>HTML</h1>
|
||||
<div>
|
||||
<pre class="prettyprint lang-html"><table id="external_controls">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="select2">filters: </td>
|
||||
<td class="select2tag"></td>
|
||||
<td>
|
||||
<input type="search" placeholder="num" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="search" placeholder="anim" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="search" placeholder="sites" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></pre>
|
||||
</div>
|
||||
|
||||
<h1>Javascript</h1>
|
||||
<div id="javascript">
|
||||
<pre class="prettyprint lang-javascript"></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,247 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery plugin: Tablesorter 2.0 - Column Math Widget</title>
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
|
||||
|
||||
<!-- Demo stuff -->
|
||||
<link rel="stylesheet" href="../docs/css/jq.css">
|
||||
<link href="../docs/css/prettify.css" rel="stylesheet">
|
||||
<script src="../docs/js/prettify.js"></script>
|
||||
<script src="../docs/js/docs.js"></script>
|
||||
|
||||
<!-- Tablesorter: required -->
|
||||
<link rel="stylesheet" href="../css/theme.blue.css">
|
||||
<script src="../js/jquery.tablesorter.js"></script>
|
||||
|
||||
<script src="widget-column-math.js"></script>
|
||||
|
||||
<style>
|
||||
.align-decimal { width: 85px; text-align: right; }
|
||||
</style>
|
||||
|
||||
<script id="js">$(function() {
|
||||
|
||||
// call the tablesorter plugin and assign widgets with id "zebra" (Default widget in the core) and the newly created "repeatHeaders"
|
||||
$("table").tablesorter({
|
||||
theme: 'blue',
|
||||
widgets: ['zebra', 'column-math'],
|
||||
widgetOptions: {
|
||||
columnMath_data : 'math', // data-math attribute
|
||||
columnMath_format : {
|
||||
// would prefer to just use a formatting mask instead of all these options, something like: "$ #,###.00"
|
||||
output_prefix : '$ ',
|
||||
output_suffix : '',
|
||||
thousands_separator : ',',
|
||||
thousands_grouping : 3,
|
||||
decimal_separator : '.',
|
||||
decimal_places : 2,
|
||||
format_complete : null // function(number, $cell){ return number; }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="banner">
|
||||
<h1>table<em>sorter</em></h1>
|
||||
<h2>Column Math Widget</h2>
|
||||
<h3>Flexible client-side table sorting</h3>
|
||||
<a href="index.html">Back to documentation</a>
|
||||
</div>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<p class="tip">
|
||||
<em>NOTE!</em>
|
||||
<ul>
|
||||
<li>This is an attempt to generalize <a href="http://jsfiddle.net/Mottie/vCTHw/729/">this demo</a>.</li>
|
||||
<li>It still needs a LOT of work (incomplete functionality).</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h1>Demo</h1>
|
||||
|
||||
<div id="demo"><table class="sortable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="sorter-false">Region</th>
|
||||
<th>Salesman</th>
|
||||
<th>FastCar</th>
|
||||
<th>RapidZoo</th>
|
||||
<th>SuperGlue</th>
|
||||
<th>Grand Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="2">Column Totals</td>
|
||||
<td data-math="sumcol"></td>
|
||||
<td data-math="sumcol"></td>
|
||||
<td data-math="sumcol"></td>
|
||||
<td data-math="sumcol" data-math-target="[data-math]"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5">Grand Total</td>
|
||||
<td data-math="sumall"></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="block">Middle</td>
|
||||
<td>Joseph</td>
|
||||
<td>$ 3,623</td>
|
||||
<td>$ 4,782</td>
|
||||
<td>$ 7,055</td>
|
||||
<td data-math="sumrow"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="block">Middle</td>
|
||||
<td>Lawrence</td>
|
||||
<td>$ 5,908</td>
|
||||
<td>$ 4,642</td>
|
||||
<td>$ 4,593</td>
|
||||
<td data-math="sumrow"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="block">Middle</td>
|
||||
<td>Maria</td>
|
||||
<td>$ 6,502</td>
|
||||
<td>$ 3,969</td>
|
||||
<td>$ 5,408</td>
|
||||
<td data-math="sumrow"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="block">Middle</td>
|
||||
<td>Matt</td>
|
||||
<td>$ 4,170</td>
|
||||
<td>$ 6,093</td>
|
||||
<td>$ 5,039</td>
|
||||
<td data-math="sumrow"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<tbody class="tablesorter-infoOnly">
|
||||
<tr>
|
||||
<td colspan="2">Middle Total</td>
|
||||
<td data-math="sumabove"></td>
|
||||
<td data-math="sumabove"></td>
|
||||
<td data-math="sumabove"></td>
|
||||
<td data-math="sumabove" data-math-target="[data-math]"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="block">North</td>
|
||||
<td>Joseph</td>
|
||||
<td>$ 3,643</td>
|
||||
<td>$ 5,846</td>
|
||||
<td>$ 6,574</td>
|
||||
<td data-math="sumrow"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="block">North</td>
|
||||
<td>Lawrence</td>
|
||||
<td>$ 4,456</td>
|
||||
<td>$ 6,658</td>
|
||||
<td>$ 7,685</td>
|
||||
<td data-math="sumrow"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="block">North</td>
|
||||
<td>Maria</td>
|
||||
<td>$ 6,235</td>
|
||||
<td>$ 4,616.99</td>
|
||||
<td>$ 3,612.33</td>
|
||||
<td data-math="sumrow"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="block">North</td>
|
||||
<td>Matt</td>
|
||||
<td>$ 3,868</td>
|
||||
<td>$ 3,926</td>
|
||||
<td>$ 3,254</td>
|
||||
<td data-math="sumrow"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<tbody class="tablesorter-infoOnly">
|
||||
<tr>
|
||||
<td colspan="2">North Total</td>
|
||||
<td data-math="sumabove"></td>
|
||||
<td data-math="sumabove"></td>
|
||||
<td data-math="sumabove"></td>
|
||||
<td data-math="sumabove" data-math-target="[data-math]"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="block">West</td>
|
||||
<td>Joseph</td>
|
||||
<td>$ 5,507</td>
|
||||
<td>$ 5,186</td>
|
||||
<td>$ 4,882</td>
|
||||
<td data-math="sumrow"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="block">West</td>
|
||||
<td>Lawrence</td>
|
||||
<td>$ 4,082</td>
|
||||
<td>$ 5,272</td>
|
||||
<td>$ 6,124</td>
|
||||
<td data-math="sumrow"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="block">West</td>
|
||||
<td>Maria</td>
|
||||
<td>$ 5,520</td>
|
||||
<td>$ 5,461</td>
|
||||
<td>$ 4,872</td>
|
||||
<td data-math="sumrow"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="block">West</td>
|
||||
<td>Matt</td>
|
||||
<td>$ 6,737</td>
|
||||
<td>$ 4,598</td>
|
||||
<td>$ 4,233</td>
|
||||
<td data-math="sumrow"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<tbody class="tablesorter-infoOnly">
|
||||
<tr>
|
||||
<td colspan="2">West Total</td>
|
||||
<td data-math="sumabove"></td>
|
||||
<td data-math="sumabove"></td>
|
||||
<td data-math="sumabove"></td>
|
||||
<td data-math="sumabove" data-math-target="[data-math]"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
</table></div>
|
||||
|
||||
<h1>Javascript</h1>
|
||||
|
||||
<div id="javascript">
|
||||
<pre class="prettyprint lang-javascript"></pre>
|
||||
</div>
|
||||
|
||||
<h1>HTML</h1>
|
||||
<div id="html">
|
||||
<pre class="prettyprint lang-html"></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.8 KiB |
@ -1,652 +0,0 @@
|
||||
/*
|
||||
Version: @@ver@@ Timestamp: @@timestamp@@
|
||||
*/
|
||||
.select2-container {
|
||||
margin: 0;
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
/* inline-block for ie7 */
|
||||
zoom: 1;
|
||||
*display: inline;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.select2-container,
|
||||
.select2-drop,
|
||||
.select2-search,
|
||||
.select2-search input{
|
||||
/*
|
||||
Force border-box so that % widths fit the parent
|
||||
container without overlap because of margin/padding.
|
||||
|
||||
More Info : http://www.quirksmode.org/css/box.html
|
||||
*/
|
||||
-webkit-box-sizing: border-box; /* webkit */
|
||||
-khtml-box-sizing: border-box; /* konqueror */
|
||||
-moz-box-sizing: border-box; /* firefox */
|
||||
-ms-box-sizing: border-box; /* ie */
|
||||
box-sizing: border-box; /* css3 */
|
||||
}
|
||||
|
||||
.select2-container .select2-choice {
|
||||
display: block;
|
||||
height: 26px;
|
||||
padding: 0 0 0 8px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
|
||||
border: 1px solid #aaa;
|
||||
white-space: nowrap;
|
||||
line-height: 26px;
|
||||
color: #444;
|
||||
text-decoration: none;
|
||||
|
||||
-webkit-border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
|
||||
-webkit-background-clip: padding-box;
|
||||
-moz-background-clip: padding;
|
||||
background-clip: padding-box;
|
||||
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
|
||||
background-color: #fff;
|
||||
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eeeeee), color-stop(0.5, white));
|
||||
background-image: -webkit-linear-gradient(center bottom, #eeeeee 0%, white 50%);
|
||||
background-image: -moz-linear-gradient(center bottom, #eeeeee 0%, white 50%);
|
||||
background-image: -o-linear-gradient(bottom, #eeeeee 0%, #ffffff 50%);
|
||||
background-image: -ms-linear-gradient(top, #ffffff 0%, #eeeeee 50%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#eeeeee', GradientType = 0);
|
||||
background-image: linear-gradient(top, #ffffff 0%, #eeeeee 50%);
|
||||
}
|
||||
|
||||
.select2-container.select2-drop-above .select2-choice {
|
||||
border-bottom-color: #aaa;
|
||||
|
||||
-webkit-border-radius:0 0 4px 4px;
|
||||
-moz-border-radius:0 0 4px 4px;
|
||||
border-radius:0 0 4px 4px;
|
||||
|
||||
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eeeeee), color-stop(0.9, white));
|
||||
background-image: -webkit-linear-gradient(center bottom, #eeeeee 0%, white 90%);
|
||||
background-image: -moz-linear-gradient(center bottom, #eeeeee 0%, white 90%);
|
||||
background-image: -o-linear-gradient(bottom, #eeeeee 0%, white 90%);
|
||||
background-image: -ms-linear-gradient(top, #eeeeee 0%,#ffffff 90%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eeeeee',GradientType=0 );
|
||||
background-image: linear-gradient(top, #eeeeee 0%,#ffffff 90%);
|
||||
}
|
||||
|
||||
.select2-container.select2-allowclear .select2-choice span {
|
||||
margin-right: 42px;
|
||||
}
|
||||
|
||||
.select2-container .select2-choice span {
|
||||
margin-right: 26px;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
|
||||
white-space: nowrap;
|
||||
|
||||
-ms-text-overflow: ellipsis;
|
||||
-o-text-overflow: ellipsis;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.select2-container .select2-choice abbr {
|
||||
display: none;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
position: absolute;
|
||||
right: 24px;
|
||||
top: 8px;
|
||||
|
||||
font-size: 1px;
|
||||
text-decoration: none;
|
||||
|
||||
border: 0;
|
||||
background: url('select2.png') right top no-repeat;
|
||||
cursor: pointer;
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
.select2-container.select2-allowclear .select2-choice abbr {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.select2-container .select2-choice abbr:hover {
|
||||
background-position: right -11px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.select2-drop-mask {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
z-index: 9998;
|
||||
}
|
||||
|
||||
.select2-drop {
|
||||
width: 100%;
|
||||
margin-top:-1px;
|
||||
position: absolute;
|
||||
z-index: 9999;
|
||||
top: 100%;
|
||||
|
||||
background: #fff;
|
||||
color: #000;
|
||||
border: 1px solid #aaa;
|
||||
border-top: 0;
|
||||
|
||||
-webkit-border-radius: 0 0 4px 4px;
|
||||
-moz-border-radius: 0 0 4px 4px;
|
||||
border-radius: 0 0 4px 4px;
|
||||
|
||||
-webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
|
||||
-moz-box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
|
||||
box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
|
||||
}
|
||||
|
||||
.select2-drop-auto-width {
|
||||
border-top: 1px solid #aaa;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.select2-drop-auto-width .select2-search {
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.select2-drop.select2-drop-above {
|
||||
margin-top: 1px;
|
||||
border-top: 1px solid #aaa;
|
||||
border-bottom: 0;
|
||||
|
||||
-webkit-border-radius: 4px 4px 0 0;
|
||||
-moz-border-radius: 4px 4px 0 0;
|
||||
border-radius: 4px 4px 0 0;
|
||||
|
||||
-webkit-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
|
||||
-moz-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
|
||||
box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
|
||||
}
|
||||
|
||||
.select2-container .select2-choice div {
|
||||
display: inline-block;
|
||||
width: 18px;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
|
||||
border-left: 1px solid #aaa;
|
||||
-webkit-border-radius: 0 4px 4px 0;
|
||||
-moz-border-radius: 0 4px 4px 0;
|
||||
border-radius: 0 4px 4px 0;
|
||||
|
||||
-webkit-background-clip: padding-box;
|
||||
-moz-background-clip: padding;
|
||||
background-clip: padding-box;
|
||||
|
||||
background: #ccc;
|
||||
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee));
|
||||
background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%);
|
||||
background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%);
|
||||
background-image: -o-linear-gradient(bottom, #ccc 0%, #eee 60%);
|
||||
background-image: -ms-linear-gradient(top, #cccccc 0%, #eeeeee 60%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee', endColorstr = '#cccccc', GradientType = 0);
|
||||
background-image: linear-gradient(top, #cccccc 0%, #eeeeee 60%);
|
||||
}
|
||||
|
||||
.select2-container .select2-choice div b {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: url('select2.png') no-repeat 0 1px;
|
||||
}
|
||||
|
||||
.select2-search {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
min-height: 26px;
|
||||
margin: 0;
|
||||
padding-left: 4px;
|
||||
padding-right: 4px;
|
||||
|
||||
position: relative;
|
||||
z-index: 10000;
|
||||
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.select2-search input {
|
||||
width: 100%;
|
||||
height: auto !important;
|
||||
min-height: 26px;
|
||||
padding: 4px 20px 4px 5px;
|
||||
margin: 0;
|
||||
|
||||
outline: 0;
|
||||
font-family: sans-serif;
|
||||
font-size: 1em;
|
||||
|
||||
border: 1px solid #aaa;
|
||||
-webkit-border-radius: 0;
|
||||
-moz-border-radius: 0;
|
||||
border-radius: 0;
|
||||
|
||||
-webkit-box-shadow: none;
|
||||
-moz-box-shadow: none;
|
||||
box-shadow: none;
|
||||
|
||||
background: #fff url('select2.png') no-repeat 100% -22px;
|
||||
background: url('select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
|
||||
background: url('select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%);
|
||||
background: url('select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
|
||||
background: url('select2.png') no-repeat 100% -22px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
|
||||
background: url('select2.png') no-repeat 100% -22px, -ms-linear-gradient(top, #ffffff 85%, #eeeeee 99%);
|
||||
background: url('select2.png') no-repeat 100% -22px, linear-gradient(top, #ffffff 85%, #eeeeee 99%);
|
||||
}
|
||||
|
||||
.select2-drop.select2-drop-above .select2-search input {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.select2-search input.select2-active {
|
||||
background: #fff url('select2-spinner.gif') no-repeat 100%;
|
||||
background: url('select2-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
|
||||
background: url('select2-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%);
|
||||
background: url('select2-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
|
||||
background: url('select2-spinner.gif') no-repeat 100%, -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
|
||||
background: url('select2-spinner.gif') no-repeat 100%, -ms-linear-gradient(top, #ffffff 85%, #eeeeee 99%);
|
||||
background: url('select2-spinner.gif') no-repeat 100%, linear-gradient(top, #ffffff 85%, #eeeeee 99%);
|
||||
}
|
||||
|
||||
.select2-container-active .select2-choice,
|
||||
.select2-container-active .select2-choices {
|
||||
border: 1px solid #5897fb;
|
||||
outline: none;
|
||||
|
||||
-webkit-box-shadow: 0 0 5px rgba(0,0,0,.3);
|
||||
-moz-box-shadow: 0 0 5px rgba(0,0,0,.3);
|
||||
box-shadow: 0 0 5px rgba(0,0,0,.3);
|
||||
}
|
||||
|
||||
.select2-dropdown-open .select2-choice {
|
||||
border-bottom-color: transparent;
|
||||
-webkit-box-shadow: 0 1px 0 #fff inset;
|
||||
-moz-box-shadow: 0 1px 0 #fff inset;
|
||||
box-shadow: 0 1px 0 #fff inset;
|
||||
|
||||
-webkit-border-bottom-left-radius: 0;
|
||||
-moz-border-radius-bottomleft: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
|
||||
-webkit-border-bottom-right-radius: 0;
|
||||
-moz-border-radius-bottomright: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
|
||||
background-color: #eee;
|
||||
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, white), color-stop(0.5, #eeeeee));
|
||||
background-image: -webkit-linear-gradient(center bottom, white 0%, #eeeeee 50%);
|
||||
background-image: -moz-linear-gradient(center bottom, white 0%, #eeeeee 50%);
|
||||
background-image: -o-linear-gradient(bottom, white 0%, #eeeeee 50%);
|
||||
background-image: -ms-linear-gradient(top, #ffffff 0%,#eeeeee 50%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#ffffff',GradientType=0 );
|
||||
background-image: linear-gradient(top, #ffffff 0%,#eeeeee 50%);
|
||||
}
|
||||
|
||||
.select2-dropdown-open.select2-drop-above .select2-choice,
|
||||
.select2-dropdown-open.select2-drop-above .select2-choices {
|
||||
border: 1px solid #5897fb;
|
||||
border-top-color: transparent;
|
||||
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, white), color-stop(0.5, #eeeeee));
|
||||
background-image: -webkit-linear-gradient(center top, white 0%, #eeeeee 50%);
|
||||
background-image: -moz-linear-gradient(center top, white 0%, #eeeeee 50%);
|
||||
background-image: -o-linear-gradient(top, white 0%, #eeeeee 50%);
|
||||
background-image: -ms-linear-gradient(bottom, #ffffff 0%,#eeeeee 50%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#ffffff',GradientType=0 );
|
||||
background-image: linear-gradient(bottom, #ffffff 0%,#eeeeee 50%);
|
||||
}
|
||||
|
||||
.select2-dropdown-open .select2-choice div {
|
||||
background: transparent;
|
||||
border-left: none;
|
||||
filter: none;
|
||||
}
|
||||
.select2-dropdown-open .select2-choice div b {
|
||||
background-position: -18px 1px;
|
||||
}
|
||||
|
||||
/* results */
|
||||
.select2-results {
|
||||
max-height: 200px;
|
||||
padding: 0 0 0 4px;
|
||||
margin: 4px 4px 4px 0;
|
||||
position: relative;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
||||
}
|
||||
|
||||
.select2-results ul.select2-result-sub {
|
||||
margin: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.select2-results ul.select2-result-sub > li .select2-result-label { padding-left: 20px }
|
||||
.select2-results ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 40px }
|
||||
.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 60px }
|
||||
.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 80px }
|
||||
.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 100px }
|
||||
.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 110px }
|
||||
.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 120px }
|
||||
|
||||
.select2-results li {
|
||||
list-style: none;
|
||||
display: list-item;
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
.select2-results li.select2-result-with-children > .select2-result-label {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.select2-results .select2-result-label {
|
||||
padding: 3px 7px 4px;
|
||||
margin: 0;
|
||||
cursor: pointer;
|
||||
|
||||
min-height: 1em;
|
||||
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.select2-results .select2-highlighted {
|
||||
background: #3875d7;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.select2-results li em {
|
||||
background: #feffde;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.select2-results .select2-highlighted em {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.select2-results .select2-highlighted ul {
|
||||
background: white;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
|
||||
.select2-results .select2-no-results,
|
||||
.select2-results .select2-searching,
|
||||
.select2-results .select2-selection-limit {
|
||||
background: #f4f4f4;
|
||||
display: list-item;
|
||||
}
|
||||
|
||||
/*
|
||||
disabled look for disabled choices in the results dropdown
|
||||
*/
|
||||
.select2-results .select2-disabled.select2-highlighted {
|
||||
color: #666;
|
||||
background: #f4f4f4;
|
||||
display: list-item;
|
||||
cursor: default;
|
||||
}
|
||||
.select2-results .select2-disabled {
|
||||
background: #f4f4f4;
|
||||
display: list-item;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.select2-results .select2-selected {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.select2-more-results.select2-active {
|
||||
background: #f4f4f4 url('select2-spinner.gif') no-repeat 100%;
|
||||
}
|
||||
|
||||
.select2-more-results {
|
||||
background: #f4f4f4;
|
||||
display: list-item;
|
||||
}
|
||||
|
||||
/* disabled styles */
|
||||
|
||||
.select2-container.select2-container-disabled .select2-choice {
|
||||
background-color: #f4f4f4;
|
||||
background-image: none;
|
||||
border: 1px solid #ddd;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.select2-container.select2-container-disabled .select2-choice div {
|
||||
background-color: #f4f4f4;
|
||||
background-image: none;
|
||||
border-left: 0;
|
||||
}
|
||||
|
||||
.select2-container.select2-container-disabled .select2-choice abbr {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
/* multiselect */
|
||||
|
||||
.select2-container-multi .select2-choices {
|
||||
height: auto !important;
|
||||
height: 1%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
|
||||
border: 1px solid #aaa;
|
||||
cursor: text;
|
||||
overflow: hidden;
|
||||
|
||||
background-color: #fff;
|
||||
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
|
||||
background-image: -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background-image: -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background-image: -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background-image: -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background-image: linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
}
|
||||
|
||||
.select2-locked {
|
||||
padding: 3px 5px 3px 5px !important;
|
||||
}
|
||||
|
||||
.select2-container-multi .select2-choices {
|
||||
min-height: 26px;
|
||||
}
|
||||
|
||||
.select2-container-multi.select2-container-active .select2-choices {
|
||||
border: 1px solid #5897fb;
|
||||
outline: none;
|
||||
|
||||
-webkit-box-shadow: 0 0 5px rgba(0,0,0,.3);
|
||||
-moz-box-shadow: 0 0 5px rgba(0,0,0,.3);
|
||||
box-shadow: 0 0 5px rgba(0,0,0,.3);
|
||||
}
|
||||
.select2-container-multi .select2-choices li {
|
||||
float: left;
|
||||
list-style: none;
|
||||
}
|
||||
.select2-container-multi .select2-choices .select2-search-field {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.select2-container-multi .select2-choices .select2-search-field input {
|
||||
padding: 5px;
|
||||
margin: 1px 0;
|
||||
|
||||
font-family: sans-serif;
|
||||
font-size: 100%;
|
||||
color: #666;
|
||||
outline: 0;
|
||||
border: 0;
|
||||
-webkit-box-shadow: none;
|
||||
-moz-box-shadow: none;
|
||||
box-shadow: none;
|
||||
background: transparent !important;
|
||||
}
|
||||
|
||||
.select2-container-multi .select2-choices .select2-search-field input.select2-active {
|
||||
background: #fff url('select2-spinner.gif') no-repeat 100% !important;
|
||||
}
|
||||
|
||||
.select2-default {
|
||||
color: #999 !important;
|
||||
}
|
||||
|
||||
.select2-container-multi .select2-choices .select2-search-choice {
|
||||
padding: 3px 5px 3px 18px;
|
||||
margin: 3px 0 3px 5px;
|
||||
position: relative;
|
||||
|
||||
line-height: 13px;
|
||||
color: #333;
|
||||
cursor: default;
|
||||
border: 1px solid #aaaaaa;
|
||||
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
|
||||
-webkit-box-shadow: 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
|
||||
-moz-box-shadow: 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
|
||||
box-shadow: 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
|
||||
|
||||
-webkit-background-clip: padding-box;
|
||||
-moz-background-clip: padding;
|
||||
background-clip: padding-box;
|
||||
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
|
||||
background-color: #e4e4e4;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#f4f4f4', GradientType=0 );
|
||||
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee));
|
||||
background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
background-image: -o-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
background-image: -ms-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
}
|
||||
.select2-container-multi .select2-choices .select2-search-choice span {
|
||||
cursor: default;
|
||||
}
|
||||
.select2-container-multi .select2-choices .select2-search-choice-focus {
|
||||
background: #d4d4d4;
|
||||
}
|
||||
|
||||
.select2-search-choice-close {
|
||||
display: block;
|
||||
width: 12px;
|
||||
height: 13px;
|
||||
position: absolute;
|
||||
right: 3px;
|
||||
top: 4px;
|
||||
|
||||
font-size: 1px;
|
||||
outline: none;
|
||||
background: url('select2.png') right top no-repeat;
|
||||
}
|
||||
|
||||
.select2-container-multi .select2-search-choice-close {
|
||||
left: 3px;
|
||||
}
|
||||
|
||||
.select2-container-multi .select2-choices .select2-search-choice .select2-search-choice-close:hover {
|
||||
background-position: right -11px;
|
||||
}
|
||||
.select2-container-multi .select2-choices .select2-search-choice-focus .select2-search-choice-close {
|
||||
background-position: right -11px;
|
||||
}
|
||||
|
||||
/* disabled styles */
|
||||
.select2-container-multi.select2-container-disabled .select2-choices{
|
||||
background-color: #f4f4f4;
|
||||
background-image: none;
|
||||
border: 1px solid #ddd;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice {
|
||||
padding: 3px 5px 3px 5px;
|
||||
border: 1px solid #ddd;
|
||||
background-image: none;
|
||||
background-color: #f4f4f4;
|
||||
}
|
||||
|
||||
.select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice .select2-search-choice-close { display: none;
|
||||
background:none;
|
||||
}
|
||||
/* end multiselect */
|
||||
|
||||
|
||||
.select2-result-selectable .select2-match,
|
||||
.select2-result-unselectable .select2-match {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.select2-offscreen, .select2-offscreen:focus {
|
||||
clip: rect(0 0 0 0);
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
border: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
outline: 0;
|
||||
left: 0px;
|
||||
}
|
||||
|
||||
.select2-display-none {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.select2-measure-scrollbar {
|
||||
position: absolute;
|
||||
top: -10000px;
|
||||
left: -10000px;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
overflow: scroll;
|
||||
}
|
||||
/* Retina-ize icons */
|
||||
|
||||
@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) {
|
||||
.select2-search input, .select2-search-choice-close, .select2-container .select2-choice abbr, .select2-container .select2-choice div b {
|
||||
background-image: url('select2x2.png') !important;
|
||||
background-repeat: no-repeat !important;
|
||||
background-size: 60px 40px !important;
|
||||
}
|
||||
.select2-search input {
|
||||
background-position: 100% -21px !important;
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 613 B |
@ -1,139 +0,0 @@
|
||||
/*! tablesorter column reorder - beta testing
|
||||
* Requires tablesorter v2.8+ and jQuery 1.7+
|
||||
* by Rob Garrison
|
||||
*/
|
||||
/*jshint browser:true, jquery:true, unused:false */
|
||||
/*global jQuery: false */
|
||||
;(function($){
|
||||
"use strict";
|
||||
|
||||
var ts = $.tablesorter = $.tablesorter || {};
|
||||
|
||||
ts.columnMath = {
|
||||
|
||||
equations : {
|
||||
// sum all the cells in the row
|
||||
sumrow : function(table, $el, c, wo, direct){
|
||||
var total = 0, row = ts.columnMath.getRow(table, $el, direct);
|
||||
$.each( row, function(i){
|
||||
total += row[i];
|
||||
});
|
||||
return total;
|
||||
},
|
||||
// sum all the cells in the column
|
||||
sumcol : function(table, $el, c, wo, direct){},
|
||||
// sum all of the cells
|
||||
sumall : function(table, $el, c, wo, direct){},
|
||||
// sum all of the cells in the column above the current one, until the next sumabove is reached
|
||||
sumabove : function(table, $el, c, wo, direct){},
|
||||
// target cells in a specific column c1, c2, c3, etc
|
||||
col : function(table, $el, c, wo, direct){},
|
||||
// target cells in a specific row r1, r2, r3, etc.
|
||||
row : function(table, $el, c, wo, direct){}
|
||||
// target
|
||||
},
|
||||
|
||||
// get all of the row numerical values in an array
|
||||
// el is the table cell where the data is added; direct means get the
|
||||
// numbers directly from the table, otherwise it gets it from the cache.
|
||||
getRow : function(table, $el, direct){
|
||||
var i, txt, arry = [],
|
||||
c = table.config,
|
||||
$tb = c.$table.find('tbody'),
|
||||
cIndex = $el[0].cellIndex,
|
||||
$row = $el.closest('tr'),
|
||||
bIndex = $tb.index( $row.closest('tbody') ),
|
||||
rIndex = $tb.eq(bIndex).find('tr').index( $row ),
|
||||
row = c.cache[bIndex].normalized[rIndex] || [];
|
||||
if (direct) {
|
||||
arry = $row.children().map(function(){
|
||||
txt = (c.supportsTextContent) ? this.textContent : $(this).text();
|
||||
txt = ts.formatFloat(txt.replace(/[^\w,. \-()]/g, ""), table);
|
||||
return isNaN(txt) ? 0 : txt;
|
||||
}).get();
|
||||
} else {
|
||||
for (i = 0; i < row.length - 1; i++) {
|
||||
arry.push( (i === cIndex || isNaN(row[i]) ) ? 0 : row[i] );
|
||||
}
|
||||
}
|
||||
return arry;
|
||||
},
|
||||
|
||||
output : function($el, wo, value) {
|
||||
value = wo.columnMath_format.output_prefix + ts.columnMath.addCommas(value, wo) + wo.columnMath_format.output_suffix;
|
||||
if ($.isFunction(wo.columnMath_format.format_complete)) {
|
||||
value = wo.columnMath_format.format_complete(value, $el);
|
||||
}
|
||||
$el.html('<div class="align-decimal">' + value + '</div>');
|
||||
},
|
||||
|
||||
addCommas : function(num, wo) {
|
||||
var parts = ( num.toFixed( wo.columnMath_format.decimal_places ) + '' ).split('.');
|
||||
parts[0] = parts[0].replace( wo.columnMath_regex, "$1" + wo.columnMath_format.thousands_separator );
|
||||
return parts.join( wo.columnMath_format.decimal_separator );
|
||||
},
|
||||
|
||||
recalculate : function(table, c, wo){
|
||||
if (c) {
|
||||
wo.columnMath_regex = new RegExp('(\\d)(?=(\\d{' + (wo.columnMath_format.thousands_grouping || 3) + '})+(?!\\d))', 'g' );
|
||||
var n, t, $t,
|
||||
priority = [ 'sumrow', 'sumabove', 'sumcol', 'sumall' ],
|
||||
eq = ts.columnMath.equations,
|
||||
dat = 'data-' + (wo.columnMath_data || 'math'),
|
||||
$mathCells = c.$tbodies.find('[' + dat + ']');
|
||||
// cells with a target are calculated last
|
||||
$mathCells.not('[' + dat + '-target]').each(function(){
|
||||
$t = $(this);
|
||||
n = $t.attr(dat);
|
||||
// check for built in math
|
||||
// eq = n.match(/(\w+)[\s+]?\(/g);
|
||||
if (eq[n]) {
|
||||
t = eq[n](table, $t, c, wo);
|
||||
if (t) {
|
||||
ts.columnMath.output( $t, wo, t );
|
||||
}
|
||||
}
|
||||
});
|
||||
// console.log($mathCells);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// add new widget called repeatHeaders
|
||||
// ************************************
|
||||
$.tablesorter.addWidget({
|
||||
id: "column-math",
|
||||
options: {
|
||||
columnMath_data : 'math',
|
||||
// columnMath_ignore : 'zero, text, empty',
|
||||
columnMath_format : {
|
||||
output_prefix : '$ ',
|
||||
output_suffix : '',
|
||||
thousands_separator : ',',
|
||||
thousands_grouping : 3,
|
||||
decimal_separator : '.',
|
||||
decimal_places : 2,
|
||||
format_complete : null // function(number, $cell){ return number; }
|
||||
}
|
||||
},
|
||||
init : function(table, thisWidget, c, wo){
|
||||
var $t = $(table).bind('update.tsmath updateRow.tsmath', function(){
|
||||
$.tablesorter.columnMath.recalculate(table, c, wo);
|
||||
});
|
||||
$.tablesorter.columnMath.recalculate(table, c, wo);
|
||||
},
|
||||
// format is called when the on init and when a sorting has finished
|
||||
format: function(table) {
|
||||
// do nothing
|
||||
},
|
||||
// this remove function is called when using the refreshWidgets method or when destroying the tablesorter plugin
|
||||
// this function only applies to tablesorter v2.4+
|
||||
remove: function(table, c, wo){
|
||||
$(table)
|
||||
.unbind('update.tsmath updateRows.tsmath')
|
||||
.find('[data-' + wo.columnMath_data + ']').empty();
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
152
docs/example-widget-filter-formatter-select2.html
Normal file
152
docs/example-widget-filter-formatter-select2.html
Normal file
@ -0,0 +1,152 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery plugin: Tablesorter 2.0 - Filter Formatter: select2 (beta)</title>
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
|
||||
|
||||
<!-- Demo stuff -->
|
||||
<link rel="stylesheet" href="../docs/css/jq.css">
|
||||
<link href="../docs/css/prettify.css" rel="stylesheet">
|
||||
<script src="../docs/js/prettify.js"></script>
|
||||
<script src="../docs/js/docs.js"></script>
|
||||
|
||||
<!-- Tablesorter: required -->
|
||||
<link href="../css/theme.blue.css" rel="stylesheet">
|
||||
<script src="../js/jquery.tablesorter.js"></script>
|
||||
<script src="../js/jquery.tablesorter.widgets.js"></script>
|
||||
|
||||
<!-- Select2 code -->
|
||||
<link href="http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.6/select2.min.css" rel="stylesheet">
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.6/select2.min.js"></script>
|
||||
<script src="../js/jquery.tablesorter.widgets-filter-formatter-select2.js"></script>
|
||||
|
||||
<script id="js">$(function(){
|
||||
|
||||
$('table').tablesorter({
|
||||
theme: 'blue',
|
||||
widthFixed: true,
|
||||
widgets: ['zebra', 'stickyHeaders', 'filter'],
|
||||
widgetOptions : {
|
||||
// Use the $.tablesorter.storage utility to save the most recent filters
|
||||
filter_saveFilters : true,
|
||||
// jQuery selector string of an element used to reset the filters
|
||||
filter_reset : 'button.reset',
|
||||
// add custom selector elements to the filter row
|
||||
filter_formatter : {
|
||||
// Alphanumeric (match)
|
||||
0 : function($cell, indx){
|
||||
return $.tablesorter.filterFormatter.select2( $cell, indx, {
|
||||
match : true, // adds "filter-match" to header
|
||||
cellText : 'Match: ',
|
||||
width: '85%'
|
||||
});
|
||||
},
|
||||
// Alphanumeric (exact)
|
||||
1 : function($cell, indx){
|
||||
return $.tablesorter.filterFormatter.select2( $cell, indx, {
|
||||
match : false // adds "filter-match" to header
|
||||
});
|
||||
}
|
||||
},
|
||||
// option added in v2.16.0
|
||||
filter_selectSource : {
|
||||
// Alphanumeric match (prefix only)
|
||||
0 : function(table, column) {
|
||||
return ['abc', 'def', 'zyx'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="banner">
|
||||
<h1>table<em>sorter</em></h1>
|
||||
<h2>Filter Formatter: select2 (beta)</h2>
|
||||
<h3>Flexible client-side table sorting</h3>
|
||||
<a href="index.html">Back to documentation</a>
|
||||
</div>
|
||||
<div id="main">
|
||||
|
||||
<p class="tip">
|
||||
<em>NOTE!</em>
|
||||
<ul>
|
||||
<li>This is a demo of the select2 filter formatter code.</li>
|
||||
<li>It requires jQuery 1.7.2+, tablesorter <span class="version">2.16</span>+, the filter widget 2.16+ and <a href="http://ivaynberg.github.io/select2/">Select2</a> v3.4.6+ (not tested on older select2 versions)</li>
|
||||
<li>There are only two filter formatter options, the rest are all select2 options (defaults shown below):
|
||||
<pre class="prettyprint lang-js">// select2 filter formatter options
|
||||
cellText : '', // Text (wrapped in a label element)
|
||||
match : true, // adds "filter-match" to header & modifys search
|
||||
|
||||
// ANY select2 options can be include below (showing default settings for this formatter code)
|
||||
multiple : true, // allow multiple selections
|
||||
width : '100%' // reduce this width if you add cellText</pre>
|
||||
</li>
|
||||
<li>This demo uses the new <a href="index.html#widget-filter-selectsource"><code>filter_selectSource</code></a> option which is only available in tablesorter <span class="version">v2.16</span>+
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h1>Demo</h1>
|
||||
<div id="demo"><button class="reset">Reset Search</button>
|
||||
<table class="tablesorter">
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- filter-match is automatically added by select2 "match" option -->
|
||||
<th>AlphaNumeric (match)</th>
|
||||
<th class="filter-onlyAvail">AlphaNumeric (exact; only available)</th>
|
||||
<th>Numeric</th>
|
||||
<th>Animals</th>
|
||||
<th>Sites</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><td>abc 123</td><td>abc 123</td><td>10</td><td>Koala</td><td>http://www.google.com</td></tr>
|
||||
<tr><td>abc 1</td><td>abc 1</td><td>34</td><td>Ox</td><td>http://www.yahoo.com</td></tr>
|
||||
<tr><td>abc 9</td><td>abc 9</td><td>10</td><td>Girafee</td><td>http://www.facebook.com</td></tr>
|
||||
<tr><td>zyx 24</td><td>zyx 24</td><td>67</td><td>Bison</td><td>http://www.whitehouse.gov/</td></tr>
|
||||
<tr><td>abc 11</td><td>abc 11</td><td>3</td><td>Chimp</td><td>http://www.ucla.edu/</td></tr>
|
||||
<tr><td>def 2</td><td>def 2</td><td>56</td><td>Elephant</td><td>http://www.wikipedia.org/</td></tr>
|
||||
<tr><td>abc 9</td><td>abc 9</td><td>75</td><td>Lion</td><td>http://www.nytimes.com/</td></tr>
|
||||
<tr><td>def 10</td><td>def 10</td><td>87</td><td>Zebra</td><td>http://www.google.com</td></tr>
|
||||
<tr><td>zyx 1</td><td>zyx 1</td><td>99</td><td>Koala</td><td>http://www.mit.edu/</td></tr>
|
||||
<tr><td>zyx 12</td><td>zyx 12</td><td>0</td><td>Llama</td><td>http://www.nasa.gov/</td></tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
|
||||
<h1>Header</h1>
|
||||
<div>
|
||||
<pre class="prettyprint lang-html"><!-- jQuery -->
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
|
||||
|
||||
<!-- Tablesorter: required -->
|
||||
<link href="../css/theme.blue.css" rel="stylesheet">
|
||||
<script src="../js/jquery.tablesorter.js"></script>
|
||||
<script src="../js/jquery.tablesorter.widgets.js"></script>
|
||||
|
||||
<!-- Select2 code -->
|
||||
<link href="http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.6/select2.min.css" rel="stylesheet">
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.6/select2.min.js"></script>
|
||||
<script src="../js/jquery.tablesorter.widgets-filter-formatter-select2.js"></script></pre>
|
||||
</div>
|
||||
|
||||
<h1>HTML</h1>
|
||||
<div id="html">
|
||||
<pre class="prettyprint lang-html"></pre>
|
||||
</div>
|
||||
|
||||
<h1>Javascript</h1>
|
||||
<div id="javascript">
|
||||
<pre class="prettyprint lang-javascript"></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -468,7 +468,8 @@
|
||||
<li><a href="example-widget-filter-any-match.html">external option (match any column)</a> (<span class="version">v2.13.3</span>; <span class="version updated">v2.15</span>)</li>
|
||||
<li><a href="example-widget-filter-external-inputs.html">external inputs</a> (<span class="version">v2.14</span>; <span class="version updated">v2.15</span>)</li>
|
||||
<li><a href="example-widget-filter-custom.html">custom</a> (v2.3.6; <span class="version updated">v2.10.1</span>)</li>
|
||||
<li>formatter (<a href="example-widget-filter-formatter-1.html">jQuery UI widgets</a> and <a href="example-widget-filter-formatter-2.html">HTML5 Elements</a>) (v2.7.7; <span class="version updated">v2.15</span>).</li>
|
||||
<li>formatter: <a href="example-widget-filter-formatter-1.html">jQuery UI widgets</a> and <a href="example-widget-filter-formatter-2.html">HTML5 Elements</a> (v2.7.7; <span class="version updated">v2.15</span>).</li>
|
||||
<li>formatter: <a href="example-widget-filter-formatter-select2.html">select2</a> (<span class="version updated">v2.16.0</span>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Grouping rows widget:
|
||||
@ -516,9 +517,7 @@
|
||||
<h4>Work-in-progress</h4>
|
||||
<ul>
|
||||
<li><span class="label label-info">Beta</span> <a href="../beta-testing/example-pager-custom-controls.html">Custom pager control script</a></li>
|
||||
<li><span class="label label-info">Beta</span> <a href="../beta-testing/example-external-filters-using-select2.html">External filters using Select2 plugin</a> (<span class="version updated">v2.15</span>)</li>
|
||||
<li><span class="label label-info">Alpha</span> <a href="../beta-testing/example-widget-column-reorder.html">Column reorder widget</a> - not working 100% with sticky headers</li>
|
||||
<li><span class="label label-info">Alpha</span> <a href="../beta-testing/example-widget-sum-columns.html">Column sum widget</a> - still needs LOTS of work!</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
130
js/jquery.tablesorter.widgets-filter-formatter-select2.js
Normal file
130
js/jquery.tablesorter.widgets-filter-formatter-select2.js
Normal file
@ -0,0 +1,130 @@
|
||||
/*! Filter widget formatter functions - updated 4/20/2014 (v2.16)
|
||||
* requires: jQuery 1.7.2+, tableSorter 2.16+, filter widget 2.16+ and select2 v3.4.6+ plugin
|
||||
*/
|
||||
/*jshint browser:true, jquery:true, unused:false */
|
||||
/*global jQuery: false */
|
||||
;(function($){
|
||||
"use strict";
|
||||
|
||||
var ts = $.tablesorter || {};
|
||||
ts.filterFormatter = ts.filterFormatter || {};
|
||||
|
||||
/************************\
|
||||
Select2 Filter Formatter
|
||||
\************************/
|
||||
ts.filterFormatter.select2 = function($cell, indx, select2Def) {
|
||||
var o = $.extend({
|
||||
// select2 filter formatter options
|
||||
cellText : '', // Text (wrapped in a label element)
|
||||
match : true, // adds "filter-match" to header
|
||||
// include ANY select2 options below
|
||||
multiple : true,
|
||||
width : '100%'
|
||||
|
||||
}, select2Def ),
|
||||
arry, data,
|
||||
c = $cell.closest('table')[0].config,
|
||||
wo = c.widgetOptions,
|
||||
// Add a hidden input to hold the range values
|
||||
$input = $('<input class="filter" type="hidden">')
|
||||
.appendTo($cell)
|
||||
// hidden filter update namespace trigger by filter widget
|
||||
.bind('change' + c.namespace + 'filter', function(){
|
||||
var val = this.value;
|
||||
val = val.replace(/[/()$]/g, '').split('|');
|
||||
updateSelect2(val);
|
||||
}),
|
||||
$header = c.$headers.filter('[data-column="' + indx + '"]:last'),
|
||||
onlyAvail = $header.hasClass(wo.filter_onlyAvail),
|
||||
$shcell = [],
|
||||
match = o.match ? '' : '$',
|
||||
|
||||
// this function updates the hidden input and adds the current values to the header cell text
|
||||
updateSelect2 = function(v, notrigger) {
|
||||
v = typeof v === "undefined" || v === '' ? $cell.find('.select2').select2('val') || o.value || '' : v || '';
|
||||
$input
|
||||
// add equal to the beginning, so we filter exact numbers
|
||||
.val( $.isArray(v) && v.length ? '/(' + (v || []).join(match + '|') + match + ')/' : '' )
|
||||
.trigger( notrigger ? '' : 'search' ).end()
|
||||
.find('.select2').select2('val', v);
|
||||
// update sticky header cell
|
||||
if ($shcell.length) {
|
||||
$shcell
|
||||
.find('.select2').select2('val', v);
|
||||
}
|
||||
},
|
||||
updateOptions = function(){
|
||||
data = [];
|
||||
arry = ts.filter.getOptionSource(c.$table[0], indx, onlyAvail) || [];
|
||||
// build select2 data option
|
||||
$.each(arry, function(i,v){
|
||||
data.push({id: v, text: v});
|
||||
});
|
||||
o.data = data;
|
||||
};
|
||||
|
||||
// get filter-match class from option
|
||||
$header.toggleClass('filter-match', o.match);
|
||||
if (o.cellText) {
|
||||
$cell.prepend('<label>' + o.cellText + '</label>');
|
||||
}
|
||||
|
||||
if (!(o.ajax && !$.isEmptyObject(o.ajax)) && !o.data) {
|
||||
updateOptions();
|
||||
if (onlyAvail) {
|
||||
c.$table.bind('filterEnd', function(){
|
||||
updateOptions();
|
||||
$cell.add($shcell).find('.select2').select2(o);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// add a select2!
|
||||
$('<input class="select2 select2-' + indx + '" type="hidden" />')
|
||||
.val(o.value)
|
||||
.appendTo($cell)
|
||||
.select2(o)
|
||||
.bind('change', function(){
|
||||
updateSelect2();
|
||||
});
|
||||
|
||||
// update spinner from hidden input, in case of saved filters
|
||||
c.$table.bind('filterFomatterUpdate', function(){
|
||||
// value = '/(x$|y$)/' => 'x,y'
|
||||
var val = c.$table.data('lastSearch')[indx] || '';
|
||||
val = val.replace(/[/()$]/g, '').split('|');
|
||||
$cell.find('.select2').select2('val', val);
|
||||
updateSelect2(val, true);
|
||||
});
|
||||
|
||||
// has sticky headers?
|
||||
c.$table.bind('stickyHeadersInit', function(){
|
||||
$shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
|
||||
// add a select2!
|
||||
$('<input class="select2 select2-' + indx + '" type="hidden">')
|
||||
.val(o.value)
|
||||
.appendTo($shcell)
|
||||
.select2(o)
|
||||
.bind('change', function(){
|
||||
$cell.find('.select2').select2('val', $shcell.find('.select2').select2('val') );
|
||||
updateSelect2();
|
||||
});
|
||||
if (o.cellText) {
|
||||
$shcell.prepend('<label>' + o.cellText + '</label>');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// on reset
|
||||
c.$table.bind('filterReset', function(){
|
||||
$cell.find('.select2').select2('val', o.value || '');
|
||||
setTimeout(function(){
|
||||
updateSelect2();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
updateSelect2();
|
||||
return $input;
|
||||
};
|
||||
|
||||
})(jQuery);
|
Loading…
Reference in New Issue
Block a user