Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52dd2067 authored by Scott Main's avatar Scott Main
Browse files

fix two bugs in site script.

1. Fix URL path check for reference docs to initalize api level and sidenav.
Previously, this condition was never true, so the sidenav would not be initialized
under default conditions and the reference drag bar would not appear.
2. Fix the recent change to the 'scroll into view' script so that it works
properly in a multi-pane sidenav (reference docs) by again making the offset
measurement relative to the parent container (but much better than was done before).

Change-Id: I2a31ed59d772346651c2432f0ed26530983c49ff
parent 3b90aff0
Loading
Loading
Loading
Loading
+11 −13
Original line number Diff line number Diff line
@@ -183,7 +183,6 @@ $(document).ready(function() {
        $("#nav-x li.google a").addClass("selected");
      } else {
        $("#nav-x li.reference a").addClass("selected");
        changeApiLevel();  // turn things grey
      }
    } else if ((rootDir == "tools") || (rootDir == "sdk")) {
      $("#nav-x li.tools a").addClass("selected");
@@ -825,14 +824,13 @@ function scrollIntoView(nav) {
      // If no selected item found, exit
      return;
    }

    var selectedOffset = $selected.offset().top; // measure offset from top, relative to entire page
    if (selectedOffset > $nav.height() * .8) { // multiply nav height by .8 so we move up any
                                               // items more than 80% down the nav
      // scroll the item up by an amount 125px less than the window height (account for site header)
      // and then multiply nav height by .8 to match the 80% threshold used above
      api.scrollTo(0, selectedOffset - 125 - ($nav.height() * .8), false);

    // get the selected item's offset from its container nav by measuring the item's offset
    // relative to the document then subtract the container nav's offset relative to the document
    var selectedOffset = $selected.offset().top - $nav.offset().top;
    if (selectedOffset > $nav.height() * .8) { // multiply nav height by .8 so we move up the item
                                               // if it's more than 80% down the nav
      // scroll the item up by an amount equal to 80% the container nav's height
      api.scrollTo(0, selectedOffset - ($nav.height() * .8), false);
    }
  }
}
@@ -2232,10 +2230,10 @@ function escapeHTML(string) {
/* ######################################################## */

/* Initialize some droiddoc stuff, but only if we're in the reference */
if (location.pathname.indexOf("/reference")) {
  if(!location.pathname.indexOf("/reference-gms/packages.html")
    && !location.pathname.indexOf("/reference-gcm/packages.html")
    && !location.pathname.indexOf("/reference/com/google") == 0) {
if (location.pathname.indexOf("/reference") == 0) {
  if(!(location.pathname.indexOf("/reference-gms/packages.html") == 0)
    && !(location.pathname.indexOf("/reference-gcm/packages.html") == 0)
    && !(location.pathname.indexOf("/reference/com/google") == 0)) {
    $(document).ready(function() {
      // init available apis based on user pref
      changeApiLevel();