mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Clean up code
- Set dropzoneOptions.url to arrow function which returns empty string... url is required, but we don't use a restful api, we crop the image and save the update file(blob) to an image - set min-height of vuedropzone to 500px to be closer to the cropped image and to center image overlay - remove dz-message div, as one is already created automatically by vue2-dropzone
This commit is contained in:
parent
2818b63fe9
commit
cabd68f7d8
@ -9,22 +9,20 @@
|
|||||||
@vdropzone-thumbnail="transformImage"
|
@vdropzone-thumbnail="transformImage"
|
||||||
@vdropzone-drop="dropzoneDrop"
|
@vdropzone-drop="dropzoneDrop"
|
||||||
>
|
>
|
||||||
<div class="dz-message">
|
<div
|
||||||
|
:class="{
|
||||||
|
'hc-attachments-upload-area-post': true,
|
||||||
|
'hc-attachments-upload-area-update-post': contribution,
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<slot></slot>
|
||||||
<div
|
<div
|
||||||
:class="{
|
:class="{
|
||||||
'hc-attachments-upload-area-post': true,
|
'hc-drag-marker-post': true,
|
||||||
'hc-attachments-upload-area-update-post': contribution,
|
'hc-drag-marker-update-post': contribution,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<slot></slot>
|
<ds-icon name="image" size="xxx-large" />
|
||||||
<div
|
|
||||||
:class="{
|
|
||||||
'hc-drag-marker-post': true,
|
|
||||||
'hc-drag-marker-update-post': contribution,
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<ds-icon name="image" size="xxx-large" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</vue-dropzone>
|
</vue-dropzone>
|
||||||
@ -45,7 +43,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
dropzoneOptions: {
|
dropzoneOptions: {
|
||||||
url: this.addTeaserImage,
|
url: () => '',
|
||||||
maxFilesize: 5.0,
|
maxFilesize: 5.0,
|
||||||
previewTemplate: this.template(),
|
previewTemplate: this.template(),
|
||||||
},
|
},
|
||||||
@ -73,15 +71,11 @@ export default {
|
|||||||
this.error = true
|
this.error = true
|
||||||
this.$toast.error(file.status, message)
|
this.$toast.error(file.status, message)
|
||||||
},
|
},
|
||||||
addTeaserImage(file) {
|
|
||||||
this.$emit('addTeaserImage', file[0])
|
|
||||||
return ''
|
|
||||||
},
|
|
||||||
transformImage(file) {
|
transformImage(file) {
|
||||||
let thumbnailElement, editor, confirm, thumbnailPreview, contributionImage
|
let thumbnailElement, editor, confirm, thumbnailPreview, contributionImage
|
||||||
// Create the image editor overlay
|
// Create the image editor overlay
|
||||||
editor = document.createElement('div')
|
editor = document.createElement('div')
|
||||||
thumbnailElement = document.querySelectorAll('.dz-image')[0]
|
thumbnailElement = document.querySelectorAll('#postdropzone')[0]
|
||||||
thumbnailPreview = document.querySelectorAll('.thumbnail-preview')[0]
|
thumbnailPreview = document.querySelectorAll('.thumbnail-preview')[0]
|
||||||
if (thumbnailPreview) thumbnailPreview.remove()
|
if (thumbnailPreview) thumbnailPreview.remove()
|
||||||
contributionImage = document.querySelectorAll('.contribution-image')[0]
|
contributionImage = document.querySelectorAll('.contribution-image')[0]
|
||||||
@ -106,7 +100,7 @@ export default {
|
|||||||
thumbnailElement.appendChild(image)
|
thumbnailElement.appendChild(image)
|
||||||
// Remove the editor from view
|
// Remove the editor from view
|
||||||
editor.parentNode.removeChild(editor)
|
editor.parentNode.removeChild(editor)
|
||||||
this.addTeaserImage([blob])
|
this.$emit('addTeaserImage', blob)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
editor.appendChild(confirm)
|
editor.appendChild(confirm)
|
||||||
@ -128,7 +122,7 @@ export default {
|
|||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
#postdropzone {
|
#postdropzone {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 300px;
|
min-height: 500px;
|
||||||
background-color: $background-color-softest;
|
background-color: $background-color-softest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,10 +158,10 @@ export default {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
margin: 180px 5px;
|
||||||
color: hsl(0, 0%, 25%);
|
color: hsl(0, 0%, 25%);
|
||||||
transition: all 0.2s ease-out;
|
transition: all 0.2s ease-out;
|
||||||
font-size: 60px;
|
font-size: 60px;
|
||||||
margin: 180px 5px;
|
|
||||||
background-color: $background-color-softest;
|
background-color: $background-color-softest;
|
||||||
opacity: 0.65;
|
opacity: 0.65;
|
||||||
|
|
||||||
@ -208,11 +202,11 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.contribution-image {
|
.contribution-image {
|
||||||
max-height: 620px;
|
max-height: 710px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.crop-overlay {
|
.crop-overlay {
|
||||||
max-height: 620px;
|
max-height: 710px;
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
// height: 100%;
|
// height: 100%;
|
||||||
@ -227,6 +221,6 @@ export default {
|
|||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
}
|
}
|
||||||
.thumbnail-preview {
|
.thumbnail-preview {
|
||||||
max-height: 620px;
|
max-height: 710px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user