Github user benkeen commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/139#discussion_r20113488
--- Diff: app/addons/config/views.js ---
@@ -139,35 +139,120 @@ function(app, FauxtonAPI, Config, Components) {
}
});
- Views.Modal = FauxtonAPI.View.extend({
- className: 'add-section-modal modal hide fade',
- template: 'addons/config/templates/modal',
+ Views.ConfigHeader = FauxtonAPI.View.extend({
+ template: 'addons/config/templates/header',
+ className: 'header-right',
+
+ initialize: function () {
+ this.rightHeader = this.setView('#add-section-button', new
Views.AddConfigOptionsButton({ collection: this.collection }));
+ }
+ });
+
+
+ Views.AddConfigOptionsButton = FauxtonAPI.View.extend({
+ template: 'addons/config/templates/add_config_option',
events: {
- 'submit #js-add-section-form': 'submitClick'
+ 'click #add-new-section': 'toggleTray',
+ 'click #js-create-config-section': 'createConfigOption'
},
initialize: function () {
- this.sourceArray = _.map(this.collection.toJSON(), function (item,
key) {
- return item.section;
+ var hideTray = _.bind(this.hideTray, this),
+ trayVisible = _.bind(this.trayVisible, this);
+
+ $('body').on('click.add-new-section', function(e) {
+ var $clickEl = $(e.target);
+
+ if (!trayVisible()) { return; }
+ if ($clickEl.closest('.add-new-section').length) { return; }
+ if (!$clickEl.closest('.add-section-tray').length) {
+ hideTray();
+ }
+ });
+ },
+
+ cleanup: function () {
+ $('body').off('click.add-new-section');
+ },
+
+ processKey: function (e) {
+ if (e.which === 13) {
+ this.createConfigOption(e);
--- End diff --
Hmmm... true... but it'll mean one extra (and technically redundant) line
of code to cancel the event in `processKey` as well as `createConfigOption`.
But agreed, it'd be looser coupled. Adding!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---