mediawiki-extensions-Popups/.storybook/helpers/createPopup.js
Thiemo Kreuz fb5b120515 Minor fix-ups to type hints in JavaScript code
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
2019-02-14 11:15:01 +01:00

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;