Add link on feed items
This commit is contained in:
@@ -739,7 +739,7 @@ function focusOnPost(oFocusPost) {
|
||||
var $Post = oSpot.tmp('$PostList').find(sElemId);
|
||||
var bGetToTop = (oSpot.tmp('$PostList').height() - (($Post.length > 0)?$Post.position().top:0) >= $(window).height());
|
||||
if($Post.length > 0 && (bGetToTop || self.tmp('out-of-data'))) {
|
||||
self.tmp('simple-bar').getScrollElement().scrollTop = $Post.position().top + self.tmp('$Poster').outerHeight(true);
|
||||
self.tmp('simple-bar').getScrollElement().scrollTop = $Post.position().top + parseInt($Post.css('margin-top')) + self.tmp('$Poster').outerHeight(true);
|
||||
if(oFocusPost.type=='media' || oFocusPost.type=='message') $Post.find('a.drill').click();
|
||||
}
|
||||
else if(!self.tmp('out-of-data')) updateFeed(false, false, function() {focusOnPost(oFocusPost);});
|
||||
@@ -758,6 +758,9 @@ function setFeedUpdateTimer(iSeconds, fCallback) {
|
||||
|
||||
function getPost(asPost) {
|
||||
asPost.headerless = asPost.headerless || false;
|
||||
var bLink = false;
|
||||
var asHash = oSpot.getHash();
|
||||
var sHash = '#'+[asHash.page, asHash.items[0], asPost.type, asPost.id].join(self.consts.hash_sep);
|
||||
|
||||
var $Post = $('<div>', {'class':'post-item '+asPost.type+(asPost.headerless?' headerless':'')});
|
||||
if(asPost.id) $Post.prop('id', asPost.type+'-'+asPost.id);
|
||||
@@ -769,6 +772,7 @@ function getPost(asPost) {
|
||||
|
||||
switch(asPost.type) {
|
||||
case 'message':
|
||||
bLink = true;
|
||||
$Body = $('<div>', {'class':'body-box'})
|
||||
.data('id', asPost.id_message)
|
||||
.data('clicked', false)
|
||||
@@ -811,10 +815,12 @@ function getPost(asPost) {
|
||||
);
|
||||
break;
|
||||
case 'media':
|
||||
bLink = true;
|
||||
$Body = $('<div>', {'class':'body-box'}).append(getMediaLink(asPost, 'post'));
|
||||
if(asPost.comment) $Body.find('a.drill').append($('<span>', {'class':'comment'}).text(asPost.comment));
|
||||
break;
|
||||
case 'post':
|
||||
bLink = true;
|
||||
$Body = $('<div>')
|
||||
.append($('<p>', {'class':'message'}).text(asPost.content))
|
||||
.append($('<p>', {'class':'signature'}).text('-- '+asPost.formatted_name));
|
||||
@@ -832,11 +838,27 @@ function getPost(asPost) {
|
||||
|
||||
$Post
|
||||
.append($('<div>', {'class':'header'})
|
||||
.append($('<span>', {'class':'index'}).addIcon('fa-'+sType))
|
||||
.append($('<span>', {'class':'index'})
|
||||
.addIcon('fa-'+sType)
|
||||
.append(asPost.displayed_id?' '+oSpot.lang('counter', asPost.displayed_id):'')
|
||||
)
|
||||
.append($('<span>', {'class':'time'}).hoverSwap(sRelTime, sAbsTime+((self.tmp('site_tz_notice')!='')?' ('+self.tmp('site_tz_notice')+')':''))))
|
||||
.append($('<div>', {'class':'body'}).append($Body));
|
||||
|
||||
if(asPost.displayed_id) $Post.find('.index').append(' '+oSpot.lang('counter', asPost.displayed_id));
|
||||
if(bLink) {
|
||||
$Post.find('.index').append($('<a>', {'class':'link', 'href':sHash, 'title':oSpot.lang('copy_to_clipboard')})
|
||||
.data('url', self.consts.server+sHash)
|
||||
.addIcon('fa-link')
|
||||
.click(function(){
|
||||
copyTextToClipboard($(this).data('url'));
|
||||
$(this).parent().append($('<span>', {'class':'link_copied'})
|
||||
.text(oSpot.lang('link_copied'))
|
||||
.delay(5000)
|
||||
.fadeOut(400, function(){$(this).remove();})
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return $Post;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user