Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
add a share button
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Apr 2, 2014
1 parent 732aaab commit 51cb669
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<polymer-ui-icon-button src="assets/code.png" name="code"></polymer-ui-icon-button>
</polymer-selector>
<polymer-ui-icon-button icon="add" on-tap="{{saveAction}}"></polymer-ui-icon-button>
<polymer-ui-icon-button icon="shortcut" on-click="{{shareAction}}"></polymer-ui-icon-button>
</polymer-ui-toolbar>

<polymer-ui-pages flex selected="{{selected}}">
Expand Down Expand Up @@ -221,6 +222,17 @@
this.$.github.save('designer', true, options);
//}
},
shareAction: function() {
this.sharing = true;
// must open window immediately so that it opens in a tab, not a window
this.shareWindow = window.open(this.getGistUrl());
this.saveAction();
},
share: function() {
if (this.fileId && this.shareWindow) {
this.shareWindow.location.href = this.getGistUrl();
}
},
loadRemoteContent: function() {
var id = window.location.hash.replace('#', '');
if (id) {
Expand All @@ -236,6 +248,10 @@
},
documentSaved: function(event, detail) {
this.fileId = detail.id;
if (this.sharing) {
this.sharing = false;
this.share();
}
},
remoteHtmlChanged: function() {
//console.log(this.remoteHtml);
Expand All @@ -246,11 +262,15 @@
},
tokenChangeHandler: function() {
this.$.github.cancel();
// make login work
/*
this.async(function() {
this.$.github.style.position = 'static';
});
*/
},
getGistUrl: function() {
return 'https://gist.github.com/anonymous/' + this.fileId;
}
});
</script>
Expand Down

0 comments on commit 51cb669

Please sign in to comment.