mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-12-21 03:22:41 +00:00
c35715bdec
This gets rid of a little bit of code duplication, and makes the interfaces all conform to one standard again after I05ed4b8 left them in a little inconsistent (but properly documented) state. Bug: T214970 Change-Id: If8407c1a48aff1cb31fc2e74b3c2b846e79a3cb5
37 lines
958 B
JavaScript
37 lines
958 B
JavaScript
/**
|
|
* @module preview
|
|
*/
|
|
|
|
import { renderPopup } from '../popup/popup';
|
|
import { escapeHTML } from '../templateUtil';
|
|
|
|
/**
|
|
* @param {ext.popups.PreviewModel} model
|
|
* @param {boolean} showTitle
|
|
* @param {string} extractMsg
|
|
* @param {string} linkMsg
|
|
* @return {jQuery}
|
|
*/
|
|
export function renderPreview(
|
|
model, showTitle, extractMsg, linkMsg
|
|
) {
|
|
const title = escapeHTML( model.title ),
|
|
url = escapeHTML( model.url ),
|
|
type = escapeHTML( model.type );
|
|
extractMsg = escapeHTML( extractMsg );
|
|
linkMsg = escapeHTML( linkMsg );
|
|
|
|
return renderPopup( model.type,
|
|
`
|
|
<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>
|
|
</a>
|
|
<footer>
|
|
<a href='${ url }' class='mwe-popups-read-link'>${ linkMsg }</a>
|
|
</footer>
|
|
`
|
|
);
|
|
}
|