summaryrefslogtreecommitdiffstats
path: root/web/html
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2017-04-19 17:21:15 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2017-04-20 07:03:54 +0200
commit4abde895a5b579fb798e062806c8fef2289f0d8f (patch)
tree6898017bad6285e6a2c9c76c89dc39506f357570 /web/html
parent44858e06188946c0082bb09061fcfa6cbb33938b (diff)
downloadaur-4abde895a5b579fb798e062806c8fef2289f0d8f.tar.gz
aur-4abde895a5b579fb798e062806c8fef2289f0d8f.tar.xz
Use JavaScript to collapse long comments
Instead of using CSS to limit the height of package comments as implemented in 7b13203 (Limit comment height to 15 lines, 2016-03-12), use JavaScript to collapse long comments and add a link to expand them. Clicking the same link twice results in the corresponding comment being collapsed again. If JavaScript is disabled, the full comments are shown (without any possibility to collapse or expand). Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web/html')
-rw-r--r--web/html/css/aurweb.css5
-rw-r--r--web/html/packages.php35
2 files changed, 35 insertions, 5 deletions
diff --git a/web/html/css/aurweb.css b/web/html/css/aurweb.css
index f777ab83..f5e10371 100644
--- a/web/html/css/aurweb.css
+++ b/web/html/css/aurweb.css
@@ -148,8 +148,3 @@ label.confirmation,
color: red;
font-weight: bold;
}
-
-#news div p {
- max-height: 15em;
- overflow: auto;
-}
diff --git a/web/html/packages.php b/web/html/packages.php
index 113a1145..8d76c76d 100644
--- a/web/html/packages.php
+++ b/web/html/packages.php
@@ -72,10 +72,45 @@ function collapseDependsList(list) {
});
}
+function collapseComment(div) {
+ var linkid = div.attr('id') + 'link',
+ par = div.find('p'),
+ height = par.height(),
+ maxheight = 200;
+
+ if (height <= maxheight)
+ return;
+
+ par.css({ 'overflow': 'hidden', 'height': maxheight + 'px' });
+ par.addClass('collapsed');
+ par.after('<p><a id="' + linkid + '" href="#">Show More…</a></p>');
+
+ $('#' + linkid).click(function(event) {
+ var newheight;
+
+ if (par.hasClass('collapsed')) {
+ par.css({ 'height': 'auto' });
+ newheight = par.height();
+ par.css({ 'height': maxheight });
+ $(this).text('Collapse');
+ } else {
+ newheight = maxheight;
+ $(this).text('Show More…');
+ }
+
+ par.animate({ 'height': newheight });
+ par.toggleClass('collapsed');
+ event.preventDefault();
+ });
+}
+
$(document).ready(function() {
collapseDependsList("#pkgdepslist");
collapseDependsList("#pkgreqslist");
collapseDependsList("#pkgsrcslist");
+ $(".article-content").each(function() {
+ collapseComment($(this));
+ });
});
</script>