1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 10:32:35 +01:00
Radarr/UI/MainMenuView.js

43 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
define(['marionette'], function (Marionette) {
var MainMenuView = 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);
}
},
setActive: function (element) {
//Todo: Set active on first load
this.$('a').removeClass('active');
$(element).addClass('active');
},
initialize: function () {
this.setElement($('#main-menu-region'));
}
});
return new MainMenuView();
});