ソースを参照

Merge branch 'master' of https://github.com/djhvscf/bootstrap-table

Dennis Hernández 10 年 前
コミット
2532bab302

+ 13 - 0
src/extensions/naturalsorting/README.md

@@ -0,0 +1,13 @@
+# Table Natural Sorting
+
+Use Plugin: [bootstrap-table-naturalsorting](https://github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/naturalsorting)
+
+## Usage
+
+```html
+<script src="extensions/naturalsorting/bootstrap-table-naturalsorting.js"></script>
+```
+
+### Options
+
+* Just add data-sorter="alphanum" to any th

+ 47 - 0
src/extensions/naturalsorting/bootstrap-table-naturalsorting.js

@@ -0,0 +1,47 @@
+/**
+ * @author: Brian Huisman
+ * @webSite: http://www.greywyvern.com
+ * @version: v1.0.0
+ * JS function to allow natural sorting on bootstrap-table columns
+ * just add data-sorter="alphanum" to any th
+ *
+ * @update Dennis Hernández <http://djhvscf.github.io/Blog>
+ */
+
+function alphanum(a, b) {
+  function chunkify(t) {
+    var tz = [],
+        x = 0,
+        y = -1,
+        n = 0,
+        i,
+        j;
+
+    while (i = (j = t.charAt(x++)).charCodeAt(0)) {
+      var m = (i === 46 || (i >= 48 && i <= 57));
+      if (m !== n) {
+        tz[++y] = "";
+        n = m;
+      }
+      tz[y] += j;
+    }
+    return tz;
+  }
+
+  var aa = chunkify(a);
+  var bb = chunkify(b);
+
+  for (x = 0; aa[x] && bb[x]; x++) {
+    if (aa[x] !== bb[x]) {
+      var c = Number(aa[x]),
+          d = Number(bb[x]);
+
+      if (c == aa[x] && d == bb[x]) {
+        return c - d;
+      } else {
+          return (aa[x] > bb[x]) ? 1 : -1;
+      }
+    }
+  }
+  return aa.length - bb.length;
+}

+ 0 - 32
src/extensions/sorting/bootstrap-table_natural-sorting.js

@@ -1,32 +0,0 @@
-//JS function to allow natural sorting on bootstrap-table columns
-//just add data-sorter="alphanum" to any th
-//Thanks to Brian Huisman: http://www.greywyvern.com
-
-function alphanum(a, b) {
-  function chunkify(t) {
-    var tz = [], x = 0, y = -1, n = 0, i, j;
-
-    while (i = (j = t.charAt(x++)).charCodeAt(0)) {
-      var m = (i == 46 || (i >=48 && i <= 57));
-      if (m !== n) {
-        tz[++y] = "";
-        n = m;
-      }
-      tz[y] += j;
-    }
-    return tz;
-  }
-
-  var aa = chunkify(a);
-  var bb = chunkify(b);
-
-  for (x = 0; aa[x] && bb[x]; x++) {
-    if (aa[x] !== bb[x]) {
-      var c = Number(aa[x]), d = Number(bb[x]);
-      if (c == aa[x] && d == bb[x]) {
-        return c - d;
-      } else return (aa[x] > bb[x]) ? 1 : -1;
-    }
-  }
-  return aa.length - bb.length;
-}