changelog_bot (changelog_bot) wrote in changelog,
changelog_bot
changelog_bot
changelog

[ljcom] r9617: LJSUP-6481 show_thread_expander hook ret...

Committer: dnikolaev
LJSUP-6481 show_thread_expander hook returns sub for s1 now.

U   trunk/cgi-bin/LJ/Hooks/SUP.pm
Modified: trunk/cgi-bin/LJ/Hooks/SUP.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/SUP.pm	2010-10-13 09:21:58 UTC (rev 9616)
+++ trunk/cgi-bin/LJ/Hooks/SUP.pm	2010-10-13 09:38:02 UTC (rev 9617)
@@ -641,22 +641,41 @@
     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->{has_closed_children}) {
+            if ($args->{thread_show_link} eq 'expand') {
                 return "(<a href='$args->{thread_url}' " . 
                        qq[onClick="ExpanderEx.make(this,'$args->{thread_url}','$args->{thread_id}',true);return false;"] .
-                       ">" . BML::ml('talk.expandlink') . "</a>)";
+                       ">" . BML::ml('talk.expandlink') . "</a>) ";
             }
-            elsif ($args->{thread_show_collapse}) {
-                return "(<a href='$args->{thread_url}' " .
+            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>)";
+                       ">" . BML::ml('talk.collapselink') . "</a>) </span>";
             }
             else {
                 return '';
@@ -665,16 +684,29 @@
         else {
             return "(<a href='$args->{thread_url}' " .
                    qq[onClick="ExpanderEx.make(this,'$args->{thread_url}','$args->{thread_id}',true);return false;"] .
-                   ">" . BML::ml('talk.expandlink') . "</a>)";
+                   ">" . BML::ml('talk.expandlink') . "</a>) ";
         }  
     };
     
     if ($args && $args->{is_s1}) {
         return undef if $LJ::DISABLED{thread_expander};
+        my $who = (LJ::SUP->is_remote_sup() ? 'sup' : 'nonsup');
+
+        my $func;
+        if (ref($LJ::DISABLED{thread_expander_new}) eq 'HASH') {
+            $func = $LJ::DISABLED{thread_expander_new}->{$who} ?
+                    $thread_expander_old :
+                    $thread_expander_new;
+        } else {
+            $func = $LJ::DISABLED{thread_expander_new} ?
+                    $thread_expander_old :
+                    $thread_expander_new;
+        }
+        
         my $u = LJ::load_userid(LJ::Request->notes("journalid"));
-        return $thread_expander_new if $u && $u->get_cap('thread_expander');
+        return $func if $u && $u->get_cap('thread_expander');
         my $remote = LJ::get_remote();
-        return $thread_expander_new if $remote && $remote->get_cap('thread_expander');
+        return $func if $remote && $remote->get_cap('thread_expander');
         return undef;
     }
     else {

Tags: changelog_bot, ljcom, pm
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments