mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-29 17:42:12 +08:00
UI, utils: modularize (AMD) naturalSort and move to utils
This commit is contained in:
@@ -207,33 +207,6 @@ function make_popup_menus( parent ) {
|
||||
});
|
||||
}
|
||||
|
||||
// Alphanumeric/natural sort fn
|
||||
function naturalSort(a, b) {
|
||||
// setup temp-scope variables for comparison evauluation
|
||||
var re = /(-?[0-9\.]+)/g,
|
||||
x = a.toString().toLowerCase() || '',
|
||||
y = b.toString().toLowerCase() || '',
|
||||
nC = String.fromCharCode(0),
|
||||
xN = x.replace( re, nC + '$1' + nC ).split(nC),
|
||||
yN = y.replace( re, nC + '$1' + nC ).split(nC),
|
||||
xD = (new Date(x)).getTime(),
|
||||
yD = xD ? (new Date(y)).getTime() : null;
|
||||
// natural sorting of dates
|
||||
if ( yD ) {
|
||||
if ( xD < yD ) { return -1; }
|
||||
else if ( xD > yD ) { return 1; }
|
||||
}
|
||||
// natural sorting through split numeric strings and default strings
|
||||
var oFxNcL, oFyNcL;
|
||||
for ( var cLoc = 0, numS = Math.max(xN.length, yN.length); cLoc < numS; cLoc++ ) {
|
||||
oFxNcL = parseFloat(xN[cLoc]) || xN[cLoc];
|
||||
oFyNcL = parseFloat(yN[cLoc]) || yN[cLoc];
|
||||
if (oFxNcL < oFyNcL) { return -1; }
|
||||
else if (oFxNcL > oFyNcL) { return 1; }
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
$.fn.refresh_select2 = function() {
|
||||
var select_elt = $(this);
|
||||
var options = { placeholder:'Click to select',
|
||||
|
||||
Reference in New Issue
Block a user