diff options
author | Dan McGee <dan@archlinux.org> | 2012-09-30 18:18:19 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-09-30 18:18:19 -0500 |
commit | febf5e92233738198107a69f66c9f3443b4306c7 (patch) | |
tree | 0c8e069360e26314d498251e15cf672743f8a03b /sitestatic/archweb.js | |
parent | 58ecb90c3f0254cdfab290234d309cad14a17723 (diff) |
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>
Diffstat (limited to 'sitestatic/archweb.js')
-rw-r--r-- | sitestatic/archweb.js | 24 |
1 files changed, 23 insertions, 1 deletions
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('<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 */ |