mirror of
https://github.com/correl/melpa.git
synced 2025-04-09 01:01:06 -09:00
Minimise re-rendering of package list while searching
This commit is contained in:
parent
0815c34afd
commit
5cb9603286
2 changed files with 7 additions and 4 deletions
|
@ -23,6 +23,9 @@ pre code { /* Match highlight.js styles to bootstrap */
|
||||||
#package-list th, #package-list td.version, #package-list td.recipe {
|
#package-list th, #package-list td.version, #package-list td.recipe {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
#package-list tr.filtered {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
#package-list td a:link {
|
#package-list td a:link {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,8 +60,8 @@
|
||||||
var packages = savedSearches[t];
|
var packages = savedSearches[t];
|
||||||
if (!packages) {
|
if (!packages) {
|
||||||
var preFiltered = preFilteredPackages(t);
|
var preFiltered = preFilteredPackages(t);
|
||||||
packages = _.filter(preFiltered || this.packages,
|
packages = preFiltered || this.packages;
|
||||||
function(p) { return p.matchesTerm(t); });
|
_.each(packages, function(p) { p.visible = p.matchesTerm(t); });
|
||||||
if (preFiltered) packages.sortKey = preFiltered.sortKey;
|
if (preFiltered) packages.sortKey = preFiltered.sortKey;
|
||||||
}
|
}
|
||||||
var sortKey = sortBy + "-" + sortAscending;
|
var sortKey = sortBy + "-" + sortAscending;
|
||||||
|
@ -208,7 +208,7 @@
|
||||||
m("input.form-control", {type: "search", placeholder: "Enter filter terms", autofocus: true,
|
m("input.form-control", {type: "search", placeholder: "Enter filter terms", autofocus: true,
|
||||||
value: ctrl.filterTerms(), onkeyup: m.withAttr("value", ctrl.filterTerms)}),
|
value: ctrl.filterTerms(), onkeyup: m.withAttr("value", ctrl.filterTerms)}),
|
||||||
" ",
|
" ",
|
||||||
m("span.help-block", ["Showing ", ctrl.filteredPackages().length, " matching package(s)"])
|
m("span.help-block", ["Showing ", _.filter(ctrl.filteredPackages(), 'visible').length, " matching package(s)"])
|
||||||
]),
|
]),
|
||||||
m("table#package-list.table.table-bordered.table-responsive.table-hover", [
|
m("table#package-list.table.table-bordered.table-responsive.table-hover", [
|
||||||
m("thead", [
|
m("thead", [
|
||||||
|
@ -223,7 +223,7 @@
|
||||||
]),
|
]),
|
||||||
m("tbody",
|
m("tbody",
|
||||||
ctrl.filteredPackages().map(function(p) {
|
ctrl.filteredPackages().map(function(p) {
|
||||||
return m("tr", [
|
return m("tr", {class: p.visible ? '' : 'filtered'}, [
|
||||||
m("td", [
|
m("td", [
|
||||||
m("a", {href: "/" + p.name, config: m.route}, [
|
m("a", {href: "/" + p.name, config: m.route}, [
|
||||||
p.name
|
p.name
|
||||||
|
|
Loading…
Add table
Reference in a new issue