// likes and comments
'riverdashboard:n_more_comments' => '+%s more',
+ 'riverdashboard:show_less' => 'Show less',
// ecml desc
'riverdashboard:ecml:riverdashboard' => 'River Dashboard',
}
// get last three comments display
-// want the 3 most recent comments (order by time_created desc = 3 2 1)
+// want the 3 most recent comments (order by time_created desc = 3 2 1 limit 3)
// but will display them with the newest at the bottom (1 2 3)
if ($comments = get_annotations($vars['item']->object_guid, "", "", 'generic_comment', "", "", 3, 0, "desc")) {
$comments = array_reverse($comments);
echo "<div class=\"comments_container\">";
// display appropriate comment link
if ($more_comments_count > 0) {
- echo "<a class=\"river_show_more_comments link\">" .
+ echo "<a class=\"river_more_comments show_more_button link\">" .
sprintf(elgg_echo('riverdashboard:n_more_comments'), $more_comments_count) . '</a>';
+
+ echo "<a style=\"display: none\" class=\"river_more_comments show_less_button link\">" . elgg_echo('riverdashboard:show_less') . '</a>';
}
echo "<div class=\"comments_list\">";
foreach ($comments as $comment) {
<?php
/**
* Elgg riverdashboard CSS
- *
+ *
*/
?>
#riverdashboard_updates {
font-weight: bold;
padding:1px 8px 2px 24px;
margin-top:9px;
- cursor: pointer;
+ cursor: pointer;
background: red url("<?php echo $vars['url']; ?>mod/riverdashboard/graphics/refresh.png") no-repeat 5px 3px;
- -webkit-border-radius: 10px;
- -moz-border-radius: 10px;
+ -webkit-border-radius: 10px;
+ -moz-border-radius: 10px;
}
#riverdashboard_updates a.update_link:hover {
background: #4690D6 url("<?php echo $vars['url']; ?>mod/riverdashboard/graphics/refresh.png") no-repeat 5px -22px;
-webkit-border-top-left-radius:5px;
-webkit-border-top-right-radius:0;
-webkit-border-bottom-right-radius:5px;
- -webkit-border-bottom-left-radius:5px;
- background-color: #eeeeee;
+ -webkit-border-bottom-left-radius:5px;
+ background-color: #eeeeee;
}
.river_comment {
padding:3px;
- border-bottom:1px solid white;
+ border-bottom:1px solid white;
}
.river_comment.penultimate {
/* hidden inline comment form */
.river_comment_form.hidden {
padding:5px;
- height:26px;
+ height:26px;
}
.river_comment_form.hidden .input_text {
width:560px;
.river_item .river_comment_contents {
margin-left:34px;
}
-a.river_show_more_comments {
+a.river_more_comments {
float:right;
font-size:85%;
padding-right:7px;
});
// grab more comments
- $('.river_show_more_comments').click(function() {
+ $('.river_more_comments.show_more_button').click(function() {
+ var showLess = $(this).next('.show_less_button');
+ var showMore = $(this);
var riverItem = $(this).closest('.river_item');
+
var guid = riverItem.attr('id').replace('river_entity_', '');
var commentsList = riverItem.find('.comments_list');
var numComments = riverItem.find('.river_comment').length;
$.post('<?php echo $vars['url'];?>mod/riverdashboard/endpoint/get_comments.php', params, function(data) {
commentsList.prepend(data);
- commentsList.prev('.river_show_more_comments').html('Show less');
- // @todo need a new function to collapse list back down to only show 3 comments
-
+
+ showLess.toggle();
+ showMore.toggle();
+
});
});
+
+ // hide more comments
+ $('.river_more_comments.show_less_button').click(function() {
+ var showLess = $(this);
+ var showMore = $(this).prev('.show_more_button');
+ var riverItem = $(this).closest('.river_item');
+ // want to keep the latest 3 comments
+ var comments = riverItem.find('.river_comment')
+ comments = $.makeArray(comments).reverse();
+ //reverse().splice(0, 3);
+
+ len = comments.length;
+
+ for (i=3; i<len; i++) {
+ $(comments[i]).empty().remove();
+ }
+
+
+ // remove them so we can force an ajax update when clicked again.
+
+ showLess.toggle();
+ showMore.toggle();
+
+ });
});
</script>