summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/blob/balsamiq_viewer.js
blob: 8641a6fdae6e513d12d0ef4e6e8d4623bbf5d477 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* global Flash */

import BalsamiqViewer from './balsamiq/balsamiq_viewer';

function onError() {
  const flash = new window.Flash('Balsamiq file could not be loaded.');

  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);