Code tags do not display properly on Chrome

Started by winkio, November 23, 2012, 02:07:03 am

Previous topic - Next topic

winkio

It's been like this for years, but we should really do something about it.  Code boxes on chrome always collapse to 1.5 or so lines, so it is really annoying to scroll through them when you can't see more than one line at a time.  It should be an easy fix to define a minimum height or minimum number of lines to display.

G_G

I've noticed this too, but what's really odd is sometimes it'll display properly, other times it won't.

Blizzard

I think that it should actually work fine. If I remember right, the CSS defines the height of the boxes. Maybe it uses height-in-points or height-in-pixels instead of height-in-lines. I'll check this out. Or somebody feels up to messing around with the source in your browser and try to fix it, feel free to do so.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

its'a bug with web kit based browsers when the code boxes are inside a spoiler.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

G_G

November 23, 2012, 09:14:03 am #4 Last Edit: November 23, 2012, 09:22:27 am by gameus
I found the culprit.
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
window.addEventListener("load", smf_codeFix, false);
function smf_codeFix()
{
   var codeFix = document.getElementsByTagName ? document.getElementsByTagName("div") : document.all.tags("div");
   for (var i = 0; i < codeFix.length; i++)
   {
       if ((codeFix[i].className == "code" || codeFix[i].className == "post" || codeFix[i].className == "signature") && codeFix[i].offsetHeight < 20)
           codeFix[i].style.height = (codeFix[i].offsetHeight + 20) + "px";
   }
}
// ]]></script>

When this JS is applied, it's setting the code box's height to 20 pixels.


If you can figure out where that JS is being set (which is in one of the theme files I assume) then we can simply force the height of the code boxes. I've been doing some testing and it's really odd. Some codeboxes get generated with an offsetHeight of 0 and others get an offsetHeight of 28.

Blizzard

Found it, fixed it. The spoiler uses a style attribute called "display". The thing is that Webkit does not seem to propagate the change of height when "display" is changed to the children so I basically had to change this callback:

Spoiler: ShowHide
content = this.parentNode.parentNode.lastChild;
if (content.style.display == \'none\')
{
    content.style.display = \'block\';
}
else
{
    content.style.display = \'none\';
}
return false;


to this:

Spoiler: ShowHide
content = this.parentNode.parentNode.lastChild;
if (content.style.display == \'none\')
{
    content.style.display = \'block\';
}
else
{
    content.style.display = \'none\';
}
content.lastChild.style.height = content.style.height;
return false;


Chrome users, notice how it works properly now. <3
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

winkio


Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.