madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r19887: LJSUP-9393: Comment__print_expand_collap...

Committer: sbelyaev
LJSUP-9393: Comment__print_expand_collapse_links support templates for expand and collapse links.
U   trunk/bin/upgrading/s2layers/core1.s2
U   trunk/cgi-bin/LJ/S2.pm
Modified: trunk/bin/upgrading/s2layers/core1.s2
===================================================================
--- trunk/bin/upgrading/s2layers/core1.s2	2011-08-30 03:39:29 UTC (rev 19886)
+++ trunk/bin/upgrading/s2layers/core1.s2	2011-08-30 04:13:09 UTC (rev 19887)
@@ -424,6 +424,7 @@
     function builtin print_expand_link (string{} opts) : string "Prints a link to expand a collapsed comment. Can pass options 'text', 'title', 'class', and 'img_url' (and other 'img_*' options).";
 
     function builtin print_expand_collapse_links () "Prints links to expand and to collapse this comment.";
+    function builtin print_expand_collapse_links (string{} template) "Prints links to expand and to collapse this comment (output with template).";
 
     function time_display (string datefmt, string timefmt, bool edittime) : string "Same as EntryLite::time_display, except can pass in if we want the edit time or not.";
     function edittime_display () : string "Show the time that this comment was edited, with most useful information for user.  Empty string if the comment hasn't been edited.";

Modified: trunk/cgi-bin/LJ/S2.pm
===================================================================
--- trunk/cgi-bin/LJ/S2.pm	2011-08-30 03:39:29 UTC (rev 19886)
+++ trunk/cgi-bin/LJ/S2.pm	2011-08-30 04:13:09 UTC (rev 19887)
@@ -3566,25 +3566,32 @@
 
 sub Comment__print_expand_collapse_links
 {
-    my ($ctx, $this) = @_;
+    my ($ctx, $this, $cetemplate) = @_;
+    $cetemplate ||= { 'expand' => '%_', 'collapse' => '%_'};
 
     my $text_expand = LJ::ehtml($ctx->[S2::PROPS]->{"text_comment_expand"});
     my $text_collapse = LJ::ehtml($ctx->[S2::PROPS]->{"text_comment_collapse"});
 
     my $print_expand_link = sub {
-        $S2::pout->(
-            "<span id='expand_$this->{talkid}'>" .
-                "<a href='$this->{thread_url}' onclick=\"ExpanderEx.make(event,this,'$this->{thread_url}','$this->{talkid}',true)\">$text_expand</a>" .
-            "</span>"
-        );
+        return unless $text_expand;
+
+        my $outString = "<span id='expand_$this->{talkid}'>";
+        my $link = "<a href='$this->{thread_url}' onclick=\"ExpanderEx.make(event,this,'$this->{thread_url}','$this->{talkid}',true)\">$text_expand</a>";
+        my $template = $cetemplate->{'expand'};
+        $template =~ s/%_/$link/;
+        $outString .= "$template</span>";
+        $S2::pout->($outString);
     };
 
     my $print_collapse_link = sub {
-        $S2::pout->(
-            "<span id='collapse_$this->{talkid}'>" .
-                "<a href='$this->{thread_url}' onclick=\"ExpanderEx.collapse(event,this,'$this->{thread_url}','$this->{talkid}',true)\">$text_collapse</a>" .
-            "</span>"
-        );
+        return unless $text_collapse;
+
+        my $outString =  "<span id='collapse_$this->{talkid}'>";
+        my $link = "<a href='$this->{thread_url}' onclick=\"ExpanderEx.collapse(event,this,'$this->{thread_url}','$this->{talkid}',true)\">$text_collapse</a>";
+        my $template = $cetemplate->{'collapse'};
+        $template =~ s/%_/$link/;
+        $outString .= "$template</span>";
+        $S2::pout->($outString);
     };
 
     my $show_expand_link = sub {

Tags: livejournal, madeon, pm, s2
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