Commits

Sergey Astanin committed b7844ef

adjust height of visible panes too (reader, gmail)

Comments (0)

Files changed (1)

Minimize_Navigation_in_Google_Webapps.user.js

 // @include     https://www.google.tld/reader/*
 // @include     http://www.google.tld/reader/*
 // @include     https://plus.google.tld/*
-// @version     1.0
+// @version     1.1
 // @grant       none
 // ==/UserScript==
 
+function resizableElements() {
+    // elements to be resized when navigation bar is toggled
+    var reader = [].concat(document.getElementById("scrollable-sections"),
+                           document.getElementById("viewer-entries-container"));
+    var gmail  = [].concat(document.getElementsByClassName("aeN")[0],
+                           document.getElementsByClassName("ajl")[0],
+                           document.getElementById(":rp"));
+    return [].concat(reader, gmail);
+}
+
+function adjustResizableElements(delta) {
+    var panes = resizableElements();
+    console.log(panes);
+    for (var i=0; i < panes.length; i++) {
+        if (panes[i] != null) {
+            var name = panes[i].id || ("class=\"" + panes[i].className + "\"");
+            var oldh = panes[i].clientHeight;
+            panes[i].style.height = (panes[i].clientHeight + delta) + "px";
+            console.log(name+ " height: " + oldh + " -> " + panes[i].clientHeight);
+        }
+    }
+}
+
 function addToggleButton() {
     var tb = document.getElementById("toggle_google_bars");
     var gb = document.getElementById("gb");
-
     if (tb) {
         return;
     }
         }
         return;
     }
-
     // create toggle button
     var tb = document.createElement("div");
     tb.setAttribute("id","toggle_google_bars");
-
     // styles
     tb.style.background = "url('https://ssl.gstatic.com/ui/v1/zippy/arrow_down.png') no-repeat center #f2f2f2";
     tb.style.height = "8px";
     tb.style.width = "100%";
+    var headHeight = gb.offsetHeight - 8;
+    adjustResizableElements(headHeight);
     gb.style.display = "none";
-
     // insert toggle button after google bars
     gb.parentNode.insertBefore(tb, gb.nextSibling);
-
     // add callback
     tb.addEventListener("click", function() {
         var gb = document.getElementById("gb");
         var tb = document.getElementById("toggle_google_bars");
         if (gb && (gb.style.display == "block")) {
+            adjustResizableElements(headHeight);
             gb.style.display = "none";
             tb.style.MozTransform = "rotate(0deg)";
         } else {
+            adjustResizableElements(-headHeight);
             gb.style.display = "block";
             tb.style.MozTransform = "rotate(180deg)";
         }
         return false;
     }, false);
-
     return;
 }
-
 // wait until google bars appear, check every second
 setTimeout(addToggleButton, 1000);
 window.triedToAddToggleButton = 0;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.