MediaWiki:Common.js: различия между версиями
Нет описания правки Метка: отменено |
Нет описания правки Метка: отменено |
||
| Строка 164: | Строка 164: | ||
/* Функция для вставки Vimeo-видео на страницу для шаблона Vimeo, простая версия */ | /* Функция для вставки Vimeo-видео на страницу для шаблона Vimeo, простая версия */ | ||
function loadVimeoPlayers() { | |||
var players = document.getElementsByClassName('vimeo-player'); | |||
var | for (var i = 0; i < players.length; i++) { | ||
var player = players[i]; | |||
var videoId = player.getAttribute('data-id'); | |||
if (videoId && !player.querySelector('iframe')) { | |||
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; | |||
player.appendChild(iframe); | |||
} | |||
} | |||
} | } | ||
} | |||
if (document.readyState === 'loading') { | |||
document.addEventListener('DOMContentLoaded', loadVimeoPlayers); | |||
} else { | |||
loadVimeoPlayers(); | loadVimeoPlayers(); | ||
} | |||
if (typeof mw !== 'undefined' && mw.hook) { | |||
mw.hook('wikipage.content').add(loadVimeoPlayers); | mw.hook('wikipage.content').add(loadVimeoPlayers); | ||
} | } | ||