[Rt-devel] Re: [Rt-commit] r3277 - in rt/branches/CHALDEA-EXPERIMENTAL: . bin html html/Elements html/Ticket html/Ticket/Elements lib/RT

Ruslan U. Zakirov Ruslan.Zakirov at miet.ru
Tue Jul 5 23:09:30 EDT 2005


Thomas Sibley wrote:
> Ruslan U. Zakirov wrote:
> 
>> This is not crossbrowser hideshow function.
>> Should be something like:
>> <<<
>> if (t.className.match(/\bhidden\b/))
>>   t.className = t.className.replace(/\s?\bhidden\b/, '');
>> else
>>   t.className += ' hidden';
>>
>> + CSS record for "hidden" class
> 
> 
> Which browser(s) won't support the t.style.display property?  (Mostly
> curious than anything.)
style.display = "none" is ok for all browsers I know, but when you want
 to show element then you have to restore default value which is browser
specific and is not in the standard.

Examples: IE(don't have win* near to check what version) throw
exceptions if you try to set "table" for table element because it
doesn't know such display value(mozilla also reports errors about wrong
values, but only in debug mode). Of course you can use "block", but
gecko uses different math to calculate height and width of the blocks
and tables, so you loose layout. I know only one way to restore default
display value - multiple classes.
I can find my old function based on the style.display that I was using
before, but it's a lot more complicated with browser checks...
Here is some old-old variant:

function hideNode( node )
{
        if(node.nodeType != 1) return;
        node.style.display = "none";
        return;
}

function showNode( node )
{
        if(node.nodeType != 1) return;
        switch( node.nodeName ) {
                case 'a':
                case 'A':
                case 'span':
                case 'SPAN':
                        node.style.display = "inline";
                        break;
                default:
                        node.style.display = "block";
        }
        return;
}



> 
>> also should be more generic:
>>     idstring = "element-" + num;
>> is crap. function should take DOM object or object id.
> 
> 
> I fixed this "problem" earlier today in my local working copy, but I
> haven't pushed it to the main repo yet.  I'll probably push it tonight.
> 
> In reality though, there's nothing (too) wrong with the way it was done
> since it was a special use function and not a true generalized hideshow
> func.
Hide/show functions are one of the most used and IMHO should be generalized.

> 
> Cheers,
> Tom
> 



More information about the Rt-devel mailing list