From 7b4c75f0dd755e28fcffc0e4fdd05452458a3b09 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 24 Mar 2013 21:27:43 +0100 Subject: added view type for input fields --- module/web/static/js/views/input/inputView.js | 55 +++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 module/web/static/js/views/input/inputView.js (limited to 'module/web/static/js/views/input/inputView.js') 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 -- cgit v1.2.3