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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/jquery-tablesorter/version.rb +1 -1
  4. data/vendor/assets/javascripts/jquery-tablesorter/addons/pager/jquery.tablesorter.pager.js +76 -71
  5. data/vendor/assets/javascripts/jquery-tablesorter/extras/jquery.dragtable.mod.js +1 -1
  6. data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.combined.js +2647 -2576
  7. data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.js +174 -119
  8. data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.widgets.js +2487 -2471
  9. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-extract.js +15 -15
  10. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-iso8601.js +1 -1
  11. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-month.js +4 -4
  12. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-range.js +1 -1
  13. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-two-digit-year.js +12 -12
  14. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-weekday.js +4 -4
  15. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date.js +1 -1
  16. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-duration.js +1 -1
  17. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-feet-inch-fraction.js +6 -6
  18. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-file-type.js +22 -22
  19. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-globalize.js +1 -1
  20. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-ignore-articles.js +15 -15
  21. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-image.js +3 -3
  22. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-input-select.js +10 -3
  23. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-metric.js +2 -2
  24. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-named-numbers.js +3 -3
  25. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-network.js +1 -1
  26. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-roman.js +4 -4
  27. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-alignChar.js +122 -121
  28. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-build-table.js +13 -13
  29. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-chart.js +2 -2
  30. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-columnSelector.js +324 -324
  31. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-columns.js +60 -60
  32. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-editable.js +219 -219
  33. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-formatter-html5.js +360 -361
  34. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-formatter-jui.js +666 -666
  35. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-formatter-select2.js +124 -124
  36. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-type-insideRange.js +1 -1
  37. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter.js +1448 -1433
  38. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-formatter.js +1 -1
  39. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-grouping.js +213 -213
  40. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-headerTitles.js +3 -3
  41. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-math.js +271 -216
  42. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-output.js +339 -320
  43. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-pager.js +1057 -1045
  44. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-print.js +109 -109
  45. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-reflow.js +114 -115
  46. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-resizable.js +360 -359
  47. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-saveSort.js +59 -59
  48. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-scroller.js +818 -806
  49. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-sort2Hash.js +128 -0
  50. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-sortTbodies.js +195 -195
  51. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-staticRow.js +90 -90
  52. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-stickyHeaders.js +257 -257
  53. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-storage.js +76 -76
  54. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-uitheme.js +170 -170
  55. metadata +3 -3
  56. data/vendor/assets/javascripts/jquery-tablesorter/extras/jquery.quicksearch.js +0 -195
@@ -1,78 +1,78 @@
1
1
  /*! Widget: columns */
2
2
  ;(function ($) {
3
- 'use strict';
4
- var ts = $.tablesorter || {};
3
+ 'use strict';
4
+ var ts = $.tablesorter || {};
5
5
 
6
- ts.addWidget({
7
- id: "columns",
8
- priority: 30,
9
- options : {
10
- columns : [ "primary", "secondary", "tertiary" ]
11
- },
12
- format: function(table, c, wo) {
13
- var $tbody, tbodyIndex, $rows, rows, $row, $cells, remove, indx,
6
+ ts.addWidget({
7
+ id: 'columns',
8
+ priority: 30,
9
+ options : {
10
+ columns : [ 'primary', 'secondary', 'tertiary' ]
11
+ },
12
+ format: function(table, c, wo) {
13
+ var $tbody, tbodyIndex, $rows, rows, $row, $cells, remove, indx,
14
14
  $table = c.$table,
15
15
  $tbodies = c.$tbodies,
16
16
  sortList = c.sortList,
17
17
  len = sortList.length,
18
18
  // removed c.widgetColumns support
19
- css = wo && wo.columns || [ "primary", "secondary", "tertiary" ],
19
+ css = wo && wo.columns || [ 'primary', 'secondary', 'tertiary' ],
20
20
  last = css.length - 1;
21
21
  remove = css.join(' ');
22
- // check if there is a sort (on initialization there may not be one)
23
- for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
24
- $tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true); // detach tbody
25
- $rows = $tbody.children('tr');
26
- // loop through the visible rows
27
- $rows.each(function() {
28
- $row = $(this);
29
- if (this.style.display !== 'none') {
30
- // remove all columns class names
31
- $cells = $row.children().removeClass(remove);
32
- // add appropriate column class names
33
- if (sortList && sortList[0]) {
34
- // primary sort column class
35
- $cells.eq(sortList[0][0]).addClass(css[0]);
36
- if (len > 1) {
37
- for (indx = 1; indx < len; indx++) {
38
- // secondary, tertiary, etc sort column classes
39
- $cells.eq(sortList[indx][0]).addClass( css[indx] || css[last] );
22
+ // check if there is a sort (on initialization there may not be one)
23
+ for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
24
+ $tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true); // detach tbody
25
+ $rows = $tbody.children('tr');
26
+ // loop through the visible rows
27
+ $rows.each(function() {
28
+ $row = $(this);
29
+ if (this.style.display !== 'none') {
30
+ // remove all columns class names
31
+ $cells = $row.children().removeClass(remove);
32
+ // add appropriate column class names
33
+ if (sortList && sortList[0]) {
34
+ // primary sort column class
35
+ $cells.eq(sortList[0][0]).addClass(css[0]);
36
+ if (len > 1) {
37
+ for (indx = 1; indx < len; indx++) {
38
+ // secondary, tertiary, etc sort column classes
39
+ $cells.eq(sortList[indx][0]).addClass( css[indx] || css[last] );
40
+ }
40
41
  }
41
42
  }
42
43
  }
43
- }
44
- });
45
- ts.processTbody(table, $tbody, false);
46
- }
47
- // add classes to thead and tfoot
48
- rows = wo.columns_thead !== false ? ['thead tr'] : [];
49
- if (wo.columns_tfoot !== false) {
50
- rows.push('tfoot tr');
51
- }
52
- if (rows.length) {
53
- $rows = $table.find( rows.join(',') ).children().removeClass(remove);
54
- if (len) {
55
- for (indx = 0; indx < len; indx++) {
56
- // add primary. secondary, tertiary, etc sort column classes
57
- $rows.filter('[data-column="' + sortList[indx][0] + '"]').addClass(css[indx] || css[last]);
44
+ });
45
+ ts.processTbody(table, $tbody, false);
46
+ }
47
+ // add classes to thead and tfoot
48
+ rows = wo.columns_thead !== false ? [ 'thead tr' ] : [];
49
+ if (wo.columns_tfoot !== false) {
50
+ rows.push('tfoot tr');
51
+ }
52
+ if (rows.length) {
53
+ $rows = $table.find( rows.join(',') ).children().removeClass(remove);
54
+ if (len) {
55
+ for (indx = 0; indx < len; indx++) {
56
+ // add primary. secondary, tertiary, etc sort column classes
57
+ $rows.filter('[data-column="' + sortList[indx][0] + '"]').addClass(css[indx] || css[last]);
58
+ }
58
59
  }
59
60
  }
61
+ },
62
+ remove: function(table, c, wo) {
63
+ var tbodyIndex, $tbody,
64
+ $tbodies = c.$tbodies,
65
+ remove = (wo.columns || [ 'primary', 'secondary', 'tertiary' ]).join(' ');
66
+ c.$headers.removeClass(remove);
67
+ c.$table.children('tfoot').children('tr').children('th, td').removeClass(remove);
68
+ for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
69
+ $tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true); // remove tbody
70
+ $tbody.children('tr').each(function() {
71
+ $(this).children().removeClass(remove);
72
+ });
73
+ ts.processTbody(table, $tbody, false); // restore tbody
74
+ }
60
75
  }
61
- },
62
- remove: function(table, c, wo) {
63
- var tbodyIndex, $tbody,
64
- $tbodies = c.$tbodies,
65
- remove = (wo.columns || [ "primary", "secondary", "tertiary" ]).join(' ');
66
- c.$headers.removeClass(remove);
67
- c.$table.children('tfoot').children('tr').children('th, td').removeClass(remove);
68
- for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
69
- $tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true); // remove tbody
70
- $tbody.children('tr').each(function() {
71
- $(this).children().removeClass(remove);
72
- });
73
- ts.processTbody(table, $tbody, false); // restore tbody
74
- }
75
- }
76
- });
76
+ });
77
77
 
78
78
  })(jQuery);
@@ -7,254 +7,254 @@
7
7
  ;( function( $ ){
8
8
  'use strict';
9
9
 
10
- var tse = $.tablesorter.editable = {
11
- namespace : '.tseditable',
12
- // last edited class name
13
- lastEdited: 'tseditable-last-edited-cell',
10
+ var tse = $.tablesorter.editable = {
11
+ namespace : '.tseditable',
12
+ // last edited class name
13
+ lastEdited: 'tseditable-last-edited-cell',
14
14
 
15
- editComplete: function( c, wo, $cell, refocus ) {
16
- c.$table
17
- .find( '.' + tse.lastEdited )
18
- .removeClass( tse.lastEdited )
19
- .trigger( wo.editable_editComplete, [ c ] );
20
- // restore focus last cell after updating
21
- if ( refocus ) {
22
- setTimeout( function() {
23
- $cell.focus();
24
- }, 50 );
25
- }
26
- },
27
-
28
- selectAll: function( cell ) {
29
- setTimeout( function() {
30
- // select all text in contenteditable
31
- // see http://stackoverflow.com/a/6150060/145346
32
- var range, selection;
33
- if ( document.body.createTextRange ) {
34
- range = document.body.createTextRange();
35
- range.moveToElementText( cell );
36
- range.select();
37
- } else if ( window.getSelection ) {
38
- selection = window.getSelection();
39
- range = document.createRange();
40
- range.selectNodeContents( cell );
41
- selection.removeAllRanges();
42
- selection.addRange( range );
15
+ editComplete: function( c, wo, $cell, refocus ) {
16
+ c.$table
17
+ .find( '.' + tse.lastEdited )
18
+ .removeClass( tse.lastEdited )
19
+ .trigger( wo.editable_editComplete, [ c ] );
20
+ // restore focus last cell after updating
21
+ if ( refocus ) {
22
+ setTimeout( function() {
23
+ $cell.focus();
24
+ }, 50 );
43
25
  }
44
- }, 100 );
45
- },
26
+ },
27
+
28
+ selectAll: function( cell ) {
29
+ setTimeout( function() {
30
+ // select all text in contenteditable
31
+ // see http://stackoverflow.com/a/6150060/145346
32
+ var range, selection;
33
+ if ( document.body.createTextRange ) {
34
+ range = document.body.createTextRange();
35
+ range.moveToElementText( cell );
36
+ range.select();
37
+ } else if ( window.getSelection ) {
38
+ selection = window.getSelection();
39
+ range = document.createRange();
40
+ range.selectNodeContents( cell );
41
+ selection.removeAllRanges();
42
+ selection.addRange( range );
43
+ }
44
+ }, 100 );
45
+ },
46
46
 
47
- getColumns : function( c, wo ) {
48
- var indx, tmp,
49
- colIndex = [],
50
- cols = [];
51
- if ( !wo.editable_columnsArray && $.type( wo.editable_columns ) === 'string' && wo.editable_columns.indexOf( '-' ) >= 0 ) {
52
- // editable_columns can contain a range string ( i.e. '2-4' )
53
- tmp = wo.editable_columns.split( /\s*-\s*/ );
54
- indx = parseInt( tmp[ 0 ], 10 ) || 0;
55
- tmp = parseInt( tmp[ 1 ], 10 ) || ( c.columns - 1 );
56
- if ( tmp > c.columns ) {
57
- tmp = c.columns - 1;
47
+ getColumns : function( c, wo ) {
48
+ var indx, tmp,
49
+ colIndex = [],
50
+ cols = [];
51
+ if ( !wo.editable_columnsArray && $.type( wo.editable_columns ) === 'string' && wo.editable_columns.indexOf( '-' ) >= 0 ) {
52
+ // editable_columns can contain a range string ( i.e. '2-4' )
53
+ tmp = wo.editable_columns.split( /\s*-\s*/ );
54
+ indx = parseInt( tmp[ 0 ], 10 ) || 0;
55
+ tmp = parseInt( tmp[ 1 ], 10 ) || ( c.columns - 1 );
56
+ if ( tmp > c.columns ) {
57
+ tmp = c.columns - 1;
58
+ }
59
+ for ( ; indx <= tmp; indx++ ) {
60
+ colIndex.push( indx );
61
+ cols.push( 'td:nth-child(' + ( indx + 1 ) + ')' );
62
+ }
63
+ } else if ( $.isArray( wo.editable_columns ) ) {
64
+ $.each( wo.editable_columnsArray || wo.editable_columns, function( i, col ) {
65
+ if ( col < c.columns ) {
66
+ colIndex.push( col );
67
+ cols.push( 'td:nth-child(' + ( col + 1 ) + ')' );
68
+ }
69
+ });
58
70
  }
59
- for ( ; indx <= tmp; indx++ ) {
60
- colIndex.push( indx );
61
- cols.push( 'td:nth-child(' + ( indx + 1 ) + ')' );
71
+ if ( !wo.editable_columnsArray ) {
72
+ wo.editable_columnsArray = colIndex;
73
+ wo.editable_columnsArray.sort(function(a, b){ return a - b; });
62
74
  }
63
- } else if ( $.isArray( wo.editable_columns ) ) {
64
- $.each( wo.editable_columnsArray || wo.editable_columns, function( i, col ) {
65
- if ( col < c.columns ) {
66
- colIndex.push( col );
67
- cols.push( 'td:nth-child(' + ( col + 1 ) + ')' );
68
- }
69
- });
70
- }
71
- if ( !wo.editable_columnsArray ) {
72
- wo.editable_columnsArray = colIndex;
73
- wo.editable_columnsArray.sort(function(a,b){ return a - b; });
74
- }
75
- return cols;
76
- },
75
+ return cols;
76
+ },
77
77
 
78
- update: function( c, wo ) {
79
- var $t,
80
- tmp = $( '<div>' ).wrapInner( wo.editable_wrapContent ).children().length || $.isFunction( wo.editable_wrapContent ),
81
- cols = tse.getColumns( c, wo ).join( ',' );
78
+ update: function( c, wo ) {
79
+ var $t,
80
+ tmp = $( '<div>' ).wrapInner( wo.editable_wrapContent ).children().length || $.isFunction( wo.editable_wrapContent ),
81
+ cols = tse.getColumns( c, wo ).join( ',' );
82
82
 
83
- // turn off contenteditable to allow dynamically setting the wo.editable_noEdit
84
- // class on table cells - see issue #900
85
- c.$tbodies.find( cols ).find( '[contenteditable]' ).prop( 'contenteditable', false );
83
+ // turn off contenteditable to allow dynamically setting the wo.editable_noEdit
84
+ // class on table cells - see issue #900
85
+ c.$tbodies.find( cols ).find( '[contenteditable]' ).prop( 'contenteditable', false );
86
86
 
87
- // IE does not allow making TR/TH/TD cells directly editable ( issue #404 )
88
- // so add a div or span inside ( it's faster than using wrapInner() )
89
- c.$tbodies.find( cols ).not( '.' + wo.editable_noEdit ).each( function() {
90
- // test for children, if they exist, then make the children editable
91
- $t = $( this );
87
+ // IE does not allow making TR/TH/TD cells directly editable ( issue #404 )
88
+ // so add a div or span inside ( it's faster than using wrapInner() )
89
+ c.$tbodies.find( cols ).not( '.' + wo.editable_noEdit ).each( function() {
90
+ // test for children, if they exist, then make the children editable
91
+ $t = $( this );
92
92
 
93
- if ( tmp && $t.children( 'div, span' ).length === 0 ) {
94
- $t.wrapInner( wo.editable_wrapContent );
95
- }
96
- if ( $t.children( 'div, span' ).length ) {
97
- // make div/span children content editable
98
- $t.children( 'div, span' ).not( '.' + wo.editable_noEdit ).each( function() {
99
- var $this = $( this );
93
+ if ( tmp && $t.children( 'div, span' ).length === 0 ) {
94
+ $t.wrapInner( wo.editable_wrapContent );
95
+ }
96
+ if ( $t.children( 'div, span' ).length ) {
97
+ // make div/span children content editable
98
+ $t.children( 'div, span' ).not( '.' + wo.editable_noEdit ).each( function() {
99
+ var $this = $( this );
100
+ if ( wo.editable_trimContent ) {
101
+ $this.html( function( i, txt ) {
102
+ return $.trim( txt );
103
+ });
104
+ }
105
+ $this.prop( 'contenteditable', true );
106
+ });
107
+ } else {
100
108
  if ( wo.editable_trimContent ) {
101
- $this.html( function( i, txt ) {
109
+ $t.html( function( i, txt ) {
102
110
  return $.trim( txt );
103
111
  });
104
112
  }
105
- $this.prop( 'contenteditable', true );
106
- });
107
- } else {
108
- if ( wo.editable_trimContent ) {
109
- $t.html( function( i, txt ) {
110
- return $.trim( txt );
111
- });
112
- }
113
- $t.prop( 'contenteditable', true );
114
- }
115
- });
116
- },
117
-
118
- bindEvents: function( c, wo ) {
119
- var namespace = tse.namespace;
120
- c.$table
121
- .off( ( 'updateComplete pagerComplete '.split( ' ' ).join( namespace + ' ' ) ).replace( /\s+/g, ' ' ) )
122
- .on( 'updateComplete pagerComplete '.split( ' ' ).join( namespace + ' ' ), function() {
123
- tse.update( c, c.widgetOptions );
124
- })
125
- // prevent sort initialized by user click on the header from changing the row indexing before
126
- // updateCell can finish processing the change
127
- .children( 'thead' )
128
- .add( $( c.namespace + '_extra_table' ).children( 'thead' ) )
129
- .off( 'mouseenter' + namespace )
130
- .on( 'mouseenter' + namespace, function() {
131
- if ( c.$table.data( 'contentFocused' ) ) {
132
- // change to 'true' instead of element to allow focusout to process
133
- c.$table.data( 'contentFocused', true );
134
- $( ':focus' ).trigger( 'focusout' );
113
+ $t.prop( 'contenteditable', true );
135
114
  }
136
115
  });
116
+ },
137
117
 
138
- c.$tbodies
139
- .off( ( 'focus blur focusout keydown '.split( ' ' ).join( namespace + ' ' ) ).replace( /\s+/g, ' ' ) )
140
- .on( 'focus' + namespace, '[contenteditable]', function( e ) {
141
- clearTimeout( $( this ).data( 'timer' ) );
142
- c.$table.data( 'contentFocused', e.target );
143
- c.table.isUpdating = true; // prevent sorting while editing
144
- var $this = $( this ),
145
- selAll = wo.editable_selectAll,
146
- column = $this.closest( 'td' ).index(),
147
- txt = $this.html();
148
- if ( wo.editable_trimContent ) {
149
- txt = $.trim( txt );
150
- }
151
- // prevent enter from adding into the content
152
- $this
153
- .off( 'keydown' + namespace )
154
- .on( 'keydown' + namespace, function( e ){
155
- if ( wo.editable_enterToAccept && e.which === 13 && !e.shiftKey ) {
156
- e.preventDefault();
157
- }
158
- });
159
- $this.data({ before : txt, original: txt });
160
-
161
- if ( typeof wo.editable_focused === 'function' ) {
162
- wo.editable_focused( txt, column, $this );
163
- }
164
-
165
- if ( selAll ) {
166
- if ( typeof selAll === 'function' ) {
167
- if ( selAll( txt, column, $this ) ) {
168
- tse.selectAll( $this[0] );
169
- }
170
- } else {
171
- tse.selectAll( $this[0] );
118
+ bindEvents: function( c, wo ) {
119
+ var namespace = tse.namespace;
120
+ c.$table
121
+ .off( ( 'updateComplete pagerComplete '.split( ' ' ).join( namespace + ' ' ) ).replace( /\s+/g, ' ' ) )
122
+ .on( 'updateComplete pagerComplete '.split( ' ' ).join( namespace + ' ' ), function() {
123
+ tse.update( c, c.widgetOptions );
124
+ })
125
+ // prevent sort initialized by user click on the header from changing the row indexing before
126
+ // updateCell can finish processing the change
127
+ .children( 'thead' )
128
+ .add( $( c.namespace + '_extra_table' ).children( 'thead' ) )
129
+ .off( 'mouseenter' + namespace )
130
+ .on( 'mouseenter' + namespace, function() {
131
+ if ( c.$table.data( 'contentFocused' ) ) {
132
+ // change to 'true' instead of element to allow focusout to process
133
+ c.$table.data( 'contentFocused', true );
134
+ $( ':focus' ).trigger( 'focusout' );
172
135
  }
173
- }
174
- })
175
- .on( 'blur focusout keydown '.split( ' ' ).join( namespace + ' ' ), '[contenteditable]', function( e ) {
176
- if ( !c.$table.data( 'contentFocused' ) ) { return; }
177
- var t, validate,
178
- valid = false,
179
- $this = $( e.target ),
180
- txt = $this.html(),
181
- column = $this.closest( 'td' ).index();
182
- if ( wo.editable_trimContent ) {
183
- txt = $.trim( txt );
184
- }
185
- if ( e.which === 27 ) {
186
- // user cancelled
187
- $this.html( $this.data( 'original' ) ).trigger( 'blur' + namespace );
188
- c.$table.data( 'contentFocused', false );
189
- c.table.isUpdating = false;
190
- return false;
191
- }
192
- // accept on enter ( if set ), alt-enter ( always ) or if autoAccept is set and element is blurred or unfocused
193
- t = e.which === 13 && !e.shiftKey && ( wo.editable_enterToAccept || e.altKey ) || wo.editable_autoAccept && e.type !== 'keydown';
194
- // change if new or user hits enter ( if option set )
195
- if ( t && $this.data( 'before' ) !== txt ) {
136
+ });
196
137
 
197
- validate = wo.editable_validate;
198
- valid = txt;
138
+ c.$tbodies
139
+ .off( ( 'focus blur focusout keydown '.split( ' ' ).join( namespace + ' ' ) ).replace( /\s+/g, ' ' ) )
140
+ .on( 'focus' + namespace, '[contenteditable]', function( e ) {
141
+ clearTimeout( $( this ).data( 'timer' ) );
142
+ c.$table.data( 'contentFocused', e.target );
143
+ c.table.isUpdating = true; // prevent sorting while editing
144
+ var $this = $( this ),
145
+ selAll = wo.editable_selectAll,
146
+ column = $this.closest( 'td' ).index(),
147
+ txt = $this.html();
148
+ if ( wo.editable_trimContent ) {
149
+ txt = $.trim( txt );
150
+ }
151
+ // prevent enter from adding into the content
152
+ $this
153
+ .off( 'keydown' + namespace )
154
+ .on( 'keydown' + namespace, function( e ){
155
+ if ( wo.editable_enterToAccept && e.which === 13 && !e.shiftKey ) {
156
+ e.preventDefault();
157
+ }
158
+ });
159
+ $this.data({ before : txt, original: txt });
199
160
 
200
- if ( typeof( validate ) === 'function' ) {
201
- valid = validate( txt, $this.data( 'original' ), column, $this );
202
- } else if ( typeof ( validate = $.tablesorter.getColumnData( c.table, validate, column ) ) === 'function' ) {
203
- valid = validate( txt, $this.data( 'original' ), column, $this );
161
+ if ( typeof wo.editable_focused === 'function' ) {
162
+ wo.editable_focused( txt, column, $this );
204
163
  }
205
164
 
206
- if ( t && valid !== false ) {
207
- c.$table.find( '.' + tse.lastEdited ).removeClass( tse.lastEdited );
208
- $this
209
- .addClass( tse.lastEdited )
210
- .html( valid )
211
- .data( 'before', valid )
212
- .data( 'original', valid )
213
- .trigger( 'change' );
214
- c.$table.trigger( 'updateCell', [ $this.closest( 'td' ), false, function() {
215
- if ( wo.editable_autoResort ) {
216
- setTimeout( function() {
217
- c.$table.trigger( 'sorton', [ c.sortList, function() {
218
- tse.editComplete( c, wo, c.$table.data( 'contentFocused' ), true );
219
- }, true ] );
220
- }, 10 );
221
- } else {
222
- tse.editComplete( c, wo, c.$table.data( 'contentFocused' ) );
165
+ if ( selAll ) {
166
+ if ( typeof selAll === 'function' ) {
167
+ if ( selAll( txt, column, $this ) ) {
168
+ tse.selectAll( $this[0] );
223
169
  }
224
- } ] );
170
+ } else {
171
+ tse.selectAll( $this[0] );
172
+ }
173
+ }
174
+ })
175
+ .on( 'blur focusout keydown '.split( ' ' ).join( namespace + ' ' ), '[contenteditable]', function( e ) {
176
+ if ( !c.$table.data( 'contentFocused' ) ) { return; }
177
+ var t, validate,
178
+ valid = false,
179
+ $this = $( e.target ),
180
+ txt = $this.html(),
181
+ column = $this.closest( 'td' ).index();
182
+ if ( wo.editable_trimContent ) {
183
+ txt = $.trim( txt );
184
+ }
185
+ if ( e.which === 27 ) {
186
+ // user cancelled
187
+ $this.html( $this.data( 'original' ) ).trigger( 'blur' + namespace );
188
+ c.$table.data( 'contentFocused', false );
189
+ c.table.isUpdating = false;
225
190
  return false;
226
191
  }
227
- } else if ( !valid && e.type !== 'keydown' ) {
228
- clearTimeout( $this.data( 'timer' ) );
229
- $this.data( 'timer', setTimeout( function() {
230
- c.table.isUpdating = false; // clear flag or sorting will be disabled
192
+ // accept on enter ( if set ), alt-enter ( always ) or if autoAccept is set and element is blurred or unfocused
193
+ t = e.which === 13 && !e.shiftKey && ( wo.editable_enterToAccept || e.altKey ) || wo.editable_autoAccept && e.type !== 'keydown';
194
+ // change if new or user hits enter ( if option set )
195
+ if ( t && $this.data( 'before' ) !== txt ) {
196
+
197
+ validate = wo.editable_validate;
198
+ valid = txt;
231
199
 
232
- if ( $.isFunction( wo.editable_blur ) ) {
233
- txt = $this.html();
234
- wo.editable_blur( wo.editable_trimContent ? $.trim( txt ) : txt, column, $this );
200
+ if ( typeof validate === 'function' ) {
201
+ valid = validate( txt, $this.data( 'original' ), column, $this );
202
+ } else if ( typeof ( validate = $.tablesorter.getColumnData( c.table, validate, column ) ) === 'function' ) {
203
+ valid = validate( txt, $this.data( 'original' ), column, $this );
235
204
  }
236
- }, 100 ) );
237
- // restore original content on blur
238
- $this.html( $this.data( 'original' ) );
239
- }
240
- });
241
- },
242
- destroy : function( c, wo ) {
243
- var namespace = tse.namespace,
244
- cols = tse.getColumns( c, wo ),
245
205
 
246
- tmp = ( 'updateComplete pagerComplete '.split( ' ' ).join( namespace + ' ' ) ).replace( /\s+/g, ' ' );
247
- c.$table.off( tmp );
206
+ if ( t && valid !== false ) {
207
+ c.$table.find( '.' + tse.lastEdited ).removeClass( tse.lastEdited );
208
+ $this
209
+ .addClass( tse.lastEdited )
210
+ .html( valid )
211
+ .data( 'before', valid )
212
+ .data( 'original', valid )
213
+ .trigger( 'change' );
214
+ c.$table.trigger( 'updateCell', [ $this.closest( 'td' ), false, function() {
215
+ if ( wo.editable_autoResort ) {
216
+ setTimeout( function() {
217
+ c.$table.trigger( 'sorton', [ c.sortList, function() {
218
+ tse.editComplete( c, wo, c.$table.data( 'contentFocused' ), true );
219
+ }, true ] );
220
+ }, 10 );
221
+ } else {
222
+ tse.editComplete( c, wo, c.$table.data( 'contentFocused' ) );
223
+ }
224
+ } ] );
225
+ return false;
226
+ }
227
+ } else if ( !valid && e.type !== 'keydown' ) {
228
+ clearTimeout( $this.data( 'timer' ) );
229
+ $this.data( 'timer', setTimeout( function() {
230
+ c.table.isUpdating = false; // clear flag or sorting will be disabled
231
+
232
+ if ( $.isFunction( wo.editable_blur ) ) {
233
+ txt = $this.html();
234
+ wo.editable_blur( wo.editable_trimContent ? $.trim( txt ) : txt, column, $this );
235
+ }
236
+ }, 100 ) );
237
+ // restore original content on blur
238
+ $this.html( $this.data( 'original' ) );
239
+ }
240
+ });
241
+ },
242
+ destroy : function( c, wo ) {
243
+ var namespace = tse.namespace,
244
+ cols = tse.getColumns( c, wo ),
245
+
246
+ tmp = ( 'updateComplete pagerComplete '.split( ' ' ).join( namespace + ' ' ) ).replace( /\s+/g, ' ' );
247
+ c.$table.off( tmp );
248
248
 
249
- tmp = ( 'focus blur focusout keydown '.split( ' ' ).join( namespace + ' ' ) ).replace( /\s+/g, ' ' );
250
- c.$tbodies
251
- .off( tmp )
252
- .find( cols.join( ',' ) )
253
- .find( '[contenteditable]' )
254
- .prop( 'contenteditable', false );
255
- }
249
+ tmp = ( 'focus blur focusout keydown '.split( ' ' ).join( namespace + ' ' ) ).replace( /\s+/g, ' ' );
250
+ c.$tbodies
251
+ .off( tmp )
252
+ .find( cols.join( ',' ) )
253
+ .find( '[contenteditable]' )
254
+ .prop( 'contenteditable', false );
255
+ }
256
256
 
257
- };
257
+ };
258
258
 
259
259
  $.tablesorter.addWidget({
260
260
  id: 'editable',