From 2e3863895c86f3f03b37715a64386606204d2bc5 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Mon, 3 Jun 2013 20:34:06 -0700 Subject: [PATCH] internal links are automatically handled using NzbDrone.Router.navigate instead of re-loading page. --- UI/Content/base.less | 4 +++- UI/Content/theme.less | 3 ++- UI/Mixins/backbone.modelbinder.mixin.js | 31 +++++++++++++++++++++---- UI/Series/Index/List/ItemView.js | 7 ------ 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/UI/Content/base.less b/UI/Content/base.less index 734d76987..7fc5b7aa1 100644 --- a/UI/Content/base.less +++ b/UI/Content/base.less @@ -1,4 +1,6 @@ -@import "bootstrap/bootstrap"; +@import "bootstrap/variables"; +@import "bootstrap/mixins"; +@import "bootstrap/type"; .progress { width: 125px; diff --git a/UI/Content/theme.less b/UI/Content/theme.less index 09af6eafb..2b9f88557 100644 --- a/UI/Content/theme.less +++ b/UI/Content/theme.less @@ -119,8 +119,9 @@ } body { - background-color: #252525; + background-color: #1c1c1c; background-image: url('../content/images/pattern.png'); + margin-bottom: 100px; p.sub { color: #999999; } diff --git a/UI/Mixins/backbone.modelbinder.mixin.js b/UI/Mixins/backbone.modelbinder.mixin.js index 08f30dd9f..e7d28b70e 100644 --- a/UI/Mixins/backbone.modelbinder.mixin.js +++ b/UI/Mixins/backbone.modelbinder.mixin.js @@ -1,6 +1,6 @@ 'use strict'; -var oldItemViewRender = Marionette.ItemView.prototype.render; +var oldMarionetteItemViewRender = Marionette.ItemView.prototype.render; var oldItemCollectionViewRender = Marionette.CollectionView.prototype.render; @@ -21,9 +21,32 @@ 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 = oldItemViewRender.apply(this, arguments); + var result = oldMarionetteItemViewRender.apply(this, arguments); this.$el.removeClass('iv-' + this.viewName()); @@ -38,13 +61,11 @@ Marionette.ItemView.prototype.render = function () { this._modelBinder = new Backbone.ModelBinder(); } - window.console.log('binding ' + this.viewName()); - 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/Series/Index/List/ItemView.js b/UI/Series/Index/List/ItemView.js index 24f93743d..c3a3bd019 100644 --- a/UI/Series/Index/List/ItemView.js +++ b/UI/Series/Index/List/ItemView.js @@ -19,7 +19,6 @@ define([ events: { 'click .x-edit' : 'editSeries', 'click .x-remove': 'removeSeries', - 'click a' : 'showEpisodeList' }, initialize: function (options) { @@ -34,12 +33,6 @@ define([ removeSeries: function () { var view = new NzbDrone.Series.Delete.DeleteSeriesView({ model: this.model }); NzbDrone.modalRegion.show(view); - }, - - showEpisodeList: function (e) { - e.preventDefault(); - NzbDrone.Router.navigate('/series/details/' + this.model.get('id'), { trigger: true}); - } }); });