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

Converts Services to Ember.Service extensions #36

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,6 @@ As an 'a' tag:
{{/facebook-share}}
```

#### Facepile

Current URL:

`{{facebook-facepile}}`

Specified URL:

`{{facebook-facepile url='http://plyfe.github.io/ember-social'}}`

##### Themes

`light`
`dark`

`{{facebook-facepile fb-colorscheme='dark'}}`

### Twitter

#### Share
Expand Down Expand Up @@ -236,7 +219,6 @@ For more information on using ember-cli, visit [http://www.ember-cli.com/](http:
### TODO

* Implement click/share tracking for `{{facebook-like}}`
* Implement click/share tracking for `{{facebook-facepile}}`

### Contributors

Expand Down
26 changes: 0 additions & 26 deletions addon/components/facebook-facepile.js

This file was deleted.

5 changes: 2 additions & 3 deletions addon/components/facebook-like.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import Ember from 'ember';

export default Ember.Component.extend({
socialApiClient: null, // injected
socialApiClient: Ember.inject.service('facebook-api-client'),

url: null, // Defaults to current url
'fb-layout': 'standard', // Valid options: 'standard', 'button_count', 'button', or 'box_count'
'fb-action': 'like', // Valid options: 'like' or 'recommend'

createFacebookLikeButton: Ember.on('didInsertElement', function() {
var self = this;
this.socialApiClient.load().then(function(FB) {
this.get('socialApiClient').load().then(function(FB) {
if (self._state !== 'inDOM') { return; }
var attrs = [];
var url = self.get('url');
Expand All @@ -28,5 +28,4 @@ export default Ember.Component.extend({
FB.XFBML.parse(self.get('element'));
});
})

});
10 changes: 5 additions & 5 deletions addon/components/facebook-share.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Ember from 'ember';
* tracking is not supported due to restrictions of the Facebook SDK.
*/
export default Ember.Component.extend({
socialApiClient: null, // injected
socialApiClient: Ember.inject.service('facebook-api-client'),

tagName: 'div', // set tagName to 'a' in handlebars to use your own css/content
// instead of the standard Facebook share button UI
Expand All @@ -21,7 +21,7 @@ export default Ember.Component.extend({

createFacebookShareButton: Ember.on('didInsertElement', function() {
var self = this;
this.socialApiClient.load().then(function(FB) {
this.get('socialApiClient').load().then(function(FB) {
self.FB = FB;
if (self._state !== 'inDOM') { return; }
if (self.get('useFacebookUi')) {
Expand All @@ -43,7 +43,7 @@ export default Ember.Component.extend({
}),

showShareDialog: Ember.on('click', function(e){
this.socialApiClient.clicked({
this.get('socialApiClient').clicked({
url: this.get('url'),
componentName: 'facebook-share'
});
Expand All @@ -57,7 +57,7 @@ export default Ember.Component.extend({
},
function(response) {
if (response && !response.error_code) {
self.socialApiClient.shared('facebook', response);
self.get('socialApiClient').shared('facebook', response);
} else {
Ember.Logger.error('Error while posting.');
}
Expand All @@ -67,7 +67,7 @@ export default Ember.Component.extend({
if (this.FB) {
showDialog(this.FB);
} else {
this.socialApiClient.load().then(function(FB) {
this.get('socialApiClient').load().then(function(FB) {
showDialog(FB);
});
}
Expand Down
8 changes: 4 additions & 4 deletions addon/components/linkedin-share.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Ember from 'ember';

export default Ember.Component.extend({
socialApiClient: null, // injected
socialApiClient: Ember.inject.service('linkedin-api-client'),
tagName: 'div', // set tagName to 'a' in handlebars to use your own css/content
// instead of the standard Linkedin share button UI
isCustomLink: Ember.computed.equal('tagName','a'),
Expand All @@ -11,7 +11,7 @@ export default Ember.Component.extend({
url: null, // Defaults to current url
createLinkedinShareButton: Ember.on('didInsertElement', function() {
var self = this;
this.socialApiClient.load().then(function(IN) {
this.get('socialApiClient').load().then(function(IN) {
self.IN = IN;
self.shareHandlerName = IN.shareHandlerName;
if (self._state !== 'inDOM') { return; }
Expand All @@ -36,7 +36,7 @@ export default Ember.Component.extend({

showShareDialog: Ember.on('click', function(e){
var self = this;
this.socialApiClient.clicked(this.get('url') || window.location.href);
this.get('socialApiClient').clicked(this.get('url') || window.location.href);
if (this.get('useLinkedinUi')) { return; }
function showDialog(IN) {
IN.UI.Share().params({
Expand All @@ -46,7 +46,7 @@ export default Ember.Component.extend({
if (this.IN) {
showDialog(this.IN);
} else {
this.socialApiClient.load().then(function(IN) {
this.get('socialApiClient').load().then(function(IN) {
showDialog(IN);
});
}
Expand Down
2 changes: 1 addition & 1 deletion addon/components/social-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import layout from '../templates/components/social-widget';
export default Ember.Component.extend({
classNames: ['social-widget'],
layout: layout,

url: null,

like: true,
Expand Down
4 changes: 2 additions & 2 deletions addon/components/twitter-card.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Ember from 'ember';

export default Ember.Component.extend({
socialApiClient: null, // injected
socialApiClient: Ember.inject.service('twitter-api-client'),

"tweet-id": null, // required - id of the tweet that you want to embed
cards: "hidden", // When set to hidden, links in a Tweet are not expanded to photo, video, or link previews.
Expand All @@ -15,7 +15,7 @@ export default Ember.Component.extend({

loadTwitterClient: Ember.on('didInsertElement', function() {
var self = this;
this.socialApiClient.load().then(function(twttr) {
this.get('socialApiClient').load().then(function(twttr) {
if (self._state !== 'inDOM') { return; }
self.twttr = twttr;
self.trigger('twitterLoaded');
Expand Down
4 changes: 2 additions & 2 deletions addon/components/twitter-share.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Ember from 'ember';

export default Ember.Component.extend({
socialApiClient: null, // injected
socialApiClient: Ember.inject.service('twitter-api-client'),

tagName: 'div', // set tagName to 'a' in handlebars to use your own css/content
// instead of the standard Twitter share button UI
Expand Down Expand Up @@ -40,7 +40,7 @@ export default Ember.Component.extend({

loadTwitterClient: Ember.on('didInsertElement', function() {
var self = this;
this.socialApiClient.load().then(function(twttr) {
this.get('socialApiClient').load().then(function(twttr) {
if (self._state !== 'inDOM') { return; }
self.twttr = twttr;
self.trigger('twitterLoaded');
Expand Down
16 changes: 0 additions & 16 deletions addon/initializers/ember-social-services.js

This file was deleted.

2 changes: 1 addition & 1 deletion addon/services/facebook-api-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Ember from 'ember';

var facebookScriptPromise;

export default Ember.Object.extend({
export default Ember.Service.extend({
/*
* A tracking object implementing `shared(serviceName, payload)` and/or
* `clicked(serviceName, payload)` can be set on this object, and will
Expand Down
2 changes: 1 addition & 1 deletion addon/services/linkedin-api-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Ember from 'ember';

var linkedinScriptPromise;

export default Ember.Object.extend({
export default Ember.Service.extend({
/*
* A tracking object implementing `shared(serviceName, payload)` and/or
* `clicked(serviceName, payload)` can be set on this object, and will
Expand Down
2 changes: 1 addition & 1 deletion addon/services/twitter-api-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Ember from 'ember';

var twitterScriptPromise;

export default Ember.Object.extend({
export default Ember.Service.extend({
/*
* A tracking object implementing `shared(serviceName, payload)` and/or
* `clicked(serviceName, payload)` can be set on this object, and will
Expand Down
38 changes: 21 additions & 17 deletions addon/templates/components/social-widget.hbs
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
{{#if facebookLike}}
{{facebook-like url=url fb-layout='button'}}
{{/if}}
{{#if hasBlock}}
{{yield}}
{{else}}
{{#if facebookLike}}
{{facebook-like url=url fb-layout='button'}}
{{/if}}

{{#if facebookShare}}
{{facebook-share url=url}}
{{/if}}
{{#if facebookShare}}
{{facebook-share url=url}}
{{/if}}

{{#if twitterShare}}
{{twitter-share url=url}}
{{/if}}
{{#if twitterShare}}
{{twitter-share url=url}}
{{/if}}

{{#if linkedinShare}}
{{linkedin-share url=url}}
{{/if}}
{{#if linkedinShare}}
{{linkedin-share url=url}}
{{/if}}

{{#if emailShare}}
{{#email-share subject=emailSubject url=url body=emailBody}}
{{emailLinkText}}
{{/email-share}}
{{/if}}
{{#if emailShare}}
{{#email-share subject=emailSubject url=url body=emailBody}}
{{emailLinkText}}
{{/email-share}}
{{/if}}
{{/if}}
2 changes: 0 additions & 2 deletions app/components/facebook-facepile.js

This file was deleted.

2 changes: 0 additions & 2 deletions app/initializers/ember-social-services.js

This file was deleted.

35 changes: 8 additions & 27 deletions tests/acceptance/facebook-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Ember from 'ember';
import startApp from '../helpers/start-app';
import { module, test } from 'qunit';

var App;

Expand All @@ -12,11 +13,11 @@ module('Acceptance: Facebook', {
}
});

test('share', function() {
test('share', function(assert) {
visit('/facebook/share');

andThen(function() {
equal(currentPath(), 'facebook.share');
assert.equal(currentPath(), 'facebook.share');

var exampleElementIds = [
'no-parameters',
Expand All @@ -31,19 +32,19 @@ test('share', function() {

Ember.run.later(function() {
exampleElementIds.forEach(function(exampleId) {
equal(find('#' + exampleId + ' iframe').length, 1, 'Renders ' + exampleId);
assert.equal(find('#' + exampleId + ' iframe').length, 1, 'Renders ' + exampleId);
});

equal(find('#tag-name-a a').length, 1, 'Renders anchor tag');
assert.equal(find('#tag-name-a a').length, 1, 'Renders anchor tag');
}, 2500);
});
});

test('like', function() {
test('like', function(assert) {
visit('/facebook/like');

andThen(function() {
equal(currentPath(), 'facebook.like');
assert.equal(currentPath(), 'facebook.like');

var exampleElementIds = [
'no-parameters',
Expand All @@ -57,27 +58,7 @@ test('like', function() {

Ember.run.later(function() {
exampleElementIds.forEach(function(exampleId) {
equal(find('#' + exampleId + ' iframe').length, 1, 'Renders ' + exampleId);
});
}, 2500);
});
});

test('facepile', function() {
visit('/facebook/facepile');

andThen(function() {
equal(currentPath(), 'facebook.facepile');

var exampleElementIds = [
'no-parameters',
'custom-url',
'custom-colorscheme'
];

Ember.run.later(function() {
exampleElementIds.forEach(function(exampleId) {
equal(find('#' + exampleId + ' iframe').length, 1, 'Renders ' + exampleId);
assert.equal(find('#' + exampleId + ' iframe').length, 1, 'Renders ' + exampleId);
});
}, 2500);
});
Expand Down
Loading