ngx-social-button
Version:
Social login/share buttons for Angular 6, 7, 8
1,006 lines (985 loc) • 125 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('@angular/common')) :
typeof define === 'function' && define.amd ? define('ngx-social-button', ['exports', '@angular/core', 'rxjs', '@angular/common'], factory) :
(factory((global['ngx-social-button'] = {}),global.ng.core,global.rxjs,global.ng.common));
}(this, (function (exports,i0,rxjs,common) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
/**
* @abstract
*/
var /**
* @abstract
*/ BaseLoginProviderImpl = (function () {
function BaseLoginProviderImpl() {
}
/**
* @param {?} obj
* @param {?} onload
* @return {?}
*/
BaseLoginProviderImpl.prototype.loadScript = /**
* @param {?} obj
* @param {?} onload
* @return {?}
*/
function (obj, onload) {
if (document.getElementById(obj.name)) {
return;
}
/** @type {?} */
var signInJS = document.createElement('script');
signInJS.async = true;
signInJS.src = obj.url;
signInJS.onload = onload;
if (obj.name === 'linkedin') {
signInJS.async = false;
signInJS.text = ('api_key: ' + obj.id).replace('\'', '');
}
document.head.appendChild(signInJS);
};
return BaseLoginProviderImpl;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var SocialUser = (function () {
function SocialUser() {
}
return SocialUser;
}());
var LoginProviderClass = (function () {
function LoginProviderClass() {
}
return LoginProviderClass;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var FacebookLoginProvider = (function (_super) {
__extends(FacebookLoginProvider, _super);
function FacebookLoginProvider(clientId) {
var _this = _super.call(this) || this;
_this.clientId = clientId;
_this.TYPE = 'facebook';
_this.loginProviderObj = new LoginProviderClass();
_this.loginProviderObj.id = clientId;
_this.loginProviderObj.name = 'facebook';
_this.loginProviderObj.url = 'https://connect.facebook.net/en_US/sdk.js';
return _this;
}
/**
* @return {?}
*/
FacebookLoginProvider.prototype.initialize = /**
* @return {?}
*/
function () {
var _this = this;
return new Promise(function (resolve, reject) {
_this.loadScript(_this.loginProviderObj, function () {
FB.init({
appId: _this.clientId,
autoLogAppEvents: true,
cookie: true,
xfbml: true,
version: 'v2.8'
});
FB.AppEvents.logPageView();
FB.getLoginStatus(function (response) {
if (response.status === 'connected') {
/** @type {?} */
var accessToken_1 = FB.getAuthResponse()['accessToken'];
FB.api('/me?fields=name,email,picture', function (res) {
resolve(FacebookLoginProvider.drawUser(Object.assign({}, { token: accessToken_1 }, res)));
});
}
});
});
});
};
/**
* @param {?} response
* @return {?}
*/
FacebookLoginProvider.drawUser = /**
* @param {?} response
* @return {?}
*/
function (response) {
/** @type {?} */
var user = new SocialUser();
user.id = response.id;
user.name = response.name;
user.email = response.email;
user.accessToken = response.accessToken;
user.image = 'https://graph.facebook.com/' + response.id + '/picture?type=normal';
return user;
};
/**
* @param {?=} scopes
* @return {?}
*/
FacebookLoginProvider.prototype.signIn = /**
* @param {?=} scopes
* @return {?}
*/
function (scopes) {
return new Promise(function (resolve, reject) {
FB.login(function (response) {
console.log("facebook", response);
if (response.authResponse) {
/** @type {?} */
var accessToken_2 = FB.getAuthResponse()['accessToken'];
FB.api('/me?fields=name,email,picture', function (res) {
console.log("me", res);
resolve(FacebookLoginProvider.drawUser(Object.assign({}, { accessToken: accessToken_2 }, res)));
});
}
}, { scope: scopes && scopes.length > 0 ? scopes.join(',') : 'email,public_profile' });
});
};
/**
* @param {?=} share
* @return {?}
*/
FacebookLoginProvider.prototype.sharing = /**
* @param {?=} share
* @return {?}
*/
function (share) {
return new Promise(function (resolve, reject) {
FB.ui({
method: 'share',
href: share.href,
hashtag: (share.hashtag && share.hashtag.indexOf('#') >= 0) ? share.hashtag : null
}, function (response) {
console.log(response);
resolve();
});
});
};
/**
* @return {?}
*/
FacebookLoginProvider.prototype.signOut = /**
* @return {?}
*/
function () {
return new Promise(function (resolve, reject) {
FB.logout(function (response) {
resolve();
});
});
};
FacebookLoginProvider.PROVIDER_TYPE = 'facebook';
FacebookLoginProvider.SCOPES = {
EMAIL: 'email',
PUBLIC_PROFILE: 'public_profile'
};
return FacebookLoginProvider;
}(BaseLoginProviderImpl));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var GoogleLoginProvider = (function (_super) {
__extends(GoogleLoginProvider, _super);
function GoogleLoginProvider(clientId) {
var _this = _super.call(this) || this;
_this.clientId = clientId;
_this.loginProviderObj = new LoginProviderClass();
_this.TYPE = 'google';
_this.loginProviderObj.id = clientId;
_this.loginProviderObj.name = 'google';
_this.loginProviderObj.url = 'https://apis.google.com/js/platform.js';
return _this;
}
/**
* @return {?}
*/
GoogleLoginProvider.prototype.initialize = /**
* @return {?}
*/
function () {
var _this = this;
return new Promise(function (resolve, reject) {
_this.loadScript(_this.loginProviderObj, function () {
gapi.load('auth2', function () {
_this.auth2 = gapi.auth2.init({
client_id: _this.clientId,
scope: 'email'
});
_this.auth2.then(function () {
if (_this.auth2.isSignedIn.get()) {
resolve(_this.drawUser());
}
});
});
});
});
};
/**
* @return {?}
*/
GoogleLoginProvider.prototype.drawUser = /**
* @return {?}
*/
function () {
/** @type {?} */
var user = new SocialUser();
/** @type {?} */
var profile = this.auth2.currentUser.get().getBasicProfile();
/** @type {?} */
var authResponseObj = this.auth2.currentUser.get().getAuthResponse(true);
user.id = profile.getId();
user.name = profile.getName();
user.email = profile.getEmail();
user.image = profile.getImageUrl();
user.accessToken = authResponseObj.access_token;
user.idToken = authResponseObj.id_token;
return user;
};
/**
* @param {?=} scopes
* @return {?}
*/
GoogleLoginProvider.prototype.signIn = /**
* @param {?=} scopes
* @return {?}
*/
function (scopes) {
var _this = this;
return new Promise(function (resolve, reject) {
/** @type {?} */
var promise = _this.auth2.signIn();
promise.then(function () {
resolve(_this.drawUser());
}).catch(function (err) {
reject(err);
});
});
};
/**
* @return {?}
*/
GoogleLoginProvider.prototype.signOut = /**
* @return {?}
*/
function () {
var _this = this;
return new Promise(function (resolve, reject) {
_this.auth2.signOut().then(function (err) {
if (err) {
reject(err);
}
else {
resolve();
}
});
});
};
/**
* @param {?=} share
* @return {?}
*/
GoogleLoginProvider.prototype.sharing = /**
* @param {?=} share
* @return {?}
*/
function (share) {
return new Promise(function (resolve, reject) {
resolve();
});
};
GoogleLoginProvider.PROVIDER_TYPE = 'google';
return GoogleLoginProvider;
}(BaseLoginProviderImpl));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var LinkedinLoginProvider = (function (_super) {
__extends(LinkedinLoginProvider, _super);
function LinkedinLoginProvider(clientId) {
var _this = _super.call(this) || this;
_this.clientId = clientId;
_this.loginProviderObj = new LoginProviderClass();
_this.TYPE = 'linkedin';
_this.loginProviderObj.id = clientId;
_this.loginProviderObj.name = 'linkedin';
_this.loginProviderObj.url = 'https://platform.linkedin.com/in.js';
return _this;
}
/**
* @return {?}
*/
LinkedinLoginProvider.prototype.initialize = /**
* @return {?}
*/
function () {
var _this = this;
return new Promise(function (resolve, reject) {
_this.loadScript(_this.loginProviderObj, function () {
IN.init({
api_key: _this.clientId,
authorize: true,
onLoad: _this.onLinkedInLoad()
});
IN.Event.on(IN, 'auth', function () {
if (IN.User.isAuthorized()) {
IN.API.Raw('/people/~:(id,first-name,last-name,email-address,picture-url)').result(function (res) {
resolve(_this.drawUser(res));
});
}
});
});
});
};
/**
* @return {?}
*/
LinkedinLoginProvider.prototype.onLinkedInLoad = /**
* @return {?}
*/
function () {
IN.Event.on(IN, 'systemReady', function () {
IN.User.refresh();
});
};
/**
* @param {?} response
* @return {?}
*/
LinkedinLoginProvider.prototype.drawUser = /**
* @param {?} response
* @return {?}
*/
function (response) {
/** @type {?} */
var user = new SocialUser();
user.id = response.id;
user.name = response.firstName + ' ' + response.lastName;
user.email = response.emailAddress;
user.image = response.pictureUrl;
user.accessToken = IN.ENV.auth.oauth_token;
return user;
};
/**
* @return {?}
*/
LinkedinLoginProvider.prototype.signIn = /**
* @return {?}
*/
function () {
var _this = this;
return new Promise(function (resolve, reject) {
IN.User.authorize(function () {
IN.API.Raw('/people/~:(id,first-name,last-name,email-address,picture-url)').result(function (res) {
console.log('linkedin', res);
resolve(_this.drawUser(res));
});
});
});
};
/**
* @return {?}
*/
LinkedinLoginProvider.prototype.signOut = /**
* @return {?}
*/
function () {
return new Promise(function (resolve, reject) {
IN.User.logout(function (response) {
resolve();
}, function (err) {
reject(err);
});
});
};
/**
* @param {?=} share
* @return {?}
*/
LinkedinLoginProvider.prototype.sharing = /**
* @param {?=} share
* @return {?}
*/
function (share) {
return new Promise(function (resolve, reject) {
/** @type {?} */
var payload = {
'comment': share ? share.comment : '',
'visibility': {
'code': 'anyone'
}
};
IN.API.Raw('/people/~/shares?format=json')
.method('POST')
.body(JSON.stringify(payload))
.result(function (data) {
console.log('linkedin share', data);
resolve();
})
.error(function (onError) {
console.log('linkedin', onError);
});
});
};
LinkedinLoginProvider.PROVIDER_TYPE = 'linkedin';
return LinkedinLoginProvider;
}(BaseLoginProviderImpl));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var SocialServiceConfig = (function () {
function SocialServiceConfig(providers) {
this.providers = new Map();
if (providers) {
for (var i = 0; i < providers.length; i++) {
/** @type {?} */
var element = providers[i];
this.providers.set(element.provider.TYPE, element.provider);
}
}
}
/**
* @return {?}
*/
SocialServiceConfig.prototype.getProviders = /**
* @return {?}
*/
function () {
return this.providers;
};
/**
* @param {?} provider
* @return {?}
*/
SocialServiceConfig.prototype.addProvider = /**
* @param {?} provider
* @return {?}
*/
function (provider) {
if (!this.providers.get(provider.TYPE)) {
this.providers.set(provider.TYPE, provider);
}
};
/**
* @param {?} clientId
* @return {?}
*/
SocialServiceConfig.prototype.addFacebook = /**
* @param {?} clientId
* @return {?}
*/
function (clientId) {
this.addProvider(new FacebookLoginProvider(clientId));
return this;
};
/**
* @param {?} clientId
* @return {?}
*/
SocialServiceConfig.prototype.addGoogle = /**
* @param {?} clientId
* @return {?}
*/
function (clientId) {
this.addProvider(new GoogleLoginProvider(clientId));
return this;
};
/**
* @param {?} clientId
* @return {?}
*/
SocialServiceConfig.prototype.addLinkedIn = /**
* @param {?} clientId
* @return {?}
*/
function (clientId) {
this.addProvider(new LinkedinLoginProvider(clientId));
return this;
};
return SocialServiceConfig;
}());
var SocialService = (function () {
function SocialService(config) {
var _this = this;
this._user = null;
this._authState = new rxjs.BehaviorSubject(null);
this.providers = config.getProviders();
this.providers.forEach(function (provider, key) {
provider.initialize().then(function (user) {
user.provider = key;
_this._user = user;
_this._authState.next(user);
}).catch(function (err) {
// this._authState.next(null);
});
});
}
Object.defineProperty(SocialService.prototype, "authState", {
get: /**
* @return {?}
*/ function () {
return this._authState.asObservable();
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
SocialService.prototype.isSocialLoggedIn = /**
* @return {?}
*/
function () {
return (this._user != null);
};
/**
* @param {?} providerType
* @param {?=} share
* @return {?}
*/
SocialService.prototype.sharing = /**
* @param {?} providerType
* @param {?=} share
* @return {?}
*/
function (providerType, share) {
var _this = this;
return new Promise(function (resolve, reject) {
/** @type {?} */
var providerObject = _this.providers.get(providerType);
if (providerObject) {
providerObject.sharing(share).then(function () {
resolve(true);
});
}
else {
reject(SocialService.LOGIN_PROVIDER_NOT_FOUND);
}
});
};
/**
* @param {?=} share
* @return {?}
*/
SocialService.prototype.facebookSharing = /**
* @param {?=} share
* @return {?}
*/
function (share) {
return this.sharing('facebook', share);
};
// linkedinSharing(share?: any) {
// return this.sharing('linkedin', share);
// }
/**
* @param {?} providerType
* @param {?=} scopes
* @return {?}
*/
SocialService.prototype.signIn = /**
* @param {?} providerType
* @param {?=} scopes
* @return {?}
*/
function (providerType, scopes) {
var _this = this;
return new Promise(function (resolve, reject) {
/** @type {?} */
var providerObject = _this.providers.get(providerType);
if (providerObject) {
providerObject.signIn(scopes).then(function (user) {
user.provider = providerType;
resolve(user);
_this._user = user;
_this._authState.next(user);
}).catch(function (err) {
reject(SocialService.USER_POPUP_CLOSE);
});
}
else {
reject(SocialService.LOGIN_PROVIDER_NOT_FOUND);
}
});
};
/**
* @return {?}
*/
SocialService.prototype.signOut = /**
* @return {?}
*/
function () {
var _this = this;
return new Promise(function (resolve, reject) {
if (_this._user && _this._user.provider) {
/** @type {?} */
var providerType = _this._user.provider;
/** @type {?} */
var providerObject = _this.providers.get(providerType);
providerObject.signOut().then(function () {
_this._user = null;
_this._authState.next(null);
resolve();
}).catch(function (err) {
_this._authState.next(null);
});
}
else {
reject(SocialService.LOGIN_PROVIDER_NOT_FOUND);
}
});
};
SocialService.LOGIN_PROVIDER_NOT_FOUND = 'Login provider not found';
SocialService.USER_POPUP_CLOSE = 'User close the popup';
SocialService.decorators = [
{ type: i0.Injectable, args: [{
providedIn: 'root'
},] },
];
/** @nocollapse */
SocialService.ctorParameters = function () {
return [
{ type: SocialServiceConfig }
];
};
/** @nocollapse */ SocialService.ngInjectableDef = i0.defineInjectable({ factory: function SocialService_Factory() { return new SocialService(i0.inject(SocialServiceConfig)); }, token: SocialService, providedIn: "root" });
return SocialService;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var FacebookLoginButton = (function () {
function FacebookLoginButton(socialAuthService) {
this.socialAuthService = socialAuthService;
this.socialUser = new i0.EventEmitter();
}
/**
* @return {?}
*/
FacebookLoginButton.prototype.ngOnInit = /**
* @return {?}
*/
function () {
};
/**
* @return {?}
*/
FacebookLoginButton.prototype.socialSignIn = /**
* @return {?}
*/
function () {
var _this = this;
this.socialAuthService.signIn('facebook', this.scopes).then(function (userData) {
console.log("socialSignIn", userData);
_this.socialUser.emit(userData);
}).catch(function () {
_this.socialUser.emit(null);
});
};
FacebookLoginButton.decorators = [
{ type: i0.Component, args: [{
selector: 'facebook-login-button',
template: "\n <button [className]=\"style == 'round' ? 'social-btn facebook ' : 'button btn-block loginBtn --facebook '\"\n (click)=\"socialSignIn()\" type=\"button\">\n {{style == 'round' ? '': text ? text : 'Login with Facebook'}}</button>\n ",
styles: [".button{font-family:Lato,\"Lucida Grande\",\"Lucida Sans Unicode\",Tahoma,Sans-Serif;-webkit-appearance:none;display:inline-block;outline:0;border-radius:3px;border:3px solid transparent;cursor:pointer;text-overflow:ellipsis;text-decoration:none!important;font-weight:400!important}.loginBtn{box-sizing:border-box;position:relative;margin:.2em;padding:0 15px 0 46px;border:none;text-align:left;line-height:34px;white-space:nowrap;border-radius:3px;font-size:16px;color:#fff}.loginBtn:before{content:\"\";box-sizing:border-box;position:absolute;top:0;left:0;width:34px;height:100%}.loginBtn:focus{outline:0}.loginBtn:active{box-shadow:inset 0 0 0 32px rgba(0,0,0,.1)}.shareBtn{box-sizing:border-box;position:relative;margin:.2em;padding:0 15px 0 46px;border:none;text-align:left;line-height:34px;white-space:nowrap;border-radius:3px;font-size:16px;color:#fff}.shareBtn:before{content:\"\";box-sizing:border-box;position:absolute;top:0;left:0;width:34px;height:100%}.shareBtn:focus{outline:0}.shareBtn:active{box-shadow:inset 0 0 0 32px rgba(0,0,0,.1)}.--facebook{background-color:#4c69ba;background-image:linear-gradient(#4c69ba,#3b55a0);text-shadow:0 -1px 0 #354c8c}.--facebook:before{border-right:1px solid #364e92;background:url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/14082/icon_facebook.png) 6px 6px no-repeat}.--facebook:focus,.--facebook:hover{background-color:#5b7bd5;background-image:linear-gradient(#5b7bd5,#4864b1)}.--google{background:#dd4b39}.--google:before{border-right:1px solid #bb3f30;background:url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/14082/icon_google.png) 6px 6px no-repeat}.--google:focus,.--google:hover{background:#e74b37}.--linkedin{background:#007bb6}.--linkedin:before{border-right:1px solid #007bb6;background:url(https://content.linkedin.com/content/dam/developer/global/en_US/site/img/signin-button.png) -3px -3px no-repeat}.--linkedin:focus,.--linkedin:hover{background:linear-gradient(#007bb6,#4864b1)}.social-btn{width:50px;height:50px;background-size:cover;background-repeat:no-repeat;cursor:pointer;border-radius:10px;border:none}.social-btn.facebook{background-image:url(https://raw.githubusercontent.com/JohnnieLi/ngx-social-button/master/assets/facebook.png)}.social-btn.google{background-image:url(https://raw.githubusercontent.com/JohnnieLi/ngx-social-button/master/assets/google.png)}.social-btn.linkedin{background-image:url(https://raw.githubusercontent.com/JohnnieLi/ngx-social-button/master/assets/LinkedIn.png)}.social-btn.wechat{background-image:url(https://github.com/JohnnieLi/ngx-social-button/blob/master/assets/wechat.png?raw=true)}"],
},] },
];
/** @nocollapse */
FacebookLoginButton.ctorParameters = function () {
return [
{ type: SocialService }
];
};
FacebookLoginButton.propDecorators = {
size: [{ type: i0.Input }],
text: [{ type: i0.Input }],
style: [{ type: i0.Input }],
scopes: [{ type: i0.Input }],
socialUser: [{ type: i0.Output }]
};
return FacebookLoginButton;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var GoogleLoginButton = (function () {
function GoogleLoginButton(socialAuthService) {
this.socialAuthService = socialAuthService;
this.socialUser = new i0.EventEmitter();
}
/**
* @return {?}
*/
GoogleLoginButton.prototype.ngOnInit = /**
* @return {?}
*/
function () {
};
/**
* @return {?}
*/
GoogleLoginButton.prototype.socialSignIn = /**
* @return {?}
*/
function () {
var _this = this;
this.socialAuthService.signIn('google', this.scopes).then(function (userData) {
_this.socialUser.emit(userData);
}).catch(function () {
_this.socialUser.emit(null);
});
};
GoogleLoginButton.decorators = [
{ type: i0.Component, args: [{
selector: 'google-login-button',
template: "\n\t\t<button [className]=\"style == 'round' ? 'social-btn google' : 'button btn-block loginBtn --google'\"\n\t\t (click)=\"socialSignIn()\" type=\"button\">\n\t\t\t{{style == 'round' ? '': text ? text : 'Login with Google'}}\n\t\t</button>\n ", styles: [".button{font-family:Lato,\"Lucida Grande\",\"Lucida Sans Unicode\",Tahoma,Sans-Serif;-webkit-appearance:none;display:inline-block;outline:0;border-radius:3px;border:3px solid transparent;cursor:pointer;text-overflow:ellipsis;text-decoration:none!important;font-weight:400!important}.loginBtn{box-sizing:border-box;position:relative;margin:.2em;padding:0 15px 0 46px;border:none;text-align:left;line-height:34px;white-space:nowrap;border-radius:3px;font-size:16px;color:#fff}.loginBtn:before{content:\"\";box-sizing:border-box;position:absolute;top:0;left:0;width:34px;height:100%}.loginBtn:focus{outline:0}.loginBtn:active{box-shadow:inset 0 0 0 32px rgba(0,0,0,.1)}.shareBtn{box-sizing:border-box;position:relative;margin:.2em;padding:0 15px 0 46px;border:none;text-align:left;line-height:34px;white-space:nowrap;border-radius:3px;font-size:16px;color:#fff}.shareBtn:before{content:\"\";box-sizing:border-box;position:absolute;top:0;left:0;width:34px;height:100%}.shareBtn:focus{outline:0}.shareBtn:active{box-shadow:inset 0 0 0 32px rgba(0,0,0,.1)}.--facebook{background-color:#4c69ba;background-image:linear-gradient(#4c69ba,#3b55a0);text-shadow:0 -1px 0 #354c8c}.--facebook:before{border-right:1px solid #364e92;background:url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/14082/icon_facebook.png) 6px 6px no-repeat}.--facebook:focus,.--facebook:hover{background-color:#5b7bd5;background-image:linear-gradient(#5b7bd5,#4864b1)}.--google{background:#dd4b39}.--google:before{border-right:1px solid #bb3f30;background:url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/14082/icon_google.png) 6px 6px no-repeat}.--google:focus,.--google:hover{background:#e74b37}.--linkedin{background:#007bb6}.--linkedin:before{border-right:1px solid #007bb6;background:url(https://content.linkedin.com/content/dam/developer/global/en_US/site/img/signin-button.png) -3px -3px no-repeat}.--linkedin:focus,.--linkedin:hover{background:linear-gradient(#007bb6,#4864b1)}.social-btn{width:50px;height:50px;background-size:cover;background-repeat:no-repeat;cursor:pointer;border-radius:10px;border:none}.social-btn.facebook{background-image:url(https://raw.githubusercontent.com/JohnnieLi/ngx-social-button/master/assets/facebook.png)}.social-btn.google{background-image:url(https://raw.githubusercontent.com/JohnnieLi/ngx-social-button/master/assets/google.png)}.social-btn.linkedin{background-image:url(https://raw.githubusercontent.com/JohnnieLi/ngx-social-button/master/assets/LinkedIn.png)}.social-btn.wechat{background-image:url(https://github.com/JohnnieLi/ngx-social-button/blob/master/assets/wechat.png?raw=true)}"],
},] },
];
/** @nocollapse */
GoogleLoginButton.ctorParameters = function () {
return [
{ type: SocialService }
];
};
GoogleLoginButton.propDecorators = {
size: [{ type: i0.Input }],
style: [{ type: i0.Input }],
text: [{ type: i0.Input }],
scopes: [{ type: i0.Input }],
socialUser: [{ type: i0.Output }]
};
return GoogleLoginButton;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var LinkedinLoginButton = (function () {
function LinkedinLoginButton(socialAuthService) {
this.socialAuthService = socialAuthService;
this.socialUser = new i0.EventEmitter();
}
/**
* @return {?}
*/
LinkedinLoginButton.prototype.ngOnInit = /**
* @return {?}
*/
function () {
};
/**
* @return {?}
*/
LinkedinLoginButton.prototype.socialSignIn = /**
* @return {?}
*/
function () {
var _this = this;
this.socialAuthService.signIn('linkedin', this.scopes).then(function (userData) {
_this.socialUser.emit(userData);
}).catch(function () {
_this.socialUser.emit(null);
});
};
LinkedinLoginButton.decorators = [
{ type: i0.Component, args: [{
selector: 'linkedin-login-button',
template: "\n\t\t<button [className]=\"style == 'round' ? 'social-btn linkedin' : 'button btn-block loginBtn --linkedin'\"\n\t\t (click)=\"socialSignIn()\" type=\"button\">\n\t\t\t{{style == 'round' ? '': text ? text : 'Login with LinkedIn'}}\n\t\t</button>\n ", styles: [".button{font-family:Lato,\"Lucida Grande\",\"Lucida Sans Unicode\",Tahoma,Sans-Serif;-webkit-appearance:none;display:inline-block;outline:0;border-radius:3px;border:3px solid transparent;cursor:pointer;text-overflow:ellipsis;text-decoration:none!important;font-weight:400!important}.loginBtn{box-sizing:border-box;position:relative;margin:.2em;padding:0 15px 0 46px;border:none;text-align:left;line-height:34px;white-space:nowrap;border-radius:3px;font-size:16px;color:#fff}.loginBtn:before{content:\"\";box-sizing:border-box;position:absolute;top:0;left:0;width:34px;height:100%}.loginBtn:focus{outline:0}.loginBtn:active{box-shadow:inset 0 0 0 32px rgba(0,0,0,.1)}.shareBtn{box-sizing:border-box;position:relative;margin:.2em;padding:0 15px 0 46px;border:none;text-align:left;line-height:34px;white-space:nowrap;border-radius:3px;font-size:16px;color:#fff}.shareBtn:before{content:\"\";box-sizing:border-box;position:absolute;top:0;left:0;width:34px;height:100%}.shareBtn:focus{outline:0}.shareBtn:active{box-shadow:inset 0 0 0 32px rgba(0,0,0,.1)}.--facebook{background-color:#4c69ba;background-image:linear-gradient(#4c69ba,#3b55a0);text-shadow:0 -1px 0 #354c8c}.--facebook:before{border-right:1px solid #364e92;background:url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/14082/icon_facebook.png) 6px 6px no-repeat}.--facebook:focus,.--facebook:hover{background-color:#5b7bd5;background-image:linear-gradient(#5b7bd5,#4864b1)}.--google{background:#dd4b39}.--google:before{border-right:1px solid #bb3f30;background:url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/14082/icon_google.png) 6px 6px no-repeat}.--google:focus,.--google:hover{background:#e74b37}.--linkedin{background:#007bb6}.--linkedin:before{border-right:1px solid #007bb6;background:url(https://content.linkedin.com/content/dam/developer/global/en_US/site/img/signin-button.png) -3px -3px no-repeat}.--linkedin:focus,.--linkedin:hover{background:linear-gradient(#007bb6,#4864b1)}.social-btn{width:50px;height:50px;background-size:cover;background-repeat:no-repeat;cursor:pointer;border-radius:10px;border:none}.social-btn.facebook{background-image:url(https://raw.githubusercontent.com/JohnnieLi/ngx-social-button/master/assets/facebook.png)}.social-btn.google{background-image:url(https://raw.githubusercontent.com/JohnnieLi/ngx-social-button/master/assets/google.png)}.social-btn.linkedin{background-image:url(https://raw.githubusercontent.com/JohnnieLi/ngx-social-button/master/assets/LinkedIn.png)}.social-btn.wechat{background-image:url(https://github.com/JohnnieLi/ngx-social-button/blob/master/assets/wechat.png?raw=true)}"],
},] },
];
/** @nocollapse */
LinkedinLoginButton.ctorParameters = function () {
return [
{ type: SocialService }
];
};
LinkedinLoginButton.propDecorators = {
size: [{ type: i0.Input }],
style: [{ type: i0.Input }],
text: [{ type: i0.Input }],
scopes: [{ type: i0.Input }],
socialUser: [{ type: i0.Output }]
};
return LinkedinLoginButton;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var FacebookSharingButton = (function () {
function FacebookSharingButton(socialAuthService, document) {
this.socialAuthService = socialAuthService;
this.document = document;
this.share = null;
this.response = new i0.EventEmitter();
}
/**
* @return {?}
*/
FacebookSharingButton.prototype.ngOnInit = /**
* @return {?}
*/
function () {
};
/**
* @return {?}
*/
FacebookSharingButton.prototype.sharing = /**
* @return {?}
*/
function () {
var _this = this;
console.log(this.document.location.href);
if (!this.share) {
this.share = { href: this.document.location.href };
}
else if (!this.share.href) {
this.share.href = this.document.location.href;
}
this.socialAuthService.facebookSharing(this.share).then(function () {
_this.response.emit(true);
}).catch(function (err) {
_this.response.emit(false);
});
};
FacebookSharingButton.decorators = [
{ type: i0.Component, args: [{
selector: 'facebook-share-button',
template: "\n <button class=\"button btn-block loginBtn --facebook\" \n (click)=\"sharing()\" type=\"button\">Share</button>\n ",
styles: [".button{font-family:Lato,\"Lucida Grande\",\"Lucida Sans Unicode\",Tahoma,Sans-Serif;-webkit-appearance:none;display:inline-block;outline:0;border-radius:3px;border:3px solid transparent;cursor:pointer;text-overflow:ellipsis;text-decoration:none!important;font-weight:400!important}.loginBtn{box-sizing:border-box;position:relative;margin:.2em;padding:0 15px 0 46px;border:none;text-align:left;line-height:34px;white-space:nowrap;border-radius:3px;font-size:16px;color:#fff}.loginBtn:before{content:\"\";box-sizing:border-box;position:absolute;top:0;left:0;width:34px;height:100%}.loginBtn:focus{outline:0}.loginBtn:active{box-shadow:inset 0 0 0 32px rgba(0,0,0,.1)}.shareBtn{box-sizing:border-box;position:relative;margin:.2em;padding:0 15px 0 46px;border:none;text-align:left;line-height:34px;white-space:nowrap;border-radius:3px;font-size:16px;color:#fff}.shareBtn:before{content:\"\";box-sizing:border-box;position:absolute;top:0;left:0;width:34px;height:100%}.shareBtn:focus{outline:0}.shareBtn:active{box-shadow:inset 0 0 0 32px rgba(0,0,0,.1)}.--facebook{background-color:#4c69ba;background-image:linear-gradient(#4c69ba,#3b55a0);text-shadow:0 -1px 0 #354c8c}.--facebook:before{border-right:1px solid #364e92;background:url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/14082/icon_facebook.png) 6px 6px no-repeat}.--facebook:focus,.--facebook:hover{background-color:#5b7bd5;background-image:linear-gradient(#5b7bd5,#4864b1)}.--google{background:#dd4b39}.--google:before{border-right:1px solid #bb3f30;background:url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/14082/icon_google.png) 6px 6px no-repeat}.--google:focus,.--google:hover{background:#e74b37}.--linkedin{background:#007bb6}.--linkedin:before{border-right:1px solid #007bb6;background:url(https://content.linkedin.com/content/dam/developer/global/en_US/site/img/signin-button.png) -3px -3px no-repeat}.--linkedin:focus,.--linkedin:hover{background:linear-gradient(#007bb6,#4864b1)}.social-btn{width:50px;height:50px;background-size:cover;background-repeat:no-repeat;cursor:pointer;border-radius:10px;border:none}.social-btn.facebook{background-image:url(https://raw.githubusercontent.com/JohnnieLi/ngx-social-button/master/assets/facebook.png)}.social-btn.google{background-image:url(https://raw.githubusercontent.com/JohnnieLi/ngx-social-button/master/assets/google.png)}.social-btn.linkedin{background-image:url(https://raw.githubusercontent.com/JohnnieLi/ngx-social-button/master/assets/LinkedIn.png)}.social-btn.wechat{background-image:url(https://github.com/JohnnieLi/ngx-social-button/blob/master/assets/wechat.png?raw=true)}"],
},] },
];
/** @nocollapse */
FacebookSharingButton.ctorParameters = function () {
return [
{ type: SocialService },
{ type: undefined, decorators: [{ type: i0.Inject, args: [common.DOCUMENT,] }] }
];
};
FacebookSharingButton.propDecorators = {
share: [{ type: i0.Input }],
response: [{ type: i0.Output }]
};
return FacebookSharingButton;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var LinkedinSharingButton = (function () {
function LinkedinSharingButton(socialAuthService, document) {
this.socialAuthService = socialAuthService;
this.document = document;
this.share = { href: location.href };
this.response = new i0.EventEmitter();
}
/**
* @return {?}
*/
LinkedinSharingButton.prototype.ngAfterViewInit = /**
* @return {?}
*/
function () {
// add linkedin share button script tag to element
this.element.nativeElement.innerHTML = "<script type=\"IN/Share\" data-url=\"" + this.share.href + "\"></script>";
// render share button
// window['IN'] && window['IN'].parse();
};
LinkedinSharingButton.decorators = [
{ type: i0.Component, args: [{
selector: 'linkedin-share-button',
template: "\n <span #element></span>\n ",
},] },
];
/** @nocollapse */
LinkedinSharingButton.ctorParameters = function () {
return [
{ type: SocialService },
{ type: undefined, decorators: [{ type: i0.Inject, args: [common.DOCUMENT,] }] }
];
};
LinkedinSharingButton.propDecorators = {
share: [{ type: i0.Input }],
response: [{ type: i0.Output }],
element: [{ type: i0.ViewChild, args: ['element',] }]
};
return LinkedinSharingButton;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var NgxSocialButtonModule = (function () {
function NgxSocialButtonModule() {
}
NgxSocialButtonModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [],
declarations: [FacebookLoginButton, GoogleLoginButton,
FacebookSharingButton, LinkedinLoginButton,
LinkedinSharingButton],
exports: [FacebookLoginButton, GoogleLoginButton,
FacebookSharingButton, LinkedinLoginButton,
LinkedinSharingButton]
},] },
];
return NgxSocialButtonModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
exports.SocialServiceConfig = SocialServiceConfig;
exports.SocialService = SocialService;
exports.FacebookLoginProvider = FacebookLoginProvider;
exports.GoogleLoginProvider = GoogleLoginProvider;
exports.FacebookLoginButton = FacebookLoginButton;
exports.GoogleLoginButton = GoogleLoginButton;
exports.LinkedinLoginButton = LinkedinLoginButton;
exports.FacebookSharingButton = FacebookSharingButton;
exports.NgxSocialButtonModule = NgxSocialButtonModule;
exports.ɵb = LinkedinSharingButton;
exports.ɵa = BaseLoginProviderImpl;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmd4LXNvY2lhbC1idXR0b24udW1kLmpzLm1hcCIsInNvdXJjZXMiOltudWxsLCJuZzovL25neC1zb2NpYWwtYnV0dG9uL2xpYi9lbnRpdGllcy9iYXNlTG9naW5Qcm92aWRlckltcGwudHMiLCJuZzovL25neC1zb2NpYWwtYnV0dG9uL2xpYi9lbnRpdGllcy91c2VyLnRzIiwibmc6Ly9uZ3gtc29jaWFsLWJ1dHRvbi9saWIvcHJvdmlkZXJzL2ZhY2Vib29rUHJvdmlkZXIudHMiLCJuZzovL25neC1zb2NpYWwtYnV0dG9uL2xpYi9wcm92aWRlcnMvZ29vZ2xlUHJvdmlkZXIudHMiLCJuZzovL25neC1zb2NpYWwtYnV0dG9uL2xpYi9wcm92aWRlcnMvbGlua2VkaW5Qcm92aWRlci50cyIsIm5nOi8vbmd4LXNvY2lhbC1idXR0b24vbGliL3NvY2lhbC5zZXJ2aWNlLnRzIiwibmc6Ly9uZ3gtc29jaWFsLWJ1dHRvbi9saWIvYnV0dG9ucy9mYWNlYm9va0xvZ2luQnV0dG9uLnRzIiwibmc6Ly9uZ3gtc29jaWFsLWJ1dHRvbi9saWIvYnV0dG9ucy9nb29nbGVMb2dpbkJ1dHRvbi50cyIsIm5nOi8vbmd4LXNvY2lhbC1idXR0b24vbGliL2J1dHRvbnMvbGlua2VkaW5Mb2dpbkJ1dHRvbi50cyIsIm5nOi8vbmd4LXNvY2lhbC1idXR0b24vbGliL2J1dHRvbnMvZmFjZWJvb2tTaGFyaW5nQnV0dG9uLnRzIiwibmc6Ly9uZ3gtc29jaWFsLWJ1dHRvbi9saWIvYnV0dG9ucy9saW5rZWRpblNoYXJpbmdCdXR0b24udHMiLCJuZzovL25neC1zb2NpYWwtYnV0dG9uL2xpYi9uZ3gtc29jaWFsLWJ1dHRvbi5tb2R1bGUudHMiXSwic291cmNlc0NvbnRlbnQiOlsiLyohICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqXHJcbkNvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLiBBbGwgcmlnaHRzIHJlc2VydmVkLlxyXG5MaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgXCJMaWNlbnNlXCIpOyB5b3UgbWF5IG5vdCB1c2VcclxudGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGVcclxuTGljZW5zZSBhdCBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjBcclxuXHJcblRISVMgQ09ERSBJUyBQUk9WSURFRCBPTiBBTiAqQVMgSVMqIEJBU0lTLCBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9