user cog menu in user lists too

This commit is contained in:
Hannes Mannerheim 2016-03-01 01:58:12 +01:00
parent c3aed808ba
commit 049049d8bf
5 changed files with 49 additions and 57 deletions

View File

@ -1685,7 +1685,7 @@ body.rtl #history-container.menu-container a .chev-right {
position: absolute; position: absolute;
text-shadow: none; text-shadow: none;
} }
.profile-card:not(.logged-in) .user-menu-cog { .user-menu-cog:not(.logged-in) {
display:none !important; display:none !important;
} }
#stream-menu-cog::before, #stream-menu-cog::before,
@ -2042,8 +2042,8 @@ body.has-right-to-sandbox .profile-card .profile-header-inner.sandboxed span.san
body.rtl .queet.rtl .expanded-content { body.rtl .queet.rtl .expanded-content {
direction:rtl; direction:rtl;
} }
.stream-item.expanded > div:first-child, .stream-item.expanded > div.first-visible,
.stream-item.expanded > div:first-child > .queet { .stream-item.expanded > div.first-visible > .queet {
border-top-left-radius:6px; border-top-left-radius:6px;
border-top-right-radius:6px; border-top-right-radius:6px;
} }
@ -2118,16 +2118,9 @@ body.rtl .queet.rtl .expanded-content {
box-sizing: border-box; box-sizing: border-box;
} }
/* only show activity notices if they are conversation starters
we never need to see these, but sometimes someone replies to
an activity notice, and then it can be good to know what the
user is replying to... */
#feed-body > .stream-item.activity { #feed-body > .stream-item.activity {
display:none; display:none;
} }
.stream-item > .stream-item.activity:first-child {
display:block;
}
.quoted-notices, .quoted-notices,
.oembed-data { .oembed-data {

View File

@ -523,6 +523,7 @@ function APISandboxCreateOrDestroy(createOrDestroy,userId,actionOnSuccess) {
data = iterateRecursiveReplaceHtmlSpecialChars(data); data = iterateRecursiveReplaceHtmlSpecialChars(data);
searchForUserDataToCache(data); searchForUserDataToCache(data);
updateUserDataInStream(); updateUserDataInStream();
rememberStreamStateInLocalStorage();
actionOnSuccess(data); actionOnSuccess(data);
} }
}); });
@ -552,6 +553,7 @@ function APISilenceCreateOrDestroy(createOrDestroy,userId,actionOnSuccess) {
data = iterateRecursiveReplaceHtmlSpecialChars(data); data = iterateRecursiveReplaceHtmlSpecialChars(data);
searchForUserDataToCache(data); searchForUserDataToCache(data);
updateUserDataInStream(); updateUserDataInStream();
rememberStreamStateInLocalStorage();
actionOnSuccess(data); actionOnSuccess(data);
} }
}); });

View File

@ -438,7 +438,7 @@ function buildProfileCard(data) {
<li class="groups-num"><a href="' + data.statusnet_profile_url + '/groups" class="groups-stats">' + window.sL.groups + '<strong>' + data.groups_count + '</strong></a></li>\ <li class="groups-num"><a href="' + data.statusnet_profile_url + '/groups" class="groups-stats">' + window.sL.groups + '<strong>' + data.groups_count + '</strong></a></li>\
</ul>\ </ul>\
' + followButton + '\ ' + followButton + '\
<div class="user-menu-cog" data-tooltip="' + window.sL.userOptions + '"></div>\ <div class="user-menu-cog' + is_silenced + is_sandboxed + logged_in + '" data-tooltip="' + window.sL.userOptions + '" data-user-id="' + data.id + '" data-screen-name="' + data.screen_name + '"></div>\
<div class="clearfix"></div>\ <div class="clearfix"></div>\
</div>\ </div>\
</div>\ </div>\
@ -471,6 +471,18 @@ function buildExternalProfileCard(data) {
var followButton = buildFollowBlockbutton(data.local); var followButton = buildFollowBlockbutton(data.local);
} }
// me?
var is_me = '';
if(window.loggedIn !== false && window.loggedIn.id == data.local.id) {
var is_me = ' is-me';
}
// logged in?
var logged_in = '';
if(window.loggedIn !== false) {
var logged_in = ' logged-in';
}
// silenced? // silenced?
var is_silenced = ''; var is_silenced = '';
if(data.local.is_silenced === true) { if(data.local.is_silenced === true) {
@ -483,8 +495,9 @@ function buildExternalProfileCard(data) {
is_sandboxed = ' sandboxed'; is_sandboxed = ' sandboxed';
} }
// local id // local id/screen_name
var localUserId = data.local.id; var localUserId = data.local.id;
var localUserScreenName = data.local.screen_name;
// empty strings and zeros instead of null // empty strings and zeros instead of null
data = cleanUpUserObject(data.external); data = cleanUpUserObject(data.external);
@ -519,8 +532,8 @@ function buildExternalProfileCard(data) {
data.screenNameWithServer = '@' + data.screen_name + '@' + serverUrl; data.screenNameWithServer = '@' + data.screen_name + '@' + serverUrl;
data.profileCardHtml = '\ data.profileCardHtml = '\
<div class="profile-card">\ <div class="profile-card' + is_me + logged_in + '">\
<div class="profile-header-inner' + is_silenced + is_sandboxed + '" style="background-image:url(\'' + cover_photo + '\')" data-user-id="' + localUserId + '">\ <div class="profile-header-inner' + is_silenced + is_sandboxed + '" style="background-image:url(\'' + cover_photo + '\')" data-user-id="' + localUserId + '" data-screen-name="' + localUserScreenName + '">\
<div class="profile-header-inner-overlay"></div>\ <div class="profile-header-inner-overlay"></div>\
<a class="profile-picture"><img src="' + data.profile_image_url_profile_size + '" /></a>\ <a class="profile-picture"><img src="' + data.profile_image_url_profile_size + '" /></a>\
<div class="profile-card-inner">\ <div class="profile-card-inner">\
@ -551,7 +564,7 @@ function buildExternalProfileCard(data) {
<li class="follower-num"><a class="follower-stats" target="_blank" href="' + data.statusnet_profile_url + '/subscribers">' + window.sL.followers + '<strong>' + data.followers_count + '</strong></a></li>\ <li class="follower-num"><a class="follower-stats" target="_blank" href="' + data.statusnet_profile_url + '/subscribers">' + window.sL.followers + '<strong>' + data.followers_count + '</strong></a></li>\
</ul>\ </ul>\
' + followButton + '\ ' + followButton + '\
<div class="user-menu-cog" data-tooltip="' + window.sL.userOptions + '"></div>\ <div class="user-menu-cog' + is_silenced + is_sandboxed + logged_in + '" data-tooltip="' + window.sL.userOptions + '" data-user-id="' + localUserId + '" data-screen-name="' + localUserScreenName + '"></div>\
<div class="clearfix"></div>\ <div class="clearfix"></div>\
</div>\ </div>\
</div>\ </div>\
@ -1599,7 +1612,7 @@ function showConversation(q, qid, data, offsetScroll) {
/* · /* ·
· ·
· Add last visible class, since that's not possible to select in pure css · Add last&first visible class, since that's not possible to select in pure css
· ·
· · · · · · · · · · · · · */ · · · · · · · · · · · · · */
function findAndMarkLastVisibleInConversation(streamItem) { function findAndMarkLastVisibleInConversation(streamItem) {
@ -1607,6 +1620,8 @@ function findAndMarkLastVisibleInConversation(streamItem) {
streamItem.children().removeClass('first-visible-after-parent'); streamItem.children().removeClass('first-visible-after-parent');
streamItem.children().not('.hidden-conversation').not('.always-hidden').last().addClass('last-visible'); streamItem.children().not('.hidden-conversation').not('.always-hidden').last().addClass('last-visible');
streamItem.children('.queet').nextAll().not('.hidden-conversation').not('.always-hidden').first().addClass('first-visible-after-parent'); streamItem.children('.queet').nextAll().not('.hidden-conversation').not('.always-hidden').first().addClass('first-visible-after-parent');
streamItem.children().removeClass('first-visible');
streamItem.children().not('.hidden-conversation').not('.always-hidden').first().addClass('first-visible');
} }
@ -1995,6 +2010,11 @@ function buildUserStreamItemHtml(obj) {
if(obj.is_sandboxed === true) { if(obj.is_sandboxed === true) {
sandboxedClass = ' sandboxed'; sandboxedClass = ' sandboxed';
} }
// logged in?
var loggedInClass = '';
if(window.loggedIn !== false) {
loggedInClass = ' logged-in';
}
var followButton = ''; var followButton = '';
if(typeof window.loggedIn.screen_name != 'undefined' // if logged in if(typeof window.loggedIn.screen_name != 'undefined' // if logged in
@ -2007,6 +2027,7 @@ function buildUserStreamItemHtml(obj) {
return '<div id="stream-item-' + obj.id + '" class="stream-item user' + silencedClass + sandboxedClass + '" data-user-id="' + obj.id + '">\ return '<div id="stream-item-' + obj.id + '" class="stream-item user' + silencedClass + sandboxedClass + '" data-user-id="' + obj.id + '">\
<div class="queet ' + rtlOrNot + '">\ <div class="queet ' + rtlOrNot + '">\
' + followButton + '\ ' + followButton + '\
<div class="user-menu-cog' + silencedClass + sandboxedClass + loggedInClass + '" data-tooltip="' + window.sL.userOptions + '" data-user-id="' + obj.id + '" data-screen-name="' + obj.screen_name + '"></div>\
<div class="queet-content">\ <div class="queet-content">\
<div class="stream-item-header">\ <div class="stream-item-header">\
<a class="account-group" href="' + obj.statusnet_profile_url + '" data-user-id="' + obj.id + '">\ <a class="account-group" href="' + obj.statusnet_profile_url + '" data-user-id="' + obj.id + '">\

View File

@ -404,9 +404,11 @@ function markUserAsUnblockedInDOM(userId, following) {
} }
// hide the user from lists of blocked users // hide the user from lists of blocked users
if(window.currentStreamObject.name == 'user blocks' && window.currentStreamObject.nickname == window.loggedIn.screen_name) {
$.each($('.stream-item.user[data-user-id="' + userId + '"]'),function(){ $.each($('.stream-item.user[data-user-id="' + userId + '"]'),function(){
slideUpAndRemoveStreamItem($(this)); slideUpAndRemoveStreamItem($(this));
}); });
}
// unhide notices from the blocked user // unhide notices from the blocked user
$.each($('.stream-item[data-quitter-id-in-stream][data-user-id="' + userId + '"]'),function(){ $.each($('.stream-item[data-quitter-id-in-stream][data-user-id="' + userId + '"]'),function(){
@ -461,25 +463,11 @@ function markAllNoticesFromBlockedUsersAsBlockedInJQueryObject(obj) {
function sandboxCreateOrDestroy(arg, callback) { function sandboxCreateOrDestroy(arg, callback) {
$('body').click(); // a click somewhere hides any open menus $('body').click(); // a click somewhere hides any open menus
var userId = arg.userId;
var createOrDestroy = arg.createOrDestroy;
display_spinner(); display_spinner();
APISandboxCreateOrDestroy(createOrDestroy, userId, function(data) { APISandboxCreateOrDestroy(arg.createOrDestroy, arg.userId, function(data) {
remove_spinner(); remove_spinner();
if(data) { if(!data) {
// success, mark the user's notices and profile cards as sandboxed or unsandboxed
if(data.is_sandboxed === true) {
$('.stream-item[data-user-id="' + userId + '"]').addClass('sandboxed');
$('.profile-card .profile-header-inner[data-user-id="' + userId + '"]').addClass('sandboxed');
}
else {
$('.stream-item[data-user-id="' + userId + '"]').removeClass('sandboxed');
$('.profile-card .profile-header-inner[data-user-id="' + userId + '"]').removeClass('sandboxed');
}
rememberStreamStateInLocalStorage();
}
else {
// failed! // failed!
showErrorMessage(window.sL.ERRORfailedSandboxingUser); showErrorMessage(window.sL.ERRORfailedSandboxingUser);
} }
@ -495,25 +483,11 @@ function sandboxCreateOrDestroy(arg, callback) {
function silenceCreateOrDestroy(arg, callback) { function silenceCreateOrDestroy(arg, callback) {
$('body').click(); // a click somewhere hides any open menus $('body').click(); // a click somewhere hides any open menus
var userId = arg.userId;
var createOrDestroy = arg.createOrDestroy;
display_spinner(); display_spinner();
APISilenceCreateOrDestroy(createOrDestroy, userId, function(data) { APISilenceCreateOrDestroy(arg.createOrDestroy, arg.userId, function(data) {
remove_spinner(); remove_spinner();
if(data) { if(!data) {
// success, mark the user's notices and profile cards as silenced or unsilenced
if(data.is_silenced === true) {
$('.stream-item[data-user-id="' + userId + '"]').addClass('silenced');
$('.profile-card .profile-header-inner[data-user-id="' + userId + '"]').addClass('silenced');
}
else {
$('.stream-item[data-user-id="' + userId + '"]').removeClass('silenced');
$('.profile-card .profile-header-inner[data-user-id="' + userId + '"]').removeClass('silenced');
}
rememberStreamStateInLocalStorage();
}
else {
// failed! // failed!
showErrorMessage(window.sL.ERRORfailedSilencingUser); showErrorMessage(window.sL.ERRORfailedSilencingUser);
} }
@ -1065,10 +1039,12 @@ function updateUserDataInStream() {
if(userArray.local.is_silenced === true) { if(userArray.local.is_silenced === true) {
$('.stream-item[data-user-id=' + userArray.local.id + ']').addClass('silenced'); $('.stream-item[data-user-id=' + userArray.local.id + ']').addClass('silenced');
$('.profile-card .profile-header-inner[data-user-id=' + userArray.local.id + ']').addClass('silenced'); $('.profile-card .profile-header-inner[data-user-id=' + userArray.local.id + ']').addClass('silenced');
$('.user-menu-cog[data-user-id=' + userArray.local.id + ']').addClass('silenced');
} }
else { else {
$('.stream-item[data-user-id=' + userArray.local.id + ']').removeClass('silenced') $('.stream-item[data-user-id=' + userArray.local.id + ']').removeClass('silenced')
$('.profile-card .profile-header-inner[data-user-id=' + userArray.local.id + ']').removeClass('silenced'); $('.profile-card .profile-header-inner[data-user-id=' + userArray.local.id + ']').removeClass('silenced');
$('.user-menu-cog[data-user-id=' + userArray.local.id + ']').removeClass('silenced');
} }
@ -1076,10 +1052,12 @@ function updateUserDataInStream() {
if(userArray.local.is_sandboxed === true) { if(userArray.local.is_sandboxed === true) {
$('.stream-item[data-user-id=' + userArray.local.id + ']').addClass('sandboxed'); $('.stream-item[data-user-id=' + userArray.local.id + ']').addClass('sandboxed');
$('.profile-card .profile-header-inner[data-user-id=' + userArray.local.id + ']').addClass('sandboxed'); $('.profile-card .profile-header-inner[data-user-id=' + userArray.local.id + ']').addClass('sandboxed');
$('.user-menu-cog[data-user-id=' + userArray.local.id + ']').addClass('sandboxed');
} }
else { else {
$('.stream-item[data-user-id=' + userArray.local.id + ']').removeClass('sandboxed') $('.stream-item[data-user-id=' + userArray.local.id + ']').removeClass('sandboxed')
$('.profile-card .profile-header-inner[data-user-id=' + userArray.local.id + ']').removeClass('sandboxed'); $('.profile-card .profile-header-inner[data-user-id=' + userArray.local.id + ']').removeClass('sandboxed');
$('.user-menu-cog[data-user-id=' + userArray.local.id + ']').removeClass('sandboxed');
} }
// profile size avatars (notices, users) // profile size avatars (notices, users)

View File

@ -1197,12 +1197,10 @@ $('body').on('click','.user-menu-cog',function(e){
$(this).addClass('dropped'); $(this).addClass('dropped');
var profileCard = $(this).closest('.profile-card'); var userID = $(this).attr('data-user-id');
var profileHeaderInner = profileCard.children('.profile-header-inner'); var userScreenName = $(this).attr('data-screen-name');
var userID = profileHeaderInner.attr('data-user-id'); var silenced = $(this).hasClass('silenced');
var userScreenName = profileHeaderInner.attr('data-screen-name'); var sandboxed = $(this).hasClass('sandboxed');
var silenced = profileHeaderInner.hasClass('silenced');
var sandboxed = profileHeaderInner.hasClass('sandboxed');
// menu // menu
var menuArray = []; var menuArray = [];