mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-24 00:03:56 +00:00
Add whitelistHtml method
Used in source/authour and description patches Change-Id: Iff17ee74f7a1bcee1c099053a2b15be7fc8bab77
This commit is contained in:
parent
084cbfe7e4
commit
c9bd8416ec
|
@ -79,6 +79,42 @@
|
|||
viewer.lightbox.open();
|
||||
|
||||
viewer.fetchImageInfo( fileTitle, function ( imageInfo ) {
|
||||
function whitelistHtml( $ele ) {
|
||||
function test( $ele ) {
|
||||
return $ele.jquery && (
|
||||
$ele.is( 'a' ) ||
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
var $children,
|
||||
whitelisted = '';
|
||||
|
||||
if ( $ele && $ele.jquery && $ele.contents ) {
|
||||
$children = $ele.contents();
|
||||
} else if ( $ele && $ele.textContent ) {
|
||||
return $ele.textContent;
|
||||
} else if ( $ele ) {
|
||||
return $ele;
|
||||
}
|
||||
|
||||
if ( !$children || $children.length === 0 ) {
|
||||
return $ele.text();
|
||||
}
|
||||
|
||||
$children.each( function ( i, ele ) {
|
||||
var $ele = $( ele );
|
||||
|
||||
if ( test( $ele ) === true ) {
|
||||
whitelisted += $ele.html( whitelistHtml( $ele ) ).get( 0 ).outerHTML;
|
||||
} else {
|
||||
whitelisted += '<span>' + whitelistHtml( $ele ) + '</span>';
|
||||
}
|
||||
} );
|
||||
|
||||
return whitelisted;
|
||||
}
|
||||
|
||||
var extmeta,
|
||||
repoInfo, articlePath,
|
||||
ui = viewer.lightbox.iface,
|
||||
|
|
Loading…
Reference in a new issue