maestro-server/analytics-front

View on GitHub
assets/js/libs/appSVG.js

Summary

Maintainability
A
25 mins
Test Coverage
'use strict';

var SVG = require('svg.js');
var AppTooltip = require('./appTooltip.js');
var AnimateLines = require('./animateLines.js');
var MenuBar = require('./menuBar.js');
var ZoomPanSVG = require('./zoomPanSVG.js');


function AppSVG(svg) {
    this.app = null;
    this.root = null;

    this.setupSVGObject = function() {
        var qapp = document.querySelector("svg .svg-pan-zoom_viewport");
        this.app = SVG.adopt(qapp);

        var qobj = document.querySelector("svg");
        this.root = SVG.adopt(qobj);
    }

    this.setup = function() {
        var urlParams = new URLSearchParams(window.location.search);
        var jwt = urlParams.get('jwt');
        var hm = urlParams.get('hm');

        new ZoomPanSVG().setup();

        this.setupSVGObject();

        if (hm && window.matchMedia("(min-width: 700px)").matches) {
            new AppTooltip(this.root, jwt).setup();
            new AnimateLines(this.app).setup();

            if (jwt)
                new MenuBar().setup();
        }

        
    };
}

module.exports = AppSVG;