mirror of
https://github.com/fergalmoran/dss.git
synced 2025-12-30 13:39:05 +00:00
101 lines
3.7 KiB
JavaScript
101 lines
3.7 KiB
JavaScript
var AppRouter = Backbone.Router.extend({
|
|
routes:{
|
|
"":"defaultRoute",
|
|
"/mixes":"mixList",
|
|
"/mixes/:type":"mixList",
|
|
"/mix/:id":"mixDetails",
|
|
"/releases":"releaseList",
|
|
"/release/:id":"releaseDetails",
|
|
"/accounts/login/":"login",
|
|
"/accounts/logout/":"logout"
|
|
},
|
|
initialize:function () {
|
|
this.headerView = new HeaderView();
|
|
$('#header').html(this.headerView.el);
|
|
$('#site-content-fill').html('');
|
|
},
|
|
defaultRoute:function (path) {
|
|
if (!path)
|
|
this.mixList('latest');
|
|
else if (path == "" || path == "/")
|
|
this.mixList('latest');
|
|
},
|
|
mixList:function (type) {
|
|
var mixList = new MixCollection();
|
|
mixList.type = type || 'latest';
|
|
$('#site-content-fill').html('');
|
|
//this.sidebarView = new SidebarView();
|
|
//$('#sidebar').html(this.sidebarView.el);
|
|
var data = type != undefined ? $.param({sort:type}) : null;
|
|
mixList.fetch({
|
|
data:data,
|
|
success:function () {
|
|
var content = new MixListView({collection:mixList}).el;
|
|
$('#content').html(content);
|
|
}
|
|
});
|
|
},
|
|
mixDetails:function (id) {
|
|
var mix = new Mix({id:id});
|
|
mix.fetch({success:function () {
|
|
var html = new MixView({model:mix});
|
|
$('#content').html(html.el);
|
|
$('#site-content-fill').html('');
|
|
var comments = new CommentCollection();
|
|
comments.url = window.appSettings.urlRoot + mix.attributes.item_url + "/comments/";
|
|
comments.mix_id = id;
|
|
comments.mix = mix.get("resource_uri");
|
|
comments.fetch({success:function (data) {
|
|
var content = new CommentListView({collection:comments}).render();
|
|
$('#site-content-fill').html(content.el);
|
|
}});
|
|
}});
|
|
},
|
|
releaseList:function (page) {
|
|
var releaseList = new ReleaseCollection();
|
|
releaseList.fetch({
|
|
success:function () {
|
|
var content = new ReleaseListView({collection:releaseList}).el;
|
|
$('#content').html(content);
|
|
}
|
|
});
|
|
},
|
|
releaseDetails:function (id) {
|
|
var release = new Release({id:id});
|
|
$('#site-content-fill').html('');
|
|
release.fetch({success:function () {
|
|
var content = new ReleaseView({model:release}).el;
|
|
$('#content').html(content);
|
|
var audio = new ReleaseAudioCollection();
|
|
audio.url = window.appSettings.urlRoot + release.attributes.item_url + "/release_audio/";
|
|
audio.audio_id = id;
|
|
audio.release = release.get("resource_uri");
|
|
audio.fetch({success:function (data) {
|
|
var content = new ReleaseAudioListView({collection:audio});
|
|
$('#release-description').html(content.el);
|
|
}});
|
|
}});
|
|
},
|
|
login:function () {
|
|
$.colorbox({
|
|
href:"/tpl/LoginView/",
|
|
onClosed:function () {
|
|
app.navigate('/');
|
|
}
|
|
})
|
|
},
|
|
logout:function () {
|
|
window.utils.showAlert("Success", "You are now logged out", "alert-success");
|
|
}
|
|
});
|
|
|
|
utils.loadTemplate([
|
|
'HeaderView', 'SidebarView',
|
|
'MixListView', 'MixItemView', 'MixView',
|
|
'CommentListView', 'CommentItemView',
|
|
'ReleaseListView', 'ReleaseListItemView', 'ReleaseItemView', 'ReleaseView', 'ReleaseAudioListView', 'ReleaseAudioItemView'], function () {
|
|
window.app = new AppRouter();
|
|
Backbone.history.start();
|
|
});
|
|
var _eventAggregator = _.extend({}, Backbone.Events);
|