Browse Source

Merge pull request #21 from wenzhixin/master

Update my repo
Dennis Hernández 11 years ago
parent
commit
658c463d14

File diff suppressed because it is too large
+ 7 - 0
dist/locale/bootstrap-table-ka-GE.min.js


+ 7 - 0
docs/_i18n/en/documentation/table-options.md

@@ -245,6 +245,13 @@ The table options is defined in `jQuery.fn.bootstrapTable.defaults`.
         <td>Set timeout for search fire.</td>
     </tr>
     <tr>
+        <td>trimOnSearch</td>
+        <td>data-trim-on-search</td>
+        <td>Boolean</td>
+        <td>true</td>
+        <td>True to trim spaces in search field.</td>
+    </tr
+    <tr>
         <td>showHeader</td>
         <td>data-show-header</td>
         <td>Boolean</td>

+ 5 - 1
docs/_i18n/en/faq/faq.md

@@ -26,4 +26,8 @@ For merged cells, when you do refresh, next page or switch columns to show, the
 $table.on('load-success.bs.table column-switch.bs.table page-change.bs.table search.bs.table', function () {
     $table.bootstrapTable('mergeCells', {...});
 });
-```
+```
+
+### Export extension does not support unicode characters?
+
+The extension is using the Plugin: [tableExport.jquery.plugin](https://github.com/kayalshri/tableExport.jquery.plugin), because this plugin has [this same problem](https://github.com/carlo/jquery-base64/issues/1), so it doesn't belong to the category of the bootstrap-table, but I think we can try to use this: [jquery.base64.js](https://gist.github.com/wenzhixin/09e218c884f4f380b68a) to replace the base64 plugin.

+ 8 - 1
src/bootstrap-table.css

@@ -23,13 +23,20 @@
 .fixed-table-footer,
 .fixed-table-header {
     height: 37px; /*cellHeight*/
-    border-bottom: 1px solid #dddddd;
     overflow: hidden;
     border-radius: 4px 4px 0 0;
     -webkit-border-radius: 4px 4px 0 0;
     -moz-border-radius: 4px 4px 0 0;
 }
 
+.fixed-table-header {
+    border-bottom: 1px solid #dddddd;
+}
+
+.fixed-table-footer {
+    border-top: 1px solid #dddddd;
+}
+
 .fixed-table-body {
     overflow-x: auto;
     overflow-y: auto;

+ 29 - 22
src/bootstrap-table.js

@@ -481,7 +481,7 @@
 
             columns.push(column);
         });
-        this.options.columns = $.extend([], columns, this.options.columns);
+        this.options.columns = $.extend(true, [], columns, this.options.columns);
         $.each(this.options.columns, function (i, column) {
             that.options.columns[i] = $.extend({}, BootstrapTable.COLUMN_DEFAULTS,
                 {field: i}, column); // when field is undefined, use index instead
@@ -689,15 +689,15 @@
     };
 
     BootstrapTable.prototype.resetFooter = function () {
-        var bt   = this,
-            data = bt.getData(),
+        var that = this,
+            data = that.getData(),
             html = [];
 
         if (!this.options.showFooter || this.options.cardView) { //do nothing
             return;
         }
 
-        $.each(bt.options.columns, function (i, column) {
+        $.each(this.options.columns, function (i, column) {
             var falign = '', // footer align style
                 style  = '',
                 class_ = sprintf(' class="%s"', column['class']);
@@ -720,34 +720,35 @@
             html.push('</td>');
         });
 
-        bt.$footer.find('tr').html(html.join(''));
-        clearTimeout(bt.timeoutFooter_);
-        bt.timeoutFooter_ = setTimeout($.proxy(bt.fitFooter, bt), bt.$el.is(':hidden') ? 100: 0);
-        return;
+        this.$footer.find('tr').html(html.join(''));
+        clearTimeout(this.timeoutFooter_);
+        this.timeoutFooter_ = setTimeout($.proxy(this.fitFooter, this),
+            this.$el.is(':hidden') ? 100: 0);
     };
 
     BootstrapTable.prototype.fitFooter = function () {
-        var bt = this,
+        var that = this,
             $fixedBody,
             $footerTd,
             elWidth,
             scrollWidth;
-        clearTimeout(bt.timeoutFooter_);
-        if (bt.$el.is(':hidden')) {
-            bt.timeoutFooter_ = setTimeout($.proxy(bt.fitFooter, bt), 100);
+
+        clearTimeout(this.timeoutFooter_);
+        if (this.$el.is(':hidden')) {
+            this.timeoutFooter_ = setTimeout($.proxy(this.fitFooter, this), 100);
             return;
         }
 
-        $fixedBody  = bt.$container.find('.fixed-table-body');
-        elWidth     = bt.$el.css('width');
+        $fixedBody  = this.$container.find('.fixed-table-body');
+        elWidth     = this.$el.css('width');
         scrollWidth = elWidth > $fixedBody.width() ? getScrollBarWidth() : 0;
 
-        bt.$footer.css({
+        this.$footer.css({
             'margin-right': scrollWidth
         }).find('table').css('width', elWidth)
-            .attr('class', bt.$el.attr('class'));
+            .attr('class', this.$el.attr('class'));
 
-        $footerTd = bt.$footer.find('td');
+        $footerTd = this.$footer.find('td');
 
         $fixedBody.find('tbody tr:first-child:not(.no-records-found) > td').each(function(i) {
             $footerTd.eq(i).outerWidth($(this).outerWidth());
@@ -959,7 +960,8 @@
                 .off('click').on('click', function () {
                     that.options.cardView = !that.options.cardView;
                     that.initHeader();
-                    that.initToolbar();
+                    // Fixed remove toolbar when click cardView button.
+                    //that.initToolbar();
                     that.initBody();
                 });
         }
@@ -1204,8 +1206,9 @@
         html.push(this.options.formatRecordsPerPage(pageNumber.join('')));
         html.push('</span>');
 
+        // Fixed #611 vertical-align between pagination block and pagination-detail block. Remove class pagination.
         html.push('</div>',
-            '<div class="pull-' + this.options.paginationHAlign + ' pagination">',
+            '<div class="pull-' + this.options.paginationHAlign + '">',
             '<ul class="pagination' + (this.options.iconSize === undefined ? '' : ' pagination-' + this.options.iconSize) + '">',
             '<li class="page-first"><a href="javascript:void(0)">&lt;&lt;</a></li>',
             '<li class="page-pre"><a href="javascript:void(0)">&lt;</a></li>');
@@ -1630,9 +1633,10 @@
                 order: params.sortOrder
             };
             if (this.options.pagination) {
-                params.limit = this.options.pageSize === this.options.formatAllRows() ? this.options.totalRows : this.options.pageSize;
-                params.offset = (this.options.pageSize === this.options.formatAllRows() ? this.options.totalRows : this.options.pageSize)
-                                * (this.options.pageNumber - 1);
+                params.limit = this.options.pageSize === this.options.formatAllRows() ?
+                    this.options.totalRows : this.options.pageSize;
+                params.offset = this.options.pageSize === this.options.formatAllRows() ?
+                    0 : this.options.pageSize * (this.options.pageNumber - 1);
             }
         }
 
@@ -1932,6 +1936,7 @@
             this.resetHeader();
             padding += cellHeight;
         } else {
+            this.$container.find('.fixed-table-header').hide();
             this.trigger('post-header');
         }
 
@@ -2017,6 +2022,8 @@
             return;
         }
         this.data.splice(params.index, 0, params.row);
+        this.initSearch();
+        this.initPagination();
         this.initBody(true);
     };
 

+ 7 - 1
src/extensions/export/README.md

@@ -20,4 +20,10 @@ Use Plugin: [tableExport.jquery.plugin](https://github.com/kayalshri/tableExport
 
 * type: Array
 * description: export types, support types: 'json', 'xml', 'png', 'csv', 'txt', 'sql', 'doc', 'excel', 'powerpoint', 'pdf'.
-* default: `['json', 'xml', 'csv', 'txt', 'sql', 'excel']`
+* default: `['json', 'xml', 'csv', 'txt', 'sql', 'excel']`
+
+### exportOptions
+
+* type: Object
+* description: export [options](https://github.com/kayalshri/tableExport.jquery.plugin#options) of `tableExport.jquery.plugin`
+* default: `{}`

+ 5 - 4
src/extensions/export/bootstrap-table-export.js

@@ -22,7 +22,8 @@
     $.extend($.fn.bootstrapTable.defaults, {
         showExport: false,
         // 'json', 'xml', 'png', 'csv', 'txt', 'sql', 'doc', 'excel', 'powerpoint', 'pdf'
-        exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel']
+        exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel'],
+        exportOptions: {}
     });
 
     var BootstrapTable = $.fn.bootstrapTable.Constructor,
@@ -72,12 +73,12 @@
                 });
 
                 $menu.find('li').click(function () {
-                    that.$el.tableExport({
+                    that.$el.tableExport($.extend({}, that.options.exportOptions, {
                         type: $(this).data('type'),
                         escape: false
-                    });
+                    }));
                 });
             }
         }
     };
-})(jQuery);
+})(jQuery);

+ 200 - 0
src/extensions/toolbar/bootstrap-table-toolbar.js

@@ -0,0 +1,200 @@
+/**
+ * @author aperez <aperez@datadec.es>
+ * Añade los iconos de buscador y buscador avanzado detrás del campo search.
+ */
+
+! function($) {
+
+    'use strict';
+
+    var firstLoad = false;
+    var firstBody = false;
+
+    var sprintf = function(str) {
+        var args = arguments,
+            flag = true,
+            i = 1;
+
+        str = str.replace(/%s/g, function() {
+            var arg = args[i++];
+
+            if (typeof arg === 'undefined') {
+                flag = false;
+                return '';
+            }
+            return arg;
+        });
+        return flag ? str : '';
+    };
+
+
+    var showAvdSearch = function(pColumns, pObjSearch) {
+
+        if (!$("#avdSearchModal").hasClass("modal")) {
+            var vModal = "<div id=\"avdSearchModal\" class=\"modal fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"mySmallModalLabel\" aria-hidden=\"true\">";
+            vModal += "<div class=\"modal-dialog modal-xs\">";
+            vModal += " <div class=\"modal-content\">";
+            vModal += "  <div class=\"modal-header\">";
+            vModal += "   <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\" >&times;</button>";
+            vModal += "   <h4 class=\"modal-title\">Buscador Avanzado</h4>";
+            vModal += "  </div>";
+            vModal += "  <div class=\"modal-body modal-body-custom\">";
+            vModal += "   <div class=\"container-fluid\" id=\"avdSearchModalContent\" style=\"padding-right: 0px;padding-left: 0px;\" >";
+            vModal += "   </div>";
+            vModal += "  </div>";
+            vModal += "  </div>";
+            vModal += " </div>";
+            vModal += "</div>";
+
+            $("body").append($(vModal));
+            var vFormAvd = createFormAvd(pColumns, pObjSearch);
+            $('#avdSearchModalContent').append(vFormAvd.join(''));
+            //
+
+
+
+            $("#btnSearchAvd").click(function() {
+                var vFormData = $("#" + pObjSearch.idForm).serializeJSON();
+                var vText = $('#' + pObjSearch.idTable).parents('.bootstrap-table').find('.search input').val();
+
+                $.extend(vFormData, {
+                    searchText: vText
+                });
+                var sFunctionData = JSON.stringify(vFormData);
+                BootstrapTable.DEFAULTS.searchText = sFunctionData;
+
+                //BootstrapTable.prototype.onSearch(this,$.Event('keyup'));
+                /*********************
+
+                  * Here, I want to call the method onSearch.
+
+                ***********************/
+
+
+            });
+
+            $("#avdSearchModal").modal();
+        } else {
+            $("#avdSearchModal").modal();
+        }
+
+    };
+
+
+    var createFormAvd = function(pColumns, pObjSearch) {
+        var htmlForm = [];
+        htmlForm.push('<form class="form-horizontal" id="' + pObjSearch.idForm + '" action="' + pObjSearch.actionForm + '" >');
+
+        for (var i in pColumns) {
+            var vObjCol = pColumns[i];
+            if (!vObjCol.checkbox && vObjCol.visible && vObjCol.searchable) {
+                htmlForm.push('<div class="form-group">',
+                    '<label class="col-sm-4 control-label">' + vObjCol.title + '</label>',
+                    '<div class="col-sm-6">',
+                    '<input type = "text" class="form-control input-md" name="' + vObjCol.field + '" placeholder="Email">',
+                    '</div>',
+                    '</div>');
+            }
+        }
+
+        htmlForm.push('<div class="form-group">',
+            '<div class="col-sm-offset-9 col-sm-3">',
+            '<button type="button" id="btnSearchAvd" class="btn btn-default" >Buscar</button>',
+            '</div>',
+            '</div>',
+            '</form>');
+
+        return htmlForm;
+    }
+
+
+
+    $.extend($.fn.bootstrapTable.defaults, {
+        advancedSearch: undefined,
+        idTable: undefined
+    });
+
+    $.extend($.fn.bootstrapTable.defaults.icons, {
+        avdSearch: 'glyphicon-chevron-down'
+    });
+
+    $.extend($.fn.bootstrapTable.locales, {
+        formatAvancedSearch: function() {
+            return 'Buscador Avanzado';
+        }
+    });
+
+    $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
+
+
+    var BootstrapTable = $.fn.bootstrapTable.Constructor,
+        _initToolbar = BootstrapTable.prototype.initToolbar,        
+        _load = BootstrapTable.prototype.load;
+
+    BootstrapTable.prototype.initToolbar = function() {
+        var that = this,
+            htmlBtns = [],
+            $search,
+            advSearch = {
+                active: false,
+                idTable: '',
+                idForm: '',
+                actionForm: ''
+            };
+
+        _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
+
+        if (typeof this.options.advancedSearch !== 'undefined') {
+            advSearch = this.options.advancedSearch;
+        }
+
+        if (advSearch.active) {
+            htmlBtns.push(sprintf('<div class="btn-group" role="group"><button class="btn btn-default' + (that.options.iconSize === undefined ? '' : ' btn-' + that.options.iconSize) + '" type="button" name="avdSearch" title="%s">',
+                    that.options.formatAvancedSearch()),
+                sprintf('<i class="%s %s"></i>', that.options.iconsPrefix, that.options.icons.avdSearch),
+                '</button></div>');
+
+            // Añadimos el botón al toolbar.
+            that.$toolbar.find('.columns').prepend(htmlBtns.join(''));
+
+            // Creamos el onclick para el booton            
+            that.$toolbar.find('button[name="avdSearch"]')
+                .off('click').on('click', function() {
+                    showAvdSearch(that.options.columns, advSearch);
+                });
+        }
+
+        // Anulamos la búsqueda automática
+        if (that.options.searchTimeOut === -1) {
+            $search = that.$toolbar.find('.search input');
+            $search.off('keyup').on('keyup', function(event) {
+                var text = $.trim($(event.currentTarget).val());
+                // Al pulsar Enter realizamos la búsqueda.
+                if (event.which === 13) {
+                    that.onSearch(event);
+                }
+
+            });
+        }
+
+    };
+
+    BootstrapTable.prototype.load = function(data) {
+
+        _load.apply(this, Array.prototype.slice.apply(arguments));
+
+        if (typeof this.options.idTable === 'undefined') {
+            alert('Error: La propiedad "idTable" de bootstrapTable debe tener el id definido en la tabla.');
+        } else {
+            if (!firstLoad) {
+                var vTam = parseInt($(".bootstrap-table").height());
+                vTam += 10;
+                $("#" + this.options.idTable).bootstrapTable("resetView", {height: vTam});
+                firstLoad = true;
+            }
+        }
+
+    };
+
+
+}(jQuery);

+ 1 - 1
src/locale/bootstrap-table-da-DK.js

@@ -16,7 +16,7 @@
             return 'Viser ' + pageFrom + ' til ' + pageTo + ' af ' + totalRows + ' rækker';
         },
         formatSearch: function () {
-            return 'Søg'
+            return 'Søg';
         },
         formatNoMatches: function () {
             return 'Ingen poster fundet';

+ 40 - 0
src/locale/bootstrap-table-es-SP.js

@@ -0,0 +1,40 @@
+/**
+ * Bootstrap Table Spanish (España) translation
+ * Author: Antonio Pérez <anpegar@gmail.com>
+ */
+ (function ($) {
+    'use strict';
+    
+    $.fn.bootstrapTable.locales['es-SP'] = {
+        formatLoadingMessage: function () {
+            return 'Cargando, por favor espera...';
+        },
+        formatRecordsPerPage: function (pageNumber) {
+            return pageNumber + ' registros por p&#225;gina.';
+        },
+        formatShowingRows: function (pageFrom, pageTo, totalRows) {
+            return pageFrom + ' - ' + pageTo + ' de ' + totalRows + ' registros.';
+        },
+        formatSearch: function () {
+            return 'Buscar';
+        },
+        formatNoMatches: function () {
+            return 'No se han encontrado registros.';
+        },
+        formatRefresh: function () {
+            return 'Actualizar';
+        },
+        formatToggle: function () {
+            return 'Alternar';
+        },
+        formatColumns: function () {
+            return 'Columnas';
+        },
+        formatAllRows: function () {
+            return 'Todo';
+        }
+    };
+
+    $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['es-SP']);
+
+})(jQuery);

+ 41 - 0
src/locale/bootstrap-table-ka-GE.js

@@ -0,0 +1,41 @@
+/**
+ * Bootstrap Table Georgian translation
+ * Author: Levan Lotuashvili <l.lotuashvili@gmail.com>
+ */
+(function ($) {
+    'use strict';
+
+    $.fn.bootstrapTable.locales['ka-GE'] = {
+        formatLoadingMessage: function() {
+            return "იტვირთება, გთხოვთ მოიცადოთ...";
+        },
+        formatRecordsPerPage: function(pageNumber) {
+            return pageNumber + " ჩანაწერი ერთ გვერდზე";
+        },
+        formatShowingRows: function(pageFrom, pageTo, totalRows) {
+            return "ნაჩვენებია " + pageFrom + "-დან " + pageTo + "-მდე ჩანაწერი " + totalRows + "-დან";
+        },
+        formatSearch: function() {
+            return "ძებნა";
+        },
+        formatNoMatches: function() {
+            return "მონაცემები არ არის";
+        },
+        formatPaginationSwitch: function() {
+            return "გვერდების გადამრთველის დამალვა/გამოჩენა";
+        },
+        formatRefresh: function() {
+            return "განახლება";
+        },
+        formatToggle: function() {
+            return "ჩართვა/გამორთვა";
+        },
+        formatColumns: function() {
+            return "სვეტები";
+        }
+    };
+    
+    $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['ka-GE']);
+  });
+
+})(jQuery);

+ 1 - 1
src/locale/bootstrap-table-nb-NO.js

@@ -16,7 +16,7 @@
             return 'Viser ' + pageFrom + ' til ' + pageTo + ' av ' + totalRows + ' rekker';
         },
         formatSearch: function () {
-            return 'Søk'
+            return 'Søk';
         },
         formatNoMatches: function () {
             return 'Ingen poster funnet';