44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
<script>
|
|
|
|
// custom resize function as there is no event to fire and we need
|
|
// to react to the sidebar.
|
|
$.getJSON('[% uri_for('/ajax/data/device/netmap') %]', {q: '[% params.q %]'}, function(data) {
|
|
function resizeGraphContainer() {
|
|
setTimeout(function(){
|
|
var graph = jQuery('#netmap_pane');
|
|
netmap_pane.width( parseInt(graph.parent().css('width')) ).resume();
|
|
netmap_pane.height( window.innerHeight - 100 ).resume();
|
|
}, 500)
|
|
}
|
|
|
|
jQuery(document).ready(function() {
|
|
window.netmap_pane = netGobrechtsD3Force('netmap_pane')
|
|
.debug(true)
|
|
.lassoMode(true)
|
|
.nodeEventToOpenLink('click')
|
|
.nodeLinkTarget('none')
|
|
.labelDistance(2)
|
|
.charge(-850)
|
|
.zoomMode(true)
|
|
.preventLabelOverlappingOnForceEnd(true)
|
|
.showLinkDirection(false)
|
|
.showSelfLinks(true)
|
|
.showLoadingIndicatorOnAjaxCall(true)
|
|
.minZoomFactor(0.1)
|
|
.maxZoomFactor(10)
|
|
.start(data);
|
|
|
|
jQuery('#nd_sidebar-toggle-img-in').on("click", resizeGraphContainer);
|
|
jQuery('#nd_sidebar-toggle-img-out').on("click", resizeGraphContainer);
|
|
jQuery(window).on("resize", resizeGraphContainer);
|
|
resizeGraphContainer();
|
|
|
|
// sort-of center on our selected device
|
|
var node = netmap_pane.nodeDataById( data['data']['centernode'] );
|
|
netmap_pane.zoom(node.x, node.y, 850);
|
|
});
|
|
});
|
|
|
|
// vim: ft=javascript
|
|
</script>
|