You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Plugins/sorting/alt-string.js

58 lines
1.4 KiB
JavaScript

/*! © SpryMedia Ltd, Jumpy - datatables.net/license */
(function( factory ){
if ( typeof define === 'function' && define.amd ) {
// AMD
define( ['datatables.net'], function ( $ ) {
return factory( $, window, document );
} );
}
else if ( typeof exports === 'object' ) {
// CommonJS
module.exports = function (root, $) {
if ( ! root ) {
// CommonJS environments without a window global must pass a
// root. This will give an error otherwise
root = window;
}
if ( ! $.fn.dataTable ) {
require('datatables.net')(root, $);
}
return factory( $, root, root.document );
};
}
else {
// Browser
factory( jQuery, window, document );
}
}(function( $, window, document, undefined ) {
'use strict';
var DataTable = $.fn.dataTable;
/**
* Sort on the 'alt' tag of images in a column. This is particularly useful if
* you have a column of images (ticks and crosses for example) and you want to
* control the sorting using the alt tag.
*
* @name Alt string
* @summary Use the `alt` attribute of an image tag as the data to sort upon.
* @author _Jumpy_
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'alt-string', targets: 0 }
* ]
* } );
*/
DataTable.ext.order['alt-string-pre'] = function (a) {
return a.match(/alt="(.*?)"/)[1].toLowerCase();
};
return DataTable;
}));