summaryrefslogtreecommitdiffstats
path: root/module/web/static/js/views/input
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-24 21:27:43 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-24 21:27:43 +0100
commit7b4c75f0dd755e28fcffc0e4fdd05452458a3b09 (patch)
tree43ef5fe76ff5ff235cc52b79f16b9a8b6047bca8 /module/web/static/js/views/input
parentMerge remote-tracking branch 'origin/stable' (diff)
downloadpyload-7b4c75f0dd755e28fcffc0e4fdd05452458a3b09.tar.xz
added view type for input fields
Diffstat (limited to 'module/web/static/js/views/input')
-rw-r--r--module/web/static/js/views/input/inputLoader.js7
-rw-r--r--module/web/static/js/views/input/inputView.js55
-rw-r--r--module/web/static/js/views/input/textInput.js33
3 files changed, 95 insertions, 0 deletions
diff --git a/module/web/static/js/views/input/inputLoader.js b/module/web/static/js/views/input/inputLoader.js
new file mode 100644
index 000000000..5ccf07695
--- /dev/null
+++ b/module/web/static/js/views/input/inputLoader.js
@@ -0,0 +1,7 @@
+define(['./textInput'], function(textInput) {
+
+ // selects appropriate input element
+ return function(input, value, default_value, description) {
+ return textInput;
+ };
+}); \ No newline at end of file
diff --git a/module/web/static/js/views/input/inputView.js b/module/web/static/js/views/input/inputView.js
new file mode 100644
index 000000000..15dc71aad
--- /dev/null
+++ b/module/web/static/js/views/input/inputView.js
@@ -0,0 +1,55 @@
+define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) {
+
+ // Renders input elements
+ return Backbone.View.extend({
+
+ tagName: 'input',
+
+ model: null,
+ value: null,
+ default_value: null,
+ description: null,
+
+ initialize: function(model, value, default_value, description) {
+ this.model = model;
+ this.value = value;
+ this.default_value = default_value;
+ this.description = description;
+ },
+
+ render: function() {
+ return this;
+ },
+
+ destroy: function() {
+ this.undelegateEvents();
+ this.unbind();
+ if (this.onDestroy) {
+ this.onDestroy();
+ }
+ this.$el.removeData().unbind();
+ this.remove();
+ },
+
+ // focus the input element
+ focus: function() {
+ this.$el.focus();
+ },
+
+ // Clear the input
+ clear: function() {
+
+ },
+
+ // retrieve value of the input
+ getVal: function() {
+ return this.value;
+ },
+
+ // the child class must call this when the value changed
+ setVal: function(value) {
+ this.value = value;
+ this.trigger('change', value);
+ }
+ });
+}); \ No newline at end of file
diff --git a/module/web/static/js/views/input/textInput.js b/module/web/static/js/views/input/textInput.js
new file mode 100644
index 000000000..7252ce289
--- /dev/null
+++ b/module/web/static/js/views/input/textInput.js
@@ -0,0 +1,33 @@
+define(['jquery', 'backbone', 'underscore', './inputView'], function($, Backbone, _, inputView) {
+
+ return inputView.extend({
+
+ // TODO
+ tagName: 'input',
+ events: {
+ 'keypress': 'onChange'
+ },
+
+ render: function() {
+ this.$el.attr('type', 'text');
+ this.$el.attr('name', 'textInput');
+
+ if (this.default_value)
+ this.$el.attr('placeholder', this.default_value);
+
+ if (this.value)
+ this.$el.val(this.value);
+
+ return this;
+ },
+
+ clear: function() {
+ this.$el.val('');
+ },
+
+ onChange: function(e) {
+ this.setVal(this.$el.val());
+ }
+
+ });
+}); \ No newline at end of file