diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-05-15 10:48:54 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-05-15 10:48:54 +0300 |
commit | b504b09b682e8b2bf65e3f027308f19bc0d688e9 (patch) | |
tree | 0c775f9887bda4009cac8ae1b09cd4a72fdbda7f /app/assets/javascripts/blob/balsamiq_viewer.js | |
parent | c48554edc24fcdddd4af374ff99f5953a5e672d4 (diff) |
Added balsamiq jasmine integration test
Diffstat (limited to 'app/assets/javascripts/blob/balsamiq_viewer.js')
-rw-r--r-- | app/assets/javascripts/blob/balsamiq_viewer.js | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/app/assets/javascripts/blob/balsamiq_viewer.js b/app/assets/javascripts/blob/balsamiq_viewer.js index 1dacf84470f..8641a6fdae6 100644 --- a/app/assets/javascripts/blob/balsamiq_viewer.js +++ b/app/assets/javascripts/blob/balsamiq_viewer.js @@ -1,6 +1,22 @@ +/* global Flash */ + import BalsamiqViewer from './balsamiq/balsamiq_viewer'; -document.addEventListener('DOMContentLoaded', () => { - const balsamiqViewer = new BalsamiqViewer(document.getElementById('js-balsamiq-viewer')); - balsamiqViewer.loadFile(); -}); +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); |