table_setter 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +20 -0
- data/LICENSE +20 -0
- data/README +10 -0
- data/Rakefile +66 -0
- data/TODO +3 -0
- data/VERSION.yml +5 -0
- data/bin/table-setter +5 -0
- data/doc/TableFu/Formatting.html +178 -0
- data/doc/TableSetter/App.html +176 -0
- data/doc/TableSetter/Command.html +376 -0
- data/doc/TableSetter/Table.html +1813 -0
- data/doc/TableSetter.html +292 -0
- data/doc/_index.html +146 -0
- data/doc/class_list.html +36 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +50 -0
- data/doc/css/style.css +268 -0
- data/doc/file.README.html +68 -0
- data/doc/file_list.html +38 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +68 -0
- data/doc/js/app.js +99 -0
- data/doc/js/full_list.js +106 -0
- data/doc/js/jquery.js +19 -0
- data/doc/method_list.html +291 -0
- data/doc/top-level-namespace.html +85 -0
- data/documentation/css/dawn.css +121 -0
- data/documentation/css/styles.css +63 -0
- data/documentation/images/folder.png +0 -0
- data/documentation/images/key.png +0 -0
- data/documentation/images/proplogo.png +0 -0
- data/documentation/images/publish.png +0 -0
- data/documentation/images/text-x-generic.png +0 -0
- data/documentation/index.html.erb +221 -0
- data/documentation/tables/example/index.html +4074 -0
- data/documentation/tables/example_faceted/index.html +17239 -0
- data/documentation/tables/example_formatted/index.html +861 -0
- data/documentation/tables/example_local/1/index.html +6084 -0
- data/documentation/tables/example_local/10/index.html +6084 -0
- data/documentation/tables/example_local/11/index.html +6084 -0
- data/documentation/tables/example_local/12/index.html +6084 -0
- data/documentation/tables/example_local/13/index.html +6084 -0
- data/documentation/tables/example_local/14/index.html +6084 -0
- data/documentation/tables/example_local/15/index.html +6084 -0
- data/documentation/tables/example_local/16/index.html +6084 -0
- data/documentation/tables/example_local/17/index.html +6084 -0
- data/documentation/tables/example_local/18/index.html +6084 -0
- data/documentation/tables/example_local/19/index.html +6084 -0
- data/documentation/tables/example_local/2/index.html +6084 -0
- data/documentation/tables/example_local/20/index.html +6084 -0
- data/documentation/tables/example_local/21/index.html +6084 -0
- data/documentation/tables/example_local/22/index.html +6084 -0
- data/documentation/tables/example_local/23/index.html +6084 -0
- data/documentation/tables/example_local/24/index.html +1404 -0
- data/documentation/tables/example_local/3/index.html +6084 -0
- data/documentation/tables/example_local/4/index.html +6084 -0
- data/documentation/tables/example_local/5/index.html +6084 -0
- data/documentation/tables/example_local/6/index.html +6084 -0
- data/documentation/tables/example_local/7/index.html +6084 -0
- data/documentation/tables/example_local/8/index.html +6084 -0
- data/documentation/tables/example_local/9/index.html +6084 -0
- data/documentation/tables/example_local/index.html +6084 -0
- data/documentation/tables/favicon.ico +0 -0
- data/documentation/tables/images/th_arrow_asc.gif +0 -0
- data/documentation/tables/images/th_arrow_desc.gif +0 -0
- data/documentation/tables/index.html +48 -0
- data/documentation/tables/javascripts/application.js +32 -0
- data/documentation/tables/javascripts/jquery.tablesorter.js +852 -0
- data/documentation/tables/javascripts/jquery.tablesorter.multipagefilter.js +111 -0
- data/documentation/tables/javascripts/jquery.tablesorter.pager.js +183 -0
- data/documentation/tables/stylesheets/stylesheet.css +67 -0
- data/index.html +238 -0
- data/lib/table_setter/app.rb +54 -0
- data/lib/table_setter/command.rb +139 -0
- data/lib/table_setter/table.rb +226 -0
- data/lib/table_setter.rb +32 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/table-setter-app_spec.rb +24 -0
- data/spec/table-setter_spec.rb +179 -0
- data/table_setter.gemspec +171 -0
- data/template/config.ru +33 -0
- data/template/public/favicon.ico +0 -0
- data/template/public/images/th_arrow_asc.gif +0 -0
- data/template/public/images/th_arrow_desc.gif +0 -0
- data/template/public/javascripts/application.js +32 -0
- data/template/public/javascripts/jquery.tablesorter.js +852 -0
- data/template/public/javascripts/jquery.tablesorter.multipagefilter.js +111 -0
- data/template/public/javascripts/jquery.tablesorter.pager.js +183 -0
- data/template/public/stylesheets/stylesheet.css +74 -0
- data/template/tables/example.yml +21 -0
- data/template/tables/example_faceted.yml +27 -0
- data/template/tables/example_formatted.csv +1 -0
- data/template/tables/example_formatted.yml +27 -0
- data/template/tables/example_local.csv +5806 -0
- data/template/tables/example_local.yml +27 -0
- data/template/views/404.erb +4 -0
- data/template/views/500.erb +4 -0
- data/template/views/index.erb +7 -0
- data/template/views/layout.erb +34 -0
- data/template/views/table.erb +78 -0
- metadata +240 -0
@@ -0,0 +1,111 @@
|
|
1
|
+
(function($){
|
2
|
+
$.extend({
|
3
|
+
tablesorterMultiPageFilter : new function(){
|
4
|
+
|
5
|
+
function replaceRows(table){
|
6
|
+
// clear the table body
|
7
|
+
$.tablesorter.clearTableBody(table);
|
8
|
+
var tableBody = $(table.tBodies[0]);
|
9
|
+
|
10
|
+
for(var i = 0; i < table.config.collection.length; i++) {
|
11
|
+
var o = table.config.collection[i];
|
12
|
+
var l = o.length;
|
13
|
+
for(var j=0; j < l; j++) {
|
14
|
+
tableBody[0].appendChild(o[j]);
|
15
|
+
}
|
16
|
+
}
|
17
|
+
$(table).trigger("applyWidgets");
|
18
|
+
}
|
19
|
+
|
20
|
+
|
21
|
+
function renderTable(table){
|
22
|
+
var newString = table.config.filterSelector[0].value;
|
23
|
+
if(newString.length > 1){
|
24
|
+
if(table.config.container){
|
25
|
+
table.config.container.hide();
|
26
|
+
}
|
27
|
+
|
28
|
+
var toShow = [];
|
29
|
+
newString = $.trim(newString);
|
30
|
+
var words = newString.toLowerCase().split(" ");
|
31
|
+
|
32
|
+
// no change, don't do anything
|
33
|
+
if (newString === table.config.string) return false;
|
34
|
+
// press was just a string
|
35
|
+
if (newString[-1] === " ") { table.config.string = newString; return false; }
|
36
|
+
// most of the string is old
|
37
|
+
if (newString.indexOf(table.config.string) > -1){
|
38
|
+
// don't change the search array but we only need the last word
|
39
|
+
words = [words.pop()];
|
40
|
+
} else {
|
41
|
+
// we need to search all rows
|
42
|
+
table.config.collection = table.config.rowsCopy.slice(0);
|
43
|
+
};
|
44
|
+
|
45
|
+
// split out words
|
46
|
+
len = table.config.collection.length;
|
47
|
+
var counter = 0;
|
48
|
+
for(var j = 0; j < len; j++ ){
|
49
|
+
var text = table.config.collection[j].text().toLowerCase();
|
50
|
+
for (var i=0; i < words.length; i++) {
|
51
|
+
if (text.indexOf(words[i]) > -1) {
|
52
|
+
toShow.push(table.config.collection[j]);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
counter++;
|
56
|
+
};
|
57
|
+
table.config.collection = toShow.slice(0);
|
58
|
+
replaceRows(table);
|
59
|
+
table.config.string = newString;
|
60
|
+
} else {
|
61
|
+
table.config.string = "";
|
62
|
+
table.config.collection = table.config.rowsCopy.slice(0);
|
63
|
+
if(table.config.container){
|
64
|
+
table.config.container.show();
|
65
|
+
} else {
|
66
|
+
replaceRows(table);
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
this.defaults = {
|
72
|
+
filterSelector: $("#filter")
|
73
|
+
}
|
74
|
+
|
75
|
+
this.init = function(settings) {
|
76
|
+
return this.each(function(){
|
77
|
+
config = $.extend(this.config, $.tablesorterMultiPageFilter.defaults, settings);
|
78
|
+
|
79
|
+
var table = this,
|
80
|
+
filter = config.filterSelector
|
81
|
+
;
|
82
|
+
|
83
|
+
// save old appenders and define a new one that grabs the row cache and saves it
|
84
|
+
if(!table.config.rowsCopy){
|
85
|
+
var oldAppend = config.appender || function (table, rows) {};
|
86
|
+
this.config.appender = function(table, rows){
|
87
|
+
table.config.rowsCopy = rows;
|
88
|
+
oldAppend(table, rows);
|
89
|
+
}
|
90
|
+
$(this).trigger("appendCache");
|
91
|
+
}
|
92
|
+
table.config.string = "";
|
93
|
+
table.config.collection = [];
|
94
|
+
table.config.collection = table.config.rowsCopy.slice(0)
|
95
|
+
|
96
|
+
function filterMe(){
|
97
|
+
renderTable(table);
|
98
|
+
return false;
|
99
|
+
}
|
100
|
+
$(filter).keyup(filterMe);
|
101
|
+
$(filter).submit(filterMe);
|
102
|
+
});
|
103
|
+
}
|
104
|
+
}
|
105
|
+
});
|
106
|
+
|
107
|
+
|
108
|
+
$.fn.extend({
|
109
|
+
tablesorterMultiPageFilter: $.tablesorterMultiPageFilter.init
|
110
|
+
});
|
111
|
+
}(jQuery))
|
@@ -0,0 +1,183 @@
|
|
1
|
+
(function($) {
|
2
|
+
$.extend({
|
3
|
+
tablesorterPager: new function() {
|
4
|
+
|
5
|
+
function updatePageDisplay(c) {
|
6
|
+
var s = $(c.cssPageDisplay,c.container).text((c.page+1) + c.seperator + c.totalPages);
|
7
|
+
}
|
8
|
+
|
9
|
+
function setPageSize(table,size) {
|
10
|
+
var c = table.config;
|
11
|
+
c.size = size;
|
12
|
+
c.totalPages = Math.ceil(c.totalRows / c.size);
|
13
|
+
c.pagerPositionSet = false;
|
14
|
+
moveToPage(table);
|
15
|
+
fixPosition(table);
|
16
|
+
}
|
17
|
+
|
18
|
+
function fixPosition(table) {
|
19
|
+
var c = table.config;
|
20
|
+
if(!c.pagerPositionSet && c.positionFixed) {
|
21
|
+
var c = table.config, o = $(table);
|
22
|
+
if(o.offset) {
|
23
|
+
c.container.css({
|
24
|
+
top: o.offset().top + o.height() + 'px',
|
25
|
+
position: 'absolute'
|
26
|
+
});
|
27
|
+
}
|
28
|
+
c.pagerPositionSet = true;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
function moveToFirstPage(table) {
|
33
|
+
var c = table.config;
|
34
|
+
c.page = 0;
|
35
|
+
moveToPage(table);
|
36
|
+
}
|
37
|
+
|
38
|
+
function moveToLastPage(table) {
|
39
|
+
var c = table.config;
|
40
|
+
c.page = (c.totalPages-1);
|
41
|
+
moveToPage(table);
|
42
|
+
}
|
43
|
+
|
44
|
+
function moveToNextPage(table) {
|
45
|
+
var c = table.config;
|
46
|
+
c.page++;
|
47
|
+
if(c.page >= (c.totalPages-1)) {
|
48
|
+
c.page = (c.totalPages-1);
|
49
|
+
}
|
50
|
+
moveToPage(table);
|
51
|
+
}
|
52
|
+
|
53
|
+
function moveToPrevPage(table) {
|
54
|
+
var c = table.config;
|
55
|
+
c.page--;
|
56
|
+
if(c.page <= 0) {
|
57
|
+
c.page = 0;
|
58
|
+
}
|
59
|
+
moveToPage(table);
|
60
|
+
}
|
61
|
+
|
62
|
+
|
63
|
+
function moveToPage(table) {
|
64
|
+
var c = table.config;
|
65
|
+
if(c.page < 0 || c.page > (c.totalPages-1)) {
|
66
|
+
c.page = 0;
|
67
|
+
}
|
68
|
+
|
69
|
+
renderTable(table,c.rowsCopy);
|
70
|
+
}
|
71
|
+
|
72
|
+
function renderTable(table,rows) {
|
73
|
+
|
74
|
+
var c = table.config;
|
75
|
+
var l = rows.length;
|
76
|
+
var s = (c.page * c.size);
|
77
|
+
var e = (s + c.size);
|
78
|
+
if(e > rows.length ) {
|
79
|
+
e = rows.length;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
var tableBody = $(table.tBodies[0]);
|
84
|
+
|
85
|
+
// clear the table body
|
86
|
+
|
87
|
+
$.tablesorter.clearTableBody(table);
|
88
|
+
|
89
|
+
for(var i = s; i < e; i++) {
|
90
|
+
|
91
|
+
//tableBody.append(rows[i]);
|
92
|
+
|
93
|
+
var o = rows[i];
|
94
|
+
var l = o.length;
|
95
|
+
for(var j=0; j < l; j++) {
|
96
|
+
|
97
|
+
tableBody[0].appendChild(o[j]);
|
98
|
+
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
fixPosition(table,tableBody);
|
103
|
+
|
104
|
+
$(table).trigger("applyWidgets");
|
105
|
+
|
106
|
+
if( c.page >= c.totalPages ) {
|
107
|
+
moveToLastPage(table);
|
108
|
+
}
|
109
|
+
|
110
|
+
updatePageDisplay(c);
|
111
|
+
}
|
112
|
+
|
113
|
+
this.appender = function(table,rows) {
|
114
|
+
|
115
|
+
var c = table.config;
|
116
|
+
|
117
|
+
c.rowsCopy = rows;
|
118
|
+
c.totalRows = rows.length;
|
119
|
+
c.totalPages = Math.ceil(c.totalRows / c.size);
|
120
|
+
renderTable(table,rows);
|
121
|
+
};
|
122
|
+
|
123
|
+
this.defaults = {
|
124
|
+
size: 10,
|
125
|
+
offset: 0,
|
126
|
+
page: 0,
|
127
|
+
totalRows: 0,
|
128
|
+
totalPages: 0,
|
129
|
+
container: null,
|
130
|
+
cssNext: '.next',
|
131
|
+
cssPrev: '.prev',
|
132
|
+
cssFirst: '.first',
|
133
|
+
cssLast: '.last',
|
134
|
+
cssPageDisplay: '.pagedisplay',
|
135
|
+
cssPageSize: '.pagesize',
|
136
|
+
seperator: "/",
|
137
|
+
positionFixed: true,
|
138
|
+
appender: this.appender
|
139
|
+
};
|
140
|
+
|
141
|
+
this.construct = function(settings) {
|
142
|
+
|
143
|
+
return this.each(function() {
|
144
|
+
|
145
|
+
config = $.extend(this.config, $.tablesorterPager.defaults, settings);
|
146
|
+
|
147
|
+
var table = this, pager = config.container;
|
148
|
+
|
149
|
+
$(this).trigger("appendCache");
|
150
|
+
|
151
|
+
config.size = parseInt($(".pagesize",pager).val());
|
152
|
+
|
153
|
+
$(config.cssFirst,pager).click(function() {
|
154
|
+
moveToFirstPage(table);
|
155
|
+
return false;
|
156
|
+
});
|
157
|
+
$(config.cssNext,pager).click(function() {
|
158
|
+
moveToNextPage(table);
|
159
|
+
return false;
|
160
|
+
});
|
161
|
+
$(config.cssPrev,pager).click(function() {
|
162
|
+
moveToPrevPage(table);
|
163
|
+
return false;
|
164
|
+
});
|
165
|
+
$(config.cssLast,pager).click(function() {
|
166
|
+
moveToLastPage(table);
|
167
|
+
return false;
|
168
|
+
});
|
169
|
+
$(config.cssPageSize,pager).change(function() {
|
170
|
+
setPageSize(table,parseInt($(this).val()));
|
171
|
+
return false;
|
172
|
+
});
|
173
|
+
});
|
174
|
+
};
|
175
|
+
|
176
|
+
}
|
177
|
+
});
|
178
|
+
// extend plugin scope
|
179
|
+
$.fn.extend({
|
180
|
+
tablesorterPager: $.tablesorterPager.construct
|
181
|
+
});
|
182
|
+
|
183
|
+
})(jQuery);
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#table_fu{
|
2
|
+
width: 980px;
|
3
|
+
margin-left: auto;
|
4
|
+
margin-right: auto;
|
5
|
+
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
6
|
+
font-size: 14px;
|
7
|
+
line-height: 20px;
|
8
|
+
color: #333;
|
9
|
+
}
|
10
|
+
#table_fu *{
|
11
|
+
margin: 0;
|
12
|
+
padding: 0;
|
13
|
+
}
|
14
|
+
#table_fu div#table_title{
|
15
|
+
font-size: 24px;
|
16
|
+
font-weight: bold;
|
17
|
+
font-family: Palatino Linotype,Book Antiqua,Palatino,serif;
|
18
|
+
}
|
19
|
+
#table_fu div{
|
20
|
+
margin-bottom: 14px;
|
21
|
+
}
|
22
|
+
#table_fu #controls{
|
23
|
+
overflow:auto;
|
24
|
+
clear: both;
|
25
|
+
margin-bottom: 0px;
|
26
|
+
|
27
|
+
}
|
28
|
+
#table_fu div#pager{
|
29
|
+
float:right;
|
30
|
+
width: 15%;
|
31
|
+
}
|
32
|
+
#table_fu div#pager div.pagedisplay{
|
33
|
+
display: inline;
|
34
|
+
}
|
35
|
+
#table_fu div#filter{
|
36
|
+
float:left;
|
37
|
+
width:30%;
|
38
|
+
}
|
39
|
+
|
40
|
+
#table_fu #data{
|
41
|
+
border: 1px solid #ababab;
|
42
|
+
border-collapse: collapse;
|
43
|
+
margin-bottom:14px;
|
44
|
+
width: 100%;
|
45
|
+
}
|
46
|
+
#table_fu td, #table_fu th{
|
47
|
+
padding: 7px;
|
48
|
+
border-bottom: 1px solid #ababab;
|
49
|
+
text-align: center;
|
50
|
+
}
|
51
|
+
#table_fu th{
|
52
|
+
cursor: pointer;
|
53
|
+
vertical-align: bottom;
|
54
|
+
}
|
55
|
+
#table_fu td.sorted{
|
56
|
+
background-color: #edf4ff;
|
57
|
+
}
|
58
|
+
#table_fu td .bar{
|
59
|
+
width: 100%;
|
60
|
+
height: 100%;
|
61
|
+
text-align:left;
|
62
|
+
background-color: #99CA3C;
|
63
|
+
color:#444;
|
64
|
+
float:left;
|
65
|
+
padding:0.5em;
|
66
|
+
margin-top: 0.7em;
|
67
|
+
font-weight:bold;
|
68
|
+
}
|
69
|
+
#table_fu th.headerSortDown{
|
70
|
+
background: #ccc url(../images/th_arrow_asc.gif) no-repeat 100% 75%;
|
71
|
+
}
|
72
|
+
#table_fu th.headerSortUp{
|
73
|
+
background: #ccc url(../images/th_arrow_desc.gif) no-repeat 100% 75%;
|
74
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
table:
|
2
|
+
title: Failed Banks List
|
3
|
+
google_key: thJa_BvqQuNdaFfFJMMII0Q
|
4
|
+
deck:
|
5
|
+
<p>The financial crisis has contributed to the failure of scores of banks this year. We’ve put together a handy chart of the fallen banks, the federal agency that provided oversight to each one, and the major public enforcement that occurred against the bank prior to its collapse. It’s all sortable state, date, or even regulatory agency.</p>
|
6
|
+
footer:
|
7
|
+
<p>Source: <a href="http://www.fdic.gov/bank/individual/failed/banklist.html">FDIC</a></p>
|
8
|
+
column_options:
|
9
|
+
columns:
|
10
|
+
- Bank
|
11
|
+
- State
|
12
|
+
- Closing Date
|
13
|
+
- Our Coverage
|
14
|
+
- Federal Regulators
|
15
|
+
- Public Enforcement Documents
|
16
|
+
style:
|
17
|
+
Bank: 'text-align:left;'
|
18
|
+
sorted_by:
|
19
|
+
Closing Date: 'ascending'
|
20
|
+
live: true
|
21
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
table:
|
2
|
+
title: Appropriations by District
|
3
|
+
google_key: tcSL0eqrj3yb5d6ljak4Dcw
|
4
|
+
deck:
|
5
|
+
<p><strong>by <a href="http://www.propublica.org/site/author/christopher_flavelle/">Christopher Flavelle</a>, ProPublica - July 7, 2009 4:00 pm EST</strong></p>
|
6
|
+
footer:
|
7
|
+
<p>This chart and other stories are part of <a href="http://www.propublica.org/ion/stimulus/">Eye on the Stimulus</a>, our blog dedicated to tracking the stimulus from bill to building.</p>
|
8
|
+
column_options:
|
9
|
+
columns:
|
10
|
+
- State
|
11
|
+
- Cong. District
|
12
|
+
- Representative
|
13
|
+
- Party
|
14
|
+
- Leadership
|
15
|
+
- Projects
|
16
|
+
- Total Appropriation
|
17
|
+
style:
|
18
|
+
State: "text-align:left"
|
19
|
+
formatting:
|
20
|
+
Total Appropriation: :currency
|
21
|
+
total: ['Total Appropriation', 'Projects']
|
22
|
+
sorted_by:
|
23
|
+
Cong. District: descending
|
24
|
+
faceting:
|
25
|
+
facet_by: State
|
26
|
+
live: true
|
27
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
Agency,Spent (Thousands),In Process (Thousands),Left to Spend (Thousands),Total (Thousands),Spent (%),Left To Spend (Thousands),Source,,,
|
@@ -0,0 +1,27 @@
|
|
1
|
+
table:
|
2
|
+
title: Stimulus Progress
|
3
|
+
file: example_formatted.csv
|
4
|
+
deck:
|
5
|
+
<p>The success of the federal stimulus program may hinge on the speed with which the government is able to distribute the billions authorized by Congress. Unlike some other estimates of the cost of the stimulus, which are based on spending projections, we took our numbers from the actual budget authority issued by Congress — $792 billion and change. We'll be tracking the progress of stimulus payments made by federal agencies weekly.</p>
|
6
|
+
|
7
|
+
footer:
|
8
|
+
<p>This chart and other stories are part of Eye on the Stimulus, our blog dedicated to tracking the stimulus from bill to building.</p>
|
9
|
+
column_options:
|
10
|
+
columns:
|
11
|
+
- Agency Webpage
|
12
|
+
- Spent (Thousands)
|
13
|
+
- In Process (Thousands)
|
14
|
+
- Left to Spend (Thousands)
|
15
|
+
- Total (Thousands)
|
16
|
+
- Spent (%)
|
17
|
+
style:
|
18
|
+
Agency: 'text-align:left;'
|
19
|
+
Spent (%): 'width: 200px;'
|
20
|
+
sorted_by:
|
21
|
+
Spent (%): ascending
|
22
|
+
formatting:
|
23
|
+
Spent (%): bar
|
24
|
+
Agency Webpage:
|
25
|
+
method: link
|
26
|
+
arguments: [Agency, Source]
|
27
|
+
live: true
|