Browse Source

Open Facebook and Twitter sharing sheet in new window

Tobias Reich 8 years ago
parent
commit
da92ac245a
3 changed files with 9 additions and 27 deletions
  1. 3 9
      src/scripts/album.js
  2. 3 9
      src/scripts/photo.js
  3. 3 9
      src/scripts/view/main.js

+ 3 - 9
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) {

+ 3 - 9
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) {

+ 3 - 9
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() {