VRFS-2701 refactor / added action links to each section
This commit is contained in:
parent
4d133e0043
commit
fa7ec522c5
|
|
@ -96,6 +96,9 @@
|
|||
var $btnAddFriend = $screen.find('#btn-add-friend');
|
||||
var $btnFollowUser = $screen.find('#btn-follow-user');
|
||||
var $btnMessageUser = $screen.find('#btn-message-user');
|
||||
var $btnAddRecordings = $screen.find('.add-recordings');
|
||||
var $btnAddSites = $screen.find('.add-sites');
|
||||
var $btnAddInterests = $screen.find('.add-interests');
|
||||
|
||||
// social
|
||||
var $socialLeft = $screen.find('.profile-social-left');
|
||||
|
|
@ -426,15 +429,121 @@
|
|||
|
||||
function bindAbout() {
|
||||
|
||||
$instruments.empty();
|
||||
if (!isCurrentUser()) {
|
||||
$btnAddRecordings.hide();
|
||||
$btnAddSites.hide();
|
||||
$btnAddInterests.hide();
|
||||
}
|
||||
|
||||
renderNameLocationStats();
|
||||
renderBio();
|
||||
renderMusicalExperience();
|
||||
renderPerformanceSamples();
|
||||
renderOnlinePresence();
|
||||
renderInterests();
|
||||
}
|
||||
|
||||
function renderNameLocationStats() {
|
||||
// name
|
||||
$userName.html(user.name);
|
||||
|
||||
// avatar
|
||||
$avatar.attr('src', context.JK.resolveAvatarUrl(user.photo_url));
|
||||
|
||||
// instruments
|
||||
// location
|
||||
$location.html(user.location);
|
||||
|
||||
$age.html(user.age ? user.age + " years old" : "");
|
||||
|
||||
// stats
|
||||
var text = user.friend_count > 1 || user.friend_count === 0 ? " Friends" : " Friend";
|
||||
$friendStats.html('<span class="friend-count">' + user.friend_count + '</span>' + text);
|
||||
|
||||
text = user.follower_count > 1 || user.follower_count === 0 ? " Followers" : " Follower";
|
||||
$followerStats.html('<span class="follower-count">' + user.follower_count + '</span>' + text);
|
||||
|
||||
if (isMusician()) {
|
||||
text = user.session_count > 1 || user.session_count === 0 ? " Sessions" : " Session";
|
||||
$sessionStats.html(user.session_count + text);
|
||||
|
||||
text = user.recording_count > 1 || user.recording_count === 0 ? " Recordings" : " Recording";
|
||||
$recordingStats.html(user.recording_count + text);
|
||||
}
|
||||
else {
|
||||
text = " Following";
|
||||
$followingStats.html(user.following_count + text);
|
||||
text = user.favorite_count > 1 || user.favorite_count === 0 ? " Favorites" : " Favorite";
|
||||
$favoriteStats.html(user.favorite_count + text);
|
||||
}
|
||||
}
|
||||
|
||||
function renderBio() {
|
||||
|
||||
function initializeBioVisibility() {
|
||||
|
||||
$showBio.hide();
|
||||
$noBio.hide();
|
||||
$biographyEditor.hide();
|
||||
|
||||
$bioTextArea.val(user.biography);
|
||||
|
||||
if(user.biography) {
|
||||
|
||||
$showBio.show();
|
||||
$biographyText.text(user.biography).show();
|
||||
}
|
||||
else {
|
||||
if(isCurrentUser()) {
|
||||
$noBio.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initializeBioVisibility();
|
||||
|
||||
// $addBiographyButton.unbind('click').click(function() {
|
||||
// $biographyEditor.val(user.biography).show();
|
||||
// return false;
|
||||
// });
|
||||
|
||||
$submitBiographyButton.unbind('click').click(function() {
|
||||
var bio = $bioTextArea.val();
|
||||
$bioTextArea.closest('div.field').removeClass('error');
|
||||
$('.error-text', $bioTextArea.closest('div.field')).remove();
|
||||
userDefer = rest.updateUser({
|
||||
biography: bio
|
||||
})
|
||||
.done(function(response) {
|
||||
user = response;
|
||||
initializeBioVisibility();
|
||||
})
|
||||
.fail(function(jqXHR) {
|
||||
if(jqXHR.status == 422) {
|
||||
var errors = JSON.parse(jqXHR.responseText)
|
||||
var biography = context.JK.format_errors("biography", errors);
|
||||
if(biography != null) {
|
||||
$bioTextArea.closest('div.field').addClass('error').end().after(biography);
|
||||
}
|
||||
else {
|
||||
app.notifyServerError(jqXHR, "Unable to update biography")
|
||||
}
|
||||
}
|
||||
else {
|
||||
app.notifyServerError(jqXHR, "Unable to update biography")
|
||||
}
|
||||
})
|
||||
return false;
|
||||
})
|
||||
|
||||
$cancelBiographyButton.unbind('click').click(function() {
|
||||
initializeBioVisibility();
|
||||
return false;
|
||||
})
|
||||
}
|
||||
|
||||
function renderMusicalExperience() {
|
||||
$instruments.empty();
|
||||
|
||||
if (user.instruments) {
|
||||
for (var i = 0; i < user.instruments.length; i++) {
|
||||
var instrument = user.instruments[i];
|
||||
|
|
@ -471,28 +580,20 @@
|
|||
// studio gigs
|
||||
var studioGigCount = user.studio_session_count;
|
||||
$studioCount.html(studioGigCount > 0 ? 'Has played ' + profileUtils.gigMap[studioGigCount] + ' studio session gigs' : NOT_SPECIFIED_TEXT);
|
||||
}
|
||||
|
||||
// location
|
||||
$location.html(user.location);
|
||||
|
||||
$age.html(user.age ? user.age + " years old" : "");
|
||||
|
||||
// stats
|
||||
var text = user.friend_count > 1 || user.friend_count === 0 ? " Friends" : " Friend";
|
||||
$friendStats.html('<span class="friend-count">' + user.friend_count + '</span>' + text);
|
||||
|
||||
text = user.follower_count > 1 || user.follower_count === 0 ? " Followers" : " Follower";
|
||||
$followerStats.html('<span class="follower-count">' + user.follower_count + '</span>' + text);
|
||||
|
||||
// text = user.following_count > 1 || user.following_count === 0 ? " Followings" : " Following";
|
||||
// $('#profile-following-stats').html('<span class="following-count">' + user.following_count + '</span>' + text);
|
||||
|
||||
function renderPerformanceSamples() {
|
||||
// performance samples
|
||||
var performanceSamples = user.performance_samples;
|
||||
if (!performanceSamples || performanceSamples.length === 0) {
|
||||
$noSamples.show();
|
||||
|
||||
if (isCurrentUser()) {
|
||||
$btnAddRecordings.show();
|
||||
}
|
||||
}
|
||||
else {
|
||||
$btnAddRecordings.hide();
|
||||
$noSamples.hide();
|
||||
|
||||
// show samples section
|
||||
|
|
@ -512,13 +613,23 @@
|
|||
$youTubeSamples.append("<a href=''>" + sample.service_id + "</a>");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function renderOnlinePresence() {
|
||||
// online presences
|
||||
var onlinePresences = user.online_presences;
|
||||
if ((!onlinePresences || onlinePresences.length === 0) && !user.website) {
|
||||
$noOnlinePresence.show();
|
||||
|
||||
if (isCurrentUser()) {
|
||||
$btnAddSites.show();
|
||||
}
|
||||
else {
|
||||
$btnAddSites.hide();
|
||||
}
|
||||
}
|
||||
else {
|
||||
$btnAddSites.hide();
|
||||
$noOnlinePresence.hide();
|
||||
|
||||
if (user.website) {
|
||||
|
|
@ -581,7 +692,9 @@
|
|||
$twitterPresence.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function renderInterests() {
|
||||
// current interests
|
||||
var noInterests = !user.paid_sessions && !user.free_sessions && !user.cowriting && !user.virtual_band && !user.traditional_band;
|
||||
if (noInterests) {
|
||||
|
|
@ -591,9 +704,16 @@
|
|||
$cowritingSection.hide();
|
||||
$traditionalBandSection.hide();
|
||||
$virtualBandSection.hide();
|
||||
|
||||
if (isCurrentUser()) {
|
||||
$btnAddInterests.show();
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
$btnAddInterests.hide();
|
||||
$noInterests.hide();
|
||||
|
||||
// paid sessions
|
||||
if (user.paid_sessions) {
|
||||
$paidGigSection.show();
|
||||
|
|
@ -662,87 +782,6 @@
|
|||
$virtualBandSection.hide();
|
||||
}
|
||||
}
|
||||
|
||||
if (isMusician()) {
|
||||
text = user.session_count > 1 || user.session_count === 0 ? " Sessions" : " Session";
|
||||
$sessionStats.html(user.session_count + text);
|
||||
|
||||
text = user.recording_count > 1 || user.recording_count === 0 ? " Recordings" : " Recording";
|
||||
$recordingStats.html(user.recording_count + text);
|
||||
} else {
|
||||
text = " Following";
|
||||
$followingStats.html(user.following_count + text);
|
||||
text = user.favorite_count > 1 || user.favorite_count === 0 ? " Favorites" : " Favorite";
|
||||
$favoriteStats.html(user.favorite_count + text);
|
||||
}
|
||||
|
||||
renderBio();
|
||||
}
|
||||
|
||||
/** The biography show/edit functionality */
|
||||
function renderBio() {
|
||||
|
||||
|
||||
function initializeBioVisibility() {
|
||||
|
||||
$showBio.hide();
|
||||
$noBio.hide();
|
||||
$biographyEditor.hide();
|
||||
|
||||
$bioTextArea.val(user.biography);
|
||||
|
||||
if(user.biography) {
|
||||
|
||||
$showBio.show();
|
||||
$biographyText.text(user.biography).show();
|
||||
}
|
||||
else {
|
||||
if(isCurrentUser()) {
|
||||
$noBio.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initializeBioVisibility();
|
||||
|
||||
// $addBiographyButton.unbind('click').click(function() {
|
||||
// $biographyEditor.val(user.biography).show();
|
||||
// return false;
|
||||
// });
|
||||
|
||||
$submitBiographyButton.unbind('click').click(function() {
|
||||
var bio = $bioTextArea.val();
|
||||
$bioTextArea.closest('div.field').removeClass('error');
|
||||
$('.error-text', $bioTextArea.closest('div.field')).remove();
|
||||
userDefer = rest.updateUser({
|
||||
biography: bio
|
||||
})
|
||||
.done(function(response) {
|
||||
user = response;
|
||||
initializeBioVisibility();
|
||||
})
|
||||
.fail(function(jqXHR) {
|
||||
if(jqXHR.status == 422) {
|
||||
var errors = JSON.parse(jqXHR.responseText)
|
||||
var biography = context.JK.format_errors("biography", errors);
|
||||
if(biography != null) {
|
||||
$bioTextArea.closest('div.field').addClass('error').end().after(biography);
|
||||
}
|
||||
else {
|
||||
app.notifyServerError(jqXHR, "Unable to update biography")
|
||||
}
|
||||
}
|
||||
else {
|
||||
app.notifyServerError(jqXHR, "Unable to update biography")
|
||||
}
|
||||
})
|
||||
return false;
|
||||
})
|
||||
|
||||
$cancelBiographyButton.unbind('click').click(function() {
|
||||
initializeBioVisibility();
|
||||
return false;
|
||||
})
|
||||
}
|
||||
|
||||
/****************** SOCIAL TAB *****************/
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@
|
|||
</div>
|
||||
|
||||
<br clear="all" />
|
||||
<div><a href="/client#/account/profile" class="add-recordings">Add Recordings</a></div>
|
||||
<br clear="all" />
|
||||
|
||||
<div class="section-header">Online Presence</div>
|
||||
|
|
@ -170,6 +171,7 @@
|
|||
</div>
|
||||
|
||||
<br clear="all" />
|
||||
<div><a href="/client#/account/profile" class="add-sites">Add Sites</a></div>
|
||||
<br clear="all" />
|
||||
|
||||
<div class="section-header">Current Interests</div>
|
||||
|
|
@ -227,7 +229,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<br clear="all" />
|
||||
<div><a href="/client#/account/profile" class="add-interests">Add Interests</a></div>
|
||||
|
||||
<div id="virtual-band">
|
||||
<div class="left profile-details">I'm interested in forming virtual band(s)</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue