2018-12-12 23:08:38 +00:00
|
|
|
import { SIZES } from '../../src/ui/thumbnail';
|
|
|
|
import { createPreviewWithType, layoutPreview, getClasses } from '../../src/ui/renderer.js';
|
|
|
|
import scaleDownThumbnail from './scaleDownThumbnail';
|
|
|
|
|
|
|
|
const POINTER_SIZE = 8;
|
|
|
|
|
|
|
|
/**
|
2019-02-14 10:13:33 +00:00
|
|
|
* Creates a static/stateless Popup and returns its HTML.
|
2018-12-12 23:08:38 +00:00
|
|
|
*
|
|
|
|
* @param {ext.popups.PreviewModel} model
|
|
|
|
* @param {object} layout
|
|
|
|
*
|
2019-08-05 12:35:21 +00:00
|
|
|
* @return {string} HTML
|
2018-12-12 23:08:38 +00:00
|
|
|
*/
|
|
|
|
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;
|