pull/161/merge
Mohammad Javad Naderi 9 years ago committed by GitHub
commit 1e8b2fa65f

@ -6,6 +6,7 @@
* @name Persian * @name Persian
* @summary Sort Persian strings alphabetically * @summary Sort Persian strings alphabetically
* @author [Afshin Mehrabani](http://www.afshinblog.com/) * @author [Afshin Mehrabani](http://www.afshinblog.com/)
* @author [Mohammad Javad Naderi](https://github.com/mjnaderi)
* *
* @example * @example
* $('#example').dataTable( { * $('#example').dataTable( {
@ -26,25 +27,27 @@ function GetUniCode(source) {
var i, index; var i, index;
for (i = 0; i < source.length; i++) { for (i = 0; i < source.length; i++) {
//Check and fix IE indexOf bug //Check and fix IE indexOf bug
if (!Array.indexOf) { if (!Array.indexOf)
index = jQuery.inArray(source.charAt(i), persianSort); index = jQuery.inArray(source.charAt(i), persianSort);
}else{ else
index = persianSort.indexOf(source.charAt(i)); index = persianSort.indexOf(source.charAt(i));
}
if (index < 0) { if (index < 0)
index = source.charCodeAt(i); index = source.charCodeAt(i) + 40;
}
if (index < 10) { if (index < 10)
index = '00' + index;
else if (index < 100)
index = '0' + index; index = '0' + index;
}
result += '00' + index; result += index;
} }
return 'a' + result; return 'a' + result;
} }
jQuery.extend(jQuery.fn.dataTableExt.oSort, { jQuery.extend(jQuery.fn.dataTableExt.oSort, {
"pstring-pre": function (a) { "pstring-pre": function (a) {
return GetUniCode(a.toLowerCase()); return GetUniCode($(a.toLowerCase()).text());
}, },
"pstring-asc": function (a, b) { "pstring-asc": function (a, b) {

Loading…
Cancel
Save