madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r22136: LJSUP-12148: JSON-RPC

Committer: sbelyaev
LJSUP-12148: JSON-RPC
U   trunk/cgi-bin/LJ/Entry/Repost.pm
U   trunk/cgi-bin/LJ/S2.pm
Modified: trunk/cgi-bin/LJ/Entry/Repost.pm
===================================================================
--- trunk/cgi-bin/LJ/Entry/Repost.pm	2012-05-31 12:30:37 UTC (rev 22135)
+++ trunk/cgi-bin/LJ/Entry/Repost.pm	2012-05-31 12:41:08 UTC (rev 22136)
@@ -362,6 +362,13 @@
     return LJ::API::Error->get_error('entry_not_found');
 }
 
+sub render_delete_js {
+    my ($class, $url) = @_;
+    return
+        qq{<script type="text/javascript">jQuery('a:last').click(function(ev) {
+        ev.preventDefault(); LiveJournal.run_hook('repost.requestRemove', this, $url); });</script>};
+}
+
 sub create {
     my ($class, $u, $entry_obj, $timezone) = @_;
     my $result = {};

Modified: trunk/cgi-bin/LJ/S2.pm
===================================================================
--- trunk/cgi-bin/LJ/S2.pm	2012-05-31 12:30:37 UTC (rev 22135)
+++ trunk/cgi-bin/LJ/S2.pm	2012-05-31 12:41:08 UTC (rev 22136)
@@ -1958,7 +1958,7 @@
     $e->{'depth'} = 0;  # Entries are always depth 0.  Comments are 1+.
 
     my $link_keyseq = $e->{'link_keyseq'};
-    push @$link_keyseq, 'delete_reference'  if LJ::is_enabled('entry_reference');
+    push @$link_keyseq, 'delete_repost'  if LJ::is_enabled('entry_reference');
     push @$link_keyseq, 'mem_add'           if LJ::is_enabled('memories');
     push @$link_keyseq, 'tell_friend'       if LJ::is_enabled('tellafriend');
     push @$link_keyseq, 'share'             if LJ::is_enabled('sharing');
@@ -3996,14 +3996,16 @@
     my $real_user = $this->{'real_journalid'} ? LJ::want_user($this->{'real_journalid'}) : undef;
 
     if ($this->{'real_itemid'}) {
-        if ($key eq 'delete_reference') {
+        if ($key eq 'delete_repost') {
             return $null_link unless $remote;
             return $null_link unless LJ::u_equals($remote, $real_user);
 
             my $entry = LJ::Entry->new($journalu, ditemid => $this->{'itemid'});
-            return LJ::S2::Link($entry->url,
+            my $link = LJ::S2::Link($entry->url,
                             $ctx->[S2::PROPS]->{"text_delete_repost"},
                             LJ::S2::Image("$LJ::IMGPREFIX/btn_delete_repost.gif", 24, 24));
+            $link->{'_raw'} = LJ::Entry::Repost->render_delete_js( $entry->url );
+            return $link;
         }
     }
 

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