1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-21 21:30:08 +00:00

Disable attachment button when input is not empty

This commit is contained in:
Maximilian Mader 2020-11-01 17:06:02 +01:00
parent 5439c325af
commit 5ed54335a1
Signed by: Max
GPG Key ID: F71D56A3151C4FB3
2 changed files with 18 additions and 2 deletions

View File

@ -385,6 +385,12 @@ #tpl_chat_log {
flex-shrink: 0;
margin-right: 5px;
@include screen-xs {
> .disabled {
display: none;
}
}
.icon16 {
display: none;
}

View File

@ -23,9 +23,9 @@ define([ 'WoltLabSuite/Core/Language'
const DIALOG_BUTTON_ID = 'chatAttachmentUploadButton'
const DIALOG_CONTAINER_ID = 'chatAttachmentUploadDialog'
const DEPENDENCIES = [ 'Room' ];
const DEPENDENCIES = [ 'UiInput', 'Room' ];
class UiAttachmentUpload extends Upload {
constructor(room) {
constructor(input, room) {
const buttonContainer = document.querySelector(`#${DIALOG_CONTAINER_ID} > .upload`)
const buttonContainerId = DomUtil.identify(buttonContainer)
@ -37,6 +37,7 @@ define([ 'WoltLabSuite/Core/Language'
acceptableFiles: [ '.png', '.gif', '.jpg', '.jpeg' ]
})
this.input = input
this.room = room
this.previewContainer = previewContainer
this.tmpHash = undefined
@ -64,6 +65,15 @@ define([ 'WoltLabSuite/Core/Language'
const deleteAction = new WCF.Action.Delete('wcf\\data\\attachment\\AttachmentAction', `#${this.previewContainer.id} > p`)
deleteAction.setCallback(() => this.closeDialog())
this.input.on('input', (event) => {
if (event.target.input.value.length == 0) {
button.classList.remove('disabled')
}
else {
button.classList.add('disabled')
}
})
}
}