couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From benk...@apache.org
Subject fauxton commit: updated refs/heads/master to 0e8b68e
Date Thu, 08 Jan 2015 15:59:28 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master f2640155a -> 0e8b68edf


Keep track of sidebar status

This is a simple usability fix: it keeps track of whether the user
has expanded or shrunk the sidebar so on future refreshes it
doesn't revert to the wrong state.


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

Branch: refs/heads/master
Commit: 0e8b68edfacdddfcf6d777fc61c605d159fa47b9
Parents: f264015
Author: Benjamin Keen <ben.keen@gmail.com>
Authored: Tue Dec 30 18:53:40 2014 -0800
Committer: Benjamin Keen <ben.keen@gmail.com>
Committed: Thu Jan 8 07:58:46 2015 -0800

----------------------------------------------------------------------
 app/addons/fauxton/base.js | 18 +++++++++++++++++-
 app/constants.js           |  4 ++++
 2 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0e8b68ed/app/addons/fauxton/base.js
----------------------------------------------------------------------
diff --git a/app/addons/fauxton/base.js b/app/addons/fauxton/base.js
index ed94bb9..d5229c9 100644
--- a/app/addons/fauxton/base.js
+++ b/app/addons/fauxton/base.js
@@ -130,8 +130,10 @@ function(app, FauxtonAPI, Components, ZeroClipboard) {
 
     toggleMenu: function(){
        var $selectorList = $('body');
+      var minimized = !$selectorList.hasClass('closeMenu');
+      this.setState(minimized);
        $selectorList.toggleClass('closeMenu');
-      FauxtonAPI.Events.trigger(FauxtonAPI.constants.EVENTS.BURGER_CLICKED);
+       FauxtonAPI.Events.trigger(FauxtonAPI.constants.EVENT_BURGER_CLICK, { minimized: minimized
});
     },
 
     // TODO: can we generate this list from the router?
@@ -148,6 +150,11 @@ function(app, FauxtonAPI, Components, ZeroClipboard) {
       FauxtonAPI.extensions.on('add:navbar:addHeaderLink', this.addLink);
       FauxtonAPI.extensions.on('removeItem:navbar:addHeaderLink', this.removeLink);
       this.versionFooter = new Fauxton.Footer({});
+
+      // if needed, minimize the sidebar
+      if (this.isMinimized()) {
+        $('body').addClass('closeMenu');
+      }
     },
 
     serialize: function() {
@@ -223,6 +230,15 @@ function(app, FauxtonAPI, Components, ZeroClipboard) {
           that.insertView(selector, link.view).render();
         });
       }, this);
+    },
+
+    setState: function (minimized) {
+      app.utils.localStorageSet(FauxtonAPI.constants.LOCAL_STORAGE.SIDEBAR_MINIMIZED, minimized);
+    },
+
+    isMinimized: function () {
+      var isMinimized = app.utils.localStorageGet(FauxtonAPI.constants.LOCAL_STORAGE.SIDEBAR_MINIMIZED);
+      return (_.isUndefined(isMinimized)) ? false : isMinimized;
     }
 
     // TODO: ADD ACTIVE CLASS

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0e8b68ed/app/constants.js
----------------------------------------------------------------------
diff --git a/app/constants.js b/app/constants.js
index bd46359..91cffda 100644
--- a/app/constants.js
+++ b/app/constants.js
@@ -45,6 +45,10 @@ define([], function () {
       CONFIG: '/_utils/docs/config/index.html',
       VIEWS: '/_utils/docs/intro/overview.html#views',
       CHANGES: '/_utils/docs/api/database/changes.html?highlight=changes#post--db-_changes'
+    },
+
+    LOCAL_STORAGE: {
+      SIDEBAR_MINIMIZED: 'sidebar-minimized'
     }
   };
 


Mime
View raw message