Extras: Dropping support for quicksearch plugin

This commit is contained in:
Mottie 2015-07-14 21:18:43 -05:00
parent de8f60172c
commit c705656e90
2 changed files with 0 additions and 196 deletions

View File

@ -1 +0,0 @@
!function(a,b,c,d){a.fn.quicksearch=function(c,d){var e,f,g,h,i="",j=this,k=a.extend({delay:100,selector:null,stripeRows:null,loader:null,noResults:"",childRow:"tablesorter-childRow",matchedResultsCount:0,bind:"keyup",onBefore:function(){},onAfter:function(){},show:function(){this.style.display=""},hide:function(){this.style.display="none"},prepareQuery:function(a){return a.toLowerCase().split(" ")},testQuery:function(a,b){for(var c=0;c<a.length;c+=1)if(-1===b.indexOf(a[c]))return!1;return!0}},d);return this.go=function(){var b,c=0,d=0,e=!0,h=k.prepareQuery(i),j=0===i.replace(" ","").length;for(c=0,b=g.length;b>c;c++)j||k.testQuery(h,f[c],g[c])||a(g[c]).hasClass(k.childRow)&&a(g[c>1?c-1:0]).is(":visible")?(k.show.apply(g[c]),e=!1,d++):k.hide.apply(g[c]);return e?this.results(!1):(this.results(!0),this.stripe()),this.matchedResultsCount=d,this.loader(!1),k.onAfter(),this},this.search=function(a){i=a,j.trigger()},this.currentMatchedResults=function(){return this.matchedResultsCount},this.stripe=function(){if("object"==typeof k.stripeRows&&null!==k.stripeRows){var b=k.stripeRows.join(" "),c=k.stripeRows.length;h.not(":hidden").each(function(d){a(this).removeClass(b).addClass(k.stripeRows[d%c])})}return this},this.strip_html=function(b){var c=b.replace(new RegExp("<[^<]+>","g"),"");return c=a.trim(c.toLowerCase())},this.results=function(b){return"string"==typeof k.noResults&&""!==k.noResults&&(b?a(k.noResults).hide():a(k.noResults).show()),this},this.loader=function(b){return"string"==typeof k.loader&&""!==k.loader&&(b?a(k.loader).show():a(k.loader).hide()),this},this.cache=function(){h=a(c),"string"==typeof k.noResults&&""!==k.noResults&&(h=h.not(k.noResults));var b="string"==typeof k.selector?h.find(k.selector):a(c).not(k.noResults);return f=b.map(function(){return j.strip_html(this.innerHTML)}),g=h.map(function(){return this}),i=i||this.val()||"",this.go()},this.trigger=function(){return this.loader(!0),k.onBefore(),b.clearTimeout(e),e=b.setTimeout(function(){j.go()},k.delay),this},this.cache(),this.results(!0),this.stripe(),this.loader(!1),this.each(function(){a(this).on(k.bind,function(){i=a(this).val(),j.trigger()})})}}(jQuery,this,document);

View File

@ -1,195 +0,0 @@
/* jQuery Quicksearch plugin
by riklomas https://github.com/riklomas/quicksearch
Modified to include childRows (for tablesorter)
See http://stackoverflow.com/q/20342203/145346 for
more details
*/
(function($, window, document, undefined) {
$.fn.quicksearch = function (target, opt) {
var timeout, cache, rowcache, jq_results, val = '', e = this, options = $.extend({
delay: 100,
selector: null,
stripeRows: null,
loader: null,
noResults: '',
childRow: 'tablesorter-childRow', // include child row with search results
matchedResultsCount: 0,
bind: 'keyup',
onBefore: function () {
return;
},
onAfter: function () {
return;
},
show: function () {
this.style.display = "";
},
hide: function () {
this.style.display = "none";
},
prepareQuery: function (val) {
return val.toLowerCase().split(' ');
},
testQuery: function (query, txt) {
for (var i = 0; i < query.length; i += 1) {
if (txt.indexOf(query[i]) === -1) {
return false;
}
}
return true;
}
}, opt);
this.go = function () {
var len, i = 0,
numMatchedRows = 0,
noresults = true,
query = options.prepareQuery(val),
val_empty = (val.replace(' ', '').length === 0);
for (i = 0, len = rowcache.length; i < len; i++) {
if (val_empty || options.testQuery(query, cache[i], rowcache[i]) ||
($(rowcache[i]).hasClass(options.childRow) && $(rowcache[i > 1 ? i - 1 : 0]).is(':visible'))) {
options.show.apply(rowcache[i]);
noresults = false;
numMatchedRows++;
} else {
options.hide.apply(rowcache[i]);
}
}
if (noresults) {
this.results(false);
} else {
this.results(true);
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)
{
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]);
});
}
return this;
};
this.strip_html = function (input) {
var output = input.replace(new RegExp('<[^<]+\>', 'g'), "");
output = $.trim(output.toLowerCase());
return output;
};
this.results = function (bool) {
if (typeof options.noResults === "string" && options.noResults !== "") {
if (bool) {
$(options.noResults).hide();
} else {
$(options.noResults).show();
}
}
return this;
};
this.loader = function (bool) {
if (typeof options.loader === "string" && options.loader !== "") {
if (bool) {
$(options.loader).show();
} else {
$(options.loader).hide();
}
}
return this;
};
this.cache = function () {
jq_results = $(target);
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 () {
return this;
});
/*
* Modified fix for sync-ing "val".
* Original fix https://github.com/michaellwest/quicksearch/commit/4ace4008d079298a01f97f885ba8fa956a9703d1
* */
val = val || this.val() || "";
return this.go();
};
this.trigger = function () {
this.loader(true);
options.onBefore();
window.clearTimeout(timeout);
timeout = window.setTimeout(function () {
e.go();
}, options.delay);
return this;
};
this.cache();
this.results(true);
this.stripe();
this.loader(false);
return this.each(function () {
/*
* Changed from .bind to .on.
* */
$(this).on(options.bind, function () {
val = $(this).val();
e.trigger();
});
});
};
}(jQuery, this, document));