footable_rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,44 @@
1
+ (function ($, w, undefined) {
2
+ if (w.footable === undefined || w.foobox === 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
+ /*
7
+ Plugin options here, example:
8
+
9
+ var defaults = {
10
+ myPlugin: {
11
+ enabled: true
12
+ }
13
+ };
14
+
15
+ This would allow you to access this option using ft.options.myPlugin.enabled
16
+ */
17
+ };
18
+
19
+ function MyPlugin() {
20
+ var p = this;
21
+ p.name = 'Footable MyPlugin';
22
+ p.init = function(ft) {
23
+ $(ft.table).bind({
24
+ /*
25
+ Bind to relevant events here to modify/add functionality to Footable, example:
26
+
27
+ $(ft.table).bind({
28
+ 'footable_initialized': function(e){
29
+ if (e.ft.options.myPlugin.enabled === true){
30
+ alert('Hello World');
31
+ }
32
+ }
33
+ });
34
+
35
+ This would listen for the 'footable_initialized' event and when called check if the plugin is enabled
36
+ and if it is alert 'Hello World' to the user.
37
+ */
38
+ });
39
+ };
40
+ }
41
+
42
+ w.footable.plugins.register(MyPlugin, defaults);
43
+
44
+ })(jQuery, window);
@@ -0,0 +1,190 @@
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 (typeof(a) === 'string') { a = a.toLowerCase(); }
10
+ if (typeof(b) === 'string') { b = b.toLowerCase(); }
11
+ if (a === b) return 0;
12
+ if (a < b) return -1;
13
+ return 1;
14
+ },
15
+ numeric: function (a, b) {
16
+ return a - b;
17
+ }
18
+ },
19
+ classes: {
20
+ sort: {
21
+ sortable: 'footable-sortable',
22
+ sorted: 'footable-sorted',
23
+ descending: 'footable-sorted-desc',
24
+ indicator: 'footable-sort-indicator'
25
+ }
26
+ },
27
+ events: {
28
+ sort: {
29
+ sorting: 'footable_sorting',
30
+ sorted: 'footable_sorted'
31
+ }
32
+ }
33
+ };
34
+
35
+ function Sort() {
36
+ var p = this;
37
+ p.name = 'Footable Sortable';
38
+ p.init = function (ft) {
39
+ p.footable = ft;
40
+ if (ft.options.sort === true) {
41
+ $(ft.table)
42
+ .unbind('.sorting')
43
+ .bind({
44
+ 'footable_initialized.sorting': function (e) {
45
+ var $table = $(ft.table),
46
+ $tbody = $table.find('> tbody'),
47
+ cls = ft.options.classes.sort,
48
+ column, $th;
49
+
50
+ if ($table.data('sort') === false) return;
51
+
52
+ $table.find('> thead > tr:last-child > th, > thead > tr:last-child > td').each(function (ec) {
53
+ var $th = $(this), column = ft.columns[$th.index()];
54
+ if (column.sort.ignore !== true && !$th.hasClass(cls.sortable)) {
55
+ $th.addClass(cls.sortable);
56
+ $('<span />').addClass(cls.indicator).appendTo($th);
57
+ }
58
+ });
59
+
60
+ $table.find('> thead > tr:last-child > th.' + cls.sortable + ', > thead > tr:last-child > td.' + cls.sortable).unbind('click.footable').bind('click.footable', function (ec) {
61
+ ec.preventDefault();
62
+ $th = $(this);
63
+ var ascending = !$th.hasClass(cls.sorted);
64
+ p.doSort($th.index(), ascending);
65
+ return false;
66
+ });
67
+
68
+ var didSomeSorting = false;
69
+ for (var c in ft.columns) {
70
+ column = ft.columns[c];
71
+ if (column.sort.initial) {
72
+ var ascending = (column.sort.initial !== 'descending');
73
+ p.doSort(column.index, ascending);
74
+ break;
75
+ }
76
+ }
77
+ if (didSomeSorting) {
78
+ ft.bindToggleSelectors();
79
+ }
80
+ },
81
+ 'footable_redrawn.sorting': function(e) {
82
+ var $table = $(ft.table),
83
+ cls = ft.options.classes.sort;
84
+ if ($table.data('sorted') >= 0) {
85
+ $table.find('> thead > tr:last-child > th').each(function(i){
86
+ var $th = $(this);
87
+ if ($th.hasClass(cls.sorted) || $th.hasClass(cls.descending)) {
88
+ p.doSort(i);
89
+ return;
90
+ }
91
+ });
92
+ }
93
+ },
94
+ 'footable_column_data.sorting': function (e) {
95
+ var $th = $(e.column.th);
96
+ e.column.data.sort = e.column.data.sort || {};
97
+ e.column.data.sort.initial = $th.data('sort-initial') || false;
98
+ e.column.data.sort.ignore = $th.data('sort-ignore') || false;
99
+ e.column.data.sort.selector = $th.data('sort-selector') || null;
100
+
101
+ var match = $th.data('sort-match') || 0;
102
+ if (match >= e.column.data.matches.length) match = 0;
103
+ e.column.data.sort.match = e.column.data.matches[match];
104
+ }
105
+ })
106
+ //save the sort object onto the table so we can access it later
107
+ .data('footable-sort', p);
108
+ }
109
+ };
110
+
111
+ p.doSort = function(columnIndex, ascending) {
112
+ var ft = p.footable;
113
+ if ($(ft.table).data('sort') === false) return;
114
+
115
+ var $table = $(ft.table),
116
+ $tbody = $table.find('> tbody'),
117
+ column = ft.columns[columnIndex],
118
+ $th = $table.find('> thead > tr:last-child > th:eq(' + columnIndex + ')'),
119
+ cls = ft.options.classes.sort,
120
+ evt = ft.options.events.sort;
121
+
122
+ ascending = (ascending === undefined) ? $th.hasClass(cls.sorted) :
123
+ (ascending === 'toggle') ? !$th.hasClass(cls.sorted) : ascending;
124
+
125
+ if (column.sort.ignore === true) return true;
126
+
127
+ //raise a pre-sorting event so that we can cancel the sorting if needed
128
+ var event = ft.raise(evt.sorting, { column: column, direction: ascending ? 'ASC' : 'DESC' });
129
+ if (event && event.result === false) return;
130
+
131
+ $table.data('sorted', column.index);
132
+
133
+ $table.find('> thead > tr:last-child > th, > thead > tr:last-child > td').not($th).removeClass(cls.sorted + ' ' + cls.descending);
134
+
135
+ if (ascending === undefined) {
136
+ ascending = $th.hasClass(cls.sorted);
137
+ }
138
+
139
+ if (ascending) {
140
+ $th.removeClass(cls.descending).addClass(cls.sorted);
141
+ } else {
142
+ $th.removeClass(cls.sorted).addClass(cls.descending);
143
+ }
144
+
145
+ p.sort(ft, $tbody, column, ascending);
146
+
147
+ ft.bindToggleSelectors();
148
+ ft.raise(evt.sorted, { column: column, direction: ascending ? 'ASC' : 'DESC' });
149
+ };
150
+
151
+ p.rows = function (ft, tbody, column) {
152
+ var rows = [];
153
+ tbody.find('> tr').each(function () {
154
+ var $row = $(this), $next = null;
155
+ if ($row.hasClass(ft.options.classes.detail)) return true;
156
+ if ($row.next().hasClass(ft.options.classes.detail)) {
157
+ $next = $row.next().get(0);
158
+ }
159
+ var row = { 'row': $row, 'detail': $next };
160
+ if (column !== undefined) {
161
+ row.value = ft.parse(this.cells[column.sort.match], column);
162
+ }
163
+ rows.push(row);
164
+ return true;
165
+ }).detach();
166
+ return rows;
167
+ };
168
+
169
+ p.sort = function (ft, tbody, column, ascending) {
170
+ var rows = p.rows(ft, tbody, column);
171
+ var sorter = ft.options.sorters[column.type] || ft.options.sorters.alpha;
172
+ rows.sort(function (a, b) {
173
+ if (ascending) {
174
+ return sorter(a.value, b.value);
175
+ } else {
176
+ return sorter(b.value, a.value);
177
+ }
178
+ });
179
+ for (var j = 0; j < rows.length; j++) {
180
+ tbody.append(rows[j].row);
181
+ if (rows[j].detail !== null) {
182
+ tbody.append(rows[j].detail);
183
+ }
184
+ }
185
+ };
186
+ }
187
+
188
+ w.footable.plugins.register(Sort, defaults);
189
+
190
+ })(jQuery, window);
@@ -0,0 +1,57 @@
1
+ (function ($, w, undefined) {
2
+ if (w.footable === undefined || w.foobox === 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
+ striping: {
7
+ enabled: true
8
+ },
9
+ classes: {
10
+ striping: {
11
+ odd: 'footable-odd',
12
+ even: 'footable-even'
13
+ }
14
+ }
15
+ };
16
+
17
+ function Striping() {
18
+ var p = this;
19
+ p.name = 'Footable Striping';
20
+ p.init = function (ft) {
21
+ p.footable = ft;
22
+ $(ft.table)
23
+ .unbind('striping')
24
+ .bind({
25
+ 'footable_initialized.striping footable_row_removed.striping footable_redrawn.striping footable_sorted.striping footable_filtered.striping': function () {
26
+
27
+ if ($(this).data('striping') === false) return;
28
+
29
+ p.setupStriping(ft);
30
+ }
31
+ });
32
+ };
33
+
34
+ p.setupStriping = function (ft) {
35
+
36
+ var rowIndex = 0;
37
+ $(ft.table).find('> tbody > tr:not(.footable-row-detail)').each(function () {
38
+
39
+ var $row = $(this);
40
+
41
+ //Clean off old classes
42
+ $row.removeClass(ft.options.classes.striping.even).removeClass(ft.options.classes.striping.odd);
43
+
44
+ if (rowIndex % 2 === 0) {
45
+ $row.addClass(ft.options.classes.striping.even);
46
+ } else {
47
+ $row.addClass(ft.options.classes.striping.odd);
48
+ }
49
+
50
+ rowIndex++;
51
+ });
52
+ };
53
+ }
54
+
55
+ w.footable.plugins.register(Striping, defaults);
56
+
57
+ })(jQuery, window);
@@ -0,0 +1,178 @@
1
+ @font-face {
2
+ font-family: 'footable';
3
+ src: url('fonts/footable.eot');
4
+ src: url('fonts/footable.eot?#iefix') format('embedded-opentype'), url('fonts/footable.woff') format('woff'), url('fonts/footable.ttf') format('truetype'), url('fonts/footable.svg#footable') format('svg');
5
+ font-weight: normal;
6
+ font-style: normal;
7
+ }
8
+ @media screen and (-webkit-min-device-pixel-ratio: 0) {
9
+ @font-face {
10
+ font-family: 'footable';
11
+ src: url('fonts/footable.svg#footable') format('svg');
12
+ font-weight: normal;
13
+ font-style: normal;
14
+ }
15
+ }
16
+ .footable {
17
+ width: 100%;
18
+ /** SORTING **/
19
+
20
+ /** PAGINATION **/
21
+
22
+ }
23
+ .footable.breakpoint > tbody > tr.footable-detail-show > td {
24
+ border-bottom: none;
25
+ }
26
+ .footable.breakpoint > tbody > tr.footable-detail-show > td > span.footable-toggle:before {
27
+ content: "\e001";
28
+ }
29
+ .footable.breakpoint > tbody > tr:hover:not(.footable-row-detail) {
30
+ cursor: pointer;
31
+ }
32
+ .footable.breakpoint > tbody > tr > td.footable-cell-detail {
33
+ background: #eee;
34
+ border-top: none;
35
+ }
36
+ .footable.breakpoint > tbody > tr > td > span.footable-toggle {
37
+ display: inline-block;
38
+ font-family: 'footable';
39
+ speak: none;
40
+ font-style: normal;
41
+ font-weight: normal;
42
+ font-variant: normal;
43
+ text-transform: none;
44
+ -webkit-font-smoothing: antialiased;
45
+ padding-right: 5px;
46
+ font-size: 14px;
47
+ color: #888888;
48
+ }
49
+ .footable.breakpoint > tbody > tr > td > span.footable-toggle:before {
50
+ content: "\e000";
51
+ }
52
+ .footable.breakpoint.toggle-circle > tbody > tr.footable-detail-show > td > span.footable-toggle:before {
53
+ content: "\e005";
54
+ }
55
+ .footable.breakpoint.toggle-circle > tbody > tr > td > span.footable-toggle:before {
56
+ content: "\e004";
57
+ }
58
+ .footable.breakpoint.toggle-circle-filled > tbody > tr.footable-detail-show > td > span.footable-toggle:before {
59
+ content: "\e003";
60
+ }
61
+ .footable.breakpoint.toggle-circle-filled > tbody > tr > td > span.footable-toggle:before {
62
+ content: "\e002";
63
+ }
64
+ .footable.breakpoint.toggle-square > tbody > tr.footable-detail-show > td > span.footable-toggle:before {
65
+ content: "\e007";
66
+ }
67
+ .footable.breakpoint.toggle-square > tbody > tr > td > span.footable-toggle:before {
68
+ content: "\e006";
69
+ }
70
+ .footable.breakpoint.toggle-square-filled > tbody > tr.footable-detail-show > td > span.footable-toggle:before {
71
+ content: "\e009";
72
+ }
73
+ .footable.breakpoint.toggle-square-filled > tbody > tr > td > span.footable-toggle:before {
74
+ content: "\e008";
75
+ }
76
+ .footable.breakpoint.toggle-arrow > tbody > tr.footable-detail-show > td > span.footable-toggle:before {
77
+ content: "\e00f";
78
+ }
79
+ .footable.breakpoint.toggle-arrow > tbody > tr > td > span.footable-toggle:before {
80
+ content: "\e011";
81
+ }
82
+ .footable.breakpoint.toggle-arrow-small > tbody > tr.footable-detail-show > td > span.footable-toggle:before {
83
+ content: "\e013";
84
+ }
85
+ .footable.breakpoint.toggle-arrow-small > tbody > tr > td > span.footable-toggle:before {
86
+ content: "\e015";
87
+ }
88
+ .footable.breakpoint.toggle-arrow-circle > tbody > tr.footable-detail-show > td > span.footable-toggle:before {
89
+ content: "\e01b";
90
+ }
91
+ .footable.breakpoint.toggle-arrow-circle > tbody > tr > td > span.footable-toggle:before {
92
+ content: "\e01d";
93
+ }
94
+ .footable.breakpoint.toggle-arrow-circle-filled > tbody > tr.footable-detail-show > td > span.footable-toggle:before {
95
+ content: "\e00b";
96
+ }
97
+ .footable.breakpoint.toggle-arrow-circle-filled > tbody > tr > td > span.footable-toggle:before {
98
+ content: "\e00d";
99
+ }
100
+ .footable.breakpoint.toggle-arrow-tiny > tbody > tr.footable-detail-show > td > span.footable-toggle:before {
101
+ content: "\e01f";
102
+ }
103
+ .footable.breakpoint.toggle-arrow-tiny > tbody > tr > td > span.footable-toggle:before {
104
+ content: "\e021";
105
+ }
106
+ .footable.breakpoint.toggle-arrow-alt > tbody > tr.footable-detail-show > td > span.footable-toggle:before {
107
+ content: "\e017";
108
+ }
109
+ .footable.breakpoint.toggle-arrow-alt > tbody > tr > td > span.footable-toggle:before {
110
+ content: "\e019";
111
+ }
112
+ .footable.breakpoint.toggle-medium > tbody > tr > td > span.footable-toggle {
113
+ font-size: 18px;
114
+ }
115
+ .footable.breakpoint.toggle-large > tbody > tr > td > span.footable-toggle {
116
+ font-size: 24px;
117
+ }
118
+ .footable > thead > tr > th {
119
+ -webkit-touch-callout: none;
120
+ -webkit-user-select: none;
121
+ -khtml-user-select: none;
122
+ -moz-user-select: -moz-none;
123
+ -ms-user-select: none;
124
+ user-select: none;
125
+ }
126
+ .footable > thead > tr > th.footable-sortable:hover {
127
+ cursor: pointer;
128
+ }
129
+ .footable > thead > tr > th.footable-sorted > span.footable-sort-indicator:before {
130
+ content: "\e013";
131
+ }
132
+ .footable > thead > tr > th.footable-sorted-desc > span.footable-sort-indicator:before {
133
+ content: "\e012";
134
+ }
135
+ .footable > thead > tr > th > span.footable-sort-indicator {
136
+ display: inline-block;
137
+ font-family: 'footable';
138
+ speak: none;
139
+ font-style: normal;
140
+ font-weight: normal;
141
+ font-variant: normal;
142
+ text-transform: none;
143
+ -webkit-font-smoothing: antialiased;
144
+ padding-left: 5px;
145
+ }
146
+ .footable > thead > tr > th > span.footable-sort-indicator:before {
147
+ content: "\e022";
148
+ }
149
+ .footable > tfoot .pagination {
150
+ margin: 0;
151
+ }
152
+ .footable.no-paging .hide-if-no-paging {
153
+ display: none;
154
+ }
155
+ .footable-row-detail-inner {
156
+ display: table;
157
+ }
158
+ .footable-row-detail-row {
159
+ display: table-row;
160
+ line-height: 1.5em;
161
+ }
162
+ .footable-row-detail-group {
163
+ display: block;
164
+ line-height: 2em;
165
+ font-size: 1.2em;
166
+ font-weight: bold;
167
+ }
168
+ .footable-row-detail-name {
169
+ display: table-cell;
170
+ font-weight: bold;
171
+ padding-right: 0.5em;
172
+ }
173
+ .footable-row-detail-value {
174
+ display: table-cell;
175
+ }
176
+ .footable-odd {
177
+ background-color: #f7f7f7;
178
+ }