IMPR: don't load iframe when offline

This commit is contained in:
Tony Air 2020-09-11 04:58:11 +07:00
parent 61441b65e9
commit abbaf22f99

View File

@ -285,8 +285,14 @@ const MetaLightboxUI = (($) => {
classTerm = `${classTerm} meta-lightbox-vimeo`; classTerm = `${classTerm} meta-lightbox-vimeo`;
} }
if (src) { if (!src) {
ui.loadIframe(src, classTerm); console.warn(`${NAME}: Video loading bad URL`);
return false;
}
const $iframe = ui.loadIframe(src, classTerm);
if (!$iframe) {
return false;
} }
// Set the title // Set the title
@ -344,7 +350,12 @@ const MetaLightboxUI = (($) => {
if ($link.data('force-iframe')) { if ($link.data('force-iframe')) {
console.log(`${NAME}: IFrame forced`); console.log(`${NAME}: IFrame forced`);
return ui.loadIframe(href, 'meta-lightbox-iframe-content'); const $iframe = ui.loadIframe(href, 'meta-lightbox-iframe-content');
if (!$iframe) {
return false;
}
return true;
} }
console.log(`${NAME}: loading AJAX`); console.log(`${NAME}: loading AJAX`);
@ -490,6 +501,12 @@ const MetaLightboxUI = (($) => {
static loadIframe(href, classTerm) { static loadIframe(href, classTerm) {
const ui = this; const ui = this;
// don't load on offline
if ($Body.hasClass('is-offline')) {
console.warn(`${NAME}: Unable to load iframe offline`);
return false;
}
const $iframe = $('<iframe>', { const $iframe = $('<iframe>', {
src: href, src: href,
class: classTerm, class: classTerm,