diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-11-07 18:24:57 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-11-07 18:24:57 -0500 |
| commit | 5b801067f0da66191090465e72d1758826461fd3 (patch) | |
| tree | 8b02ce4443f7e5bbefb59c29ffa9219eaf02a56f /public/assets/javascripts/ui/reader/ShareView.js | |
| parent | 22c4fd94cd4b3f5f881f0ad91597b7c208e89eff (diff) | |
| parent | f246a18bf02d2476b5f2bbc87a563b997b384a2c (diff) | |
merge
Diffstat (limited to 'public/assets/javascripts/ui/reader/ShareView.js')
| -rw-r--r-- | public/assets/javascripts/ui/reader/ShareView.js | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/public/assets/javascripts/ui/reader/ShareView.js b/public/assets/javascripts/ui/reader/ShareView.js index 4e5f832..dbe6f64 100644 --- a/public/assets/javascripts/ui/reader/ShareView.js +++ b/public/assets/javascripts/ui/reader/ShareView.js @@ -2,31 +2,61 @@ var ShareView = View.extend({ el: ".share", events: { + "keydown": "stopPropagation", "click #share_facebook": "facebook", "click #share_twitter": "twitter", + "click #share_embed": "embed", }, initialize: function(opt){ this.parent = opt.parent + this.embedView = new EmbedView ({ parent: this }) + this.$link = this.$("#share_link") + }, + + toggle: function(state){ + if (typeof state == "boolean") { + this.$el.toggleClass("active", state) + } + else { + this.$el.toggleClass("active") + } + }, + show: function(){ + this.toggle(true) + }, + hide: function(){ + this.toggle(false) + }, + + setLink: function(url){ + this.$link.val( url ) + }, + getLink: function(){ + var link = window.location.origin + window.location.pathname + link = link.replace(/\/edit\/?$/, "") + return link }, facebook: function (e) { e.preventDefault() - var msg = $(".roomName").html() + " on VValls" - var url = "https://www.facebook.com/share.php?u=" + encodeURIComponent(window.location.origin + window.location.pathname) + "&t=" + encodeURIComponent(msg); + var link = this.getLink() + var msg = app.controller.data.name + " on VValls" + var url = "https://www.facebook.com/share.php?u=" + encodeURIComponent(link) + "&t=" + encodeURIComponent(msg) window.open(url, "_blank") }, twitter: function (e) { e.preventDefault() - var msg = $(".roomName").html() + " on VValls" - var url = "https://twitter.com/home?status=" + encodeURIComponent(window.location.origin + window.location.pathname + " " + msg); + var link = this.getLink() + var msg = app.controller.data.name + " on VValls" + var url = "https://twitter.com/home?status=" + encodeURIComponent(link + " " + msg) window.open(url, "_blank") }, embed: function (e) { e.preventDefault() - + this.embedView.show() }, }) |
