Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #64 from zakame/smarter-search-field
Make module search box a bit smarter
  • Loading branch information
zoffixznet committed Oct 31, 2016
2 parents 9fa5ea3 + e1d7c00 commit 5bdb297
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
27 changes: 27 additions & 0 deletions assets/js/dataTables.filter.perlModule.js
@@ -0,0 +1,27 @@
/**
* This filtering plugin will allow matching of module names in either
* form of 'Foo::Bar', or 'Foo-Bar'.
*
* Based on dataTables.filter.phoneNumber.js
*
* @summary Make Perl module names searchable
* @name Perl module
* @author Zak B. Elep
*
* @example
* $(document).ready(function() {
* $('#example').dataTable({
* columDefs: [
* { type: 'perlModule', target: 1 }
* ]
* });
* });
*/

jQuery.fn.DataTable.ext.type.search.perlModule = function(data) {
return !data ?
'' :
typeof data === 'string' ?
data + data.replace(/::/g, '-') :
data;
};
4 changes: 4 additions & 0 deletions assets/js/main.js
Expand Up @@ -43,6 +43,10 @@ function setup_table() {
scrollX: false,
info: false,
columnDefs: [
{
targets: [ 0, 1 ],
type: "perlModule"
},
{
targets: [ 2, 3, 4, 5 ],
searchable: false
Expand Down
1 change: 1 addition & 0 deletions lib/ModulesPerl6.pm
Expand Up @@ -53,6 +53,7 @@ sub startup {
$self->asset->process('app.js' => qw{
https://code.jquery.com/jquery-1.11.3.min.js
https://cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js
/js/dataTables.filter.perlModule.js
/js/jquery-deparam.js
/js/main.js
});
Expand Down

0 comments on commit 5bdb297

Please sign in to comment.