2013-05-22 05:33:35 +02:00
|
|
|
'use strict';
|
2013-06-15 01:36:59 +02:00
|
|
|
define(['app', 'handlebars'], function (App,Handlebars) {
|
|
|
|
Handlebars.registerHelper('formBuilder', function () {
|
2013-06-22 08:24:24 +02:00
|
|
|
var ret = '';
|
2013-06-15 01:36:59 +02:00
|
|
|
_.each(this.fields, function (field) {
|
2013-05-22 05:33:35 +02:00
|
|
|
ret += NzbDrone.Form.FieldBuilder(field);
|
|
|
|
});
|
|
|
|
|
|
|
|
return new Handlebars.SafeString(ret);
|
|
|
|
});
|
|
|
|
|
2013-06-15 01:36:59 +02:00
|
|
|
NzbDrone.Form.FieldBuilder = function (field) {
|
2013-05-22 05:33:35 +02: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 09:20:33 +02:00
|
|
|
if (field.type === 'select') {
|
|
|
|
return Handlebars.helpers.partial.apply(field, ['Form/SelectTemplate']);
|
|
|
|
}
|
|
|
|
|
2013-05-22 05:33:35 +02:00
|
|
|
return Handlebars.helpers.partial.apply(field, ['Form/TextboxTemplate']);
|
|
|
|
};
|
|
|
|
});
|