From 19dfd49ad3587964d575f0bad27089ea2a9480a8 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Wed, 10 Apr 2013 21:28:17 -0700 Subject: [PATCH] added view name as class to DOM element for easier debugging. --- UI/Mixins/backbone.modelbinder.mixin.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/UI/Mixins/backbone.modelbinder.mixin.js b/UI/Mixins/backbone.modelbinder.mixin.js index 8d422f91b..fc9bcbf02 100644 --- a/UI/Mixins/backbone.modelbinder.mixin.js +++ b/UI/Mixins/backbone.modelbinder.mixin.js @@ -3,13 +3,27 @@ var oldItemViewRender = Marionette.ItemView.prototype.render; var oldItemCollectionViewRender = Marionette.CollectionView.prototype.render; + +Marionette.View.prototype.viewName = function () { + if (this.template) { + var regex = new RegExp('\/', 'g'); + + return this.template + .toLocaleLowerCase() + .replace('template','') + .replace(regex, '-'); + } + + return undefined; +}; + Marionette.ItemView.prototype.render = function () { if (this.model) { NzbDrone.ModelBinder.bind(this.model, this.el); } - console.log("render"); + this.$el.addClass('iv-' + this.viewName()); return oldItemViewRender.apply(this, arguments); }; @@ -20,7 +34,5 @@ Marionette.CollectionView.prototype.render = function () { NzbDrone.ModelBinder.bind(this.model, this.el); } - console.log("render"); - return oldItemCollectionViewRender.apply(this, arguments); -}; +}; \ No newline at end of file