From bc037e7319a7d39a676b30429085d1b431329804 Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Tue, 3 Feb 2015 15:33:13 -0800 Subject: [PATCH] don't add named views in production --- src/UI/Mixins/AsNamedView.js | 17 +++++++++++------ src/UI/Series/Details/SeriesDetailsLayout.js | 10 +++++----- src/UI/Shims/backbone.marionette.js | 5 ++++- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/UI/Mixins/AsNamedView.js b/src/UI/Mixins/AsNamedView.js index 9ecf841fc..90c5ea0b4 100644 --- a/src/UI/Mixins/AsNamedView.js +++ b/src/UI/Mixins/AsNamedView.js @@ -1,19 +1,24 @@ module.exports = function(){ - this.viewName = function(){ - if(this.template) { - var regex = new RegExp('/', 'g'); - return this.template.toLocaleLowerCase().replace('template', '').replace(regex, '-'); + + var regex = new RegExp('/', 'g'); + + var _getViewName = function(template){ + if(template) { + return template.toLocaleLowerCase().replace('template', '').replace(regex, '-'); } return undefined; }; + var originalOnRender = this.onRender; this.onRender = function(){ - this.$el.removeClass('iv-' + this.viewName()); - this.$el.addClass('iv-' + this.viewName()); + this.$el.addClass('iv-' + _getViewName(this.template)); + if(originalOnRender) { return originalOnRender.call(this); } + return undefined; }; + return this; }; \ No newline at end of file diff --git a/src/UI/Series/Details/SeriesDetailsLayout.js b/src/UI/Series/Details/SeriesDetailsLayout.js index 2acd1941a..ebd299689 100644 --- a/src/UI/Series/Details/SeriesDetailsLayout.js +++ b/src/UI/Series/Details/SeriesDetailsLayout.js @@ -31,11 +31,11 @@ module.exports = Marionette.Layout.extend({ search : '.x-search' }, events : { - "click .x-monitored" : '_toggleMonitored', - "click .x-edit" : '_editSeries', - "click .x-refresh" : '_refreshSeries', - "click .x-rename" : '_renameSeries', - "click .x-search" : '_seriesSearch' + 'click .x-monitored' : '_toggleMonitored', + 'click .x-edit' : '_editSeries', + 'click .x-refresh' : '_refreshSeries', + 'click .x-rename' : '_renameSeries', + 'click .x-search' : '_seriesSearch' }, initialize : function(){ this.seriesCollection = SeriesCollection.clone(); diff --git a/src/UI/Shims/backbone.marionette.js b/src/UI/Shims/backbone.marionette.js index 8d072ee7b..56eff9681 100644 --- a/src/UI/Shims/backbone.marionette.js +++ b/src/UI/Shims/backbone.marionette.js @@ -7,6 +7,9 @@ var templateMixin = require('../Handlebars/backbone.marionette.templates'); var asNamedView = require('../Mixins/AsNamedView'); templateMixin.call(window.Marionette.TemplateCache); -asNamedView.call(window.Marionette.ItemView.prototype); + +if(!window.NzbDrone.Production) { + asNamedView.call(window.Marionette.ItemView.prototype); +} module.exports = window.Marionette; \ No newline at end of file