hopglass/lib/sidebar.js
Nils Schneider 8de28b903b enhance sidebar and content styling
- 3 sidebar variations (margin, no margin, below content)
  depending on screen size
- scrolling sidebar will scroll document (more space on mobile devices)
- wrap map/graph on div.content
2015-04-02 04:17:35 +02:00

34 lines
726 B
JavaScript

define([], function () {
return function (el) {
var self = this
var sidebar = document.createElement("div")
sidebar.classList.add("sidebar")
el.appendChild(sidebar)
var button = document.createElement("button")
sidebar.appendChild(button)
button.classList.add("sidebarhandle")
button.onclick = function () {
sidebar.classList.toggle("hidden")
}
self.getWidth = function () {
if (sidebar.classList.contains("hidden"))
return 0
var small = window.matchMedia("(max-width: 60em)")
return small.matches ? 0 : sidebar.offsetWidth
}
self.add = function (d) {
d.render(sidebar)
}
self.container = sidebar
return self
}
})