1/** 2 * This sorting type will replace DataTables' default string sort with one that 3 * will use a locale aware collator. This is supported by IE11, Edge, Chrome, 4 * Firefox and Safari 10+. Any browser that does not support the Intl will 5 * simply fall back to UTF8 string sorting. 6 * 7 * This method simply needs to be called prior to the DataTables' initialisation 8 * to replace the default string sort with locale aware sorting. The method 9 * optionally takes two arguments: 10 * 11 * 1. [Optional] Locale or array of locales 12 * 2. [Optional] Collator options 13 * 14 * For the supported options please see the 15 * [MDN Intl documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator). 16 * 17 * @name intl 18 * @summary Sort string data using the Intl Javascript API 19 * @author [Allan Jardine](//datatables.net) 20 * @depends DataTables 1.10+ 21 * 22 * @example 23 * // Host's current locale 24 * jQuery.fn.dataTable.ext.order.intl(); 25 * 26 * @example 27 * // Explicit locale 28 * jQuery.fn.dataTable.ext.order.intl('de-u-co-phonebk'); 29 * 30 * @example 31 * // Locale with configuration options 32 * jQuery.fn.dataTable.ext.order.intl('fr', { 33 * sensitivity: 'base' 34 * } ); 35 */ 36 37 38// UMD 39(function( factory ) { 40 "use strict"; 41 42 if ( typeof define === 'function' && define.amd ) { 43 // AMD 44 define( ['jquery'], function ( $ ) { 45 return factory( jQuery, window, document ); 46 } ); 47 } 48 else if ( typeof exports === 'object' ) { 49 // CommonJS 50 module.exports = function (root, jQuery) { 51 if ( ! root ) { 52 root = window; 53 } 54 55 if ( ! jQuery ) { 56 jQuery = typeof window !== 'undefined' ? 57 require('jquery') : 58 require('jquery')( root ); 59 } 60 61 return factory( jQuery, root, root.document ); 62 }; 63 } 64 else { 65 // Browser 66 factory( jQuery, window, document ); 67 } 68} 69(function( jQuery, window, document ) { 70 71 72jQuery.fn.dataTable.ext.order.intl = function ( locales, options ) { 73 if ( window.Intl ) { 74 var collator = new Intl.Collator( locales, options ); 75 var types = jQuery.fn.dataTable.ext.type; 76 77 delete types.order['string-pre']; 78 types.order['string-asc'] = collator.compare; 79 types.order['string-desc'] = function ( a, b ) { 80 return collator.compare( a, b ) * -1; 81 }; 82 } 83}; 84 85 86}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.