Skip to content

Commit 7730b58

Browse files
committed
Format the JS file
1 parent 8a07c3d commit 7730b58

File tree

1 file changed

+31
-39
lines changed

1 file changed

+31
-39
lines changed

jquery.uitablefilter.js

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -20,79 +20,72 @@
2020
* array of columns to limit search too (the column title in the table header)
2121
* ifHidden - callback to execute if one or more elements was hidden
2222
*/
23-
(function($) {
24-
$.uiTableFilter = function(jq, phrase, column, ifHidden){
23+
(function ($) {
24+
$.uiTableFilter = function (jq, phrase, column, ifHidden) {
2525
var new_hidden = false;
26-
if( this.last_phrase === phrase ) return false;
26+
if (this.last_phrase === phrase) return false;
2727

2828
var phrase_length = phrase.length;
2929
var words = phrase.toLowerCase().split(" ");
3030

3131
// these function pointers may change
32-
var matches = function(elem) { elem.show() }
33-
var noMatch = function(elem) { elem.hide(); new_hidden = true }
34-
var getText = function(elem) { return elem.text() }
32+
var matches = function (elem) { elem.show() }
33+
var noMatch = function (elem) { elem.hide(); new_hidden = true }
34+
var getText = function (elem) { return elem.text() }
3535

36-
if( column )
37-
{
38-
if (!$.isArray(column))
39-
{
36+
if (column) {
37+
if (!$.isArray(column)) {
4038
column = new Array(column);
4139
}
4240

4341
var index = new Array();
4442

45-
jq.find("thead > tr:last > th").each(function(i)
46-
{
47-
for (var j = 0; j < column.length; j++)
48-
{
49-
if ($.trim($(this).text()) == column[j])
50-
{
51-
index[j] = i;
52-
break;
53-
}
43+
jq.find("thead > tr:last > th").each(function (i) {
44+
for (var j = 0; j < column.length; j++) {
45+
if ($.trim($(this).text()) == column[j]) {
46+
index[j] = i;
47+
break;
5448
}
49+
}
5550

5651
});
5752

58-
getText = function(elem) {
59-
var selector = "";
60-
for (var i = 0; i < index.length; i++)
61-
{
62-
if (i != 0) {selector += ",";}
63-
selector += "td:eq(" + index[i] + ")";
64-
}
65-
return $(elem.find((selector))).text();
53+
getText = function (elem) {
54+
var selector = "";
55+
for (var i = 0; i < index.length; i++) {
56+
if (i != 0) { selector += ","; }
57+
selector += "td:eq(" + index[i] + ")";
58+
}
59+
return $(elem.find((selector))).text();
6660
}
6761
}
6862

6963
// if added one letter to last time,
7064
// just check newest word and only need to hide
71-
if( (words.size > 1) && (phrase.substr(0, phrase_length - 1) ===
72-
this.last_phrase) ) {
65+
if ((words.size > 1) && (phrase.substr(0, phrase_length - 1) ===
66+
this.last_phrase)) {
7367

74-
if( phrase[-1] === " " )
75-
{ this.last_phrase = phrase; return false; }
68+
if (phrase[-1] === " ") { this.last_phrase = phrase; return false; }
7669

7770
var words = words[-1]; // just search for the newest word
7871

7972
// only hide visible rows
80-
matches = function(elem) {;}
73+
matches = function (elem) { ; }
8174
var elems = jq.find("tbody:first > tr:visible")
8275
}
8376
else {
8477
new_hidden = true;
8578
var elems = jq.find("tbody:first > tr")
8679
}
8780

88-
elems.each(function(){
81+
elems.each(function () {
8982
var elem = $(this);
90-
$.uiTableFilter.has_words( getText(elem), words, false ) ?
83+
$.uiTableFilter.has_words(getText(elem), words, false) ?
9184
matches(elem) : noMatch(elem);
9285
});
9386

9487
last_phrase = phrase;
95-
if( ifHidden && new_hidden ) ifHidden();
88+
if (ifHidden && new_hidden) ifHidden();
9689
return jq;
9790
};
9891

@@ -102,12 +95,11 @@
10295
// not jQuery dependent
10396
// "" [""] -> Boolean
10497
// "" [""] Boolean -> Boolean
105-
$.uiTableFilter.has_words = function( str, words, caseSensitive )
106-
{
98+
$.uiTableFilter.has_words = function (str, words, caseSensitive) {
10799
var text = caseSensitive ? str : str.toLowerCase();
108-
for (var i=0; i < words.length; i++) {
100+
for (var i = 0; i < words.length; i++) {
109101
if (text.indexOf(words[i]) === -1) return false;
110102
}
111103
return true;
112104
}
113-
}) (jQuery);
105+
})(jQuery);

0 commit comments

Comments
 (0)