diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-06-08 21:37:14 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-06-08 21:37:14 +0000 |
commit | 375a3021d73e629883830c1c9aa6fd216d59e6d3 (patch) | |
tree | bd8b237d877ee383125a7a68b72d1b190287e989 /mod | |
parent | b6ec22721c68bd12db74c0bb9e55482e17f4e58e (diff) | |
download | elgg-375a3021d73e629883830c1c9aa6fd216d59e6d3.tar.gz elgg-375a3021d73e629883830c1c9aa6fd216d59e6d3.tar.bz2 |
Ajaxified likes view on activity stream.
git-svn-id: http://code.elgg.org/elgg/trunk@6409 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod')
-rw-r--r-- | mod/riverdashboard/endpoint/get_likes.php | 22 | ||||
-rw-r--r-- | mod/riverdashboard/views/default/river/item/wrapper.php | 7 | ||||
-rw-r--r-- | mod/riverdashboard/views/default/riverdashboard/js.php | 29 |
3 files changed, 46 insertions, 12 deletions
diff --git a/mod/riverdashboard/endpoint/get_likes.php b/mod/riverdashboard/endpoint/get_likes.php new file mode 100644 index 000000000..cc9e83aaf --- /dev/null +++ b/mod/riverdashboard/endpoint/get_likes.php @@ -0,0 +1,22 @@ +<?php +/** + * Grabs more "likes" to display. + */ + +require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"); + +$limit = get_input('limit', 25); +$offset = get_input('offset', 0); +$entity_guid = get_input('entity_guid'); + +if (!$entity = get_entity($entity_guid)) { + exit; +} + +$annotations = $entity->getAnnotations('likes', $limit, $offset); + +if (is_array($annotations) && sizeof($annotations) > 0) { + foreach($annotations as $annotation) { + echo elgg_view_annotation($annotation, "", false); + } +} 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'); + }); } }); |