couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject [7/7] fauxton commit: updated refs/heads/master to 6c9a5a6
Date Tue, 26 Aug 2014 16:24:16 GMT
Code improvements from PR


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/6c9a5a64
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/6c9a5a64
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/6c9a5a64

Branch: refs/heads/master
Commit: 6c9a5a643fa6bd2e090ea25fb09bef2c477877c2
Parents: 3e6ab2e
Author: Garren Smith <garren.smith@gmail.com>
Authored: Mon Aug 25 11:17:05 2014 +0200
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Tue Aug 26 18:23:44 2014 +0200

----------------------------------------------------------------------
 app/addons/fauxton/base.js | 41 +++++++++++++++++++----------------------
 1 file changed, 19 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/6c9a5a64/app/addons/fauxton/base.js
----------------------------------------------------------------------
diff --git a/app/addons/fauxton/base.js b/app/addons/fauxton/base.js
index e890c1a..207a0f6 100644
--- a/app/addons/fauxton/base.js
+++ b/app/addons/fauxton/base.js
@@ -266,49 +266,47 @@ function(app, FauxtonAPI, resizeColumns, Components, ZeroClipboard,
velocity) {
     endpoint: '_all_docs',
 
     documentation: 'docs',
-    apiBarVisible: false,
 
     events:  {
       "click .api-url-btn" : "toggleAPIbar"
     },
     
     initialize: function () {
-      var that = this;
+      var hideAPIbar = _.bind(this.hideAPIbar, this),
+          navbarVisible = _.bind(this.navbarVisible, this);
+
 
       $('body').on('click.apibar',function(e) {
-        if (!that.apiBarVisible) { return;}
-        if ($(e.target).hasClass('.api-url-btn')) { return;}
+        var $navbar = $(e.target);
+        if (!navbarVisible()) { return;}
+        if ($navbar.hasClass('.api-url-btn')) { return;}
 
-        if (!$(e.target).closest('.api-navbar').length){
-          that.hideAPIbar();
+        if (!$navbar.closest('.api-navbar').length){
+          hideAPIbar();
         }
       });
     },
 
+    navbarVisible: function () {
+      return this.$('.api-navbar').is(':visible');
+    },
+
     cleanup: function () {
       $('body').off('click.apibar');
     },
 
     hideAPIbar: function () {
-      this.$('.api-navbar').velocity("reverse", 250);
-
-      this.apiBarVisible = false;
+      var $navBar = this.$('.api-navbar');
+      $navBar.velocity("reverse", 250, function () {
+        $navBar.hide();
+      });
     },
 
     toggleAPIbar: function(event){
-      event.preventDefault();
-      event.stopPropagation();
-
-      if (this.apiBarVisible) {
-        this.apiBarVisible = false;
-        
-        this.$('.api-navbar')
-        .velocity("reverse", 250);
+      if (this.navbarVisible()) {
+        this.$('.api-navbar').velocity("reverse", 250);
       } else {
-        this.apiBarVisible = true;
-        
-        this.$('.api-navbar')
-        .velocity("transition.slideUpIn", 250);
+        this.$('.api-navbar').velocity("transition.slideDownIn", 250);
       }
     },
 
@@ -320,7 +318,6 @@ function(app, FauxtonAPI, resizeColumns, Components, ZeroClipboard, velocity)
{
     },
 
     hide: function(){
-      this.apiBarVisible = false;
       this.$el.addClass('hide');
     },
     show: function(){


Mime
View raw message