Browse Source

Removed natural-sorting extension (#4692)

文翼 6 years ago
parent
commit
e3f5dae40c

+ 1 - 0
CHANGELOG.md

@@ -7,6 +7,7 @@ ChangeLog
 - **New:** Added `printFormatter` data-attribute supported for print extension.
 - **New:** Added `customSort` option supported for group-by extension.
 - **New:** Added `orderColumns` method for reorder-columns extension.
+- **Remove:** Removed natural-sorting extension.
 - **Update:** Updated event name to lowercase hyphen format for vue component.
 - **Update:** Improved the `resize` problem with multiple tables.
 - **Update:** Improved `number` type supported for group-by extension.

+ 0 - 1
site/_data/nav.yml

@@ -32,7 +32,6 @@
     - title: Key Events
     - title: Mobile
     - title: Multiple Sort
-    - title: Natural Sorting
     - title: Page Jump To
     - title: Print
     - title: Reorder Columns

+ 0 - 34
site/docs/extensions/natural-sorting.md

@@ -1,34 +0,0 @@
----
-layout: docs
-title: Table Natural Sorting
-description: Table Natural Sorting extension of Bootstrap Table.
-group: extensions
-toc: true
----
-
-## Usage
-
-{% highlight html %}
-<script src="extensions/natural-sorting/bootstrap-table-natural-sorting.js"></script>
-{% endhighlight %}
-
-add a data-sorter atribute to any th.
-*e.g.*
-
-{% highlight html %}
-<th data-sortable="true" data-sorter="alphanum">Price</th>
-{% endhighlight %}
-
-## Options
-
-### alphanum
-* sort alpha or numeric content naturally.
-* This can be used in columns that contain text or numeric content.
-* Numbers will be sorted as expected and not in ASCII order
-
-### numericOnly
-* extract numeric content and sort numerically.
-* This can be used in columns that contain formated numeric content.
-*  *e.g.* $ and , will be removed, then Numbers will be sorted as expected
-* an alpha sort crrently sorts these as ASCII so you get $1, $100, $2, $20
-  instead of $1, $2, $20, $100.

+ 0 - 71
src/extensions/natural-sorting/bootstrap-table-natural-sorting.js

@@ -1,71 +0,0 @@
-/**
- * @author: Brian Huisman
- * @webSite: http://www.greywyvern.com
- * JS functions to allow natural sorting on bootstrap-table columns
- * add data-sorter="alphanum" or data-sorter="numericOnly" to any th
- *
- * @update Dennis Hernández <http://djhvscf.github.io/Blog>
- * @update Duane May
- */
-
-function alphanum (a, b) {
-  function chunkify (t) {
-    const tz = []
-    let y = -1
-    let n = 0
-
-    for (let i = 0; i <= t.length; i++) {
-      const char = t.charAt(i)
-      const charCode = char.charCodeAt(0)
-      const m = (charCode === 46 || (charCode >= 48 && charCode <= 57))
-      if (m !== n) {
-        tz[++y] = ''
-        n = m
-      }
-      tz[y] += char
-    }
-
-    return tz
-  }
-
-  function stringfy (v) {
-    if (typeof(v) === 'number') {
-      v = `${v}`
-    }
-    if (!v) {
-      v = ''
-    }
-    return v
-  }
-
-  const aa = chunkify(stringfy(a))
-  const bb = chunkify(stringfy(b))
-
-  for (let x = 0; aa[x] && bb[x]; x++) {
-    if (aa[x] !== bb[x]) {
-      const c = Number(aa[x])
-      const d = Number(bb[x])
-
-      if (c === aa[x] && d === bb[x]) {
-        return c - d
-      }
-      return (aa[x] > bb[x]) ? 1 : -1
-
-    }
-  }
-  return aa.length - bb.length
-}
-
-function numericOnly (a, b) {
-  function stripNonNumber (s) {
-    s = s.replace(new RegExp(/[^0-9]/g), '')
-    return parseInt(s, 10)
-  }
-
-  return stripNonNumber(a) - stripNonNumber(b)
-}
-
-export default {
-  alphanum,
-  numericOnly
-}

+ 0 - 17
src/extensions/natural-sorting/extension.json

@@ -1,17 +0,0 @@
-{
-  "name": "Natural Sorting",
-  "version": "1.0.0",
-  "description": "Plugin to support the natural sorting.",
-  "url": "https://github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/natural-sorting",
-  "example": "#",
-
-  "plugins": [{
-    "name": "bootstrap-table-natural-sorting",
-    "url": "https://github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/natural-sorting"
-  }],
-
-  "author": {
-    "name": "GreyWyvern",
-    "image": "https://avatars1.githubusercontent.com/u/137631"
-  }
-}