You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Radarr/UI/Form/FormBuilder.js

56 lines
1.5 KiB

'use strict';
define(
[
'handlebars'
], function (Handlebars) {
12 years ago
var _fieldBuilder = function (field) {
if (!field.type) {
12 years ago
return _templateRenderer.apply(field,
[
'Form/TextboxTemplate'
]);
}
if (field.type === 'password') {
12 years ago
return _templateRenderer.apply(field,
[
'Form/PasswordTemplate'
]);
}
if (field.type === 'checkbox') {
12 years ago
return _templateRenderer.apply(field,
[
'Form/CheckboxTemplate'
]);
}
if (field.type === 'select') {
12 years ago
return _templateRenderer.apply(field,
[
'Form/SelectTemplate'
]);
}
12 years ago
return _templateRenderer.apply(field,
[
'Form/TextboxTemplate'
]);
};
12 years ago
var _templateRenderer = function (templateName) {
var templateFunction = Marionette.TemplateCache.get(templateName);
return new Handlebars.SafeString(templateFunction(this));
};
Handlebars.registerHelper('formBuilder', function () {
var ret = '';
_.each(this.fields, function (field) {
12 years ago
ret += _fieldBuilder(field);
});
return new Handlebars.SafeString(ret);
});
});