metamaps--metamaps/frontend/src/Metamaps/GlobalUI/ImportDialog.js

48 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-10-08 00:31:32 +08:00
/* global $ */
import React from 'react'
import ReactDOM from 'react-dom'
import outdent from 'outdent'
import ImportDialogBox from '../../components/ImportDialogBox'
import PasteInput from '../PasteInput'
import Map from '../Map'
const ImportDialog = {
openLightbox: null,
closeLightbox: null,
2016-11-07 15:25:08 -05:00
init: function(serverData, openLightbox, closeLightbox) {
const self = ImportDialog
self.openLightbox = openLightbox
self.closeLightbox = closeLightbox
$('#lightbox_content').append($(outdent`
<div class="lightboxContent" id="import-dialog-lightbox">
<div class="importDialogWrapper" />
</div>
`))
ReactDOM.render(React.createElement(ImportDialogBox, {
onFileAdded: PasteInput.handleFile,
exampleImageUrl: serverData['import-example.png'],
downloadScreenshot: ImportDialog.downloadScreenshot,
2017-03-07 16:55:15 +00:00
onExport: format => () => {
window.open(`${window.location.pathname}/export.${format}`, '_blank')
}
}), $('.importDialogWrapper').get(0))
},
2016-11-07 15:25:08 -05:00
show: function() {
2016-10-08 00:31:32 +08:00
ImportDialog.openLightbox('import-dialog')
},
2016-11-07 15:25:08 -05:00
hide: function() {
ImportDialog.closeLightbox()
},
downloadScreenshot: function() {
ImportDialog.hide()
Map.offerScreenshotDownload()
}
}
export default ImportDialog