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