MediaWiki:Common.js: Difference between revisions
Embed Google Drive folder grid for Photos page |
Embed Google Forms for Contact Us page |
||
| Line 28: | Line 28: | ||
}()); | }()); | ||
(function buildGoogleFormEmbeds() { | |||
$('.mw-parser-output .google-form-embed[data-form-id]').each(function () { | |||
var $slot = $(this); | |||
if ($slot.data('rbGoogleFormEmbed')) { | |||
return; | |||
} | |||
$slot.data('rbGoogleFormEmbed', 1); | |||
var id = String($slot.attr('data-form-id') || ''); | |||
if (!/^1FAIpQLS[A-Za-z0-9_-]+$/.test(id)) { | |||
return; | |||
} | |||
var src = 'https://docs.google.com/forms/d/e/' + | |||
encodeURIComponent(id) + '/viewform?embedded=true'; | |||
var $iframe = $('<iframe class="google-form-frame" title="Ritchie Boys Contact Us Form" loading="lazy" allowfullscreen></iframe>') | |||
.attr({ | |||
src: src, | |||
frameborder: '0', | |||
sandbox: 'allow-scripts allow-popups allow-forms allow-same-origin allow-popups-to-escape-sandbox allow-downloads allow-modals' | |||
}); | |||
var $fallback = $slot.find('.google-form-fallback'); | |||
if ($fallback.length) { | |||
$fallback.before($iframe); | |||
} else { | |||
$slot.prepend($iframe); | |||
} | |||
}); | |||
}()); | |||
(function buildDriveFolderEmbeds() { | (function buildDriveFolderEmbeds() { | ||