vrfs-916: added fan page branching logic
This commit is contained in:
parent
4e136659e8
commit
f7c08ce472
|
|
@ -6,7 +6,7 @@
|
|||
context.JK.ProfileScreen = function(app) {
|
||||
var logger = context.JK.logger;
|
||||
var userId;
|
||||
var user = {};
|
||||
var user = null;
|
||||
|
||||
var instrument_logo_map = context.JK.getInstrumentIconMap24();
|
||||
|
||||
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
function beforeShow(data) {
|
||||
userId = data.id;
|
||||
user = null;
|
||||
}
|
||||
|
||||
function afterShow(data) {
|
||||
|
|
@ -45,6 +46,69 @@
|
|||
$('.profile-nav a.#profile-about-link').addClass('active');
|
||||
}
|
||||
|
||||
function getUser() {
|
||||
if (user === null) {
|
||||
var url = "/api/users/" + userId;
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: url,
|
||||
async: false,
|
||||
processData:false,
|
||||
success: function(response) {
|
||||
user = response;
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorMessage) {
|
||||
user = null;
|
||||
app.ajaxError(jqXHR, textStatus, errorMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
function isMusician() {
|
||||
if (getUser()) {
|
||||
return user.musician === true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function configUserType() {
|
||||
if (isMusician()) {
|
||||
$('#profile-history-link').show();
|
||||
$('#profile-bands-link').show();
|
||||
$('#profile-instruments').show();
|
||||
$('#profile-session-stats').show();
|
||||
$('#profile-recording-stats').show();
|
||||
|
||||
$('#profile-following-stats').hide();
|
||||
$('#profile-favorites-stats').hide();
|
||||
|
||||
$('#btn-add-friend').show();
|
||||
$('#profile-social-left').show();
|
||||
|
||||
$('#profile-type-label').text('musician');
|
||||
$('#profile-location-label').text('Location');
|
||||
|
||||
} else {
|
||||
$('#profile-history-link').hide();
|
||||
$('#profile-bands-link').hide();
|
||||
$('#profile-instruments').hide();
|
||||
$('#profile-session-stats').hide();
|
||||
$('#profile-recording-stats').hide();
|
||||
|
||||
$('#profile-following-stats').show();
|
||||
$('#profile-favorites-stats').show();
|
||||
|
||||
$('#btn-add-friend').hide();
|
||||
$('#profile-social-left').hide();
|
||||
|
||||
$('#profile-type-label').text('fan');
|
||||
$('#profile-location-label').text('Presence');
|
||||
}
|
||||
}
|
||||
|
||||
/****************** MAIN PORTION OF SCREEN *****************/
|
||||
// events for main screen
|
||||
function events() {
|
||||
|
|
@ -94,27 +158,7 @@
|
|||
}
|
||||
|
||||
function isFriend() {
|
||||
var alreadyFriend = false;
|
||||
|
||||
var url = "/api/users/" + context.JK.currentUserId + "/friends/" + userId;
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: url,
|
||||
async: false,
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
if (response.id !== undefined) {
|
||||
alreadyFriend = true;
|
||||
}
|
||||
else {
|
||||
alreadyFriend = false;
|
||||
}
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
|
||||
return alreadyFriend;
|
||||
return getUser() ? user.is_friend : false;
|
||||
}
|
||||
|
||||
function friendRequestCallback() {
|
||||
|
|
@ -186,27 +230,7 @@
|
|||
}
|
||||
|
||||
function isFollowing() {
|
||||
var alreadyFollowing = false;
|
||||
|
||||
var url = "/api/users/" + context.JK.currentUserId + "/followings/" + userId;
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: url,
|
||||
async: false,
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
if (response.id !== undefined) {
|
||||
alreadyFollowing = true;
|
||||
}
|
||||
else {
|
||||
alreadyFollowing = false;
|
||||
}
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
|
||||
return alreadyFollowing;
|
||||
return getUser() ? user.is_following : false;
|
||||
}
|
||||
|
||||
function configureFollowingButton(following) {
|
||||
|
|
@ -261,21 +285,9 @@
|
|||
|
||||
function bindAbout() {
|
||||
$('#profile-instruments').empty();
|
||||
var url = "/api/users/" + userId;
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: url,
|
||||
async: false,
|
||||
processData:false,
|
||||
success: function(response) {
|
||||
user = response;
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
|
||||
if (user) {
|
||||
|
||||
if (getUser()) {
|
||||
configUserType();
|
||||
// name
|
||||
$('#profile-username').html(user.name);
|
||||
|
||||
|
|
@ -313,11 +325,16 @@
|
|||
text = user.follower_count > 1 || user.follower_count === 0 ? " Followers" : " Follower";
|
||||
$('#profile-follower-stats').html(user.follower_count + text);
|
||||
|
||||
text = user.session_count > 1 || user.session_count === 0 ? " Sessions" : " Session";
|
||||
$('#profile-session-stats').html(user.session_count + text);
|
||||
if (user.musician === true) {
|
||||
text = user.session_count > 1 || user.session_count === 0 ? " Sessions" : " Session";
|
||||
$('#profile-session-stats').html(user.session_count + text);
|
||||
|
||||
text = user.recording_count > 1 || user.recording_count === 0 ? " Recordings" : " Recording";
|
||||
$('#profile-recording-stats').html(user.recording_count + text);
|
||||
text = user.recording_count > 1 || user.recording_count === 0 ? " Recordings" : " Recording";
|
||||
$('#profile-recording-stats').html(user.recording_count + text);
|
||||
} else {
|
||||
text = " Following";
|
||||
$('#profile-following-stats').html(user.following_count + text);
|
||||
}
|
||||
|
||||
$('#profile-biography').html(user.biography);
|
||||
}
|
||||
|
|
@ -345,29 +362,31 @@
|
|||
}
|
||||
|
||||
function bindSocial() {
|
||||
// FRIENDS
|
||||
var url = "/api/users/" + userId + "/friends";
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: url,
|
||||
async: false,
|
||||
processData:false,
|
||||
success: function(response) {
|
||||
$.each(response, function(index, val) {
|
||||
var template = $('#template-profile-social').html();
|
||||
var friendHtml = context.JK.fillTemplate(template, {
|
||||
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
||||
userName: val.name,
|
||||
location: val.location,
|
||||
type: "Friends"
|
||||
});
|
||||
if (isMusician()) {
|
||||
// FRIENDS
|
||||
var url = "/api/users/" + userId + "/friends";
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: url,
|
||||
async: false,
|
||||
processData:false,
|
||||
success: function(response) {
|
||||
$.each(response, function(index, val) {
|
||||
var template = $('#template-profile-social').html();
|
||||
var friendHtml = context.JK.fillTemplate(template, {
|
||||
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
||||
userName: val.name,
|
||||
location: val.location,
|
||||
type: "Friends"
|
||||
});
|
||||
|
||||
$('#profile-social-friends').append(friendHtml);
|
||||
});
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
$('#profile-social-friends').append(friendHtml);
|
||||
});
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
}
|
||||
|
||||
// FOLLOWINGS (USERS)
|
||||
url = "/api/users/" + userId + "/followings";
|
||||
|
|
|
|||
|
|
@ -1,11 +1,23 @@
|
|||
object @user
|
||||
|
||||
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :location, :online, :photo_url, :musician, :gender, :birth_date, :internet_service_provider, :friend_count, :liker_count, :like_count, :band_like_count, :follower_count, :following_count, :band_following_count, :recording_count, :session_count,
|
||||
:biography
|
||||
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :location, :online, :photo_url, :musician, :gender, :birth_date, :internet_service_provider, :friend_count, :liker_count, :like_count, :band_like_count, :follower_count, :following_count, :band_following_count, :recording_count, :session_count, :biography
|
||||
|
||||
if @user.musician?
|
||||
node :location do @user.location end
|
||||
else
|
||||
node :location do @user.online ? 'Online' : 'Offline' end
|
||||
end
|
||||
|
||||
# give back more info if the user being fetched is yourself
|
||||
if @user == current_user
|
||||
attributes :email, :original_fpfile, :cropped_fpfile, :crop_selection, :session_settings, :show_whats_next, :subscribe_email
|
||||
elsif current_user
|
||||
node :is_friend do |uu|
|
||||
@user.friends?(current_user)
|
||||
end
|
||||
node :is_following do |uu|
|
||||
@user.following?(current_user)
|
||||
end
|
||||
end
|
||||
|
||||
unless @user.friends.nil? || @user.friends.size == 0
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<%= image_tag "content/icon_profile.png", :size => "19x19" %>
|
||||
</div>
|
||||
|
||||
<h1>musician profile</h1>
|
||||
<h1><span id="profile-type-label">musician</span> profile</h1>
|
||||
|
||||
<%= render "screen_navigation" %>
|
||||
</div>
|
||||
|
|
@ -47,11 +47,12 @@
|
|||
<div id="profile-about" class="profile-wrapper">
|
||||
<!-- stats & location -->
|
||||
<div class="profile-about-left">
|
||||
<h3>Location:</h3><br />
|
||||
<h3><span id="profile-location-label">Location</span>:</h3><br />
|
||||
<span id="profile-location"></span><br /><br /><br />
|
||||
<h3>Stats:</h3><br />
|
||||
<span id="profile-friend-stats"></span><br />
|
||||
<span id="profile-follower-stats"></span><br />
|
||||
<span id="profile-following-stats"></span><br />
|
||||
<span id="profile-session-stats"></span><br />
|
||||
<span id="profile-recording-stats"></span><br />
|
||||
</div>
|
||||
|
|
@ -149,4 +150,4 @@
|
|||
<div class="profile-block-name">{userName}</div>
|
||||
<div class="profile-block-city">{location}</div>
|
||||
</div>
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue