bootstrap-table-rails 1.11.1.1 → 1.12.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +7 -7
  2. data/README.md +6 -3
  3. data/lib/bootstrap-table-rails/version.rb +1 -1
  4. data/vendor/assets/javascripts/bootstrap-table-locale-all.js +374 -6
  5. data/vendor/assets/javascripts/bootstrap-table.js +348 -147
  6. data/vendor/assets/javascripts/extensions/bootstrap-table-accent-neutralise.js +1 -1
  7. data/vendor/assets/javascripts/extensions/bootstrap-table-angular.js +0 -0
  8. data/vendor/assets/javascripts/extensions/bootstrap-table-auto-refresh.js +62 -62
  9. data/vendor/assets/javascripts/extensions/bootstrap-table-click-edit-row.js +0 -0
  10. data/vendor/assets/javascripts/extensions/bootstrap-table-cookie.js +48 -69
  11. data/vendor/assets/javascripts/extensions/bootstrap-table-copy-rows.js +0 -0
  12. data/vendor/assets/javascripts/extensions/bootstrap-table-defer-url.js +32 -0
  13. data/vendor/assets/javascripts/extensions/bootstrap-table-editable.js +0 -0
  14. data/vendor/assets/javascripts/extensions/bootstrap-table-export.js +56 -8
  15. data/vendor/assets/javascripts/extensions/bootstrap-table-filter-control.js +93 -46
  16. data/vendor/assets/javascripts/extensions/bootstrap-table-filter.js +0 -0
  17. data/vendor/assets/javascripts/extensions/bootstrap-table-flat-json.js +0 -0
  18. data/vendor/assets/javascripts/extensions/bootstrap-table-group-by-v2.js +0 -0
  19. data/vendor/assets/javascripts/extensions/bootstrap-table-group-by.js +2 -2
  20. data/vendor/assets/javascripts/extensions/bootstrap-table-i18n-enhance.js +3 -2
  21. data/vendor/assets/javascripts/extensions/bootstrap-table-jumpto.js +50 -0
  22. data/vendor/assets/javascripts/extensions/bootstrap-table-key-events.js +0 -0
  23. data/vendor/assets/javascripts/extensions/bootstrap-table-mobile.js +1 -1
  24. data/vendor/assets/javascripts/extensions/bootstrap-table-multi-toggle.js +0 -0
  25. data/vendor/assets/javascripts/extensions/bootstrap-table-multiple-search.js +1 -1
  26. data/vendor/assets/javascripts/extensions/bootstrap-table-multiple-selection-row.js +0 -0
  27. data/vendor/assets/javascripts/extensions/bootstrap-table-multiple-sort.js +31 -12
  28. data/vendor/assets/javascripts/extensions/bootstrap-table-natural-sorting.js +0 -0
  29. data/vendor/assets/javascripts/extensions/bootstrap-table-print.js +33 -17
  30. data/vendor/assets/javascripts/extensions/bootstrap-table-reorder-columns.js +2 -2
  31. data/vendor/assets/javascripts/extensions/bootstrap-table-reorder-rows.js +0 -0
  32. data/vendor/assets/javascripts/extensions/bootstrap-table-resizable.js +2 -1
  33. data/vendor/assets/javascripts/extensions/bootstrap-table-select2-filter.js +136 -107
  34. data/vendor/assets/javascripts/extensions/bootstrap-table-sticky-header.js +11 -4
  35. data/vendor/assets/javascripts/extensions/bootstrap-table-toolbar.js +0 -0
  36. data/vendor/assets/javascripts/extensions/bootstrap-table-tree-column.js +0 -0
  37. data/vendor/assets/javascripts/extensions/bootstrap-table-treegrid.js +95 -0
  38. data/vendor/assets/javascripts/locale/bootstrap-table-af-ZA.js +0 -0
  39. data/vendor/assets/javascripts/locale/bootstrap-table-ar-SA.js +0 -0
  40. data/vendor/assets/javascripts/locale/bootstrap-table-ca-ES.js +0 -0
  41. data/vendor/assets/javascripts/locale/bootstrap-table-cs-CZ.js +0 -0
  42. data/vendor/assets/javascripts/locale/bootstrap-table-da-DK.js +0 -0
  43. data/vendor/assets/javascripts/locale/bootstrap-table-de-DE.js +14 -5
  44. data/vendor/assets/javascripts/locale/bootstrap-table-el-GR.js +0 -0
  45. data/vendor/assets/javascripts/locale/bootstrap-table-en-US.js +0 -0
  46. data/vendor/assets/javascripts/locale/bootstrap-table-es-AR.js +0 -0
  47. data/vendor/assets/javascripts/locale/bootstrap-table-es-CL.js +0 -0
  48. data/vendor/assets/javascripts/locale/bootstrap-table-es-CR.js +0 -0
  49. data/vendor/assets/javascripts/locale/bootstrap-table-es-ES.js +0 -0
  50. data/vendor/assets/javascripts/locale/bootstrap-table-es-MX.js +20 -1
  51. data/vendor/assets/javascripts/locale/bootstrap-table-es-NI.js +0 -0
  52. data/vendor/assets/javascripts/locale/bootstrap-table-es-SP.js +0 -0
  53. data/vendor/assets/javascripts/locale/bootstrap-table-et-EE.js +0 -0
  54. data/vendor/assets/javascripts/locale/bootstrap-table-eu-EU.js +43 -0
  55. data/vendor/assets/javascripts/locale/bootstrap-table-fa-IR.js +0 -0
  56. data/vendor/assets/javascripts/locale/bootstrap-table-fr-BE.js +0 -0
  57. data/vendor/assets/javascripts/locale/bootstrap-table-fr-FR.js +54 -0
  58. data/vendor/assets/javascripts/locale/bootstrap-table-he-IL.js +0 -0
  59. data/vendor/assets/javascripts/locale/bootstrap-table-hr-HR.js +0 -0
  60. data/vendor/assets/javascripts/locale/bootstrap-table-hu-HU.js +0 -0
  61. data/vendor/assets/javascripts/locale/bootstrap-table-id-ID.js +0 -0
  62. data/vendor/assets/javascripts/locale/bootstrap-table-it-IT.js +0 -0
  63. data/vendor/assets/javascripts/locale/bootstrap-table-ja-JP.js +0 -0
  64. data/vendor/assets/javascripts/locale/bootstrap-table-ka-GE.js +0 -0
  65. data/vendor/assets/javascripts/locale/bootstrap-table-ko-KR.js +0 -0
  66. data/vendor/assets/javascripts/locale/bootstrap-table-ms-MY.js +0 -0
  67. data/vendor/assets/javascripts/locale/bootstrap-table-nb-NO.js +0 -0
  68. data/vendor/assets/javascripts/locale/bootstrap-table-nl-NL.js +0 -0
  69. data/vendor/assets/javascripts/locale/bootstrap-table-pl-PL.js +0 -0
  70. data/vendor/assets/javascripts/locale/bootstrap-table-pt-BR.js +0 -0
  71. data/vendor/assets/javascripts/locale/bootstrap-table-pt-PT.js +0 -0
  72. data/vendor/assets/javascripts/locale/bootstrap-table-ro-RO.js +0 -0
  73. data/vendor/assets/javascripts/locale/bootstrap-table-ru-RU.js +0 -0
  74. data/vendor/assets/javascripts/locale/bootstrap-table-sk-SK.js +12 -0
  75. data/vendor/assets/javascripts/locale/bootstrap-table-sv-SE.js +0 -0
  76. data/vendor/assets/javascripts/locale/bootstrap-table-th-TH.js +0 -0
  77. data/vendor/assets/javascripts/locale/bootstrap-table-tr-TR.js +0 -0
  78. data/vendor/assets/javascripts/locale/bootstrap-table-uk-UA.js +0 -0
  79. data/vendor/assets/javascripts/locale/bootstrap-table-ur-PK.js +0 -0
  80. data/vendor/assets/javascripts/locale/bootstrap-table-uz-Latn-UZ.js +0 -0
  81. data/vendor/assets/javascripts/locale/bootstrap-table-vi-VN.js +0 -0
  82. data/vendor/assets/javascripts/locale/bootstrap-table-zh-CN.js +0 -0
  83. data/vendor/assets/javascripts/locale/bootstrap-table-zh-TW.js +0 -0
  84. data/vendor/assets/stylesheets/bootstrap-table.css +11 -6
  85. data/vendor/assets/stylesheets/extensions/bootstrap-table-auto-refresh.css +1 -1
  86. data/vendor/assets/stylesheets/extensions/bootstrap-table-click-edit-row.css +0 -0
  87. data/vendor/assets/stylesheets/extensions/bootstrap-table-filter-control.css +0 -0
  88. data/vendor/assets/stylesheets/extensions/bootstrap-table-group-by-v2.css +0 -0
  89. data/vendor/assets/stylesheets/extensions/bootstrap-table-group-by.css +0 -0
  90. data/vendor/assets/stylesheets/extensions/bootstrap-table-jumpto.css +8 -0
  91. data/vendor/assets/stylesheets/extensions/bootstrap-table-multiple-selection-row.css +0 -0
  92. data/vendor/assets/stylesheets/extensions/bootstrap-table-reorder-rows.css +0 -0
  93. data/vendor/assets/stylesheets/extensions/bootstrap-table-sticky-header.css +0 -0
  94. data/vendor/assets/stylesheets/extensions/bootstrap-table-tree-column.css +0 -0
  95. metadata +49 -50
  96. data/vendor/assets/javascripts/locale/README.md +0 -179
  97. data/vendor/assets/javascripts/locale/bootstrap-table-en-US.js.template +0 -49
@@ -149,7 +149,7 @@
149
149
  for (var key in item) {
150
150
  key = $.isNumeric(key) ? parseInt(key, 10) : key;
151
151
  var value = item[key],
152
- column = that.columns[$.fn.bootstrapTable.utils.getFieldIndex(that.columns, key)],
152
+ column = that.columns[that.fieldsColumnsIndex[key]],
153
153
  j = $.inArray(key, that.header.fields);
154
154
 
155
155
  if (column && column.searchFormatter) {
@@ -6,79 +6,79 @@
6
6
 
7
7
  (function ($) {
8
8
 
9
- 'use strict';
9
+ 'use strict';
10
10
 
11
- $.extend($.fn.bootstrapTable.defaults, {
12
- autoRefresh: false,
13
- autoRefreshInterval: 60,
14
- autoRefreshSilent: true,
15
- autoRefreshStatus: true,
16
- autoRefreshFunction: null
17
- });
11
+ $.extend($.fn.bootstrapTable.defaults, {
12
+ autoRefresh: false,
13
+ autoRefreshInterval: 60,
14
+ autoRefreshSilent: true,
15
+ autoRefreshStatus: true,
16
+ autoRefreshFunction: null
17
+ });
18
18
 
19
- $.extend($.fn.bootstrapTable.defaults.icons, {
20
- autoRefresh: 'glyphicon-time icon-time'
21
- });
19
+ $.extend($.fn.bootstrapTable.defaults.icons, {
20
+ autoRefresh: 'glyphicon-time icon-time'
21
+ });
22
22
 
23
- $.extend($.fn.bootstrapTable.locales, {
24
- formatAutoRefresh: function() {
25
- return 'Auto Refresh';
26
- }
27
- });
23
+ $.extend($.fn.bootstrapTable.locales, {
24
+ formatAutoRefresh: function() {
25
+ return 'Auto Refresh';
26
+ }
27
+ });
28
28
 
29
- $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
29
+ $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
30
30
 
31
- var BootstrapTable = $.fn.bootstrapTable.Constructor;
32
- var _init = BootstrapTable.prototype.init;
33
- var _initToolbar = BootstrapTable.prototype.initToolbar;
34
- var sprintf = $.fn.bootstrapTable.utils.sprintf;
31
+ var BootstrapTable = $.fn.bootstrapTable.Constructor;
32
+ var _init = BootstrapTable.prototype.init;
33
+ var _initToolbar = BootstrapTable.prototype.initToolbar;
34
+ var sprintf = $.fn.bootstrapTable.utils.sprintf;
35
35
 
36
- BootstrapTable.prototype.init = function () {
37
- _init.apply(this, Array.prototype.slice.apply(arguments));
36
+ BootstrapTable.prototype.init = function () {
37
+ _init.apply(this, Array.prototype.slice.apply(arguments));
38
38
 
39
- if (this.options.autoRefresh && this.options.autoRefreshStatus) {
40
- var that = this;
41
- this.options.autoRefreshFunction = setInterval(function () {
42
- that.refresh({silent: that.options.autoRefreshSilent});
43
- }, this.options.autoRefreshInterval*1000);
44
- }
45
- };
39
+ if (this.options.autoRefresh && this.options.autoRefreshStatus) {
40
+ var that = this;
41
+ this.options.autoRefreshFunction = setInterval(function () {
42
+ that.refresh({silent: that.options.autoRefreshSilent});
43
+ }, this.options.autoRefreshInterval*1000);
44
+ }
45
+ };
46
46
 
47
- BootstrapTable.prototype.initToolbar = function() {
48
- _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
47
+ BootstrapTable.prototype.initToolbar = function() {
48
+ _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
49
49
 
50
- if (this.options.autoRefresh) {
51
- var $btnGroup = this.$toolbar.find('>.btn-group');
52
- var $btnAutoRefresh = $btnGroup.find('.auto-refresh');
50
+ if (this.options.autoRefresh) {
51
+ var $btnGroup = this.$toolbar.find('>.btn-group');
52
+ var $btnAutoRefresh = $btnGroup.find('.auto-refresh');
53
53
 
54
- if (!$btnAutoRefresh.length) {
55
- $btnAutoRefresh = $([
56
- sprintf('<button class="btn btn-default auto-refresh %s" ', this.options.autoRefreshStatus ? 'enabled' : ''),
57
- 'type="button" ',
58
- sprintf('title="%s">', this.options.formatAutoRefresh()),
59
- sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.autoRefresh),
60
- '</button>'
61
- ].join('')).appendTo($btnGroup);
54
+ if (!$btnAutoRefresh.length) {
55
+ $btnAutoRefresh = $([
56
+ sprintf('<button class="btn btn-default auto-refresh %s" ', this.options.autoRefreshStatus ? 'enabled' : ''),
57
+ 'type="button" ',
58
+ sprintf('title="%s">', this.options.formatAutoRefresh()),
59
+ sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.autoRefresh),
60
+ '</button>'
61
+ ].join('')).appendTo($btnGroup);
62
62
 
63
- $btnAutoRefresh.on('click', $.proxy(this.toggleAutoRefresh, this));
64
- }
65
- }
66
- };
63
+ $btnAutoRefresh.on('click', $.proxy(this.toggleAutoRefresh, this));
64
+ }
65
+ }
66
+ };
67
67
 
68
- BootstrapTable.prototype.toggleAutoRefresh = function() {
69
- if (this.options.autoRefresh) {
70
- if (this.options.autoRefreshStatus) {
71
- clearInterval(this.options.autoRefreshFunction);
72
- this.$toolbar.find('>.btn-group').find('.auto-refresh').removeClass('enabled');
73
- } else {
74
- var that = this;
75
- this.options.autoRefreshFunction = setInterval(function () {
76
- that.refresh({silent: that.options.autoRefreshSilent});
77
- }, this.options.autoRefreshInterval*1000);
78
- this.$toolbar.find('>.btn-group').find('.auto-refresh').addClass('enabled');
79
- }
80
- this.options.autoRefreshStatus = !this.options.autoRefreshStatus;
81
- }
82
- };
68
+ BootstrapTable.prototype.toggleAutoRefresh = function() {
69
+ if (this.options.autoRefresh) {
70
+ if (this.options.autoRefreshStatus) {
71
+ clearInterval(this.options.autoRefreshFunction);
72
+ this.$toolbar.find('>.btn-group').find('.auto-refresh').removeClass('enabled');
73
+ } else {
74
+ var that = this;
75
+ this.options.autoRefreshFunction = setInterval(function () {
76
+ that.refresh({silent: that.options.autoRefreshSilent});
77
+ }, this.options.autoRefreshInterval*1000);
78
+ this.$toolbar.find('>.btn-group').find('.auto-refresh').addClass('enabled');
79
+ }
80
+ this.options.autoRefreshStatus = !this.options.autoRefreshStatus;
81
+ }
82
+ };
83
83
 
84
84
  })(jQuery);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @author: Dennis Hernández
3
3
  * @webSite: http://djhvscf.github.io/Blog
4
- * @version: v1.2.2
4
+ * @version: v1.2.3
5
5
  *
6
6
  * @update zhixin wen <wenzhixin2010@gmail.com>
7
7
  */
@@ -68,19 +68,18 @@
68
68
  switch(that.options.cookieStorage) {
69
69
  case 'cookieStorage':
70
70
  document.cookie = [
71
- cookieName, '=', cookieValue,
72
- '; expires=' + that.options.cookieExpire,
73
- that.options.cookiePath ? '; path=' + that.options.cookiePath : '',
74
- that.options.cookieDomain ? '; domain=' + that.options.cookieDomain : '',
75
- that.options.cookieSecure ? '; secure' : ''
76
- ].join('');
77
- break;
71
+ cookieName, '=', cookieValue,
72
+ '; expires=' + calculateExpiration(that.options.cookieExpire),
73
+ that.options.cookiePath ? '; path=' + that.options.cookiePath : '',
74
+ that.options.cookieDomain ? '; domain=' + that.options.cookieDomain : '',
75
+ that.options.cookieSecure ? '; secure' : ''
76
+ ].join('');
78
77
  case 'localStorage':
79
78
  localStorage.setItem(cookieName, cookieValue);
80
- break;
79
+ break;
81
80
  case 'sessionStorage':
82
81
  sessionStorage.setItem(cookieName, cookieValue);
83
- break;
82
+ break;
84
83
  default:
85
84
  return false;
86
85
  }
@@ -101,7 +100,9 @@
101
100
 
102
101
  switch(that.options.cookieStorage) {
103
102
  case 'cookieStorage':
104
- return decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' + encodeURIComponent(cookieName).replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null;
103
+ var value = '; ' + document.cookie;
104
+ var parts = value.split('; ' + cookieName + '=');
105
+ return parts.length === 2 ? parts.pop().split(';').shift() : null;
105
106
  case 'localStorage':
106
107
  return localStorage.getItem(cookieName);
107
108
  case 'sessionStorage':
@@ -113,22 +114,22 @@
113
114
 
114
115
  var deleteCookie = function (that, tableName, cookieName) {
115
116
  cookieName = tableName + '.' + cookieName;
116
-
117
+
117
118
  switch(that.options.cookieStorage) {
118
119
  case 'cookieStorage':
119
120
  document.cookie = [
120
- encodeURIComponent(cookieName), '=',
121
- '; expires=Thu, 01 Jan 1970 00:00:00 GMT',
122
- that.options.cookiePath ? '; path=' + that.options.cookiePath : '',
123
- that.options.cookieDomain ? '; domain=' + that.options.cookieDomain : '',
124
- ].join('');
121
+ encodeURIComponent(cookieName), '=',
122
+ '; expires=Thu, 01 Jan 1970 00:00:00 GMT',
123
+ that.options.cookiePath ? '; path=' + that.options.cookiePath : '',
124
+ that.options.cookieDomain ? '; domain=' + that.options.cookieDomain : '',
125
+ ].join('');
125
126
  break;
126
127
  case 'localStorage':
127
128
  localStorage.removeItem(cookieName);
128
- break;
129
+ break;
129
130
  case 'sessionStorage':
130
131
  sessionStorage.removeItem(cookieName);
131
- break;
132
+ break;
132
133
 
133
134
  }
134
135
  return true;
@@ -136,7 +137,7 @@
136
137
 
137
138
  var calculateExpiration = function(cookieExpire) {
138
139
  var time = cookieExpire.replace(/[0-9]*/, ''); //s,mi,h,d,m,y
139
- cookieExpire = cookieExpire.replace(/[A-Za-z]{1,2}}/, ''); //number
140
+ cookieExpire = cookieExpire.replace(/[A-Za-z]{1,2}/, ''); //number
140
141
 
141
142
  switch (time.toLowerCase()) {
142
143
  case 's':
@@ -161,8 +162,12 @@
161
162
  cookieExpire = undefined;
162
163
  break;
163
164
  }
164
-
165
- return cookieExpire === undefined ? '' : '; max-age=' + cookieExpire;
165
+ if (!cookieExpire) {
166
+ return '';
167
+ }
168
+ var d = new Date();
169
+ d.setTime(d.getTime() + cookieExpire * 1000);
170
+ return d.toGMTString();
166
171
  };
167
172
 
168
173
  var initCookieFilters = function (bootstrapTable) {
@@ -170,7 +175,6 @@
170
175
  var parsedCookieFilters = JSON.parse(getCookie(bootstrapTable, bootstrapTable.options.cookieIdTable, cookieIds.filterControl));
171
176
 
172
177
  if (!bootstrapTable.options.filterControlValuesLoaded && parsedCookieFilters) {
173
- bootstrapTable.options.filterControlValuesLoaded = true;
174
178
 
175
179
  var cachedFilters = {},
176
180
  header = getCurrentHeader(bootstrapTable),
@@ -178,8 +182,10 @@
178
182
 
179
183
  applyCookieFilters = function (element, filteredCookies) {
180
184
  $(filteredCookies).each(function (i, cookie) {
181
- $(element).val(cookie.text);
182
- cachedFilters[cookie.field] = cookie.text;
185
+ if (cookie.text !== '') {
186
+ $(element).val(cookie.text);
187
+ cachedFilters[cookie.field] = cookie.text;
188
+ }
183
189
  });
184
190
  };
185
191
 
@@ -193,6 +199,8 @@
193
199
  });
194
200
 
195
201
  bootstrapTable.initColumnSearch(cachedFilters);
202
+ bootstrapTable.options.filterControlValuesLoaded = true;
203
+ bootstrapTable.initServer();
196
204
  }
197
205
  }, 250);
198
206
  };
@@ -231,23 +239,20 @@
231
239
  _onSort = BootstrapTable.prototype.onSort,
232
240
  _onPageNumber = BootstrapTable.prototype.onPageNumber,
233
241
  _onPageListChange = BootstrapTable.prototype.onPageListChange,
234
- _onPageFirst = BootstrapTable.prototype.onPageFirst,
235
242
  _onPagePre = BootstrapTable.prototype.onPagePre,
236
243
  _onPageNext = BootstrapTable.prototype.onPageNext,
237
- _onPageLast = BootstrapTable.prototype.onPageLast,
238
244
  _toggleColumn = BootstrapTable.prototype.toggleColumn,
239
245
  _selectPage = BootstrapTable.prototype.selectPage,
240
246
  _onSearch = BootstrapTable.prototype.onSearch;
241
247
 
242
248
  BootstrapTable.prototype.init = function () {
243
- var timeoutId = 0;
244
249
  this.options.filterControls = [];
245
250
  this.options.filterControlValuesLoaded = false;
246
251
 
247
252
  this.options.cookiesEnabled = typeof this.options.cookiesEnabled === 'string' ?
248
253
  this.options.cookiesEnabled.replace('[', '').replace(']', '')
249
254
  .replace(/ /g, '').toLowerCase().split(',') :
250
- this.options.cookiesEnabled;
255
+ this.options.cookiesEnabled;
251
256
 
252
257
  if (this.options.filterControl) {
253
258
  var that = this;
@@ -275,36 +280,12 @@
275
280
  };
276
281
 
277
282
  BootstrapTable.prototype.initServer = function () {
278
- var bootstrapTable = this,
279
- selectsWithoutDefaults = [],
280
-
281
- columnHasSelectControl = function (column) {
282
- return column.filterControl && column.filterControl === 'select';
283
- },
284
-
285
- columnHasDefaultSelectValues = function (column) {
286
- return column.filterData && column.filterData !== 'column';
287
- },
288
-
289
- cookiesPresent = function() {
290
- var cookie = JSON.parse(getCookie(bootstrapTable, bootstrapTable.options.cookieIdTable, cookieIds.filterControl));
291
- return bootstrapTable.options.cookie && cookie;
292
- };
293
-
294
- selectsWithoutDefaults = $.grep(bootstrapTable.columns, function(column) {
295
- return columnHasSelectControl(column) && !columnHasDefaultSelectValues(column);
296
- });
297
-
298
- // reset variable to original initServer function, so that future calls to initServer
299
- // use the original function from this point on.
300
- BootstrapTable.prototype.initServer = _initServer;
301
-
302
- // early return if we don't need to populate any select values with cookie values
303
- if (this.options.filterControl && cookiesPresent() && selectsWithoutDefaults.length === 0) {
304
- return;
283
+ var bootstrapTable = this;
284
+ if (bootstrapTable.options.cookie && bootstrapTable.options.filterControl && !bootstrapTable.options.filterControlValuesLoaded) {
285
+ var cookie = JSON.parse(getCookie(bootstrapTable, bootstrapTable.options.cookieIdTable, cookieIds.filterControl));
286
+ if (cookie)
287
+ return;
305
288
  }
306
-
307
- // call BootstrapTable.prototype.initServer
308
289
  _initServer.apply(this, Array.prototype.slice.apply(arguments));
309
290
  };
310
291
 
@@ -320,7 +301,9 @@
320
301
  }
321
302
 
322
303
  if ((this.options.cookieIdTable === '') || (this.options.cookieExpire === '') || (!cookieEnabled())) {
323
- throw new Error("Configuration error. Please review the cookieIdTable, cookieExpire properties, if those properties are ok, then this browser does not support the cookies");
304
+ console.error("Configuration error. Please review the cookieIdTable, cookieExpire properties, if those properties are ok, then this browser does not support the cookies");
305
+ this.options.cookie = false; //Make sure that the cookie extension is disabled
306
+ return;
324
307
  }
325
308
 
326
309
  var sortOrderCookie = getCookie(this, this.options.cookieIdTable, cookieIds.sortOrder),
@@ -357,31 +340,26 @@
357
340
  BootstrapTable.prototype.onPageNumber = function () {
358
341
  _onPageNumber.apply(this, Array.prototype.slice.apply(arguments));
359
342
  setCookie(this, cookieIds.pageNumber, this.options.pageNumber);
343
+ return false;
360
344
  };
361
345
 
362
346
  BootstrapTable.prototype.onPageListChange = function () {
363
347
  _onPageListChange.apply(this, Array.prototype.slice.apply(arguments));
364
348
  setCookie(this, cookieIds.pageList, this.options.pageSize);
365
- };
366
-
367
- BootstrapTable.prototype.onPageFirst = function () {
368
- _onPageFirst.apply(this, Array.prototype.slice.apply(arguments));
369
349
  setCookie(this, cookieIds.pageNumber, this.options.pageNumber);
350
+ return false;
370
351
  };
371
352
 
372
353
  BootstrapTable.prototype.onPagePre = function () {
373
354
  _onPagePre.apply(this, Array.prototype.slice.apply(arguments));
374
355
  setCookie(this, cookieIds.pageNumber, this.options.pageNumber);
356
+ return false;
375
357
  };
376
358
 
377
359
  BootstrapTable.prototype.onPageNext = function () {
378
360
  _onPageNext.apply(this, Array.prototype.slice.apply(arguments));
379
361
  setCookie(this, cookieIds.pageNumber, this.options.pageNumber);
380
- };
381
-
382
- BootstrapTable.prototype.onPageLast = function () {
383
- _onPageLast.apply(this, Array.prototype.slice.apply(arguments));
384
- setCookie(this, cookieIds.pageNumber, this.options.pageNumber);
362
+ return false;
385
363
  };
386
364
 
387
365
  BootstrapTable.prototype.toggleColumn = function () {
@@ -408,8 +386,9 @@
408
386
  _onSearch.apply(this, target);
409
387
 
410
388
  if ($(target[0].currentTarget).parent().hasClass('search')) {
411
- setCookie(this, cookieIds.searchText, this.searchText);
389
+ setCookie(this, cookieIds.searchText, this.searchText);
412
390
  }
391
+ setCookie(this, cookieIds.pageNumber, this.options.pageNumber);
413
392
  };
414
393
 
415
394
  BootstrapTable.prototype.getCookies = function () {
@@ -0,0 +1,32 @@
1
+ /**
2
+ * When using server-side processing, the default mode of operation for
3
+ * bootstrap-table is to simply throw away any data that currently exists in the
4
+ * table and make a request to the server to get the first page of data to
5
+ * display. This is fine for an empty table, but if you already have the first
6
+ * page of data displayed in the plain HTML, it is a waste of resources. As
7
+ * such, you can use data-defer-url instead of data-url to allow you to instruct
8
+ * bootstrap-table to not make that initial request, rather it will use the data
9
+ * already on the page.
10
+ *
11
+ * @author: Ruben Suarez
12
+ * @webSite: http://rubensa.eu.org
13
+ * @version: v1.0.0
14
+ */
15
+
16
+ (function($) {
17
+ 'use strict';
18
+
19
+ $.extend($.fn.bootstrapTable.defaults, {
20
+ deferUrl : undefined
21
+ });
22
+
23
+ var BootstrapTable = $.fn.bootstrapTable.Constructor, _init = BootstrapTable.prototype.init;
24
+
25
+ BootstrapTable.prototype.init = function() {
26
+ _init.apply(this, Array.prototype.slice.apply(arguments));
27
+
28
+ if (this.options.deferUrl) {
29
+ this.options.url = this.options.deferUrl;
30
+ }
31
+ }
32
+ })(jQuery);
@@ -44,7 +44,7 @@
44
44
  _initToolbar = BootstrapTable.prototype.initToolbar;
45
45
 
46
46
  BootstrapTable.prototype.initToolbar = function () {
47
- this.showToolbar = this.options.showExport;
47
+ this.showToolbar = this.showToolbar || this.options.showExport;
48
48
 
49
49
  _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
50
50
 
@@ -93,37 +93,85 @@
93
93
  $menu.find('li').click(function () {
94
94
  var type = $(this).data('type'),
95
95
  doExport = function () {
96
+
97
+ if (!!that.options.exportFooter) {
98
+ var data = that.getData();
99
+ var $footerRow = that.$tableFooter.find("tr").first();
100
+
101
+ var footerData = { };
102
+ var footerHtml = [];
103
+
104
+ $.each($footerRow.children(), function (index, footerCell) {
105
+
106
+ var footerCellHtml = $(footerCell).children(".th-inner").first().html();
107
+ footerData[that.columns[index].field] = footerCellHtml == '&nbsp;' ? null : footerCellHtml;
108
+
109
+ // grab footer cell text into cell index-based array
110
+ footerHtml.push(footerCellHtml);
111
+ });
112
+
113
+ that.append(footerData);
114
+
115
+ var $lastTableRow = that.$body.children().last();
116
+
117
+ $.each($lastTableRow.children(), function (index, lastTableRowCell) {
118
+
119
+ $(lastTableRowCell).html(footerHtml[index]);
120
+ });
121
+ }
122
+
96
123
  that.$el.tableExport($.extend({}, that.options.exportOptions, {
97
124
  type: type,
98
125
  escape: false
99
126
  }));
127
+
128
+ if (!!that.options.exportFooter) {
129
+ that.load(data);
130
+ }
100
131
  };
101
132
 
133
+ var stateField = that.header.stateField;
134
+
102
135
  if (that.options.exportDataType === 'all' && that.options.pagination) {
103
136
  that.$el.one(that.options.sidePagination === 'server' ? 'post-body.bs.table' : 'page-change.bs.table', function () {
137
+ if (stateField) {
138
+ that.hideColumn(stateField);
139
+ }
104
140
  doExport();
105
141
  that.togglePagination();
106
142
  });
107
143
  that.togglePagination();
108
144
  } else if (that.options.exportDataType === 'selected') {
109
145
  var data = that.getData(),
110
- selectedData = that.getAllSelections();
146
+ selectedData = that.getSelections();
147
+ if (!selectedData.length) {
148
+ return;
149
+ }
111
150
 
112
- // Quick fix #2220
113
151
  if (that.options.sidePagination === 'server') {
114
- data = {total: that.options.totalRows};
115
- data[that.options.dataField] = that.getData();
116
-
117
- selectedData = {total: that.options.totalRows};
118
- selectedData[that.options.dataField] = that.getAllSelections();
152
+ var dataServer = {total: that.options.totalRows};
153
+ dataServer[that.options.dataField] = data;
154
+ data = dataServer;
155
+ var selectedDataServer = {total: selectedData.length};
156
+ selectedDataServer[that.options.dataField] = selectedData;
157
+ selectedData = selectedDataServer;
119
158
  }
120
159
 
121
160
  that.load(selectedData);
161
+ if (stateField) {
162
+ that.hideColumn(stateField);
163
+ }
122
164
  doExport();
123
165
  that.load(data);
124
166
  } else {
167
+ if (stateField) {
168
+ that.hideColumn(stateField);
169
+ }
125
170
  doExport();
126
171
  }
172
+ if (stateField) {
173
+ that.showColumn(stateField);
174
+ }
127
175
  });
128
176
  }
129
177
  }