fixed more require issues

This commit is contained in:
kay.one 2013-06-14 22:28:35 -07:00
parent d1c279d3cd
commit 0ae1865dd8
6 changed files with 49 additions and 44 deletions

View File

@ -76,7 +76,7 @@ module.exports = function (grunt) {
handlebars: {
options: {
namespace : "Templates",
namespace : "T",
partialRegex: /Partial.html/,
wrapped : true,
amd : true,

View File

@ -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;
}
return function (data) {
try {
return templateFunction(data);
}
catch (error) {
console.error('template render failed for ' + templateKey + ' ' + error);
console.error(data);
throw error;
if (!templateFunction) {
throw 'couldn\'t find pre-compiled template ' + templateKey;
}
return function (data) {
try {
return templateFunction(data);
}
catch (error) {
console.error('template render failed for ' + templateKey + ' ' + error);
console.error(data);
throw error;
}
};
};
};
});

View File

@ -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);

View File

@ -1,6 +1,6 @@
"use strict";
define(['app'], function () {
define(['app','backgrid'], function () {
NzbDrone.Release.DownloadReportCell = Backgrid.Cell.extend({
className: "download-report-cell",

View File

@ -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 () {

View File

@ -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 = {};