2016-10-08 00:31:32 +08:00
|
|
|
/* global $ */
|
|
|
|
|
2016-09-25 00:27:04 +08:00
|
|
|
import React from 'react'
|
|
|
|
import ReactDOM from 'react-dom'
|
|
|
|
import outdent from 'outdent'
|
|
|
|
|
|
|
|
import ImportDialogBox from '../../components/ImportDialogBox'
|
|
|
|
|
|
|
|
import PasteInput from '../PasteInput'
|
2017-01-19 14:50:08 -05:00
|
|
|
import Map from '../Map'
|
2016-09-25 00:27:04 +08:00
|
|
|
|
|
|
|
const ImportDialog = {
|
|
|
|
openLightbox: null,
|
|
|
|
closeLightbox: null,
|
|
|
|
|
2016-11-07 15:25:08 -05:00
|
|
|
init: function(serverData, openLightbox, closeLightbox) {
|
2016-09-25 00:27:04 +08:00
|
|
|
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,
|
2017-01-19 14:50:08 -05:00
|
|
|
exampleImageUrl: serverData['import-example.png'],
|
2017-03-06 02:29:12 +08:00
|
|
|
downloadScreenshot: ImportDialog.downloadScreenshot,
|
2017-03-07 16:55:15 +00:00
|
|
|
onExport: format => () => {
|
2017-03-06 02:29:12 +08:00
|
|
|
window.open(`${window.location.pathname}/export.${format}`, '_blank')
|
|
|
|
}
|
2016-09-25 00:27:04 +08:00
|
|
|
}), $('.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-09-25 00:27:04 +08:00
|
|
|
},
|
2016-11-07 15:25:08 -05:00
|
|
|
hide: function() {
|
2017-01-19 14:50:08 -05:00
|
|
|
ImportDialog.closeLightbox()
|
|
|
|
},
|
|
|
|
downloadScreenshot: function() {
|
|
|
|
ImportDialog.hide()
|
|
|
|
Map.offerScreenshotDownload()
|
2016-09-25 00:27:04 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ImportDialog
|