Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

made in error - kindly ignore #83

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
THIS PROJECT IS VERY MUCH DEAD AND NOT MAINTAINED. IT'S BEEN 6+ YEARS SINCE THE LAST UPDATES. DON'T EXPECT THIS TO WORK.

# jQuery quicksearch plug-in

A [jQuery][jquery_site] based plug-in for filtering large data sets with user input
Expand Down Expand Up @@ -156,4 +158,4 @@ Thanks to [Seth F.][thelizardreborn] for fixes and [Krzysiek Goj][goj] for the
[github_follow]: http://github.com/users/follow?target=riklomas
[twitter_follow]: http://twitter.com/riklomas
[thelizardreborn]: http://github.com/thelizardreborn
[goj]: http://github.com/goj
[goj]: http://github.com/goj
43 changes: 37 additions & 6 deletions jquery.quicksearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
stripeRows: null,
loader: null,
noResults: '',
matchedResultsCount: 0,
bind: 'keyup',
onBefore: function () {
return;
Expand Down Expand Up @@ -35,15 +36,17 @@

this.go = function () {

var i = 0,
noresults = true,
query = options.prepareQuery(val),
val_empty = (val.replace(' ', '').length === 0);
var i = 0,
numMatchedRows = 0,
noresults = true,
query = options.prepareQuery(val),
val_empty = (val.replace(' ', '').length === 0);

for (var i = 0, len = rowcache.length; i < len; i++) {
if (val_empty || options.testQuery(query, cache[i], rowcache[i])) {
options.show.apply(rowcache[i]);
noresults = false;
numMatchedRows++;
} else {
options.hide.apply(rowcache[i]);
}
Expand All @@ -56,12 +59,29 @@
this.stripe();
}

this.matchedResultsCount = numMatchedRows;
this.loader(false);
options.onAfter();

return this;
};

/*
* External API so that users can perform search programatically.
* */
this.search = function (submittedVal) {
val = submittedVal;
e.trigger();
};

/*
* External API to get the number of matched results as seen in
* https://github.com/ruiz107/quicksearch/commit/f78dc440b42d95ce9caed1d087174dd4359982d6
* */
this.currentMatchedResults = function() {
return this.matchedResultsCount;
};

this.stripe = function () {

if (typeof options.stripeRows === "object" && options.stripeRows !== null)
Expand Down Expand Up @@ -117,6 +137,12 @@
rowcache = jq_results.map(function () {
return this;
});

/*
* Modified fix for sync-ing "val".
* Original fix https://github.com/michaellwest/quicksearch/commit/4ace4008d079298a01f97f885ba8fa956a9703d1
* */
val = val || this.val() || "";

return this.go();
};
Expand All @@ -139,12 +165,17 @@
this.loader(false);

return this.each(function () {
$(this).bind(options.bind, function () {

/*
* Changed from .bind to .on.
* */
$(this).on(options.bind, function () {

val = $(this).val();
e.trigger();
});
});

};

}(jQuery, this, document));
}(jQuery, this, document));