diff --git a/admin/app/admin/promo_latest.rb b/admin/app/admin/promo_latest.rb
index f31aa2e46..22ae49575 100644
--- a/admin/app/admin/promo_latest.rb
+++ b/admin/app/admin/promo_latest.rb
@@ -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
diff --git a/web/app/assets/javascripts/hoverRecording.js b/web/app/assets/javascripts/hoverRecording.js
index 687268100..e73fda527 100644
--- a/web/app/assets/javascripts/hoverRecording.js
+++ b/web/app/assets/javascripts/hoverRecording.js
@@ -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('
Recording Detail
' + recordingHtml);
})
.fail(function(xhr) {
diff --git a/web/app/assets/javascripts/hoverSession.js b/web/app/assets/javascripts/hoverSession.js
index ed926c889..055d8cf17 100644
--- a/web/app/assets/javascripts/hoverSession.js
+++ b/web/app/assets/javascripts/hoverSession.js
@@ -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,
diff --git a/web/app/assets/javascripts/shareDialog.js b/web/app/assets/javascripts/shareDialog.js
index 309c17e66..f946460a8 100644
--- a/web/app/assets/javascripts/shareDialog.js
+++ b/web/app/assets/javascripts/shareDialog.js
@@ -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 = $('')
- $(dialogId + ' .content-head').after(spinner);
+ function showSpinner() {
+ $(dialogId + ' .dialog-inner').hide();
+ var spinner = $('')
+ $(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('');
- });
- });
- }
+ 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('');
+ // });
+ // });
+ // }
+ // }
+
+ 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);
diff --git a/web/app/assets/javascripts/utils.js b/web/app/assets/javascripts/utils.js
index f8c630d69..daad31904 100644
--- a/web/app/assets/javascripts/utils.js
+++ b/web/app/assets/javascripts/utils.js
@@ -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() {
diff --git a/web/app/assets/javascripts/web/recordings.js b/web/app/assets/javascripts/web/recordings.js
index 1d4c38c32..e942bcd5f 100644
--- a/web/app/assets/javascripts/web/recordings.js
+++ b/web/app/assets/javascripts/web/recordings.js
@@ -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);
\ No newline at end of file
diff --git a/web/app/assets/javascripts/web/sessions.js b/web/app/assets/javascripts/web/sessions.js
index b0b8b02c3..05e79e7db 100644
--- a/web/app/assets/javascripts/web/sessions.js
+++ b/web/app/assets/javascripts/web/sessions.js
@@ -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);
\ No newline at end of file
diff --git a/web/app/assets/stylesheets/custom.css.scss b/web/app/assets/stylesheets/custom.css.scss
index 974ed3a85..96a023e01 100644
--- a/web/app/assets/stylesheets/custom.css.scss
+++ b/web/app/assets/stylesheets/custom.css.scss
@@ -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;
}
diff --git a/web/app/views/clients/_hoverRecording.html.erb b/web/app/views/clients/_hoverRecording.html.erb
index 22af21705..dab2ecdee 100644
--- a/web/app/views/clients/_hoverRecording.html.erb
+++ b/web/app/views/clients/_hoverRecording.html.erb
@@ -2,6 +2,18 @@
+
+
+
<% end %>