From 040e0ddea591702856ce7d737bf4ea31f60a89e5 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 11 Dec 2012 20:53:50 -0600 Subject: Collapse really long signoff specifications using JS Signed-off-by: Dan McGee --- sitestatic/archweb.js | 31 +++++++++++++++++++++++++++++-- templates/packages/signoffs.html | 5 ++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/sitestatic/archweb.js b/sitestatic/archweb.js index a0c5713a..42efb3fa 100644 --- a/sitestatic/archweb.js +++ b/sitestatic/archweb.js @@ -301,7 +301,7 @@ function filter_packages_reset() { /* todolists/view.html */ function todolist_flag() { - // TODO: fix usage of this + // TODO: fix usage of this var link = this; $.getJSON(link.href, function(data) { if (data.complete) { @@ -353,7 +353,7 @@ function filter_pkgs_reset(callback) { /* signoffs.html */ function signoff_package() { - // TODO: fix usage of this + // TODO: fix usage of this var link = this; $.getJSON(link.href, function(data) { link = $(link); @@ -436,6 +436,33 @@ function filter_signoffs_reset() { filter_signoffs(); } +function collapseNotes(elements) { + // Remove any trailing
tags from the note contents + $(elements).children('br').filter(':last-child').filter(function(i, e) { return !e.nextSibling; }).remove(); + + var maxElements = 8; + $(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 contents = ele.contents(); + if (contents.length <= maxElements || ele.find('a.morelink').length > 0) { + return; + } + contents.slice(maxElements).wrapAll('
'); + ele.append('
Show Moreā€¦'); + + // add link and wire it up to show the hidden items + ele.find('a.morelink').click(function(event) { + event.preventDefault(); + ele.find('div.hide').show(); + $(this).remove(); + // remove trailing line break between text and our link + $(this).contents().last().filter('br').remove(); + }); + }); +} + /* visualizations */ function format_filesize(size, decimals) { /*var labels = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];*/ diff --git a/templates/packages/signoffs.html b/templates/packages/signoffs.html index b6737230..20371f95 100644 --- a/templates/packages/signoffs.html +++ b/templates/packages/signoffs.html @@ -69,7 +69,7 @@ {% endif %} {% endif %} {% include "packages/signoff_cell.html" %} - {% if not group.default_spec %}{% with group.specification as spec %}{% comment %} + {% if not group.default_spec %}{% with group.specification as spec %}{% comment %} {% endcomment %}{% if spec.required != 2 %}Required signoffs: {{ spec.required }}
{% endif %}{% comment %} {% endcomment %}{% if not spec.enabled %}Signoffs are not currently enabled
{% endif %}{% comment %} {% endcomment %}{% if spec.known_bad %}Package is known to be bad
{% endif %}{% comment %} @@ -95,5 +95,8 @@ $(document).ready(function() { // fire function on page load to ensure the current form selections take effect filter_signoffs(); }); +$(document).ready(function() { + collapseNotes('.note'); +}); {% endblock %} -- cgit v1.2.3-55-g3dc8