Skip to content

Commit

Permalink
auto-url features
Browse files Browse the repository at this point in the history
It's now possible to share the current url with the auto-url attribute.

Small fixes & doc update

V2.1.0
  • Loading branch information
MacTheZazou committed Mar 9, 2017
1 parent 96e5353 commit 3f99f4d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "paper-share-button",
"version": "2.0.0",
"version": "2.1.0",
"description": "A Material Design sharing button (Polymer 1.x)",
"authors": [
"Zaccharie Jacquat"
],
"repository": {
"type": "git",
"url": "git://github.com/MacTheZazou/paper-share-button.git"
"url": "git://github.com/koada-os/paper-share-button.git"
},
"main": "paper-share-button.html",
"dependencies": {
Expand Down
6 changes: 6 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ <h3>paper-share-button can open popup w/ compatible social media (Not working in
<paper-share-button popup url="https://www.webcomponents.org/" facebook google twitter></paper-share-button>
</template>
</demo-snippet>
<h3>paper-share-button can share the actual url</h3>
<demo-snippet>
<template>
<paper-share-button auto-url twitter facebook></paper-share-button>
</template>
</demo-snippet>
</div>
</body>
</html>
18 changes: 13 additions & 5 deletions paper-share-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@
url: {
type: String
},
/** Use window.location.href as url. (Only if the url is not set) */
autoUrl: {
type: Boolean
},
/** The icon for the button (share icon by default)*/
buttonIcon: {
type: String,
Expand Down Expand Up @@ -197,25 +201,29 @@
value: false
}
},

_share: function(event) {
var element = Polymer.dom(event).localTarget;
if (!this.url && this.autoUrl) {
this.url = window.location.href;
}
if (this.url) {
if (this.popup) {
switch (element.icon) {
case 'brand:facebook':
this._openPopup(element.href, 'Sharing', 600, 375);
this._openPopup(element.getAttribute('href'), 'Sharing', 600, 375);
break;
case 'brand:google':
this._openPopup(element.href, 'Sharing', 400, 445);
this._openPopup(element.getAttribute('href'), 'Sharing', 400, 445);
break;
case 'brand:twitter':
this._openPopup(element.href, 'Sharing', 500, 230);
this._openPopup(element.getAttribute('href'), 'Sharing', 500, 230);
break;
default:
window.open(element.href, 'Sharing');
window.open(element.getAttribute('href'), 'Sharing');
}
} else {
window.open(element.href, 'Sharing');
window.open(element.getAttribute('href'), 'Sharing');
}
} else {
console.error("Impossible to share, no url set");
Expand Down

0 comments on commit 3f99f4d

Please sign in to comment.