Browse Source

Merge pull request #2 from wenzhixin/develop

Updating my repo
Dennis Hernández 8 years ago
parent
commit
4b6845f99e

+ 22 - 0
docs/_i18n/en/faq/faq.md

@@ -30,6 +30,28 @@ $table.on('load-success.bs.table column-switch.bs.table page-change.bs.table sea
 
 
 ---
 ---
 
 
+### Is event parameter put in the wrong order?
+
+When you use like this:
+
+```
+$('#eventsTable').on('click-row.bs.table', function (event, row, $element) {
+
+});
+```
+
+the first parameter is always `event`: http://jsfiddle.net/wenyi/e3nk137y/11688/
+
+and use onClickRow event:
+
+```
+onClickRow: function (row, $element) {
+
+}
+```
+
+---
+
 ### How can I support development of bootstrap-table?
 ### How can I support development of bootstrap-table?
 
 
 All your ideas and feedback are very appreciated! Please feel free to open issues on GitHub or send me email.
 All your ideas and feedback are very appreciated! Please feel free to open issues on GitHub or send me email.

+ 23 - 1
docs/_i18n/es/faq/faq.md

@@ -30,8 +30,30 @@ $table.on('load-success.bs.table column-switch.bs.table page-change.bs.table sea
 
 
 ---
 ---
 
 
+### Is event parameter put in the wrong order?
+
+When you use like this:
+
+```
+$('#eventsTable').on('click-row.bs.table', function (event, row, $element) {
+
+});
+```
+
+the first parameter is always `event`: http://jsfiddle.net/wenyi/e3nk137y/11688/
+
+and use onClickRow event:
+
+```
+onClickRow: function (row, $element) {
+
+}
+```
+
+---
+
 ### How can I support development of bootstrap-table?
 ### How can I support development of bootstrap-table?
 
 
 All your ideas and feedback are very appreciated! Please feel free to open issues on GitHub or send me email.
 All your ideas and feedback are very appreciated! Please feel free to open issues on GitHub or send me email.
 
 
-I'm also grateful for your donations: <a href="donate">{% t pages.donate.title %}</a>
+I'm also grateful for your donations: <a href="donate">{% t pages.donate.title %}</a>

+ 21 - 1
docs/_i18n/zh-cn/faq/faq.md

@@ -30,8 +30,28 @@ $table.on('load-success.bs.table column-switch.bs.table page-change.bs.table sea
 
 
 ---
 ---
 
 
+### 事件参数位置错误?
+
+当你使用:
+
+```
+$('#eventsTable').on('click-row.bs.table', function (event, row, $element) {
+
+});
+```
+
+的时候,第一个参数总是 `event`:http://jsfiddle.net/wenyi/e3nk137y/11688/
+
+而使用 `onClickRow` 就正常:
+
+```
+onClickRow: function (row, $element) {
+
+}
+```
+
 ### 我要如何支持 Bootstrap Table 的开发?
 ### 我要如何支持 Bootstrap Table 的开发?
 
 
 非常感谢你的想法和建议,你可以到 GitHub 上提 issue 或者发邮件给我。
 非常感谢你的想法和建议,你可以到 GitHub 上提 issue 或者发邮件给我。
 
 
-当然,假如你也可以 <a href="donate">{% t pages.donate.title %}</a> 我们的项目。
+当然,假如你也可以 <a href="donate">{% t pages.donate.title %}</a> 我们的项目。

+ 27 - 14
src/bootstrap-table.js

@@ -41,7 +41,7 @@
         });
         });
         return result;
         return result;
     };
     };
-    
+
     // http://jsfiddle.net/wenyi/47nz7ez9/3/
     // http://jsfiddle.net/wenyi/47nz7ez9/3/
     var setFieldIndex = function (columns) {
     var setFieldIndex = function (columns) {
         var i, j, k,
         var i, j, k,
@@ -931,7 +931,7 @@
         if (index !== -1) {
         if (index !== -1) {
             if (this.options.sortStable) {
             if (this.options.sortStable) {
                 $.each(this.data, function (i, row) {
                 $.each(this.data, function (i, row) {
-                    if (!row.hasOwnProperty('_position')) row._position = i;
+                    row._position = i;
                 });
                 });
             }
             }
 
 
@@ -944,6 +944,9 @@
                     value = calculateObjectValue(that.header, that.header.sorters[index], [aa, bb]);
                     value = calculateObjectValue(that.header, that.header.sorters[index], [aa, bb]);
 
 
                 if (value !== undefined) {
                 if (value !== undefined) {
+                    if (that.options.sortStable && value === 0) {
+                        return a._position - b._position;
+                    }
                     return order * value;
                     return order * value;
                 }
                 }
 
 
@@ -958,6 +961,7 @@
                 if (that.options.sortStable && aa === bb) {
                 if (that.options.sortStable && aa === bb) {
                     aa = a._position;
                     aa = a._position;
                     bb = b._position;
                     bb = b._position;
+                    return a._position - b._position;
                 }
                 }
 
 
                 // IF both values are numeric, do a numeric comparison
                 // IF both values are numeric, do a numeric comparison
@@ -2157,7 +2161,6 @@
             .html('').attr('class', this.$el.attr('class'))
             .html('').attr('class', this.$el.attr('class'))
             .append(this.$header_);
             .append(this.$header_);
 
 
-
         focusedTemp = $('.focus-temp:visible:eq(0)');
         focusedTemp = $('.focus-temp:visible:eq(0)');
         if (focusedTemp.length > 0) {
         if (focusedTemp.length > 0) {
             focusedTemp.focus();
             focusedTemp.focus();
@@ -2190,16 +2193,9 @@
 
 
             $th.find('.fht-cell').width($this.innerWidth());
             $th.find('.fht-cell').width($this.innerWidth());
         });
         });
-        // horizontal scroll event
-        // TODO: it's probably better improving the layout than binding to scroll event
-        this.$tableBody.off('scroll').on('scroll', function () {
-            that.$tableHeader.scrollLeft($(this).scrollLeft());
 
 
-            if (that.options.showFooter && !that.options.cardView) {
-                that.$tableFooter.scrollLeft($(this).scrollLeft());
-            }
-        });
-        that.trigger('post-header');
+        this.horizontalScroll();
+        this.trigger('post-header');
     };
     };
 
 
     BootstrapTable.prototype.resetFooter = function () {
     BootstrapTable.prototype.resetFooter = function () {
@@ -2287,6 +2283,23 @@
 
 
             $footerTd.eq(i).find('.fht-cell').width($this.innerWidth());
             $footerTd.eq(i).find('.fht-cell').width($this.innerWidth());
         });
         });
+
+        this.horizontalScroll();
+    };
+
+    BootstrapTable.prototype.horizontalScroll = function () {
+        var that = this;
+        // horizontal scroll event
+        // TODO: it's probably better improving the layout than binding to scroll event
+        this.$tableBody.off('scroll').on('scroll', function () {
+            if (that.options.showHeader && that.options.height) {
+              that.$tableHeader.scrollLeft($(this).scrollLeft());
+            }
+
+            if (that.options.showFooter && !that.options.cardView) {
+                that.$tableFooter.scrollLeft($(this).scrollLeft());
+            }
+        });
     };
     };
 
 
     BootstrapTable.prototype.toggleColumn = function (index, checked, needUpdate) {
     BootstrapTable.prototype.toggleColumn = function (index, checked, needUpdate) {
@@ -2542,7 +2555,7 @@
         if (!params.hasOwnProperty('index') || !params.hasOwnProperty('row')) {
         if (!params.hasOwnProperty('index') || !params.hasOwnProperty('row')) {
             return;
             return;
         }
         }
-        this.data.splice(params.index, 0, params.row);
+        this.options.data.splice(params.index, 0, params.row);
         this.initSearch();
         this.initSearch();
         this.initPagination();
         this.initPagination();
         this.initSort();
         this.initSort();
@@ -2809,7 +2822,7 @@
         if (this.options.showHeader && this.options.height) {
         if (this.options.showHeader && this.options.height) {
             this.fitHeader();
             this.fitHeader();
         }
         }
-        if (this.options.showFooter) {
+        if (this.options.showFooter && !that.options.cardView) {
             this.fitFooter();
             this.fitFooter();
         }
         }
     };
     };

+ 1 - 1
src/extensions/filter-control/bootstrap-table-filter-control.js

@@ -446,7 +446,7 @@
         valuesFilterControl: []
         valuesFilterControl: []
     });
     });
 
 
-    $.extend($.fn.bootstrapTable.COLUMN_DEFAULTS, {
+    $.extend($.fn.bootstrapTable.columnDefaults, {
         filterControl: undefined,
         filterControl: undefined,
         filterData: undefined,
         filterData: undefined,
         filterDatepickerOptions: undefined,
         filterDatepickerOptions: undefined,

+ 13 - 0
src/extensions/multiple-sort/README.md

@@ -16,6 +16,12 @@ Use Plugin: [bootstrap-table-multiple-sort](https://github.com/dimbslmh/bootstra
 * description: Set true to allow the multiple sort.
 * description: Set true to allow the multiple sort.
 * default: `false`
 * default: `false`
 
 
+### showMultiSortButton
+
+* type: Boolean
+* description: Set false to hide multiple sort UI button.
+* default: `true`
+
 ### sortPriority
 ### sortPriority
 
 
 * type: Object
 * type: Object
@@ -27,6 +33,13 @@ Use Plugin: [bootstrap-table-multiple-sort](https://github.com/dimbslmh/bootstra
 * plus: `glyphicon-plus`
 * plus: `glyphicon-plus`
 * minus: `glyphicon-minus`
 * minus: `glyphicon-minus`
 
 
+## methods
+
+### multipleSort
+
+* parameters: none
+* description: Force mutltiple sort table (usable after manual data changes).
+
 ## Locales
 ## Locales
 
 
 ### formatMultipleSort
 ### formatMultipleSort

+ 19 - 7
src/extensions/multiple-sort/bootstrap-table-multiple-sort.js

@@ -11,16 +11,16 @@
     var isSingleSort = false;
     var isSingleSort = false;
 
 
     var showSortModal = function(that) {
     var showSortModal = function(that) {
-        var _selector = that.$sortModal.selector,
-            _id = _selector.substr(1);
+        var _selector = that.sortModalSelector,
+            _id = '#' + _selector;
 
 
         if (!$(_id).hasClass("modal")) {
         if (!$(_id).hasClass("modal")) {
-            var sModal = '  <div class="modal fade" id="' + _id + '" tabindex="-1" role="dialog" aria-labelledby="' + _id + 'Label" aria-hidden="true">';
+            var sModal = '  <div class="modal fade" id="' + _selector + '" tabindex="-1" role="dialog" aria-labelledby="' + _selector + 'Label" aria-hidden="true">';
             sModal += '         <div class="modal-dialog">';
             sModal += '         <div class="modal-dialog">';
             sModal += '             <div class="modal-content">';
             sModal += '             <div class="modal-content">';
             sModal += '                 <div class="modal-header">';
             sModal += '                 <div class="modal-header">';
             sModal += '                     <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
             sModal += '                     <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
-            sModal += '                     <h4 class="modal-title" id="' + _id + 'Label">' + that.options.formatMultipleSort() + '</h4>';
+            sModal += '                     <h4 class="modal-title" id="' + _selector + 'Label">' + that.options.formatMultipleSort() + '</h4>';
             sModal += '                 </div>';
             sModal += '                 </div>';
             sModal += '                 <div class="modal-body">';
             sModal += '                 <div class="modal-body">';
             sModal += '                     <div class="bootstrap-table">';
             sModal += '                     <div class="bootstrap-table">';
@@ -56,7 +56,7 @@
 
 
             $('body').append($(sModal));
             $('body').append($(sModal));
 
 
-            that.$sortModal = $(_selector);
+            that.$sortModal = $(_id);
             var $rows = that.$sortModal.find('tbody > tr');
             var $rows = that.$sortModal.find('tbody > tr');
 
 
             that.$sortModal.off('click', '#add').on('click', '#add', function() {
             that.$sortModal.off('click', '#add').on('click', '#add', function() {
@@ -161,8 +161,11 @@
         }
         }
     };
     };
 
 
+    $.fn.bootstrapTable.methods.push('multipleSort');
+
     $.extend($.fn.bootstrapTable.defaults, {
     $.extend($.fn.bootstrapTable.defaults, {
         showMultiSort: false,
         showMultiSort: false,
+        showMultiSortButton: true,
         sortPriority: null,
         sortPriority: null,
         onMultipleSort: function() {
         onMultipleSort: function() {
             return false;
             return false;
@@ -229,8 +232,10 @@
     BootstrapTable.prototype.initToolbar = function() {
     BootstrapTable.prototype.initToolbar = function() {
         this.showToolbar = true;
         this.showToolbar = true;
         var that = this,
         var that = this,
-            sortModalId = '#sortModal_' + this.$el.attr('id');
+            sortModalSelector = 'sortModal_' + this.$el.attr('id'),
+            sortModalId = '#' + sortModalSelector;
         this.$sortModal = $(sortModalId);
         this.$sortModal = $(sortModalId);
+        this.sortModalSelector = sortModalSelector;
 
 
         _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
         _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
 
 
@@ -238,7 +243,7 @@
             var $btnGroup = this.$toolbar.find('>.btn-group').first(),
             var $btnGroup = this.$toolbar.find('>.btn-group').first(),
                 $multiSortBtn = this.$toolbar.find('div.multi-sort');
                 $multiSortBtn = this.$toolbar.find('div.multi-sort');
 
 
-            if (!$multiSortBtn.length) {
+            if (!$multiSortBtn.length && this.options.showMultiSortButton) {
                 $multiSortBtn = '  <button class="multi-sort btn btn-default' + (this.options.iconSize === undefined ? '' : ' btn-' + this.options.iconSize) + '" type="button" data-toggle="modal" data-target="' + sortModalId + '" title="' + this.options.formatMultipleSort() + '">';
                 $multiSortBtn = '  <button class="multi-sort btn btn-default' + (this.options.iconSize === undefined ? '' : ' btn-' + this.options.iconSize) + '" type="button" data-toggle="modal" data-target="' + sortModalId + '" title="' + this.options.formatMultipleSort() + '">';
                 $multiSortBtn += '     <i class="' + this.options.iconsPrefix + ' ' + this.options.icons.sort + '"></i>';
                 $multiSortBtn += '     <i class="' + this.options.iconsPrefix + ' ' + this.options.icons.sort + '"></i>';
                 $multiSortBtn += '</button>';
                 $multiSortBtn += '</button>';
@@ -282,6 +287,13 @@
         }
         }
     };
     };
 
 
+    BootstrapTable.prototype.multipleSort = function() {
+        var that = this;
+        if (!isSingleSort && that.options.sortPriority !== null && typeof that.options.sortPriority === 'object' && that.options.sidePagination !== 'server') {
+            that.onMultipleSort();
+        }
+    };
+
     BootstrapTable.prototype.onMultipleSort = function() {
     BootstrapTable.prototype.onMultipleSort = function() {
         var that = this;
         var that = this;
 
 

+ 43 - 0
src/locale/bootstrap-table-eu-EU.js

@@ -0,0 +1,43 @@
+/**
+ * Bootstrap Table Basque (Basque Country) translation
+ * Author: Iker Ibarguren Berasaluze<ikerib@gmail.com>
+ */
+(function ($) {
+    'use strict';
+
+    $.fn.bootstrapTable.locales['eu-EU'] = {
+        formatLoadingMessage: function () {
+            return 'Itxaron mesedez...';
+        },
+        formatRecordsPerPage: function (pageNumber) {
+            return pageNumber + ' emaitza orriko.';
+        },
+        formatShowingRows: function (pageFrom, pageTo, totalRows) {
+            return totalRows + ' erregistroetatik ' + pageFrom + 'etik ' + pageTo +'erakoak erakusten.';
+        },
+        formatSearch: function () {
+            return 'Bilatu';
+        },
+        formatNoMatches: function () {
+            return 'Ez da emaitzarik aurkitu';
+        },
+        formatPaginationSwitch: function () {
+            return 'Ezkutatu/Erakutsi orrikatzea';
+        },
+        formatRefresh: function () {
+            return 'Eguneratu';
+        },
+        formatToggle: function () {
+            return 'Ezkutatu/Erakutsi';
+        },
+        formatColumns: function () {
+            return 'Zutabeak';
+        },
+        formatAllRows: function () {
+            return 'Guztiak';
+        }
+    };
+
+    $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['eu-EU']);
+
+})(jQuery);

+ 51 - 0
src/locale/bootstrap-table-fr-FR.js

@@ -34,6 +34,57 @@
         formatAllRows: function () {
         formatAllRows: function () {
             return 'Tous';
             return 'Tous';
         }
         }
+        formatExport: function () {
+            return 'Exporter les données';
+        },
+        formatClearFilters: function () {
+            return 'Vider les filtres';
+        },
+        formatMultipleSort: function() {
++            return 'Tri avancé';
++        },
++        formatAddLevel: function() {
++            return 'Ajouter un niveau';
++        },
++        formatDeleteLevel: function() {
++            return 'Supprimer un niveau';
++        },
++        formatColumn: function() {
++            return 'Colonne';
++        },
++        formatOrder: function() {
++            return 'Ordre';
++        },
++        formatSortBy: function() {
++            return 'Trier par';
++        },
++        formatThenBy: function() {
++            return 'Puis par';
++        },
++        formatSort: function() {
++            return 'Trier';
++        },
++        formatCancel: function() {
++            return 'Annuler';
++        },
++        formatDuplicateAlertTitle: function() {
++            return 'Doublon(s) détecté(s)!';
++        },
++        formatDuplicateAlertDescription: function() {
++            return 'Supprimez ou changez les colonnes dupliquées.';
++        },
++        formatSortOrders: function() {
++            return {
++                asc: 'Croissant',
++                desc: 'Décroissant'
++            };
++        },
+         formatAdvancedSearch: function() {
++            return 'Recherche avancée';
++        },
++        formatAdvancedCloseButton: function() {
++            return "Fermer";
++        }
     };
     };
 
 
     $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['fr-FR']);
     $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['fr-FR']);

+ 12 - 0
src/locale/bootstrap-table-sk-SK.js

@@ -21,6 +21,9 @@
         formatNoMatches: function () {
         formatNoMatches: function () {
             return 'Nenájdená žiadna vyhovujúca položka';
             return 'Nenájdená žiadna vyhovujúca položka';
         },
         },
+        formatPaginationSwitch: function () {
+            return 'Skry/Zobraz stránkovanie';
+        },
         formatRefresh: function () {
         formatRefresh: function () {
             return 'Obnoviť';
             return 'Obnoviť';
         },
         },
@@ -29,6 +32,15 @@
         },
         },
         formatColumns: function () {
         formatColumns: function () {
             return 'Stĺpce';
             return 'Stĺpce';
+        },
+        formatAllRows: function () {
+            return 'Všetky';
+        },
+        formatExport: function () {
+            return 'Exportuj dáta';
+        },
+        formatClearFilters: function () {
+            return 'Odstráň filtre';
         }
         }
     };
     };