summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/controls/Comments/comments.js
diff options
context:
space:
mode:
authorwei <>2007-01-26 02:06:46 +0000
committerwei <>2007-01-26 02:06:46 +0000
commit5a34c0337eda45f2b1342771a937fd9a029cb319 (patch)
tree9b690a21c60054c4f64677dbe14974d8bf84fc0e /demos/quickstart/protected/controls/Comments/comments.js
parente30048fca6e6cb351f311b2dc039f31210db8eec (diff)
add "view all comments" for quickstart comments.
Diffstat (limited to 'demos/quickstart/protected/controls/Comments/comments.js')
-rw-r--r--demos/quickstart/protected/controls/Comments/comments.js51
1 files changed, 38 insertions, 13 deletions
diff --git a/demos/quickstart/protected/controls/Comments/comments.js b/demos/quickstart/protected/controls/Comments/comments.js
index 629694a5..46dd0a16 100644
--- a/demos/quickstart/protected/controls/Comments/comments.js
+++ b/demos/quickstart/protected/controls/Comments/comments.js
@@ -6,14 +6,28 @@ function show_comment_list()
$('add-comment').hide();
$('show-comment-link').addClassName("active");
$('add-comment-link').removeClassName("active");
+ $('all-comments-link').removeClassName("active");
+ show_comments_in_list(currentCommentID);
}
+function show_all_comments()
+{
+ $('comment-list').show();
+ $('add-comment').hide();
+ $('show-comment-link').removeClassName("active");
+ $('add-comment-link').removeClassName("active");
+ $('all-comments-link').addClassName("active");
+ show_comments_in_list();
+}
+
+
function show_add_comment()
{
$('comment-list').hide();
$('add-comment').show();
$('show-comment-link').removeClassName("active");
$('add-comment-link').addClassName("active");
+ $('all-comments-link').removeClassName("active");
}
function hide_add_comment()
@@ -24,18 +38,8 @@ function hide_add_comment()
$(currentCommentID).style.zIndex = 0;
}
-function show_comments(block)
+function show_comments_in_list(id)
{
- var id = block.id
- currentCommentID = id;
- $(hidden_block_id).value = id;
- var commentBlock = $('user-comments');
- var pos = Position.cumulativeOffset(block);
- var top = pos[1] + block.offsetHeight;
- commentBlock.style.top = top+"px";
- commentBlock.style.width = (block.offsetWidth-22)+"px";
-
- commentBlock.show();
var list = $('comment-list');
var count=0;
for(var i=0, k=list.childNodes.length; i < k; i++)
@@ -43,7 +47,7 @@ function show_comments(block)
var node = list.childNodes[i];
if(node.nodeType == 1) //an element node
{
- if(node.className.indexOf(id) >= 0)
+ if(typeof(id) == "undefined" || node.className.indexOf(id) >= 0)
{
node.style.display="block"
count++;
@@ -52,8 +56,25 @@ function show_comments(block)
node.style.display="none";
}
}
+ return count;
+}
+
+function show_comments(block)
+{
+ var id = block.id
+ currentCommentID = id;
+ $(hidden_block_id).value = id;
+ var commentBlock = $('user-comments');
+ var pos = Position.cumulativeOffset(block);
+ var top = pos[1] + block.offsetHeight;
+ commentBlock.style.top = top+"px";
+ commentBlock.style.width = (block.offsetWidth-22)+"px";
- list.show();
+ commentBlock.show();
+
+ var count = show_comments_in_list(id);
+
+ $('comment-list').show();
if(count > 0)
show_comment_list();
else
@@ -164,9 +185,12 @@ if(!Prado.Browser.ie) //not IE 4,5,6
$('show-comment-link').style.display="";
$('to-top').hide();
$('close-comments').show();
+ $('all-comments-link').show();
userComments.hide();
$('comments-header').hide();
+ $$('#comment-list .source-link').each(function(el){ el.hide(); });
+
$$('#content .block-content').each(function(el)
{
Event.observe(el, 'mouseover', function(e){ if(typeof(show_block)!="undefined") show_block(Event.element(e)); });
@@ -176,6 +200,7 @@ if(!Prado.Browser.ie) //not IE 4,5,6
Event.observe($('show-comment-link'), "click", function(e) { show_comment_list(); Event.stop(e); });
Event.observe($('add-comment-link'), "click", function(e) { show_add_comment(); Event.stop(e); });
+ Event.observe($('all-comments-link'), "click", function(e) { show_all_comments(); Event.stop(e); });
Event.observe($('close-comments'), "click", function(e) { hide_add_comment(); Event.stop(e); });
})();