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