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';
|
2017-04-08 04:18:37 +00:00
|
|
|
|
2017-05-15 07:48:54 +00:00
|
|
|
function onError() {
|
2017-10-02 12:32:53 +00:00
|
|
|
const flash = new Flash('Balsamiq file could not be loaded.');
|
2017-05-15 07:48:54 +00:00
|
|
|
|
|
|
|
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);
|