|
|
@ -49,12 +49,20 @@ $.fn.dataTable.ext.search.push( function ( context, searchData ) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($.fn.dataTable.AlphabetSearch.caseSensitive) {
|
|
|
|
if (context.oInit.alphabet !== undefined) {
|
|
|
|
if ( searchData[$.fn.dataTable.AlphabetSearch.column].charAt(0) === context.alphabetSearch ) {
|
|
|
|
var columnId = (context.oInit.alphabet.column !== undefined) ? context.oInit.alphabet.column : 0
|
|
|
|
|
|
|
|
var caseSensitive = (context.oInit.alphabet.caseSensitive !== undefined) ? context.oInit.alphabet.caseSensitive : false
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
var columnId = 0
|
|
|
|
|
|
|
|
var caseSensitive = false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (caseSensitive) {
|
|
|
|
|
|
|
|
if ( searchData[columnId].charAt(0) === context.alphabetSearch ) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if ( searchData[$.fn.dataTable.AlphabetSearch.column].charAt(0).toUpperCase() === context.alphabetSearch ) {
|
|
|
|
if ( searchData[columnId].charAt(0).toUpperCase() === context.alphabetSearch ) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -64,11 +72,11 @@ $.fn.dataTable.ext.search.push( function ( context, searchData ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Private support methods
|
|
|
|
// Private support methods
|
|
|
|
function bin ( data ) {
|
|
|
|
function bin ( data, options ) {
|
|
|
|
var letter, bins = {};
|
|
|
|
var letter, bins = {};
|
|
|
|
|
|
|
|
|
|
|
|
for ( var i=0, ien=data.length ; i<ien ; i++ ) {
|
|
|
|
for ( var i=0, ien=data.length ; i<ien ; i++ ) {
|
|
|
|
if ($.fn.dataTable.AlphabetSearch.caseSensitive) {
|
|
|
|
if (options.caseSensitive) {
|
|
|
|
letter = data[i]
|
|
|
|
letter = data[i]
|
|
|
|
.toString()
|
|
|
|
.toString()
|
|
|
|
.replace(/<.*?>/g, '')
|
|
|
|
.replace(/<.*?>/g, '')
|
|
|
@ -90,13 +98,13 @@ function bin ( data ) {
|
|
|
|
return bins;
|
|
|
|
return bins;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function draw ( table, alphabet )
|
|
|
|
function draw ( table, alphabet, options )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
alphabet.empty();
|
|
|
|
alphabet.empty();
|
|
|
|
alphabet.append( 'Search: ' );
|
|
|
|
alphabet.append( 'Search: ' );
|
|
|
|
|
|
|
|
|
|
|
|
var columnData = table.column($.fn.dataTable.AlphabetSearch.column).data();
|
|
|
|
var columnData = table.column(options.column).data();
|
|
|
|
var bins = bin( columnData );
|
|
|
|
var bins = bin( columnData, options );
|
|
|
|
|
|
|
|
|
|
|
|
$('<span class="clear active"/>')
|
|
|
|
$('<span class="clear active"/>')
|
|
|
|
.data( 'letter', '' )
|
|
|
|
.data( 'letter', '' )
|
|
|
@ -104,7 +112,7 @@ function draw ( table, alphabet )
|
|
|
|
.html( 'None' )
|
|
|
|
.html( 'None' )
|
|
|
|
.appendTo( alphabet );
|
|
|
|
.appendTo( alphabet );
|
|
|
|
|
|
|
|
|
|
|
|
if ($.fn.dataTable.AlphabetSearch.addNumbers) {
|
|
|
|
if (options.numbers) {
|
|
|
|
for (var i = 0; i < 10; i++) {
|
|
|
|
for (var i = 0; i < 10; i++) {
|
|
|
|
var letter = String.fromCharCode(48 + i);
|
|
|
|
var letter = String.fromCharCode(48 + i);
|
|
|
|
|
|
|
|
|
|
|
@ -126,7 +134,7 @@ function draw ( table, alphabet )
|
|
|
|
.html( letter )
|
|
|
|
.html( letter )
|
|
|
|
.appendTo( alphabet );
|
|
|
|
.appendTo( alphabet );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($.fn.dataTable.AlphabetSearch.caseSensitive === true) {
|
|
|
|
if (options.caseSensitive) {
|
|
|
|
for (var i = 0; i < 26; i++) {
|
|
|
|
for (var i = 0; i < 26; i++) {
|
|
|
|
var letter = String.fromCharCode(97 + i);
|
|
|
|
var letter = String.fromCharCode(97 + i);
|
|
|
|
|
|
|
|
|
|
|
@ -147,8 +155,13 @@ function draw ( table, alphabet )
|
|
|
|
$.fn.dataTable.AlphabetSearch = function ( context ) {
|
|
|
|
$.fn.dataTable.AlphabetSearch = function ( context ) {
|
|
|
|
var table = new $.fn.dataTable.Api( context );
|
|
|
|
var table = new $.fn.dataTable.Api( context );
|
|
|
|
var alphabet = $('<div class="alphabet"/>');
|
|
|
|
var alphabet = $('<div class="alphabet"/>');
|
|
|
|
|
|
|
|
var options = $.extend({
|
|
|
|
|
|
|
|
column: 0,
|
|
|
|
|
|
|
|
caseSensitive: false,
|
|
|
|
|
|
|
|
numbers: false
|
|
|
|
|
|
|
|
}, table.init().alphabet);
|
|
|
|
|
|
|
|
|
|
|
|
draw( table, alphabet );
|
|
|
|
draw( table, alphabet, options );
|
|
|
|
|
|
|
|
|
|
|
|
// Trigger a search
|
|
|
|
// Trigger a search
|
|
|
|
alphabet.on( 'click', 'span', function () {
|
|
|
|
alphabet.on( 'click', 'span', function () {
|
|
|
@ -185,7 +198,6 @@ $.fn.dataTable.AlphabetSearch = function ( context ) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
$.fn.DataTable.AlphabetSearch = $.fn.dataTable.AlphabetSearch;
|
|
|
|
$.fn.DataTable.AlphabetSearch = $.fn.dataTable.AlphabetSearch;
|
|
|
|
$.fn.dataTable.AlphabetSearch.column = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Register a search plug-in
|
|
|
|
// Register a search plug-in
|
|
|
|
$.fn.dataTable.ext.feature.push( {
|
|
|
|
$.fn.dataTable.ext.feature.push( {
|
|
|
|