(function(context,$) {
"use strict";
context.JK = context.JK || {};
context.JK.BandHoverBubble = function(bandId, position) {
var logger = context.JK.logger;
var rest = context.JK.Rest();
var instrumentLogoMap = context.JK.getInstrumentIconMap24();
var hoverSelector = "#band-hover";
this.showBubble = function() {
$(hoverSelector).css({left: position.left-100, top: position.top});
$(hoverSelector).fadeIn(500);
rest.getBand(bandId)
.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-band').html();
if (response.biography == null) {
response.biography = 'No Biography Available';
}
var genres = [];
genres = $.map(response.genres, function(n, i) {
return n.description;
});
var bandHtml = context.JK.fillTemplate(template, {
avatar_url: context.JK.resolveBandAvatarUrl(response.photo_url),
name: response.name,
location: response.location,
genres: genres.join(', '),
musicians: musicianHtml,
like_count: response.liker_count,
follower_count: response.follower_count,
recording_count: response.recording_count,
session_count: response.session_count,
biography: response.biography,
profile_url: "/client#/bandProfile/" + response.id
});
$(hoverSelector).append('Band Detail
' + bandHtml);
})
.fail(function(xhr) {
if(xhr.status >= 500) {
context.JK.fetchUserNetworkOrServerFailure();
}
else if(xhr.status == 404) {
context.JK.entityNotFound("Band");
}
else {
context.JK.app.ajaxError(arguments);
}
});
};
this.hideBubble = function() {
$(hoverSelector).hide();
};
this.id = function() {
return hoverSelector;
};
}
})(window,jQuery);