mirror of https://github.com/lidarr/Lidarr
handlebars and templates are loaded with require.js
This commit is contained in:
parent
2407e33ea2
commit
7c483e2db9
|
@ -76,9 +76,10 @@ module.exports = function (grunt) {
|
||||||
|
|
||||||
handlebars: {
|
handlebars: {
|
||||||
options: {
|
options: {
|
||||||
namespace : "Templates",
|
namespace : "Templates",
|
||||||
partialRegex: /Partial.html/,
|
partialRegex: /Partial.html/,
|
||||||
wrapped : true,
|
wrapped : true,
|
||||||
|
amd : true,
|
||||||
processName: function (fileName) {
|
processName: function (fileName) {
|
||||||
return fileName
|
return fileName
|
||||||
.replace('UI/', '')
|
.replace('UI/', '')
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define(['app', 'AddSeries/RootFolders/RootFolderCollection'], function (app, rootFolders) {
|
define(['app', 'AddSeries/RootFolders/RootFolderCollection','handlebars'], function (app, rootFolders, Handlebars) {
|
||||||
|
|
||||||
Handlebars.registerHelper('rootFolderSelection', function () {
|
Handlebars.registerHelper('rootFolderSelection', function () {
|
||||||
//TODO: We should be able to pass in the context, either an object or a property
|
//TODO: We should be able to pass in the context, either an object or a property
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
define(['app'], function () {
|
define(['app', 'handlebars'], function (App,Handlebars) {
|
||||||
Handlebars.registerHelper('formBuilder', function (){
|
Handlebars.registerHelper('formBuilder', function () {
|
||||||
var ret = "";
|
var ret = "";
|
||||||
_.each(this.fields, function(field){
|
_.each(this.fields, function (field) {
|
||||||
ret += NzbDrone.Form.FieldBuilder(field);
|
ret += NzbDrone.Form.FieldBuilder(field);
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Handlebars.SafeString(ret);
|
return new Handlebars.SafeString(ret);
|
||||||
});
|
});
|
||||||
|
|
||||||
NzbDrone.Form.FieldBuilder = function(field) {
|
NzbDrone.Form.FieldBuilder = function (field) {
|
||||||
if (!field.type) {
|
if (!field.type) {
|
||||||
return Handlebars.helpers.partial.apply(field, ['Form/TextboxTemplate']);
|
return Handlebars.helpers.partial.apply(field, ['Form/TextboxTemplate']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,12 +78,8 @@
|
||||||
</body>
|
</body>
|
||||||
<script src="/JsLibraries/jquery.js"></script>
|
<script src="/JsLibraries/jquery.js"></script>
|
||||||
<script src="/JsLibraries/messenger.js"></script>
|
<script src="/JsLibraries/messenger.js"></script>
|
||||||
<script src="/JsLibraries/handlebars.runtime.js"></script>
|
|
||||||
<script src="/JsLibraries/lunr.js"></script>
|
<script src="/JsLibraries/lunr.js"></script>
|
||||||
<!--<script src="/JsLibraries/backbone.backgrid.js"></script>
|
|
||||||
<script src="/JsLibraries/backbone.backgrid.filter.js"></script>-->
|
|
||||||
<script src="/JsLibraries/sugar.js"></script>
|
<script src="/JsLibraries/sugar.js"></script>
|
||||||
<script src="/templates.js"></script>
|
|
||||||
<script data-main="/app" src="/JsLibraries/require.js"></script>
|
<script data-main="/app" src="/JsLibraries/require.js"></script>
|
||||||
<script src="/Routing.js"></script>
|
<script src="/Routing.js"></script>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
define(['app', 'marionette'], function (App, Marionette) {
|
define(['app', 'marionette', 'handlebars', 'templates'], function (App, Marionette, HandleBars, Templates) {
|
||||||
Marionette.TemplateCache.get = function (templateId) {
|
Marionette.TemplateCache.get = function (templateId) {
|
||||||
|
|
||||||
var templateKey = templateId.toLowerCase();
|
var templateKey = templateId.toLowerCase();
|
||||||
|
|
||||||
var templateFunction = window.Templates[templateKey];
|
var templateFunction = Templates[templateKey];
|
||||||
|
|
||||||
if (!templateFunction) {
|
if (!templateFunction) {
|
||||||
throw 'couldn\'t find pre-compiled template ' + templateKey;
|
throw 'couldn\'t find pre-compiled template ' + templateKey;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define(['app', 'Quality/QualityProfileCollection'], function (app, qualityProfiles) {
|
define(['app', 'Quality/QualityProfileCollection','handlebars'], function (app, qualityProfiles,Handlebars) {
|
||||||
|
|
||||||
Handlebars.registerHelper('qualityProfileSelection', function () {
|
Handlebars.registerHelper('qualityProfileSelection', function () {
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
define(['app'], function () {
|
define(['app','handlebars'], function (App,Handlebars) {
|
||||||
Handlebars.registerHelper('partial', function (templateName) {
|
Handlebars.registerHelper('partial', function (templateName) {
|
||||||
//TODO: We should be able to pass in the context, either an object or a property
|
//TODO: We should be able to pass in the context, either an object or a property
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ require.config({
|
||||||
|
|
||||||
paths: {
|
paths: {
|
||||||
'backbone' : 'JsLibraries/backbone',
|
'backbone' : 'JsLibraries/backbone',
|
||||||
|
'handlebars' : 'JsLibraries/handlebars.runtime',
|
||||||
'bootstrap' : 'JsLibraries/bootstrap',
|
'bootstrap' : 'JsLibraries/bootstrap',
|
||||||
'bootstrap.slider' : 'JsLibraries/bootstrap.slider',
|
'bootstrap.slider' : 'JsLibraries/bootstrap.slider',
|
||||||
'backbone.mutators' : 'JsLibraries/backbone.mutators',
|
'backbone.mutators' : 'JsLibraries/backbone.mutators',
|
||||||
|
@ -15,7 +16,6 @@ require.config({
|
||||||
'$' : 'JsLibraries/jquery',
|
'$' : 'JsLibraries/jquery',
|
||||||
'underscore' : 'JsLibraries/underscore',
|
'underscore' : 'JsLibraries/underscore',
|
||||||
'marionette' : 'JsLibraries/backbone.marionette',
|
'marionette' : 'JsLibraries/backbone.marionette',
|
||||||
'handlebars' : 'JsLibraries/handlebars',
|
|
||||||
'signalR' : 'JsLibraries/jquery.signalR',
|
'signalR' : 'JsLibraries/jquery.signalR',
|
||||||
'libs' : 'JsLibraries/'
|
'libs' : 'JsLibraries/'
|
||||||
},
|
},
|
||||||
|
@ -62,10 +62,6 @@ require.config({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
handlebars: {
|
|
||||||
exports: 'Handlebars'
|
|
||||||
},
|
|
||||||
|
|
||||||
signalR: {
|
signalR: {
|
||||||
dep: ['$']
|
dep: ['$']
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue