Committer: dnikolaev
LJSUP-7813: New thread expander in S2, minimalismU trunk/bin/upgrading/s2layers/sup/layout.s2 U trunk/cgi-bin/LJ/Hooks/SUP.pm
Modified: trunk/bin/upgrading/s2layers/sup/layout.s2 =================================================================== --- trunk/bin/upgrading/s2layers/sup/layout.s2 2011-03-29 09:26:16 UTC (rev 10322) +++ trunk/bin/upgrading/s2layers/sup/layout.s2 2011-03-30 01:53:21 UTC (rev 10323) @@ -1416,34 +1416,45 @@ function EntryPage::print_comments (Comment[] cs) { var Page p = get_page(); if (size $cs == 0) { return; } + foreach var Comment c ($cs) { - var int indent = ($c.depth - 1) * 25; - var string comment_classes = "comment-wrap"; - if ($c.deleted) { $comment_classes = $comment_classes + " deleted"; } - if ($c.screened) { $comment_classes = $comment_classes + " screened"; } - if ($c.edited) { $comment_classes = $comment_classes + " edited"; } - if ($c.frozen) { $comment_classes = $comment_classes + " frozen"; } - if ($c.spam) { $comment_classes = $comment_classes + " spam"; } - if (not $c.full) { $comment_classes = $comment_classes + " partial"; } - """<div id="$c.dom_id" class="$comment_classes" style="margin-left:${indent}px;">"""; - if ($c.screened and not $c.full and not viewer_is_owner()) { - """<strong>(Screened comment)</strong>"""; - } elseif ($c.deleted) { - """<strong>(Deleted comment)</strong>"""; - } elseif (($c.spam) and (not $p.showspam) and (size($c.replies) > 0)) { - """<strong>$*text_spam_comment</strong>"""; - } elseif ($c.full) { - $this->print_comment($c); - } else { - $this->print_comment_partial($c); - } - "</div>"; - $c->print_reply_container(); + $this->print_comment($c); $this->print_comments($c.replies); } } function EntryPage::print_comment (Comment c) { + var Page p = get_page(); + var int indent = ($c.depth - 1) * 25; + + var string comment_classes = "comment-wrap"; + if ($c.deleted) { $comment_classes = $comment_classes + " deleted"; } + if ($c.screened) { $comment_classes = $comment_classes + " screened"; } + if ($c.edited) { $comment_classes = $comment_classes + " edited"; } + if ($c.frozen) { $comment_classes = $comment_classes + " frozen"; } + if ($c.spam) { $comment_classes = $comment_classes + " spam"; } + if (not $c.full) { $comment_classes = $comment_classes + " partial"; } + + """<div id="$c.dom_id" class="$comment_classes" style="margin-left:${indent}px;">"""; + + if ($c.screened and not $c.full and not viewer_is_owner()) { + """<strong>$*text_comment_screened</strong>"""; + } elseif ($c.deleted) { + """<strong>$*text_comment_deleted</strong>"""; + } elseif (($c.spam) and (not $p.showspam) and (size($c.replies) > 0)) { + """<strong>$*text_spam_comment</strong>"""; + } elseif ($c.full) { + $this->print_comment_full($c); + } else { + $this->print_comment_partial($c); + } + + "</div>"; + + $c->print_reply_container(); +} + +function EntryPage::print_comment_full (Comment c) { var string poster = defined $c.poster ? _user_print($c.poster, "microformatted") : "<em>$*text_poster_anonymous</em>"; var string evenodd = $c.depth % 2 ? "odd" : "even"; if (defined $c.userpic and $*comment_userpic_style != "off") { @@ -1481,10 +1492,7 @@ if ($c.parent_url != "") { print safe """(<a href="$c.parent_url">$*text_comment_parent</a>) """; } if ($c.thread_url != "") { print safe """(<a href="$c.thread_url">$*text_comment_thread</a>) """; - var Link expand_link = $c->get_link("expand_comments"); - if (defined $expand_link) { - "("; $c->print_expand_link(); ") "; - } + $c->print_expand_collapse_links(); } """</div><div class="hr"><hr /></div>"""; } @@ -1496,8 +1504,7 @@ $subj = "…"; } print safe """<a href="$c.permalink_url">$subj</a> <span class="emdash">—</span> $poster"""; - var Link expand_link = $c->get_link("expand_comments"); - if ($c.thread_url != "" and defined $expand_link) { - " ("; $c->print_expand_link(); ")"; + if ($c.thread_url != "") { + $c->print_expand_collapse_links(); } } Modified: trunk/cgi-bin/LJ/Hooks/SUP.pm =================================================================== --- trunk/cgi-bin/LJ/Hooks/SUP.pm 2011-03-29 09:26:16 UTC (rev 10322) +++ trunk/cgi-bin/LJ/Hooks/SUP.pm 2011-03-30 01:53:21 UTC (rev 10323) @@ -638,76 +638,9 @@ LJ::register_hook('show_thread_expander', sub { my $args = shift; - my $thread_expander_old = sub { - my $args = shift; - - if ($args->{thread_loaded}) { - if ($args->{thread_show_link}) { - return "(<a href='$args->{thread_url}' " . - qq[onClick="Expander.make(this,'$args->{thread_url}','$args->{thread_id}',true);return false;"] . - ">" . BML::ml('talk.expandlink') . "</a>) "; - } - else { - return ''; - } - } - else { - return "(<a href='$args->{thread_url}' " . - qq[onClick="Expander.make(this,'$args->{thread_url}','$args->{thread_id}',true);return false;"] . - ">" . BML::ml('talk.expandlink') . "</a>) "; - } - }; - - my $thread_expander_new = sub { - my $args = shift; - - if ($args->{thread_loaded}) { - if ($args->{thread_show_link} eq 'expand') { - return "<span>(<a href='$args->{thread_url}' " . - qq[onClick="ExpanderEx.make(this,'$args->{thread_url}','$args->{thread_id}',true);return false;"] . - ">" . BML::ml('talk.expandlink') . "</a>)</span> "; - } - elsif ($args->{thread_show_link} eq 'all') { - return "<span id='expand_$args->{thread_id}'>(<a href='$args->{thread_url}' " . - qq[onClick="ExpanderEx.make(this,'$args->{thread_url}','$args->{thread_id}',true);return false;"] . - ">" . BML::ml('talk.expandlink') . "</a>) </span>" . - "<span id='collapse_$args->{thread_id}'>(<a href='$args->{thread_url}' " . - qq[onClick="ExpanderEx.collapse(this,'$args->{thread_url}','$args->{thread_id}',true);return false;"] . - ">" . BML::ml('talk.collapselink') . "</a>) </span>"; - } - else { - return ''; - } - } - else { - return "<span>(<a href='$args->{thread_url}' " . - qq[onClick="ExpanderEx.make(this,'$args->{thread_url}','$args->{thread_id}',true);return false;"] . - ">" . BML::ml('talk.expandlink') . "</a>)</span> "; - } - }; - if ($args && $args->{is_s1}) { - return undef if $LJ::DISABLED{thread_expander}; - - my $who = (LJ::SUP->is_remote_sup() ? 'sup' : 'nonsup'); - - my $use_new = 0; - if (ref($LJ::DISABLED{thread_expander_new}) eq 'HASH') { - $use_new = $LJ::DISABLED{thread_expander_new}->{$who} ? 0 : 1; - } else { - $use_new = $LJ::DISABLED{thread_expander_new} ? 0 : 1; - } - - if ($use_new) { - return $thread_expander_new; - } else { - my $u = LJ::load_userid(LJ::Request->notes("journalid")); - unless ($u && $u->get_cap('thread_expander')) { - my $remote = LJ::get_remote(); - return undef unless ($remote && $remote->get_cap('thread_expander')); - } - return $thread_expander_old; - } + return 0 if $LJ::DISABLED{thread_expander}; + return 1; } else { return 0 if $LJ::DISABLED{thread_expander};