2018-03-13 22:03:49 +00:00
|
|
|
/**
|
|
|
|
* @module preview
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { escapeHTML } from './templateUtil';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {ext.popups.PreviewModel} model
|
|
|
|
* @param {boolean} showTitle
|
|
|
|
* @param {string} extractMsg
|
|
|
|
* @param {string} linkMsg
|
|
|
|
* @return {string} HTML string.
|
|
|
|
*/
|
|
|
|
export function renderPreview(
|
|
|
|
{ title, url, type }, showTitle, extractMsg, linkMsg
|
|
|
|
) {
|
|
|
|
title = escapeHTML( title );
|
|
|
|
extractMsg = escapeHTML( extractMsg );
|
|
|
|
linkMsg = escapeHTML( linkMsg );
|
|
|
|
return `
|
2018-03-20 17:01:18 +00:00
|
|
|
<div class='mwe-popups mwe-popups-type-${ type }' role='tooltip' aria-hidden>
|
2018-03-13 22:03:49 +00:00
|
|
|
<div class='mwe-popups-container'>
|
2018-03-20 17:01:18 +00:00
|
|
|
<div class='mw-ui-icon mw-ui-icon-element mw-ui-icon-preview-${ type }'></div>
|
|
|
|
${ showTitle ? `<strong class='mwe-popups-title'>${ title }</strong>` : '' }
|
|
|
|
<a href='${ url }' class='mwe-popups-extract'>
|
|
|
|
<span class='mwe-popups-message'>${ extractMsg }</span>
|
2018-03-13 22:03:49 +00:00
|
|
|
</a>
|
|
|
|
<footer>
|
2018-03-20 17:01:18 +00:00
|
|
|
<a href='${ url }' class='mwe-popups-read-link'>${ linkMsg }</a>
|
2018-03-13 22:03:49 +00:00
|
|
|
</footer>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`.trim();
|
|
|
|
}
|