1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2025-07-15 01:25:05 +02:00
Files
Sonarr/UI/Form/FormBuilder.js

32 lines
1005 B
JavaScript
Raw Normal View History

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