tablecloth-rails 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +1 -0
- data/lib/tablecloth-rails.rb +2 -0
- data/lib/tablecloth-rails/engine.rb +6 -0
- data/lib/tablecloth-rails/version.rb +12 -0
- data/tablecloth-rails.gemspec +25 -0
- data/vendor/assets/javascripts/tablecloth.js +184 -0
- data/vendor/assets/stylesheets/tablecloth.css +32 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f812590fa967a2928c7b360c1be3fc3bde27e4d7
|
4
|
+
data.tar.gz: 69e1f4aac6074762c9e250d808dc1e6d4be0294b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 67b0606ec3dc7a33f0ce07997e053c7f2c7a892820b8e6ae8ed33274cac49c783418b7d128411f427218676dd88b2f22f6acb923781fb11e4e4d6e62173d6093
|
7
|
+
data.tar.gz: 8023a581503c1d8beab5dd2c58c80028fc00bb7b0a165fa4d5748b86ee0f434339536c391ae255e29371609bc8a62df297eb4cb4fb26fa8b54aab5a8b7762694
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Doc Walker
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# tablecloth-rails [![Gem Version](https://badge.fury.io/rb/tablecloth-rails.png)](http://badge.fury.io/rb/tablecloth-rails)
|
2
|
+
|
3
|
+
> Created by Doc Walker
|
4
|
+
|
5
|
+
Provides the `Tablecloth` JavaScript/CSS packaged for the Rails 3.1+ asset pipeline.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add these lines to your application's Gemfile:
|
10
|
+
|
11
|
+
# tablecloth table js/css packaged for the rails asset pipeline
|
12
|
+
gem 'tablecloth-rails', '~> 1.0'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install tablecloth-rails
|
21
|
+
|
22
|
+
Gem version notes:
|
23
|
+
|
24
|
+
- x.y.z version will track the `Tablecloth` version;
|
25
|
+
- It may contain a suffix to differentiate versions of the gem based on the same `Tablecloth` version;
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Add these lines to `app/assets/javascripts/application.js`
|
30
|
+
|
31
|
+
// provides tablecloth table js/css from gem 'tablecloth-rails':
|
32
|
+
//= require tablecloth
|
33
|
+
|
34
|
+
Add these lines to `app/assets/stylesheets/application.css`
|
35
|
+
|
36
|
+
provides tablecloth table js/css from gem 'tablecloth-rails':
|
37
|
+
= require tablecloth
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
1. Fork it
|
42
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
+
5. Create new Pull Request
|
46
|
+
|
47
|
+
## Acknowledgements
|
48
|
+
|
49
|
+
- [Tablecloth](http://cssglobe.com/lab/tablecloth/) written by Alen Grakalic, provided by Css Globe (cssglobe.com)
|
50
|
+
- [RailsCast #245](http://railscasts.com/episodes/245-new-gem-with-bundler) New Gem with Bundler -- inspiration
|
51
|
+
- [Gemify Assets for Rails](http://prioritized.net/blog/gemify-assets-for-rails/) -- guidance
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Tablecloth
|
2
|
+
module Rails
|
3
|
+
# Use tablecloth version; append a pre-release version identifier if gem
|
4
|
+
# is updated without updating version of tablecloth.
|
5
|
+
# Examples:
|
6
|
+
# "2.0.0.rc1"
|
7
|
+
# "2.0.0.pre"
|
8
|
+
# "2.0.0.beta"
|
9
|
+
# Refer to Semantic Versioning 2.0.0 (http://semver.org).
|
10
|
+
VERSION = "1.0.0"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tablecloth-rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tablecloth-rails"
|
8
|
+
spec.version = Tablecloth::Rails::VERSION
|
9
|
+
spec.authors = ["Doc Walker"]
|
10
|
+
spec.email = ["doc.walker@jameshardie.com"]
|
11
|
+
spec.description = %q{Provides the `Tablecloth` JavaScript/CSS packaged for the Rails 3.1+ asset pipeline.}
|
12
|
+
spec.summary = %q{Provides the `Tablecloth` JavaScript/CSS packaged for the Rails 3.1+ asset pipeline.}
|
13
|
+
spec.homepage = "https://github.com/jhx/gem-tablecloth-rails"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "railties", "~> 3.1"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Tablecloth
|
4
|
+
written by Alen Grakalic, provided by Css Globe (cssglobe.com)
|
5
|
+
please visit http://cssglobe.com/lab/tablecloth/
|
6
|
+
|
7
|
+
*/
|
8
|
+
|
9
|
+
this.tablecloth = function(){
|
10
|
+
|
11
|
+
// CONFIG
|
12
|
+
|
13
|
+
// if set to true then mouseover a table cell will highlight entire column (except sibling headings)
|
14
|
+
var highlightCols = true;
|
15
|
+
|
16
|
+
// if set to true then mouseover a table cell will highlight entire row (except sibling headings)
|
17
|
+
var highlightRows = true;
|
18
|
+
|
19
|
+
// if set to true then click on a table sell will select row or column based on config
|
20
|
+
var selectable = true;
|
21
|
+
|
22
|
+
// this function is called when
|
23
|
+
// add your own code if you want to add action
|
24
|
+
// function receives object that has been clicked
|
25
|
+
this.clickAction = function(obj){
|
26
|
+
//alert(obj.innerHTML);
|
27
|
+
|
28
|
+
};
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
// END CONFIG (do not edit below this line)
|
33
|
+
|
34
|
+
|
35
|
+
var tableover = false;
|
36
|
+
this.start = function(){
|
37
|
+
var tables = document.getElementsByTagName("table");
|
38
|
+
for (var i=0;i<tables.length;i++){
|
39
|
+
tables[i].onmouseover = function(){tableover = true};
|
40
|
+
tables[i].onmouseout = function(){tableover = false};
|
41
|
+
rows(tables[i]);
|
42
|
+
};
|
43
|
+
};
|
44
|
+
|
45
|
+
this.rows = function(table){
|
46
|
+
var css = "";
|
47
|
+
var tr = table.getElementsByTagName("tr");
|
48
|
+
for (var i=0;i<tr.length;i++){
|
49
|
+
css = (css == "odd") ? "even" : "odd";
|
50
|
+
tr[i].className = css;
|
51
|
+
var arr = new Array();
|
52
|
+
for(var j=0;j<tr[i].childNodes.length;j++){
|
53
|
+
if(tr[i].childNodes[j].nodeType == 1) arr.push(tr[i].childNodes[j]);
|
54
|
+
};
|
55
|
+
for (var j=0;j<arr.length;j++){
|
56
|
+
arr[j].row = i;
|
57
|
+
arr[j].col = j;
|
58
|
+
if(arr[j].innerHTML == " " || arr[j].innerHTML == "") arr[j].className += " empty";
|
59
|
+
arr[j].css = arr[j].className;
|
60
|
+
arr[j].onmouseover = function(){
|
61
|
+
over(table,this,this.row,this.col);
|
62
|
+
};
|
63
|
+
arr[j].onmouseout = function(){
|
64
|
+
out(table,this,this.row,this.col);
|
65
|
+
};
|
66
|
+
arr[j].onmousedown = function(){
|
67
|
+
down(table,this,this.row,this.col);
|
68
|
+
};
|
69
|
+
arr[j].onmouseup = function(){
|
70
|
+
up(table,this,this.row,this.col);
|
71
|
+
};
|
72
|
+
arr[j].onclick = function(){
|
73
|
+
click(table,this,this.row,this.col);
|
74
|
+
};
|
75
|
+
};
|
76
|
+
};
|
77
|
+
};
|
78
|
+
|
79
|
+
// appyling mouseover state for objects (th or td)
|
80
|
+
this.over = function(table,obj,row,col){
|
81
|
+
if (!highlightCols && !highlightRows) obj.className = obj.css + " over";
|
82
|
+
if(check1(obj,col)){
|
83
|
+
if(highlightCols) highlightCol(table,obj,col);
|
84
|
+
if(highlightRows) highlightRow(table,obj,row);
|
85
|
+
};
|
86
|
+
};
|
87
|
+
// appyling mouseout state for objects (th or td)
|
88
|
+
this.out = function(table,obj,row,col){
|
89
|
+
if (!highlightCols && !highlightRows) obj.className = obj.css;
|
90
|
+
unhighlightCol(table,col);
|
91
|
+
unhighlightRow(table,row);
|
92
|
+
};
|
93
|
+
// appyling mousedown state for objects (th or td)
|
94
|
+
this.down = function(table,obj,row,col){
|
95
|
+
obj.className = obj.css + " down";
|
96
|
+
};
|
97
|
+
// appyling mouseup state for objects (th or td)
|
98
|
+
this.up = function(table,obj,row,col){
|
99
|
+
obj.className = obj.css + " over";
|
100
|
+
};
|
101
|
+
// onclick event for objects (th or td)
|
102
|
+
this.click = function(table,obj,row,col){
|
103
|
+
if(check1){
|
104
|
+
if(selectable) {
|
105
|
+
unselect(table);
|
106
|
+
if(highlightCols) highlightCol(table,obj,col,true);
|
107
|
+
if(highlightRows) highlightRow(table,obj,row,true);
|
108
|
+
document.onclick = unselectAll;
|
109
|
+
}
|
110
|
+
};
|
111
|
+
clickAction(obj);
|
112
|
+
};
|
113
|
+
|
114
|
+
this.highlightCol = function(table,active,col,sel){
|
115
|
+
var css = (typeof(sel) != "undefined") ? "selected" : "over";
|
116
|
+
var tr = table.getElementsByTagName("tr");
|
117
|
+
for (var i=0;i<tr.length;i++){
|
118
|
+
var arr = new Array();
|
119
|
+
for(j=0;j<tr[i].childNodes.length;j++){
|
120
|
+
if(tr[i].childNodes[j].nodeType == 1) arr.push(tr[i].childNodes[j]);
|
121
|
+
};
|
122
|
+
var obj = arr[col];
|
123
|
+
if (check2(active,obj) && check3(obj)) obj.className = obj.css + " " + css;
|
124
|
+
};
|
125
|
+
};
|
126
|
+
this.unhighlightCol = function(table,col){
|
127
|
+
var tr = table.getElementsByTagName("tr");
|
128
|
+
for (var i=0;i<tr.length;i++){
|
129
|
+
var arr = new Array();
|
130
|
+
for(j=0;j<tr[i].childNodes.length;j++){
|
131
|
+
if(tr[i].childNodes[j].nodeType == 1) arr.push(tr[i].childNodes[j])
|
132
|
+
};
|
133
|
+
var obj = arr[col];
|
134
|
+
if(check3(obj)) obj.className = obj.css;
|
135
|
+
};
|
136
|
+
};
|
137
|
+
this.highlightRow = function(table,active,row,sel){
|
138
|
+
var css = (typeof(sel) != "undefined") ? "selected" : "over";
|
139
|
+
var tr = table.getElementsByTagName("tr")[row];
|
140
|
+
for (var i=0;i<tr.childNodes.length;i++){
|
141
|
+
var obj = tr.childNodes[i];
|
142
|
+
if (check2(active,obj) && check3(obj)) obj.className = obj.css + " " + css;
|
143
|
+
};
|
144
|
+
};
|
145
|
+
this.unhighlightRow = function(table,row){
|
146
|
+
var tr = table.getElementsByTagName("tr")[row];
|
147
|
+
for (var i=0;i<tr.childNodes.length;i++){
|
148
|
+
var obj = tr.childNodes[i];
|
149
|
+
if(check3(obj)) obj.className = obj.css;
|
150
|
+
};
|
151
|
+
};
|
152
|
+
this.unselect = function(table){
|
153
|
+
tr = table.getElementsByTagName("tr")
|
154
|
+
for (var i=0;i<tr.length;i++){
|
155
|
+
for (var j=0;j<tr[i].childNodes.length;j++){
|
156
|
+
var obj = tr[i].childNodes[j];
|
157
|
+
if(obj.className) obj.className = obj.className.replace("selected","");
|
158
|
+
};
|
159
|
+
};
|
160
|
+
};
|
161
|
+
this.unselectAll = function(){
|
162
|
+
if(!tableover){
|
163
|
+
tables = document.getElementsByTagName("table");
|
164
|
+
for (var i=0;i<tables.length;i++){
|
165
|
+
unselect(tables[i])
|
166
|
+
};
|
167
|
+
};
|
168
|
+
};
|
169
|
+
this.check1 = function(obj,col){
|
170
|
+
return (!(col == 0 && obj.className.indexOf("empty") != -1));
|
171
|
+
}
|
172
|
+
this.check2 = function(active,obj){
|
173
|
+
return (!(active.tagName == "TH" && obj.tagName == "TH"));
|
174
|
+
};
|
175
|
+
this.check3 = function(obj){
|
176
|
+
return (obj.className) ? (obj.className.indexOf("selected") == -1) : true;
|
177
|
+
};
|
178
|
+
|
179
|
+
start();
|
180
|
+
|
181
|
+
};
|
182
|
+
|
183
|
+
/* script initiates on page load. */
|
184
|
+
window.onload = tablecloth;
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
TableCloth
|
4
|
+
by Alen Grakalic, brought to you by cssglobe.com
|
5
|
+
|
6
|
+
*/
|
7
|
+
|
8
|
+
/* general styles */
|
9
|
+
/* original header color #328aa4 */
|
10
|
+
table, td{
|
11
|
+
font:90% Arial, Helvetica, sans-serif;
|
12
|
+
}
|
13
|
+
table{width:100%;border-collapse:collapse;margin:1em 0;}
|
14
|
+
th, td{text-align:left;padding:.5em;border:1px solid #fff;}
|
15
|
+
th{background:#444 ;color:#fff;}
|
16
|
+
td{background:#e5f1f4;}
|
17
|
+
|
18
|
+
/* tablecloth styles */
|
19
|
+
|
20
|
+
tr.even td{background:#e5f1f4;}
|
21
|
+
tr.odd td{background:#f8fbfc;}
|
22
|
+
|
23
|
+
th.over, tr.even th.over, tr.odd th.over{background:#4a98af;}
|
24
|
+
th.down, tr.even th.down, tr.odd th.down{background:#bce774;}
|
25
|
+
th.selected, tr.even th.selected, tr.odd th.selected{}
|
26
|
+
|
27
|
+
td.over, tr.even td.over, tr.odd td.over{background:#ecfbd4;}
|
28
|
+
td.down, tr.even td.down, tr.odd td.down{background:#bbb;color:black;}
|
29
|
+
td.selected, tr.even td.selected, tr.odd td.selected{background:#bbb;color:black;}
|
30
|
+
|
31
|
+
/* use this if you want to apply different styleing to empty table cells*/
|
32
|
+
td.empty, tr.odd td.empty, tr.even td.empty{background:#fff;}
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tablecloth-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Doc Walker
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Provides the `Tablecloth` JavaScript/CSS packaged for the Rails 3.1+
|
56
|
+
asset pipeline.
|
57
|
+
email:
|
58
|
+
- doc.walker@jameshardie.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/tablecloth-rails.rb
|
69
|
+
- lib/tablecloth-rails/engine.rb
|
70
|
+
- lib/tablecloth-rails/version.rb
|
71
|
+
- tablecloth-rails.gemspec
|
72
|
+
- vendor/assets/javascripts/tablecloth.js
|
73
|
+
- vendor/assets/stylesheets/tablecloth.css
|
74
|
+
homepage: https://github.com/jhx/gem-tablecloth-rails
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.0.3
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Provides the `Tablecloth` JavaScript/CSS packaged for the Rails 3.1+ asset
|
98
|
+
pipeline.
|
99
|
+
test_files: []
|