Chaosforge Forum

  • March 28, 2024, 08:21
  • Welcome, Guest
Please login or register.



Login with username, password and session length
Pages: [1]

Author Topic: Request to fix code/mortem tags in spoilers for Chrome/Safari  (Read 4834 times)

AStranger

  • First Lieutenant
  • *
  • Offline Offline
  • Posts: 233
  • Cyberdemon Blade
    • View Profile

Currently if you place a mortem or code tag inside a spoiler tag the mortem/code tag gets set to a height of 20px in all webkit browsers (mainly Chrome and Safari). I've tracked the problem down this file: http://forum.chaosforge.org/Themes/Blackrainv2_20/scripts/theme.js?rc2. The offending function is presented below:
Code: [Select]
// The purpose of this code is to fix the height of overflow: auto blocks, because some browsers can't figure it out for themselves.
function smf_codeBoxFix()
{
var codeFix = document.getElementsByTagName('code');
for (var i = codeFix.length - 1; i >= 0; i--)
{
if (is_webkit && codeFix[i].offsetHeight < 20)
codeFix[i].style.height = (codeFix[i].offsetHeight + 20) + 'px';

else if (is_ff && (codeFix[i].scrollWidth > codeFix[i].clientWidth || codeFix[i].clientWidth == 0))
codeFix[i].style.overflow = 'scroll';

else if ('currentStyle' in codeFix[i] && codeFix[i].currentStyle.overflow == 'auto' && (codeFix[i].currentStyle.height == '' || codeFix[i].currentStyle.height == 'auto') && (codeFix[i].scrollWidth > codeFix[i].clientWidth || codeFix[i].clientWidth == 0) && (codeFix[i].offsetHeight != 0))
codeFix[i].style.height = (codeFix[i].offsetHeight + 24) + 'px';
}
}

Now I'm not quite sure what problem the first if statement is trying to fix, but it is causing the problem that I'm referring to. It looks like the if statement is trying to ensure that the code block is at least 20px high, but I can't figure out a situation where that is needed. It would seem that removing the if statement would probably be the logical answer, but if it really is there for a reason then maybe it should be changed to something like this:
Code: [Select]
if (is_webkit && codeFix[i].offsetHeight < 20 && codeFix[i].parentNode.style.display != "none")
This change fixes the problem I'm talking about, but without knowing the purpose of the if statement I can't tell if it breaks anything. Webkit browsers seem to be pretty compliant, so I kinda doubt that this if statement is needed.
Logged
[24|23|20|18|13] v.0.9.9.3
[17|10|8|5|2] v.0.9.9.2
[15|11|10|6|3] v.0.9.9.1
[18|17|14|10|6] v.0.9.9

AStranger

  • First Lieutenant
  • *
  • Offline Offline
  • Posts: 233
  • Cyberdemon Blade
    • View Profile

Well until this get fixed I made a Chrome extension (more like a hack) that fixes the problem. Specifically it changes the onclick code of the spoiler tags to check for code blocks inside and remove the height value, then show or hide the div.
Logged
[24|23|20|18|13] v.0.9.9.3
[17|10|8|5|2] v.0.9.9.2
[15|11|10|6|3] v.0.9.9.1
[18|17|14|10|6] v.0.9.9

Pricklyman

  • Sergeant Major
  • *
  • Offline Offline
  • Posts: 156
  • Crazy Nutjob - and lovin it
    • View Profile

Holy crap thank you.

Works like a treat.

Although to be honest, I'd much prefer a server-side fix... :P
Logged
Pages: [1]