diff --git a/UI/Calendar/CalendarItemTemplate.html b/UI/Calendar/CalendarItemTemplate.html index 4a0062894..214584d2f 100644 --- a/UI/Calendar/CalendarItemTemplate.html +++ b/UI/Calendar/CalendarItemTemplate.html @@ -3,7 +3,7 @@

{{day}}

{{month}}

- +

{{series.title}}

{{startTime}} {{bestDateString}}{{seasonNumber}}x{{paddedEpisodeNumber}}
{{episodeTitle}}

diff --git a/UI/MainMenuView.js b/UI/MainMenuView.js index b9ff92f8c..28748dd86 100644 --- a/UI/MainMenuView.js +++ b/UI/MainMenuView.js @@ -24,13 +24,6 @@ define(['app'], function () { } else { this.setActive(event.target); } - - if (href && href.startsWith('http')) { - window.location.href = href; - } else { - NzbDrone.Router.navigate(href, { trigger: true }); - } - }, setActive: function (element) { diff --git a/UI/Mixins/backbone.modelbinder.mixin.js b/UI/Mixins/backbone.modelbinder.mixin.js index e7d28b70e..460756e26 100644 --- a/UI/Mixins/backbone.modelbinder.mixin.js +++ b/UI/Mixins/backbone.modelbinder.mixin.js @@ -21,29 +21,6 @@ Marionette.ItemView.prototype.self$ = function (selector) { return this.$(selector).not("[class*='iv-'] " + selector); }; - -Marionette.ItemView.prototype._handleRelativeLink = function (event) { - console.log('clikc'); - event.preventDefault(); - var $target = $(event.target); - - var href = event.target.getAttribute('href'); - - if (!href && $target.parent('a') && $target.parent('a')[0]) { - - var linkElement = $target.parent('a')[0]; - - href = linkElement.getAttribute('href'); - } - - if (!href) { - throw 'couldnt find route target'; - } - - NzbDrone.Router.navigate(href, { trigger: true }); -}; - - Marionette.ItemView.prototype.render = function () { var result = oldMarionetteItemViewRender.apply(this, arguments); @@ -64,7 +41,6 @@ Marionette.ItemView.prototype.render = function () { this._modelBinder.bind(this.model, this.el); } - this.$('a[href^="/"]').children().click(this._handleRelativeLink); this.$el.addClass('iv-' + this.viewName()); return result; diff --git a/UI/RouteBinder.js b/UI/RouteBinder.js new file mode 100644 index 000000000..7b5b1e108 --- /dev/null +++ b/UI/RouteBinder.js @@ -0,0 +1,44 @@ +"use strict"; +define(['app'], function () { + + //This module will automatically route all links through backbone router rather than + //causing links to reload pages. + + var routeBinder = { + + bind: function () { + $(document).on('click', 'a[href]', this._handleClick); + }, + + _handleClick: function (event) { + var $target = $(event.target); + + if ($target.hasClass('no-router')) { + return; + } + + console.log('click'); + event.preventDefault(); + + var href = event.target.getAttribute('href'); + + if (!href && $target.parent('a') && $target.parent('a')[0]) { + + var linkElement = $target.parent('a')[0]; + + href = linkElement.getAttribute('href'); + } + + if (!href) { + throw 'couldnt find route target'; + } + + + if (!href.startsWith('http')) { + NzbDrone.Router.navigate(href, { trigger: true }); + } + } + }; + + return routeBinder; +}); diff --git a/UI/Routing.js b/UI/Routing.js index 173b41fc8..f45ea2bbe 100644 --- a/UI/Routing.js +++ b/UI/Routing.js @@ -1,5 +1,5 @@ "use strict"; -require(['app', 'Controller'], function (app, controller) { +require(['app', 'Controller', 'RouteBinder'], function (app, controller, routeBinder) { NzbDrone.Router = Backbone.Marionette.AppRouter.extend({ @@ -27,6 +27,7 @@ require(['app', 'Controller'], function (app, controller) { NzbDrone.Router = new NzbDrone.Router(); Backbone.history.start({ pushState: true }); + routeBinder.bind(); }); }); diff --git a/UI/Settings/SettingsLayoutTemplate.html b/UI/Settings/SettingsLayoutTemplate.html index adbbfa740..dadc85908 100644 --- a/UI/Settings/SettingsLayoutTemplate.html +++ b/UI/Settings/SettingsLayoutTemplate.html @@ -1,11 +1,11 @@ 
@@ -18,4 +18,4 @@
Misc Settings
- \ No newline at end of file +