You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.6 KiB

  1. <template lang="pug">
  2. transition(:duration="400")
  3. .modal(v-show='isShown', v-cloak)
  4. transition(name='modal-background')
  5. .modal-background(v-show='isShown')
  6. .modal-container
  7. transition(name='modal-content')
  8. .modal-content(v-show='isShown')
  9. header.is-blue
  10. span {{ $t('modal.anchortitle') }}
  11. section
  12. p.control.is-fullwidth
  13. input.input(type='text', ref='anchorURLinput', v-model='anchorURL')
  14. footer
  15. a.button.is-grey.is-outlined(v-on:click='cancel') {{ $t('modal.discard') }}
  16. a.button.is-blue(v-clipboard='anchorURL', @success="clipboardSuccess", @error="clipboardError") {{ $t('modal.copyclipboard') }}
  17. </template>
  18. <script>
  19. export default {
  20. name: 'anchor',
  21. data () {
  22. return {}
  23. },
  24. computed: {
  25. anchorURL () {
  26. return window.location.href.split('#')[0] + '#' + this.$store.state.anchor.hash
  27. },
  28. isShown () {
  29. return this.$store.state.anchor.shown
  30. }
  31. },
  32. methods: {
  33. cancel () {
  34. this.$store.dispatch('anchor/close')
  35. },
  36. clipboardSuccess () {
  37. this.$store.dispatch('alert', {
  38. style: 'blue',
  39. icon: 'business_notes',
  40. msg: this.$t('modal.anchorsuccess')
  41. })
  42. this.$store.dispatch('anchor/close')
  43. },
  44. clipboardError () {
  45. this.$store.dispatch('alert', {
  46. style: 'red',
  47. icon: 'business_notes',
  48. msg: this.$t('modal.anchorerror')
  49. })
  50. this.$refs.anchorURLinput.select()
  51. }
  52. }
  53. }
  54. </script>