]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Ajaxified likes view on activity stream.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 8 Jun 2010 21:37:14 +0000 (21:37 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 8 Jun 2010 21:37:14 +0000 (21:37 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@6409 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/riverdashboard/endpoint/get_likes.php [new file with mode: 0644]
mod/riverdashboard/views/default/river/item/wrapper.php
mod/riverdashboard/views/default/riverdashboard/js.php

diff --git a/mod/riverdashboard/endpoint/get_likes.php b/mod/riverdashboard/endpoint/get_likes.php
new file mode 100644 (file)
index 0000000..cc9e83a
--- /dev/null
@@ -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);
+       }
+}
index a2bc10c54c490faf6027bcc01c653602abfcd363..e50a3fe3ff318d0e90d42e40c4ab036e62454e40 100644 (file)
@@ -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>
index 37de3ad049f5b6ce27dee3ef453f3214c87d5236..edb041e4ffe6fc8f44bc971525fcd94a04be57f4 100644 (file)
@@ -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');
+                               });
                        }
                });