2021-05-18 18:08:03 +03:00
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import {action} from '@ember/object';
|
2019-03-21 20:55:58 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
2021-05-18 18:36:18 +03:00
|
|
|
import {tracked} from '@glimmer/tracking';
|
2019-03-21 20:55:58 +03:00
|
|
|
|
2021-05-18 18:08:03 +03:00
|
|
|
export default class GhSiteIframeComponent extends Component {
|
|
|
|
@service config;
|
2021-01-18 20:48:11 +03:00
|
|
|
|
2021-05-18 18:36:18 +03:00
|
|
|
@tracked isInvisible = this.args.invisibleUntilLoaded;
|
|
|
|
|
2021-05-18 18:08:03 +03:00
|
|
|
get srcUrl() {
|
|
|
|
return this.args.src || `${this.config.get('blogUrl')}/`;
|
|
|
|
}
|
2021-01-18 20:48:11 +03:00
|
|
|
|
2021-05-18 18:08:03 +03:00
|
|
|
@action
|
|
|
|
resetSrcAttribute(iframe) {
|
2019-03-21 20:55:58 +03:00
|
|
|
// reset the src attribute each time the guid changes - allows for
|
|
|
|
// a click on the navigation item to reset back to the homepage
|
2021-05-18 18:08:03 +03:00
|
|
|
if (this.args.guid !== this._lastGuid) {
|
2019-03-21 20:55:58 +03:00
|
|
|
if (iframe) {
|
2021-05-18 18:08:03 +03:00
|
|
|
iframe.src = this.srcUrl;
|
2019-03-21 20:55:58 +03:00
|
|
|
}
|
|
|
|
}
|
2021-05-18 18:08:03 +03:00
|
|
|
this._lastGuid = this.args.guid;
|
2019-03-21 20:55:58 +03:00
|
|
|
}
|
2021-05-18 18:36:18 +03:00
|
|
|
|
|
|
|
@action
|
|
|
|
onLoad(event) {
|
|
|
|
if (this.args.invisibleUntilLoaded) {
|
|
|
|
this.isInvisible = false;
|
|
|
|
}
|
|
|
|
this.args.onLoad?.(event);
|
|
|
|
}
|
2021-05-18 18:08:03 +03:00
|
|
|
}
|