Alexander Nazarov (nfokz) wrote in changelog,
Alexander Nazarov
nfokz
changelog

[livejournal] r22584: LJSUP-13108: Paid repost button

Committer: anazarov
LJSUP-13108: Paid repost button
U   trunk/cgi-bin/weblib.pl
U   trunk/htdocs/js/livejournal.js
Modified: trunk/cgi-bin/weblib.pl
===================================================================
--- trunk/cgi-bin/weblib.pl	2012-08-07 11:18:11 UTC (rev 22583)
+++ trunk/cgi-bin/weblib.pl	2012-08-07 12:31:26 UTC (rev 22584)
@@ -2149,6 +2149,7 @@
     LJ::need_res(qw{js/jquery/jquery.lj.repostbutton.js
                     templates/CleanHtml/reposted.tmpl
                     templates/CleanHtml/Repost.tmpl
+                    templates/CleanHtml/PaidRepost.tmpl
                     js/s2.js
                     js/jquery/jquery.lj.confirmbubble.js
                     templates/Widgets/popupcontent.tmpl

Modified: trunk/htdocs/js/livejournal.js
===================================================================
--- trunk/htdocs/js/livejournal.js	2012-08-07 11:18:11 UTC (rev 22583)
+++ trunk/htdocs/js/livejournal.js	2012-08-07 12:31:26 UTC (rev 22584)
@@ -455,16 +455,30 @@
 
 	var initRepostButton = function(link, url, data) {
 		data = data || {};
-		var reposted = !!data.reposted;
 
-		var repostNode = LJ.UI.template('templates-CleanHtml-Repost', { url: url,
-			count: data.count || 0, reposted: reposted });
+		var meta = {
+				paid: !!data.paid,
+				url: url,
+				cost: Number(data.cost || 0),
+				budget: Number(data.budget || 0),
+				count: Number(data.count || 0),
+				reposted: !!data.reposted
+			},
+			template = 'templates-CleanHtml-Repost',
+			options = {};
+
+		if (meta.paid) {
+			template = 'templates-CleanHtml-PaidRepost';
+			meta.owner = !meta.cost;
+			options.classNames = {
+				active: 'paidrepost-button-active',
+				inactive: 'paidrepost-button-inactive'
+			};
+		}
+
+		var repostNode = LJ.UI.template(template, meta);
 		link.replaceWith(repostNode);
-
-		repostNode.repostbutton({
-			url: url,
-			reposted: reposted
-		});
+		repostNode.repostbutton(jQuery.extend(options, meta));
 	}
 	
 	jQuery('div.lj-like-item-repost > a', ctx || document).each(function() {

Tags: anazarov, js, livejournal, nfokz, pl
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