diff options
Diffstat (limited to 'mod/riverdashboard/views')
-rw-r--r-- | mod/riverdashboard/views/default/river/item/wrapper.php | 7 | ||||
-rw-r--r-- | mod/riverdashboard/views/default/riverdashboard/js.php | 29 |
2 files changed, 24 insertions, 12 deletions
diff --git a/mod/riverdashboard/views/default/river/item/wrapper.php b/mod/riverdashboard/views/default/river/item/wrapper.php index a2bc10c54..e50a3fe3f 100644 --- a/mod/riverdashboard/views/default/river/item/wrapper.php +++ b/mod/riverdashboard/views/default/river/item/wrapper.php @@ -69,9 +69,8 @@ if ($comments){ if ($likes_count != 0) { //show the users who liked the object - echo "<div class='likes_list hidden'>"; - echo list_annotations($object->getGUID(), 'likes', 99); - echo "</div>"; + // this is loaded via ajax to avoid pounding the server with avatar requests. + echo "<div class='likes_list hidden'></div>"; } echo "<div class=\"comments_container\">"; @@ -148,4 +147,4 @@ if ($comments){ } ?> </div> -</div>
\ No newline at end of file +</div> diff --git a/mod/riverdashboard/views/default/riverdashboard/js.php b/mod/riverdashboard/views/default/riverdashboard/js.php index 37de3ad04..edb041e4f 100644 --- a/mod/riverdashboard/views/default/riverdashboard/js.php +++ b/mod/riverdashboard/views/default/riverdashboard/js.php @@ -6,14 +6,27 @@ $('.likes_user_list_button').click(function() { var myParent = $(this).closest('.river_item'); - if (myParent.find('.likes_list').css('display') == 'none') { - // hide comments - myParent.find('.comments_container').animate({"height": "toggle", "opacity": "toggle"}, { duration: 400 }); - // change selected tab - myParent.find('.show_comments_button').addClass('off'); - myParent.find('.likes_user_list_button').removeClass('off'); - // show users that liked object - elgg_slide_toggle(this, '.river_item', '.likes_list'); + var likesList = myParent.find('.likes_list'); + + if (likesList.css('display') == 'none') { + // pull in likes via ajax to save on loading many avatars + var riverItem = $(this).closest('.river_item'); + var guid = riverItem.attr('id').replace('river_entity_', ''); + + var params = { + 'entity_guid': guid + } + + $(likesList).load('<?php echo $vars['url'];?>mod/riverdashboard/endpoint/get_likes.php', params, function(data) { + console.log(data); + // hide comments + myParent.find('.comments_container').animate({"height": "toggle", "opacity": "toggle"}, { duration: 400 }); + // change selected tab + myParent.find('.show_comments_button').addClass('off'); + myParent.find('.likes_user_list_button').removeClass('off'); + // show users that liked object + elgg_slide_toggle(this, '.river_item', '.likes_list'); + }); } }); |