(function($, window, document, undefined) {
$.fn.quicksearch = function (target, opt) {
var timeout, cache, rowcache, jq_results, val = '', e = this, options = $.extend({
this.style.display = "none";
prepareQuery: function (val) {
return val.toLowerCase().split(' ');
testQuery: function (query, txt, _row) {
for (var i = 0; i < query.length; i += 1) {
if (txt.indexOf(query[i]) === -1) {
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]);
options.hide.apply(rowcache[i]);
this.matchedResultsCount = numMatchedRows;
this.search = function (submittedVal) {
this.currentMatchedResults = function() {
return this.matchedResultsCount;
this.stripe = function () {
if (typeof options.stripeRows === "object" && options.stripeRows !== null)
var joined = options.stripeRows.join(' ');
var stripeRows_length = options.stripeRows.length;
jq_results.not(':hidden').each(function (i) {
$(this).removeClass(joined).addClass(options.stripeRows[i % stripeRows_length]);
this.strip_html = function (input) {
var output = input.replace(new RegExp('<[^<]+\>', 'g'), "");
output = $.trim(output.toLowerCase());
this.results = function (bool) {
if (typeof options.noResults === "string" && options.noResults !== "") {
$(options.noResults).hide();
$(options.noResults).show();
this.loader = function (bool) {
if (typeof options.loader === "string" && options.loader !== "") {
(bool) ? $(options.loader).show() : $(options.loader).hide();
this.cache = function () {
if (typeof options.noResults === "string" && options.noResults !== "") {
jq_results = jq_results.not(options.noResults);
var t = (typeof options.selector === "string") ? jq_results.find(options.selector) : $(target).not(options.noResults);
cache = t.map(function () {
return e.strip_html(this.innerHTML);
rowcache = jq_results.map(function () {
val = val || this.val() || "";
this.trigger = function () {
window.clearTimeout(timeout);
timeout = window.setTimeout(function () {
return this.each(function () {
$(this).on(options.bind, function () {
}(jQuery, this, document));
$("#id_search").quicksearch("ol li article ", {