Skip to content

Commit 993c04a

Browse files
committed
wegue-oss#122 Share Button w dropdown for Copy URL and Embed
1 parent 850c10b commit 993c04a

File tree

1 file changed

+73
-24
lines changed

1 file changed

+73
-24
lines changed

src/components/sharebutton/ShareButton.vue

+73-24
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,56 @@
11
<template>
2-
<div>
3-
<div>
4-
<v-btn icon :dark="dark" @click="onClick">
5-
<v-icon medium>{{icon}}</v-icon>
6-
{{text}}
7-
</v-btn>
8-
<textarea id="permalinkurl" ref="permalinkurl" style="display: none; position: relative"></textarea>
2+
<div class="text-xs-center">
3+
<v-menu>
4+
<template #activator="{ on: menu }">
5+
<v-tooltip bottom>
6+
<template #activator="{ on: tooltip }">
7+
<v-btn icon :dark="dark" v-on="{ ...tooltip, ...menu }">
8+
<v-icon medium>{{icon}}</v-icon>
9+
{{text}}
10+
</v-btn>
11+
<textarea id="textstore" ref="textstore" style="display: none; position: relative"></textarea>
12+
</template>
13+
<span>{{hoverText}}</span>
14+
</v-tooltip>
15+
</template>
16+
<v-list>
17+
<v-list-tile
18+
v-for="(item, index) in items"
19+
:key="index"
20+
@click="onClick(item.action)"
21+
>
22+
<v-list-tile-title>{{ item.title }}</v-list-tile-title>
23+
</v-list-tile>
24+
</v-list>
25+
</v-menu>
26+
<v-alert
27+
class="wgu-alert"
28+
:value="alert"
29+
:dark="dark"
30+
type="info"
31+
transition="fade-transition"
32+
>
33+
{{alertText}}
34+
</v-alert>
935
</div>
10-
<v-alert
11-
class="wgu-alert"
12-
:value="alert"
13-
:dark="dark"
14-
type="info"
15-
transition="fade-transition"
16-
>
17-
{{alertText}}
18-
</v-alert>
19-
</div>
36+
<!-- <div>-->
37+
<!-- <div>-->
38+
<!-- <v-btn icon :dark="dark" @click="onClick">-->
39+
<!-- <v-icon medium>{{icon}}</v-icon>-->
40+
<!-- {{text}}-->
41+
<!-- </v-btn>-->
42+
<!-- <textarea id="textstore" ref="textstore" style="display: none; position: relative"></textarea>-->
43+
<!-- </div>-->
44+
<!-- <v-alert-->
45+
<!-- class="wgu-alert"-->
46+
<!-- :value="alert"-->
47+
<!-- :dark="dark"-->
48+
<!-- type="info"-->
49+
<!-- transition="fade-transition"-->
50+
<!-- >-->
51+
<!-- {{alertText}}-->
52+
<!-- </v-alert>-->
53+
<!-- </div>-->
2054
</template>
2155

2256
<script>
@@ -29,17 +63,23 @@ export default {
2963
props: {
3064
icon: {type: String, required: false, default: 'share'},
3165
text: {type: String, required: false, default: ''},
32-
alertText: {type: String, required: false, default: 'Link copied!'},
33-
alertTimeMillis: {type: Number, required: false, default: 750},
66+
hoverText: {type: String, required: false, default: 'Share permalink'},
67+
alertText: {type: String, required: false, default: 'Copied'},
68+
alertTimeMillis: {type: Number, required: false, default: 1000},
3469
dark: {type: Boolean, required: false, default: false}
3570
},
3671
data () {
3772
return {
38-
alert: false
73+
alert: false,
74+
items: [
75+
{ title: 'Copy URL', action: 'copy' },
76+
{ title: 'Copy HTML Embed Code', action: 'embed' }
77+
// { title: 'Email URL', action: 'email' }
78+
]
3979
}
4080
},
4181
methods: {
42-
onClick () {
82+
onClick (action) {
4383
// Get permalink URL and copy to clipboard
4484
const permalinkController = this.map.get('permalinkcontroller');
4585
if (!permalinkController) {
@@ -49,11 +89,20 @@ export default {
4989
try {
5090
// Copy to clipboard: selected text needs to be visible so
5191
// toggle textarea short time
52-
const url = permalinkController.getShareUrl();
53-
const textArea = this.$refs.permalinkurl;
92+
let text;
93+
94+
if (action === 'copy') {
95+
text = permalinkController.getShareUrl();
96+
} else if (action === 'embed') {
97+
text = permalinkController.getEmbedHTML();
98+
} else {
99+
console.error('no permalink controller available!');
100+
return true;
101+
}
102+
const textArea = this.$refs.textstore;
54103
// Show and select textarea
55104
textArea.style.display = 'block';
56-
textArea.value = url;
105+
textArea.value = text;
57106
textArea.select();
58107
59108
// Copy to clipboard

0 commit comments

Comments
 (0)