/** * _ ___ Another * / |/ (_)______ __ _____ * / / / __(_- // (_-< * /_/|_/_/\__/___/\_, /___/ * /___/ * production ! * * Licensed under the MIT License: * This code is free to use and modify, * as long as the copyright notice and license are kept. */ class BZgrafloweditor extends Buildoz{ constructor(){ super() this.defaultAttrs = { } } async connectedCallback() { await customElements.whenDefined('bz-graflow') await customElements.whenDefined('bz-slidepane') await customElements.whenDefined('bz-select') super.connectedCallback() const nodesUrl = this.getBZAttribute('nodes') this.mainContainer = document.createElement('div') this.mainContainer.classList.add('bzgfe-main-container') this.nodesContainer = document.createElement('div') this.nodesContainer.classList.add('bzgfe-nodes-container') this.mainContainer.append(this.nodesContainer) this.slidePane = document.createElement('bz-slidepane') this.slidePane.setAttribute('side', 'right') this.slidePane.setAttribute('data-output', 'console') this.slidePane.setAttribute('maxwidth', '350') this.slidePane.setAttribute('minwidth', '200') this.fillconsole() //this.mainContainer.append(this.slidePane) this.graflow = document.createElement('bz-graflow') this.graflow.setAttribute('nodes', nodesUrl) this.graflow.setAttribute('edit', "nodesmove,editwires,dropnodes") this.graflow.setAttribute('align', "center") this.graflow.setAttribute('wiretype', "bezier") this.graflow.setAttribute('tension', "30") this.graflow.setAttribute('gapx', "80") this.graflow.setAttribute('gapy', "20") this.graflow.addEventListener('bz:graflow:domConnected', this.setupDropZone.bind(this)) this.graflow.append(this.slidePane) this.mainContainer.append(this.graflow) this.append(this.mainContainer) document.querySelector('[data-trigger="onAutoplace1H"]').addEventListener('click', (evt) => { this.graflow.autoPlace('horizontal', null, null, 1000, null) } ) document.querySelector('[data-trigger="onAutoplace1V"]').addEventListener('click', (evt) => { this.graflow.autoPlace('vertical', null, null, 1000, null) } ) document.querySelector('input[name="tension"]').addEventListener('change', (evt) => { this.graflow.setAttribute('tension', evt.target.value); this.graflow.refresh() } ) document.querySelector('input[name="gapx"]').addEventListener('change', (evt) => { this.graflow.setAttribute('gapx', evt.target.value); this.graflow.refresh() } ) document.querySelector('input[name="gapy"]').addEventListener('change', (evt) => { this.graflow.setAttribute('gapy', evt.target.value); this.graflow.refresh() } ) document.querySelector('bz-select[name="wiretype"]').addEventListener('change', (evt) => { this.graflow.setAttribute('wiretype', evt.target.value); this.graflow.refresh() } ) document.querySelector('bz-select[name="align"]').addEventListener('change', (evt) => { this.graflow.setAttribute('align', evt.target.value); this.graflow.refresh() } ) this.graflow.addEventListener('bz:graflow:nodesLoaded', this.refreshNodes.bind(this)) this.graflow.loadNodes(nodesUrl) } fillconsole(){ this.slidePane.innerHTML = `