Дополнительные действия
Oagapov (обсуждение | вклад) Полностью удалено содержимое страницы Метка: очистка |
Oagapov (обсуждение | вклад) Просмотр картинки в полном размере по клику |
||
| Строка 1: | Строка 1: | ||
/* Просмотр картинки по клику; Ctrl/Cmd+клик открывает страницу файла как раньше. | |||
Стили окна — в MediaWiki:Citizen.css (.era-lightbox) */ | |||
$( function () { | |||
$( document ).on( 'click', '.mw-parser-output a.mw-file-description, .mw-parser-output a.image', function ( e ) { | |||
if ( e.ctrlKey || e.metaKey || e.shiftKey || e.button !== 0 ) return; | |||
var img = this.querySelector( 'img' ); | |||
if ( !img ) return; | |||
e.preventDefault(); | |||
// из адреса миниатюры получаем оригинал | |||
var full = ( img.currentSrc || img.src ).replace( /\/thumb(\/.+?\/[^\/]+)\/[^\/]+$/, '$1' ); | |||
var box = document.createElement( 'div' ); | |||
box.className = 'era-lightbox'; | |||
var big = document.createElement( 'img' ); | |||
big.src = full; | |||
big.alt = img.alt || ''; | |||
box.appendChild( big ); | |||
function close() { | |||
box.remove(); | |||
document.removeEventListener( 'keydown', onKey ); | |||
document.documentElement.style.overflow = ''; | |||
} | |||
function onKey( ev ) { if ( ev.key === 'Escape' ) close(); } | |||
box.addEventListener( 'click', close ); | |||
document.addEventListener( 'keydown', onKey ); | |||
document.documentElement.style.overflow = 'hidden'; | |||
document.body.appendChild( box ); | |||
} ); | |||
} ); | |||
Версия от 19:19, 27 октября 2026
/* Просмотр картинки по клику; Ctrl/Cmd+клик открывает страницу файла как раньше.
Стили окна — в MediaWiki:Citizen.css (.era-lightbox) */
$( function () {
$( document ).on( 'click', '.mw-parser-output a.mw-file-description, .mw-parser-output a.image', function ( e ) {
if ( e.ctrlKey || e.metaKey || e.shiftKey || e.button !== 0 ) return;
var img = this.querySelector( 'img' );
if ( !img ) return;
e.preventDefault();
// из адреса миниатюры получаем оригинал
var full = ( img.currentSrc || img.src ).replace( /\/thumb(\/.+?\/[^\/]+)\/[^\/]+$/, '$1' );
var box = document.createElement( 'div' );
box.className = 'era-lightbox';
var big = document.createElement( 'img' );
big.src = full;
big.alt = img.alt || '';
box.appendChild( big );
function close() {
box.remove();
document.removeEventListener( 'keydown', onKey );
document.documentElement.style.overflow = '';
}
function onKey( ev ) { if ( ev.key === 'Escape' ) close(); }
box.addEventListener( 'click', close );
document.addEventListener( 'keydown', onKey );
document.documentElement.style.overflow = 'hidden';
document.body.appendChild( box );
} );
} );