<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[BuddyPress] [2266] trunk/bp-themes/bp-default:
Limiting the maximum number of comments that can show for an activity thread
.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>2266</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2010-01-06 12:07:27 +0000 (Wed, 06 Jan 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Limiting the maximum number of comments that can show for an activity thread. I18n still to be fixed up in JS.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpthemesbpdefault_inccssdefaultcss">trunk/bp-themes/bp-default/_inc/css/default.css</a></li>
<li><a href="#trunkbpthemesbpdefault_incglobaljs">trunk/bp-themes/bp-default/_inc/global.js</a></li>
<li><a href="#trunkbpthemesbpdefaultactivityentryphp">trunk/bp-themes/bp-default/activity/entry.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpthemesbpdefault_inccssdefaultcss"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/_inc/css/default.css (2265 => 2266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/_inc/css/default.css        2010-01-06 09:32:33 UTC (rev 2265)
+++ trunk/bp-themes/bp-default/_inc/css/default.css        2010-01-06 12:07:27 UTC (rev 2266)
</span><span class="lines">@@ -480,7 +480,7 @@
</span><span class="cx">                         -moz-border-radius-topright: 3px;
</span><span class="cx">                         -webkit-border-top-right-radius: 3px;
</span><span class="cx">                 }
</span><del>-                        div.item-list-tabs ul li.loading a {
</del><ins>+                        ul li.loading a {
</ins><span class="cx">                                 background-image: url( ../images/ajax-loader.gif );
</span><span class="cx">                                 background-position: 92% 50%;
</span><span class="cx">                                 background-repeat: no-repeat;
</span></span></pre></div>
<a id="trunkbpthemesbpdefault_incglobaljs"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/_inc/global.js (2265 => 2266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/_inc/global.js        2010-01-06 09:32:33 UTC (rev 2265)
+++ trunk/bp-themes/bp-default/_inc/global.js        2010-01-06 12:07:27 UTC (rev 2266)
</span><span class="lines">@@ -106,6 +106,7 @@
</span><span class="cx">                 }
</span><span class="cx">         });
</span><span class="cx">
</span><ins>+        /* Activity filter select */
</ins><span class="cx">         j('#activity-filter-select select').change( function() {
</span><span class="cx">                 var selected_tab = j( '.' + j(this).parent().parent().parent().attr('class') + ' li.selected');
</span><span class="cx">
</span><span class="lines">@@ -246,6 +247,9 @@
</span><span class="cx">
</span><span class="cx">                         j('div.item-list-tabs li.selected, div.item-list-tabs li.current').removeClass('loading');
</span><span class="cx">
</span><ins>+                        /* Selectively hide comments */
+                        bp_dtheme_hide_comments();
+
</ins><span class="cx">                 }, 'json' );
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -254,6 +258,10 @@
</span><span class="cx">         /* Hide all activity comment forms */
</span><span class="cx">         j('form.ac-form').hide();
</span><span class="cx">
</span><ins>+        /* Hide excess comments */
+        if ( j('div.activity-comments').length )
+                bp_dtheme_hide_comments();
+
</ins><span class="cx">         /* Activity list event delegation */
</span><span class="cx">         j('div.activity').click( function(event) {
</span><span class="cx">                 var target = j(event.target);
</span><span class="lines">@@ -346,6 +354,9 @@
</span><span class="cx">                                         );
</span><span class="cx">                                         j( 'form#' + form + ' textarea').val('');
</span><span class="cx">
</span><ins>+                                        /* Increase the "Reply (X)" button count */
+                                        j('li#activity-' + form_id[2] + ' a.acomment-reply span').html( Number( j('li#activity-' + form_id[2] + ' a.acomment-reply span').html() ) + 1 );
+
</ins><span class="cx">                                         /* Re-enable the submit button after 5 seconds. */
</span><span class="cx">                                         setTimeout( function() { target.attr("disabled", ''); }, 5000 );
</span><span class="cx">                                 }
</span><span class="lines">@@ -388,11 +399,28 @@
</span><span class="cx">                                                 if ( children.length )
</span><span class="cx">                                                         comment_li.parent().append( children.html() ).hide().fadeIn( 200 );
</span><span class="cx">                                          });
</span><ins>+
+                                        /* Decrease the "Reply (X)" button count */
+                                        var parent_li = comment_li.parents('ul#activity-stream > li');
+                                        j('li#' + parent_li.attr('id') + ' a.acomment-reply span').html( j('li#' + parent_li.attr('id') + ' a.acomment-reply span').html() - 1 );
</ins><span class="cx">                                 }
</span><span class="cx">                         });
</span><span class="cx">
</span><span class="cx">                         return false;
</span><span class="cx">                 }
</span><ins>+
+                /* Showing hidden comments - pause for half a second */
+                if ( target.parent().hasClass('show-all') ) {
+                        target.parent().addClass('loading');
+
+                        setTimeout( function() {
+                                target.parent().parent().children('li').fadeIn(200, function() {
+                                        target.parent().remove();
+                                });
+                        }, 600 );
+
+                        return false;
+                }
</ins><span class="cx">         });
</span><span class="cx">
</span><span class="cx">         /* Escape Key Press for cancelling comment forms */
</span><span class="lines">@@ -419,6 +447,33 @@
</span><span class="cx">                 }
</span><span class="cx">         });
</span><span class="cx">
</span><ins>+        function bp_dtheme_hide_comments() {
+                var comments_divs = j('div.activity-comments');
+
+                if ( !comments_divs.length )
+                        return false;
+
+                comments_divs.each( function() {
+                        if ( j(this).children('ul').children('li').length < 5 ) return;
+
+                        var comments_div = j(this);
+                        var parent_li = comments_div.parents('ul#activity-stream > li');
+                        var comment_lis = j(this).children('ul').children('li');
+
+                        comment_lis.each( function(i) {
+                                /* Show the latest 5 root comments */
+                                if ( i < comment_lis.length - 5 ) {
+                                        j(this).addClass('hidden');
+                                        j(this).toggle();
+
+                                        if ( !i )
+                                                j(this).before( '<li class="show-all"><a href="#' + parent_li.attr('id') + '/show-all/" title="Show all comments for this thread">Show all ' + j('li#' + parent_li.attr('id') + ' a.acomment-reply span').html() + ' comments</a></li>' );
+                                }
+                        });
+
+                });
+        }
+
</ins><span class="cx">         /**** Directory Search ****************************************************/
</span><span class="cx">
</span><span class="cx">         j('div.dir-search').click( function(event) {
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultactivityentryphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/activity/entry.php (2265 => 2266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/activity/entry.php        2010-01-06 09:32:33 UTC (rev 2265)
+++ trunk/bp-themes/bp-default/activity/entry.php        2010-01-06 12:07:27 UTC (rev 2266)
</span><span class="lines">@@ -10,7 +10,7 @@
</span><span class="cx">
</span><span class="cx">                 <div class="activity-meta">
</span><span class="cx">                         <?php if ( is_user_logged_in() && bp_activity_can_comment() ) : ?>
</span><del>-                                <a href="#acomment-<?php bp_activity_id() ?>" class="acomment-reply" id="acomment-comment-<?php bp_activity_id() ?>"><?php _e( 'Reply', 'buddypress' ) ?> (<?php bp_activity_comment_count() ?>)</a>
</del><ins>+                                <a href="#acomment-<?php bp_activity_id() ?>" class="acomment-reply" id="acomment-comment-<?php bp_activity_id() ?>"><?php _e( 'Reply', 'buddypress' ) ?> (<span><?php bp_activity_comment_count() ?></span>)</a>
</ins><span class="cx">                         <?php endif; ?>
</span><span class="cx">
</span><span class="cx">                         <?php if ( is_user_logged_in() ) : ?>
</span></span></pre>
</div>
</div>
</body>
</html>