Skip to content
Browse files

Display the number of comment gildings.

  • Loading branch information...
1 parent 039a85d commit 987eb7b1767b45d162f0e59a276ba4262a2e1d93 @chromakode chromakode committed
View
2 r2/r2/controllers/ipn.py
@@ -346,7 +346,7 @@ def POST_spendcreddits(self, form, jquery, months, passthrough):
if comment:
gilding_message = make_comment_gold_message(comment,
user_gilded=True)
- jquery.gild_comment(comment_id, gilding_message)
+ jquery.gild_comment(comment_id, gilding_message, comment.gildings)
@textresponse(full_sn = VLength('serial-number', 100))
def POST_gcheckout(self, full_sn):
View
2 r2/r2/lib/jsontemplates.py
@@ -380,7 +380,7 @@ def thing_attr(self, thing, attr):
elif attr == "body_html":
return spaceCompress(safemarkdown(thing.body))
elif attr == "gilded":
- return bool(thing.gildings)
+ return thing.gildings
return ThingJsonTemplate.thing_attr(self, thing, attr)
def kind(self, wrapped):
View
2 r2/r2/lib/pages/pages.py
@@ -1199,7 +1199,7 @@ def renderer():
if t.likes is False:
dislikes.append(t._fullname)
if t.user_gilded:
- gildings[t._fullname] = t.gilded_message
+ gildings[t._fullname] = (t.gilded_message, t.gildings)
if t.saved:
saves.add(t._fullname)
self.rendered += ThingUpdater(likes = likes,
View
6 r2/r2/public/static/css/compact.css
@@ -284,12 +284,14 @@ body[orient="landscape"] > #topbar > h1 { margin-left: -125px; width: 250px; }
.comment.collapsed .tagline { margin-left: 20px; font-style: italcs; color: #AAA; }
/** comment gilding */
-.gilded-comment-icon { position: relative; display: inline-block; background-image: url(../gold-coin.png); /* SPRITE */ background-repeat: no-repeat; height: 14px; width: 13px; margin: 0 0 -14px 6px; top: -8px; vertical-align: middle; }
+.gilded-comment-icon { position: relative; display: inline-block; background-image: url(../gold-coin.png); /* SPRITE */ background-repeat: no-repeat; height: 14px; width: 0; padding-left: 13px; margin: 0 0 -14px 6px; top: -8px; vertical-align: middle; }
-.user-gilded > .entry .gilded-comment-icon { width: 23px; }
+.user-gilded > .entry .gilded-comment-icon { padding-left: 23px; }
body.post-under-1h-old .gilded-comment-icon, body.post-under-6h-old .gilded-comment-icon { opacity: .55; }
+.gilded-comment-count { color: #99895F; padding-left: 2px; font-size: .9em; vertical-align: middle; }
+
/** messages and inbox */
.message { background: white; position: relative; border: 1px solid #d9d9d9; margin: 10px; -moz-border-radius: 8px; -webkit-border-radius: 8px; -o-border-radius: 8px; -ms-border-radius: 8px; -khtml-border-radius: 8px; border-radius: 8px; padding: 5px; }
View
11 r2/r2/public/static/css/compact.scss
@@ -882,14 +882,15 @@ padding: 5px;
background-image: url(../gold-coin.png); /* SPRITE */
background-repeat: no-repeat;
height: 14px;
- width: 13px;
+ width: 0;
+ padding-left: 13px;
margin: 0 0 -14px 6px;
top: -8px;
vertical-align: middle;
}
.user-gilded > .entry .gilded-comment-icon {
- width: 23px;
+ padding-left: 23px;
}
body.post-under-1h-old .gilded-comment-icon,
@@ -897,6 +898,12 @@ body.post-under-6h-old .gilded-comment-icon {
opacity: .55;
}
+.gilded-comment-count {
+ color: #99895F;
+ padding-left: 2px;
+ font-size: .9em;
+ vertical-align: middle;
+}
/** messages and inbox */
.message {
View
12 r2/r2/public/static/css/reddit.css
@@ -6318,14 +6318,15 @@ span.gilded-comment-icon {
background-image: url(../gold-coin.png); /* SPRITE */
background-repeat: no-repeat;
height: 14px;
- width: 13px;
+ width: 0;
+ padding-left: 13px;
margin: 0 0 -14px 8px;
top: -8px;
vertical-align: middle;
}
.user-gilded > .entry span.gilded-comment-icon {
- width: 23px;
+ padding-left: 23px;
}
body.post-under-1h-old .gilded-comment-icon,
@@ -6333,6 +6334,13 @@ body.post-under-6h-old .gilded-comment-icon {
opacity: .55;
}
+.gilded-comment-count {
+ color: #99895F;
+ padding-left: 2px;
+ font-size: .9em;
+ vertical-align: middle;
+}
+
.buttons li.comment-save-button { display: none; }
.buttons li.comment-unsave-button { display: inline; }
View
16 r2/r2/public/static/js/gold.js
@@ -64,7 +64,7 @@ r.gold = {
return false
},
- gildComment: function (comment_id, new_title) {
+ gildComment: function (comment_id, new_title, gilding_count) {
var comment = $('.id-' + comment_id)
if (!comment.length) {
@@ -75,13 +75,25 @@ r.gold = {
var tagline = comment.children('.entry').find('p.tagline'),
icon = tagline.find('.gilded-comment-icon')
+ gilding_count = gilding_count || icon.data('count') || 0
+ gilding_count++
+
comment.addClass('gilded user-gilded')
if (!icon.length) {
icon = $('<span>')
.addClass('gilded-comment-icon')
tagline.append(icon)
}
- icon.attr('title', new_title)
+ icon
+ .attr('title', new_title)
+ .data('count', gilding_count)
+ if (gilding_count > 1) {
+ icon.empty()
+ $('<span class="gilded-comment-count">')
+ .text('x' + gilding_count)
+ .appendTo(icon)
+ }
+
comment.children('.entry').find('.give-gold').parent().remove()
}
};
View
8 r2/r2/templates/comment.compact
@@ -65,7 +65,13 @@
## thing.timesince is a cache stub
${unsafe(_("%(timeago)s ago") % dict(timeago=thing.timesince))}
% if thing.gilded_message:
- <span class="gilded-comment-icon" title="${thing.gilded_message}"></span>
+ <span class="gilded-comment-icon" title="${thing.gilded_message}" data-count="${thing.gildings}">
+ % if thing.gildings > 1:
+ <span class="gilded-comment-count">
+ x${thing.gildings}
+ </span>
+ % endif
+ </span>
% endif
</div>
<a href="javascript:void(0)" class="options_link"></a>
View
8 r2/r2/templates/comment.html
@@ -113,7 +113,13 @@
%endif
% if thing.gilded_message:
- <span class="gilded-comment-icon" title="${thing.gilded_message}"></span>
+ <span class="gilded-comment-icon" title="${thing.gilded_message}" data-count="${thing.gildings}">
+ % if thing.gildings > 1:
+ <span class="gilded-comment-count">
+ x${thing.gildings}
+ </span>
+ % endif
+ </span>
% endif
%if collapse:
View
3 r2/r2/templates/thingupdater.html
@@ -37,7 +37,8 @@
var gildings = ${unsafe(simplejson.dumps(thing.gildings))};
for (var gilded_comment in gildings) {
- r.gold.gildComment(gilded_comment, gildings[gilded_comment]);
+ var gilding_data = gildings[gilded_comment];
+ r.gold.gildComment(gilded_comment, gilding_data[0], gilding_data[1]);
}
var saves = ${unsafe(simplejson.dumps(list(thing.saves)))};

0 comments on commit 987eb7b

Please sign in to comment.
Something went wrong with that request. Please try again.