ソースを参照

Merge pull request #1 from wenzhixin/master

Update the project
Dennis Hernández 11 年 前
コミット
b11de8d7c4
6 ファイル変更79 行追加55 行削除
  1. 2 2
      README.md
  2. 41 37
      docs/common.js
  3. 7 7
      docs/examples.html
  4. 2 0
      docs/jsfiddle-examples.md
  5. 13 3
      src/bootstrap-table.js
  6. 14 6
      src/locale/bootstrap-table-ru-RU.js

+ 2 - 2
README.md

@@ -25,9 +25,9 @@ Bootstrap table displays data in a tabular format and offers rich support to rad
 - [ ] Fix #144: onCheck and onUncheck functionalities are reversed when using `clickToSelect` option. (jQuery 1.7.2 bug).
 - [x] Apply `width` column option to row style.
 - [x] Add bootstrap-table-filter extension.
-- [x] Add czech translation.
+- [x] Add cs-CZ and es-CR locales.
 - [x] Fix minimumCountColumns option init error.
-
+- [x] Fix #161: undefined or null string sort bug.
 
 ## Features
 

+ 41 - 37
docs/common.js

@@ -1,25 +1,29 @@
-$(function() {
+$(function () {
     'use strict';
 
-	var defaultTranslation = 'en',
-		translations = {'en': {title: 'English', code: 'en'},'zh': {title: '简体中文', code: 'zh'},'es': {title: 'Español', code: 'es'}};
-	
-	window.getLocale = function () {
+    var defaultTranslation = 'en',
+        translations = {
+            'en': {title: 'English', code: 'en'},
+            'zh': {title: '简体中文', code: 'zh'},
+            'es': {title: 'Español', code: 'es'}
+        };
+
+    window.getLocale = function () {
         if (!localStorage) {
             return defaultTranslation;
         }
-		
-		if (location.search !== '') {
+
+        if (location.search !== '') {
             localStorage.locale = translations[location.search.replace('?locale=', '')].code;
         }
-		
+
         return localStorage.locale === undefined ? defaultTranslation : localStorage.locale;
     };
-	
-	function main() {
+
+    function main() {
         $(window).scroll(showGotoTop);
         $(window).resize(showGotoTop);
-        $('.goto-top').click(function() {
+        $('.goto-top').click(function () {
             document.body.scrollTop = 0;
             document.documentElement.scrollTop = 0;
             return false;
@@ -32,42 +36,42 @@ $(function() {
 
     function initLocale() {
         var $locale = $('#locale'),
-			translation = {};
-			
+            translation = {};
+
         if (!localStorage) {
             $locale.hide();
             return;
         }
-		
-		translation = translations[getLocale()];
-		setGlobalLanguage($locale, translation.title, translation.code);
+
+        translation = translations[getLocale()];
+        setGlobalLanguage($locale, translation.title, translation.code);
 
         $('[data-locale]').click(function () {
             localStorage.locale = $(this).data('locale');
             location.reload(true);
         });
     }
-	
-	function setGlobalLanguage($locale, text, languageCode) {
-		var translationsArray = $.map(translations, function(value, index) {
-			return [value];
-		});
-		
-		for(var i = 0; i < translationsArray.length; i++) { 
-			if(translationsArray[i].code !== languageCode) {
-				$locale.find('[data-locale="'+ translationsArray[i].code + '"]').removeClass('active').end()
-				.find('.dropdown-toggle img').removeClass('flag-'+ translationsArray[i].code +'').end();
-			}
-		}
-		
-		$locale.find('.language').text(text).end()
-			.find('[data-locale="'+languageCode + '"]').addClass('active').end()
-			.find('.dropdown-toggle img').addClass('flag-'+ languageCode +'').end();
-			
-		$('[data-'+ languageCode + ']').each(function () {
-			$(this).html($(this).data(languageCode));
-		});	
-	}
+
+    function setGlobalLanguage($locale, text, languageCode) {
+        var translationsArray = $.map(translations, function (value, index) {
+            return [value];
+        });
+
+        for (var i = 0; i < translationsArray.length; i++) {
+            if (translationsArray[i].code !== languageCode) {
+                $locale.find('[data-locale="' + translationsArray[i].code + '"]').removeClass('active').end()
+                    .find('.dropdown-toggle img').removeClass('flag-' + translationsArray[i].code + '').end();
+            }
+        }
+
+        $locale.find('.language').text(text).end()
+            .find('[data-locale="' + languageCode + '"]').addClass('active').end()
+            .find('.dropdown-toggle img').addClass('flag-' + languageCode + '').end();
+
+        $('[data-' + languageCode + ']').each(function () {
+            $(this).html($(this).data(languageCode));
+        });
+    }
 
     function initScrollspy() {
         var $window = $(window),

+ 7 - 7
docs/examples.html

@@ -73,7 +73,7 @@
                                 <img src="blank.gif" class="flag flag-zh" alt="China"> 简体中文
                             </a>
                         </li>
-						<!-- <li data-locale="es">
+                        <!-- <li data-locale="es">
                             <a href="javascript:void(0)">
                                 <img src="blank.gif" class="flag flag-es" alt="Esapñol"> Español
                             </a>
@@ -212,27 +212,27 @@
                         <tbody>
                         <tr>
                             <td>1</td>
-                            <td>test1</td>
+                            <td>Item 1</td>
                             <td>$1</td>
                         </tr>
                         <tr>
                             <td>2</td>
-                            <td>test2</td>
+                            <td>Item 2</td>
                             <td>$2</td>
                         </tr>
                         <tr>
                             <td>3</td>
-                            <td>test3</td>
+                            <td>Item 3</td>
                             <td>$3</td>
                         </tr>
                         <tr>
                             <td>4</td>
-                            <td>test4</td>
+                            <td>Item 4</td>
                             <td>$4</td>
                         </tr>
                         <tr>
                             <td>5</td>
-                            <td>test5</td>
+                            <td>Item 5</td>
                             <td>$5</td>
                         </tr>
                         </tbody>
@@ -260,7 +260,7 @@
                     </button>
                 </div>
                 <p data-zh="用<code>height</code>, <code>classes</code>, <code>striped</code>, <code>rowStyle</code> 属性和<code>class</code>, <code>width</code>, <code>cellStyle</code> 列属性设置 bootstrap table 的样式。"
-				data-es="Use las opciones <code>height</code>, <code>classes</code>, <code>striped</code>, <code>rowStyle</code> y las opciones de columnas <code>class</code>, <code>width</code>, <code>cellStyle</code> para setear los estilos de bootstrap table.">Use <code>height</code>, <code>classes</code>, <code>striped</code>, <code>rowStyle</code> options and <code>class</code>, <code>width</code>, <code>cellStyle</code> column options to set the styles of bootstrap table.</p>
+                data-es="Use las opciones <code>height</code>, <code>classes</code>, <code>striped</code>, <code>rowStyle</code> y las opciones de columnas <code>class</code>, <code>width</code>, <code>cellStyle</code> para setear los estilos de bootstrap table.">Use <code>height</code>, <code>classes</code>, <code>striped</code>, <code>rowStyle</code> options and <code>class</code>, <code>width</code>, <code>cellStyle</code> column options to set the styles of bootstrap table.</p>
                 <div class="bs-example">
                     <div>
                         <label><input id="hover" type="checkbox" checked> hover</label>

+ 2 - 0
docs/jsfiddle-examples.md

@@ -3,3 +3,5 @@
 * Nested data: [http://jsfiddle.net/8svjf80g/3/](http://jsfiddle.net/8svjf80g/3/)
 * Multiple Fields in Column: [http://jsfiddle.net/a9a4yxqw/1/](http://jsfiddle.net/a9a4yxqw/1/)
 * Remove row data use modal: [http://jsfiddle.net/1314arL3/1/](http://jsfiddle.net/1314arL3/1/)
+* JSONP data: [http://jsfiddle.net/wenyi/8svjf80g/33/](http://jsfiddle.net/wenyi/8svjf80g/33/)
+* Custom scrollbar: [http://plnkr.co/edit/IHnFAiVh0gfcmBdy05Mt?p=preview](http://plnkr.co/edit/IHnFAiVh0gfcmBdy05Mt?p=preview)

+ 13 - 3
src/bootstrap-table.js

@@ -425,16 +425,26 @@
 
         if (index !== -1) {
             this.data.sort(function (a, b) {
-                var value = calculateObjectValue(that.header, that.header.sorters[index], [a[name], b[name]]);
+                var aa = a[name],
+                    bb = b[name],
+                    value = calculateObjectValue(that.header, that.header.sorters[index], [aa, bb]);
 
                 if (value !== undefined) {
                     return order * value;
                 }
 
-                if (a[name] === b[name]) {
+                // Fix #161: undefined or null string sort bug.
+                if (aa === null) {
+                    aa = '';
+                }
+                if (bb === null) {
+                    bb = '';
+                }
+
+                if (aa === bb) {
                     return 0;
                 }
-                if (a[name] < b[name]) {
+                if (aa < bb) {
                     return order * -1;
                 }
                 return order;

+ 14 - 6
src/locale/bootstrap-table-ru-RU.js

@@ -1,25 +1,33 @@
 /**
  * Bootstrap Table Russian translation
- * Author: gnhaku <hello@gnhaku.me>
+ * Author: Dunaevsky Maxim <dunmaksim@yandex.ru>
  */
 (function ($) {
     'use strict';
-
     $.extend($.fn.bootstrapTable.defaults, {
         formatLoadingMessage: function () {
-            return 'Пожалуйста подождите, идет загрузка…';
+            return 'Пожалуйста, подождите, идёт загрузка...';
         },
         formatRecordsPerPage: function (pageNumber) {
-            return pageNumber + ' записей на странице';
+            return pageNumber + ' записей на страницу';
         },
         formatShowingRows: function (pageFrom, pageTo, totalRows) {
-            return 'Показаны записи с ' + pageFrom + ' по ' + pageTo + ' из ' + totalRows;
+            return 'Записи с ' + pageFrom + ' по ' + pageTo + ' из ' + totalRows;
         },
         formatSearch: function () {
             return 'Поиск';
         },
         formatNoMatches: function () {
-            return 'Записи не найдены';
+            return 'Ничего не найдено';
+        },
+        formatRefresh: function () {
+            return 'Обновить';
+        },
+        formatToggle: function () {
+            return 'Переключить';
+        },
+        formatColumns: function () {
+            return 'Колонки';
         }
     });
 })(jQuery);