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

function onError() {
  const flash = new Flash(__('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);
}