Added Twitter sharing texts

This commit is contained in:
Moritz Kröger 2017-08-29 00:17:48 +02:00
parent ea9e1006ad
commit 9c435af684
2 changed files with 35 additions and 6 deletions

View file

@ -46,6 +46,11 @@
privacy: 'Datenschutz'
},
socialMedia: {
twitter: {
text: 'Cool! BTW17 kann jetzt auch Sterne. Neugierig was die Parteien zur EU sagen? Mach den EUROMAT & finde heraus mit wem du übereinstimmst!',
hashtags: 'BTW17,EUROMAT'
},
facebook: 'Cool! #BTW17 kann jetzt auch Sterne. Neugierig was die Parteien zur EU sagen? Mach den #EUROMAT & finde heraus mit wem du übereinstimmst!',
clipboard: 'In Zwischenablage kopiert'
}
},
@ -62,6 +67,11 @@
privacy: 'Data privacy'
},
socialMedia: {
twitter: {
text: 'Great! GermanElections are now star-spangled. Curious what parties say about EU? Compare your views w/EUROMAT & see who you match up with!',
hashtags: 'GermanElections,EUROMAT'
},
facebook: 'Great! #GermanElections are now star-spangled. Curious what parties say about EU? Compare your views w/#EUROMAT & see who you match up with!',
clipboard: 'Copied to clipboard'
}
}
@ -121,9 +131,24 @@
},
socialMedia () {
return [
{ label: 'twitter', icon: 'twitter', message: '' },
{ label: 'facebook', icon: 'facebook', message: '' },
{ label: 'clipboard', icon: 'clipboard', message: this.$t('socialMedia.clipboard') }
{
label: 'twitter',
icon: 'twitter',
message: {
text: this.$t('socialMedia.twitter.text'),
hashtags: this.$t('socialMedia.twitter.hashtags')
}
},
{
label: 'facebook',
icon: 'facebook',
message: this.$t('socialMedia.facebook')
},
{
label: 'clipboard',
icon: 'clipboard',
message: this.$t('socialMedia.clipboard')
}
]
}
}

View file

@ -52,6 +52,11 @@
top: ((height / 2) - (h / 2)) + dualScreenTop
}
},
constructTwitterURL (message) {
const { text, hashtags } = message
const url = 'https://twitter.com/intent/tweet'
return `${url}?text=${encodeURI(text)}&hashtags=${hashtags}&url=${this.shareURL}`
},
share (social) {
switch (social.label.toLowerCase()) {
case 'twitter': return this.shareViaTwitter(social.message)
@ -60,13 +65,12 @@
default: return
}
},
shareViaTwitter () {
const url = 'https://twitter.com/intent/tweet'
shareViaTwitter (message) {
const frameName = 'Post a Tweet on Twitter'
const { width, height, left, top } = this.getPopupDimensions()
const options = `resizable,scrollbars,width=${width},height=${height},top=${top},left=${left}`
const popup = window.open(url, frameName, options)
const popup = window.open(this.constructTwitterURL(message), frameName, options)
if (window.focus) {
popup.focus()
}