Add whitelistHtml method

Used in source/authour and description patches

Change-Id: Iff17ee74f7a1bcee1c099053a2b15be7fc8bab77
This commit is contained in:
Mark Holmquist 2013-10-22 12:53:07 -07:00
parent 084cbfe7e4
commit c9bd8416ec

View file

@ -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,