corrade-nucleus-nucleons

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 19  →  ?path2? @ 20
/pack-rat/003_pack_rat/pack-rat/node_modules/bootstrap-table/src/extensions/natural-sorting/README.md
@@ -0,0 +1,27 @@
# Table Natural Sorting
 
Use Plugin: [bootstrap-table-natural-sorting](https://github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/natural-sorting)
 
## Usage
 
```html
<script src="extensions/natural-sorting/bootstrap-table-natural-sorting.js"></script>
```
 
add a data-sorter atribute to any th.
*e.g.* ``` <th data-sortable="true" data-sorter="alphanum">Price</th>```
 
## 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.
 
/pack-rat/003_pack_rat/pack-rat/node_modules/bootstrap-table/src/extensions/natural-sorting/bootstrap-table-natural-sorting.js
@@ -0,0 +1,67 @@
/**
* @author: Brian Huisman
* @webSite: http://www.greywyvern.com
* @version: v1.0.0
* 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) {
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;
}
 
function stringfy(v) {
if (typeof(v) === "number") {
v = "" + v;
}
if (!v) {
v = "";
}
return v;
}
 
var aa = chunkify(stringfy(a));
var bb = chunkify(stringfy(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;
}
 
function numericOnly(a, b) {
function stripNonNumber(s) {
s = s.replace(new RegExp(/[^0-9]/g), "");
return parseInt(s, 10);
}
 
return stripNonNumber(a) - stripNonNumber(b);
}
/pack-rat/003_pack_rat/pack-rat/node_modules/bootstrap-table/src/extensions/natural-sorting/extension.json
@@ -0,0 +1,17 @@
{
"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"
}
}