R3277 - in rt/branches/CHALDEA-EXPERIMENTAL: . bin html html/Elements html/Ticket html/Ticket/Elements lib/RT

alexmv@bestpractical.com wrote:

Author: alexmv
Date: Fri Jul 1 16:12:56 2005
New Revision: 3277

[snip]

Added: rt/branches/CHALDEA-EXPERIMENTAL/html/rt.js

— (empty file)
+++ rt/branches/CHALDEA-EXPERIMENTAL/html/rt.js Fri Jul 1 16:12:56 2005
@@ -0,0 +1,19 @@
+% $r->content_type(‘application/x-javascript’);
+
+function hideshow(num) {

  • idstring = “element-” + num;
  • chunk = document.getElementById(idstring);
  • if ( chunk.style.display == “none”) {
  • chunk.style.display = chunk.style.tag;
  • } else {
  •    chunk.style.tag = chunk.style.display;
    
  •    chunk.style.display = "none";
    
  • }
    +}

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

also should be more generic:
idstring = “element-” + num;
is crap. function should take DOM object or object id.

Ruslan.

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.) I am aware that the t.style.tag thing is a bit
sour.

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.

Cheers,
Tom

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.

Ruslan U. Zakirov wrote:

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.

Ah, good point.

Hide/show functions are one of the most used and IMHO should be generalized.

True enough. It’ll be fixed tonight.

Thanks for the heads up!

Cheers,
Tom