ngx-gist-runkit
Version:
Gist RunKit combines the power of Github Gist with RunKit.
2 lines • 2.9 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("rxjs"),require("@angular/common/http")):"function"==typeof define&&define.amd?define("ngx-gist-runkit",["exports","@angular/core","rxjs","@angular/common/http"],e):e(t["ngx-gist-runkit"]={},t.ng.core,t.rxjs,t.ng.common.http)}(this,function(t,e,i,n){"use strict";var o=function(){function t(){this.TWITTER_OBJECT="RunKit",this.TWITTER_SCRIPT_ID="RunKit-js",this.TWITTER_WIDGET_URL="https://embed.runkit.com"}return t.prototype.loadScript=function(){var e=this;return i.Observable.create(function(t){e._startScriptLoad(),window[e.TWITTER_OBJECT].ready(e._onTwitterScriptLoadedFactory(t))})},t.prototype._startScriptLoad=function(){var e=window[this.TWITTER_OBJECT]||{};this._twitterScriptAlreadyExists()||(this._appendTwitterScriptToDOM(),e._e=[],e.ready=function(t){e._e.push(t)}),window[this.TWITTER_OBJECT]=e},t.prototype._twitterScriptAlreadyExists=function(){var t=document.getElementById(this.TWITTER_SCRIPT_ID);return null!==t||"object"!=typeof t},t.prototype._appendTwitterScriptToDOM=function(){var t=document.getElementsByTagName("script")[0],e=document.createElement("script");e.id=this.TWITTER_SCRIPT_ID,e.src=this.TWITTER_WIDGET_URL,t.parentNode.insertBefore(e,t)},t.prototype._onTwitterScriptLoadedFactory=function(e){return function(t){e.next(t),e.complete()}},t.decorators=[{type:e.Injectable,args:[{providedIn:"root"}]}],t.ngInjectableDef=e.defineInjectable({factory:function(){return new t},token:t,providedIn:"root"}),t}(),r=function(){function t(t,e){this.http=t,this.ngxGistRunkitService=e,this.gistId=undefined,this.gistFileName=undefined}return t.prototype.ngAfterViewInit=function(){var i=this;if(window.RunKit&&this.gistId!==undefined&&this.gistFileName!==undefined){var t=window.RunKit;this.fetchGithubGist(t,this.gistId,this.gistFileName)}else this.ngxGistRunkitService.loadScript().subscribe(function(t){var e=window.RunKit;i.fetchGithubGist(e,i.gistId,i.gistFileName)})},t.prototype.createNotebook=function(t,e){this.notebook=window.RunKit.createNotebook({element:this.embed.nativeElement,source:e})},t.prototype.fetchGithubGist=function(e,t,i){var n=this;this.http.get("https://api.github.com/gists/"+t).subscribe(function(t){t&&n.createNotebook(e,t.files[i].content)})},t.decorators=[{type:e.Component,args:[{selector:"app-ngx-gist-runkit",template:"<div #runKit></div>\n"}]}],t.ctorParameters=function(){return[{type:n.HttpClient},{type:o}]},t.propDecorators={embed:[{type:e.ViewChild,args:["runKit"]}],gistId:[{type:e.Input}],gistFileName:[{type:e.Input}]},t}(),s=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[n.HttpClientModule],declarations:[r],providers:[o],exports:[r]}]}],t}();t.NgxGistRunkitModule=s,t.ɵa=r,t.ɵb=o,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=ngx-gist-runkit.umd.min.js.map