1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-28 02:37:40 +00:00
Sonarr/UI/Form/FormBuilder.js

51 lines
1.4 KiB
JavaScript
Raw Normal View History

2013-05-22 03:33:35 +00:00
'use strict';
define(
[
'handlebars'
], function (Handlebars) {
2013-05-22 03:33:35 +00:00
var formBuilder = function (field) {
if (!field.type) {
return Handlebars.helpers.partial.apply(field,
[
'Form/TextboxTemplate'
]);
}
if (field.type === 'password') {
return Handlebars.helpers.partial.apply(field,
[
'Form/PasswordTemplate'
]);
}
2013-05-22 03:33:35 +00:00
if (field.type === 'checkbox') {
return Handlebars.helpers.partial.apply(field,
[
'Form/CheckboxTemplate'
]);
}
2013-05-22 03:33:35 +00:00
if (field.type === 'select') {
return Handlebars.helpers.partial.apply(field,
[
'Form/SelectTemplate'
]);
}
2013-05-22 03:33:35 +00:00
return Handlebars.helpers.partial.apply(field,
[
'Form/TextboxTemplate'
]);
};
2013-05-22 03:33:35 +00:00
Handlebars.registerHelper('formBuilder', function () {
var ret = '';
_.each(this.fields, function (field) {
ret += this.FieldBuilder(field);
});
2013-06-13 07:20:33 +00:00
return new Handlebars.SafeString(ret);
});
});