(function(context,$) { "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(); var hoverSelector = "#recording-hover"; this.showBubble = function() { $(hoverSelector).css({left: position.left-100, top: position.top+20}); $(hoverSelector).fadeIn(500); rest.getClaimedRecording(recordingId) .done(function(response) { var claimedRecording = response; var recording = response.recording; $(hoverSelector).html(''); // musicians var musicianHtml = ''; $.each(recording.recorded_tracks, function(index, val) { var instrumentHtml = ''; var musician = val.user; musicianHtml += ''; musicianHtml += '' + musician.name + ''; instrumentHtml = '
'; instrumentHtml += ' '; instrumentHtml += '
'; musicianHtml += instrumentHtml; musicianHtml += ''; }); var template = $('#template-hover-recording').html(); var creator = recording.band == null ? recording.owner : recording.band; var recordingHtml = context.JK.fillTemplate(template, { recordingId: recording.id, claimedRecordingId: claimedRecording.id, name: claimedRecording.name, genre: claimedRecording.genre_id.toUpperCase(), created_at: context.JK.formatDateTime(recording.created_at), description: response.description, play_count: recording.play_count, comment_count: recording.comment_count, like_count: recording.like_count, creator_avatar_url: recording.band === null ? context.JK.resolveAvatarUrl(creator.photo_url) : context.JK.resolveBandAvatarUrl(creator.photo_url), creator_name: creator.name, location: creator.location, musicians: musicianHtml }); $(hoverSelector).append('

Recording Detail

' + recordingHtml); toggleActionButtons(); }) .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); } }); }; function toggleActionButtons() { if (!context.JK.currentUserId) { $("#btnLike", hoverSelector).hide(); $("#btnShare", hoverSelector).hide(); } } this.hideBubble = function() { $(hoverSelector).hide(); }; this.id = function() { return hoverSelector; }; } })(window,jQuery);