diff --git a/Gruntfile.js b/Gruntfile.js index 36418330a..bcfba4f64 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -76,7 +76,7 @@ module.exports = function (grunt) { handlebars: { options: { - namespace : "Templates", + namespace : "T", partialRegex: /Partial.html/, wrapped : true, amd : true, diff --git a/UI/Mixins/backbone.marionette.templates.js b/UI/Mixins/backbone.marionette.templates.js index d6207dbfb..b5c2a32a5 100644 --- a/UI/Mixins/backbone.marionette.templates.js +++ b/UI/Mixins/backbone.marionette.templates.js @@ -1,26 +1,30 @@ "use strict"; -define(['app', 'marionette', 'handlebars', 'templates'], function (App, Marionette, HandleBars, Templates) { - Marionette.TemplateCache.get = function (templateId) { +define(['templates'], function (Templates) { + return function () { + this.get = function (templateId) { - var templateKey = templateId.toLowerCase(); + var templateKey = templateId.toLowerCase(); - var templateFunction = Templates[templateKey]; + var templateFunction = Templates[templateKey]; - if (!templateFunction) { - throw 'couldn\'t find pre-compiled template ' + templateKey; - } + if (!templateFunction) { + throw 'couldn\'t find pre-compiled template ' + templateKey; + } - return function (data) { + return function (data) { - try { - return templateFunction(data); - } - catch (error) { - console.error('template render failed for ' + templateKey + ' ' + error); - console.error(data); - throw error; - } + try { + return templateFunction(data); + } + catch (error) { + console.error('template render failed for ' + templateKey + ' ' + error); + console.error(data); + throw error; + } + }; }; }; }); + + diff --git a/UI/Mixins/underscore.mixin.deepExtend.js b/UI/Mixins/underscore.mixin.deepExtend.js index 5b6a20f25..6a1d41c1a 100644 --- a/UI/Mixins/underscore.mixin.deepExtend.js +++ b/UI/Mixins/underscore.mixin.deepExtend.js @@ -98,12 +98,15 @@ return finalObj; }; - _.mixin({ - deepClone: deepClone, - isBasicObject: isBasicObject, - basicObjects: basicObjects, - arrays: arrays, - deepExtend: deepExtend + require(['underscore'], function (_) { + + _.mixin({ + deepClone : deepClone, + isBasicObject: isBasicObject, + basicObjects : basicObjects, + arrays : arrays, + deepExtend : deepExtend + }); }); }).call(this); diff --git a/UI/Release/DownloadReportCell.js b/UI/Release/DownloadReportCell.js index 3bf832a14..bb308c2dc 100644 --- a/UI/Release/DownloadReportCell.js +++ b/UI/Release/DownloadReportCell.js @@ -1,6 +1,6 @@ "use strict"; -define(['app'], function () { +define(['app','backgrid'], function () { NzbDrone.Release.DownloadReportCell = Backgrid.Cell.extend({ className: "download-report-cell", diff --git a/UI/Shared/Modal/Region.js b/UI/Shared/Modal/Region.js index b8cd75e7c..d5311902e 100644 --- a/UI/Shared/Modal/Region.js +++ b/UI/Shared/Modal/Region.js @@ -1,6 +1,6 @@ "use strict"; -define(['marionette'], function () { - return Backbone.Marionette.Region.extend({ +define(['marionette', 'bootstrap'], function (Marionette) { + return Marionette.Region.extend({ el: "#modal-region", constructor: function () { diff --git a/UI/app.js b/UI/app.js index 73c4a6a8f..6920b406a 100644 --- a/UI/app.js +++ b/UI/app.js @@ -39,38 +39,33 @@ require.config({ }, 'underscore': { - dep : ['$'], - exports: '_', - init : function () { - require(['mixins/underscore.mixin.deepExtend']); - } + deps : ['$'], + exports: '_' }, backbone: { deps : ['underscore', '$'], - exports: 'Backbone', - init : function () { - require(['libs/backbone.mutators']); - } + exports: 'Backbone' + }, + + 'backbone.deepmodel': { + deps: ['mixins/underscore.mixin.deepExtend'] }, marionette: { - deps : ['backbone'], + deps : ['backbone', 'mixins/backbone.marionette.templates'], exports: 'Marionette', - init : function () { - require(['mixins/backbone.marionette.templates']); + init : function (Backbone, TemplateMixin) { + TemplateMixin.call(Marionette.TemplateCache); } }, signalR: { - dep: ['$'] + deps: ['$'] }, 'backbone.pageable': { - dep : ['backbone'], - init: function () { - console.log(this); - } + deps: ['backbone'] }, backgrid : { @@ -101,6 +96,9 @@ define([ 'Instrumentation/ErrorHandler' ], function (Marionette, ModalRegion) { + require(['libs/backbone.mutators']); + + window.NzbDrone = new Marionette.Application(); window.NzbDrone.Config = {}; window.NzbDrone.Form = {};