bootstrap-table-rails 1.11.1.1 → 1.12.1

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 (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
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @author zhixin wen <wenzhixin2010@gmail.com>
3
- * version: 1.11.1
3
+ * version: 1.12.1
4
4
  * https://github.com/wenzhixin/bootstrap-table/
5
5
  */
6
6
 
@@ -10,6 +10,53 @@
10
10
  // TOOLS DEFINITION
11
11
  // ======================
12
12
 
13
+ var bootstrapVersion = 3;
14
+ try {
15
+ bootstrapVersion = parseInt($.fn.dropdown.Constructor.VERSION, 10);
16
+ } catch (e) {}
17
+ var bs = {
18
+ 3: {
19
+ buttonsClass: 'default',
20
+ iconsPrefix: 'glyphicon',
21
+ icons: {
22
+ paginationSwitchDown: 'glyphicon-collapse-down icon-chevron-down',
23
+ paginationSwitchUp: 'glyphicon-collapse-up icon-chevron-up',
24
+ refresh: 'glyphicon-refresh icon-refresh',
25
+ toggleOff: 'glyphicon-list-alt icon-list-alt',
26
+ toggleOn: 'glyphicon-list-alt icon-list-alt',
27
+ columns: 'glyphicon-th icon-th',
28
+ detailOpen: 'glyphicon-plus icon-plus',
29
+ detailClose: 'glyphicon-minus icon-minus',
30
+ fullscreen: 'glyphicon-fullscreen'
31
+ },
32
+ pullClass: 'pull',
33
+ toobarDropdowHtml: ['<ul class="dropdown-menu" role="menu">', '</ul>'],
34
+ toobarDropdowItemHtml: '<li role="menuitem"><label>%s</label></li>',
35
+ pageDropdownHtml: ['<ul class="dropdown-menu" role="menu">', '</ul>'],
36
+ pageDropdownItemHtml: '<li role="menuitem" class="%s"><a href="#">%s</a></li>'
37
+ },
38
+ 4: {
39
+ buttonsClass: 'secondary',
40
+ iconsPrefix: 'fa',
41
+ icons: {
42
+ paginationSwitchDown: 'fa-toggle-down',
43
+ paginationSwitchUp: 'fa-toggle-up',
44
+ refresh: 'fa-refresh',
45
+ toggleOff: 'fa-toggle-off',
46
+ toggleOn: 'fa-toggle-on',
47
+ columns: 'fa-th-list',
48
+ detailOpen: 'fa-plus',
49
+ detailClose: 'fa-minus',
50
+ fullscreen: 'fa-arrows-alt'
51
+ },
52
+ pullClass: 'float',
53
+ toobarDropdowHtml: ['<div class="dropdown-menu dropdown-menu-right">', '</div>'],
54
+ toobarDropdowItemHtml: '<label class="dropdown-item">%s</label>',
55
+ pageDropdownHtml: ['<div class="dropdown-menu">', '</div>'],
56
+ pageDropdownItemHtml: '<a class="dropdown-item %s" href="#">%s</a>'
57
+ }
58
+ }[bootstrapVersion];
59
+
13
60
  var cachedWidth = null;
14
61
 
15
62
  // it only does '%s', and return '' when arguments are undefined
@@ -42,19 +89,6 @@
42
89
  return result;
43
90
  };
44
91
 
45
- var getFieldIndex = function (columns, field) {
46
- var index = -1;
47
-
48
- $.each(columns, function (i, column) {
49
- if (column.field === field) {
50
- index = i;
51
- return false;
52
- }
53
- return true;
54
- });
55
- return index;
56
- };
57
-
58
92
  // http://jsfiddle.net/wenyi/47nz7ez9/3/
59
93
  var setFieldIndex = function (columns) {
60
94
  var i, j, k,
@@ -150,8 +184,17 @@
150
184
 
151
185
  var compareObjects = function (objectA, objectB, compareLength) {
152
186
  // Create arrays of property names
153
- var objectAProperties = Object.getOwnPropertyNames(objectA),
154
- objectBProperties = Object.getOwnPropertyNames(objectB),
187
+ var getOwnPropertyNames = Object.getOwnPropertyNames || function (obj) {
188
+ var arr = [];
189
+ for (var k in obj) {
190
+ if (obj.hasOwnProperty(k)) {
191
+ arr.push(k);
192
+ }
193
+ }
194
+ return arr;
195
+ };
196
+ var objectAProperties = getOwnPropertyNames(objectA),
197
+ objectBProperties = getOwnPropertyNames(objectB),
155
198
  propName = '';
156
199
 
157
200
  if (compareLength) {
@@ -286,6 +329,7 @@
286
329
  sortName: undefined,
287
330
  sortOrder: 'asc',
288
331
  sortStable: false,
332
+ rememberOrder: false,
289
333
  striped: false,
290
334
  columns: [[]],
291
335
  data: [],
@@ -329,7 +373,7 @@
329
373
  showPaginationSwitch: false,
330
374
  showRefresh: false,
331
375
  showToggle: false,
332
- buttonsAlign: 'right',
376
+ showFullscreen: false,
333
377
  smartDisplay: true,
334
378
  escape: false,
335
379
  minimumCountColumns: 1,
@@ -340,11 +384,16 @@
340
384
  detailFormatter: function (index, row) {
341
385
  return '';
342
386
  },
387
+ detailFilter: function (index, row) {
388
+ return true;
389
+ },
343
390
  trimOnSearch: true,
344
391
  clickToSelect: false,
345
392
  singleSelect: false,
346
393
  toolbar: undefined,
347
394
  toolbarAlign: 'left',
395
+ buttonsToolbar: undefined,
396
+ buttonsAlign: 'right',
348
397
  checkboxHeader: true,
349
398
  sortable: true,
350
399
  silentSort: true,
@@ -352,22 +401,18 @@
352
401
  searchTimeOut: 500,
353
402
  searchText: '',
354
403
  iconSize: undefined,
355
- buttonsClass: 'default',
356
- iconsPrefix: 'glyphicon', // glyphicon of fa (font awesome)
357
- icons: {
358
- paginationSwitchDown: 'glyphicon-collapse-down icon-chevron-down',
359
- paginationSwitchUp: 'glyphicon-collapse-up icon-chevron-up',
360
- refresh: 'glyphicon-refresh icon-refresh',
361
- toggle: 'glyphicon-list-alt icon-list-alt',
362
- columns: 'glyphicon-th icon-th',
363
- detailOpen: 'glyphicon-plus icon-plus',
364
- detailClose: 'glyphicon-minus icon-minus'
365
- },
404
+ buttonsClass: bs.buttonsClass,
405
+ iconsPrefix: bs.iconsPrefix, // glyphicon or fa (font awesome)
406
+ icons: bs.icons,
366
407
 
367
408
  customSearch: $.noop,
368
409
 
369
410
  customSort: $.noop,
370
411
 
412
+ ignoreClickToSelectOn: function (element) {
413
+ return $.inArray(element.tagName, ['A', 'BUTTON']);
414
+ },
415
+
371
416
  rowStyle: function (row, index) {
372
417
  return {};
373
418
  },
@@ -457,6 +502,9 @@
457
502
  },
458
503
  onResetView: function () {
459
504
  return false;
505
+ },
506
+ onScrollBody: function () {
507
+ return false;
460
508
  }
461
509
  };
462
510
 
@@ -490,6 +538,9 @@
490
538
  formatToggle: function () {
491
539
  return 'Toggle';
492
540
  },
541
+ formatFullscreen: function () {
542
+ return 'Fullscreen';
543
+ },
493
544
  formatColumns: function () {
494
545
  return 'Columns';
495
546
  },
@@ -527,7 +578,8 @@
527
578
  searchable: true,
528
579
  searchFormatter: true,
529
580
  cardVisible: true,
530
- escape : false
581
+ escape: false,
582
+ showSelectTitle: false
531
583
  };
532
584
 
533
585
  BootstrapTable.EVENTS = {
@@ -556,7 +608,8 @@
556
608
  'collapse-row.bs.table': 'onCollapseRow',
557
609
  'refresh-options.bs.table': 'onRefreshOptions',
558
610
  'reset-view.bs.table': 'onResetView',
559
- 'refresh.bs.table': 'onRefresh'
611
+ 'refresh.bs.table': 'onRefresh',
612
+ 'scroll-body.bs.table': 'onScrollBody'
560
613
  };
561
614
 
562
615
  BootstrapTable.prototype.init = function () {
@@ -578,7 +631,9 @@
578
631
  if (this.options.locale) {
579
632
  var parts = this.options.locale.split(/-|_/);
580
633
  parts[0].toLowerCase();
581
- if (parts[1]) parts[1].toUpperCase();
634
+ if (parts[1]) {
635
+ parts[1].toUpperCase();
636
+ }
582
637
  if ($.fn.bootstrapTable.locales[this.options.locale]) {
583
638
  // locale as requested
584
639
  $.extend(this.options, $.fn.bootstrapTable.locales[this.options.locale]);
@@ -607,10 +662,10 @@
607
662
  '</div>',
608
663
  '</div>',
609
664
  '<div class="fixed-table-footer"><table><tr></tr></table></div>',
665
+ '</div>',
610
666
  this.options.paginationVAlign === 'bottom' || this.options.paginationVAlign === 'both' ?
611
667
  '<div class="fixed-table-pagination"></div>' :
612
668
  '',
613
- '</div>',
614
669
  '</div>'
615
670
  ].join(''));
616
671
 
@@ -620,7 +675,12 @@
620
675
  this.$tableBody = this.$container.find('.fixed-table-body');
621
676
  this.$tableLoading = this.$container.find('.fixed-table-loading');
622
677
  this.$tableFooter = this.$container.find('.fixed-table-footer');
623
- this.$toolbar = this.$container.find('.fixed-table-toolbar');
678
+ // checking if custom table-toolbar exists or not
679
+ if (this.options.buttonsToolbar) {
680
+ this.$toolbar = $('body').find(this.options.buttonsToolbar);
681
+ } else {
682
+ this.$toolbar = this.$container.find('.fixed-table-toolbar');
683
+ }
624
684
  this.$pagination = this.$container.find('.fixed-table-pagination');
625
685
 
626
686
  this.$tableBody.append(this.$el);
@@ -667,6 +727,7 @@
667
727
  }
668
728
  this.options.columns = $.extend(true, [], columns, this.options.columns);
669
729
  this.columns = [];
730
+ this.fieldsColumnsIndex = [];
670
731
 
671
732
  setFieldIndex(this.options.columns);
672
733
  $.each(this.options.columns, function (i, columns) {
@@ -675,6 +736,7 @@
675
736
 
676
737
  if (typeof column.fieldIndex !== 'undefined') {
677
738
  that.columns[column.fieldIndex] = column;
739
+ that.fieldsColumnsIndex[column.field] = column.fieldIndex;
678
740
  }
679
741
 
680
742
  that.options.columns[i][j] = column;
@@ -699,9 +761,11 @@
699
761
  var $this = $(this),
700
762
  cspan = +$this.attr('colspan') || 1,
701
763
  rspan = +$this.attr('rowspan') || 1,
702
- tx, ty;
764
+ tx,
765
+ ty;
703
766
 
704
- for (; m[y] && m[y][x]; x++); //skip already occupied cells in current row
767
+ // skip already occupied cells in current row
768
+ for (; m[y] && m[y][x]; x++);
705
769
 
706
770
  for (tx = x; tx < x + cspan; tx++) { //mark matrix elements occupied by current cell with true
707
771
  for (ty = y; ty < y + rspan; ty++) {
@@ -779,7 +843,8 @@
779
843
  align = sprintf('text-align: %s; ', column.align);
780
844
  style = sprintf('vertical-align: %s; ', column.valign);
781
845
  style += sprintf('width: %s; ', (column.checkbox || column.radio) && !width ?
782
- '36px' : (width ? width + unitWidth : undefined));
846
+ (!column.showSelectTitle ? '36px' : undefined) :
847
+ (width ? width + unitWidth : undefined));
783
848
 
784
849
  if (typeof column.fieldIndex !== 'undefined') {
785
850
  that.header.fields[column.fieldIndex] = column.field;
@@ -811,6 +876,7 @@
811
876
  sprintf(' rowspan="%s"', column.rowspan),
812
877
  sprintf(' colspan="%s"', column.colspan),
813
878
  sprintf(' data-field="%s"', column.field),
879
+ j === 0 && column.fieldIndex ? ' data-not-first-th' : '',
814
880
  '>');
815
881
 
816
882
  html.push(sprintf('<div class="th-inner %s">', that.options.sortable && column.sortable ?
@@ -818,7 +884,9 @@
818
884
 
819
885
  text = that.options.escape ? escapeHTML(column.title) : column.title;
820
886
 
887
+ var title = text;
821
888
  if (column.checkbox) {
889
+ text = '';
822
890
  if (!that.options.singleSelect && that.options.checkboxHeader) {
823
891
  text = '<input name="btSelectAll" type="checkbox" />';
824
892
  }
@@ -829,6 +897,9 @@
829
897
  that.header.stateField = column.field;
830
898
  that.options.singleSelect = true;
831
899
  }
900
+ if (!text && column.showSelectTitle) {
901
+ text += title;
902
+ }
832
903
 
833
904
  html.push(text);
834
905
  html.push('</div>');
@@ -844,14 +915,15 @@
844
915
  $(this).data(visibleColumns[$(this).data('field')]);
845
916
  });
846
917
  this.$container.off('click', '.th-inner').on('click', '.th-inner', function (event) {
847
- var target = $(this);
918
+ var $this = $(this);
848
919
 
849
- if (that.options.detailView) {
850
- if (target.closest('.bootstrap-table')[0] !== that.$container[0])
920
+ if (that.options.detailView && !$this.parent().hasClass('bs-checkbox')) {
921
+ if ($this.closest('.bootstrap-table')[0] !== that.$container[0]) {
851
922
  return false;
923
+ }
852
924
  }
853
925
 
854
- if (that.options.sortable && target.parent().data().sortable) {
926
+ if (that.options.sortable && $this.parent().data().sortable) {
855
927
  that.onSort(event);
856
928
  }
857
929
  });
@@ -900,23 +972,16 @@
900
972
  * @param type: append / prepend
901
973
  */
902
974
  BootstrapTable.prototype.initData = function (data, type) {
903
- if (type === 'append') {
904
- this.data = this.data.concat(data);
905
- } else if (type === 'prepend') {
906
- this.data = [].concat(data).concat(this.data);
907
- } else {
908
- this.data = data || this.options.data;
909
- }
910
-
911
- // Fix #839 Records deleted when adding new row on filtered table
912
975
  if (type === 'append') {
913
976
  this.options.data = this.options.data.concat(data);
914
977
  } else if (type === 'prepend') {
915
978
  this.options.data = [].concat(data).concat(this.options.data);
916
979
  } else {
917
- this.options.data = this.data;
980
+ this.options.data = data || this.options.data;
918
981
  }
919
982
 
983
+ this.data = this.options.data;
984
+
920
985
  if (this.options.sidePagination === 'server') {
921
986
  return;
922
987
  }
@@ -938,7 +1003,7 @@
938
1003
  if (index !== -1) {
939
1004
  if (this.options.sortStable) {
940
1005
  $.each(this.data, function (i, row) {
941
- if (!row.hasOwnProperty('_position')) row._position = i;
1006
+ row._position = i;
942
1007
  });
943
1008
  }
944
1009
 
@@ -948,9 +1013,12 @@
948
1013
  }
949
1014
  var aa = getItemField(a, name, that.options.escape),
950
1015
  bb = getItemField(b, name, that.options.escape),
951
- value = calculateObjectValue(that.header, that.header.sorters[index], [aa, bb]);
1016
+ value = calculateObjectValue(that.header, that.header.sorters[index], [aa, bb, a, b]);
952
1017
 
953
1018
  if (value !== undefined) {
1019
+ if (that.options.sortStable && value === 0) {
1020
+ return a._position - b._position;
1021
+ }
954
1022
  return order * value;
955
1023
  }
956
1024
 
@@ -965,6 +1033,7 @@
965
1033
  if (that.options.sortStable && aa === bb) {
966
1034
  aa = a._position;
967
1035
  bb = b._position;
1036
+ return a._position - b._position;
968
1037
  }
969
1038
 
970
1039
  // IF both values are numeric, do a numeric comparison
@@ -1017,7 +1086,11 @@
1017
1086
  this.options.sortOrder = this.options.sortOrder === 'asc' ? 'desc' : 'asc';
1018
1087
  } else {
1019
1088
  this.options.sortName = $this.data('field');
1020
- this.options.sortOrder = $this.data('order') === 'asc' ? 'desc' : 'asc';
1089
+ if (this.options.rememberOrder) {
1090
+ this.options.sortOrder = $this.data('order') === 'asc' ? 'desc' : 'asc';
1091
+ } else {
1092
+ this.options.sortOrder = this.columns[this.fieldsColumnsIndex[$this.data('field')]].order;
1093
+ }
1021
1094
  }
1022
1095
  this.trigger('sort', this.options.sortName, this.options.sortOrder);
1023
1096
 
@@ -1049,14 +1122,14 @@
1049
1122
  this.$toolbar.html('');
1050
1123
 
1051
1124
  if (typeof this.options.toolbar === 'string' || typeof this.options.toolbar === 'object') {
1052
- $(sprintf('<div class="bs-bars pull-%s"></div>', this.options.toolbarAlign))
1125
+ $(sprintf('<div class="bs-bars %s-%s"></div>', bs.pullClass, this.options.toolbarAlign))
1053
1126
  .appendTo(this.$toolbar)
1054
1127
  .append($(this.options.toolbar));
1055
1128
  }
1056
1129
 
1057
1130
  // showColumns, showToggle, showRefresh
1058
- html = [sprintf('<div class="columns columns-%s btn-group pull-%s">',
1059
- this.options.buttonsAlign, this.options.buttonsAlign)];
1131
+ html = [sprintf('<div class="columns columns-%s btn-group %s-%s">',
1132
+ this.options.buttonsAlign, bs.pullClass, this.options.buttonsAlign)];
1060
1133
 
1061
1134
  if (typeof this.options.icons === 'string') {
1062
1135
  this.options.icons = calculateObjectValue(null, this.options.icons);
@@ -1072,6 +1145,11 @@
1072
1145
  '</button>');
1073
1146
  }
1074
1147
 
1148
+ if (this.options.showFullscreen) {
1149
+ this.$toolbar.find('button[name="fullscreen"]')
1150
+ .off('click').on('click', $.proxy(this.toggleFullscreen, this));
1151
+ }
1152
+
1075
1153
  if (this.options.showRefresh) {
1076
1154
  html.push(sprintf('<button class="btn' +
1077
1155
  sprintf(' btn-%s', this.options.buttonsClass) +
@@ -1092,6 +1170,16 @@
1092
1170
  '</button>');
1093
1171
  }
1094
1172
 
1173
+ if (this.options.showFullscreen) {
1174
+ html.push(sprintf('<button class="btn' +
1175
+ sprintf(' btn-%s', this.options.buttonsClass) +
1176
+ sprintf(' btn-%s', this.options.iconSize) +
1177
+ '" type="button" name="fullscreen" aria-label="fullscreen" title="%s">',
1178
+ this.options.formatFullscreen()),
1179
+ sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.fullscreen),
1180
+ '</button>');
1181
+ }
1182
+
1095
1183
  if (this.options.showColumns) {
1096
1184
  html.push(sprintf('<div class="keep-open btn-group" title="%s">',
1097
1185
  this.options.formatColumns()),
@@ -1102,7 +1190,7 @@
1102
1190
  sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.columns),
1103
1191
  ' <span class="caret"></span>',
1104
1192
  '</button>',
1105
- '<ul class="dropdown-menu" role="menu">');
1193
+ bs.toobarDropdowHtml[0]);
1106
1194
 
1107
1195
  $.each(this.columns, function (i, column) {
1108
1196
  if (column.radio || column.checkbox) {
@@ -1116,14 +1204,13 @@
1116
1204
  var checked = column.visible ? ' checked="checked"' : '';
1117
1205
 
1118
1206
  if (column.switchable) {
1119
- html.push(sprintf('<li role="menuitem">' +
1120
- '<label><input type="checkbox" data-field="%s" value="%s"%s> %s</label>' +
1121
- '</li>', column.field, i, checked, column.title));
1207
+ html.push(sprintf(bs.toobarDropdowItemHtml,
1208
+ sprintf('<input type="checkbox" data-field="%s" value="%s"%s> %s',
1209
+ column.field, i, checked, column.title)));
1122
1210
  switchableCount++;
1123
1211
  }
1124
1212
  });
1125
- html.push('</ul>',
1126
- '</div>');
1213
+ html.push(bs.toobarDropdowHtml[1], '</div>');
1127
1214
  }
1128
1215
 
1129
1216
  html.push('</div>');
@@ -1171,7 +1258,7 @@
1171
1258
  if (this.options.search) {
1172
1259
  html = [];
1173
1260
  html.push(
1174
- '<div class="pull-' + this.options.searchAlign + ' search">',
1261
+ sprintf('<div class="%s-%s search">', bs.pullClass, this.options.searchAlign),
1175
1262
  sprintf('<input class="form-control' +
1176
1263
  sprintf(' input-%s', this.options.iconSize) +
1177
1264
  '" type="text" placeholder="%s">',
@@ -1222,7 +1309,13 @@
1222
1309
 
1223
1310
  this.options.pageNumber = 1;
1224
1311
  this.initSearch();
1225
- this.updatePagination();
1312
+ if (event.firedByInitSearchText) {
1313
+ if (this.options.sidePagination === 'client') {
1314
+ this.updatePagination();
1315
+ }
1316
+ } else {
1317
+ this.updatePagination();
1318
+ }
1226
1319
  this.trigger('search', text);
1227
1320
  };
1228
1321
 
@@ -1231,7 +1324,7 @@
1231
1324
 
1232
1325
  if (this.options.sidePagination !== 'server') {
1233
1326
  if (this.options.customSearch !== $.noop) {
1234
- this.options.customSearch.apply(this, [this.searchText]);
1327
+ window[this.options.customSearch].apply(this, [this.searchText]);
1235
1328
  return;
1236
1329
  }
1237
1330
 
@@ -1258,14 +1351,16 @@
1258
1351
  }
1259
1352
 
1260
1353
  var key = $.isNumeric(that.header.fields[j]) ? parseInt(that.header.fields[j], 10) : that.header.fields[j];
1261
- var column = that.columns[getFieldIndex(that.columns, key)];
1354
+ var column = that.columns[that.fieldsColumnsIndex[key]];
1262
1355
  var value;
1263
1356
 
1264
1357
  if (typeof key === 'string') {
1265
1358
  value = item;
1266
1359
  var props = key.split('.');
1267
1360
  for (var prop_index = 0; prop_index < props.length; prop_index++) {
1268
- value = value[props[prop_index]];
1361
+ if (value[props[prop_index]] != null) {
1362
+ value = value[props[prop_index]];
1363
+ }
1269
1364
  }
1270
1365
 
1271
1366
  // Fix #142: respect searchForamtter boolean
@@ -1307,8 +1402,8 @@
1307
1402
  $allSelected = false,
1308
1403
  i, from, to,
1309
1404
  $pageList,
1310
- $first, $pre,
1311
- $next, $last,
1405
+ $pre,
1406
+ $next,
1312
1407
  $number,
1313
1408
  data = this.getData(),
1314
1409
  pageList = this.options.pageList;
@@ -1348,7 +1443,7 @@
1348
1443
  }
1349
1444
 
1350
1445
  html.push(
1351
- '<div class="pull-' + this.options.paginationDetailHAlign + ' pagination-detail">',
1446
+ sprintf('<div class="%s-%s pagination-detail">', bs.pullClass, this.options.paginationDetailHAlign),
1352
1447
  '<span class="pagination-info">',
1353
1448
  this.options.onlyInfoPagination ? this.options.formatDetailPagination(this.options.totalRows) :
1354
1449
  this.options.formatShowingRows(this.pageFrom, this.pageTo, this.options.totalRows),
@@ -1370,7 +1465,7 @@
1370
1465
  '</span>',
1371
1466
  ' <span class="caret"></span>',
1372
1467
  '</button>',
1373
- '<ul class="dropdown-menu" role="menu">'
1468
+ bs.pageDropdownHtml[0]
1374
1469
  ];
1375
1470
 
1376
1471
  if (typeof this.options.pageList === 'string') {
@@ -1379,7 +1474,7 @@
1379
1474
 
1380
1475
  pageList = [];
1381
1476
  $.each(list, function (i, value) {
1382
- pageList.push(value.toUpperCase() === that.options.formatAllRows().toUpperCase() ?
1477
+ pageList.push((value.toUpperCase() === that.options.formatAllRows().toUpperCase() || value.toUpperCase() === "UNLIMITED") ?
1383
1478
  that.options.formatAllRows() : +value);
1384
1479
  });
1385
1480
  }
@@ -1388,22 +1483,23 @@
1388
1483
  if (!that.options.smartDisplay || i === 0 || pageList[i - 1] < that.options.totalRows) {
1389
1484
  var active;
1390
1485
  if ($allSelected) {
1391
- active = page === that.options.formatAllRows() ? ' class="active"' : '';
1486
+ active = page === that.options.formatAllRows() ? 'active' : '';
1392
1487
  } else {
1393
- active = page === that.options.pageSize ? ' class="active"' : '';
1488
+ active = page === that.options.pageSize ? 'active' : '';
1394
1489
  }
1395
- pageNumber.push(sprintf('<li role="menuitem"%s><a href="#">%s</a></li>', active, page));
1490
+ pageNumber.push(sprintf(bs.pageDropdownItemHtml, active, page));
1396
1491
  }
1397
1492
  });
1398
- pageNumber.push('</ul></span>');
1493
+ pageNumber.push(bs.pageDropdownHtml[1] + '</span>');
1399
1494
 
1400
1495
  html.push(this.options.formatRecordsPerPage(pageNumber.join('')));
1401
1496
  html.push('</span>');
1402
1497
 
1403
1498
  html.push('</div>',
1404
- '<div class="pull-' + this.options.paginationHAlign + ' pagination">',
1499
+ sprintf('<div class="%s-%s pagination">', bs.pullClass, this.options.paginationHAlign),
1405
1500
  '<ul class="pagination' + sprintf(' pagination-%s', this.options.iconSize) + '">',
1406
- '<li class="page-pre"><a href="#">' + this.options.paginationPreText + '</a></li>');
1501
+ sprintf('<li class="page-item page-pre"><a class="page-link" href="#">%s</a></li>',
1502
+ this.options.paginationPreText));
1407
1503
 
1408
1504
  if (this.totalPages < 5) {
1409
1505
  from = 1;
@@ -1423,8 +1519,10 @@
1423
1519
 
1424
1520
  if (this.totalPages >= 6) {
1425
1521
  if (this.options.pageNumber >= 3) {
1426
- html.push('<li class="page-first' + (1 === this.options.pageNumber ? ' active' : '') + '">',
1427
- '<a href="#">', 1, '</a>',
1522
+ html.push(
1523
+ sprintf('<li class="page-item page-first%s">',
1524
+ 1 === this.options.pageNumber ? ' active' : ''),
1525
+ '<a class="page-link" href="#">', 1, '</a>',
1428
1526
  '</li>');
1429
1527
 
1430
1528
  from++;
@@ -1434,8 +1532,8 @@
1434
1532
  if (this.options.pageNumber == 4 || this.totalPages == 6 || this.totalPages == 7) {
1435
1533
  from--;
1436
1534
  } else {
1437
- html.push('<li class="page-first-separator disabled">',
1438
- '<a href="#">...</a>',
1535
+ html.push('<li class="page-item page-first-separator disabled">',
1536
+ '<a class="page-link" href="#">...</a>',
1439
1537
  '</li>');
1440
1538
  }
1441
1539
 
@@ -1460,29 +1558,32 @@
1460
1558
  }
1461
1559
 
1462
1560
  for (i = from; i <= to; i++) {
1463
- html.push('<li class="page-number' + (i === this.options.pageNumber ? ' active' : '') + '">',
1464
- '<a href="#">', i, '</a>',
1561
+ html.push(sprintf('<li class="page-item%s">',
1562
+ i === this.options.pageNumber ? ' active' : ''),
1563
+ '<a class="page-link" href="#">', i, '</a>',
1465
1564
  '</li>');
1466
1565
  }
1467
1566
 
1468
1567
  if (this.totalPages >= 8) {
1469
1568
  if (this.options.pageNumber <= (this.totalPages - 4)) {
1470
- html.push('<li class="page-last-separator disabled">',
1471
- '<a href="#">...</a>',
1569
+ html.push('<li class="page-item page-last-separator disabled">',
1570
+ '<a class="page-link" href="#">...</a>',
1472
1571
  '</li>');
1473
1572
  }
1474
1573
  }
1475
1574
 
1476
1575
  if (this.totalPages >= 6) {
1477
1576
  if (this.options.pageNumber <= (this.totalPages - 3)) {
1478
- html.push('<li class="page-last' + (this.totalPages === this.options.pageNumber ? ' active' : '') + '">',
1479
- '<a href="#">', this.totalPages, '</a>',
1577
+ html.push(sprintf('<li class="page-item page-last%s">',
1578
+ this.totalPages === this.options.pageNumber ? ' active' : ''),
1579
+ '<a class="page-link" href="#">', this.totalPages, '</a>',
1480
1580
  '</li>');
1481
1581
  }
1482
1582
  }
1483
1583
 
1484
1584
  html.push(
1485
- '<li class="page-next"><a href="#">' + this.options.paginationNextText + '</a></li>',
1585
+ sprintf('<li class="page-item page-next"><a class="page-link" href="#">%s</a></li>',
1586
+ this.options.paginationNextText),
1486
1587
  '</ul>',
1487
1588
  '</div>');
1488
1589
  }
@@ -1490,11 +1591,9 @@
1490
1591
 
1491
1592
  if (!this.options.onlyInfoPagination) {
1492
1593
  $pageList = this.$pagination.find('.page-list a');
1493
- $first = this.$pagination.find('.page-first');
1494
1594
  $pre = this.$pagination.find('.page-pre');
1495
1595
  $next = this.$pagination.find('.page-next');
1496
- $last = this.$pagination.find('.page-last');
1497
- $number = this.$pagination.find('.page-number');
1596
+ $number = this.$pagination.find('.page-item').not('.page-next, .page-pre');
1498
1597
 
1499
1598
  if (this.options.smartDisplay) {
1500
1599
  if (this.totalPages <= 1) {
@@ -1520,11 +1619,10 @@
1520
1619
  if ($allSelected) {
1521
1620
  this.options.pageSize = this.options.formatAllRows();
1522
1621
  }
1622
+ // removed the events for last and first, onPageNumber executeds the same logic
1523
1623
  $pageList.off('click').on('click', $.proxy(this.onPageListChange, this));
1524
- $first.off('click').on('click', $.proxy(this.onPageFirst, this));
1525
1624
  $pre.off('click').on('click', $.proxy(this.onPagePre, this));
1526
1625
  $next.off('click').on('click', $.proxy(this.onPageNext, this));
1527
- $last.off('click').on('click', $.proxy(this.onPageLast, this));
1528
1626
  $number.off('click').on('click', $.proxy(this.onPageNumber, this));
1529
1627
  }
1530
1628
  };
@@ -1550,6 +1648,7 @@
1550
1648
  };
1551
1649
 
1552
1650
  BootstrapTable.prototype.onPageListChange = function (event) {
1651
+ event.preventDefault();
1553
1652
  var $this = $(event.currentTarget);
1554
1653
 
1555
1654
  $this.parent().addClass('active').siblings().removeClass('active');
@@ -1561,13 +1660,8 @@
1561
1660
  return false;
1562
1661
  };
1563
1662
 
1564
- BootstrapTable.prototype.onPageFirst = function (event) {
1565
- this.options.pageNumber = 1;
1566
- this.updatePagination(event);
1567
- return false;
1568
- };
1569
-
1570
1663
  BootstrapTable.prototype.onPagePre = function (event) {
1664
+ event.preventDefault();
1571
1665
  if ((this.options.pageNumber - 1) === 0) {
1572
1666
  this.options.pageNumber = this.options.totalPages;
1573
1667
  } else {
@@ -1578,6 +1672,7 @@
1578
1672
  };
1579
1673
 
1580
1674
  BootstrapTable.prototype.onPageNext = function (event) {
1675
+ event.preventDefault();
1581
1676
  if ((this.options.pageNumber + 1) > this.options.totalPages) {
1582
1677
  this.options.pageNumber = 1;
1583
1678
  } else {
@@ -1587,13 +1682,8 @@
1587
1682
  return false;
1588
1683
  };
1589
1684
 
1590
- BootstrapTable.prototype.onPageLast = function (event) {
1591
- this.options.pageNumber = this.totalPages;
1592
- this.updatePagination(event);
1593
- return false;
1594
- };
1595
-
1596
1685
  BootstrapTable.prototype.onPageNumber = function (event) {
1686
+ event.preventDefault();
1597
1687
  if (this.options.pageNumber === +$(event.currentTarget).text()) {
1598
1688
  return;
1599
1689
  }
@@ -1658,11 +1748,15 @@
1658
1748
  }
1659
1749
 
1660
1750
  if (!this.options.cardView && this.options.detailView) {
1661
- html.push('<td>',
1662
- '<a class="detail-icon" href="#">',
1751
+ html.push('<td>');
1752
+
1753
+ if (calculateObjectValue(null, this.options.detailFilter, [i, item])) {
1754
+ html.push('<a class="detail-icon" href="#">',
1663
1755
  sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.detailOpen),
1664
- '</a>',
1665
- '</td>');
1756
+ '</a>');
1757
+ }
1758
+
1759
+ html.push('</td>');
1666
1760
  }
1667
1761
 
1668
1762
  $.each(this.header.fields, function(j, field) {
@@ -1680,7 +1774,9 @@
1680
1774
  column = that.columns[j];
1681
1775
 
1682
1776
  if (that.fromHtml && typeof value_ === 'undefined') {
1683
- return;
1777
+ if((!column.checkbox) && (!column.radio)) {
1778
+ return;
1779
+ }
1684
1780
  }
1685
1781
 
1686
1782
  if (!column.visible) {
@@ -1727,7 +1823,7 @@
1727
1823
  }
1728
1824
 
1729
1825
  value = calculateObjectValue(column,
1730
- that.header.formatters[j], [value_, item, i], value_);
1826
+ that.header.formatters[j], [value_, item, i, field], value_);
1731
1827
 
1732
1828
  if (item['_' + field + '_data'] && !$.isEmptyObject(item['_' + field + '_data'])) {
1733
1829
  $.each(item['_' + field + '_data'], function(k, v) {
@@ -1759,7 +1855,7 @@
1759
1855
  that.options.cardView ? '</div>' : '</td>'
1760
1856
  ].join('');
1761
1857
 
1762
- item[that.header.stateField] = value === true || (value && value.checked);
1858
+ item[that.header.stateField] = value === true || (!!value_ || value && value.checked);
1763
1859
  } else {
1764
1860
  value = typeof value === 'undefined' || value === null ?
1765
1861
  that.options.undefinedText : value;
@@ -1847,7 +1943,7 @@
1847
1943
  index = $td[0].cellIndex,
1848
1944
  fields = that.getVisibleFields(),
1849
1945
  field = fields[that.options.detailView && !that.options.cardView ? index - 1 : index],
1850
- column = that.columns[getFieldIndex(that.columns, field)],
1946
+ column = that.columns[that.fieldsColumnsIndex[field]],
1851
1947
  value = getItemField(item, field, that.options.escape);
1852
1948
 
1853
1949
  if ($td.find('.detail-icon').length) {
@@ -1858,7 +1954,7 @@
1858
1954
  that.trigger(e.type === 'click' ? 'click-row' : 'dbl-click-row', item, $tr, field);
1859
1955
 
1860
1956
  // if click to select - then trigger the checkbox/radio click
1861
- if (e.type === 'click' && that.options.clickToSelect && column.clickToSelect) {
1957
+ if (e.type === 'click' && that.options.clickToSelect && column.clickToSelect && that.options.ignoreClickToSelectOn(e.target)) {
1862
1958
  var $selectItem = $tr.find(sprintf('[name="%s"]', that.options.selectItemName));
1863
1959
  if ($selectItem.length) {
1864
1960
  $selectItem[0].click(); // #144: .trigger('click') bug
@@ -1866,7 +1962,9 @@
1866
1962
  }
1867
1963
  });
1868
1964
 
1869
- this.$body.find('> tr[data-index] > td > .detail-icon').off('click').on('click', function () {
1965
+ this.$body.find('> tr[data-index] > td > .detail-icon').off('click').on('click', function (e) {
1966
+ e.preventDefault();
1967
+
1870
1968
  var $this = $(this),
1871
1969
  $tr = $this.parent().parent(),
1872
1970
  index = $tr.data('index'),
@@ -1875,14 +1973,14 @@
1875
1973
  // remove and update
1876
1974
  if ($tr.next().is('tr.detail-view')) {
1877
1975
  $this.find('i').attr('class', sprintf('%s %s', that.options.iconsPrefix, that.options.icons.detailOpen));
1878
- that.trigger('collapse-row', index, row);
1976
+ that.trigger('collapse-row', index, row, $tr.next());
1879
1977
  $tr.next().remove();
1880
1978
  } else {
1881
1979
  $this.find('i').attr('class', sprintf('%s %s', that.options.iconsPrefix, that.options.icons.detailClose));
1882
1980
  $tr.after(sprintf('<tr class="detail-view"><td colspan="%s"></td></tr>', $tr.find('td').length));
1883
1981
  var $element = $tr.next().find('td');
1884
1982
  var content = calculateObjectValue(that.options, that.options.detailFormatter, [index, row, $element], '');
1885
- if($element.length === 1) {
1983
+ if ($element.length === 1) {
1886
1984
  $element.append(content);
1887
1985
  }
1888
1986
  that.trigger('expand-row', index, row, $element);
@@ -1899,7 +1997,7 @@
1899
1997
  checked = $this.prop('checked'),
1900
1998
  row = that.data[$this.data('index')];
1901
1999
 
1902
- if (that.options.maintainSelected && $(this).is(':radio')) {
2000
+ if ($(this).is(':radio') || that.options.singleSelect) {
1903
2001
  $.each(that.options.data, function (i, row) {
1904
2002
  row[that.header.stateField] = false;
1905
2003
  });
@@ -1930,6 +2028,10 @@
1930
2028
  var field = that.header.fields[i],
1931
2029
  fieldIndex = $.inArray(field, that.getVisibleFields());
1932
2030
 
2031
+ if (fieldIndex === -1) {
2032
+ return;
2033
+ }
2034
+
1933
2035
  if (that.options.detailView && !that.options.cardView) {
1934
2036
  fieldIndex += 1;
1935
2037
  }
@@ -1963,6 +2065,7 @@
1963
2065
  BootstrapTable.prototype.initServer = function (silent, query, url) {
1964
2066
  var that = this,
1965
2067
  data = {},
2068
+ index = $.inArray(this.options.sortName, this.header.fields),
1966
2069
  params = {
1967
2070
  searchText: this.searchText,
1968
2071
  sortName: this.options.sortName,
@@ -1970,7 +2073,11 @@
1970
2073
  },
1971
2074
  request;
1972
2075
 
1973
- if (this.options.pagination) {
2076
+ if (this.header.sortNames[index]) {
2077
+ params.sortName = this.header.sortNames[index];
2078
+ }
2079
+
2080
+ if (this.options.pagination && this.options.sidePagination === 'server') {
1974
2081
  params.pageSize = this.options.pageSize === this.options.formatAllRows() ?
1975
2082
  this.options.totalRows : this.options.pageSize;
1976
2083
  params.pageNumber = this.options.pageNumber;
@@ -1987,11 +2094,14 @@
1987
2094
  order: params.sortOrder
1988
2095
  };
1989
2096
 
1990
- if (this.options.pagination) {
2097
+ if (this.options.pagination && this.options.sidePagination === 'server') {
1991
2098
  params.offset = this.options.pageSize === this.options.formatAllRows() ?
1992
2099
  0 : this.options.pageSize * (this.options.pageNumber - 1);
1993
2100
  params.limit = this.options.pageSize === this.options.formatAllRows() ?
1994
2101
  this.options.totalRows : this.options.pageSize;
2102
+ if (params.limit === 0) {
2103
+ delete params.limit;
2104
+ }
1995
2105
  }
1996
2106
  }
1997
2107
 
@@ -2027,6 +2137,13 @@
2027
2137
  if (!silent) that.$tableLoading.hide();
2028
2138
  },
2029
2139
  error: function (res) {
2140
+ var data = [];
2141
+ if (that.options.sidePagination === 'server') {
2142
+ data = {};
2143
+ data[that.options.totalField] = 0;
2144
+ data[that.options.dataField] = [];
2145
+ }
2146
+ that.load(data);
2030
2147
  that.trigger('load-error', res.status, res);
2031
2148
  if (!silent) that.$tableLoading.hide();
2032
2149
  }
@@ -2044,10 +2161,11 @@
2044
2161
 
2045
2162
  BootstrapTable.prototype.initSearchText = function () {
2046
2163
  if (this.options.search) {
2164
+ this.searchText = '';
2047
2165
  if (this.options.searchText !== '') {
2048
2166
  var $search = this.$toolbar.find('.search input');
2049
2167
  $search.val(this.options.searchText);
2050
- this.onSearch({currentTarget: $search});
2168
+ this.onSearch({currentTarget: $search, firedByInitSearchText: true});
2051
2169
  }
2052
2170
  }
2053
2171
  };
@@ -2152,7 +2270,6 @@
2152
2270
  .html('').attr('class', this.$el.attr('class'))
2153
2271
  .append(this.$header_);
2154
2272
 
2155
-
2156
2273
  focusedTemp = $('.focus-temp:visible:eq(0)');
2157
2274
  if (focusedTemp.length > 0) {
2158
2275
  focusedTemp.focus();
@@ -2178,23 +2295,21 @@
2178
2295
  index = i - 1;
2179
2296
  }
2180
2297
 
2298
+ if (index === -1) {
2299
+ return;
2300
+ }
2301
+
2181
2302
  var $th = that.$header_.find(sprintf('th[data-field="%s"]', visibleFields[index]));
2182
2303
  if ($th.length > 1) {
2183
2304
  $th = $($ths[$this[0].cellIndex]);
2184
2305
  }
2185
2306
 
2186
- $th.find('.fht-cell').width($this.innerWidth());
2307
+ var zoomWidth = $th.width() - $th.find('.fht-cell').width();
2308
+ $th.find('.fht-cell').width($this.innerWidth() - zoomWidth);
2187
2309
  });
2188
- // horizontal scroll event
2189
- // TODO: it's probably better improving the layout than binding to scroll event
2190
- this.$tableBody.off('scroll').on('scroll', function () {
2191
- that.$tableHeader.scrollLeft($(this).scrollLeft());
2192
2310
 
2193
- if (that.options.showFooter && !that.options.cardView) {
2194
- that.$tableFooter.scrollLeft($(this).scrollLeft());
2195
- }
2196
- });
2197
- that.trigger('post-header');
2311
+ this.horizontalScroll();
2312
+ this.trigger('post-header');
2198
2313
  };
2199
2314
 
2200
2315
  BootstrapTable.prototype.resetFooter = function () {
@@ -2282,6 +2397,25 @@
2282
2397
 
2283
2398
  $footerTd.eq(i).find('.fht-cell').width($this.innerWidth());
2284
2399
  });
2400
+
2401
+ this.horizontalScroll();
2402
+ };
2403
+
2404
+ BootstrapTable.prototype.horizontalScroll = function () {
2405
+ var that = this;
2406
+ // horizontal scroll event
2407
+ // TODO: it's probably better improving the layout than binding to scroll event
2408
+
2409
+ that.trigger('scroll-body');
2410
+ this.$tableBody.off('scroll').on('scroll', function () {
2411
+ if (that.options.showHeader && that.options.height) {
2412
+ that.$tableHeader.scrollLeft($(this).scrollLeft());
2413
+ }
2414
+
2415
+ if (that.options.showFooter && !that.options.cardView) {
2416
+ that.$tableFooter.scrollLeft($(this).scrollLeft());
2417
+ }
2418
+ });
2285
2419
  };
2286
2420
 
2287
2421
  BootstrapTable.prototype.toggleColumn = function (index, checked, needUpdate) {
@@ -2312,7 +2446,7 @@
2312
2446
  visibleFields = [];
2313
2447
 
2314
2448
  $.each(this.header.fields, function (j, field) {
2315
- var column = that.columns[getFieldIndex(that.columns, field)];
2449
+ var column = that.columns[that.fieldsColumnsIndex[field]];
2316
2450
 
2317
2451
  if (!column.visible) {
2318
2452
  return;
@@ -2374,16 +2508,23 @@
2374
2508
  };
2375
2509
 
2376
2510
  BootstrapTable.prototype.getData = function (useCurrentPage) {
2377
- return (this.searchText || !$.isEmptyObject(this.filterColumns) || !$.isEmptyObject(this.filterColumnsPartial)) ?
2378
- (useCurrentPage ? this.data.slice(this.pageFrom - 1, this.pageTo) : this.data) :
2379
- (useCurrentPage ? this.options.data.slice(this.pageFrom - 1, this.pageTo) : this.options.data);
2511
+ var data = this.options.data;
2512
+ if (this.searchText || this.options.sortName || !$.isEmptyObject(this.filterColumns) || !$.isEmptyObject(this.filterColumnsPartial)) {
2513
+ data = this.data;
2514
+ }
2515
+
2516
+ if (useCurrentPage) {
2517
+ return data.slice(this.pageFrom - 1, this.pageTo);
2518
+ }
2519
+
2520
+ return data;
2380
2521
  };
2381
2522
 
2382
2523
  BootstrapTable.prototype.load = function (data) {
2383
2524
  var fixedScroll = false;
2384
2525
 
2385
2526
  // #431: support pagination
2386
- if (this.options.sidePagination === 'server') {
2527
+ if (this.options.pagination && this.options.sidePagination === 'server') {
2387
2528
  this.options.totalRows = data[this.options.totalField];
2388
2529
  fixedScroll = data.fixedScroll;
2389
2530
  data = data[this.options.dataField];
@@ -2533,11 +2674,30 @@
2533
2674
  this.initBody(true);
2534
2675
  };
2535
2676
 
2677
+ BootstrapTable.prototype.refreshColumnTitle = function (params) {
2678
+ if (!params.hasOwnProperty('field') || !params.hasOwnProperty('title')) {
2679
+ return;
2680
+ }
2681
+
2682
+ this.columns[this.fieldsColumnsIndex[params.field]].title =
2683
+ this.options.escape ? escapeHTML(params.title) : params.title;
2684
+
2685
+ if (this.columns[this.fieldsColumnsIndex[params.field]].visible) {
2686
+ var header = this.options.height !== undefined ? this.$tableHeader : this.$header;
2687
+ header.find('th[data-field]').each(function (i) {
2688
+ if ($(this).data('field') === params.field) {
2689
+ $($(this).find(".th-inner")[0]).text(params.title);
2690
+ return false;
2691
+ }
2692
+ });
2693
+ }
2694
+ };
2695
+
2536
2696
  BootstrapTable.prototype.insertRow = function (params) {
2537
2697
  if (!params.hasOwnProperty('index') || !params.hasOwnProperty('row')) {
2538
2698
  return;
2539
2699
  }
2540
- this.data.splice(params.index, 0, params.row);
2700
+ this.options.data.splice(params.index, 0, params.row);
2541
2701
  this.initSearch();
2542
2702
  this.initPagination();
2543
2703
  this.initSort();
@@ -2653,8 +2813,36 @@
2653
2813
  this.initBody(true);
2654
2814
  };
2655
2815
 
2816
+ BootstrapTable.prototype.updateCellById = function (params) {
2817
+ var that = this;
2818
+ if (!params.hasOwnProperty('id') ||
2819
+ !params.hasOwnProperty('field') ||
2820
+ !params.hasOwnProperty('value')) {
2821
+ return;
2822
+ }
2823
+ var allParams = $.isArray(params) ? params : [ params ];
2824
+
2825
+ $.each(allParams, function(i, params) {
2826
+ var rowId;
2827
+
2828
+ rowId = $.inArray(that.getRowByUniqueId(params.id), that.options.data);
2829
+
2830
+ if (rowId === -1) {
2831
+ return;
2832
+ }
2833
+ that.data[rowId][params.field] = params.value;
2834
+ });
2835
+
2836
+ if (params.reinit === false) {
2837
+ return;
2838
+ }
2839
+ this.initSort();
2840
+ this.initBody(true);
2841
+ };
2842
+
2656
2843
  BootstrapTable.prototype.getOptions = function () {
2657
- return this.options;
2844
+ //Deep copy
2845
+ return $.extend(true, {}, this.options);
2658
2846
  };
2659
2847
 
2660
2848
  BootstrapTable.prototype.getSelections = function () {
@@ -2785,6 +2973,10 @@
2785
2973
  this.updatePagination();
2786
2974
  };
2787
2975
 
2976
+ BootstrapTable.prototype.toggleFullscreen = function () {
2977
+ this.$el.closest('.bootstrap-table').toggleClass('fullscreen');
2978
+ };
2979
+
2788
2980
  BootstrapTable.prototype.refresh = function (params) {
2789
2981
  if (params && params.url) {
2790
2982
  this.options.url = params.url;
@@ -2804,17 +2996,17 @@
2804
2996
  if (this.options.showHeader && this.options.height) {
2805
2997
  this.fitHeader();
2806
2998
  }
2807
- if (this.options.showFooter) {
2999
+ if (this.options.showFooter && !this.options.cardView) {
2808
3000
  this.fitFooter();
2809
3001
  }
2810
3002
  };
2811
3003
 
2812
3004
  BootstrapTable.prototype.showColumn = function (field) {
2813
- this.toggleColumn(getFieldIndex(this.columns, field), true, true);
3005
+ this.toggleColumn(this.fieldsColumnsIndex[field], true, true);
2814
3006
  };
2815
3007
 
2816
3008
  BootstrapTable.prototype.hideColumn = function (field) {
2817
- this.toggleColumn(getFieldIndex(this.columns, field), false, true);
3009
+ this.toggleColumn(this.fieldsColumnsIndex[field], false, true);
2818
3010
  };
2819
3011
 
2820
3012
  BootstrapTable.prototype.getHiddenColumns = function () {
@@ -2830,8 +3022,9 @@
2830
3022
  };
2831
3023
 
2832
3024
  BootstrapTable.prototype.toggleAllColumns = function (visible) {
3025
+ var that = this;
2833
3026
  $.each(this.columns, function (i, column) {
2834
- this.columns[i].visible = visible;
3027
+ that.columns[i].visible = visible;
2835
3028
  });
2836
3029
 
2837
3030
  this.initHeader();
@@ -2904,6 +3097,14 @@
2904
3097
  this.initHeader();
2905
3098
  // Fixed remove toolbar when click cardView button.
2906
3099
  //that.initToolbar();
3100
+ var $icon = this.$toolbar.find('button[name="toggle"] i');
3101
+ if (this.options.cardView) {
3102
+ $icon.removeClass(this.options.icons.toggleOff);
3103
+ $icon.addClass(this.options.icons.toggleOn);
3104
+ } else {
3105
+ $icon.removeClass(this.options.icons.toggleOn);
3106
+ $icon.addClass(this.options.icons.toggleOff);
3107
+ }
2907
3108
  this.initBody();
2908
3109
  this.trigger('toggle', this.options.cardView);
2909
3110
  };
@@ -3013,7 +3214,7 @@
3013
3214
  'load', 'append', 'prepend', 'remove', 'removeAll',
3014
3215
  'insertRow', 'updateRow', 'updateCell', 'updateByUniqueId', 'removeByUniqueId',
3015
3216
  'getRowByUniqueId', 'showRow', 'hideRow', 'getHiddenRows',
3016
- 'mergeCells',
3217
+ 'mergeCells', 'refreshColumnTitle',
3017
3218
  'checkAll', 'uncheckAll', 'checkInvert',
3018
3219
  'check', 'uncheck',
3019
3220
  'checkBy', 'uncheckBy',
@@ -3033,7 +3234,7 @@
3033
3234
  'refreshOptions',
3034
3235
  'resetSearch',
3035
3236
  'expandRow', 'collapseRow', 'expandAllRows', 'collapseAllRows',
3036
- 'updateFormatText'
3237
+ 'updateFormatText', 'updateCellById'
3037
3238
  ];
3038
3239
 
3039
3240
  $.fn.bootstrapTable = function (option) {
@@ -3076,8 +3277,8 @@
3076
3277
  $.fn.bootstrapTable.locales = BootstrapTable.LOCALES;
3077
3278
  $.fn.bootstrapTable.methods = allowedMethods;
3078
3279
  $.fn.bootstrapTable.utils = {
3280
+ bootstrapVersion: bootstrapVersion,
3079
3281
  sprintf: sprintf,
3080
- getFieldIndex: getFieldIndex,
3081
3282
  compareObjects: compareObjects,
3082
3283
  calculateObjectValue: calculateObjectValue,
3083
3284
  getItemField: getItemField,