1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00
Radarr/UI/MainMenuView.js

50 lines
1.3 KiB
JavaScript
Raw Normal View History

"use strict";
define(['app'], function () {
NzbDrone.MainMenuView = Backbone.Marionette.ItemView.extend({
events: {
'click a': 'onClick'
},
onClick: function (event) {
event.preventDefault();
var target = $(event.target);
//look down for <a/>
var 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 });
}
},
setActive: function (element) {
2013-04-23 02:35:04 +02:00
//Todo: Set active on first load
this.$('a').removeClass('active');
$(element).addClass('active');
},
initialize: function () {
this.setElement($('#main-menu-region'));
}
});
return new NzbDrone.MainMenuView();
});