Open Facebook and Twitter sharing sheet in new window

This commit is contained in:
Tobias Reich 2016-04-08 23:05:19 +02:00
parent 9f8f3f73d8
commit da92ac245a
3 changed files with 9 additions and 27 deletions

View File

@ -509,26 +509,20 @@ album.setPublic = function(albumID, modal, e) {
album.share = function(service) {
let link = ''
let url = location.href
switch (service) {
case 'twitter':
link = `https://twitter.com/share?url=${ encodeURI(url) }`
window.open(`https://twitter.com/share?url=${ encodeURI(url) }`)
break
case 'facebook':
link = `http://www.facebook.com/sharer.php?u=${ encodeURI(url) }&t=${ encodeURI(album.json.title) }`
window.open(`http://www.facebook.com/sharer.php?u=${ encodeURI(url) }&t=${ encodeURI(album.json.title) }`)
break
case 'mail':
link = `mailto:?subject=${ encodeURI(album.json.title) }&body=${ encodeURI(url) }`
break
default:
link = ''
location.href = `mailto:?subject=${ encodeURI(album.json.title) }&body=${ encodeURI(url) }`
break
}
if (link!=='') location.href = link
}
album.getArchive = function(albumID) {

View File

@ -610,18 +610,17 @@ photo.deleteTag = function(photoID, index) {
photo.share = function(photoID, service) {
let link = ''
let url = photo.getViewLink(photoID)
switch (service) {
case 'twitter':
link = `https://twitter.com/share?url=${ encodeURI(url) }`
window.open(`https://twitter.com/share?url=${ encodeURI(url) }`)
break
case 'facebook':
link = `http://www.facebook.com/sharer.php?u=${ encodeURI(url) }&t=${ encodeURI(photo.json.title) }`
window.open(`http://www.facebook.com/sharer.php?u=${ encodeURI(url) }&t=${ encodeURI(photo.json.title) }`)
break
case 'mail':
link = `mailto:?subject=${ encodeURI(photo.json.title) }&body=${ encodeURI(url) }`
location.href = `mailto:?subject=${ encodeURI(photo.json.title) }&body=${ encodeURI(url) }`
break
case 'dropbox':
lychee.loadDropbox(function() {
@ -629,13 +628,8 @@ photo.share = function(photoID, service) {
Dropbox.save(photo.getDirectLink(), filename)
})
break
default:
link = ''
break
}
if (link!=='') location.href = link
}
photo.getArchive = function(photoID) {

View File

@ -66,26 +66,20 @@ let photo = {}
photo.share = function(photoID, service) {
let link = ''
let url = location.toString()
switch (service) {
case 'twitter':
link = `https://twitter.com/share?url=${ encodeURI(url) }`
window.open(`https://twitter.com/share?url=${ encodeURI(url) }`)
break
case 'facebook':
link = `http://www.facebook.com/sharer.php?u=${ encodeURI(url) }`
window.open(`http://www.facebook.com/sharer.php?u=${ encodeURI(url) }`)
break
case 'mail':
link = `mailto:?subject=&body=${ encodeURI(url) }`
break
default:
link = ''
location.href = `mailto:?subject=&body=${ encodeURI(url) }`
break
}
if (link!=='') location.href = link
}
photo.getDirectLink = function() {