mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-12-18 18:20:51 +00:00
2687d12c52
Change-Id: I6a9936743a74afb528713f21e016838947fa1914
37 lines
865 B
JavaScript
37 lines
865 B
JavaScript
import { SIZES } from '../../src/ui/thumbnail';
|
|
import { createPreviewWithType, layoutPreview, getClasses } from '../../src/ui/renderer.js';
|
|
import scaleDownThumbnail from './scaleDownThumbnail';
|
|
|
|
const POINTER_SIZE = 8;
|
|
|
|
/**
|
|
* Creates a static/stateless Popup and returns its HTML.
|
|
*
|
|
* @param {ext.popups.PreviewModel} model
|
|
* @param {object} layout
|
|
*
|
|
* @return {string} HTML
|
|
*/
|
|
function createPopup( model, layout ) {
|
|
if ( model.thumbnail ) {
|
|
model.thumbnail = scaleDownThumbnail( model.thumbnail );
|
|
}
|
|
|
|
const preview = createPreviewWithType( model );
|
|
|
|
Object.assign( layout, { dir: model.languageDirection } );
|
|
layoutPreview(
|
|
preview,
|
|
layout,
|
|
getClasses( preview, {
|
|
flippedX: layout.flippedX,
|
|
flippedY: layout.flippedY
|
|
} ),
|
|
SIZES.landscapeImage.h,
|
|
POINTER_SIZE
|
|
);
|
|
return preview.el[ 0 ].outerHTML;
|
|
}
|
|
|
|
export default createPopup;
|