Merge branch 'develop' of bitbucket.org:jamkazam/jam-cloud into develop
This commit is contained in:
commit
f0cb73e842
|
|
@ -37,7 +37,7 @@ ActiveAdmin.register JamRuby::PromoLatest, :as => 'Latest' do
|
|||
|
||||
def create
|
||||
promo = PromoLatest.create_with_params(params[:jam_ruby_promo_latest])
|
||||
redirect_to('/admin/admin/latests')
|
||||
redirect_to('/admin/latests')
|
||||
end
|
||||
|
||||
def edit
|
||||
|
|
@ -48,7 +48,7 @@ ActiveAdmin.register JamRuby::PromoLatest, :as => 'Latest' do
|
|||
|
||||
def update
|
||||
resource.update_with_params(params[:jam_ruby_promo_latest]).save!
|
||||
redirect_to('/admin/admin/latests')
|
||||
redirect_to('/admin/latests')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
"use strict";
|
||||
context.JK = context.JK || {};
|
||||
context.JK.RecordingHoverBubble = function(recordingId, position) {
|
||||
|
||||
var logger = context.JK.logger;
|
||||
var rest = context.JK.Rest();
|
||||
var instrumentLogoMap = context.JK.getInstrumentIconMap24();
|
||||
|
|
@ -40,6 +39,7 @@
|
|||
var creator = recording.band == null ? recording.owner : recording.band;
|
||||
|
||||
var recordingHtml = context.JK.fillTemplate(template, {
|
||||
recordingId: recording.id,
|
||||
name: claimedRecording.name,
|
||||
genre: claimedRecording.genre_id.toUpperCase(),
|
||||
created_at: context.JK.formatDateTime(recording.created_at),
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
location: creator.location,
|
||||
musicians: musicianHtml
|
||||
});
|
||||
|
||||
|
||||
$(hoverSelector).append('<h2>Recording Detail</h2>' + recordingHtml);
|
||||
})
|
||||
.fail(function(xhr) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
var hoverSelector = "#session-hover";
|
||||
|
||||
this.showBubble = function() {
|
||||
$(hoverSelector).css({left: position.left-100, top: position.top+20});
|
||||
$(hoverSelector).css({left: position.left-100, top: position.top+10});
|
||||
$(hoverSelector).fadeIn(500);
|
||||
|
||||
rest.getSessionHistory(sessionId)
|
||||
|
|
@ -40,6 +40,7 @@
|
|||
var template = $('#template-hover-session').html();
|
||||
|
||||
var sessionHtml = context.JK.fillTemplate(template, {
|
||||
musicSessionId: response.id,
|
||||
description: response.description,
|
||||
genre: response.genres.toUpperCase(),
|
||||
comment_count: response.comment_count,
|
||||
|
|
|
|||
|
|
@ -1,504 +1,502 @@
|
|||
(function(context,$) {
|
||||
|
||||
"use strict";
|
||||
context.JK = context.JK || {};
|
||||
context.JK.ShareDialog = function(app, entityId, entityType) {
|
||||
var logger = context.JK.logger;
|
||||
var rest = context.JK.Rest();
|
||||
var facebookRest = context.JK.FacebookRest();
|
||||
var facebookHelper = null;
|
||||
var dialogId = '#share-dialog';
|
||||
var userDetail = null;
|
||||
var entity = null;
|
||||
var remainingCap = 140 - 22 - 1; // 140 tweet max, minus 22 for link size, minus 1 for space
|
||||
"use strict";
|
||||
context.JK = context.JK || {};
|
||||
context.JK.ShareDialog = function(app, entityId, entityType) {
|
||||
var logger = context.JK.logger;
|
||||
var rest = context.JK.Rest();
|
||||
var facebookRest = context.JK.FacebookRest();
|
||||
var facebookHelper = null;
|
||||
var dialogId = '#share-dialog';
|
||||
var userDetail = null;
|
||||
var entity = null;
|
||||
var remainingCap = 140 - 22 - 1; // 140 tweet max, minus 22 for link size, minus 1 for space
|
||||
|
||||
var textMap = {
|
||||
LIVE_SESSION: "LIVE SESSION",
|
||||
SESSION: "SESSION",
|
||||
RECORDING: "RECORDING",
|
||||
RECORDED: "RECORDED"
|
||||
};
|
||||
var textMap = {
|
||||
LIVE_SESSION: "LIVE SESSION",
|
||||
SESSION: "SESSION",
|
||||
RECORDING: "RECORDING",
|
||||
RECORDED: "RECORDED"
|
||||
};
|
||||
|
||||
function showSpinner() {
|
||||
$(dialogId + ' .dialog-inner').hide();
|
||||
var spinner = $('<div class="spinner spinner-large"></div>')
|
||||
$(dialogId + ' .content-head').after(spinner);
|
||||
function showSpinner() {
|
||||
$(dialogId + ' .dialog-inner').hide();
|
||||
var spinner = $('<div class="spinner spinner-large"></div>')
|
||||
$(dialogId + ' .content-head').after(spinner);
|
||||
}
|
||||
|
||||
function hideSpinner() {
|
||||
$(dialogId + ' .spinner').remove();
|
||||
$(dialogId + ' .dialog-inner').show();
|
||||
}
|
||||
|
||||
|
||||
function checkShareCheckbox(provider, checked) {
|
||||
var checkbox = $(dialogId + ' .share-with-' + provider + ' input');
|
||||
|
||||
if(checked) {
|
||||
checkbox.attr('checked', 'checked');
|
||||
}
|
||||
|
||||
function hideSpinner() {
|
||||
$(dialogId + ' .spinner').remove();
|
||||
$(dialogId + ' .dialog-inner').show();
|
||||
else {
|
||||
checkbox.removeAttr('checked');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function checkShareCheckbox(provider, checked) {
|
||||
var checkbox = $(dialogId + ' .share-with-' + provider + ' input');
|
||||
function handleRecordingShareWithGoogle(message) {
|
||||
var defer = $.Deferred();
|
||||
|
||||
if(checked) {
|
||||
checkbox.attr('checked', 'checked');
|
||||
}
|
||||
else {
|
||||
checkbox.removeAttr('checked');
|
||||
}
|
||||
}
|
||||
defer.resolve(); // remove when implemented
|
||||
|
||||
return defer;
|
||||
}
|
||||
|
||||
function handleRecordingShareWithGoogle(message) {
|
||||
var defer = $.Deferred();
|
||||
function handleShareWithTwitter(message) {
|
||||
var defer = $.Deferred();
|
||||
|
||||
defer.resolve(); // remove when implemented
|
||||
rest.tweet({message: message + ' ' + entity.share_url})
|
||||
.done(function() {
|
||||
|
||||
return defer;
|
||||
}
|
||||
// uncheck facebook, because we don't want the user to re-post to their timeline by accident
|
||||
checkShareCheckbox('twitter', false);
|
||||
defer.resolve();
|
||||
})
|
||||
.fail(function(jqXHR) {
|
||||
if(jqXHR.status == 422) {
|
||||
// implies twitter token error.
|
||||
|
||||
function handleShareWithTwitter(message) {
|
||||
var defer = $.Deferred();
|
||||
var response = JSON.parse(jqXHR.responseText);
|
||||
|
||||
rest.tweet({message: message + ' ' + entity.share_url})
|
||||
.done(function() {
|
||||
|
||||
// uncheck facebook, because we don't want the user to re-post to their timeline by accident
|
||||
checkShareCheckbox('twitter', false);
|
||||
defer.resolve();
|
||||
})
|
||||
.fail(function(jqXHR) {
|
||||
if(jqXHR.status == 422) {
|
||||
// implies twitter token error.
|
||||
|
||||
var response = JSON.parse(jqXHR.responseText);
|
||||
|
||||
if(response.errors.token) {
|
||||
app.notify({
|
||||
title : "Failed to Tweet",
|
||||
text : "You need to re-authorize JamKazam to access your Twitter account. Click (sign in) in the Share Dialog.",
|
||||
"icon_url": "/assets/content/icon_alert_big.png"
|
||||
});
|
||||
disableTwitter();
|
||||
}
|
||||
else if(response.errors.twitter) {
|
||||
app.notify({
|
||||
title : "Failed to Tweet",
|
||||
text : "Twitter rejected the tweet because '" + response.errors.twitter[0] + "'",
|
||||
"icon_url": "/assets/content/icon_alert_big.png"
|
||||
});
|
||||
}
|
||||
else {
|
||||
app.notifyServerError(jqXHR, "Unable to Share with Twitter");
|
||||
}
|
||||
if(response.errors.token) {
|
||||
app.notify({
|
||||
title : "Failed to Tweet",
|
||||
text : "You need to re-authorize JamKazam to access your Twitter account. Click (sign in) in the Share Dialog.",
|
||||
"icon_url": "/assets/content/icon_alert_big.png"
|
||||
});
|
||||
disableTwitter();
|
||||
}
|
||||
else if(response.errors.twitter) {
|
||||
app.notify({
|
||||
title : "Failed to Tweet",
|
||||
text : "Twitter rejected the tweet because '" + response.errors.twitter[0] + "'",
|
||||
"icon_url": "/assets/content/icon_alert_big.png"
|
||||
});
|
||||
}
|
||||
else {
|
||||
app.notifyServerError(jqXHR, "Unable to Share with Twitter");
|
||||
}
|
||||
defer.reject();
|
||||
});
|
||||
return defer;
|
||||
}
|
||||
}
|
||||
else {
|
||||
app.notifyServerError(jqXHR, "Unable to Share with Twitter");
|
||||
}
|
||||
defer.reject();
|
||||
});
|
||||
return defer;
|
||||
}
|
||||
|
||||
function handleRecordingShareWithTwitter(message) {
|
||||
return handleShareWithTwitter(message);
|
||||
}
|
||||
function handleRecordingShareWithTwitter(message) {
|
||||
return handleShareWithTwitter(message);
|
||||
}
|
||||
|
||||
function handleRecordingShareWithFacebook(message) {
|
||||
var defer = $.Deferred();
|
||||
function handleRecordingShareWithFacebook(message) {
|
||||
var defer = $.Deferred();
|
||||
|
||||
rest.getShareRecording({ provider:'facebook', claimed_recording: entityId})
|
||||
.done(function(data) {
|
||||
facebookHelper.promptLogin()
|
||||
.done(function(response) {
|
||||
handleFbStateChange(response);
|
||||
if(response.status == "connected") {
|
||||
facebookRest.post({
|
||||
access_token: response.authResponse.accessToken,
|
||||
message: message,
|
||||
description: data.description,
|
||||
caption: data.caption,
|
||||
name: data.title,
|
||||
picture: data.photo_url
|
||||
})
|
||||
.done(function(response) {
|
||||
checkShareCheckbox('facebook', false);
|
||||
defer.resolve();
|
||||
})
|
||||
.fail(function(response) {
|
||||
app.notify({
|
||||
title : "Unable to Share with Facebook",
|
||||
text : "Error: " + response,
|
||||
"icon_url": "/assets/content/icon_alert_big.png"
|
||||
});
|
||||
defer.reject();
|
||||
})
|
||||
}
|
||||
else {
|
||||
// user doesn't want to auth; this is a form of success
|
||||
defer.resolve();
|
||||
}
|
||||
})
|
||||
})
|
||||
.fail(function(jqXHR) {
|
||||
app.notifyServerError(jqXHR, "Unable to Populate Share Data");
|
||||
defer.reject();
|
||||
})
|
||||
|
||||
return defer;
|
||||
|
||||
}
|
||||
|
||||
function handleSessionShareWithGoogle(message) {
|
||||
var defer = $.Deferred();
|
||||
|
||||
defer.resolve(); // remove when implemented
|
||||
|
||||
return defer;
|
||||
}
|
||||
|
||||
function handleSessionShareWithTwitter(message) {
|
||||
return handleShareWithTwitter(message);
|
||||
}
|
||||
|
||||
function handleSessionShareWithFacebook(message) {
|
||||
var defer = $.Deferred();
|
||||
|
||||
rest.getShareSession({ provider:'facebook', music_session: entityId})
|
||||
.done(function(data) {
|
||||
facebookHelper.promptLogin()
|
||||
.done(function(response) {
|
||||
handleFbStateChange(response);
|
||||
if(response.status == "connected") {
|
||||
facebookRest.post({
|
||||
access_token: response.authResponse.accessToken,
|
||||
message: message,
|
||||
description: data.description,
|
||||
caption: data.caption,
|
||||
name: data.title,
|
||||
picture: data.photo_url
|
||||
})
|
||||
rest.getShareRecording({ provider:'facebook', claimed_recording: entityId})
|
||||
.done(function(data) {
|
||||
facebookHelper.promptLogin()
|
||||
.done(function(response) {
|
||||
handleFbStateChange(response);
|
||||
if(response.status == "connected") {
|
||||
facebookRest.post({
|
||||
access_token: response.authResponse.accessToken,
|
||||
message: message,
|
||||
description: data.description,
|
||||
caption: data.caption,
|
||||
name: data.title,
|
||||
picture: data.photo_url
|
||||
})
|
||||
.done(function(response) {
|
||||
checkShareCheckbox('facebook', false);
|
||||
defer.resolve();
|
||||
})
|
||||
.fail(function(response) {
|
||||
app.notify({
|
||||
title : "Unable to Share with Facebook",
|
||||
text : "Error: " + response,
|
||||
"icon_url": "/assets/content/icon_alert_big.png"
|
||||
});
|
||||
app.notify({
|
||||
title : "Unable to Share with Facebook",
|
||||
text : "Error: " + response,
|
||||
"icon_url": "/assets/content/icon_alert_big.png"
|
||||
});
|
||||
defer.reject();
|
||||
})
|
||||
}
|
||||
else {
|
||||
// user doesn't want to auth; this is a form of success
|
||||
defer.resolve();
|
||||
}
|
||||
})
|
||||
})
|
||||
.fail(function(jqXHR) {
|
||||
app.notifyServerError(jqXHR, "Unable to Populate Share Data");
|
||||
defer.reject();
|
||||
})
|
||||
|
||||
return defer;
|
||||
}
|
||||
|
||||
function messageTooLongForTwitter(message) {
|
||||
return message && message.length > remainingCap;
|
||||
}
|
||||
|
||||
function socialShare() {
|
||||
var facebookCheckbox = $(dialogId + ' .share-with-facebook input');
|
||||
var shareWithFacebook = facebookCheckbox.is(':checked') && !facebookCheckbox.is(':disabled');
|
||||
|
||||
var googleCheckbox = $(dialogId + ' .share-with-google input');
|
||||
var shareWithGoogle = googleCheckbox.is(':checked') && !googleCheckbox.is(':disabled');
|
||||
|
||||
var twitterCheckbox = $(dialogId + ' .share-with-twitter input');
|
||||
var shareWithTwitter = twitterCheckbox.is(':checked') && !twitterCheckbox.is(':disabled');
|
||||
|
||||
if(!shareWithFacebook && !shareWithGoogle && !shareWithTwitter) {
|
||||
$(dialogId + ' .share-options').addClass('error')
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$(dialogId + ' .share-options').removeClass('error')
|
||||
}
|
||||
|
||||
|
||||
var message = $(dialogId + ' .share-message').val();
|
||||
if(!message) { message = undefined; }
|
||||
|
||||
|
||||
|
||||
if(shareWithTwitter && !message) {
|
||||
$(dialogId + ' .share-message-holder').addClass('error')
|
||||
$(dialogId + ' .share-message-holder .error-msg').text("You must specify a message for Twitter.");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$(dialogId + ' .share-message-holder').removeClass('error')
|
||||
$(dialogId + ' .share-message-holder .error-msg').text('');
|
||||
}
|
||||
|
||||
// validate twitter message length
|
||||
if(shareWithTwitter && messageTooLongForTwitter(message)) {
|
||||
$(dialogId + ' .share-message-holder').addClass('error')
|
||||
$(dialogId + ' .share-message-holder .error-msg').text("Your message must be less than " + (remainingCap + 1) + " characters in length for Twitter (currently " + message.length + ").");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$(dialogId + ' .share-message-holder').removeClass('error')
|
||||
$(dialogId + ' .share-message-holder .error-msg').text('');
|
||||
}
|
||||
|
||||
showSpinner();
|
||||
|
||||
var chain = [];
|
||||
|
||||
if(entityType == 'session') {
|
||||
if(shareWithFacebook) {
|
||||
chain.push(handleSessionShareWithFacebook(message))
|
||||
}
|
||||
if(shareWithTwitter) {
|
||||
chain.push(handleSessionShareWithTwitter(message))
|
||||
}
|
||||
if(shareWithGoogle) {
|
||||
chain.push(handleSessionShareWithGoogle(message))
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(shareWithFacebook) {
|
||||
chain.push(handleRecordingShareWithFacebook(message))
|
||||
}
|
||||
if(shareWithTwitter) {
|
||||
chain.push(handleRecordingShareWithTwitter(message))
|
||||
}
|
||||
if(shareWithGoogle) {
|
||||
chain.push(handleRecordingShareWithGoogle(message))
|
||||
}
|
||||
}
|
||||
|
||||
$.when.apply($, chain)
|
||||
.done(function() {
|
||||
app.layout.closeDialog('share-dialog');
|
||||
})
|
||||
.fail(function() {
|
||||
logger.error("share failed")
|
||||
})
|
||||
.always(function() {
|
||||
hideSpinner();
|
||||
});
|
||||
}
|
||||
|
||||
function enableFacebook() {
|
||||
$(dialogId + ' .share-with-facebook input').removeAttr('disabled')
|
||||
$(dialogId + ' .share-with-facebook a').css('visibility', 'hidden');
|
||||
}
|
||||
|
||||
function disableFacebook() {
|
||||
$(dialogId + ' .share-with-facebook input').attr('disabled', 'disabled')
|
||||
$(dialogId + ' .share-with-facebook a').css('visibility', 'visible');
|
||||
}
|
||||
|
||||
function enableTwitter() {
|
||||
$(dialogId + ' .share-with-twitter input').removeAttr('disabled')
|
||||
$(dialogId + ' .share-with-twitter a').css('visibility', 'hidden');
|
||||
}
|
||||
|
||||
function disableTwitter() {
|
||||
$(dialogId + ' .share-with-twitter input').attr('disabled', 'disabled')
|
||||
$(dialogId + ' .share-with-twitter a').css('visibility', 'visible');
|
||||
}
|
||||
|
||||
function handleFbStateChange(response) {
|
||||
|
||||
if (response && response.status == "connected") {
|
||||
enableFacebook();
|
||||
}
|
||||
else{
|
||||
disableFacebook();
|
||||
}
|
||||
}
|
||||
function registerEvents(onOff) {
|
||||
$(dialogId + ' .dialog-share-button').unbind('click').click(function(e){
|
||||
socialShare();
|
||||
return false;
|
||||
});
|
||||
|
||||
$(dialogId + ' .share-with-facebook a').unbind('click').click(function(e) {
|
||||
facebookHelper.promptLogin().done(function(response) {
|
||||
handleFbStateChange(response);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$(dialogId + ' .share-with-twitter a').unbind('click').click(function(e) {
|
||||
app.layout.queueDialog('share-dialog')
|
||||
window.location = '/auth/twitter';
|
||||
return false;
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
function showDialog() {
|
||||
app.layout.showDialog('share-dialog');
|
||||
}
|
||||
|
||||
function initDialog() {
|
||||
var sessionText = textMap.SESSION;
|
||||
var liveSessionText = textMap.LIVE_SESSION;
|
||||
|
||||
var fill = entityType === sessionText.toLowerCase() ? "teal-fill" : "orange-fill";
|
||||
|
||||
$("#shareType").text(entityType);
|
||||
|
||||
$("#divWidgetCodeHeader").addClass(fill);
|
||||
$("#divWidgetPreviewHeader").addClass(fill);
|
||||
$("#divWidgetPreview").addClass(entityType);
|
||||
|
||||
// SESSION
|
||||
if (entityType === sessionText.toLowerCase()) {
|
||||
$("#lblWidgetCodeType").html(sessionText.toLowerCase());
|
||||
$("#lblWidgetPreviewType").html(sessionText.toLowerCase());
|
||||
$("#spnWidgetCodeBranding").text(liveSessionText.toLowerCase());
|
||||
$("#spnWidgetPreviewBranding").text(liveSessionText.toLowerCase());
|
||||
|
||||
rest.getSessionHistory(entityId)
|
||||
.done(function(response) {
|
||||
// var name, photoUrl;
|
||||
$(".link-contents").html(response.share_url);
|
||||
});
|
||||
}
|
||||
|
||||
// RECORDING
|
||||
else if (entityType === "recording") {
|
||||
var recordedText = textMap.RECORDED.toLowerCase();
|
||||
$("#lblWidgetCodeType").text(textMap.RECORDING);
|
||||
$("#lblWidgetPreviewType").text(textMap.RECORDING);
|
||||
$("#spnWidgetCodeBranding").text(recordedText);
|
||||
$("#spnWidgetPreviewBranding").text(recordedText);
|
||||
|
||||
rest.getClaimedRecording(entityId)
|
||||
.done(function(response) {
|
||||
var name, photoUrl;
|
||||
|
||||
if (response.recording.band) {
|
||||
name = response.recording.band.name;
|
||||
photoUrl = context.JK.resolveBandAvatarUrl(response.recording.band.photo_url);
|
||||
}
|
||||
else {
|
||||
name = response.recording.owner.name;
|
||||
photoUrl = context.JK.resolveAvatarUrl(response.recording.owner.photo_url);
|
||||
// user doesn't want to auth; this is a form of success
|
||||
defer.resolve();
|
||||
}
|
||||
})
|
||||
})
|
||||
.fail(function(jqXHR) {
|
||||
app.notifyServerError(jqXHR, "Unable to Populate Share Data");
|
||||
defer.reject();
|
||||
})
|
||||
|
||||
$(".link-contents").html(response.share_url);
|
||||
return defer;
|
||||
|
||||
$("#imgWidgetCodeAvatar").attr('src', photoUrl);
|
||||
$("#imgWidgetPreviewAvatar").attr('src', photoUrl);
|
||||
}
|
||||
|
||||
$("#divWidgetPreviewTitle").html(response.recording.name);
|
||||
function handleSessionShareWithGoogle(message) {
|
||||
var defer = $.Deferred();
|
||||
|
||||
$("#spnWidgetCodeArtistName").html(name);
|
||||
$("#spnWidgetPreviewArtistName").html(name);
|
||||
defer.resolve(); // remove when implemented
|
||||
|
||||
$.each(response.recording.recorded_tracks, function(index, val) {
|
||||
$(".widget-members").append('<div class="widget-avatar-small">' + '<img src="' + context.JK.resolveAvatarUrl(val.user.photo_url) + '" alt="" />' + '</div>');
|
||||
});
|
||||
});
|
||||
}
|
||||
return defer;
|
||||
}
|
||||
|
||||
function handleSessionShareWithTwitter(message) {
|
||||
return handleShareWithTwitter(message);
|
||||
}
|
||||
|
||||
function handleSessionShareWithFacebook(message) {
|
||||
var defer = $.Deferred();
|
||||
|
||||
rest.getShareSession({ provider:'facebook', music_session: entityId})
|
||||
.done(function(data) {
|
||||
facebookHelper.promptLogin()
|
||||
.done(function(response) {
|
||||
handleFbStateChange(response);
|
||||
if(response.status == "connected") {
|
||||
facebookRest.post({
|
||||
access_token: response.authResponse.accessToken,
|
||||
message: message,
|
||||
description: data.description,
|
||||
caption: data.caption,
|
||||
name: data.title,
|
||||
picture: data.photo_url
|
||||
})
|
||||
.done(function(response) {
|
||||
checkShareCheckbox('facebook', false);
|
||||
defer.resolve();
|
||||
})
|
||||
.fail(function(response) {
|
||||
app.notify({
|
||||
title : "Unable to Share with Facebook",
|
||||
text : "Error: " + response,
|
||||
"icon_url": "/assets/content/icon_alert_big.png"
|
||||
});
|
||||
defer.reject();
|
||||
})
|
||||
}
|
||||
else {
|
||||
// user doesn't want to auth; this is a form of success
|
||||
defer.resolve();
|
||||
}
|
||||
})
|
||||
})
|
||||
.fail(function(jqXHR) {
|
||||
app.notifyServerError(jqXHR, "Unable to Populate Share Data");
|
||||
defer.reject();
|
||||
})
|
||||
|
||||
return defer;
|
||||
}
|
||||
|
||||
function messageTooLongForTwitter(message) {
|
||||
return message && message.length > remainingCap;
|
||||
}
|
||||
|
||||
function socialShare() {
|
||||
var facebookCheckbox = $(dialogId + ' .share-with-facebook input');
|
||||
var shareWithFacebook = facebookCheckbox.is(':checked') && !facebookCheckbox.is(':disabled');
|
||||
|
||||
var googleCheckbox = $(dialogId + ' .share-with-google input');
|
||||
var shareWithGoogle = googleCheckbox.is(':checked') && !googleCheckbox.is(':disabled');
|
||||
|
||||
var twitterCheckbox = $(dialogId + ' .share-with-twitter input');
|
||||
var shareWithTwitter = twitterCheckbox.is(':checked') && !twitterCheckbox.is(':disabled');
|
||||
|
||||
if(!shareWithFacebook && !shareWithGoogle && !shareWithTwitter) {
|
||||
$(dialogId + ' .share-options').addClass('error')
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$(dialogId + ' .share-options').removeClass('error')
|
||||
}
|
||||
|
||||
function beforeShow() {
|
||||
disableTwitter();
|
||||
// no disableFacebook on purpose
|
||||
|
||||
if(entityType == 'recording') {
|
||||
rest.getClaimedRecording(entityId)
|
||||
.done(function(data) {
|
||||
entity = data;
|
||||
$(dialogId + ' .link-contents').text(entity.share_url)
|
||||
})
|
||||
.fail(function(jqXHR) {
|
||||
app.notifyServerError(jqXHR, "Unable to Fetch Session Data");
|
||||
})
|
||||
}
|
||||
else {
|
||||
rest.getSession(entityId)
|
||||
.done(function(data) {
|
||||
entity = data;
|
||||
$(dialogId + ' .link-contents').text(entity.share_url)
|
||||
})
|
||||
.fail(function(jqXHR) {
|
||||
app.notifyServerError(jqXHR, "Unable to Fetch Session Data");
|
||||
});
|
||||
}
|
||||
rest.getUserDetail()
|
||||
.done(function(data) {
|
||||
userDetail = data;
|
||||
if(data.auth_twitter) {
|
||||
enableTwitter();
|
||||
}
|
||||
else {
|
||||
disableTwitter();
|
||||
}
|
||||
});
|
||||
var message = $(dialogId + ' .share-message').val();
|
||||
if(!message) { message = undefined; }
|
||||
|
||||
|
||||
|
||||
if(shareWithTwitter && !message) {
|
||||
$(dialogId + ' .share-message-holder').addClass('error')
|
||||
$(dialogId + ' .share-message-holder .error-msg').text("You must specify a message for Twitter.");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$(dialogId + ' .share-message-holder').removeClass('error')
|
||||
$(dialogId + ' .share-message-holder .error-msg').text('');
|
||||
|
||||
$(dialogId + ' .share-options').removeClass('error');
|
||||
registerEvents(true);
|
||||
}
|
||||
|
||||
function afterShow() {
|
||||
if(context.JK.hasFlash()) {
|
||||
$("#btn-share-copy").clipboard({
|
||||
path: '/assets/jquery.clipboard.swf',
|
||||
copy: function() {
|
||||
// Return text in closest element (useful when you have multiple boxes that can be copied)
|
||||
return $(".link-contents").text();
|
||||
}
|
||||
});
|
||||
// validate twitter message length
|
||||
if(shareWithTwitter && messageTooLongForTwitter(message)) {
|
||||
$(dialogId + ' .share-message-holder').addClass('error')
|
||||
$(dialogId + ' .share-message-holder .error-msg').text("Your message must be less than " + (remainingCap + 1) + " characters in length for Twitter (currently " + message.length + ").");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$(dialogId + ' .share-message-holder').removeClass('error')
|
||||
$(dialogId + ' .share-message-holder .error-msg').text('');
|
||||
}
|
||||
|
||||
showSpinner();
|
||||
|
||||
var chain = [];
|
||||
|
||||
if(entityType == 'session') {
|
||||
if(shareWithFacebook) {
|
||||
chain.push(handleSessionShareWithFacebook(message))
|
||||
}
|
||||
else {
|
||||
if(context.jamClient) {
|
||||
// uses bridge call to ultimately access QClipboard
|
||||
$("#btn-share-copy").unbind('click').click(function() {
|
||||
context.jamClient.SaveToClipboard($(".link-contents").text());
|
||||
return false;
|
||||
})
|
||||
if(shareWithTwitter) {
|
||||
chain.push(handleSessionShareWithTwitter(message))
|
||||
}
|
||||
if(shareWithGoogle) {
|
||||
chain.push(handleSessionShareWithGoogle(message))
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(shareWithFacebook) {
|
||||
chain.push(handleRecordingShareWithFacebook(message))
|
||||
}
|
||||
if(shareWithTwitter) {
|
||||
chain.push(handleRecordingShareWithTwitter(message))
|
||||
}
|
||||
if(shareWithGoogle) {
|
||||
chain.push(handleRecordingShareWithGoogle(message))
|
||||
}
|
||||
}
|
||||
|
||||
$.when.apply($, chain)
|
||||
.done(function() {
|
||||
app.layout.closeDialog('share-dialog');
|
||||
})
|
||||
.fail(function() {
|
||||
logger.error("share failed")
|
||||
})
|
||||
.always(function() {
|
||||
hideSpinner();
|
||||
});
|
||||
}
|
||||
|
||||
function enableFacebook() {
|
||||
$(dialogId + ' .share-with-facebook input').removeAttr('disabled')
|
||||
$(dialogId + ' .share-with-facebook a').css('visibility', 'hidden');
|
||||
}
|
||||
|
||||
function disableFacebook() {
|
||||
$(dialogId + ' .share-with-facebook input').attr('disabled', 'disabled')
|
||||
$(dialogId + ' .share-with-facebook a').css('visibility', 'visible');
|
||||
}
|
||||
|
||||
function enableTwitter() {
|
||||
$(dialogId + ' .share-with-twitter input').removeAttr('disabled')
|
||||
$(dialogId + ' .share-with-twitter a').css('visibility', 'hidden');
|
||||
}
|
||||
|
||||
function disableTwitter() {
|
||||
$(dialogId + ' .share-with-twitter input').attr('disabled', 'disabled')
|
||||
$(dialogId + ' .share-with-twitter a').css('visibility', 'visible');
|
||||
}
|
||||
|
||||
function handleFbStateChange(response) {
|
||||
|
||||
if (response && response.status == "connected") {
|
||||
enableFacebook();
|
||||
}
|
||||
else{
|
||||
disableFacebook();
|
||||
}
|
||||
}
|
||||
|
||||
function registerEvents(onOff) {
|
||||
$(dialogId + ' .dialog-share-button').unbind('click').click(function(e){
|
||||
socialShare();
|
||||
return false;
|
||||
});
|
||||
|
||||
$(dialogId + ' .share-with-facebook a').unbind('click').click(function(e) {
|
||||
facebookHelper.promptLogin().done(function(response) {
|
||||
handleFbStateChange(response);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$(dialogId + ' .share-with-twitter a').unbind('click').click(function(e) {
|
||||
app.layout.queueDialog('share-dialog')
|
||||
window.location = '/auth/twitter';
|
||||
return false;
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
function showDialog() {
|
||||
app.layout.showDialog('share-dialog');
|
||||
}
|
||||
|
||||
// function initDialog() {
|
||||
// var sessionText = textMap.SESSION;
|
||||
// var liveSessionText = textMap.LIVE_SESSION;
|
||||
|
||||
// var fill = entityType === sessionText.toLowerCase() ? "teal-fill" : "orange-fill";
|
||||
|
||||
// $("#shareType").text(entityType);
|
||||
|
||||
// $("#divWidgetCodeHeader").addClass(fill);
|
||||
// $("#divWidgetPreviewHeader").addClass(fill);
|
||||
// $("#divWidgetPreview").addClass(entityType);
|
||||
|
||||
// // SESSION
|
||||
// if (entityType === sessionText.toLowerCase()) {
|
||||
// $("#lblWidgetCodeType").html(sessionText.toLowerCase());
|
||||
// $("#lblWidgetPreviewType").html(sessionText.toLowerCase());
|
||||
// $("#spnWidgetCodeBranding").text(liveSessionText.toLowerCase());
|
||||
// $("#spnWidgetPreviewBranding").text(liveSessionText.toLowerCase());
|
||||
|
||||
// rest.getSessionHistory(entityId)
|
||||
// .done(function(response) {
|
||||
// $(".link-contents").html(response.share_url);
|
||||
// });
|
||||
// }
|
||||
|
||||
// // RECORDING
|
||||
// else if (entityType === "recording") {
|
||||
// var recordedText = textMap.RECORDED.toLowerCase();
|
||||
// $("#lblWidgetCodeType").text(textMap.RECORDING);
|
||||
// $("#lblWidgetPreviewType").text(textMap.RECORDING);
|
||||
// $("#spnWidgetCodeBranding").text(recordedText);
|
||||
// $("#spnWidgetPreviewBranding").text(recordedText);
|
||||
|
||||
// rest.getClaimedRecording(entityId)
|
||||
// .done(function(response) {
|
||||
// var name, photoUrl;
|
||||
|
||||
// if (response.recording.band) {
|
||||
// name = response.recording.band.name;
|
||||
// photoUrl = context.JK.resolveBandAvatarUrl(response.recording.band.photo_url);
|
||||
// }
|
||||
// else {
|
||||
// name = response.recording.owner.name;
|
||||
// photoUrl = context.JK.resolveAvatarUrl(response.recording.owner.photo_url);
|
||||
// }
|
||||
|
||||
// $(".link-contents").html(response.share_url);
|
||||
|
||||
// $("#imgWidgetCodeAvatar").attr('src', photoUrl);
|
||||
// $("#imgWidgetPreviewAvatar").attr('src', photoUrl);
|
||||
|
||||
// $("#divWidgetPreviewTitle").html(response.recording.name);
|
||||
|
||||
// $("#spnWidgetCodeArtistName").html(name);
|
||||
// $("#spnWidgetPreviewArtistName").html(name);
|
||||
|
||||
// $.each(response.recording.recorded_tracks, function(index, val) {
|
||||
// $(".widget-members").append('<div class="widget-avatar-small">' + '<img src="' + context.JK.resolveAvatarUrl(val.user.photo_url) + '" alt="" />' + '</div>');
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
function beforeShow() {
|
||||
disableTwitter();
|
||||
// no disableFacebook on purpose
|
||||
|
||||
if(entityType == 'recording') {
|
||||
rest.getClaimedRecording(entityId)
|
||||
.done(function(data) {
|
||||
entity = data;
|
||||
$(dialogId + ' .link-contents').text(entity.share_url)
|
||||
})
|
||||
.fail(function(jqXHR) {
|
||||
app.notifyServerError(jqXHR, "Unable to Fetch Session Data");
|
||||
})
|
||||
}
|
||||
else {
|
||||
rest.getSession(entityId)
|
||||
.done(function(data) {
|
||||
entity = data;
|
||||
$(dialogId + ' .link-contents').text(entity.share_url)
|
||||
})
|
||||
.fail(function(jqXHR) {
|
||||
app.notifyServerError(jqXHR, "Unable to Fetch Session Data");
|
||||
});
|
||||
}
|
||||
rest.getUserDetail()
|
||||
.done(function(data) {
|
||||
userDetail = data;
|
||||
if(data.auth_twitter) {
|
||||
enableTwitter();
|
||||
}
|
||||
else {
|
||||
console.log("no copy-to-clipboard capabilities")
|
||||
disableTwitter();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function afterHide() {
|
||||
hideSpinner();
|
||||
registerEvents(false);
|
||||
}
|
||||
|
||||
function initialize(_facebookHelper) {
|
||||
facebookHelper = _facebookHelper;
|
||||
|
||||
var dialogBindings = {
|
||||
'beforeShow' : beforeShow,
|
||||
'afterShow' : afterShow,
|
||||
'afterHide': afterHide
|
||||
};
|
||||
|
||||
app.bindDialog('share-dialog', dialogBindings);
|
||||
|
||||
initDialog();
|
||||
|
||||
facebookHelper.deferredLoginStatus().done(function(response) { handleFbStateChange(response); });
|
||||
}
|
||||
|
||||
this.initialize = initialize;
|
||||
this.showDialog = showDialog;
|
||||
$(dialogId + ' .share-message-holder').removeClass('error')
|
||||
$(dialogId + ' .share-message-holder .error-msg').text('');
|
||||
$(dialogId + ' .share-options').removeClass('error');
|
||||
registerEvents(true);
|
||||
}
|
||||
|
||||
function afterShow() {
|
||||
$("#shareType").text(entityType);
|
||||
if(context.JK.hasFlash()) {
|
||||
$("#btn-share-copy").clipboard({
|
||||
path: '/assets/jquery.clipboard.swf',
|
||||
copy: function() {
|
||||
// Return text in closest element (useful when you have multiple boxes that can be copied)
|
||||
return $(".link-contents").text();
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
if(context.jamClient) {
|
||||
// uses bridge call to ultimately access QClipboard
|
||||
$("#btn-share-copy").unbind('click').click(function() {
|
||||
context.jamClient.SaveToClipboard($(".link-contents").text());
|
||||
return false;
|
||||
})
|
||||
}
|
||||
else {
|
||||
console.log("no copy-to-clipboard capabilities")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function afterHide() {
|
||||
hideSpinner();
|
||||
registerEvents(false);
|
||||
}
|
||||
|
||||
function initialize(_facebookHelper) {
|
||||
facebookHelper = _facebookHelper;
|
||||
|
||||
var dialogBindings = {
|
||||
'beforeShow' : beforeShow,
|
||||
'afterShow' : afterShow,
|
||||
'afterHide': afterHide
|
||||
};
|
||||
|
||||
app.bindDialog('share-dialog', dialogBindings);
|
||||
|
||||
//initDialog();
|
||||
|
||||
facebookHelper.deferredLoginStatus().done(function(response) { handleFbStateChange(response); });
|
||||
}
|
||||
|
||||
this.initialize = initialize;
|
||||
this.showDialog = showDialog;
|
||||
}
|
||||
|
||||
return this;
|
||||
})(window,jQuery);
|
||||
|
|
|
|||
|
|
@ -174,15 +174,16 @@
|
|||
});
|
||||
|
||||
// FAN
|
||||
$("[hoveraction='fan']").hover(
|
||||
function() {
|
||||
$("[hoveraction='fan']").hoverIntent({
|
||||
over: function() {
|
||||
var bubble = new JK.FanHoverBubble($(this).attr('user-id'), $(this).offset());
|
||||
showBubble(bubble, $(this));
|
||||
},
|
||||
function() { // this registers for leaving the hoverable element
|
||||
out: function() { // this registers for leaving the hoverable element
|
||||
hideBubble($(this));
|
||||
}
|
||||
);
|
||||
},
|
||||
sensitivity: 1
|
||||
});
|
||||
|
||||
// BAND
|
||||
$("[hoveraction='band']").hoverIntent({
|
||||
|
|
@ -197,26 +198,28 @@
|
|||
});
|
||||
|
||||
// SESSION
|
||||
$("[hoveraction='session']").hover(
|
||||
function() {
|
||||
$("[hoveraction='session']").hoverIntent({
|
||||
over: function() {
|
||||
var bubble = new JK.SessionHoverBubble($(this).attr('session-id'), $(this).offset());
|
||||
showBubble(bubble, $(this));
|
||||
},
|
||||
function() { // this registers for leaving the hoverable element
|
||||
out: function() { // this registers for leaving the hoverable element
|
||||
hideBubble($(this));
|
||||
}
|
||||
);
|
||||
},
|
||||
sensitivity: 1
|
||||
});
|
||||
|
||||
// RECORDING
|
||||
$("[hoveraction='recording']").hover(
|
||||
function() {
|
||||
$("[hoveraction='recording']").hoverIntent({
|
||||
over: function() {
|
||||
var bubble = new JK.RecordingHoverBubble($(this).attr('recording-id'), $(this).offset());
|
||||
showBubble(bubble, $(this));
|
||||
},
|
||||
function() { // this registers for leaving the hoverable element
|
||||
out: function() { // this registers for leaving the hoverable element
|
||||
hideBubble($(this));
|
||||
}
|
||||
);
|
||||
},
|
||||
sensitivity: 1
|
||||
});
|
||||
}
|
||||
|
||||
context.JK.fetchUserNetworkOrServerFailure = function() {
|
||||
|
|
|
|||
|
|
@ -1,75 +1,76 @@
|
|||
(function(context, $) {
|
||||
|
||||
context.JK.ShowRecording = function(app) {
|
||||
var logger = context.JK.logger;
|
||||
var rest = new JK.Rest();
|
||||
var recordingId = null;
|
||||
var claimedRecordingId = null;
|
||||
context.JK.ShowRecording = function(app) {
|
||||
var logger = context.JK.logger;
|
||||
var rest = new JK.Rest();
|
||||
var recordingId = null;
|
||||
var claimedRecordingId = null;
|
||||
var $scope = $(".landing-details");
|
||||
|
||||
function like() {
|
||||
rest.addRecordingLike(recordingId, JK.currentUserId)
|
||||
.done(function(response) {
|
||||
$("#spnLikeCount").html(parseInt($("#spnLikeCount").text()) + 1);
|
||||
$("#btnLike").unbind("click");
|
||||
});
|
||||
}
|
||||
|
||||
function play() {
|
||||
rest.addRecordingPlay(recordingId, JK.currentUserId)
|
||||
.done(function(response) {
|
||||
$("#spnPlayCount").html(parseInt($("#spnPlayCount").text()) + 1);
|
||||
});
|
||||
}
|
||||
|
||||
function addComment() {
|
||||
var comment = $("#txtRecordingComment").val();
|
||||
if ($.trim(comment).length > 0) {
|
||||
rest.addRecordingComment(recordingId, JK.currentUserId, comment)
|
||||
.done(function(response) {
|
||||
$("#spnCommentCount").html(parseInt($("#spnCommentCount").text()) + 1);
|
||||
|
||||
var template = $('#template-landing-comment').html();
|
||||
var commentHtml = context.JK.fillTemplate(template, {
|
||||
avatar_url: context.JK.currentUserAvatarUrl,
|
||||
name: context.JK.currentUserName,
|
||||
comment: comment
|
||||
});
|
||||
|
||||
$(".landing-comment-scroller").prepend(commentHtml);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function initialize(_claimedRecordingId, _recordingId) {
|
||||
recordingId = _recordingId;
|
||||
claimedRecordingId = _claimedRecordingId;
|
||||
|
||||
if (JK.currentUserId) {
|
||||
var shareDialog = new JK.ShareDialog(JK.app, claimedRecordingId, "recording");
|
||||
shareDialog.initialize(context.JK.FacebookHelperInstance);
|
||||
|
||||
$("#btnShare").click(function(e) {
|
||||
shareDialog.showDialog();
|
||||
});
|
||||
|
||||
$("#txtRecordingComment").keypress(function(e) {
|
||||
if (e.which === 13) {
|
||||
addComment();
|
||||
$(this).val('');
|
||||
$(this).blur();
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
$("#txtRecordingComment").attr("disabled", "disabled");
|
||||
$("#txtRecordingComment").val("You must be logged in to add a comment.");
|
||||
}
|
||||
|
||||
$("#btnLike").click(like);
|
||||
$("#btnPlay").click(play);
|
||||
}
|
||||
|
||||
this.initialize = initialize;
|
||||
function like() {
|
||||
rest.addRecordingLike(recordingId, JK.currentUserId)
|
||||
.done(function(response) {
|
||||
$("#spnLikeCount").html(parseInt($("#spnLikeCount").text()) + 1);
|
||||
$("#btnLike", $scope).unbind("click");
|
||||
});
|
||||
}
|
||||
|
||||
function play() {
|
||||
rest.addRecordingPlay(recordingId, JK.currentUserId)
|
||||
.done(function(response) {
|
||||
$("#spnPlayCount", $scope).html(parseInt($("#spnPlayCount").text()) + 1);
|
||||
});
|
||||
}
|
||||
|
||||
function addComment() {
|
||||
var comment = $("#txtRecordingComment").val();
|
||||
if ($.trim(comment).length > 0) {
|
||||
rest.addRecordingComment(recordingId, JK.currentUserId, comment)
|
||||
.done(function(response) {
|
||||
$("#spnCommentCount", $scope).html(parseInt($("#spnCommentCount").text()) + 1);
|
||||
|
||||
var template = $('#template-landing-comment').html();
|
||||
var commentHtml = context.JK.fillTemplate(template, {
|
||||
avatar_url: context.JK.currentUserAvatarUrl,
|
||||
name: context.JK.currentUserName,
|
||||
comment: comment
|
||||
});
|
||||
|
||||
$(".landing-comment-scroller").prepend(commentHtml);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function initialize(_claimedRecordingId, _recordingId) {
|
||||
recordingId = _recordingId;
|
||||
claimedRecordingId = _claimedRecordingId;
|
||||
|
||||
if (JK.currentUserId) {
|
||||
var shareDialog = new JK.ShareDialog(JK.app, claimedRecordingId, "recording");
|
||||
shareDialog.initialize(JK.FacebookHelperInstance);
|
||||
|
||||
$("#btnShare", $scope).click(function(e) {
|
||||
shareDialog.showDialog();
|
||||
});
|
||||
|
||||
$("#txtRecordingComment", $scope).keypress(function(e) {
|
||||
if (e.which === 13) {
|
||||
addComment();
|
||||
$(this).val('');
|
||||
$(this).blur();
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
$("#txtRecordingComment", $scope).attr("disabled", "disabled");
|
||||
$("#txtRecordingComment", $scope).val("You must be logged in to add a comment.");
|
||||
}
|
||||
|
||||
$("#btnLike").click(like);
|
||||
$("#btnPlay").click(play);
|
||||
}
|
||||
|
||||
this.initialize = initialize;
|
||||
}
|
||||
|
||||
})(window, jQuery);
|
||||
|
|
@ -1,69 +1,65 @@
|
|||
(function(context, $) {
|
||||
|
||||
context.JK.ShowMusicSession = function(app) {
|
||||
var logger = context.JK.logger;
|
||||
var rest = new JK.Rest();
|
||||
var sessionId = null;
|
||||
context.JK.ShowMusicSession = function(app) {
|
||||
var logger = context.JK.logger;
|
||||
var rest = new JK.Rest();
|
||||
var sessionId = null;
|
||||
|
||||
function like() {
|
||||
rest.addSessionLike(sessionId, JK.currentUserId)
|
||||
.done(function(response) {
|
||||
$("#spnLikeCount").html(parseInt($("#spnLikeCount").text()) + 1);
|
||||
$("#btnLike").unbind("click");
|
||||
});
|
||||
}
|
||||
|
||||
function addComment() {
|
||||
var comment = $("#txtSessionComment").val();
|
||||
if ($.trim(comment).length > 0) {
|
||||
rest.addSessionComment(sessionId, JK.currentUserId, comment)
|
||||
.done(function(response) {
|
||||
$("#spnCommentCount").html(parseInt($("#spnCommentCount").text()) + 1);
|
||||
|
||||
var template = $('#template-landing-comment').html();
|
||||
var commentHtml = context.JK.fillTemplate(template, {
|
||||
avatar_url: context.JK.currentUserAvatarUrl,
|
||||
name: context.JK.currentUserName,
|
||||
comment: comment
|
||||
});
|
||||
|
||||
$(".landing-comment-scroller").prepend(commentHtml);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function initialize(musicSessionId) {
|
||||
|
||||
sessionId = musicSessionId;
|
||||
|
||||
if (context.JK.currentUserId) {
|
||||
|
||||
var shareDialog = new JK.ShareDialog(context.JK.app, sessionId, "session");
|
||||
shareDialog.initialize(context.JK.FacebookHelperInstance);
|
||||
|
||||
// shareDialog.showDialog();
|
||||
|
||||
$("#btnShare").click(function(e) {
|
||||
shareDialog.showDialog();
|
||||
});
|
||||
|
||||
$("#txtSessionComment").keypress(function(e) {
|
||||
if (e.which === 13) {
|
||||
addComment();
|
||||
$(this).val('');
|
||||
$(this).blur();
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
$("#txtSessionComment").attr("disabled", "disabled");
|
||||
$("#txtSessionComment").val("You must be logged in to add a comment.");
|
||||
}
|
||||
|
||||
$("#btnLike").click(like);
|
||||
}
|
||||
|
||||
this.initialize = initialize;
|
||||
function like() {
|
||||
rest.addSessionLike(sessionId, JK.currentUserId)
|
||||
.done(function(response) {
|
||||
$("#spnLikeCount").html(parseInt($("#spnLikeCount").text()) + 1);
|
||||
$("#btnLike").unbind("click");
|
||||
});
|
||||
}
|
||||
|
||||
function addComment() {
|
||||
var comment = $("#txtSessionComment").val();
|
||||
if ($.trim(comment).length > 0) {
|
||||
rest.addSessionComment(sessionId, JK.currentUserId, comment)
|
||||
.done(function(response) {
|
||||
$("#spnCommentCount").html(parseInt($("#spnCommentCount").text()) + 1);
|
||||
|
||||
var template = $('#template-landing-comment').html();
|
||||
var commentHtml = context.JK.fillTemplate(template, {
|
||||
avatar_url: context.JK.currentUserAvatarUrl,
|
||||
name: context.JK.currentUserName,
|
||||
comment: comment
|
||||
});
|
||||
|
||||
$(".landing-comment-scroller").prepend(commentHtml);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function initialize(musicSessionId) {
|
||||
sessionId = musicSessionId;
|
||||
|
||||
if (JK.currentUserId) {
|
||||
var shareDialog = new JK.ShareDialog(context.JK.app, sessionId, "session");
|
||||
shareDialog.initialize(JK.FacebookHelperInstance);
|
||||
|
||||
$("#btnShare").click(function(e) {
|
||||
shareDialog.showDialog();
|
||||
});
|
||||
|
||||
$("#txtSessionComment").keypress(function(e) {
|
||||
if (e.which === 13) {
|
||||
addComment();
|
||||
$(this).val('');
|
||||
$(this).blur();
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
$("#txtSessionComment").attr("disabled", "disabled");
|
||||
$("#txtSessionComment").val("You must be logged in to add a comment.");
|
||||
}
|
||||
|
||||
$("#btnLike").click(like);
|
||||
}
|
||||
|
||||
this.initialize = initialize;
|
||||
}
|
||||
|
||||
})(window, jQuery);
|
||||
|
|
@ -5,8 +5,9 @@
|
|||
$grayMediumLight: #eaeaea;
|
||||
|
||||
@mixin box_sizing {
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-ms-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,18 @@
|
|||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var rest = JK.Rest();
|
||||
|
||||
function addRecordingLike(recordingId) {
|
||||
rest.addRecordingLike(recordingId, JK.currentUserId)
|
||||
.done(function(response) {
|
||||
$("#spnLikeCount", "#recording-hover").html(parseInt($("#spnLikeCount", "#recording-hover").text()) + 1);
|
||||
$("#btnLike", "#recording-hover").unbind("click");
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="template-hover-recording">
|
||||
<div class="bubble-inner">
|
||||
<h3>{name}</h3>
|
||||
|
|
@ -10,9 +22,9 @@
|
|||
<br clear="all" />
|
||||
<div class="f11 mt5 mb5">{description}</div>
|
||||
<div class="small">
|
||||
{play_count} <img src="/assets/content/icon_arrow.png" width="7" height="12" align="absmiddle" />
|
||||
{comment_count} <img src="/assets/content/icon_comment.png" width="13" height="12" align="absmiddle" />
|
||||
{like_count} <img src="/assets/content/icon_like.png" width="12" height="12" align="absmiddle" />
|
||||
<span id="spnPlayCount">{play_count}</span> <img src="/assets/content/icon_arrow.png" width="7" height="12" align="absmiddle" style="vertical-align:middle;" />
|
||||
<span id="spnCommentCount">{comment_count}</span> <img src="/assets/content/icon_comment.png" width="13" height="12" align="absmiddle" style="vertical-align:middle;" />
|
||||
<span id="spnLikeCount">{like_count}</span> <img src="/assets/content/icon_like.png" width="12" height="12" align="absmiddle" style="vertical-align:middle;" />
|
||||
</div>
|
||||
<br /><br />
|
||||
<a href="#" class="avatar_large left mr20"><img src="{creator_avatar_url}" /></a>
|
||||
|
|
@ -24,12 +36,11 @@
|
|||
MUSICIANS:<br /><br />
|
||||
<table class="musicians" cellpadding="0" cellspacing="5">
|
||||
{musicians}
|
||||
</table>
|
||||
<br /><br />
|
||||
</table><br />
|
||||
<div align="center">
|
||||
<div class="left"><a href="#" class="button-orange">LIKE</a></div>
|
||||
<div class="left"><a href="#" class="button-orange">COMMENT</a></div>
|
||||
<div class="left"><a href="#" class="button-orange">SHARE</a></div>
|
||||
<div class="left"><a id="btnLike" onclick="addRecordingLike('{recordingId}');" class="button-orange">LIKE</a></div>
|
||||
<div class="left"><a id="btnComment" class="button-orange">COMMENT</a></div>
|
||||
<div class="left"><a id="btnShare" layout-link="share-dialog" class="button-orange">SHARE</a></div>
|
||||
</div>
|
||||
<br /><br />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,19 @@
|
|||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var $scope = $("#session-hover");
|
||||
var rest = JK.Rest();
|
||||
|
||||
function addSessionLike(sessionId) {
|
||||
rest.addSessionLike(sessionId, JK.currentUserId)
|
||||
.done(function(response) {
|
||||
$("#spnLikeCount", "#session-hover").html(parseInt($("#spnLikeCount", "#session-hover").text()) + 1);
|
||||
$("#btnLike", "#session-hover").unbind("click");
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="template-hover-session">
|
||||
<div class="bubble-inner">
|
||||
<div class="small left">{genre}</div>
|
||||
|
|
@ -9,8 +22,8 @@
|
|||
<br clear="all" />
|
||||
<div class="f11 mt5 mb5">{description}</div>
|
||||
<div class="small">
|
||||
{comment_count} <img src="/assets/content/icon_comment.png" width="13" height="12" align="absmiddle" style="vertical-align:middle;" />
|
||||
{like_count} <img src="/assets/content/icon_like.png" width="12" height="12" align="absmiddle" style="vertical-align:middle;" />
|
||||
<span id="spnCommentCount">{comment_count}</span> <img src="/assets/content/icon_comment.png" width="13" height="12" align="absmiddle" style="vertical-align:middle;" />
|
||||
<span id="spnLikeCount">{like_count}</span> <img src="/assets/content/icon_like.png" width="12" height="12" align="absmiddle" style="vertical-align:middle;" />
|
||||
</div>
|
||||
<br />
|
||||
MUSICIANS:<br /><br />
|
||||
|
|
@ -19,9 +32,9 @@
|
|||
</table>
|
||||
<br /><br />
|
||||
<div align="center">
|
||||
<div class="left"><a href="#" class="button-orange">LIKE</a></div>
|
||||
<div class="left"><a href="#" class="button-orange">COMMENT</a></div>
|
||||
<div class="left"><a href="#" class="button-orange">SHARE</a></div>
|
||||
<div class="left"><a id="btnLike" onclick="addSessionLike('{musicSessionId}');" class="button-orange">LIKE</a></div>
|
||||
<div class="left"><a id="btnComment" class="button-orange">COMMENT</a></div>
|
||||
<div class="left"><a id="btnShare" layout-link="share-dialog" class="button-orange">SHARE</a></div>
|
||||
</div>
|
||||
<br /><br />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
<a href="#" class="btn-choose-friends button-grey" id="{choose_friends_id}">CHOOSE FRIENDS</a>
|
||||
</div>
|
||||
<div style="margin-right:140px;">
|
||||
Start typing friends' names or:
|
||||
Start typing friends'' names or:
|
||||
</div>
|
||||
<div class="clearall"></div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -137,7 +137,6 @@
|
|||
<%= render "addNewGear" %>
|
||||
<%= render "error" %>
|
||||
<%= render "sessionSettings" %>
|
||||
<%= render :partial => "shareDialog" %>
|
||||
|
||||
<!-- Track Template -->
|
||||
<script type="text/template" id="template-session-track">
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
<%= render "hoverRecording" %>
|
||||
<%= render "hoverSession" %>
|
||||
<%= render "whatsNextDialog" %>
|
||||
<%= render "shareDialog" %>
|
||||
<%= render "recordingFinishedDialog" %>
|
||||
<%= render "localRecordingsDialog" %>
|
||||
<%= render "showServerErrorDialog" %>
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@
|
|||
</div>
|
||||
|
||||
<%= render "clients/invitationDialog" %>
|
||||
<%= render "clients/shareDialog" %>
|
||||
<%= render "users/signupDialog" %>
|
||||
<%= render "users/signinDialog" %>
|
||||
<%= render "clients/notify" %>
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@
|
|||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var showMusicSession = new JK.ShowMusicSession(JK.app);
|
||||
showMusicSession.initialize("<%= @music_session.music_session_id %>");
|
||||
showMusicSession.initialize("<%= @music_session.id %>");
|
||||
})
|
||||
</script>
|
||||
<% end %>
|
||||
|
|
|
|||
Loading…
Reference in New Issue