diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ad02dbd86..8dd8b1f5b1 100644 --- a/CHANGELOG.md +++ b/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. diff --git a/site/_data/nav.yml b/site/_data/nav.yml index 83e5a4ce51..4fef09004a 100644 --- a/site/_data/nav.yml +++ b/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 diff --git a/site/docs/extensions/natural-sorting.md b/site/docs/extensions/natural-sorting.md deleted file mode 100644 index 324526ce04..0000000000 --- a/site/docs/extensions/natural-sorting.md +++ /dev/null @@ -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 %} - -{% endhighlight %} - -add a data-sorter atribute to any th. -*e.g.* - -{% highlight html %} -Price -{% 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. diff --git a/src/extensions/natural-sorting/bootstrap-table-natural-sorting.js b/src/extensions/natural-sorting/bootstrap-table-natural-sorting.js deleted file mode 100644 index 97c5084450..0000000000 --- a/src/extensions/natural-sorting/bootstrap-table-natural-sorting.js +++ /dev/null @@ -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 - * @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 -} diff --git a/src/extensions/natural-sorting/extension.json b/src/extensions/natural-sorting/extension.json deleted file mode 100644 index 06bf4e4ece..0000000000 --- a/src/extensions/natural-sorting/extension.json +++ /dev/null @@ -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" - } -} \ No newline at end of file