wikijs-fork/client/js/components/anchor.vue

56 lines
1.6 KiB
Vue
Raw Normal View History

2017-05-22 17:32:52 +00:00
<template lang="pug">
2017-05-27 02:43:34 +00:00
transition(:duration="400")
.modal(v-show='isShown', v-cloak)
transition(name='modal-background')
.modal-background(v-show='isShown')
.modal-container
transition(name='modal-content')
.modal-content(v-show='isShown')
header.is-blue
span Copy link to this section
section
p.control.is-fullwidth
input.input(type='text', ref='anchorURLinput', v-model='anchorURL')
footer
a.button.is-grey.is-outlined(v-on:click='cancel') Discard
a.button.is-blue(v-clipboard='anchorURL', @success="clipboardSuccess", @error="clipboardError") Copy to Clipboard
2017-05-21 03:21:16 +00:00
</template>
<script>
export default {
name: 'anchor',
data () {
2017-05-22 17:32:52 +00:00
return {}
},
computed: {
anchorURL () {
return window.location.href.split('#')[0] + '#' + this.$store.state.anchor.hash
},
isShown () {
return this.$store.state.anchor.shown
}
},
methods: {
cancel () {
this.$store.dispatch('anchorClose')
},
clipboardSuccess () {
this.$store.dispatch('alert', {
style: 'blue',
icon: 'clipboard',
msg: 'The URL has been copied to your clipboard.'
})
this.$store.dispatch('anchorClose')
},
clipboardError () {
this.$store.dispatch('alert', {
style: 'red',
icon: 'clipboard',
msg: 'Clipboard copy failed. Copy the URL manually.'
})
this.$refs.anchorURLinput.select()
2017-05-21 03:21:16 +00:00
}
}
}
</script>