diff options
-rw-r--r-- | web/client.js | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/web/client.js b/web/client.js index fd52441..6e25c63 100644 --- a/web/client.js +++ b/web/client.js @@ -53,17 +53,15 @@ $(function() { var Field = { format: function(value, status) { var el = this.staticRender(value); - this.setStatus(status, el); + this.setElStatus(el, status); return el; }, staticRender: function(value) { return $("<div>").text(value); }, + setElStatus: function(el, status) { el.prop("class", status); }, init: function(value, meta) { this.el = $("<input>").attr({type: "text", value: value}); }, - setStatus: function(status, el) { - if (!el) el = this.el; - el.prop("class", status); - }, + setStatus: function(status) { this.setElStatus(this.el, status); }, get: function() { return this.el.val() || null; } } @@ -93,12 +91,12 @@ $(function() { CheckBox.staticRender = function(value) { return $("<div>").text(value ? "Yes" : "No"); }; + CheckBox.setElStatus = function(el, status) { + Field.setElStatus(el.parent(), status); + }; CheckBox.init = function(value, meta) { this.el = $("<input>").attr({type: "checkbox", checked: value}); }; - CheckBox.setStatus = function(status) { - Field.setStatus(status, this.el.parent()); - } CheckBox.get = function() { return this.el.is(":checked"); }; var Path = Object.create(Field); @@ -118,14 +116,17 @@ $(function() { var Reference = Object.create(Path); Reference.staticRender = function(value) { return Path.staticRender(value).text(value); - } + }; + Reference.setElStatus = function(el, status) { + ComboBox.setElStatus(el.find("select"), status); + }; Reference.init = function(value, meta) { this.cbox = Object.create(ComboBox) this.cbox.init(value, meta); - this.link = $("<div>"); + var link = $("<div>"); var update = _.bind(function() { - this.link.html(Path.staticRender(this.get())); + link.html(Path.staticRender(this.get())); }, this); this.cbox.el.change(update); update(); @@ -133,11 +134,8 @@ $(function() { this.el = $("<div>"); this.el.append(this.cbox.el); this.el.append(" "); - this.el.append(this.link); + this.el.append(link); }; - Reference.setStatus = function(status) { - ComboBox.setStatus(status, this.cbox.el); - } Reference.get = function() { return this.cbox.get(); }; |