1
0
Fork 0
mirror of https://github.com/evilhero/mylar synced 2024-12-23 08:12:41 +00:00

Update dataTables.alphabetSearch.min.js

IMP: Change handling of non-alphanumeric characters to be included in the "#" category
This commit is contained in:
barbequesauce 2018-07-17 11:17:16 -04:00 committed by evilhero
parent ad64c31b36
commit 0461fb73c5

View file

@ -8,7 +8,7 @@
$.fn.dataTable.ext.search.push(function(context, searchData) { if (!context.hasOwnProperty("alphabetSearch")) { return true; } if (!context.alphabetSearch.letterSearch) { return true; } var letter = searchData[context.alphabetSearch.column].toString() $.fn.dataTable.ext.search.push(function(context, searchData) { if (!context.hasOwnProperty("alphabetSearch")) { return true; } if (!context.alphabetSearch.letterSearch) { return true; } var letter = searchData[context.alphabetSearch.column].toString()
.replace(/<.*?>/g, "") .replace(/<.*?>/g, "")
.charAt(0) .charAt(0)
.toUpperCase(); if (context.alphabetSearch.letterSearch !== "#") { if (letter === context.alphabetSearch.letterSearch) { return true; } } else { if (/\d/.test(letter)) { return true; } } return false; }); .toUpperCase(); if (context.alphabetSearch.letterSearch !== "#") { if (letter === context.alphabetSearch.letterSearch) { return true; } } else { if (/[^a-zA-Z]/.test(letter)) { return true; } } return false; });
$.fn.dataTable.ext.order["alphabetSearch"] = function(context, col) { var order_col = this.api() $.fn.dataTable.ext.order["alphabetSearch"] = function(context, col) { var order_col = this.api()
.order()[0][0]; var order_method = this.api() .order()[0][0]; var order_method = this.api()
.order()[0][1]; if (order_col !== context.alphabetSearch.column) { context.alphabetSearch.pass = 0; } var data = this.api() .order()[0][1]; if (order_col !== context.alphabetSearch.column) { context.alphabetSearch.pass = 0; } var data = this.api()
@ -21,7 +21,7 @@
function bin(data) { var letter, bins = {}; for (var i = 0, ien = data.length; i < ien; i++) { letter = data[i].toString() function bin(data) { var letter, bins = {}; for (var i = 0, ien = data.length; i < ien; i++) { letter = data[i].toString()
.replace(/<.*?>/g, "") .replace(/<.*?>/g, "")
.charAt(0) .charAt(0)
.toUpperCase(); if (/\d/.test(letter)) { letter = "#"; } if (bins[letter]) { bins[letter]++; } else { bins[letter] = 1; } } return bins; } .toUpperCase(); if (/[^a-zA-Z]/.test(letter)) { letter = "#"; } if (bins[letter]) { bins[letter]++; } else { bins[letter] = 1; } } return bins; }
function draw(table, alphabet, context) { alphabet.empty(); if (context.oLanguage.alphabetSearch.infoDisplay !== "") { $('<span class="alphabet-info-display"></span>') function draw(table, alphabet, context) { alphabet.empty(); if (context.oLanguage.alphabetSearch.infoDisplay !== "") { $('<span class="alphabet-info-display"></span>')
.html(context.oLanguage.alphabetSearch.infoDisplay) .html(context.oLanguage.alphabetSearch.infoDisplay)