From d6238b646374df4f103a090d8636701e58c254dd Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 27 Mar 2013 18:22:57 +0100 Subject: working reset button for config --- module/web/static/js/views/configSectionView.js | 22 +++++++++++++++++----- module/web/templates/default/settings.html | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/module/web/static/js/views/configSectionView.js b/module/web/static/js/views/configSectionView.js index 0bbe61653..346f7b949 100644 --- a/module/web/static/js/views/configSectionView.js +++ b/module/web/static/js/views/configSectionView.js @@ -13,8 +13,8 @@ define(['jquery', 'underscore', 'backbone', 'app', './input/inputLoader'], rendered: false, events: { - 'click .btn-primary': 'submit' - // TODO cancel + 'click .btn-primary': 'submit', + 'click .btn-reset': 'reset' }, initialize: function() { @@ -25,8 +25,6 @@ define(['jquery', 'underscore', 'backbone', 'app', './input/inputLoader'], if (!this.rendered) { this.$el.html(this.template(this.model.toJSON())); - // TODO: only render one time, rest of the attributes set manually - // initialize the popover this.$('.page-header a').popover({ placement: 'left', @@ -67,8 +65,22 @@ define(['jquery', 'underscore', 'backbone', 'app', './input/inputLoader'], return this; }, - submit: function() { + submit: function(e) { + e.stopPropagation(); + // TODO: success / failure popups + }, + reset: function(e) { + e.stopPropagation(); + // restore the original value + _.each(this.model.get('items'), function(item) { + if (item.has('inputView')) { + var input = item.get('inputView'); + input.setVal(item.get('value')); + input.render(); + } + }); + this.render(); } }); diff --git a/module/web/templates/default/settings.html b/module/web/templates/default/settings.html index d19c72a2b..683009c37 100644 --- a/module/web/templates/default/settings.html +++ b/module/web/templates/default/settings.html @@ -39,7 +39,7 @@
- +