META-INF.resources.js.DiagramWithAutomapping.D3Handler.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.commerce.shop.by.diagram.web
Show all versions of com.liferay.commerce.shop.by.diagram.web
Liferay Commerce Shop by Diagram Web
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
import {select as d3select} from 'd3';
import {fetch} from 'frontend-js-web';
import DiagramZoomHandler from '../utilities/DiagramZoomHandler';
class D3Handler extends DiagramZoomHandler {
constructor(
diagramWrapper,
imageURL,
isAdmin,
pinsCSSSelectors,
updateLabels,
updateZoomState,
zoomWrapper
) {
super();
this._currentScale = 1;
this._diagramWrapper = diagramWrapper;
this._d3diagramWrapper = d3select(diagramWrapper);
this._d3zoomWrapper = d3select(zoomWrapper);
this._imageURL = imageURL;
this._isAdmin = isAdmin;
this._updateLabels = updateLabels;
this._pinBackground = null;
this._pinsCSSSelectors = pinsCSSSelectors;
this._updateZoomState = updateZoomState;
this._zoomWrapper = zoomWrapper;
this._handleZoom = this._handleZoom.bind(this);
this.rendered = false;
this._printSVGImage().then(() => {
this.rendered = true;
this._addZoom();
this._updatePinsState();
});
}
_printSVGImage() {
return fetch(this._imageURL)
.then((response) => response.text())
.then((svContent) => {
return svContent
.replace(/