2017-10-02 12:32:53 +00:00
|
|
|
import Flash from '../flash';
|
2017-04-10 14:48:23 +00:00
|
|
|
import BalsamiqViewer from './balsamiq/balsamiq_viewer';
|
2019-04-30 17:21:39 +00:00
|
|
|
import { __ } from '~/locale';
|
2017-04-08 04:18:37 +00:00
|
|
|
|
2017-05-15 07:48:54 +00:00
|
|
|
function onError() {
|
2019-04-30 17:21:39 +00:00
|
|
|
const flash = new Flash(__('Balsamiq file could not be loaded.'));
|
2017-05-15 07:48:54 +00:00
|
|
|
|
|
|
|
return flash;
|
|
|
|
}
|
|
|
|
|
2018-03-01 07:33:06 +00:00
|
|
|
export default function loadBalsamiqFile() {
|
2017-05-15 07:48:54 +00:00
|
|
|
const viewer = document.getElementById('js-balsamiq-viewer');
|
|
|
|
|
|
|
|
if (!(viewer instanceof Element)) return;
|
|
|
|
|
2018-06-16 21:50:13 +00:00
|
|
|
const { endpoint } = viewer.dataset;
|
2017-05-15 07:48:54 +00:00
|
|
|
|
|
|
|
const balsamiqViewer = new BalsamiqViewer(viewer);
|
|
|
|
balsamiqViewer.loadFile(endpoint).catch(onError);
|
|
|
|
}
|