-
Notifications
You must be signed in to change notification settings - Fork 6
/
ngx-gist.js
37 lines (37 loc) · 1.85 KB
/
ngx-gist.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
exports.__esModule = true;
var core_1 = require("@angular/core");
var ngxGist = (function () {
function ngxGist() {
}
ngxGist.prototype.ngAfterViewInit = function () {
this.iframe.nativeElement.id = 'gist-' + this.gistId;
var doc = this.iframe.nativeElement.contentDocument || this.iframe.nativeElement.contentElement.contentWindow;
var content = "\n <html>\n <head>\n <base target=\"_parent\">\n </head>\n <body onload=\"parent.document.getElementById('" + this.iframe.nativeElement.id + "')\n .style.height=document.body.scrollHeight + 'px'\">\n <script type=\"text/javascript\" src=\"https://gist.github.com/" + this.gistId + ".js\"></script>\n </body>\n </html>\n ";
doc.open();
doc.write(content);
doc.close();
};
return ngxGist;
}());
__decorate([
core_1.ViewChild('iframe')
], ngxGist.prototype, "iframe");
__decorate([
core_1.Input()
], ngxGist.prototype, "gistId");
ngxGist = __decorate([
core_1.Component({
selector: 'ngx-gist',
template: "\n <iframe #iframe type=\"text/javascript\" width=\"100%\" frameborder=\"0\"></iframe>\n ",
styleUrls: []
})
], ngxGist);
exports.ngxGist = ngxGist;
//# sourceMappingURL=ngx-gist.js.map