Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 26 additions & 20 deletions dist/twitter-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,7 @@
<polymer-element name="twitter-button" attributes="text type href user hashtag height width">

<template>
<template if="{{type == 'follow'}}">
<iframe src="https://platform.twitter.com/widgets/follow_button.html?screen_name={{user}}" allowtransparency="true" frameborder="0" scrolling="no"></iframe>
</template>

<template if="{{type == 'share'}}">
<iframe src="http://platform.twitter.com/widgets/tweet_button.html?url={{href}}&amp;via={{user}}&amp;text={{text}}" allowtransparency="true" frameborder="0" scrolling="no"></iframe>
</template>

<template if="{{type == 'hashtag'}}">
<iframe src="https://platform.twitter.com/widgets/tweet_button.html?text={{text}}&amp;button_hashtag={{hashtag}}&amp;type=hashtag" allowtransparency="true" frameborder="0" scrolling="no"></iframe>
</template>

<template if="{{type == 'mention'}}">
<iframe src="https://platform.twitter.com/widgets/tweet_button.html?screen_name={{user}}&amp;type=mention" allowtransparency="true" frameborder="0" scrolling="no"></iframe>
</template>
<iframe src="{{src}}" allowtransparency="true" frameborder="0" scrolling="no"></iframe>

<style>
iframe {
Expand All @@ -31,13 +17,33 @@

<script>
Polymer('twitter-button', {
text : 'Custom Elements rocks!',
href : 'http://customelements.io',
user : 'zenorocha',
hashtag: 'customelements',
text : 'Web Components rocks!',
href : 'http://webcomponents.org',
user : 'Web_Components',
hashtag: 'webcomponents',
height : '25',
width : '115',
type : 'share'
type : 'share',
ready : function() {
if (this.type == 'follow') {
var src = 'https://platform.twitter.com/widgets/follow_button.html?screen_name=' + this.user;
} else {
var src = 'https://platform.twitter.com/widgets/tweet_button.html?text=' + encodeURIComponent(this.text);
switch (this.type) {
case 'share':
if (this.href != undefined) src += '&url=' + this.href;
src += '&via=' + this.user;
break;
case 'hashtag':
src += '&button_hashtag=' + this.hashtag + '&type=hashtag';
break;
case 'mention':
src += '&screen_name=' + this.user + '&type=mention';
break;
}
}
this.src = src;
}
});
</script>

Expand Down
38 changes: 22 additions & 16 deletions src/twitter-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,7 @@
<polymer-element name="twitter-button" attributes="text type href user hashtag height width">

<template>
<template if="{{type == 'follow'}}">
<iframe src="https://platform.twitter.com/widgets/follow_button.html?screen_name={{user}}" allowtransparency="true" frameborder="0" scrolling="no"></iframe>
</template>

<template if="{{type == 'share'}}">
<iframe src="http://platform.twitter.com/widgets/tweet_button.html?url={{href}}&amp;via={{user}}&amp;text={{text}}" allowtransparency="true" frameborder="0" scrolling="no"></iframe>
</template>

<template if="{{type == 'hashtag'}}">
<iframe src="https://platform.twitter.com/widgets/tweet_button.html?text={{text}}&amp;button_hashtag={{hashtag}}&amp;type=hashtag" allowtransparency="true" frameborder="0" scrolling="no"></iframe>
</template>

<template if="{{type == 'mention'}}">
<iframe src="https://platform.twitter.com/widgets/tweet_button.html?screen_name={{user}}&amp;type=mention" allowtransparency="true" frameborder="0" scrolling="no"></iframe>
</template>
<iframe src="{{src}}" allowtransparency="true" frameborder="0" scrolling="no"></iframe>

<style>
iframe {
Expand All @@ -37,7 +23,27 @@
hashtag: 'webcomponents',
height : '25',
width : '115',
type : 'share'
type : 'share',
ready : function() {
if (this.type == 'follow') {
var src = 'https://platform.twitter.com/widgets/follow_button.html?screen_name=' + this.user;
} else {
var src = 'https://platform.twitter.com/widgets/tweet_button.html?text=' + encodeURIComponent(this.text);
switch (this.type) {
case 'share':
if (this.href != undefined) src += '&url=' + this.href;
src += '&via=' + this.user;
break;
case 'hashtag':
src += '&button_hashtag=' + this.hashtag + '&type=hashtag';
break;
case 'mention':
src += '&screen_name=' + this.user + '&type=mention';
break;
}
}
this.src = src;
}
});
</script>

Expand Down