jquery-tablesorter 1.17.2 → 1.17.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/jquery-tablesorter/version.rb +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/addons/pager/jquery.tablesorter.pager.js +76 -71
- data/vendor/assets/javascripts/jquery-tablesorter/extras/jquery.dragtable.mod.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.combined.js +2647 -2576
- data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.js +174 -119
- data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.widgets.js +2487 -2471
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-extract.js +15 -15
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-iso8601.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-month.js +4 -4
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-range.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-two-digit-year.js +12 -12
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-weekday.js +4 -4
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-duration.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-feet-inch-fraction.js +6 -6
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-file-type.js +22 -22
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-globalize.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-ignore-articles.js +15 -15
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-image.js +3 -3
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-input-select.js +10 -3
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-metric.js +2 -2
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-named-numbers.js +3 -3
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-network.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-roman.js +4 -4
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-alignChar.js +122 -121
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-build-table.js +13 -13
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-chart.js +2 -2
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-columnSelector.js +324 -324
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-columns.js +60 -60
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-editable.js +219 -219
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-formatter-html5.js +360 -361
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-formatter-jui.js +666 -666
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-formatter-select2.js +124 -124
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-type-insideRange.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter.js +1448 -1433
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-formatter.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-grouping.js +213 -213
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-headerTitles.js +3 -3
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-math.js +271 -216
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-output.js +339 -320
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-pager.js +1057 -1045
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-print.js +109 -109
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-reflow.js +114 -115
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-resizable.js +360 -359
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-saveSort.js +59 -59
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-scroller.js +818 -806
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-sort2Hash.js +128 -0
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-sortTbodies.js +195 -195
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-staticRow.js +90 -90
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-stickyHeaders.js +257 -257
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-storage.js +76 -76
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-uitheme.js +170 -170
- metadata +3 -3
- data/vendor/assets/javascripts/jquery-tablesorter/extras/jquery.quicksearch.js +0 -195
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! Widget: output - updated
|
1
|
+
/*! Widget: output - updated 7/28/2015 (v2.22.4) *//*
|
2
2
|
* Requires tablesorter v2.8+ and jQuery 1.7+
|
3
3
|
* Modified from:
|
4
4
|
* HTML Table to CSV: http://www.kunalbabre.com/projects/table2CSV.php (License unknown?)
|
@@ -7,352 +7,371 @@
|
|
7
7
|
/*jshint browser:true, jquery:true, unused:false */
|
8
8
|
/*global jQuery: false */
|
9
9
|
;(function($){
|
10
|
-
|
11
|
-
|
12
|
-
var ts = $.tablesorter,
|
13
|
-
|
14
|
-
output = ts.output = {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
10
|
+
'use strict';
|
11
|
+
|
12
|
+
var ts = $.tablesorter,
|
13
|
+
|
14
|
+
output = ts.output = {
|
15
|
+
|
16
|
+
event : 'outputTable',
|
17
|
+
|
18
|
+
// wrap line breaks & tabs in quotes
|
19
|
+
regexQuote : /([\n\t\x09\x0d\x0a]|<[^<]+>)/, // test if cell needs wrapping quotes
|
20
|
+
regexBR : /(<br([\s\/])?>|\n)/g, // replace
|
21
|
+
regexIMG : /<img[^>]+alt\s*=\s*['"]([^'"]+)['"][^>]*>/i, // match
|
22
|
+
regexHTML : /<[^<]+>/g, // replace
|
23
|
+
|
24
|
+
replaceCR : '\x0d\x0a',
|
25
|
+
replaceTab : '\x09',
|
26
|
+
|
27
|
+
popupTitle : 'Output',
|
28
|
+
popupStyle : 'width:100%;height:100%;', // for textarea
|
29
|
+
message : 'Your device does not support downloading. Please try again in desktop browser.',
|
30
|
+
|
31
|
+
init : function(c) {
|
32
|
+
c.$table
|
33
|
+
.off(output.event)
|
34
|
+
.on(output.event, function( e ) {
|
35
|
+
e.stopPropagation();
|
36
|
+
// explicitly use table.config.widgetOptions because we want
|
37
|
+
// the most up-to-date values; not the 'wo' from initialization
|
38
|
+
output.process(c, c.widgetOptions);
|
39
|
+
});
|
40
|
+
},
|
41
|
+
|
42
|
+
processRow: function(c, $rows, isHeader, isJSON) {
|
43
|
+
var $cell, $cells, cellsLen, rowIndex, row, col, indx, rowspanLen, colspanLen, txt,
|
44
|
+
wo = c.widgetOptions,
|
45
|
+
tmpRow = [],
|
46
|
+
dupe = wo.output_duplicateSpans,
|
47
|
+
addSpanIndex = isHeader && isJSON && wo.output_headerRows && $.isFunction(wo.output_callbackJSON),
|
48
|
+
cellIndex = 0,
|
49
|
+
rowsLength = $rows.length;
|
50
|
+
|
51
|
+
for ( rowIndex = 0; rowIndex < rowsLength; rowIndex++ ) {
|
52
|
+
if (!tmpRow[rowIndex]) { tmpRow[rowIndex] = []; }
|
53
|
+
cellIndex = 0;
|
54
|
+
$cells = $rows.eq( rowIndex ).children();
|
55
|
+
cellsLen = $cells.length;
|
56
|
+
for ( indx = 0; indx < cellsLen; indx++ ) {
|
57
|
+
$cell = $cells.eq( indx );
|
58
|
+
// process rowspans
|
59
|
+
if ($cell.filter('[rowspan]').length) {
|
60
|
+
rowspanLen = parseInt( $cell.attr('rowspan'), 10) - 1;
|
61
|
+
txt = output.formatData( c, wo, $cell, isHeader );
|
62
|
+
for (row = 1; row <= rowspanLen; row++) {
|
63
|
+
if (!tmpRow[rowIndex + row]) { tmpRow[rowIndex + row] = []; }
|
64
|
+
tmpRow[rowIndex + row][cellIndex] = isHeader ? txt : dupe ? txt : '';
|
65
|
+
}
|
65
66
|
}
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
67
|
+
// process colspans
|
68
|
+
if ($cell.filter('[colspan]').length) {
|
69
|
+
colspanLen = parseInt( $cell.attr('colspan'), 10) - 1;
|
70
|
+
// allow data-attribute to be an empty string
|
71
|
+
txt = output.formatData( c, wo, $cell, isHeader );
|
72
|
+
for (col = 1; col <= colspanLen; col++) {
|
73
|
+
// if we're processing the header & making JSON, the header names need to be unique
|
74
|
+
if ($cell.filter('[rowspan]').length) {
|
75
|
+
rowspanLen = parseInt( $cell.attr('rowspan'), 10);
|
76
|
+
for (row = 0; row < rowspanLen; row++) {
|
77
|
+
if (!tmpRow[rowIndex + row]) { tmpRow[rowIndex + row] = []; }
|
78
|
+
tmpRow[rowIndex + row][cellIndex + col] = addSpanIndex ?
|
79
|
+
wo.output_callbackJSON($cell, txt, cellIndex + col) ||
|
80
|
+
txt + '(' + (cellIndex + col) + ')' : isHeader ? txt : dupe ? txt : '';
|
81
|
+
}
|
82
|
+
} else {
|
83
|
+
tmpRow[rowIndex][cellIndex + col] = addSpanIndex ?
|
79
84
|
wo.output_callbackJSON($cell, txt, cellIndex + col) ||
|
80
85
|
txt + '(' + (cellIndex + col) + ')' : isHeader ? txt : dupe ? txt : '';
|
81
86
|
}
|
82
|
-
} else {
|
83
|
-
tmpRow[rowIndex][cellIndex + col] = addSpanIndex ?
|
84
|
-
wo.output_callbackJSON($cell, txt, cellIndex + col) ||
|
85
|
-
txt + '(' + (cellIndex + col) + ')' : isHeader ? txt : dupe ? txt : '';
|
86
87
|
}
|
87
88
|
}
|
88
|
-
}
|
89
89
|
|
90
|
-
|
91
|
-
|
90
|
+
// skip column if already defined
|
91
|
+
while (typeof tmpRow[rowIndex][cellIndex] !== 'undefined') { cellIndex++; }
|
92
92
|
|
93
|
-
|
94
|
-
|
95
|
-
|
93
|
+
tmpRow[rowIndex][cellIndex] = tmpRow[rowIndex][cellIndex] ||
|
94
|
+
output.formatData( c, wo, $cell, isHeader );
|
95
|
+
cellIndex++;
|
96
|
+
}
|
96
97
|
}
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
98
|
+
return ts.output.removeColumns( c, wo, tmpRow );
|
99
|
+
},
|
100
|
+
|
101
|
+
// remove hidden/ignored columns
|
102
|
+
removeColumns : function( c, wo, arry ) {
|
103
|
+
var rowIndex, row, colIndex,
|
104
|
+
data = [],
|
105
|
+
len = arry.length;
|
106
|
+
for ( rowIndex = 0; rowIndex < len; rowIndex++ ) {
|
107
|
+
row = arry[ rowIndex ];
|
108
|
+
data[ rowIndex ] = [];
|
109
|
+
for ( colIndex = 0; colIndex < c.columns; colIndex++ ) {
|
110
|
+
if ( !wo.output_hiddenColumnArray[ colIndex ] ) {
|
111
|
+
data[ rowIndex ].push( row[ colIndex ] );
|
112
|
+
}
|
112
113
|
}
|
113
114
|
}
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
115
|
+
return data;
|
116
|
+
},
|
117
|
+
|
118
|
+
process : function(c, wo) {
|
119
|
+
var mydata, $this, $rows, headers, csvData, len, rowsLen, tmp,
|
120
|
+
hasStringify = window.JSON && JSON.hasOwnProperty('stringify'),
|
121
|
+
indx = 0,
|
122
|
+
tmpData = (wo.output_separator || ',').toLowerCase(),
|
123
|
+
outputJSON = tmpData === 'json',
|
124
|
+
outputArray = tmpData === 'array',
|
125
|
+
separator = outputJSON || outputArray ? ',' : wo.output_separator,
|
126
|
+
saveRows = wo.output_saveRows,
|
127
|
+
$el = c.$table;
|
128
|
+
// regex to look for the set separator or HTML
|
129
|
+
wo.output_regex = new RegExp('(' + (/\\/.test(separator) ? '\\' : '' ) + separator + ')' );
|
130
|
+
|
131
|
+
// make a list of hidden columns
|
132
|
+
wo.output_hiddenColumnArray = [];
|
133
|
+
for ( indx = 0; indx < c.columns; indx++ ) {
|
134
|
+
wo.output_hiddenColumnArray[ indx ] = $.inArray( indx, wo.output_ignoreColumns ) > -1 ||
|
135
|
+
( !wo.output_hiddenColumns && c.$headerIndexed[ indx ].css( 'display' ) === 'none' &&
|
136
|
+
!c.$headerIndexed[ indx ].hasClass( 'tablesorter-scroller-hidden-column' ) );
|
137
|
+
}
|
137
138
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
//
|
160
|
-
csvData =
|
161
|
-
|
139
|
+
// get header cells
|
140
|
+
$this = $el
|
141
|
+
.find('thead tr')
|
142
|
+
.not('.' + (ts.css.filterRow || 'tablesorter-filter-row') )
|
143
|
+
.filter( function() {
|
144
|
+
return wo.output_hiddenColumns || $(this).css('display') !== 'none';
|
145
|
+
});
|
146
|
+
headers = output.processRow(c, $this, true, outputJSON);
|
147
|
+
|
148
|
+
// all tbody rows
|
149
|
+
$rows = $el.children('tbody').children('tr');
|
150
|
+
|
151
|
+
// get (f)iltered, (v)isible, all rows (look for the first letter only), or jQuery filter selector
|
152
|
+
$rows = /^f/.test(saveRows) ? $rows.not('.' + (wo.filter_filteredRow || 'filtered') ) :
|
153
|
+
/^v/.test(saveRows) ? $rows.filter(':visible') :
|
154
|
+
// look for '.' (class selector), '#' (id selector),
|
155
|
+
// ':' (basic filters, e.g. ':not()') or '[' (attribute selector start)
|
156
|
+
/^[.#:\[]/.test(saveRows) ? $rows.filter(saveRows) :
|
157
|
+
// default to all rows
|
158
|
+
$rows;
|
159
|
+
|
160
|
+
// process to array of arrays
|
161
|
+
csvData = output.processRow(c, $rows);
|
162
|
+
|
163
|
+
if (wo.output_includeFooter) {
|
164
|
+
// clone, to force the tfoot rows to the end of this selection of rows
|
165
|
+
// otherwise they appear after the thead (the order in the HTML)
|
166
|
+
csvData = csvData.concat( output.processRow( c, $el.children('tfoot').children('tr:visible') ) );
|
167
|
+
}
|
162
168
|
|
163
|
-
|
169
|
+
len = headers.length;
|
164
170
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
171
|
+
if (outputJSON) {
|
172
|
+
tmpData = [];
|
173
|
+
rowsLen = csvData.length;
|
174
|
+
for ( indx = 0; indx < rowsLen; indx++ ) {
|
175
|
+
// multiple header rows & output_headerRows = true, pick the last row...
|
176
|
+
tmp = headers[ ( len > 1 && wo.output_headerRows ) ? indx % len : len - 1 ];
|
177
|
+
tmpData.push( output.row2Hash( tmp, csvData[ indx ] ) );
|
178
|
+
}
|
173
179
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
+
// requires JSON stringify; if it doesn't exist, the output will show [object Object],... in the output window
|
181
|
+
mydata = hasStringify ? JSON.stringify(tmpData) : tmpData;
|
182
|
+
} else {
|
183
|
+
tmp = [ headers[ ( len > 1 && wo.output_headerRows ) ? indx % len : len - 1 ] ];
|
184
|
+
tmpData = output.row2CSV(wo, wo.output_headerRows ? headers : tmp, outputArray)
|
185
|
+
.concat( output.row2CSV(wo, csvData, outputArray) );
|
180
186
|
|
181
|
-
|
182
|
-
|
183
|
-
|
187
|
+
// stringify the array; if stringify doesn't exist the array will be flattened
|
188
|
+
mydata = outputArray && hasStringify ? JSON.stringify(tmpData) : tmpData.join('\n');
|
189
|
+
}
|
184
190
|
|
185
|
-
|
186
|
-
|
191
|
+
// callback; if true returned, continue processing
|
192
|
+
if ($.isFunction(wo.output_callback) && !wo.output_callback(c, mydata)) { return; }
|
187
193
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
194
|
+
if ( /p/i.test( wo.output_delivery || '' ) ) {
|
195
|
+
output.popup(mydata, wo.output_popupStyle, outputJSON || outputArray);
|
196
|
+
} else {
|
197
|
+
output.download(wo, mydata);
|
198
|
+
}
|
193
199
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
200
|
+
}, // end process
|
201
|
+
|
202
|
+
row2CSV : function(wo, tmpRow, outputArray) {
|
203
|
+
var tmp, rowIndex,
|
204
|
+
csvData = [],
|
205
|
+
rowLen = tmpRow.length;
|
206
|
+
for (rowIndex = 0; rowIndex < rowLen; rowIndex++) {
|
207
|
+
// remove any blank rows
|
208
|
+
tmp = ( tmpRow[rowIndex] || [] ).join('').replace(/\"/g, '');
|
209
|
+
if ( ( tmpRow[rowIndex] || [] ).length > 0 && tmp !== '' ) {
|
210
|
+
csvData[csvData.length] = outputArray ? tmpRow[rowIndex] : tmpRow[rowIndex].join(wo.output_separator);
|
211
|
+
}
|
205
212
|
}
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
213
|
+
return csvData;
|
214
|
+
},
|
215
|
+
|
216
|
+
row2Hash : function( keys, values ) {
|
217
|
+
var indx,
|
218
|
+
json = {},
|
219
|
+
len = values.length;
|
220
|
+
for ( indx = 0; indx < len; indx++ ) {
|
221
|
+
if ( indx < keys.length ) {
|
222
|
+
json[ keys[ indx ] ] = values[ indx ];
|
223
|
+
}
|
224
|
+
}
|
225
|
+
return json;
|
226
|
+
},
|
227
|
+
|
228
|
+
formatData : function(c, wo, $el, isHeader) {
|
229
|
+
var attr = $el.attr(wo.output_dataAttrib),
|
230
|
+
txt = typeof attr !== 'undefined' ? attr : $el.html(),
|
231
|
+
quotes = (wo.output_separator || ',').toLowerCase(),
|
232
|
+
separator = quotes === 'json' || quotes === 'array',
|
233
|
+
// replace " with “ if undefined
|
234
|
+
result = txt.replace(/\"/g, wo.output_replaceQuote || '\u201c');
|
235
|
+
// replace line breaks with \\n & tabs with \\t
|
236
|
+
if (!wo.output_trimSpaces) {
|
237
|
+
result = result.replace(output.regexBR, output.replaceCR).replace(/\t/g, output.replaceTab);
|
238
|
+
} else {
|
239
|
+
result = result.replace(output.regexBR, '');
|
240
|
+
}
|
241
|
+
// extract img alt text
|
242
|
+
txt = result.match(output.regexIMG);
|
243
|
+
if (!wo.output_includeHTML && txt !== null) {
|
244
|
+
result = txt[1];
|
245
|
+
}
|
246
|
+
// replace/remove html
|
247
|
+
result = wo.output_includeHTML && !isHeader ? result : result.replace(output.regexHTML, '');
|
248
|
+
result = wo.output_trimSpaces || isHeader ? $.trim(result) : result;
|
249
|
+
// JSON & array outputs don't need quotes
|
250
|
+
quotes = separator ? false : wo.output_wrapQuotes || wo.output_regex.test(result) || output.regexQuote.test(result);
|
251
|
+
result = quotes ? '"' + result + '"' : result;
|
252
|
+
|
253
|
+
// formatting callback - added v2.22.4
|
254
|
+
if ( typeof wo.output_formatContent === 'function' ) {
|
255
|
+
return wo.output_formatContent( c, wo, {
|
256
|
+
isHeader : isHeader,
|
257
|
+
$cell : $el,
|
258
|
+
content : result
|
259
|
+
});
|
217
260
|
}
|
218
|
-
}
|
219
|
-
return json;
|
220
|
-
},
|
221
|
-
|
222
|
-
formatData : function(wo, $el, isHeader) {
|
223
|
-
var attr = $el.attr(wo.output_dataAttrib),
|
224
|
-
txt = typeof attr !== 'undefined' ? attr : $el.html(),
|
225
|
-
quotes = (wo.output_separator || ',').toLowerCase(),
|
226
|
-
separator = quotes === 'json' || quotes === 'array',
|
227
|
-
// replace " with “ if undefined
|
228
|
-
result = txt.replace(/\"/g, wo.output_replaceQuote || '\u201c');
|
229
|
-
// replace line breaks with \\n & tabs with \\t
|
230
|
-
if (!wo.output_trimSpaces) {
|
231
|
-
result = result.replace(output.regexBR, output.replaceCR).replace(/\t/g, output.replaceTab);
|
232
|
-
} else {
|
233
|
-
result = result.replace(output.regexBR, '');
|
234
|
-
}
|
235
|
-
// extract img alt text
|
236
|
-
txt = result.match(output.regexIMG);
|
237
|
-
if (!wo.output_includeHTML && txt !== null) {
|
238
|
-
result = txt[1];
|
239
|
-
}
|
240
|
-
// replace/remove html
|
241
|
-
result = wo.output_includeHTML && !isHeader ? result : result.replace(output.regexHTML, '');
|
242
|
-
result = wo.output_trimSpaces || isHeader ? $.trim(result) : result;
|
243
|
-
// JSON & array outputs don't need quotes
|
244
|
-
quotes = separator ? false : wo.output_wrapQuotes || wo.output_regex.test(result) || output.regexQuote.test(result);
|
245
|
-
return quotes ? '"' + result + '"' : result;
|
246
|
-
},
|
247
|
-
|
248
|
-
popup : function(data, style, wrap) {
|
249
|
-
var generator = window.open('', output.popupTitle, style);
|
250
|
-
generator.document.write(
|
251
|
-
'<html><head><title>' + output.popupTitle + '</title></head><body>' +
|
252
|
-
'<textarea wrap="' + (wrap ? 'on' : 'off') + '" style="' + output.popupStyle + '">' + data + '\n</textarea>' +
|
253
|
-
'</body></html>'
|
254
|
-
);
|
255
|
-
generator.document.close();
|
256
|
-
generator.focus();
|
257
|
-
// select all text and focus within the textarea in the popup
|
258
|
-
// $(generator.document).find('textarea').select().focus();
|
259
|
-
return true;
|
260
|
-
},
|
261
|
-
|
262
|
-
// modified from https://github.com/PixelsCommander/Download-File-JS
|
263
|
-
// & http://html5-demos.appspot.com/static/a.download.html
|
264
|
-
download : function (wo, data){
|
265
|
-
|
266
|
-
var e, blob, gotBlob,
|
267
|
-
nav = window.navigator,
|
268
|
-
link = document.createElement('a');
|
269
|
-
|
270
|
-
// iOS devices do not support downloading. We have to inform user about this.
|
271
|
-
if (/(iP)/g.test(nav.userAgent)) {
|
272
|
-
alert(output.message);
|
273
|
-
return false;
|
274
|
-
}
|
275
|
-
|
276
|
-
// test for blob support
|
277
|
-
try {
|
278
|
-
gotBlob = !!new Blob();
|
279
|
-
} catch (err) {
|
280
|
-
gotBlob = false;
|
281
|
-
}
|
282
261
|
|
283
|
-
|
284
|
-
|
262
|
+
return result;
|
263
|
+
},
|
264
|
+
|
265
|
+
popup : function(data, style, wrap) {
|
266
|
+
var generator = window.open('', output.popupTitle, style);
|
267
|
+
generator.document.write(
|
268
|
+
'<html><head><title>' + output.popupTitle + '</title></head><body>' +
|
269
|
+
'<textarea wrap="' + (wrap ? 'on' : 'off') + '" style="' + output.popupStyle + '">' + data + '\n</textarea>' +
|
270
|
+
'</body></html>'
|
271
|
+
);
|
272
|
+
generator.document.close();
|
273
|
+
generator.focus();
|
274
|
+
// select all text and focus within the textarea in the popup
|
275
|
+
// $(generator.document).find('textarea').select().focus();
|
276
|
+
return true;
|
277
|
+
},
|
278
|
+
|
279
|
+
// modified from https://github.com/PixelsCommander/Download-File-JS
|
280
|
+
// & http://html5-demos.appspot.com/static/a.download.html
|
281
|
+
download : function (wo, data){
|
282
|
+
|
283
|
+
var e, blob, gotBlob,
|
284
|
+
nav = window.navigator,
|
285
|
+
link = document.createElement('a');
|
286
|
+
|
287
|
+
// iOS devices do not support downloading. We have to inform user about this.
|
288
|
+
if (/(iP)/g.test(nav.userAgent)) {
|
289
|
+
alert(output.message);
|
290
|
+
return false;
|
291
|
+
}
|
285
292
|
|
286
|
-
|
287
|
-
|
288
|
-
|
293
|
+
// test for blob support
|
294
|
+
try {
|
295
|
+
gotBlob = !!new Blob();
|
296
|
+
} catch (err) {
|
297
|
+
gotBlob = false;
|
298
|
+
}
|
289
299
|
|
290
|
-
if
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
//
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
//
|
302
|
-
|
303
|
-
link.
|
300
|
+
// Use HTML5 Blob if browser supports it
|
301
|
+
if ( gotBlob ) {
|
302
|
+
|
303
|
+
window.URL = window.URL || window.webkitURL;
|
304
|
+
// prepend BOM for utf-8 encoding - see https://github.com/eligrey/FileSaver.js/blob/master/FileSaver.js#L140
|
305
|
+
blob = new Blob( [ '\ufeff', data ], { type: wo.output_encoding } );
|
306
|
+
|
307
|
+
if (nav.msSaveBlob) {
|
308
|
+
// IE 10+
|
309
|
+
nav.msSaveBlob(blob, wo.output_saveFileName);
|
310
|
+
} else {
|
311
|
+
// all other browsers
|
312
|
+
link.href = window.URL.createObjectURL(blob);
|
313
|
+
link.download = wo.output_saveFileName;
|
314
|
+
// Dispatching click event; using $(link).trigger() won't work
|
315
|
+
if (document.createEvent) {
|
316
|
+
e = document.createEvent('MouseEvents');
|
317
|
+
// event.initMouseEvent(type, canBubble, cancelable, view, detail, screenX, screenY, clientX, clientY,
|
318
|
+
// ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget);
|
319
|
+
e.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
320
|
+
link.dispatchEvent(e);
|
321
|
+
}
|
304
322
|
}
|
323
|
+
return false;
|
305
324
|
}
|
306
|
-
|
325
|
+
|
326
|
+
// fallback to force file download (whether supported by server).
|
327
|
+
// not sure if this actually works in IE9 and older...
|
328
|
+
window.open( wo.output_encoding + encodeURIComponent(data) + '?download', '_self');
|
329
|
+
return true;
|
330
|
+
|
331
|
+
},
|
332
|
+
|
333
|
+
remove : function(c) {
|
334
|
+
c.$table.off(output.event);
|
335
|
+
}
|
336
|
+
|
337
|
+
};
|
338
|
+
|
339
|
+
ts.addWidget({
|
340
|
+
id: 'output',
|
341
|
+
options: {
|
342
|
+
output_separator : ',', // set to 'json', 'array' or any separator
|
343
|
+
output_ignoreColumns : [], // columns to ignore [0, 1,... ] (zero-based index)
|
344
|
+
output_hiddenColumns : false, // include hidden columns in the output
|
345
|
+
output_includeFooter : false, // include footer rows in the output
|
346
|
+
output_dataAttrib : 'data-name', // header attrib containing modified header name
|
347
|
+
output_headerRows : false, // if true, include multiple header rows (JSON only)
|
348
|
+
output_delivery : 'popup', // popup, download
|
349
|
+
output_saveRows : 'filtered', // (a)ll, (v)isible, (f)iltered or jQuery filter selector
|
350
|
+
output_duplicateSpans : true, // duplicate output data in tbody colspan/rowspan
|
351
|
+
output_replaceQuote : '\u201c;', // left double quote
|
352
|
+
output_includeHTML : false,
|
353
|
+
output_trimSpaces : true,
|
354
|
+
output_wrapQuotes : false,
|
355
|
+
output_popupStyle : 'width=500,height=300',
|
356
|
+
output_saveFileName : 'mytable.csv',
|
357
|
+
// format $cell content callback
|
358
|
+
output_formatContent : null, // function(config, data){ return data.content; }
|
359
|
+
// callback executed when processing completes
|
360
|
+
// return true to continue download/output
|
361
|
+
// return false to stop delivery & do something else with the data
|
362
|
+
output_callback : function(config, data){ return true; },
|
363
|
+
// JSON callback executed when a colspan is encountered in the header
|
364
|
+
output_callbackJSON : function($cell, txt, cellIndex) { return txt + '(' + (cellIndex) + ')'; },
|
365
|
+
// the need to modify this for Excel no longer exists
|
366
|
+
output_encoding : 'data:application/octet-stream;charset=utf8,'
|
367
|
+
},
|
368
|
+
init: function(table, thisWidget, c) {
|
369
|
+
output.init(c);
|
370
|
+
},
|
371
|
+
remove: function(table, c){
|
372
|
+
output.remove(c);
|
307
373
|
}
|
308
374
|
|
309
|
-
|
310
|
-
// not sure if this actually works in IE9 and older...
|
311
|
-
window.open( wo.output_encoding + encodeURIComponent(data) + '?download' , '_self');
|
312
|
-
return true;
|
313
|
-
|
314
|
-
},
|
315
|
-
|
316
|
-
remove : function(c) {
|
317
|
-
c.$table.off(output.event);
|
318
|
-
}
|
319
|
-
|
320
|
-
};
|
321
|
-
|
322
|
-
ts.addWidget({
|
323
|
-
id: "output",
|
324
|
-
options: {
|
325
|
-
output_separator : ',', // set to "json", "array" or any separator
|
326
|
-
output_ignoreColumns : [], // columns to ignore [0, 1,... ] (zero-based index)
|
327
|
-
output_hiddenColumns : false, // include hidden columns in the output
|
328
|
-
output_includeFooter : false, // include footer rows in the output
|
329
|
-
output_dataAttrib : 'data-name', // header attrib containing modified header name
|
330
|
-
output_headerRows : false, // if true, include multiple header rows (JSON only)
|
331
|
-
output_delivery : 'popup', // popup, download
|
332
|
-
output_saveRows : 'filtered', // (a)ll, (v)isible, (f)iltered or jQuery filter selector
|
333
|
-
output_duplicateSpans: true, // duplicate output data in tbody colspan/rowspan
|
334
|
-
output_replaceQuote : '\u201c;', // left double quote
|
335
|
-
output_includeHTML : false,
|
336
|
-
output_trimSpaces : true,
|
337
|
-
output_wrapQuotes : false,
|
338
|
-
output_popupStyle : 'width=500,height=300',
|
339
|
-
output_saveFileName : 'mytable.csv',
|
340
|
-
// callback executed when processing completes
|
341
|
-
// return true to continue download/output
|
342
|
-
// return false to stop delivery & do something else with the data
|
343
|
-
output_callback : function(config, data){ return true; },
|
344
|
-
// JSON callback executed when a colspan is encountered in the header
|
345
|
-
output_callbackJSON : function($cell, txt, cellIndex) { return txt + '(' + (cellIndex) + ')'; },
|
346
|
-
// the need to modify this for Excel no longer exists
|
347
|
-
output_encoding : 'data:application/octet-stream;charset=utf8,'
|
348
|
-
},
|
349
|
-
init: function(table, thisWidget, c) {
|
350
|
-
output.init(c);
|
351
|
-
},
|
352
|
-
remove: function(table, c){
|
353
|
-
output.remove(c);
|
354
|
-
}
|
355
|
-
|
356
|
-
});
|
375
|
+
});
|
357
376
|
|
358
377
|
})(jQuery);
|