1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/UI/Form/FormBuilder.js
kay.one 769331d45d updated jshint to 2.1.3
single quotes
2013-06-21 23:24:24 -07:00

32 lines
1005 B
JavaScript

'use strict';
define(['app', 'handlebars'], function (App,Handlebars) {
Handlebars.registerHelper('formBuilder', function () {
var ret = '';
_.each(this.fields, function (field) {
ret += NzbDrone.Form.FieldBuilder(field);
});
return new Handlebars.SafeString(ret);
});
NzbDrone.Form.FieldBuilder = 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']);
}
if (field.type === 'checkbox') {
return Handlebars.helpers.partial.apply(field, ['Form/CheckboxTemplate']);
}
if (field.type === 'select') {
return Handlebars.helpers.partial.apply(field, ['Form/SelectTemplate']);
}
return Handlebars.helpers.partial.apply(field, ['Form/TextboxTemplate']);
};
});