remove profile popups (being replaced with hoovercards), tooltip fixes, ostatus uri in api user arrays
This commit is contained in:
parent
d6a023d4a5
commit
3eebbb34ef
|
@ -587,7 +587,6 @@ class QvitterPlugin extends Plugin {
|
|||
$twitter_user['cover_photo'] = Profile_prefs::getConfigData($profile, 'qvitter', 'cover_photo');
|
||||
$twitter_user['background_image'] = Profile_prefs::getConfigData($profile, 'qvitter', 'background_image');
|
||||
|
||||
|
||||
// follows me?
|
||||
if ($scoped) {
|
||||
$twitter_user['follows_you'] = $profile->isSubscribed($scoped);
|
||||
|
@ -597,6 +596,19 @@ class QvitterPlugin extends Plugin {
|
|||
$twitter_user['is_local'] = $profile->isLocal();
|
||||
|
||||
|
||||
// ostatus uri
|
||||
if($twitter_user['is_local']) {
|
||||
$user = $profile->getUser();
|
||||
if($user instanceof User) {
|
||||
$twitter_user['ostatus_uri'] = $user->uri;
|
||||
}
|
||||
} else {
|
||||
$ostatus_profile = Ostatus_profile::getKV('profile_id',$profile->id);
|
||||
if($ostatus_profile instanceof Ostatus_profile) {
|
||||
$twitter_user['ostatus_uri'] = $ostatus_profile->uri;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1313,6 +1313,7 @@ body.rtl #footer-spinner-container {
|
|||
transition-duration: 0.1s;
|
||||
transition-timing-function: ease-in;
|
||||
transition-delay: 0.6s;
|
||||
word-break: break-all;
|
||||
}
|
||||
.tooltip-caret {
|
||||
z-index: 10000;
|
||||
|
@ -2154,36 +2155,6 @@ body.rtl .view-more-container-bottom { direction:rtl; }
|
|||
left: 32px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#popup-external-profile .profile-card,
|
||||
#popup-external-profile .profile-card .profile-banner-footer,
|
||||
#popup-local-profile .profile-card,
|
||||
#popup-local-profile .profile-card .profile-banner-footer {
|
||||
border-radius:0;
|
||||
}
|
||||
#popup-external-profile ul.queet-actions,
|
||||
#popup-local-profile ul.queet-actions {
|
||||
display:none;
|
||||
}
|
||||
#popup-external-profile .queet,
|
||||
#popup-external-profile .queet-content,
|
||||
#popup-external-profile .queet-text
|
||||
#popup-local-profile .queet,
|
||||
#popup-local-profile .queet-content,
|
||||
#popup-local-profile .queet-text {
|
||||
cursor:auto;
|
||||
border-bottom:0 none;
|
||||
}
|
||||
#popup-external-profile .stream-item .stream-item-header .name:before,
|
||||
#popup-local-profile .stream-item .stream-item-header .name:before {
|
||||
left:10px;
|
||||
}
|
||||
#popup-external-profile .go-to-external-profile,
|
||||
#popup-local-profile .go-to-local-profile {
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
.stream-item-header .name {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
|
@ -3855,12 +3826,6 @@ button.shorten:after {
|
|||
top: 20px;
|
||||
}
|
||||
|
||||
#popup-external-profile-spinner .loader,
|
||||
#popup-local-profile-spinner .loader {
|
||||
position:absolute;
|
||||
top:150px;
|
||||
}
|
||||
|
||||
.reload-stream {
|
||||
display: block;
|
||||
position: absolute;
|
||||
|
|
|
@ -359,60 +359,6 @@ function addProfileCardToDOM(data) {
|
|||
}
|
||||
|
||||
|
||||
/* ·
|
||||
·
|
||||
· Open external profile card in popup
|
||||
·
|
||||
· @param data: an object with a user array
|
||||
·
|
||||
· · · · · · · · · */
|
||||
|
||||
function openExternalProfileInPopup(data) {
|
||||
|
||||
var data = buildExternalProfileCard(data);
|
||||
|
||||
// preview latest notice
|
||||
var noticeHtml = '';
|
||||
if(typeof data.status != 'undefined') {
|
||||
data.status.user = data;
|
||||
if(data.status.source != 'activity' && data.status.is_activity !== true) { // no acitivy notices in preview
|
||||
var $noticeHtmlObj = $('<div/>').append(buildQueetHtml(data.status));
|
||||
$noticeHtmlObj.find('.queet-thumbs').remove();
|
||||
var noticeHtml = $noticeHtmlObj.outerHTML();
|
||||
}
|
||||
}
|
||||
|
||||
popUpAction('popup-external-profile', data.screenNameWithServer,data.profileCard + noticeHtml,'<a class="go-to-external-profile" href="' + data.statusnet_profile_url + '">' + window.sL.goToExternalProfile + '</a>');
|
||||
}
|
||||
|
||||
|
||||
/* ·
|
||||
·
|
||||
· Open local profile card in popup
|
||||
·
|
||||
· @param data: an object with a user array
|
||||
·
|
||||
· · · · · · · · · */
|
||||
|
||||
function openLocalProfileInPopup(data) {
|
||||
|
||||
var data = buildProfileCard(data);
|
||||
|
||||
// preview latest notice
|
||||
var noticeHtml = '';
|
||||
if(typeof data.status != 'undefined') {
|
||||
data.status.user = data;
|
||||
if(data.status.source != 'activity' && data.status.is_activity !== true) { // no acitivy notices in preview
|
||||
var $noticeHtmlObj = $('<div/>').append(buildQueetHtml(data.status));
|
||||
$noticeHtmlObj.find('.queet-thumbs').remove();
|
||||
var noticeHtml = $noticeHtmlObj.outerHTML();
|
||||
}
|
||||
}
|
||||
|
||||
popUpAction('popup-local-profile', '@' + data.screen_name, data.profileCardHtml + '<div class="clearfix"></div>' + noticeHtml,'<a class="go-to-local-profile" href="' + data.statusnet_profile_url + '">' + window.sL.goToExternalProfile + '</a>');
|
||||
}
|
||||
|
||||
|
||||
/* ·
|
||||
·
|
||||
· Adds a profile card before feed element, with data from the first object in the included object
|
||||
|
|
|
@ -260,6 +260,7 @@ function cacheSyntaxHighlightingGroups() {
|
|||
· · · · · · · · · */
|
||||
|
||||
window.userArrayCache = new Object();
|
||||
window.convertUriToUserArrayCacheKey = new Object();
|
||||
|
||||
function userArrayCacheStore(data) {
|
||||
|
||||
|
@ -278,8 +279,8 @@ function userArrayCacheStore(data) {
|
|||
}
|
||||
// we can also get either local...
|
||||
else if(typeof data.local != 'undefined' && typeof data.local.statusnet_profile_url != 'undefined' ) {
|
||||
var instanceUrlWithoutProtocol = guessInstanceUrlWithoutProtocolFromProfileUrlAndNickname(data.local.statusnet_profile_url, data.external.screen_name);
|
||||
var key = instanceUrlWithoutProtocol + '/' + data.external.screen_name;
|
||||
var instanceUrlWithoutProtocol = guessInstanceUrlWithoutProtocolFromProfileUrlAndNickname(data.local.statusnet_profile_url, data.local.screen_name);
|
||||
var key = instanceUrlWithoutProtocol + '/' + data.local.screen_name;
|
||||
data.external = false;
|
||||
var dataToStore = data;
|
||||
}
|
||||
|
@ -324,9 +325,15 @@ function userArrayCacheStore(data) {
|
|||
}
|
||||
|
||||
window.userArrayCache[key].local = dataToStore.local;
|
||||
|
||||
// easy conversion between URI and the key we're using in window.userArrayCache
|
||||
window.convertUriToUserArrayCacheKey[dataToStore.local.ostatus_uri] = key;
|
||||
}
|
||||
if(dataToStore.external) {
|
||||
window.userArrayCache[key].external = dataToStore.external;
|
||||
|
||||
// easy conversion between URI and the key we're using in window.userArrayCache
|
||||
window.convertUriToUserArrayCacheKey[dataToStore.external.ostatus_uri] = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
156
js/qvitter.js
156
js/qvitter.js
|
@ -176,6 +176,11 @@ $('body').on({
|
|||
}
|
||||
});
|
||||
|
||||
// tooltips should be removed very easily, e.g. when any of these events happen
|
||||
$('body').on("touchstart scroll click dblclick mousedown mouseup submit keydown keypress keyup", function(e){
|
||||
removeAllTooltips();
|
||||
});
|
||||
|
||||
// removes all tooltips
|
||||
function removeAllTooltips() {
|
||||
$('.tooltip,.tooltip-caret').remove();
|
||||
|
@ -1112,11 +1117,6 @@ $('body').on('click','a', function(e) {
|
|||
return;
|
||||
}
|
||||
|
||||
// don't hijack if this is an external link that has been clicked but failed that time
|
||||
if($(this).hasClass('external-profile-clicked')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// don't hijack if this is an anchor link in the faq
|
||||
if($(this).closest('.modal-container').attr('id') == 'popup-faq' && $(this).attr('href').indexOf('#') > -1) {
|
||||
return;
|
||||
|
@ -1133,11 +1133,6 @@ $('body').on('click','a', function(e) {
|
|||
return;
|
||||
}
|
||||
|
||||
// if we're clicking something in a profile card popup, close it!
|
||||
if($(this).closest('#popup-local-profile, #popup-external-profile').length>0) {
|
||||
$('.modal-container').remove();
|
||||
}
|
||||
|
||||
// all links opens in new tab
|
||||
$(this).attr('target','_blank');
|
||||
|
||||
|
@ -1196,43 +1191,7 @@ $('body').on('click','a', function(e) {
|
|||
|
||||
e.preventDefault();
|
||||
|
||||
// logged in user
|
||||
if($(this).parent().attr('id') == 'user-profile-link'
|
||||
|| linkNickname == window.loggedIn.screen_name) {
|
||||
setNewCurrentStream('statuses/user_timeline.json?screen_name=' + window.loggedIn.screen_name,function(){},true);
|
||||
}
|
||||
// when in local profile popups
|
||||
else if($(this).closest('#popup-local-profile').length>0) {
|
||||
setNewCurrentStream('statuses/user_timeline.json?screen_name=' + linkNickname,function(){},true);
|
||||
}
|
||||
// any local user, not in popups –> open popup
|
||||
else {
|
||||
|
||||
$(this).addClass('local-profile-clicked');
|
||||
|
||||
popUpAction('popup-local-profile', '','<div id="popup-local-profile-spinner" style="height:300px;"></div>',false);
|
||||
display_spinner('#popup-local-profile-spinner');
|
||||
|
||||
var cachedUserArray = userArrayCacheGetByProfileUrlAndNickname($(this).attr('href'), linkNickname);
|
||||
|
||||
if(cachedUserArray && cachedUserArray.local) {
|
||||
openLocalProfileInPopup(cachedUserArray.local);
|
||||
remove_spinner();
|
||||
$('.local-profile-clicked').removeClass('local-profile-clicked');
|
||||
}
|
||||
|
||||
// but always query the server also
|
||||
getFromAPI('users/show.json?id=' + linkNickname,function(data){
|
||||
if(data) {
|
||||
// update the popup if it's still open
|
||||
if($('#popup-local-profile').length>0) {
|
||||
openLocalProfileInPopup(data);
|
||||
remove_spinner();
|
||||
$('.local-profile-clicked').removeClass('local-profile-clicked');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
setNewCurrentStream('statuses/user_timeline.json?screen_name=' + linkNickname,function(){},true);
|
||||
}
|
||||
// tags
|
||||
else if ($(this).attr('href').indexOf(window.siteRootDomain + '/tag/')>-1) {
|
||||
|
@ -1276,109 +1235,6 @@ $('body').on('click','a', function(e) {
|
|||
popUpAction('popup-profile-picture', $('.profile-card-inner .screen-name').html(),'<img style="width:100%;display:block;" src="' + $(this).attr('href') + '" />',false);
|
||||
}
|
||||
}
|
||||
|
||||
// external profiles
|
||||
else if (($(this).children('span.mention').length>0 // if it's a mention
|
||||
|| $(this).hasClass('h-card mention') // if it's a newer gnusocial group mention
|
||||
|| ($(this).hasClass('account-group') && $(this).attr('href').indexOf('/group/')==-1) // or if this is queet stream item header but not a group
|
||||
|| ($(this).closest('.stream-item').hasClass('activity') && $(this).attr('href').indexOf('/group/')==-1)) // or if it's a activity notice but not a group link
|
||||
&& typeof window.loggedIn.screen_name != 'undefined') { // if logged in
|
||||
e.preventDefault();
|
||||
$(this).addClass('external-profile-clicked');
|
||||
|
||||
popUpAction('popup-external-profile', '','<div id="popup-external-profile-spinner" style="height:300px;"></div>',false);
|
||||
display_spinner('#popup-external-profile-spinner');
|
||||
|
||||
// try getting from cache, to display immediately
|
||||
if($(this).hasClass('account-group')) {
|
||||
var externalNickname = $(this).children('.screen-name').text();
|
||||
}
|
||||
else {
|
||||
var externalNickname = $(this).text();
|
||||
}
|
||||
if(externalNickname.substring(0,1) == '@') {
|
||||
externalNickname = externalNickname.substring(1);
|
||||
}
|
||||
var cachedUserArray = userArrayCacheGetByProfileUrlAndNickname($(this).attr('href'), externalNickname);
|
||||
|
||||
if(cachedUserArray && cachedUserArray.external) {
|
||||
openExternalProfileInPopup(cachedUserArray);
|
||||
remove_spinner();
|
||||
$('.external-profile-clicked').removeClass('external-profile-clicked');
|
||||
}
|
||||
|
||||
// but always query the server also
|
||||
getFromAPI('qvitter/external_user_show.json?profileurl=' + encodeURIComponent($(this).attr('href')),function(data){
|
||||
|
||||
if(data && data.external !== null) {
|
||||
|
||||
// update the popup if it's still open
|
||||
if($('#popup-external-profile').length>0) {
|
||||
openExternalProfileInPopup(data);
|
||||
remove_spinner();
|
||||
}
|
||||
|
||||
$('.external-profile-clicked').removeClass('external-profile-clicked');
|
||||
}
|
||||
// if external lookup failed, and we don't have a cached profile card, trigger click again.
|
||||
// it will not be hijacked since we don't remove the external-profile-clicked class here
|
||||
else if($('#popup-external-profile-spinner').length > 0){
|
||||
$('.modal-container').remove();
|
||||
$('.external-profile-clicked')[0].click();
|
||||
$('.external-profile-clicked').removeClass('external-profile-clicked');
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// external groups
|
||||
else if (($(this).children('span.group').length>0 // if it's a group mention
|
||||
|| $(this).hasClass('h-card group') // if it's a newer gnusocial group mention
|
||||
|| ($(this).hasClass('account-group') && $(this).attr('href').indexOf('/group/')>-1) // or if this is group stream item header
|
||||
|| ($(this).closest('.stream-item').hasClass('activity') && $(this).attr('href').indexOf('/group/')>-1)) // or if it's a activity notice
|
||||
&& typeof window.loggedIn.screen_name != 'undefined') { // if logged in
|
||||
e.preventDefault();
|
||||
display_spinner();
|
||||
getFromAPI('statusnet/groups/show.json?id=foo&uri=' + encodeURIComponent($(this).attr('href')), function(data){ if(data){
|
||||
|
||||
data.nickname = data.nickname || '';
|
||||
data.fullname = data.fullname || '';
|
||||
data.stream_logo = data.stream_logo || window.defaultAvatarStreamSize;
|
||||
data.homepage_logo = data.homepage_logo || window.defaultAvatarProfileSize;
|
||||
data.original_logo = data.original_logo || window.defaultAvatarProfileSize;
|
||||
data.description = data.description || '';
|
||||
data.homepage = data.homepage || '';
|
||||
data.url = data.url || '';
|
||||
data.member_count = data.member_count || 0;
|
||||
data.admin_count = data.admin_count || 0;
|
||||
|
||||
// show user actions if logged in
|
||||
var memberClass = '';
|
||||
if(data.member) {
|
||||
memberClass = 'member';
|
||||
}
|
||||
|
||||
var groupRoot = data.url.substring(0,data.url.indexOf('/group/'));
|
||||
var groupServer = groupRoot.replace('http://','').replace('https://','');
|
||||
|
||||
var memberButton = '<div class="user-actions"><button data-group-id="' + data.id + '" type="button" class="member-button ' + memberClass + '"><span class="button-text join-text"><i class="join"></i>' + window.sL.joinGroup + '</span><span class="button-text ismember-text">' + window.sL.isMemberOfGroup + '</span><span class="button-text leave-text">' + window.sL.leaveGroup + '</span></button></div>';
|
||||
|
||||
// get local member avatars
|
||||
getFromAPI('statusnet/groups/membership.json?id=' + data.id, function(user_data){ if(user_data){
|
||||
var avatars = '';
|
||||
var i=0;
|
||||
$.each(user_data,function(k,v){
|
||||
if(i<7) {
|
||||
avatars = avatars + '<img class="avatar size30" src="' + v.profile_image_url + '" />';
|
||||
}
|
||||
i++;
|
||||
});
|
||||
var profileCard = '<div class="profile-card"><div class="profile-header-inner" style="background-image:url(' + data.original_logo + ')"><div class="profile-header-inner-overlay"></div><a class="profile-picture"><img src="' + data.homepage_logo + '" /></a><div class="profile-card-inner"><h1 class="fullname">' + data.fullname + '<span></span></h1><h2 class="username"><span class="screen-name"><a target="_blank" href="' + groupRoot + '/group/' + data.nickname + '">!' + data.nickname + '@' + groupServer + '</a></span></span></h2><div class="bio-container"><p>' + data.description + '</p></div><p class="location-and-url"></span><span class="url"><a href="' + data.homepage + '">' + data.homepage.replace('http://','').replace('https://','') + '</a></span></p></div></div><div class="profile-banner-footer"><ul class="stats"><li><a target="_blank" href="' + groupRoot + '/group/' + data.nickname + '/members" class="member-stats">' + avatars + '</a></li></ul>' + memberButton + '<div class="clearfix"></div></div></div>';
|
||||
popUpAction('popup-external-group-profile', '!' + data.nickname + '@' + groupServer,profileCard,false);
|
||||
remove_spinner();
|
||||
}});
|
||||
}});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user