1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-26 01:27:00 +00:00

main menu now uses backbone to handle navigation. no more reload.

This commit is contained in:
Keivan Beigi 2013-02-26 19:31:35 -08:00
parent 23c1c147f1
commit 82ae91dd6e
5 changed files with 65 additions and 8 deletions

View file

@ -1,7 +1,7 @@
#main-menu i:before {
#main-menu-region i:before {
font-size: 35px;
}
#main-menu i {
#main-menu-region i {
width: 40px;
}

View file

@ -1,6 +1,6 @@
define(['app', 'Shared/ModalRegion', 'AddSeries/AddSeriesLayout', 'Series/SeriesCollectionView',
'Upcoming/UpcomingCollectionView', 'Calendar/CalendarCollectionView', 'Shared/NotificationView',
'Shared/NotFoundView'], function (app, modalRegion) {
'Shared/NotFoundView', 'MainMenuView'], function (app, modalRegion) {
var controller = Backbone.Marionette.Controller.extend({
@ -43,7 +43,7 @@
}
});
//Modal dialog initializer
NzbDrone.addInitializer(function () {
NzbDrone.addRegions({ modalRegion: modalRegion });

View file

@ -44,7 +44,7 @@
<div class="container">
<div class="row">
<div class="span12">
<ul id="main-menu">
<ul id="main-menu-region">
<li><a href="/"><i class="icon-film"></i>
<br>
Series</a></li>
@ -58,7 +58,7 @@
<li><a href="settings"><i class="icon-cogs"></i>
<br>
Settings</a></li>
<li><a href="system" class="active"><i class="icon-plane"></i>
<li><a href="system"><i class="icon-plane"></i>
<br>
System</a></li>
<li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KRTE52U3XJDSQ" target="_blank"><i class="icon-star"></i>

View file

@ -0,0 +1,56 @@
define(['app'], function () {
NzbDrone.MainMenuView = Backbone.Marionette.ItemView.extend({
ui: {
seriesSearch: '.search input'
},
events: {
'click a': 'onClick'
},
onClick: function (event) {
event.preventDefault();
var target = $(event.target);
var href = undefined;
//look down for <a/>
href = event.target.getAttribute('href');
//if couldn't find it look up
if (!href && target.parent('a') && target.parent('a')[0]) {
var linkElement = target.parent('a')[0];
href = linkElement.getAttribute('href');
this.setActive(linkElement);
} else {
this.setActive(event.target);
}
if (href && href.startsWith('http')) {
window.location.href = href;
} else {
NzbDrone.Router.navigate(href, { trigger: true, replace: true });
}
},
setActive: function (element) {
this.$('a').removeClass('active');
$(element).addClass('active');
},
initialize: function () {
console.log('menue');
this.setElement($('#main-menu-region'));
}
});
return new NzbDrone.MainMenuView();
});

View file

@ -29,6 +29,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Content Include="MainMenuView.js" />
<Content Include="AddSeries\addSeries.css" />
<Content Include="AddSeries\AddSeriesLayout.js" />
<Content Include="AddSeries\addSeriesLayoutTemplate.html" />