summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/blob/balsamiq_viewer.js
blob: af8e8a4cd3d081b899dc15b0c34bd80274f14a60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import createFlash from '~/flash';
import { __ } from '~/locale';
import BalsamiqViewer from './balsamiq/balsamiq_viewer';

function onError() {
  const flash = createFlash({
    message: __('Balsamiq file could not be loaded.'),
  });

  return flash;
}

export default function loadBalsamiqFile() {
  const viewer = document.getElementById('js-balsamiq-viewer');

  if (!(viewer instanceof Element)) return;

  const { endpoint } = viewer.dataset;

  const balsamiqViewer = new BalsamiqViewer(viewer);
  balsamiqViewer.loadFile(endpoint).catch(onError);
}