added jquery.filterTable

This commit is contained in:
TotPeRo
2017-08-23 19:42:25 +03:00
parent abbc84feee
commit d0e48fb748
3 changed files with 183 additions and 0 deletions
+144
View File
@@ -0,0 +1,144 @@
/// <reference path="../jquery/jquery.d.ts" />
// Type definitions for jquery.filterTable v1.5.7
// Project: https://github.com/sunnywalker/jQuery.FilterTable
// Definitions by: TotPeRo <https://github.com/totpero/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace FilterTable {
interface FilterTableOptions {
/**
* Makes the filter input field autofocused (not recommended for accessibility reasons)
* Default: 'false'
*/
autofocus?: boolean;
/**
* Callback function after a filter is performed.
* Default: 'null'
* @param term filter term (string)
* @param table table being filtered (jQuery object)
* @returns {void}
*/
callback?: (term, table) => void;
/**
* Class applied to the main filter input container
* Default: 'filter-table'
*/
containerClass?: string;
/**
* Tag name of the main filter input container
* Default: 'p'
*/
containerTag?: string;
/**
* Controls whether the table's tfoot(s) will be hidden when the table is filtered
* Default: 'false'
*/
hideTFootOnFilter?: boolean;
/**
* Class applied to cells containing the filter term
* Default: 'alt'
*/
highlightClass?: string;
/**
* Ignore these columns (0-indexed) when filtering
* Default: '[]'
*/
ignoreColumns?: number[];
/**
* Use this selector to find the filter input instead of creating a new one (only works if selector returns a single element)
* Default: 'null'
*/
inputSelector?: string;
/**
* Name attribute of the filter input field
* Default: 'filter-table'
*/
inputName?: string;
/**
* Tag name of the filter input itself
* Default: 'search'
*/
inputType?: string;
/**
* Text to precede the filter input
* Default: 'Filter:'
*/
label?: string;
/**
* Filter only when at least this number of characters are in the filter input field
* Default: '1'
*/
minChars?: number;
/**
* Only show the filter on tables with this number of rows or more
* Default: '8'
*/
minRows?: number;
/**
* HTML5 placeholder text for the filter input
* Default: 'search this table'
*/
placeholder?: string;
/**
* Trap the return key in the filter input field to prevent form submission
* Default: 'true'
*/
preventReturnKey?: boolean;
/**
* List of clickable phrases to quick fill the search
* Default: '[]'
*/
quickList?: string[];
/**
* Class of each quick list item
* Default: 'quick'
*/
quickListClass?: string;
/**
* Label for the clear filtering quick list item (or none if blank)
* Default: ''
*/
quickListClear?: string;
/**
* Tag name surrounding quick list items (e.g., ul)
* Default: ''
*/
quickListGroupTag?: string;
/**
* Tag name of each quick list item (e.g., a or li)
* Default: 'a'
*/
quickListTag?: string; // "a" | "li"
/**
* Class applied to visible rows
* Default: 'visible'
*/
visibleClass?: string;
}
interface FilterTableStatic {
/**
* init with default options
* @returns {JQuery}
*/
(): JQuery;
/**
* init with custom options
* @param options
* @returns {JQuery}
*/
(options: FilterTableOptions): JQuery;
}
}
interface JQuery {
/**
* if this code appears after your tables; otherwise, include it in your document.ready() code.
* $('table').filterTable()
*/
filterTable: FilterTable.FilterTableStatic;
}
@@ -0,0 +1,16 @@
//import $ = require('jquery');
$(() => {
// examples from http://sunnywalker.github.io/jQuery.FilterTable/
$('table').filterTable();
$('table').filterTable({ quickList: ['class', 'tag'] });
$('table').filterTable({
callback(term, table) {
table.find('tr').removeClass('striped').filter(':visible:even').addClass('striped');
}
});
});
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jquery.filtertable-tests.ts"
]
}