From febf5e92233738198107a69f66c9f3443b4306c7 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 30 Sep 2012 18:18:19 -0500 Subject: 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 --- sitestatic/archweb.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'sitestatic') diff --git a/sitestatic/archweb.js b/sitestatic/archweb.js index 783f75c6..a42e0208 100644 --- a/sitestatic/archweb.js +++ b/sitestatic/archweb.js @@ -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('Moreā€¦'); + + // 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 */ -- cgit v1.2.3-55-g3dc8