MediaWiki:Common.js: различия между версиями
Нет описания правки Метка: отменено |
упрощение Метка: отменено |
||
| Строка 167: | Строка 167: | ||
'use strict'; | 'use strict'; | ||
function | function loadVimeoPlayers() { | ||
var | var containers = document.querySelectorAll('.vimeo-player'); | ||
containers.forEach(function(container) { | |||
var videoId = container.getAttribute('data-vimeo-id'); | |||
if (!videoId) return; | |||
var iframe = document.createElement('iframe'); | |||
iframe.src = 'https://player.vimeo.com/video/' + videoId; | |||
iframe.width = '560'; | |||
iframe.height = '315'; | |||
iframe.frameBorder = '0'; | |||
iframe.allow = 'autoplay; fullscreen; picture-in-picture'; | |||
iframe.allowFullscreen = true; | |||
container.innerHTML = ''; | |||
container.appendChild(iframe); | |||
}); | |||
} | } | ||
if (document.readyState === 'loading') { | if (document.readyState === 'loading') { | ||
document.addEventListener('DOMContentLoaded', | document.addEventListener('DOMContentLoaded', loadVimeoPlayers); | ||
} else { | } else { | ||
loadVimeoPlayers(); | |||
} | } | ||
mw.hook('wikipage.content').add( | mw.hook('wikipage.content').add(loadVimeoPlayers); | ||
})(); | })(); | ||