mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-03 15:38:59 +00:00

Add additional CSS injection to prevent code tag embedded in code tag from having its font size adjusted twice. Discussion: https://postgr.es/m/20170408015201.GA18573@momjian.us
28 lines
999 B
JavaScript
28 lines
999 B
JavaScript
function display_default_font_size(id)
|
|
{
|
|
var x = document.getElementById(id);
|
|
|
|
if (x.currentStyle)
|
|
var y = x.currentStyle['fontSize'];
|
|
else if (window.getComputedStyle)
|
|
var y = document.defaultView.getComputedStyle(x,null).getPropertyValue('font-size');
|
|
return y;
|
|
}
|
|
|
|
document.write('<pre id="monotest" style="display: none;"> </pre>');
|
|
document.write('<p id="paratest" style="display: none;"> </p>');
|
|
var monoSize = parseInt(display_default_font_size("monotest"));
|
|
var propSize = parseInt(display_default_font_size("paratest"));
|
|
var newMonoSize = propSize / monoSize;
|
|
|
|
if (newMonoSize != 1)
|
|
{
|
|
document.write('<style type="text/css" media="screen">'
|
|
+ '#docContainer tt, #docContainer pre, #docContainer code'
|
|
+ '{font-size: ' + newMonoSize.toFixed(1) + 'em;}</style>\n'
|
|
/* prevent embedded code tags from changing font size */
|
|
+ '#docContainer code code'
|
|
+ '{font-size: 1em;}</style>\n');
|
|
}
|
|
|