Spookie/assets/app.js

68 lines
2.0 KiB
JavaScript
Raw Normal View History

2022-10-28 18:48:25 +02:00
/*
* Welcome to your app's main JavaScript file!
*
* We recommend including the built version of this JavaScript file
* (and its CSS file) in your base layout (base.html.twig).
*/
// any CSS you import will output into a single css file (app.css in this case)
2022-11-03 18:52:50 +01:00
import 'fork-awesome/scss/fork-awesome.scss'
import './styles/app.scss'
import $ from 'jquery'
import 'bootstrap'
2022-11-10 13:48:29 +01:00
// Dropzone stuff move to component
import {Dropzone} from 'dropzone'
// 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
2022-11-03 18:52:50 +01:00
//import './js/index'
// needed for legacy code
//global.$ = $
2022-10-28 18:48:25 +02:00
2022-11-03 18:52:50 +01:00
if (window.matchMedia('(prefers-color-scheme)').media !== 'not all') {
2022-11-10 13:48:29 +01:00
console.log('🎉 Dark mode is supported')
2022-11-03 18:52:50 +01:00
}
$(document).ready(() => {
2022-11-10 13:48:29 +01:00
console.log('ready')
$('#toggleSidebar').on('click', () => {
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-right')
$('#sidebar').toggleClass('active')
})
2022-11-03 18:52:50 +01:00
})
2022-11-10 13:48:29 +01:00
2022-10-28 18:48:25 +02:00
// start the Stimulus application
2022-11-03 18:52:50 +01:00
//import './bootstrap'