jquery-tablesorter 1.10.1 → 1.10.10

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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/{README.markdown → README.md} +8 -3
  3. data/Rakefile +39 -35
  4. data/lib/jquery-tablesorter/version.rb +1 -1
  5. data/lib/jquery-tablesorter.rb +1 -1
  6. data/vendor/assets/javascripts/jquery-tablesorter/addons/pager/jquery.tablesorter.pager.js +66 -29
  7. data/vendor/assets/javascripts/jquery-tablesorter/extras/jquery.quicksearch.js +191 -0
  8. data/vendor/assets/javascripts/jquery-tablesorter/extras/semver-mod.js +1026 -0
  9. data/vendor/assets/javascripts/jquery-tablesorter/extras/semver.js +1011 -0
  10. data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.js +156 -99
  11. data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.widgets-filter-formatter.js +22 -22
  12. data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.widgets.js +68 -42
  13. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-iso8601.js +34 -0
  14. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-month.js +33 -0
  15. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-two-digit-year.js +74 -0
  16. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-weekday.js +33 -0
  17. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date.js +36 -0
  18. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-feet-inch-fraction.js +63 -0
  19. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-file-type.js +73 -0
  20. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-ignore-articles.js +47 -0
  21. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-input-select.js +87 -0
  22. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-ipv6.js +76 -0
  23. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-metric.js +77 -0
  24. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-alignChar.js +145 -0
  25. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-build-table.js +441 -0
  26. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-columnSelector.js +306 -0
  27. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-cssStickyHeaders.js +67 -0
  28. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-editable.js +89 -0
  29. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-grouping.js +249 -0
  30. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-headerTitles.js +91 -0
  31. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-pager.js +864 -0
  32. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-repeatheaders.js +50 -0
  33. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-scroller.js +241 -0
  34. data/vendor/assets/stylesheets/jquery-tablesorter/theme.black-ice.css +4 -0
  35. data/vendor/assets/stylesheets/jquery-tablesorter/theme.blue.css +4 -0
  36. data/vendor/assets/stylesheets/jquery-tablesorter/theme.bootstrap.css +14 -5
  37. data/vendor/assets/stylesheets/jquery-tablesorter/theme.bootstrap_2.css +4 -0
  38. data/vendor/assets/stylesheets/jquery-tablesorter/theme.dark.css +4 -0
  39. data/vendor/assets/stylesheets/jquery-tablesorter/theme.default.css +4 -0
  40. data/vendor/assets/stylesheets/jquery-tablesorter/theme.dropbox.css +4 -0
  41. data/vendor/assets/stylesheets/jquery-tablesorter/theme.green.css +4 -0
  42. data/vendor/assets/stylesheets/jquery-tablesorter/theme.grey.css +4 -0
  43. data/vendor/assets/stylesheets/jquery-tablesorter/theme.ice.css +4 -0
  44. data/vendor/assets/stylesheets/jquery-tablesorter/theme.jui.css +9 -3
  45. metadata +28 -12
  46. data/vendor/assets/images/jquery-tablesorter/dropbox-asc1.png +0 -0
  47. data/vendor/assets/images/jquery-tablesorter/dropbox-asc2.png +0 -0
  48. data/vendor/assets/images/jquery-tablesorter/dropbox-desc1.png +0 -0
  49. data/vendor/assets/images/jquery-tablesorter/dropbox-desc2.png +0 -0
  50. data/vendor/assets/images/jquery-tablesorter/green-asc.png +0 -0
  51. data/vendor/assets/images/jquery-tablesorter/green-desc.png +0 -0
  52. data/vendor/assets/images/jquery-tablesorter/green-header.png +0 -0
  53. data/vendor/assets/images/jquery-tablesorter/green-unsorted.png +0 -0
@@ -0,0 +1,306 @@
1
+ /* Column Selector/Responsive table widget (beta) for TableSorter 3/31/2014 (v2.15.12)
2
+ * Requires tablesorter v2.8+ and jQuery 1.7+
3
+ * by Justin Hallett & Rob Garrison
4
+ */
5
+ /*jshint browser:true, jquery:true, unused:false */
6
+ /*global jQuery: false */
7
+ ;(function($){
8
+ "use strict";
9
+
10
+ var ts = $.tablesorter,
11
+ namespace = '.tscolsel',
12
+ tsColSel = ts.columnSelector = {
13
+
14
+ queryAll : '@media only all { [columns] { display: none; } }',
15
+ queryBreak : '@media screen and (min-width: [size]) { [columns] { display: table-cell; } }',
16
+
17
+ init: function(table, c, wo) {
18
+ var $t, colSel;
19
+
20
+ // abort if no input is contained within the layout
21
+ $t = $(wo.columnSelector_layout);
22
+ if (!$t.find('input').add( $t.filter('input') ).length) {
23
+ if (c.debug) {
24
+ ts.log('*** ERROR: Column Selector aborting, no input found in the layout! ***');
25
+ }
26
+ return;
27
+ }
28
+
29
+ // unique table class name
30
+ c.tableId = 'tablesorter' + new Date().getTime();
31
+ c.$table.addClass( c.tableId );
32
+
33
+ // build column selector/state array
34
+ colSel = c.selector = { $container : $(wo.columnSelector_container || '<div>') };
35
+ colSel.$style = $('<style></style>').prop('disabled', true).appendTo('head');
36
+ colSel.$breakpoints = $('<style></style>').prop('disabled', true).appendTo('head');
37
+
38
+ colSel.isInitializing = true;
39
+ tsColSel.setupSelector(table, c, wo);
40
+
41
+ if (wo.columnSelector_mediaquery) {
42
+ tsColSel.setupBreakpoints(c, wo);
43
+ }
44
+
45
+ colSel.isInitializing = false;
46
+ if (colSel.$container.length) {
47
+ tsColSel.updateCols(c, wo);
48
+ }
49
+
50
+ },
51
+
52
+ setupSelector: function(table, c, wo) {
53
+ var name,
54
+ colSel = c.selector,
55
+ $container = colSel.$container,
56
+ useStorage = wo.columnSelector_saveColumns && ts.storage,
57
+ // get stored column states
58
+ saved = useStorage ? ts.storage( table, 'tablesorter-columnSelector' ) : [],
59
+ state = useStorage ? ts.storage( table, 'tablesorter-columnSelector-auto') : {};
60
+
61
+ // initial states
62
+ colSel.auto = $.isEmptyObject(state) || $.type(state.auto) !== "boolean" ? wo.columnSelector_mediaqueryState : state.auto;
63
+ colSel.states = [];
64
+ colSel.$column = [];
65
+ colSel.$wrapper = [];
66
+ colSel.$checkbox = [];
67
+ // populate the selector container
68
+ c.$table.children('thead').find('tr:first th', table).each(function() {
69
+ var $this = $(this),
70
+ // if no data-priority is assigned, default to 1, but don't remove it from the selector list
71
+ priority = $this.attr(wo.columnSelector_priority) || 1,
72
+ colId = $this.attr('data-column'),
73
+ state = ts.getData(this, c.headers[colId], 'columnSelector');
74
+
75
+
76
+ // if this column not hidable at all
77
+ // include getData check (includes "columnSelector-false" class, data attribute, etc)
78
+ if ( isNaN(priority) && priority.length > 0 || state === 'disable' ||
79
+ ( wo.columnSelector_columns[colId] && wo.columnSelector_columns[colId] === 'disable') ) {
80
+ return true; // goto next
81
+ }
82
+
83
+ // set default state; storage takes priority
84
+ colSel.states[colId] = saved && typeof(saved[colId]) !== 'undefined' ?
85
+ saved[colId] : typeof(wo.columnSelector_columns[colId]) !== 'undefined' ?
86
+ wo.columnSelector_columns[colId] : (state === 'true' || !(state === 'false'));
87
+ colSel.$column[colId] = $(this);
88
+
89
+ // set default col title
90
+ name = $this.attr(wo.columnSelector_name) || $this.text();
91
+
92
+ if ($container.length) {
93
+ colSel.$wrapper[colId] = $(wo.columnSelector_layout.replace(/\{name\}/g, name)).appendTo($container);
94
+ colSel.$checkbox[colId] = colSel.$wrapper[colId]
95
+ // input may not be wrapped within the layout template
96
+ .find('input').add( colSel.$wrapper[colId].filter('input') )
97
+ .attr('data-column', colId)
98
+ .prop('checked', colSel.states[colId])
99
+ .on('change', function(){
100
+ colSel.states[colId] = this.checked;
101
+ tsColSel.updateCols(c, wo);
102
+ }).change();
103
+ }
104
+ });
105
+
106
+ },
107
+
108
+ setupBreakpoints: function(c, wo){
109
+ var colSel = c.selector;
110
+
111
+ // add responsive breakpoints
112
+ if (wo.columnSelector_mediaquery) {
113
+ // used by window resize function
114
+ colSel.lastIndex = -1;
115
+ wo.columnSelector_breakpoints.sort();
116
+ tsColSel.updateBreakpoints(c, wo);
117
+ c.$table.off('updateAll' + namespace).on('updateAll' + namespace, function(){
118
+ tsColSel.updateBreakpoints(c, wo);
119
+ tsColSel.updateCols(c, wo);
120
+ });
121
+ }
122
+
123
+ if (colSel.$container.length) {
124
+ // Add media queries toggle
125
+ if (wo.columnSelector_mediaquery) {
126
+ colSel.$auto = $( wo.columnSelector_layout.replace(/\{name\}/g, wo.columnSelector_mediaqueryName) ).prependTo(colSel.$container);
127
+ colSel.$auto
128
+ // needed in case the input in the layout is not wrapped
129
+ .find('input').add( colSel.$auto.filter('input') )
130
+ .attr('data-column', 'auto')
131
+ .prop('checked', colSel.auto)
132
+ .on('change', function(){
133
+ colSel.auto = this.checked;
134
+ $.each( colSel.$checkbox, function(i, $cb){
135
+ if ($cb) {
136
+ $cb[0].disabled = colSel.auto;
137
+ colSel.$wrapper[i].toggleClass('disabled', colSel.auto);
138
+ }
139
+ });
140
+ if (wo.columnSelector_mediaquery) {
141
+ tsColSel.updateBreakpoints(c, wo);
142
+ }
143
+ tsColSel.updateCols(c, wo);
144
+ // copy the column selector to a popup/tooltip
145
+ if (c.selector.$popup) {
146
+ c.selector.$popup.find('.tablesorter-column-selector')
147
+ .html( colSel.$container.html() )
148
+ .find('input').each(function(){
149
+ var indx = $(this).attr('data-column');
150
+ $(this).prop( 'checked', indx === 'auto' ? colSel.auto : colSel.states[indx] );
151
+ });
152
+ }
153
+ if (wo.columnSelector_saveColumns && ts.storage) {
154
+ ts.storage( c.$table[0], 'tablesorter-columnSelector-auto', { auto : colSel.auto } );
155
+ }
156
+ }).change();
157
+ }
158
+ // Add a bind on update to re-run col setup
159
+ c.$table.off('update' + namespace).on('update' + namespace, function() {
160
+ tsColSel.updateCols(c, wo);
161
+ });
162
+ }
163
+ },
164
+
165
+ updateBreakpoints: function(c, wo) {
166
+ var priority, column, breaks,
167
+ colSel = c.selector,
168
+ prefix = '.' + c.tableId,
169
+ mediaAll = [],
170
+ breakpts = '';
171
+ if (wo.columnSelector_mediaquery && !colSel.auto) {
172
+ colSel.$breakpoints.prop('disabled', true);
173
+ colSel.$style.prop('disabled', false);
174
+ return;
175
+ }
176
+
177
+ // only 6 breakpoints (same as jQuery Mobile)
178
+ for (priority = 0; priority < 6; priority++){
179
+ /*jshint loopfunc:true */
180
+ breaks = [];
181
+ c.$headers.filter('[' + wo.columnSelector_priority + '=' + (priority + 1) + ']').each(function(){
182
+ column = parseInt($(this).attr('data-column'), 10) + 1;
183
+ breaks.push(prefix + ' tr th:nth-child(' + column + ')');
184
+ breaks.push(prefix + ' tr td:nth-child(' + column + ')');
185
+ });
186
+ if (breaks.length) {
187
+ mediaAll = mediaAll.concat( breaks );
188
+ breakpts += tsColSel.queryBreak
189
+ .replace(/\[size\]/g, wo.columnSelector_breakpoints[priority])
190
+ .replace(/\[columns\]/g, breaks.join(','));
191
+ }
192
+ }
193
+ if (colSel.$style) {
194
+ colSel.$style.prop('disabled', true);
195
+ }
196
+ colSel.$breakpoints
197
+ .prop('disabled', false)
198
+ .html( tsColSel.queryAll.replace(/\[columns\]/g, mediaAll.join(',')) + breakpts );
199
+ },
200
+
201
+ updateCols: function(c, wo) {
202
+ if (wo.columnSelector_mediaquery && c.selector.auto || c.selector.isInitializing) {
203
+ return;
204
+ }
205
+ var column,
206
+ colSel = c.selector,
207
+ styles = [],
208
+ prefix = '.' + c.tableId;
209
+ colSel.$container.find('input[data-column]').filter('[data-column!="auto"]').each(function(){
210
+ if (!this.checked) {
211
+ column = parseInt( $(this).attr('data-column'), 10 ) + 1;
212
+ styles.push(prefix + ' tr th:nth-child(' + column + ')');
213
+ styles.push(prefix + ' tr td:nth-child(' + column + ')');
214
+ }
215
+ });
216
+ if (wo.columnSelector_mediaquery){
217
+ colSel.$breakpoints.prop('disabled', true);
218
+ }
219
+ if (colSel.$style) {
220
+ colSel.$style.prop('disabled', false).html( styles.length ? styles.join(',') + ' { display: none; }' : '' );
221
+ }
222
+ if (wo.columnSelector_saveColumns && ts.storage) {
223
+ ts.storage( c.$table[0], 'tablesorter-columnSelector', colSel.states );
224
+ }
225
+ },
226
+
227
+ attachTo : function(table, elm) {
228
+ table = $(table)[0];
229
+ var colSel, wo, indx,
230
+ c = table.config,
231
+ $popup = $(elm);
232
+ if ($popup.length && c) {
233
+ if (!$popup.find('.tablesorter-column-selector').length) {
234
+ // add a wrapper to add the selector into, in case the popup has other content
235
+ $popup.append('<span class="tablesorter-column-selector"></span>');
236
+ }
237
+ colSel = c.selector;
238
+ wo = c.widgetOptions;
239
+ $popup.find('.tablesorter-column-selector')
240
+ .html( colSel.$container.html() )
241
+ .find('input').each(function(){
242
+ var indx = $(this).attr('data-column');
243
+ $(this).prop( 'checked', indx === 'auto' ? colSel.auto : colSel.states[indx] );
244
+ });
245
+ colSel.$popup = $popup.on('change', 'input', function(){
246
+ // data input
247
+ indx = $(this).attr('data-column');
248
+ // update original popup
249
+ colSel.$container.find('input[data-column="' + indx + '"]')
250
+ .prop('checked', this.checked)
251
+ .trigger('change');
252
+ });
253
+ }
254
+ }
255
+
256
+ };
257
+
258
+ ts.addWidget({
259
+ id: "columnSelector",
260
+ priority: 10,
261
+ options: {
262
+ // target the column selector markup
263
+ columnSelector_container : null,
264
+ // column status, true = display, false = hide
265
+ // disable = do not display on list
266
+ columnSelector_columns : {},
267
+ // remember selected columns
268
+ columnSelector_saveColumns: true,
269
+
270
+ // container layout
271
+ columnSelector_layout : '<label><input type="checkbox">{name}</label>',
272
+ // data attribute containing column name to use in the selector container
273
+ columnSelector_name : 'data-selector-name',
274
+
275
+ /* Responsive Media Query settings */
276
+ // enable/disable mediaquery breakpoints
277
+ columnSelector_mediaquery: true,
278
+ // toggle checkbox name
279
+ columnSelector_mediaqueryName: 'Auto: ',
280
+ // breakpoints checkbox initial setting
281
+ columnSelector_mediaqueryState: true,
282
+ // responsive table hides columns with priority 1-6 at these breakpoints
283
+ // see http://view.jquerymobile.com/1.3.2/dist/demos/widgets/table-column-toggle/#Applyingapresetbreakpoint
284
+ // *** set to false to disable ***
285
+ columnSelector_breakpoints : [ '20em', '30em', '40em', '50em', '60em', '70em' ],
286
+ // data attribute containing column priority
287
+ // duplicates how jQuery mobile uses priorities:
288
+ // http://view.jquerymobile.com/1.3.2/dist/demos/widgets/table-column-toggle/
289
+ columnSelector_priority : 'data-priority'
290
+
291
+ },
292
+ init: function(table, thisWidget, c, wo) {
293
+ tsColSel.init(table, c, wo);
294
+ },
295
+ remove: function(table, c){
296
+ var csel = c.selector;
297
+ csel.$container.empty();
298
+ csel.$popup.empty();
299
+ csel.$style.remove();
300
+ csel.$breakpoints.remove();
301
+ c.$table.off('updateAll' + namespace + ' update' + namespace);
302
+ }
303
+
304
+ });
305
+
306
+ })(jQuery);
@@ -0,0 +1,67 @@
1
+ /*! tablesorter CSS Sticky Headers widget - updated 12/17/2013 (v2.15.0)
2
+ * Requires a modern browser, tablesorter v2.8+
3
+ */
4
+ /*global jQuery: false, unused:false */
5
+ ;(function($){
6
+ "use strict";
7
+
8
+ $.tablesorter.addWidget({
9
+ id: "cssStickyHeaders",
10
+ priority: 10,
11
+ options: {
12
+ cssStickyHeaders_offset : 0,
13
+ cssStickyHeaders_addCaption : false,
14
+ cssStickyHeaders_attachTo : null,
15
+ cssStickyHeaders_zIndex : 10
16
+ },
17
+ init : function(table, thisWidget, c, wo) {
18
+ var $attach = $(wo.cssStickyHeaders_attachTo),
19
+ namespace = '.cssstickyheader',
20
+ $thead = c.$table.children('thead'),
21
+ $caption = c.$table.find('caption'),
22
+ $win = $attach.length ? $attach : $(window);
23
+ $win.bind('scroll resize '.split(' ').join(namespace + ' '), function() {
24
+ var top = $attach.length ? $attach.offset().top : $win.scrollTop(),
25
+ // add caption height; include table padding top & border-spacing or text may be above the fold (jQuery UI themes)
26
+ // border-spacing needed in Firefox, but not webkit... not sure if I should account for that
27
+ captionTop = wo.cssStickyHeaders_addCaption ? $caption.outerHeight(true) +
28
+ (parseInt(c.$table.css('padding-top'), 10) || 0) + (parseInt(c.$table.css('border-spacing'), 10) || 0) : 0,
29
+ bottom = c.$table.height() - $thead.height() - (c.$table.find('tfoot').height() || 0) - captionTop,
30
+ deltaY = top - $thead.offset().top + (parseInt(c.$table.css('border-top-width'), 10) || 0) +
31
+ (wo.cssStickyHeaders_offset || 0) + captionTop,
32
+ finalY = (deltaY > 0 && deltaY <= bottom ? deltaY : 0),
33
+ // IE can only transform header cells - fixes #447 thanks to @gakreol!
34
+ $cells = $thead.children().children();
35
+ if (wo.cssStickyHeaders_addCaption) {
36
+ $cells = $cells.add($caption);
37
+ }
38
+ $cells.css({
39
+ "position" : "relative",
40
+ "z-index" : wo.cssStickyHeaders_zIndex,
41
+ "transform" : finalY === 0 ? "" : "translate(0px," + finalY + "px)",
42
+ "-ms-transform" : finalY === 0 ? "" : "translate(0px," + finalY + "px)",
43
+ "-webkit-transform" : finalY === 0 ? "" : "translate(0px," + finalY + "px)"
44
+ });
45
+ });
46
+ c.$table.bind('filterEnd', function() {
47
+ // scroll top of table into view
48
+ window.scrollTo(0, c.$table.position().top);
49
+ });
50
+
51
+ },
52
+ remove: function(table, c, wo){
53
+ var namespace = '.cssstickyheader';
54
+ $(window).unbind('scroll resize '.split(' ').join(namespace + ' '));
55
+ c.$table
56
+ .unbind('update updateAll '.split(' ').join(namespace + ' '))
57
+ .children('thead, caption').css({
58
+ "position" : "",
59
+ "z-index" : "",
60
+ "transform" : "",
61
+ "-ms-transform" : "",
62
+ "-webkit-transform" : ""
63
+ });
64
+ }
65
+ });
66
+
67
+ })(jQuery);
@@ -0,0 +1,89 @@
1
+ /*! tablesorter Editable Content widget - updated 1/24/2014 (core v2.15.0)
2
+ * Requires tablesorter v2.8+ and jQuery 1.7+
3
+ * by Rob Garrison
4
+ */
5
+ /*jshint browser:true, jquery:true, unused:false */
6
+ /*global jQuery: false */
7
+ ;(function($){
8
+ "use strict";
9
+
10
+ $.tablesorter.addWidget({
11
+ id: 'editable',
12
+ options : {
13
+ editable_columns : [],
14
+ editable_enterToAccept : true,
15
+ editable_autoResort : false,
16
+ editable_noEdit : 'no-edit',
17
+ editable_editComplete : 'editComplete'
18
+ },
19
+ init: function(table, thisWidget, c, wo){
20
+ if (!wo.editable_columns.length) { return; }
21
+ var indx, tmp, $t, cols = [];
22
+ if (wo.editable_columns.indexOf('-') >= 0) {
23
+ // editable_columns can contain a range string (i.e. "2-4" )
24
+ tmp = wo.editable_columns.split('-');
25
+ indx = parseInt(tmp[0],10) || 0;
26
+ tmp = parseInt(tmp[1],10) || (c.columns - 1);
27
+ if (tmp > c.columns) { tmp = c.columns - 1; }
28
+ for (; indx <= tmp; indx++) {
29
+ cols.push('td:nth-child(' + (indx + 1) + ')');
30
+ }
31
+ } else if ($.isArray(wo.editable_columns)) {
32
+ $.each(wo.editable_columns, function(i, col){
33
+ cols.push('td:nth-child(' + (col + 1) + ')');
34
+ });
35
+ }
36
+ // IE does not allow making TR/TH/TD cells directly editable (issue #404)
37
+ // so add a div or span inside ( it's faster than using wrapInner() )
38
+ c.$tbodies.find( cols.join(',') ).not('.' + wo.editable_noEdit).each(function(){
39
+ // test for children, if they exist, then make the children editable
40
+ $t = $(this);
41
+ ( $t.children().length ? $t.children() : $t ).prop('contenteditable', true);
42
+ });
43
+ c.$tbodies
44
+ .on('mouseleave.tseditable', function(){
45
+ if (c.$table.data('contentFocused')) {
46
+ $(':focus').trigger('blur');
47
+ }
48
+ })
49
+ .on('focus.tseditable', '[contenteditable]', function(){
50
+ c.$table.data('contentFocused', true);
51
+ var $this = $(this), v = $this.html();
52
+ if (wo.editable_enterToAccept) {
53
+ // prevent enter from adding into the content
54
+ $this.on('keydown.tseditable', function(e){
55
+ if (e.which === 13) {
56
+ e.preventDefault();
57
+ }
58
+ });
59
+ }
60
+ $this.data({ before : v, original: v });
61
+ })
62
+ .on('blur focusout keyup '.split(' ').join('.tseditable '), '[contenteditable]', function(e){
63
+ if (!c.$table.data('contentFocused')) { return; }
64
+ var $this = $(e.target), t;
65
+ if (e.which === 27) {
66
+ // user cancelled
67
+ $this.html( $this.data('original') ).trigger('blur.tseditable');
68
+ c.$table.data('contentFocused', false);
69
+ return false;
70
+ }
71
+ t = e.type !== 'keyup' || (wo.editable_enterToAccept && e.which === 13);
72
+ // change if new or user hits enter (if option set)
73
+ if ($this.data('before') !== $this.html() || t) {
74
+ $this.data('before', $this.html()).trigger('change');
75
+ if (t) {
76
+ c.$table
77
+ .data('contentFocused', false)
78
+ .trigger('updateCell', [ $this.closest('td'), wo.editable_autoResort, function(table){
79
+ $this.trigger( wo.editable_editComplete );
80
+ c.$table.trigger('applyWidgets');
81
+ } ]);
82
+ $this.trigger('blur.tseditable');
83
+ }
84
+ }
85
+ });
86
+ }
87
+ });
88
+
89
+ })(jQuery);