UNPKG

@greg-md/ng-facebook

Version:
2 lines 8.98 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@greg-md/ng-facebook",["exports","@angular/core","@angular/common","rxjs","rxjs/operators"],t):t((e["greg-md"]=e["greg-md"]||{},e["greg-md"]["ng-facebook"]={}),e.ng.core,e.ng.common,e.rxjs,e.rxjs.operators)}(this,function(e,t,n,a,o){"use strict";var r={xfbml:!1,version:"v3.0"},i=function(){function e(e,t){this.ngZone=e,this.platformId=t,this.sdk=new a.ReplaySubject(1)}return e.prototype.load=function(r){var i=this;return void 0===r&&(r="en_US"),a.Observable.create(function(o){n.isPlatformServer(i.platformId)||i.ngZone.runOutsideAngular(function(){var e,t;delete window.FB,(e=document.getElementById("facebook-jssdk"))&&e.parentNode.removeChild(e),(t=document.getElementById("fb-root"))&&t.parentNode.removeChild(t);var n=document.createElement("script");n.id="facebook-jssdk",n.src="//connect.facebook.net/"+(r||"en_US")+"/sdk.js",n.onload=function(){i.ngZone.run(function(){o.next(FB),o.complete()})},n.onerror=function(){i.ngZone.run(function(){o.error("Facebook SDK could not be loaded."),o.complete()})},document.head.appendChild(n)})}).pipe(o.map(function(e){return i.sdk.next(e),e}))},e.prototype.init=function(t,e){var n=this;return void 0===t&&(t={}),void 0===e&&(e="en_US"),this.load(e).pipe(o.tap(function(e){t=Object.assign({},r,t),e.init(t),n.reloadRenderedElements().subscribe()}))},e.prototype.login=function(n){var o=this;return a.Observable.create(function(t){o.sdk.subscribe(function(e){o.ngZone.runOutsideAngular(function(){e.login(function(e){o.ngZone.run(function(){e.authResponse?t.next(e.authResponse):t.error(e),t.complete()})},n)})})})},e.prototype.api=function(n,o,r){var i=this;return a.Observable.create(function(t){i.sdk.subscribe(function(e){i.ngZone.runOutsideAngular(function(){e.api(n,o,r,function(e){i.ngZone.run(function(){e&&!e.error?t.next(e):t.error(e?e.error:null),t.complete()})})})})})},e.prototype.parse=function(n){var o=this;return a.Observable.create(function(t){o.sdk.subscribe(function(e){o.ngZone.runOutsideAngular(function(){e.XFBML.parse(n,function(){o.ngZone.run(function(){t.next(n),t.complete()})})})})})},e.prototype.reloadRenderedElements=function(){var r=this;return a.Observable.create(function(o){r.sdk.subscribe(function(t){var e=document.querySelectorAll('[fb-xfbml-state="rendered"]'),n=e.length;Array.from(e).forEach(function(e){r.ngZone.runOutsideAngular(function(){t.XFBML.parse(e.parentElement,function(){r.ngZone.run(function(){--n,o.next(e.parentElement),n<=0&&o.complete()})})})})})})},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:t.NgZone},{type:undefined,decorators:[{type:t.Inject,args:[t.PLATFORM_ID]}]}]},e.ngInjectableDef=t.defineInjectable({factory:function(){return new e(t.inject(t.NgZone),t.inject(t.PLATFORM_ID))},token:e,providedIn:"root"}),e}(),s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};function c(e,t){function n(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function d(e){return e&&e.getClientRects().length?(n=e.getBoundingClientRect()).width||n.height?(t=e.ownerDocument.documentElement,{top:n.top+window.pageYOffset-t.clientTop,left:n.left+window.pageXOffset-t.clientLeft}):n:{top:0,left:0};var t,n}function u(e,t){return void 0===t&&(t={}),!(function(e,t){if(void 0===t&&(t={}),!e)return!1;var n=t.container||window,o=t.threshold||0;return(n instanceof HTMLElement?d(n).top+n.offsetHeight:window.innerHeight+window.scrollY)<=d(e).top-o}(e,t)||function(e,t){if(void 0===t&&(t={}),!e)return!1;var n=t.container||window,o=t.threshold||0;return(n instanceof HTMLElement?d(n).top:window.scrollY)>=d(e).top+o+e.offsetHeight}(e,t)||function(e,t){if(void 0===t&&(t={}),!e)return!1;var n=t.container||window,o=t.threshold||0;return(n instanceof HTMLElement?d(n).left:window.scrollX)>=d(e).left+o+e.offsetWidth}(e,t)||function(e,t){if(void 0===t&&(t={}),!e)return!1;var n=t.container||window,o=t.threshold||0;return(n instanceof HTMLElement?d(n).left+n.offsetWidth:window.innerWidth+window.scrollX)<=d(e).left-o}(e,t))}var p=new t.InjectionToken("fb_parse_lazy_load"),l=function(){function e(e,t,n,o,r){this.elementRef=e,this.facebook=t,this.renderer=n,this.platformId=o,this.threshold=r}return Object.defineProperty(e.prototype,"lazyLoad",{set:function(e){this.threshold=e},enumerable:!0,configurable:!0}),e.prototype.ngAfterViewInit=function(){null===this.threshold?this.load():(this.initListeners(),this.tryLoading())},e.prototype.ngOnDestroy=function(){this.unloadListeners()},e.prototype.initListeners=function(){var e=this;this.scrollUnload=this.renderer.listen("window","scroll",function(){e.tryLoading()}),this.resizeUnload=this.renderer.listen("window","resize",function(){e.tryLoading()})},e.prototype.tryLoading=function(){n.isPlatformBrowser(this.platformId)&&u(this.elementRef.nativeElement,{threshold:this.threshold,container:this.container})&&(this.load(),this.unloadListeners())},e.prototype.load=function(){this.facebook.parse(this.elementRef.nativeElement).subscribe()},e.prototype.unloadListeners=function(){this.scrollUnload&&this.scrollUnload(),this.resizeUnload&&this.resizeUnload()},e.decorators=[{type:t.Directive,args:[{selector:"[fbParse]"}]}],e.ctorParameters=function(){return[{type:t.ElementRef},{type:i},{type:t.Renderer2},{type:Object,decorators:[{type:t.Inject,args:[t.PLATFORM_ID]}]},{type:undefined,decorators:[{type:t.Optional},{type:t.Inject,args:[p]}]}]},e.propDecorators={lazyLoad:[{type:t.Input}],container:[{type:t.Input}]},e}(),f=function(a){function e(e,t,n,o,r){var i=a.call(this,e,t,n,o,r)||this;return i.action="like",i.colorscheme="light",i.kidDirectedSite=!1,i.layout="standard",i.share=!1,i.showFaces=!1,i.size="small",i}return c(e,a),e.decorators=[{type:t.Component,args:[{selector:"fb-like",styles:[],template:'\n <div class="fb-like"\n [attr.data-action]="action"\n [attr.data-colorscheme]="colorscheme"\n [attr.data-href]="href"\n [attr.data-kid-directed-site]="kidDirectedSite"\n [attr.data-layout]="layout"\n [attr.data-ref]="ref"\n [attr.data-share]="share"\n [attr.data-show-faces]="showFaces"\n [attr.data-size]="size"\n [attr.data-width]="width"\n >\n <ng-content></ng-content>\n </div>\n ',changeDetection:t.ChangeDetectionStrategy.OnPush}]}],e.ctorParameters=function(){return[{type:t.ElementRef},{type:i},{type:t.Renderer2},{type:Object,decorators:[{type:t.Inject,args:[t.PLATFORM_ID]}]},{type:undefined,decorators:[{type:t.Optional},{type:t.Inject,args:[p]}]}]},e.propDecorators={action:[{type:t.Input}],colorscheme:[{type:t.Input}],href:[{type:t.Input}],kidDirectedSite:[{type:t.Input}],layout:[{type:t.Input}],ref:[{type:t.Input}],share:[{type:t.Input}],showFaces:[{type:t.Input}],size:[{type:t.Input}],width:[{type:t.Input}]},e}(l),h=function(a){function e(e,t,n,o,r){var i=a.call(this,e,t,n,o,r)||this;return i.width=340,i.height=500,i.tabs="timeline",i.hideCover=!1,i.showFacepile=!0,i.hideCta=!1,i.smallHeader=!1,i.adaptContainerWidth=!0,i}return c(e,a),e.decorators=[{type:t.Component,args:[{selector:"fb-page",styles:[],template:'\n <div class="fb-page"\n [attr.data-href]="href"\n [attr.data-width]="width"\n [attr.data-height]="height"\n [attr.data-tabs]="tabs"\n [attr.data-hide-cover]="hideCover"\n [attr.data-show-facepile]="showFacepile"\n [attr.data-hide-cta]="hideCta"\n [attr.data-small-header]="smallHeader"\n [attr.data-adapt-container-width]="adaptContainerWidth"\n >\n <blockquote [attr.cite]="href" class="fb-xfbml-parse-ignore">\n <a [href]="href">\n <ng-content></ng-content>\n </a>\n </blockquote>\n </div>\n ',changeDetection:t.ChangeDetectionStrategy.OnPush}]}],e.ctorParameters=function(){return[{type:t.ElementRef},{type:i},{type:t.Renderer2},{type:Object,decorators:[{type:t.Inject,args:[t.PLATFORM_ID]}]},{type:undefined,decorators:[{type:t.Optional},{type:t.Inject,args:[p]}]}]},e.propDecorators={href:[{type:t.Input}],width:[{type:t.Input}],height:[{type:t.Input}],tabs:[{type:t.Input}],hideCover:[{type:t.Input}],showFacepile:[{type:t.Input}],hideCta:[{type:t.Input}],smallHeader:[{type:t.Input}],adaptContainerWidth:[{type:t.Input}]},e}(l),y=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{imports:[n.CommonModule],declarations:[l,h,f],exports:[l,h,f]}]}],e}();e.FACEBOOK_DEFAULTS=r,e.FacebookService=i,e.FacebookLikeComponent=f,e.FacebookPageComponent=h,e.FB_PARSE_LAZY_LOAD=p,e.FacebookParseDirective=l,e.FacebookModule=y,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=greg-md-ng-facebook.umd.min.js.map