Repository: couchdb-fauxton Updated Branches: refs/heads/master 12f372ffd -> 643432415
Add Option tray now uses generic component To test this, just click on the Add Option header link on the Config page. Closes COUCHDB-2453 Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/64343241 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/64343241 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/64343241 Branch: refs/heads/master Commit: 6434324157fca8b908ae641a415c181383b7de8f Parents: 12f372f Author: Benjamin Keen <[email protected]> Authored: Tue Nov 11 12:50:39 2014 -0800 Committer: Benjamin Keen <[email protected]> Committed: Thu Nov 13 09:07:23 2014 -0800 ---------------------------------------------------------------------- app/addons/config/views.js | 49 ++--------------------------------------- 1 file changed, 2 insertions(+), 47 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/64343241/app/addons/config/views.js ---------------------------------------------------------------------- diff --git a/app/addons/config/views.js b/app/addons/config/views.js index 93bfa2b..6c02a78 100644 --- a/app/addons/config/views.js +++ b/app/addons/config/views.js @@ -149,31 +149,15 @@ function(app, FauxtonAPI, Config, Components) { }); - Views.AddConfigOptionsButton = FauxtonAPI.View.extend({ + Views.AddConfigOptionsButton = Components.Tray.extend({ template: 'addons/config/templates/add_config_option', events: { - 'click #add-new-section': 'toggleTray', 'click #js-create-config-section': 'createConfigOption' }, initialize: function () { - 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'); + this.initTray({ toggleTrayBtnSelector: '#add-new-section' }); }, processKey: function (e) { @@ -183,35 +167,6 @@ function(app, FauxtonAPI, Config, Components) { } }, - toggleTray: function (e) { - e.preventDefault(); - if (this.trayVisible()) { - this.hideTray(); - } else { - this.showTray(); - } - }, - - hideTray: function () { - var $tray = this.$('.tray'); - $tray.velocity('reverse', FauxtonAPI.constants.TRAY_TOGGLE_SPEED, function () { - $tray.hide(); - }); - this.$('#add-new-section').removeClass('enabled'); - }, - - showTray: function () { - // to be refactored out later (see COUCHDB-2401) - FauxtonAPI.Events.trigger("APIbar:closeTray"); - - this.$('.tray').velocity('transition.slideDownIn', FauxtonAPI.constants.TRAY_TOGGLE_SPEED); - this.$('#add-new-section').addClass('enabled'); - }, - - trayVisible: function () { - return this.$('.tray').is(':visible'); - }, - afterRender: function () { this.sectionNames = _.map(this.collection.toJSON(), function (item) { return item.section;
