MOBILE-3814 iframe: Add loading class to show iframe is loading
parent
e03ef0d26e
commit
9f61d559b1
|
@ -51,7 +51,7 @@ export class CoreIframeUtilsProvider {
|
||||||
protected waitAutoLoginDefer?: PromiseDefer<void>;
|
protected waitAutoLoginDefer?: PromiseDefer<void>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.logger = CoreLogger.getInstance('CoreUtilsProvider');
|
this.logger = CoreLogger.getInstance('CoreIframeUtilsProvider');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -237,7 +237,7 @@ export class CoreIframeUtilsProvider {
|
||||||
contentDocument = 'contentDocument' in element && element.contentDocument
|
contentDocument = 'contentDocument' in element && element.contentDocument
|
||||||
? element.contentDocument
|
? element.contentDocument
|
||||||
: contentWindow && contentWindow.document;
|
: contentWindow && contentWindow.document;
|
||||||
} catch (ex) {
|
} catch {
|
||||||
// Ignore errors.
|
// Ignore errors.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ export class CoreIframeUtilsProvider {
|
||||||
// It's probably an <embed>. Try to get the window and the document.
|
// It's probably an <embed>. Try to get the window and the document.
|
||||||
try {
|
try {
|
||||||
contentDocument = element.getSVGDocument();
|
contentDocument = element.getSVGDocument();
|
||||||
} catch (ex) {
|
} catch {
|
||||||
// Ignore errors.
|
// Ignore errors.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,10 +310,10 @@ export class CoreIframeUtilsProvider {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contentDocument) {
|
if (contentDocument.body) {
|
||||||
// Search sub frames.
|
// Search sub frames.
|
||||||
CoreIframeUtilsProvider.FRAME_TAGS.forEach((tag) => {
|
CoreIframeUtilsProvider.FRAME_TAGS.forEach((tag) => {
|
||||||
const elements = Array.from(contentDocument.querySelectorAll(tag));
|
const elements = Array.from(contentDocument.body.querySelectorAll(tag));
|
||||||
elements.forEach((subElement: CoreFrameElement) => {
|
elements.forEach((subElement: CoreFrameElement) => {
|
||||||
this.treatFrame(subElement, true);
|
this.treatFrame(subElement, true);
|
||||||
});
|
});
|
||||||
|
@ -333,6 +333,8 @@ export class CoreIframeUtilsProvider {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
element.classList.add('core-loading');
|
||||||
|
|
||||||
const treatElement = (sendResizeEvent: boolean = false) => {
|
const treatElement = (sendResizeEvent: boolean = false) => {
|
||||||
this.checkOnlineFrameInOffline(element, isSubframe);
|
this.checkOnlineFrameInOffline(element, isSubframe);
|
||||||
|
|
||||||
|
@ -348,9 +350,12 @@ export class CoreIframeUtilsProvider {
|
||||||
this.treatFrameLinks(element, document);
|
this.treatFrameLinks(element, document);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Iframe content has been loaded.
|
||||||
// Send a resize events to the iframe so it calculates the right size if needed.
|
// Send a resize events to the iframe so it calculates the right size if needed.
|
||||||
if (window && sendResizeEvent) {
|
if (window && sendResizeEvent) {
|
||||||
setTimeout(() => window.dispatchEvent(new Event('resize')), 1000);
|
element.classList.remove('core-loading');
|
||||||
|
|
||||||
|
setTimeout(() => window.dispatchEvent && window.dispatchEvent(new Event('resize')), 1000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue