Collapse long lists of related packages

Just like we did with the rows of depends and required by, collapse down
conflicts, provides, etc. comma-separated lists if they grow too large.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2012-09-30 18:18:19 -05:00
parent 58ecb90c3f
commit febf5e9223
3 changed files with 32 additions and 17 deletions

View File

@ -206,7 +206,7 @@ function collapseDependsList(list) {
// enough items, or the link already exists.
var linkid = list.attr('id') + 'link';
var items = list.find('li').slice(limit);
if (items.length == 0 || $('#' + linkid).length > 0) {
if (items.length <= 1 || $('#' + linkid).length > 0) {
return;
}
items.hide();
@ -221,6 +221,28 @@ function collapseDependsList(list) {
});
}
function collapseRelatedTo(elements) {
var limit = 5;
$(elements).each(function(idx, ele) {
ele = $(ele);
// Hide everything past a given limit. Don't do anything if we don't
// have enough items, or the link already exists.
var items = ele.find('span.related').slice(limit);
if (items.length <= 1 || ele.find('a.morelink').length > 0) {
return;
}
items.hide();
ele.append('<a class="morelink" href="#">More…</a>');
// add link and wire it up to show the hidden items
ele.find('a.morelink').click(function(event) {
event.preventDefault();
ele.find('span.related').show();
$(this).remove();
});
});
}
/* packages/differences.html */
function filter_packages() {
/* start with all rows, and then remove ones we shouldn't show */

View File

@ -97,7 +97,7 @@ <h4>Versions Elsewhere</h4>
{% with pkg.split_packages as splits %}{% if splits %}
<tr>
<th>Split Packages:</th>
<td class="wrap">{% for s in splits %}{% pkg_details_link s %}{% if not forloop.last %}, {% endif %}{% endfor %}</td>
<td class="wrap relatedto">{% for s in splits %}<span class="related">{% pkg_details_link s %}{% if not forloop.last %}, {% endif %}</span>{% endfor %}</td>
</tr>
{% endif %}{% endwith %}
{% else %}
@ -134,26 +134,26 @@ <h4>Versions Elsewhere</h4>
{% with pkg.provides.all as all_related %}{% if all_related %}
<tr>
<th>Provides:</th>
<td class="wrap">{% include "packages/details_relatedto.html" %}</td>
<td class="wrap relatedto">{% include "packages/details_relatedto.html" %}</td>
</tr>
{% endif %}{% endwith %}
{% with pkg.replaces.all as all_related %}{% if all_related %}
<tr>
<th>Replaces:</th>
<td class="wrap">{% include "packages/details_relatedto.html" %}</td>
<td class="wrap relatedto">{% include "packages/details_relatedto.html" %}</td>
</tr>
{% endif %}{% endwith %}
{% with pkg.conflicts.all as all_related %}{% if all_related %}
<tr>
<th>Conflicts:</th>
<td class="wrap">{% include "packages/details_relatedto.html" %}</td>
<td class="wrap relatedto">{% include "packages/details_relatedto.html" %}</td>
</tr>
{% endif %}{% endwith %}
{% with pkg.reverse_conflicts as rev_conflicts %}{% if rev_conflicts %}
<tr>
<th>Reverse Conflicts:</th>
<td class="wrap">{% for conflict in rev_conflicts %}
{% pkg_details_link conflict %}{% if not forloop.last %}, {% endif %}{% endfor %}</td>
<td class="wrap relatedto">{% for conflict in rev_conflicts %}
<span class="related">{% pkg_details_link conflict %}{% if not forloop.last %}, {% endif %}</span>{% endfor %}</td>
</tr>
{% endif %}{% endwith %}
<tr>
@ -237,6 +237,7 @@ <h3 title="Complete list of files contained within this package">
ajaxifyFiles();
collapseDependsList("#pkgdepslist");
collapseDependsList("#pkgreqslist");
collapseRelatedTo(".relatedto");
});
</script>
{% endblock %}

View File

@ -1,10 +1,2 @@
{% load package_extras %}
{% for related in all_related %}
{% with related.get_best_satisfier as best_satisfier %}
{% ifequal best_satisfier None %}
{{ related.name }}{{ related.comparison|default:"" }}{{ related.version|default:"" }}{% if not forloop.last %}, {% endif %}
{% else %}
{% pkg_details_link best_satisfier %}{{ related.comparison|default:"" }}{{related.version|default:"" }}{% if not forloop.last %}, {% endif %}
{% endifequal %}
{% endwith %}
{% endfor %}
{% load package_extras %}{% for related in all_related %}{% with related.get_best_satisfier as best_satisfier %}<span class="related">{% ifequal best_satisfier None %}{{ related.name }}{% else %}{% pkg_details_link best_satisfier %}{% endifequal %}{{ related.comparison|default:"" }}{{ related.version|default:"" }}{% if not forloop.last %}, {% endif %}</span>
{% endwith %}{% endfor %}