2021-09-30 23:02:18 +05:30
|
|
|
import createFlash from '~/flash';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { __ } from '~/locale';
|
2017-08-17 22:00:37 +05:30
|
|
|
import BalsamiqViewer from './balsamiq/balsamiq_viewer';
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
function onError() {
|
2021-09-30 23:02:18 +05:30
|
|
|
const flash = createFlash({
|
|
|
|
message: __('Balsamiq file could not be loaded.'),
|
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
return flash;
|
|
|
|
}
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
export default function loadBalsamiqFile() {
|
2017-09-10 17:25:29 +05:30
|
|
|
const viewer = document.getElementById('js-balsamiq-viewer');
|
|
|
|
|
|
|
|
if (!(viewer instanceof Element)) return;
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
const { endpoint } = viewer.dataset;
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
const balsamiqViewer = new BalsamiqViewer(viewer);
|
|
|
|
balsamiqViewer.loadFile(endpoint).catch(onError);
|
|
|
|
}
|