TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,973
  • Latest: NonStop
Stats
  • Total Posts: 196,236
  • Total Topics: 21,353
  • Online today: 577
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 295
  • Total: 295

[Block] Auto expand / collapse on mouseover/mouseout?

Started by Aqualung, June 01, 2012, 06:02:14 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Freddy

Well spotted ZP, yes that was not working.  It appears FF (and maybe IE) have a problem with the 'compact' display style.

Change this :

function showDiv(id) {
document.getElementById(id).style.display = "compact";
}


To this...

function showDiv(id) {
document.getElementById(id).style.display = "block";
}



ZP, no source code is edited in TP.  It's just on-the-fly javascript.  It finds the img (collapse image) element via it's 'id'.  Once you have the id it can add some javascript to it.  The javascript then hides or shows the associated block (again found via it's 'id').  Hope that makes sense.

IchBin

The next version of TP is shipping with jquery. I'd suggest looking into it to do these things as jquery makes things very simple. Turn that function into this with jquery.
function showDiv(id) {
    $(id).show();
}


To hide it:
function hideDiv(id) {
    $(id).hide();
}

Freddy

Yeah I use prototype a lot and it also has that kind of thing.  Makes coding a lot easier...less key strokes ;)

ZarPrime

Quote from: Freddy on June 11, 2012, 01:06:46 PM
ZP, no source code is edited in TP.  It's just on-the-fly javascript.  It finds the img (collapse image) element via it's 'id'.  Once you have the id it can add some javascript to it.  The javascript then hides or shows the associated block (again found via it's 'id').  Hope that makes sense.

Ahhh, got it.  I understand now. O0 Changing "compact" to "block" made it work right so that is cool.  So this is basically only useful if someone has something they only want to display but not interact with (like links in the block) since the block collapses when you mouseout. ;)

Thanks Freddy.
ZP

Freddy

No problem  :)  Yeah only useful for plain information and not things like links in this way.

This website is proudly hosted on Crocweb Cloud Website Hosting.