refactored dropzone stuff into controller
This commit is contained in:
parent
42a4fc1d8a
commit
5247d71050
|
@ -11,57 +11,24 @@ import './styles/app.scss'
|
||||||
import $ from 'jquery'
|
import $ from 'jquery'
|
||||||
import 'bootstrap'
|
import 'bootstrap'
|
||||||
|
|
||||||
// Dropzone stuff move to component
|
// start the Stimulus application
|
||||||
import {Dropzone} from 'dropzone'
|
import './bootstrap'
|
||||||
|
|
||||||
// TODO handle error (Chapter 26)
|
|
||||||
const formElement = $('#dropzoneForm')
|
|
||||||
if (formElement) {
|
|
||||||
const previewContent = $('#preview-content').html()
|
|
||||||
console.log(previewContent)
|
|
||||||
const dropzone = new Dropzone('#dropzoneForm', {
|
|
||||||
acceptedFiles: '.jpg, .jpeg, .png',
|
|
||||||
maxFiles: 1,
|
|
||||||
init: function () {
|
|
||||||
this.hiddenFileInput.removeAttribute('multiple')
|
|
||||||
this.on('maxfilesexceeded', (file) => {
|
|
||||||
this.removeAllFiles()
|
|
||||||
this.addFile(file)
|
|
||||||
})
|
|
||||||
this.on('error', (file, data) => {
|
|
||||||
console.log('error');
|
|
||||||
if (data.detail) {
|
|
||||||
this.emit('error', file, data.detail)
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
console.log('filename', previewContent)
|
|
||||||
const mockFile = { name: previewContent }
|
|
||||||
console.log('file', mockFile)
|
|
||||||
dropzone.displayExistingFile(mockFile)
|
|
||||||
}
|
|
||||||
|
|
||||||
// End Dropzone stuff move to component
|
|
||||||
|
|
||||||
//import './js/index'
|
//import './js/index'
|
||||||
|
|
||||||
// needed for legacy code
|
// needed for legacy code
|
||||||
//global.$ = $
|
//global.$ = $
|
||||||
|
|
||||||
if (window.matchMedia('(prefers-color-scheme)').media !== 'not all') {
|
if (window.matchMedia('(prefers-color-scheme)').media !== 'not all') {
|
||||||
console.log('🎉 Dark mode is supported')
|
console.log('🎉 Dark mode is supported')
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
console.log('ready')
|
console.log('ready')
|
||||||
$('#toggleSidebar').on('click', () => {
|
$('#toggleSidebar').on('click', () => {
|
||||||
const toggleIcon = $('#toggleIcon')
|
const toggleIcon = $('#toggleIcon')
|
||||||
toggleIcon.toggleClass('fa fa-lg fa-fw fa-caret-square-o-left')
|
toggleIcon.toggleClass('fa fa-lg fa-fw fa-caret-square-o-left')
|
||||||
toggleIcon.toggleClass('fa fa-lg fa-fw fa-caret-square-o-right')
|
toggleIcon.toggleClass('fa fa-lg fa-fw fa-caret-square-o-right')
|
||||||
$('#sidebar').toggleClass('active')
|
$('#sidebar').toggleClass('active')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// start the Stimulus application
|
|
||||||
//import './bootstrap'
|
|
||||||
|
|
Loading…
Reference in New Issue