footable 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,162 @@
1
+ (function ($, w, undefined) {
2
+ if (w.footable == undefined || w.footable == null)
3
+ throw new Error('Please check and make sure footable.js is included in the page and is loaded prior to this script.');
4
+
5
+ var defaults = {
6
+ sort: true,
7
+ sorters: {
8
+ alpha: function (a, b) {
9
+ if (a == b) return 0;
10
+ if (a < b) return -1;
11
+ return 1;
12
+ },
13
+ numeric: function (a, b) {
14
+ return a - b;
15
+ }
16
+ },
17
+ parsers: {
18
+ numeric: function (cell) {
19
+ var val = $(cell).data('value') || $(cell).text().replace(/[^0-9.-]/g, '');
20
+ val = parseFloat(val);
21
+ if (isNaN(val)) val = 0;
22
+ return val;
23
+ }
24
+ },
25
+ classes: {
26
+ sort: {
27
+ sortable: 'footable-sortable',
28
+ sorted: 'footable-sorted',
29
+ descending: 'footable-sorted-desc',
30
+ indicator: 'footable-sort-indicator'
31
+ }
32
+ }
33
+ };
34
+
35
+ function Sortable() {
36
+ var p = this;
37
+ p.name = 'Footable Sortable';
38
+ p.init = function (ft) {
39
+ if (ft.options.sort == true) {
40
+ $(ft.table).bind({
41
+ 'footable_initialized': function (e) {
42
+ var cls = ft.options.classes.sort, column;
43
+
44
+ var $table = $(e.ft.table), $tbody = $table.find('> tbody'), $th;
45
+
46
+ $table.find('> thead > tr:last-child > th, > thead > tr:last-child > td').each(function (ec) {
47
+ $th = $(this), column = e.ft.columns[$th.index()];
48
+ if (column.sort.ignore != true) {
49
+ $th.addClass(cls.sortable);
50
+ $('<span />').addClass(cls.indicator).appendTo($th);
51
+ }
52
+ });
53
+
54
+ $table.find('> thead > tr:last-child > th.' + cls.sortable + ', > thead > tr:last-child > td.' + cls.sortable).click(function (ec) {
55
+ $th = $(this), column = e.ft.columns[$th.index()];
56
+ if (column.sort.ignore == true) return true;
57
+ ec.preventDefault();
58
+
59
+ $table.find('> thead > tr:last-child > th, > thead > tr:last-child > td').not($th).removeClass(cls.sorted + ' ' + cls.descending);
60
+
61
+ if ($th.hasClass(cls.sorted)) {
62
+ p.reverse(e.ft, $tbody);
63
+ $th.removeClass(cls.sorted).addClass(cls.descending);
64
+ } else if ($th.hasClass(cls.descending)) {
65
+ p.reverse(e.ft, $tbody);
66
+ $th.removeClass(cls.descending).addClass(cls.sorted);
67
+ } else {
68
+ p.sort(e.ft, $tbody, column);
69
+ $th.removeClass(cls.descending).addClass(cls.sorted);
70
+ }
71
+ e.ft.bindToggleSelectors();
72
+ e.ft.raise('footable_sorted', {column: column});
73
+ return false;
74
+ });
75
+
76
+ var didSomeSorting = false;
77
+ for (var c in e.ft.columns) {
78
+ column = e.ft.columns[c];
79
+ if (column.sort.initial) {
80
+ p.sort(e.ft, $tbody, column);
81
+ didSomeSorting = true;
82
+ $th = $table.find('> thead > tr:last-child > th:eq(' + c + '), > thead > tr:last-child > td:eq(' + c + ')');
83
+
84
+ if (column.sort.initial == 'descending') {
85
+ p.reverse(e.ft, $tbody);
86
+ $th.addClass(cls.descending);
87
+ } else {
88
+ $th.addClass(cls.sorted);
89
+ }
90
+
91
+ break;
92
+ } else if (column.sort.ignore != true) {
93
+
94
+ }
95
+ }
96
+ if (didSomeSorting) {
97
+ e.ft.bindToggleSelectors();
98
+ }
99
+ },
100
+ 'footable_column_data': function (e) {
101
+ var $th = $(e.column.th);
102
+ e.column.data.sort = e.column.data.sort || {};
103
+ e.column.data.sort.initial = $th.data('sort-initial') || false;
104
+ e.column.data.sort.ignore = $th.data('sort-ignore') || false;
105
+ e.column.data.sort.selector = $th.data('sort-selector') || null;
106
+
107
+ var match = $th.data('sort-match') || 0;
108
+ if (match >= e.column.data.matches.length) match = 0;
109
+ e.column.data.sort.match = e.column.data.matches[match];
110
+ }
111
+ });
112
+ }
113
+ };
114
+
115
+ p.rows = function (ft, tbody, column) {
116
+ var rows = [];
117
+ tbody.find('> tr').each(function () {
118
+ var $row = $(this), $next = null;
119
+ if ($row.hasClass('footable-row-detail')) return true;
120
+ if ($row.next().hasClass('footable-row-detail')) {
121
+ $next = $row.next().get(0);
122
+ }
123
+ var row = {'row': $row, 'detail': $next};
124
+ if (column != undefined) {
125
+ row.value = ft.parse(this.cells[column.sort.match], column);
126
+ }
127
+ rows.push(row);
128
+ return true;
129
+ }).detach();
130
+ return rows;
131
+ };
132
+
133
+ p.sort = function (ft, tbody, column) {
134
+ var rows = p.rows(ft, tbody, column);
135
+ var sorter = ft.options.sorters[column.type] || ft.options.sorters.alpha;
136
+ rows.sort(function (a, b) {
137
+ return sorter(a.value, b.value);
138
+ });
139
+ for (var j = 0; j < rows.length; j++) {
140
+ tbody.append(rows[j].row);
141
+ if (rows[j].detail != null) {
142
+ tbody.append(rows[j].detail);
143
+ }
144
+ }
145
+ };
146
+
147
+ p.reverse = function (ft, tbody) {
148
+ var rows = p.rows(ft, tbody);
149
+ for (var i = rows.length - 1; i >= 0; i--) {
150
+ tbody.append(rows[i].row);
151
+ if (rows[i].detail != null) {
152
+ tbody.append(rows[i].detail);
153
+ }
154
+ }
155
+ };
156
+ }
157
+
158
+ ;
159
+
160
+ w.footable.plugins.register(new Sortable(), defaults);
161
+
162
+ })(jQuery, window);
@@ -0,0 +1,113 @@
1
+ .footable {
2
+ border-collapse: separate;
3
+ border-spacing: 0;
4
+ width: 100%;
5
+ border: solid #ccc 1px;
6
+
7
+ border-radius: 0;
8
+ font-size: 14px;
9
+
10
+ }
11
+
12
+ .footable.breakpoint > tbody > tr > td.expand {
13
+ background: url('../assets/plus.png') no-repeat 5px center;
14
+ padding-left: 40px;
15
+ }
16
+
17
+ .footable.breakpoint > tbody > tr.footable-detail-show > td.expand {
18
+ background: url('../assets/minus.png') no-repeat 5px center;
19
+ }
20
+
21
+ .footable.breakpoint > tbody > tr.footable-row-detail {
22
+ background: #EBEDEF;
23
+ }
24
+
25
+ .footable > tbody > tr:hover {
26
+ background: #fbf8e9;
27
+ }
28
+
29
+ .footable.breakpoint > tbody > tr:hover:not(.footable-row-detail) {
30
+ cursor: pointer;
31
+ }
32
+
33
+ .footable > tbody > tr > td, .footable > thead > tr > th {
34
+ border-left: 1px solid #ccc;
35
+ border-top: 1px solid #ccc;
36
+ padding: 10px;
37
+ text-align: left;
38
+ }
39
+
40
+ .footable > tbody > tr > td.footable-cell-detail {
41
+ border-left: none;
42
+ }
43
+
44
+ .footable > thead > tr > th, .footable > thead > tr > td {
45
+ background-color: #EBEDED;
46
+
47
+ -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset;
48
+ -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset;
49
+ box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset;
50
+ border-top: none;
51
+ text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
52
+ }
53
+
54
+ .footable > thead > tr:first-child > th.footable-first-column, .footable > thead > tr:first-child > td.footable-first-column {
55
+ -moz-border-radius: 0 0;
56
+ -webkit-border-radius: 0 0;
57
+ border-radius: 0 0;
58
+ }
59
+
60
+ .footable > thead > tr:first-child > th.footable-last-column, .footable > thead > tr:first-child > td.footable-last-column {
61
+ -moz-border-radius: 0 0;
62
+ -webkit-border-radius: 0 0;
63
+ border-radius: 0 0;
64
+ }
65
+
66
+ .footable > thead > tr:first-child > th.footable-first-column.footable-last-column, .footable > thead > tr:first-child > td.footable-first-column.footable-last-column {
67
+ -moz-border-radius: 6px 0;
68
+ -webkit-border-radius: 6px 0;
69
+ border-radius: 6px 0;
70
+ }
71
+
72
+ .footable > tbody > tr:last-child > td.footable-first-column {
73
+ -moz-border-radius: 0 0 0 6px;
74
+ -webkit-border-radius: 0 0 0 6px;
75
+ border-radius: 0 0 0 6px;
76
+ }
77
+
78
+ .footable > tbody > tr:last-child > td.footable-last-column {
79
+ -moz-border-radius: 0 0 6px 0;
80
+ -webkit-border-radius: 0 0 6px 0;
81
+ border-radius: 0 0 6px 0;
82
+ }
83
+
84
+ .footable > tbody > tr:last-child > td.footable-first-column.footable-last-column {
85
+ -moz-border-radius: 0 0 6px 6px;
86
+ -webkit-border-radius: 0 0 6px 6px;
87
+ border-radius: 0 0 6px 6px;
88
+ }
89
+
90
+ .footable > thead > tr > th.footable-first-column, .footable > thead > tr > td.footable-first-column,
91
+ .footable > tbody > tr > td.footable-first-column {
92
+ border-left: none;
93
+ }
94
+
95
+ .footable > tbody img {
96
+ vertical-align: middle;
97
+ }
98
+
99
+ .footable > tfoot > tr > th, .footable > tfoot > tr > td {
100
+ background-color: #dce9f9;
101
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#ebf3fc), to(#dce9f9));
102
+ background-image: -webkit-linear-gradient(top, #ebf3fc, #dce9f9);
103
+ background-image: -moz-linear-gradient(top, #ebf3fc, #dce9f9);
104
+ background-image: -ms-linear-gradient(top, #ebf3fc, #dce9f9);
105
+ background-image: -o-linear-gradient(top, #ebf3fc, #dce9f9);
106
+ background-image: linear-gradient(to bottom, #ebf3fc, #dce9f9);
107
+ -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset;
108
+ -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset;
109
+ box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset;
110
+ border-top: 1px solid #ccc;
111
+ text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
112
+ padding: 10px;
113
+ }
@@ -0,0 +1,24 @@
1
+ .footable > thead > tr > th > span.footable-sort-indicator {
2
+ width: 16px;
3
+ height: 16px;
4
+ display: block;
5
+ float: right;
6
+ background: url('../assets/sorting_sprite.png') no-repeat top left;
7
+ }
8
+
9
+ .footable > thead > tr > th.footable-sortable:hover {
10
+ cursor: pointer;
11
+ }
12
+
13
+ .footable > thead > tr > th.footable-sortable > span {
14
+
15
+ }
16
+
17
+ .footable > thead > tr > th.footable-sorted > span.footable-sort-indicator {
18
+ background-position: 0 -16px;
19
+ }
20
+
21
+ .footable > thead > tr > th.footable-sorted-desc > span.footable-sort-indicator {
22
+ background-position: 0 -32px;
23
+ }
24
+
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: footable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - amarduwal
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-04-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: FooTable - Awesome Responsive Tables. Where you can sort table through
56
+ jquery.
57
+ email:
58
+ - duwal.amar2006@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - CODE_OF_CONDUCT.md
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - bin/console
72
+ - bin/setup
73
+ - footable.gemspec
74
+ - footable.jpg
75
+ - lib/footable.rb
76
+ - lib/footable/version.rb
77
+ - vendor/assets/images/minus.png
78
+ - vendor/assets/images/plus.png
79
+ - vendor/assets/images/sorting_sprite.png
80
+ - vendor/assets/javascripts/footable.js
81
+ - vendor/assets/javascripts/footable.sortable.js
82
+ - vendor/assets/stylesheets/footable.css
83
+ - vendor/assets/stylesheets/footable.sortable.css
84
+ homepage: https://github.com/amarduwal/footable
85
+ licenses:
86
+ - MIT
87
+ metadata:
88
+ allowed_push_host: https://rubygems.org
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.6.13
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: FooTable - Awesome Responsive Tables.
109
+ test_files: []