Sha256: 1fda645b72abfe1d86fefe829bcb0b8fe276f807ad4439af7dd1093c53984f10

Contents?: true

Size: 1.33 KB

Versions: 13

Compression:

Stored size: 1.33 KB

Contents

window.gdocs = {

  eventAdd: function(el, type, handler) {
    if (el.attachEvent) el.attachEvent('on' + type, handler)
    else el.addEventListener(type, handler)
  },

  eventRemove: function(el, type, handler) {
    if (el.detachEvent) el.detachEvent('on' + type, handler)
    else el.removeEventListener(type, handler)
  },

  init: function() {
    gdocs.nav()
    document.querySelector('.content').focus()
  },

  onReady: function() {
    // in case the document is already rendered
    if (document.readyState!='loading') {
      gdocs.init()
      
    // modern browsers
    } else if (document.addEventListener) {
      document.addEventListener('DOMContentLoaded', gdocs.init)
    }
  },

  nav: function() {
    // Show/hide mobile menu
    var body = document.querySelector('body')
    var navElems = document.getElementsByClassName('toggle-nav')

    for (var i=navElems.length; i--;) {
      gdocs.eventAdd(navElems[i], 'click', function(e) {
        e.preventDefault()
        var text = this.innerText
        var textToggle = this.getAttribute('data-text-toggle')

        body.classList.toggle('nav-open')
        this.classList.toggle('nav-open')
        if (textToggle) {
          this.innerText = textToggle
          this.setAttribute('data-text-toggle', text)
          textToggle = text
        }
      })
    }
  }
}

gdocs.onReady()

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
github-docs-0.1.0 assets/js/index.js
github-docs-0.0.22 assets/js/index.js
github-docs-0.0.21 assets/js/index.js
github-docs-0.0.19 assets/js/index.js
github-docs-0.0.18 assets/js/index.js
github-docs-0.0.17 assets/js/index.js
github-docs-0.0.7 assets/js/index.js
github-docs-0.0.6 assets/js/index.js
github-docs-0.0.5 assets/js/index.js
github-docs-0.0.4 assets/js/index.js
github-docs-0.0.3 assets/js/index.js
github-docs-0.0.2 assets/js/index.js
github-docs-0.0.1 assets/js/index.js