Vue.component('tt-modal', { props: { show: {type: [Boolean, Object], default: false}, title: {type: String, default: 'Überschrift'}, delete: {type: Boolean, default: true}, deleteText: {type: String, default: 'Löschen'}, save: {type: Boolean, default: true}, saveLoading: {type: Boolean, default: false}, saveText: {type: String, default: 'Speichern'}, disableMinHeight: {type: Boolean, default: false}, }, watch: { show(newVal) { if (!newVal) { this.$emit('close') } if (newVal) { this.$nextTick(() => { const input = this.$refs.modal.querySelector('input') if (input) { if (input.classList.contains('tt-autocomplete')) { return } input.focus() } }) } }, }, // create global listener for esc + return key (if save is enabled) created() { document.addEventListener('keydown', this.keydownHandler) }, destroyed() { document.removeEventListener('keydown', this.keydownHandler) }, methods: { keydownHandler(event) { if (!this.show) { return } if (event.key === 'Escape') { this.$emit('update:show', false) } if (event.key === 'Enter' && this.save) { if (event.target.tagName === 'TEXTAREA' || event.target.tagName === 'INPUT') { return } this.$emit('submit') } } }, data() { return {window: window, isMobile: navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i) !== null} }, //language=Vue template: ` ` })