use Events to close trays
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/ad4c128c Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/ad4c128c Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/ad4c128c Branch: refs/heads/secondary-indexes Commit: ad4c128c3129b0d7c3011a1a6259d6f30349f509 Parents: ba4c20c Author: Jenn Schiffer <[email protected]> Authored: Wed Aug 13 15:16:45 2014 -0400 Committer: deathbearbrown <[email protected]> Committed: Wed Aug 13 16:30:20 2014 -0400 ---------------------------------------------------------------------- app/addons/documents/views-advancedopts.js | 15 ++++++++++----- app/addons/fauxton/components.js | 13 ++++++++++--- 2 files changed, 20 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/ad4c128c/app/addons/documents/views-advancedopts.js ---------------------------------------------------------------------- diff --git a/app/addons/documents/views-advancedopts.js b/app/addons/documents/views-advancedopts.js index 0a91914..993750f 100644 --- a/app/addons/documents/views-advancedopts.js +++ b/app/addons/documents/views-advancedopts.js @@ -26,6 +26,7 @@ function(app, FauxtonAPI, resizeColumns ) { className: "advanced-options well", initialize: function (options) { + FauxtonAPI.Events.on('AdvancedOptions:closeTray', this.closeTray); this.database = options.database; this.ddocName = options.ddocName; this.viewName = options.viewName; @@ -64,18 +65,22 @@ function(app, FauxtonAPI, resizeColumns ) { toggleQuery: function(event) { $('#dashboard-content').scrollTop(0); this.$('#query-options-tray').toggle(); - $('.api-navbar').hide(); + FauxtonAPI.Events.trigger('APIbar:closeTray'); }, + closeTray: function(){ + $('#query-options-tray').hide(); + }, + resetForm: function() { - $('input, textarea').each(function(){ + this.$('input, textarea').each(function(){ $(this).val(''); }); - $('input:checkbox').attr('checked', false); - $("select").each(function(){ + this.$('input:checkbox').attr('checked', false); + this.$("select").each(function(){ this.selectedIndex = 0; }); - $('#query-options-tray').hide(); + this.$('#query-options-tray').hide(); }, showKeys: function(){ http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/ad4c128c/app/addons/fauxton/components.js ---------------------------------------------------------------------- diff --git a/app/addons/fauxton/components.js b/app/addons/fauxton/components.js index 3784b8d..e8bd559 100644 --- a/app/addons/fauxton/components.js +++ b/app/addons/fauxton/components.js @@ -97,6 +97,7 @@ function(app, FauxtonAPI, ace, spin, ZeroClipboard) { }, initialize: function(options){ + FauxtonAPI.Events.on('APIbar:closeTray', this.closeTray); var _options = options || {}; this.endpoint = _options.endpoint || '_all_docs'; this.documentation = _options.documentation || 'docs'; @@ -109,8 +110,8 @@ function(app, FauxtonAPI, ace, spin, ZeroClipboard) { }else{ $currentTarget.removeClass("fonticon-minus").addClass("fonticon-plus"); } - $('#query-options-tray').hide(); - $('.api-navbar').toggle(); + FauxtonAPI.Events.trigger('AdvancedOptions:closeTray'); + this.$('.api-navbar').toggle(); }, serialize: function() { @@ -123,15 +124,22 @@ function(app, FauxtonAPI, ace, spin, ZeroClipboard) { hide: function(){ this.$el.addClass('hide'); }, + show: function(){ this.$el.removeClass('hide'); }, + + closeTray: function(){ + $('.api-navbar').hide(); + }, + update: function(endpoint) { this.show(); this.endpoint = endpoint[0]; this.documentation = endpoint[1]; this.render(); }, + afterRender: function(){ ZeroClipboard.config({ moviePath: "/assets/js/plugins/zeroclipboard/ZeroClipboard.swf" }); var client = new ZeroClipboard(this.$(".copy-url")); @@ -147,7 +155,6 @@ function(app, FauxtonAPI, ace, spin, ZeroClipboard) { }); }); } - });
