diff options
author | Mike Greiling <mike@pixelcog.com> | 2018-03-01 11:11:07 +0300 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2018-03-01 20:29:26 +0300 |
commit | 9d9d0105947e4cc23f150135e0c904d6ad31f315 (patch) | |
tree | 92c7f7dcf5d1b079e5e39d66832d05d1f8b1ca05 /app | |
parent | 4e86a7378cd96ffebfb1c128c9fcb614ee479ffe (diff) |
migrate sketch_viewer to dynamic import
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/blob/sketch_viewer.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/blob/viewer/index.js | 3 | ||||
-rw-r--r-- | app/views/projects/blob/viewers/_sketch.html.haml | 4 |
3 files changed, 5 insertions, 6 deletions
diff --git a/app/assets/javascripts/blob/sketch_viewer.js b/app/assets/javascripts/blob/sketch_viewer.js index 0640dd26855..2c1c6339fdb 100644 --- a/app/assets/javascripts/blob/sketch_viewer.js +++ b/app/assets/javascripts/blob/sketch_viewer.js @@ -1,8 +1,8 @@ /* eslint-disable no-new */ import SketchLoader from './sketch'; -document.addEventListener('DOMContentLoaded', () => { +export default () => { const el = document.getElementById('js-sketch-viewer'); new SketchLoader(el); -}); +}; diff --git a/app/assets/javascripts/blob/viewer/index.js b/app/assets/javascripts/blob/viewer/index.js index b227cf38920..ac18e6fb9f9 100644 --- a/app/assets/javascripts/blob/viewer/index.js +++ b/app/assets/javascripts/blob/viewer/index.js @@ -38,6 +38,9 @@ export default class BlobViewer { case 'pdf': initViewer(import(/* webpackChunkName: 'pdf_viewer' */ '../pdf_viewer')); break; + case 'sketch': + initViewer(import(/* webpackChunkName: 'sketch_viewer' */ '../sketch_viewer')); + break; default: break; } diff --git a/app/views/projects/blob/viewers/_sketch.html.haml b/app/views/projects/blob/viewers/_sketch.html.haml index 8fb67c819c1..b4b6492b92f 100644 --- a/app/views/projects/blob/viewers/_sketch.html.haml +++ b/app/views/projects/blob/viewers/_sketch.html.haml @@ -1,7 +1,3 @@ -- content_for :page_specific_javascripts do - = webpack_bundle_tag('common_vue') - = webpack_bundle_tag('sketch_viewer') - .file-content#js-sketch-viewer{ data: { endpoint: blob_raw_path } } .js-loading-icon.text-center.prepend-top-default.append-bottom-default.js-loading-icon{ 'aria-label' => 'Loading Sketch preview' } = icon('spinner spin 2x', 'aria-hidden' => 'true'); |