From 0149feee2036bebc708cdb6e073e5595efeab0d7 Mon Sep 17 00:00:00 2001 From: cdujeu Date: Wed, 11 Sep 2013 23:00:11 +0200 Subject: [PATCH] Comments feed --- .../class.CommentsMetaManager.php | 6 ++ .../meta.comments/class.CommentsPanel.js | 75 ++++++++++++----- .../plugins/meta.comments/comments_feed.css | 81 +++++++++++++++++-- 3 files changed, 135 insertions(+), 27 deletions(-) diff --git a/core/src/plugins/meta.comments/class.CommentsMetaManager.php b/core/src/plugins/meta.comments/class.CommentsMetaManager.php index 225cfde716..e1041d6fd8 100644 --- a/core/src/plugins/meta.comments/class.CommentsMetaManager.php +++ b/core/src/plugins/meta.comments/class.CommentsMetaManager.php @@ -42,6 +42,7 @@ public function switchActions($actionName, $httpVars, $fileVars) if($existingFeed == null){ $existingFeed = array(); } + $mess = ConfService::getMessages(); switch($actionName){ case "post_comment": @@ -56,6 +57,7 @@ public function switchActions($actionName, $httpVars, $fileVars) $uniqNode->removeMetadata(AJXP_META_SPACE_COMMENTS, false); $uniqNode->setMetadata(AJXP_META_SPACE_COMMENTS, $existingFeed, false); HTMLWriter::charsetHeader("application/json"); + $com["hdate"] = AJXP_Utils::relativeDate($com["date"], $mess); echo json_encode($com); break; @@ -63,6 +65,9 @@ public function switchActions($actionName, $httpVars, $fileVars) case "load_comments_feed": HTMLWriter::charsetHeader("application/json"); + foreach($existingFeed as &$item){ + $item["hdate"] = AJXP_Utils::relativeDate($item["date"], $mess); + } echo json_encode($existingFeed); break; @@ -77,6 +82,7 @@ public function switchActions($actionName, $httpVars, $fileVars) continue; } $reFeed[] = $fElement; + $reFeed["hdate"] = AJXP_Utils::relativeDate($reFeed["date"], $mess); } $uniqNode->removeMetadata(AJXP_META_SPACE_COMMENTS, false); $uniqNode->setMetadata(AJXP_META_SPACE_COMMENTS, $reFeed, false); diff --git a/core/src/plugins/meta.comments/class.CommentsPanel.js b/core/src/plugins/meta.comments/class.CommentsPanel.js index 5725c3dbd7..6d318830d3 100644 --- a/core/src/plugins/meta.comments/class.CommentsPanel.js +++ b/core/src/plugins/meta.comments/class.CommentsPanel.js @@ -22,9 +22,7 @@ Class.create("CommentsPanel", { // Warning, method is called statically, there is no "this" loadInfoPanel : function(container, node){ - console.log(container); - - container.down("#comments_container").update("Loading comments..."); + container.down("#comments_container"); container.down("textarea").observe("focus", function(){ ajaxplorer.disableAllKeyBindings(); }); @@ -34,20 +32,38 @@ Class.create("CommentsPanel", { if(node.getMetadata().get("ajxp_has_comments_feed")){ - var conn = new Connexion(); - conn.setParameters({ - file: node.getPath(), - get_action: "load_comments_feed" - }); - conn.onComplete = function(transport){ - container.down("#comments_container").update(''); - var feed = transport.responseJSON; - for(var i=0;i#{author}, #{hdate}
#{content}
'); + var el = new Element("div", {className:'comment_content'}).update(tpl.evaluate(hash._object)); - var el = new Element("div").update("
X
"+hash.get("content")+"
By "+hash.get("author")+" on "+hash.get("date")+"
"); - el.setStyle({opacity:0, display:'block'}); + if(!skipAnim) el.setStyle({opacity:0, display:'block'}); container.down("#comments_container").insert(el); - new Effect.Appear(el, {duration:0.3}); + if(!skipAnim) new Effect.Appear(el, {duration:0.3}); + if(hash.get("author") != ajaxplorer.user.id){ el.down('.comment_delete').remove(); return; @@ -96,12 +117,24 @@ Class.create("CommentsPanel", { container.down("#comments_container").update(''); var feed = transport.responseJSON; for(var i=0;i