2021-08-03 06:15:11 +00:00
|
|
|
<template>
|
|
|
|
<v-tooltip
|
|
|
|
ref="copyToolTip"
|
|
|
|
v-model="show"
|
|
|
|
color="success lighten-1"
|
|
|
|
top
|
|
|
|
:open-on-hover="false"
|
|
|
|
:open-on-click="true"
|
|
|
|
close-delay="500"
|
|
|
|
transition="slide-y-transition"
|
|
|
|
>
|
|
|
|
<template #activator="{ on }">
|
|
|
|
<v-btn
|
2021-10-05 04:16:37 +00:00
|
|
|
:icon="icon"
|
2021-08-03 06:15:11 +00:00
|
|
|
:color="color"
|
|
|
|
retain-focus-on-click
|
2021-11-05 02:15:23 +00:00
|
|
|
:class="btnClass"
|
2021-08-03 06:15:11 +00:00
|
|
|
@click="
|
|
|
|
on.click;
|
|
|
|
textToClipboard();
|
|
|
|
"
|
|
|
|
@blur="on.blur"
|
|
|
|
>
|
|
|
|
<v-icon>{{ $globals.icons.contentCopy }}</v-icon>
|
2021-10-05 04:16:37 +00:00
|
|
|
{{ icon ? "" : "Copy" }}
|
2021-08-03 06:15:11 +00:00
|
|
|
</v-btn>
|
|
|
|
</template>
|
|
|
|
<span>
|
|
|
|
<v-icon left dark>
|
|
|
|
{{ $globals.icons.clipboardCheck }}
|
|
|
|
</v-icon>
|
|
|
|
<slot> {{ $t("general.copied") }}! </slot>
|
|
|
|
</span>
|
|
|
|
</v-tooltip>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
copyText: {
|
2021-08-08 00:49:55 +00:00
|
|
|
type: String,
|
2021-08-03 06:15:11 +00:00
|
|
|
default: "Default Copy Text",
|
|
|
|
},
|
|
|
|
color: {
|
2021-08-08 00:49:55 +00:00
|
|
|
type: String,
|
2021-08-03 06:15:11 +00:00
|
|
|
default: "primary",
|
|
|
|
},
|
2021-10-05 04:16:37 +00:00
|
|
|
icon: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true,
|
|
|
|
},
|
2021-11-05 02:15:23 +00:00
|
|
|
btnClass: {
|
|
|
|
type: String,
|
|
|
|
default: "",
|
|
|
|
},
|
2021-08-03 06:15:11 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
show: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
toggleBlur() {
|
|
|
|
this.$refs.copyToolTip.deactivate();
|
|
|
|
},
|
|
|
|
textToClipboard() {
|
|
|
|
this.show = true;
|
|
|
|
const copyText = this.copyText;
|
|
|
|
navigator.clipboard.writeText(copyText).then(
|
|
|
|
() => console.log("Copied", copyText),
|
|
|
|
() => console.log("Copied Failed", copyText)
|
|
|
|
);
|
|
|
|
setTimeout(() => {
|
|
|
|
this.toggleBlur();
|
|
|
|
}, 500);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
</style>
|