|
Social = Em.Object.extend |
|
title: null |
|
url: null |
|
image: null |
|
description: null |
|
facebook: (-> |
|
endpoint = 'https://www.facebook.com/dialog/feed?' |
|
return endpoint + Em.$.param |
|
app_id: Vidz.get('facebookAppId') |
|
display: 'popup' |
|
link: this.get('url') |
|
picture: this.get('image') |
|
redirect_uri: "#{window.location.origin}/close_popup.html" |
|
).property('title', 'url', 'description', 'image') |
|
twitter: (-> |
|
endpoint = 'https://www.twitter.com/share?' |
|
return endpoint + Em.$.param |
|
text: this.get('title') |
|
related: "#{Vidz.get('twitterHandle')},CNE" |
|
via: Vidz.get('twitterHandle') |
|
url: this.get('url') |
|
).property('title', 'url') |
|
googleplus: (-> |
|
endpoint = 'https://plus.google.com/share?' |
|
return endpoint + Em.$.param |
|
url: this.get('url') |
|
).property('url') |
|
network: null |
|
createWindow: (-> |
|
return unless this.get('network')? |
|
url = this.get(this.get('network')) |
|
window.open url, 'Share', 'height=340, width=530, scrollbars=no, status=no' |
|
|
|
# TODO This should really by happening on the specific controller that uses |
|
# this Class. Reset network to null to allow multiple shares. |
|
this.set('network', null) |
|
).observes('network') |
|
|
|
Em.Application.initializer |
|
name: 'social' |
|
|
|
initialize: (container, application) -> |
|
application.register 'social:basic', Social |
|
application.inject 'controller', 'social', 'social:basic' |