Skip to content

Commit

Permalink
feat(igo-feature-detail): add html display event (#830)
Browse files Browse the repository at this point in the history
* add htmlDisplayEvent

* fix lint whiteSpace

* lint white space

* Delete angular.json from PR

* angular.json from next no modif

Co-authored-by: Marc-André Barbeau <[email protected]>
  • Loading branch information
josee666 and mbarbeau authored Apr 7, 2021
1 parent f475c1e commit e4128c1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/core/src/lib/media/media.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,9 @@ export class MediaService {
const media = this.getMedia();
return media === 'mobile';
}

isDesktop(): boolean {
const media = this.getMedia();
return media === 'desktop';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
</tbody>
</table>

<iframe *ngIf="feature && isObject(feature.properties) && feature.properties.target === 'iframe'" [srcdoc]="htmlSanitizer(feature.properties)" [src]="urlSanitizer(feature.properties.url)"></iframe>
<iframe *ngIf="isHtmlDisplay()" [srcdoc]="htmlSanitizer(feature.properties)" [src]="urlSanitizer(feature.properties.url)"></iframe>
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class FeatureDetailsComponent implements OnInit, OnDestroy {

@Output() routeEvent = new EventEmitter<boolean>();
@Output() selectFeature = new EventEmitter<boolean>();
@Output() htmlDisplayEvent = new EventEmitter<boolean>();

/**
* @internal
Expand Down Expand Up @@ -100,7 +101,17 @@ export class FeatureDetailsComponent implements OnInit, OnDestroy {
return this.sanitizer.bypassSecurityTrustResourceUrl(value);
}

htmlSanitizer(value): SafeResourceUrl {

isHtmlDisplay(): boolean {
if (this.feature && this.isObject(this.feature.properties) && this.feature.properties.target === 'iframe') {
this.htmlDisplayEvent.emit(true);
return true;
} else {
this.htmlDisplayEvent.emit(false);
return false;
}

htmlSanitizer(value): SafeResourceUrl {
if (!value.body || userAgent.getBrowserName() === 'Internet Explorer') {
return;
}
Expand Down

0 comments on commit e4128c1

Please sign in to comment.