Skip to content

Commit

Permalink
File Support Rahul
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulrsingh09 committed Aug 23, 2017
1 parent e5ca76d commit 9a631ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions lib/ngx-gist.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
import {Component, Input, ViewChild, ElementRef, AfterViewInit} from '@angular/core';
import { Component, Input, ViewChild, ElementRef, AfterViewInit, ViewEncapsulation } from '@angular/core';

@Component({
selector: 'ngx-gist',
template:`
<iframe #iframe type="text/javascript" width="100%" frameborder="0"></iframe>
<iframe #iframe type="text/javascript" width="100%" frameborder="0" style = "height:inherit"></iframe>
`,
styleUrls: []
styleUrls: [],
encapsulation: ViewEncapsulation.None
})

export class NgxGist implements AfterViewInit {
@ViewChild('iframe') iframe:ElementRef;
@Input() gistId;
@Input() file:string;

ngAfterViewInit() {
let fileName = (this.file) ? this.file : '';
this.iframe.nativeElement.id = 'gist-' + this.gistId;
let doc = this.iframe.nativeElement.contentDocument || this.iframe.nativeElement.contentElement.contentWindow;
let content = `
<html>
let content = `
<html>
<head>
<base target="_parent">
</head>
<body onload="parent.document.getElementById('${this.iframe.nativeElement.id}')
.style.height=document.body.scrollHeight + 'px'">
<script type="text/javascript" src="https://gist.github.com/${this.gistId}.js"></script>
<body onload="parent.document.getElementById('${this.iframe.nativeElement.id}')">
<script type="text/javascript" src="https://gist.github.com/${this.gistId}.js?file=${fileName}"></script>
</body>
</html>
`;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"rxjs": "^5.0.3",
"semantic-release": "^6.3.2",
"tslint": "^5.1.0",
"typescript": "^2.1.5",
"typescript": "^2.4.2",
"ts-helpers": "^1.1.2",
"ts-node": "^3.0.2",
"uglify-js": "^2.8.22",
Expand Down

0 comments on commit 9a631ff

Please sign in to comment.