diff --git a/web/app/assets/javascripts/hoverRecording.js b/web/app/assets/javascripts/hoverRecording.js index 68718743c..46f7d05bd 100644 --- a/web/app/assets/javascripts/hoverRecording.js +++ b/web/app/assets/javascripts/hoverRecording.js @@ -1,14 +1,72 @@ (function(context,$) { - "use strict"; - context.JK = context.JK || {}; - context.JK.RecordingHoverBubble = function(app) { + "use strict"; + context.JK = context.JK || {}; + context.JK.RecordingHoverBubble = function(recordingId, position) { - function initialize() { + var logger = context.JK.logger; + var rest = context.JK.Rest(); + var instrumentLogoMap = context.JK.getInstrumentIconMap24(); + var hoverSelector = "#recording-hover"; - } - - this.initialize = initialize; - this.showBubble = showBubble; - } + this.showBubble = function() { + $(hoverSelector).css({left: position.left-100, top: position.top}); + $(hoverSelector).fadeIn(500); + + rest.getClaimedRecording(recordingId) + .done(function(response) { + $(hoverSelector).html(''); + + // musicians + var musicianHtml = ''; + $.each(response.musicians, function(index, val) { + var instrumentHtml = ''; + + musicianHtml += ''; + musicianHtml += '' + val.name + ''; + + instrumentHtml = '
'; + $.each(val.instruments, function(index, instrument) { + instrumentHtml += ' '; + }); + + instrumentHtml += '
'; + + musicianHtml += instrumentHtml; + musicianHtml += ''; + }); + + var template = $('#template-hover-recording').html(); + + var recordingHtml = context.JK.fillTemplate(template, { + avatar_url: context.JK.resolveAvatarUrl(response.photo_url), + name: response.name, + location: response.location, + friend_count: response.friend_count, + follower_count: response.follower_count + }); + + $(hoverSelector).append('

Recording Detail

' + recordingHtml); + }) + .fail(function(xhr) { + if(xhr.status >= 500) { + context.JK.fetchUserNetworkOrServerFailure(); + } + else if(xhr.status == 404) { + context.JK.entityNotFound("Recording"); + } + else { + context.JK.app.ajaxError(arguments); + } + }); + }; + + this.hideBubble = function() { + $(hoverSelector).hide(); + }; + + this.id = function() { + return hoverSelector; + }; + } })(window,jQuery); \ No newline at end of file diff --git a/web/app/assets/javascripts/hoverSession.js b/web/app/assets/javascripts/hoverSession.js index 7bfe105cf..e09845841 100644 --- a/web/app/assets/javascripts/hoverSession.js +++ b/web/app/assets/javascripts/hoverSession.js @@ -1,14 +1,67 @@ (function(context,$) { - "use strict"; - context.JK = context.JK || {}; - context.JK.SessionHoverBubble = function(app) { + "use strict"; + context.JK = context.JK || {}; + context.JK.SessionHoverBubble = function(sessionId, position) { - function initialize() { + var logger = context.JK.logger; + var rest = context.JK.Rest(); + var instrumentLogoMap = context.JK.getInstrumentIconMap24(); + var hoverSelector = "#session-hover"; - } - - this.initialize = initialize; - this.showBubble = showBubble; - } + this.showBubble = function() { + $(hoverSelector).css({left: position.left-100, top: position.top}); + $(hoverSelector).fadeIn(500); + + rest.getSessionHistory(sessionId) + .done(function(response) { + $(hoverSelector).html(''); + + // musicians + var musicianHtml = ''; + $.each(response.users, function(index, val) { + var instrumentHtml = ''; + + musicianHtml += ''; + musicianHtml += '' + val.name + ''; + + instrumentHtml = '
'; + $.each(val.instruments, function(index, instrument) { + instrumentHtml += ' '; + }); + + instrumentHtml += '
'; + + musicianHtml += instrumentHtml; + musicianHtml += ''; + }); + + var template = $('#template-hover-session').html(); + + var sessionHtml = context.JK.fillTemplate(template, { + }); + + $(hoverSelector).append('

Session Detail

' + sessionHtml); + }) + .fail(function(xhr) { + if(xhr.status >= 500) { + context.JK.fetchUserNetworkOrServerFailure(); + } + else if(xhr.status == 404) { + context.JK.entityNotFound("Session"); + } + else { + context.JK.app.ajaxError(arguments); + } + }); + }; + + this.hideBubble = function() { + $(hoverSelector).hide(); + }; + + this.id = function() { + return hoverSelector; + }; + } })(window,jQuery); \ No newline at end of file diff --git a/web/app/views/api_music_sessions/history_show.rabl b/web/app/views/api_music_sessions/history_show.rabl index 7296aca8f..9d3ea1c81 100644 --- a/web/app/views/api_music_sessions/history_show.rabl +++ b/web/app/views/api_music_sessions/history_show.rabl @@ -1,6 +1,6 @@ object @history -attributes :music_session_id, :description, :genres +attributes :music_session_id, :description, :genres, :created_at node :share_url do |history| unless history.share_token.nil? diff --git a/web/app/views/clients/_hoverRecording.html.erb b/web/app/views/clients/_hoverRecording.html.erb index 12627f1b1..a6c2415ec 100644 --- a/web/app/views/clients/_hoverRecording.html.erb +++ b/web/app/views/clients/_hoverRecording.html.erb @@ -1,55 +1,36 @@ - -