110 lines
3.9 KiB
JavaScript
110 lines
3.9 KiB
JavaScript
var Pages;
|
|
Pages = (function() {
|
|
function Pages() {}
|
|
Pages.prototype.renderArtist = function(data) {
|
|
var albums_info, artist_info;
|
|
artist_info = $('\
|
|
<div class="artist-info">\
|
|
<div class="pic">\
|
|
<img src="' + data.artist.pic + '" alt="' + data.artist.name + '" width="250" />\
|
|
</div>\
|
|
<h1 class="name" data-id="' + data.artist.id + '">' + data.artist.name + '</h1>\
|
|
<div class="info">\
|
|
' + data.artist.desc + '\
|
|
</div>\
|
|
</div>');
|
|
albums_info = $('<div class="albums"></div>');
|
|
$.each(data.albums, function(i, album) {
|
|
var album_info;
|
|
if (album.year != null) {
|
|
album_info = $('\
|
|
<div class="album">\
|
|
<h2 class="name" data-id="' + album.id + '">' + album.name + ' (' + album.year + ')</h2>\
|
|
<div class="pic">\
|
|
<img src="' + (album.pic ? album.pic : '/images/kitteh.png') + '" alt="' + album.name + ' by ' + data.artist.name + '" width="250" height="250"/>\
|
|
<div class="add-album-button-container">\
|
|
<div class="add-album button gray">' + _beathaven.ls('ADD_TO_NOW_PLAYING') + '</div>\
|
|
</div>\
|
|
</div>\
|
|
<div class="tracklist"><ul></ul></div>\
|
|
</div>\
|
|
<div class="kaboom"></div>');
|
|
$.each(album.tracks.album, function(i, track) {
|
|
var track_info;
|
|
track_info = $('\
|
|
<li data-id="' + track.id + '">\
|
|
<div class="add-track button gray">+</div>\
|
|
<div class="track-container">\
|
|
<div class="fade"></div>\
|
|
<span class="index">' + (i + 1) + '</span>\
|
|
<div class="trackname" title="' + track.name.htmlsafe() + '">' + track.name + '</div>\
|
|
<div class="length">' + track.duration + '</div>\
|
|
</div>\
|
|
</li>');
|
|
return $(album_info).find('.tracklist ul').append(track_info);
|
|
});
|
|
return $(albums_info).append(album_info);
|
|
}
|
|
});
|
|
$('.data-container').css({
|
|
backgroundImage: 'none'
|
|
});
|
|
$('.data-container .inner').html('').append(artist_info).append(albums_info);
|
|
yaCounter7596904.hit(_ajax.getAnchor(), data.artist.name, _ajax.referer);
|
|
_ajax.setTitle(data.artist.name);
|
|
_beathaven.redrawScrollbar();
|
|
return false;
|
|
};
|
|
Pages.prototype.renderSearch = function(data) {
|
|
$('.data-container').css({
|
|
background: 'url(/images/concrete_wall_2.png) 0 -30px repeat'
|
|
});
|
|
$('.data-container .inner').html(data);
|
|
$('.search-container').css('marginLeft', ($('.data-container').width() - 425) / 2 + 'px').css('marginTop', ($('.data-container').height() / 2 - 230) + 'px').height(($('.data-container').height() - $('#search_form').height()) / 2);
|
|
setTimeout(function() {
|
|
$('#search_field').bh_autocomplete({
|
|
serviceUrl: '/artist/autocomplete',
|
|
minChars: 2,
|
|
delimiter: /(,|;)\s*/,
|
|
maxHeight: 400,
|
|
width: 415,
|
|
zIndex: 9999,
|
|
deferRequestBy: 500,
|
|
onSelect: function() {
|
|
return _ajax.loadArtistData($('#search_field').val());
|
|
}
|
|
});
|
|
return $('#search_field').focus();
|
|
}, 501);
|
|
yaCounter7596904.hit(_ajax.getAnchor(), 'Artist Search', _ajax.referer);
|
|
_ajax.setTitle('Artist Search');
|
|
return false;
|
|
};
|
|
Pages.prototype.renderSettings = function(data) {
|
|
if (_session.getUser().id == null) {
|
|
_ajax.go('/search/');
|
|
return false;
|
|
}
|
|
$('.data-container').css({
|
|
background: 'none'
|
|
});
|
|
$('.data-container .inner').html(data);
|
|
yaCounter7596904.hit(_ajax.getAnchor(), 'Settings', _ajax.referer);
|
|
_ajax.setTitle('Settings');
|
|
$('.settings-container .tabs .tab').first().trigger('click');
|
|
return false;
|
|
};
|
|
Pages.prototype.renderTextpage = function(data) {
|
|
$('.data-container').css({
|
|
background: 'url(/images/concrete_wall_2.png) 0 -30px repeat'
|
|
});
|
|
$('.data-container .inner').html(data);
|
|
_beathaven.redrawScrollbar();
|
|
return false;
|
|
};
|
|
return Pages;
|
|
})();
|
|
$('.about').live('click', function() {
|
|
_ajax.go('/about/');
|
|
return false;
|
|
}); |