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