From da92ac245aa3f6c7475c071487b3a075f49b33b1 Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Fri, 8 Apr 2016 23:05:19 +0200 Subject: [PATCH] Open Facebook and Twitter sharing sheet in new window --- src/scripts/album.js | 12 +++--------- src/scripts/photo.js | 12 +++--------- src/scripts/view/main.js | 12 +++--------- 3 files changed, 9 insertions(+), 27 deletions(-) diff --git a/src/scripts/album.js b/src/scripts/album.js index 961e8b1..544eb25 100644 --- a/src/scripts/album.js +++ b/src/scripts/album.js @@ -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) { diff --git a/src/scripts/photo.js b/src/scripts/photo.js index a758948..2552e7a 100644 --- a/src/scripts/photo.js +++ b/src/scripts/photo.js @@ -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) { diff --git a/src/scripts/view/main.js b/src/scripts/view/main.js index 112a545..566a605 100644 --- a/src/scripts/view/main.js +++ b/src/scripts/view/main.js @@ -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() {