mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 05:50:35 +03:00
db09b317eb
no issue - added `@onDestroyed` argument to `<GhSiteIframe>` so consumers can clean up any references - used `@onLoaded` and `@onDestroyed` to handle a reference to the preview iframe - updated portal preview load handler and update method to trigger a resize task - add a 100ms delay to allow for portal to re-render itself - reach through the two iframes to get the portal container element and use it's height to set the style attribute on the portal preview container element
39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import {action} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
export default class GhSiteIframeComponent extends Component {
|
|
@service config;
|
|
|
|
@tracked isInvisible = this.args.invisibleUntilLoaded;
|
|
|
|
willDestroy() {
|
|
this.args.onDestroyed?.();
|
|
}
|
|
|
|
get srcUrl() {
|
|
return this.args.src || `${this.config.get('blogUrl')}/`;
|
|
}
|
|
|
|
@action
|
|
resetSrcAttribute(iframe) {
|
|
// reset the src attribute each time the guid changes - allows for
|
|
// a click on the navigation item to reset back to the homepage
|
|
if (this.args.guid !== this._lastGuid) {
|
|
if (iframe) {
|
|
iframe.src = this.srcUrl;
|
|
}
|
|
}
|
|
this._lastGuid = this.args.guid;
|
|
}
|
|
|
|
@action
|
|
onLoad(event) {
|
|
if (this.args.invisibleUntilLoaded) {
|
|
this.isInvisible = false;
|
|
}
|
|
this.args.onLoad?.(event);
|
|
}
|
|
}
|