autodoc.git / modref / site.js

version» Context lines:

autodoc.git/modref/site.js:1:   /* jshint undef: true, unused: true */   /* globals window,document */   /* exported PikeDoc */      var PikeDoc = null;      if (!window.console) { -  window.console = {log:function(){},error:function(){}}; +  window.console = { log: function(){}, error: function(){} };   }      /*    Encapsulate so we don't clutter the global scope   */   (function(window, document) {   'use strict';      // The scroll position at which the navbar sticks. This actually gets   // calculated dynamically upon page load.   var stickyScrollBreak = 70,    // Window width when we go to mobile mode    mobileBreakPoint = 800,    // The navbar to the left, HTMLElement    navbar, innerNavbar,    // Content wrapper, HTMLElement    content, -  +  // The page footer +  footer,    // The height of the navbar    navbarHeight,    // The height of the window    windowHeight,    // The height of the header    headerHeight,    // The height of the footer    footerHeight,    // The menu hamburger when in mobile mode    burger,
autodoc.git/modref/site.js:59:    top[0].style.display = 'none';   }      // Called when DOM is ready   function onPageLoad() {    var versionElems, dateElems, i, tmp;       maybeHideNavbox();    navbar = document.getElementsByClassName('navbar')[0];    content = document.getElementsByClassName('content')[0]; -  footerHeight = document.getElementsByTagName('footer')[0].offsetHeight; +  footer = document.getElementsByTagName('footer')[0]; +  footerHeight = footer.offsetHeight;    windowHeight = window.outerHeight;    headerHeight = document.getElementsByTagName('header')[0].offsetHeight;    navbarHeight = windowHeight - content.offsetTop - footerHeight;    innerNavbar = document.getElementById('navbar');    burger = document.getElementById('burger');       // When the doc is compiled with FLAG_NO_DYNAMIC the version and publish date    // will not be written to the pages but inserted with JS. If the VERSION    // symbol exists we need to put the version and pubdate in the elements with    // attributes data-id="version" and data-id="date".
autodoc.git/modref/site.js:103:   // Invoked when DOM is ready, and use as callback for onscroll.   function onPageScroll() {    // If scrollY is larger than the sticky position ...    if (window.scrollY > stickyScrollBreak) {    // ... see if we're already sticky and return if so ...    if (iAmSticky) {    return;    }    // ... or else set to sticky.    iAmSticky = true; -  content.style.minHeight = (windowHeight - headerHeight - -  footerHeight + 5) + 'px'; +  content.style.minHeight = (windowHeight - headerHeight) + 'px';    navbar.classList.add('sticky');    }    // If scrollY is less than the sticky position ...    else {    // ... see if we're explicitly non-sticky and return if so ...    if (iAmSticky === false) {    return;    }    // ... else set to explicitly non-sticky    iAmSticky = false;
autodoc.git/modref/site.js:197:    window.addEventListener('resize', onWindowResize, false);    document.addEventListener('scroll', iAmMobile ? onMobilePageScroll    : onPageScroll,    false);    }, false);   }      // During a session each generated menu is cached locally in a sessionStorage   // (if available). This one handles that.   var cacheFactory = (function() { -  var cache = window.sessionStorage; +  // Don't use cache if the page isn't served through a server. +  // The cache seems buggy as hell when the pages are view directly from +  // the file system. +  var cache = document.location.hostname && window.sessionStorage;    var m, isChecked = false;       function init() {    if (m || PikeDoc.current.link === 'index.html') {    return true;    }    -  +  if (!cache) { +  return false; +  } +     if (isChecked && !m) {    return false;    }    -  if (cache) { +     m = cache.getItem(PikeDoc.current.link);    isChecked = true; -  +     if (m) {    m = JSON.parse(m); -  return validateDate(m.time); +  var ok = validateDate(m.time); +  if (!ok) { +  isChecked = false; +  cache.removeItem(PikeDoc.current.link);    } -  return false; +  return ok;    } -  -  isChecked = true; -  +     return false; -  +     }       function validateDate(time) {    var t = PikeDoc.PUBDATE; -  +  // window.console.log('PUBDATE: ', t);    if (!t) { -  t = new Date(); -  t.setTime(t.getTime() - (3600*1000)*48); +  t.setTime(Date.now() - (3600*1000)*24);    return t < new Date(time);    }       return getPubDate() < new Date(time);    }       function getPubDate() {    if (PikeDoc.PUBDATE) {    return new Date(Date.parse(PikeDoc.PUBDATE));    }    return new Date();    }       function store() {    if (cache) {    var obj = { -  time: new Date().getTime(), +  time: Date.now(),    value: innerNavbar.innerHTML    };       cache.setItem(PikeDoc.current.link||'root', JSON.stringify(obj));    }    }       function setMenu() { -  if (m) { +  if (m && validateDate(m.time)) {    innerNavbar.innerHTML = m.value;    }    }       return {    hasCache: init,    store: store,    setMenu: setMenu    };   }());
autodoc.git/modref/site.js:439:    });    });       isAllLoaded = true;    maybeRenderNavbar();    }    }       var jsMap = {};    var scriptQueue = 0; +     function loadScript(link, namespace, inherits) { -  +  // window.console.log('load: ', link);    if (cacheFactory.hasCache()) {    return;    }       link = helpers.adjustLink(link);       // Already loaded    if (jsMap[link]) {    return;    }
autodoc.git/modref/site.js:524:    div.appendChild(tnode);    });       c.appendChild(createElem('b', { class: 'heading' }, heading));    c.appendChild(div);    }       /* Render the left navigation bar. */    function navbar() {    var s = createElem('div', { class: 'sidebar' }); +  // If the cache already has set the menu, then clear it. The cache is +  // almost certainly run before this method. +  var old = innerNavbar.querySelectorAll('.sidebar'); +  var i, tmp; +  if (old.length) { +  // window.console.log('Clear cached menu and regenerate', old); +  for (i = 0; i < old.length; i++) { +  tmp = old[i]; +  tmp.parentNode.removeChild(tmp); +  } +  } +     innerNavbar.appendChild(s);       lowNavbar(s, 'Modules', types.module, '');    lowNavbar(s, 'Classes', types.class, '');    lowNavbar(s, 'Enums', types.enum, '');    lowNavbar(s, 'Directives', types.directive, '');    lowNavbar(s, 'Methods', types.method, '()');    lowNavbar(s, 'Operators', types.operator, '()');    lowNavbar(s, 'Members', types.member, '()');    lowNavbar(s, 'Namespaces', types.namespace, '::');
autodoc.git/modref/site.js:572:    });       var s = document.getElementsByTagName('script')[0];    var el = createElem('script', {    src: '/assets/js/local/refdoc-search.min.js',    async: true    });       s.parentNode.insertBefore(el, s);    +  var el2 = createElem('script', { +  src: '/assets/js/local/disqus.min.js', +  async: true +  }); +  +  s.parentNode.insertBefore(el2, s); +     var f = createElem('link', { -  href: '/assets/img/favicon.png?v=2', +  href: '/assets/img/favicon.png',    rel: 'shortcut icon'    });       document.head.appendChild(f);    }    }());       return {    registerSymbol: registerSymbol,    endInherit: endInherit,    loadScript: loadScript,    domReady: domReady,    isInline: isInline,    current: current,    finish: finish,    };      }());      }(window, document));