meshviewer/lib/infobox/main.js

57 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

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) {
var self = this;
var el;
2015-03-25 10:21:09 +00:00
function destroy() {
if (el && el.parentNode) {
el.parentNode.removeChild(el);
el = undefined;
sidebar.reveal();
2015-03-25 10:21:09 +00:00
}
}
function create() {
destroy();
sidebar.ensureVisible();
sidebar.hide();
2015-03-25 10:21:09 +00:00
el = document.createElement('div');
sidebar.container.children[1].appendChild(el);
2015-03-25 10:21:09 +00:00
el.scrollIntoView(false);
el.classList.add('infobox');
el.destroy = destroy;
2015-03-25 10:21:09 +00:00
var closeButton = document.createElement('button');
closeButton.classList.add('close');
closeButton.classList.add('ion-close');
2017-03-05 11:29:21 +00:00
closeButton.onclick = function () {
router.fullUrl();
};
el.appendChild(closeButton);
}
self.resetView = destroy;
2015-03-25 10:21:09 +00:00
2017-03-05 11:29:21 +00:00
self.gotoNode = function gotoNode(d) {
create();
node(config, el, router, d);
};
2015-03-25 10:21:09 +00:00
2017-03-05 11:29:21 +00:00
self.gotoLink = function gotoLink(d) {
create();
link(config, el, router, d);
};
2015-03-25 10:21:09 +00:00
self.gotoLocation = function gotoLocation(d) {
create();
location(config, el, router, d);
};
return self;
};
});