2016-02-25 15:47:07 +01:00
|
|
|
define(["infobox/link", "infobox/node", "infobox/location"], function (Link, Node, Location) {
|
2015-03-25 19:45:21 +01:00
|
|
|
return function (config, sidebar, router) {
|
2015-03-25 11:21:09 +01:00
|
|
|
var self = this
|
2015-03-30 03:20:43 +02:00
|
|
|
var el
|
2015-03-25 11:21:09 +01:00
|
|
|
|
|
|
|
function destroy() {
|
|
|
|
if (el && el.parentNode) {
|
|
|
|
el.parentNode.removeChild(el)
|
|
|
|
el = undefined
|
2015-07-06 22:27:16 +02:00
|
|
|
sidebar.reveal()
|
2015-03-25 11:21:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function create() {
|
|
|
|
destroy()
|
2015-07-06 22:30:45 +02:00
|
|
|
sidebar.ensureVisible()
|
2015-07-06 22:27:16 +02:00
|
|
|
sidebar.hide()
|
2015-03-25 11:21:09 +01:00
|
|
|
|
|
|
|
el = document.createElement("div")
|
2015-03-25 15:33:36 +01:00
|
|
|
sidebar.container.insertBefore(el, sidebar.container.firstChild)
|
2015-03-25 11:21:09 +01:00
|
|
|
|
|
|
|
el.scrollIntoView(false)
|
|
|
|
el.classList.add("infobox")
|
|
|
|
el.destroy = destroy
|
|
|
|
|
|
|
|
var closeButton = document.createElement("button")
|
|
|
|
closeButton.classList.add("close")
|
2015-03-25 19:45:21 +01:00
|
|
|
closeButton.onclick = router.reset
|
2015-03-25 11:21:09 +01:00
|
|
|
el.appendChild(closeButton)
|
|
|
|
}
|
|
|
|
|
|
|
|
self.resetView = destroy
|
|
|
|
|
|
|
|
self.gotoNode = function (d) {
|
|
|
|
create()
|
2015-03-25 19:45:21 +01:00
|
|
|
new Node(config, el, router, d)
|
2015-03-25 11:21:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
self.gotoLink = function (d) {
|
|
|
|
create()
|
2015-03-25 19:45:21 +01:00
|
|
|
new Link(config, el, router, d)
|
2015-03-25 11:21:09 +01:00
|
|
|
}
|
|
|
|
|
2016-02-25 15:47:07 +01:00
|
|
|
self.gotoLocation = function (d) {
|
2016-02-25 21:20:25 +01:00
|
|
|
create()
|
|
|
|
new Location(config, el, router, d)
|
|
|
|
}
|
2016-02-25 15:47:07 +01:00
|
|
|
|
2015-03-25 11:21:09 +01:00
|
|
|
return self
|
|
|
|
}
|
|
|
|
})
|