fave number in non-expanded queets
This commit is contained in:
parent
9984cf2911
commit
e3da8af8e2
|
@ -486,8 +486,18 @@ class QvitterPlugin extends Plugin {
|
|||
$twitter_status['in_reply_to_profileurl'] = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// fave number
|
||||
$faves = Fave::byNotice($notice);
|
||||
$favenum = count($faves);
|
||||
$twitter_status['fave_num'] = $favenum;
|
||||
|
||||
// repeat number
|
||||
$repeats = $notice->repeatStream();
|
||||
$repeatnum=0;
|
||||
while ($repeats->fetch()) {
|
||||
$repeatnum++;
|
||||
}
|
||||
$twitter_status['repeat_num'] = $repeatnum;
|
||||
|
||||
// some more metadata about notice
|
||||
if($notice->is_local == '1') {
|
||||
|
|
|
@ -2158,11 +2158,12 @@ ul.queet-actions {
|
|||
display: block;
|
||||
font-family: "Helvetica Neue",Arial,sans-serif;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
line-height: 26px;
|
||||
list-style: outside none none;
|
||||
margin: 5px 0 0;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
height:26px;
|
||||
}
|
||||
.queet.rtl ul.queet-actions {
|
||||
right:auto;
|
||||
|
@ -2173,7 +2174,10 @@ ul.queet-actions {
|
|||
|
||||
|
||||
ul.queet-actions a {
|
||||
color:#ddd;
|
||||
color: #ddd;
|
||||
display: block;
|
||||
height: 26px;
|
||||
line-height: 26px;
|
||||
}
|
||||
|
||||
.queet:hover ul.queet-actions > li > a {
|
||||
|
@ -2186,22 +2190,24 @@ ul.queet-actions a {
|
|||
display: block;
|
||||
}
|
||||
ul.queet-actions li {
|
||||
display:inline;
|
||||
display: inline-block;
|
||||
height: 26px;
|
||||
line-height: 26px;
|
||||
}
|
||||
ul.queet-actions li .icon {
|
||||
background-repeat: no-repeat;
|
||||
background-repeat: no-repeat;
|
||||
display: inline-block;
|
||||
vertical-align: text-top;
|
||||
height: 25px;
|
||||
line-height:25px;
|
||||
width:25px;
|
||||
text-align:center;
|
||||
margin-right:31px;
|
||||
font-size:17px;
|
||||
font-size: 17px;
|
||||
height: 25px;
|
||||
line-height: 25px;
|
||||
text-align: center;
|
||||
margin-right:7px;
|
||||
}
|
||||
ul.queet-actions li:not(:first-child) .icon {
|
||||
margin-left:26px;
|
||||
}
|
||||
.queet.rtl ul.queet-actions li .icon {
|
||||
margin-right:0;
|
||||
margin-left:31px;
|
||||
margin-right:0;
|
||||
}
|
||||
ul.queet-actions li.action-rt-container .with-icn.done .icon:before {
|
||||
color: #609928;
|
||||
|
@ -2220,15 +2226,41 @@ ul.queet-actions li.action-fav-container .with-icn.done .icon:before {
|
|||
}
|
||||
|
||||
|
||||
ul.queet-actions li.action-rq-num,
|
||||
ul.queet-actions li.action-fav-num {
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
display: inline-block;
|
||||
font-family: "Helvetica Neue",Arial,sans-serif;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
height: 26px;
|
||||
line-height: 32px;
|
||||
vertical-align: top;
|
||||
}
|
||||
.stream-item.expanded:not(.collapsing) > .queet ul.queet-actions li.action-rq-num,
|
||||
.stream-item.expanded:not(.collapsing) > .queet ul.queet-actions li.action-fav-num,
|
||||
ul.queet-actions li.action-rq-num[data-rq-num="0"],
|
||||
ul.queet-actions li.action-fav-num[data-fav-num="0"] {
|
||||
display:none;
|
||||
}
|
||||
|
||||
.stream-item.requeeted > .queet ul.queet-actions li.action-rq-num {
|
||||
color:#609928;
|
||||
}
|
||||
.stream-item.favorited > .queet ul.queet-actions li.action-fav-num {
|
||||
color:#ffac33;
|
||||
}
|
||||
|
||||
ul.queet-actions li .icon:before {
|
||||
font-family:FontAwesome;
|
||||
font-size:inherit;
|
||||
color:rgba(0,0,0,0.15);
|
||||
height: 25px;
|
||||
line-height:25px;
|
||||
width:25px;
|
||||
text-align:center;
|
||||
display:block;
|
||||
color: rgba(0, 0, 0, 0.15);
|
||||
display: inline-block;
|
||||
font-family: FontAwesome;
|
||||
font-size: inherit;
|
||||
height: 26px;
|
||||
line-height: 26px;
|
||||
text-align: center;
|
||||
vertical-align:text-top;
|
||||
width:21px;
|
||||
}
|
||||
.stream-item.temp-post ul.queet-actions li .icon:before {
|
||||
color:rgba(0,0,0,0.05);
|
||||
|
@ -2244,7 +2276,7 @@ ul.queet-actions li .icon.sm-fav.pulse:before {
|
|||
}
|
||||
@keyframes starpulse {
|
||||
0% {font-size: 17px;}
|
||||
50% {font-size: 25px;}
|
||||
50% {font-size: 22px;}
|
||||
100% {font-size: 17px;}
|
||||
}
|
||||
|
||||
|
@ -2281,7 +2313,6 @@ ul.queet-actions li .icon.sm-fav:before {
|
|||
ul.queet-actions li .icon.sm-ellipsis:before {
|
||||
content: "\f141";
|
||||
font-size: 22px;
|
||||
line-height: 28px;
|
||||
}
|
||||
ul.queet-actions li .icon.is-mine:before {
|
||||
opacity:0.4;
|
||||
|
|
|
@ -397,19 +397,16 @@ function getFavsAndRequeetsForQueet(q,qid) {
|
|||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
|
||||
if(data.favs.length > 0 || data.repeats.length > 0) {
|
||||
|
||||
localStorageObjectCache_STORE('favsAndRequeets',qid, data); // cache response
|
||||
|
||||
if(q.hasClass('expanded') && !q.hasClass('collapsing')) {
|
||||
showFavsAndRequeetsInQueet(q,data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// remove from cache and DOM if all favs and repeats are deleted
|
||||
localStorageObjectCache_STORE('favsAndRequeets',qid, false);
|
||||
q.children('.queet').find('.stats').remove();
|
||||
}
|
||||
|
||||
showFavsAndRequeetsInQueet(q,data);
|
||||
},
|
||||
error: function(data) {
|
||||
remove_spinner();
|
||||
|
|
|
@ -49,14 +49,31 @@
|
|||
|
||||
function showFavsAndRequeetsInQueet(q,data) {
|
||||
|
||||
// set the non-expanded fav- and rq-count
|
||||
q.children('.queet').find('.action-fav-num').html(data.favs.length);
|
||||
q.children('.queet').find('.action-fav-num').attr('data-fav-num',data.favs.length);
|
||||
q.children('.queet').find('.action-rq-num').html(data.repeats.length);
|
||||
q.children('.queet').find('.action-rq-num').attr('data-rq-num',data.repeats.length);
|
||||
|
||||
// don't proceed if queet is not expanded
|
||||
if(!q.hasClass('expanded') || q.hasClass('collapsing')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// don't proceed and remove expanded stats if all favs and repeats are removed
|
||||
if(data.favs.length < 1 && data.repeats.length < 1) {
|
||||
q.children('.queet').find('.stats').remove();
|
||||
return;
|
||||
}
|
||||
|
||||
// remove any existing stats container and add a new empty one
|
||||
if(q.children('.queet').find('ul.stats').length > 0) {
|
||||
q.children('.queet').find('ul.stats').remove();
|
||||
}
|
||||
|
||||
q.children('.queet').find('.queet-stats-container').prepend('<ul class="stats"><li class="avatar-row"></li></ul>');
|
||||
|
||||
// add favs
|
||||
|
||||
// set the expanded fav-count number
|
||||
if(data.favs.length > 0) {
|
||||
|
||||
if(data.favs.length == 1) {
|
||||
|
@ -65,13 +82,13 @@ function showFavsAndRequeetsInQueet(q,data) {
|
|||
else if(data.favs.length > 1) {
|
||||
var favLabel = window.sL.favoritesNoun;
|
||||
}
|
||||
|
||||
|
||||
if(q.children('.queet').find('.fav-count').length>0) {
|
||||
q.children('.queet').find('.fav-count').children('strong').html(data.favs.length);
|
||||
}
|
||||
else {
|
||||
q.children('.queet').find('li.avatar-row').before('<li class="fav-count"><a>' + favLabel + ' </a><strong>' + data.favs.length + '</strong></li>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add repeats
|
||||
|
@ -1910,7 +1927,7 @@ function buildQueetHtml(obj, idInStream, extraClassesThisRun, requeeted_by, isCo
|
|||
// actions only for logged in users
|
||||
var queetActions = '';
|
||||
if(typeof window.loggedIn.screen_name != 'undefined') {
|
||||
queetActions = '<ul class="queet-actions"><li class="action-reply-container"><a class="with-icn"><span class="icon sm-reply" title="' + window.sL.replyVerb + '"></span></a></li>' + requeetHtml + '<li class="action-fav-container">' + favoriteHtml + '</li><li class="action-ellipsis-container"><a class="with-icn"><span class="icon sm-ellipsis" title="' + window.sL.ellipsisMore + '"></span></a></li></ul>';
|
||||
queetActions = '<ul class="queet-actions"><li class="action-reply-container"><a class="with-icn"><span class="icon sm-reply" title="' + window.sL.replyVerb + '"></span></a></li>' + requeetHtml + '<li class="action-rq-num" data-rq-num="' + obj.repeat_num + '">' + obj.repeat_num + '</li><li class="action-fav-container">' + favoriteHtml + '</li><li class="action-fav-num" data-fav-num="' + obj.fave_num + '">' + obj.fave_num + '</li><li class="action-ellipsis-container"><a class="with-icn"><span class="icon sm-ellipsis" title="' + window.sL.ellipsisMore + '"></span></a></li></ul>';
|
||||
}
|
||||
|
||||
// reply-to html
|
||||
|
|
|
@ -1742,15 +1742,25 @@ $('body').on('click','.action-ellipsis-container .delete-queet',function(e){
|
|||
|
||||
$('body').on('click','.action-rt-container .icon:not(.is-mine)',function(){
|
||||
var this_stream_item = $(this).closest('.stream-item');
|
||||
var this_queet = this_stream_item.children('.queet');
|
||||
var this_action = $(this).closest('li');
|
||||
|
||||
// requeet
|
||||
if(!this_action.children('.with-icn').hasClass('done')) {
|
||||
|
||||
// update the repeat count immediately
|
||||
var newRqNum = parseInt(this_queet.find('.action-rq-num').html(),10)+1;
|
||||
this_queet.find('.action-rq-num').html(newRqNum);
|
||||
this_queet.find('.action-rq-num').attr('data-rq-num',newRqNum);
|
||||
|
||||
this_action.children('.with-icn').addClass('done');
|
||||
this_stream_item.addClass('requeeted');
|
||||
|
||||
// requeet animation
|
||||
this_action.children('.with-icn').children('.sm-rt').addClass('rotate');
|
||||
this_action.children('.with-icn').children('.sm-rt').addClass('rotate');
|
||||
|
||||
// remove the fav and rq cache for this queet, to avoid number flickering
|
||||
localStorageObjectCache_STORE('favsAndRequeets',this_stream_item.attr('data-quitter-id'), false);
|
||||
|
||||
// post requeet
|
||||
postActionToAPI('statuses/retweet/' + this_stream_item.attr('data-quitter-id') + '.json', function(data) {
|
||||
|
@ -1795,7 +1805,8 @@ $('body').on('click','.action-rt-container .icon:not(.is-mine)',function(){
|
|||
· · · · · · · · · · · · · */
|
||||
|
||||
$('body').on('click','.action-fav-container',function(){
|
||||
var this_stream_item = $(this).parent().parent().parent().parent().parent();
|
||||
var this_stream_item = $(this).closest('.stream-item');
|
||||
var this_queet = this_stream_item.children('.queet');
|
||||
|
||||
// don't do anything if this is a queet being posted
|
||||
if(this_stream_item.hasClass('temp-post')) {
|
||||
|
@ -1806,12 +1817,20 @@ $('body').on('click','.action-fav-container',function(){
|
|||
|
||||
// fav
|
||||
if(!this_action.children('.with-icn').hasClass('done')) {
|
||||
|
||||
// update the fav count immediately
|
||||
var newFavNum = parseInt(this_queet.find('.action-fav-num').html(),10)+1;
|
||||
this_queet.find('.action-fav-num').html(newFavNum);
|
||||
this_queet.find('.action-fav-num').attr('data-fav-num',newFavNum);
|
||||
|
||||
this_action.children('.with-icn').addClass('done');
|
||||
this_stream_item.addClass('favorited');
|
||||
this_stream_item.addClass('favorited');
|
||||
|
||||
// fav animation
|
||||
this_action.children('.with-icn').children('.sm-fav').addClass('pulse');
|
||||
|
||||
// remove the fav and rq cache for this queet, to avoid number flickering
|
||||
localStorageObjectCache_STORE('favsAndRequeets',this_stream_item.attr('data-quitter-id'), false);
|
||||
|
||||
// post fav
|
||||
postActionToAPI('favorites/create/' + this_stream_item.attr('data-quitter-id') + '.json', function(data) {
|
||||
|
@ -1833,16 +1852,23 @@ $('body').on('click','.action-fav-container',function(){
|
|||
}
|
||||
// unfav
|
||||
else {
|
||||
display_spinner();
|
||||
|
||||
// update the fav count immediately
|
||||
var newFavNum = Math.max(0, parseInt(this_queet.find('.action-fav-num').html(),10)-1);
|
||||
this_queet.find('.action-fav-num').html(newFavNum);
|
||||
this_queet.find('.action-fav-num').attr('data-fav-num',newFavNum);
|
||||
|
||||
this_action.children('.with-icn').removeClass('done');
|
||||
this_action.find('.with-icn b').html(window.sL.favoriteVerb);
|
||||
this_stream_item.removeClass('favorited');
|
||||
|
||||
// remove the fav and rq cache for this queet, to avoid number flickering
|
||||
localStorageObjectCache_STORE('favsAndRequeets',this_stream_item.attr('data-quitter-id'), false);
|
||||
|
||||
// post unfav
|
||||
postActionToAPI('favorites/destroy/' + this_stream_item.attr('data-quitter-id') + '.json', function(data) {
|
||||
if(data) {
|
||||
// success
|
||||
remove_spinner();
|
||||
getFavsAndRequeetsForQueet(this_stream_item, this_stream_item.attr('data-quitter-id'));
|
||||
|
||||
// mark all instances of this notice as non-favorited
|
||||
|
@ -1851,7 +1877,6 @@ $('body').on('click','.action-fav-container',function(){
|
|||
}
|
||||
else {
|
||||
// error
|
||||
remove_spinner();
|
||||
this_action.children('.with-icn').addClass('done');
|
||||
this_action.find('.with-icn b').html(window.sL.favoritedVerb);
|
||||
this_stream_item.addClass('favorited');
|
||||
|
|
Loading…
Reference in New Issue
Block a user