2017-01-29 23:51:08 +00:00
|
|
|
define(['infobox/link', 'infobox/node', 'infobox/location'], function (link, node, location) {
|
|
|
|
'use strict';
|
2016-05-27 21:59:01 +00:00
|
|
|
|
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
|
|
|
|
2017-01-29 23:51:08 +00:00
|
|
|
el = document.createElement('div');
|
2016-05-22 11:23:43 +00:00
|
|
|
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);
|
2017-01-29 23:51:08 +00:00
|
|
|
el.classList.add('infobox');
|
2016-05-22 11:23:43 +00:00
|
|
|
el.destroy = destroy;
|
2015-03-25 10:21:09 +00:00
|
|
|
|
2017-01-29 23:51:08 +00:00
|
|
|
var closeButton = document.createElement('button');
|
|
|
|
closeButton.classList.add('close');
|
2017-02-04 19:01:49 +00:00
|
|
|
closeButton.classList.add('ion-close');
|
2016-05-22 11:23:43 +00:00
|
|
|
closeButton.onclick = router.reset;
|
|
|
|
el.appendChild(closeButton);
|
2015-03-25 10:21:09 +00:00
|
|
|
}
|
|
|
|
|
2016-06-22 01:15:53 +00:00
|
|
|
function clear() {
|
|
|
|
var closeButton = el.firstChild;
|
|
|
|
while (el.firstChild) {
|
|
|
|
el.removeChild(el.firstChild);
|
|
|
|
}
|
|
|
|
el.appendChild(closeButton);
|
|
|
|
}
|
|
|
|
|
2016-05-22 11:23:43 +00:00
|
|
|
self.resetView = destroy;
|
2015-03-25 10:21:09 +00:00
|
|
|
|
2017-01-29 23:51:08 +00:00
|
|
|
self.gotoNode = function gotoNode(d, update) {
|
2016-06-22 01:15:53 +00:00
|
|
|
if (update !== true) {
|
|
|
|
create();
|
|
|
|
} else {
|
|
|
|
clear();
|
|
|
|
}
|
2017-01-29 23:51:08 +00:00
|
|
|
node(config, el, router, d);
|
2016-05-22 11:23:43 +00:00
|
|
|
};
|
2015-03-25 10:21:09 +00:00
|
|
|
|
2017-01-29 23:51:08 +00:00
|
|
|
self.gotoLink = function gotoLink(d, update) {
|
2016-06-22 01:15:53 +00:00
|
|
|
if (update !== true) {
|
|
|
|
create();
|
|
|
|
} else {
|
|
|
|
clear();
|
|
|
|
}
|
2017-01-29 23:51:08 +00:00
|
|
|
link(config, el, router, d);
|
2016-05-22 11:23:43 +00:00
|
|
|
};
|
2015-03-25 10:21:09 +00:00
|
|
|
|
2017-01-29 23:51:08 +00:00
|
|
|
self.gotoLocation = function gotoLocation(d) {
|
2016-05-22 11:23:43 +00:00
|
|
|
create();
|
2017-01-29 23:51:08 +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;
|
|
|
|
};
|
|
|
|
});
|