mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-12-01 02:36:35 +00:00
fb5b120515
This patch also removes misplaced empty lines at the beginning of a scope. In PHP code we even have a sniff for these. In JavaScript we don't, but I suggest to be consistent about this. Change-Id: Ic104ae8fe176da1dafa9bc783402adecb71de1f0
37 lines
866 B
JavaScript
37 lines
866 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
|
|
*
|
|
* @returns {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;
|