fa2af5e0f5
Reduced the technical debt around our JS flash function by making it a module that is imported rather than relying on the global function. The global function still exists mainly for technical debt with how some requests are being completed, but new JS should import the module directly. Also reduces some tech debt in the file by removing the need for jQuery. Instead Flash is now 100% vanilla JS.
21 lines
508 B
JavaScript
21 lines
508 B
JavaScript
import Flash from '../flash';
|
|
import BalsamiqViewer from './balsamiq/balsamiq_viewer';
|
|
|
|
function onError() {
|
|
const flash = new Flash('Balsamiq file could not be loaded.');
|
|
|
|
return flash;
|
|
}
|
|
|
|
function loadBalsamiqFile() {
|
|
const viewer = document.getElementById('js-balsamiq-viewer');
|
|
|
|
if (!(viewer instanceof Element)) return;
|
|
|
|
const endpoint = viewer.dataset.endpoint;
|
|
|
|
const balsamiqViewer = new BalsamiqViewer(viewer);
|
|
balsamiqViewer.loadFile(endpoint).catch(onError);
|
|
}
|
|
|
|
$(loadBalsamiqFile);
|