2015-03-25 15:33:36 +01:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
2015-04-04 18:01:57 +02:00
|
|
|
var container = document.createElement("div")
|
|
|
|
container.classList.add("container")
|
|
|
|
sidebar.appendChild(container)
|
|
|
|
|
2015-03-25 15:33:36 +01:00
|
|
|
self.getWidth = function () {
|
2015-03-31 20:32:47 +02:00
|
|
|
if (sidebar.classList.contains("hidden"))
|
|
|
|
return 0
|
|
|
|
|
2015-04-15 15:28:21 +02:00
|
|
|
var small = window.matchMedia("(max-width: 630pt)")
|
2015-03-25 15:33:36 +01:00
|
|
|
return small.matches ? 0 : sidebar.offsetWidth
|
|
|
|
}
|
|
|
|
|
|
|
|
self.add = function (d) {
|
2015-04-04 18:01:57 +02:00
|
|
|
d.render(container)
|
2015-03-25 15:33:36 +01:00
|
|
|
}
|
|
|
|
|
2015-07-06 22:27:16 +02:00
|
|
|
self.hide = function () {
|
|
|
|
container.classList.add("hidden")
|
|
|
|
}
|
|
|
|
|
|
|
|
self.reveal = function () {
|
|
|
|
container.classList.remove("hidden")
|
|
|
|
}
|
|
|
|
|
2015-04-02 04:11:49 +02:00
|
|
|
self.container = sidebar
|
2015-03-25 15:33:36 +01:00
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
})
|