summaryrefslogtreecommitdiffstats
path: root/pyload/web/app/scripts/views/input
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/web/app/scripts/views/input')
-rw-r--r--pyload/web/app/scripts/views/input/inputRenderer.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/pyload/web/app/scripts/views/input/inputRenderer.js b/pyload/web/app/scripts/views/input/inputRenderer.js
new file mode 100644
index 000000000..c20f15708
--- /dev/null
+++ b/pyload/web/app/scripts/views/input/inputRenderer.js
@@ -0,0 +1,22 @@
+define(['jquery', 'underscore', './inputLoader'], function($, _, load_input) {
+ 'use strict';
+
+ // Renders list of ConfigItems to an container
+ // Optionally binds change event to view
+ return function(container, items, template, onChange, view) {
+ _.each(items, function(item) {
+ var json = item.toJSON();
+ var el = $('<div>').html(template(json));
+ var InputView = load_input(item.get('input'));
+ var input = new InputView(json).render();
+ item.set('inputView', input);
+
+ if (_.isFunction(onChange) && view) {
+ view.listenTo(input, 'change', onChange);
+ }
+
+ el.find('.controls').append(input.el);
+ container.append(el);
+ });
+ };
+}); \ No newline at end of file