public
Created

filter for lifestream

  • Download Gist
filter.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
$("#filter").live("keyup", function (ev) {
var $filter = $(this),
keyCode = ev.keyCode || ev.which,
search;
if (keyCode === 27) { //ESC
$filter.val("");
}
search = $(this).val();
$("#lifestream").find("li").each(function () {
var $li = $(this);
if (search === "") {
$li.show();
} else {
if (_.include(service_names, search)) {
$li.toggle($li.hasClass("lifestream-" + search));
} else {
if ($li.text().search(search) > 0) {
$li.show();
} else {
$li.hide();
}
}
}
});
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.