From f3498ff5af6afdd9c201c9b0ce7987fd26604b94 Mon Sep 17 00:00:00 2001 From: Kyo Nagashima Date: Fri, 5 Jun 2009 14:12:40 +0900 Subject: [PATCH] initial commit --- jquery.table-filter.js | 89 ++++++++++++++++++++++++++++ test.html | 128 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 217 insertions(+) create mode 100644 jquery.table-filter.js create mode 100644 test.html diff --git a/jquery.table-filter.js b/jquery.table-filter.js new file mode 100644 index 0000000..c2e8be7 --- /dev/null +++ b/jquery.table-filter.js @@ -0,0 +1,89 @@ +/** + * jQuery Plugin: Table Filter - version 0.1.1 + * Insert a input form for filtering rows dinamically. + * + * Copyright (c) 2009 Kyo Nagashima + * This library licensed under MIT license: + * http://opensource.org/licenses/mit-license.php + * + * Usage: + * Insert to all table + * $("table").addTableFilter(); + * + * Insert to "#table1" only + * $("#table1").addTableFilter(); + * + * Insert with custom label text and size + * $("table").addTableFilter({ + * labelText: "Filtering Words: ", + * size: 48 + * }); + * + * Styling: + * You can style inserted elements like this: + * .formTableFilter { + * text-align: right; + * } + * + * .formTableFilter label { + * font-weight: bold; + * } + * + * .formTableFilter input { + * border: 1px solod #999999; + * width: 12em; + * color: #ffffff; + * background-color: #333333; + * } + */ + +(function($) { + $.fn.addTableFilter = function (options) { + var o = $.extend({}, $.fn.addTableFilter.defaults, options); + + if (this.is("table")) { + // Generate ID + if (!this.attr("id")) { + this.attr({ + id: "t-" + Math.floor(Math.random() * 99999999) + }); + } + var tgt = this.attr("id"); + var id = tgt + "-filtering"; + + // Build filtering form + var label = $("