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: 150
  • Total: 150

[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.

Aqualung

I read earlier that you couldnt make the blocks be collapsed as default¨, but say I got a friend who actually made that work - Now, is there any possibility to add a script that auto expands the block when you mousover the title, (the only visible thing when block is collapsed) and then autocollapse the block when you mouseout again?

Maxx1

I myself would consider this one of those things maybe nice to have, but not needed... The only sanario I can see this being useful is for mobile devices, that I think I mention once before. But at this time there are some working with this type theme/s I don't believe there are any that are ready for them att>?<

Another thing you do not always need to make so many main categories, You can create like one/two and have the others under it, and then Child board/s under those. This will limit the amount of Cat title bars.

I have been working hard on clean themes with less bars and image> and this maybe something Myself or a themer may be able to do I may look into this, but for the portal TP, is just fine for me!

JMHO

regards,
Maxx
But Mama, That's Where all the fun is!

Aqualung

I didn't mean the forum categorys themselves, but I meant the php block that I have on my sidepanel
What would be cool was a javascript that had them collapsed as default upon entering the site and then a mouseover/mouseout effect to show/hide content.
Here's the site www.sacrilegeguild.com

Freddy

You can do that with javascript pretty easily.  I don't have time to code the thing for you but try playing around with this example I wrote.  Copy & paste it into a new HTML file and just open it on your desktop.  It should get you started.

<html>

<div id="someelement" onmouseover="showDiv('hidden');" onmouseout="hideDiv('hidden');">Hover Here
<div id="hidden" style="display: none; height: 150px; width: 400px; background: #ccc">
Eam eu oratio possim moderatius. Per at electram maluisset abhorreant, enim inciderint et vel. An partem docendi vel. Per graeco omnesque euripidis ex, mea no ubique facilisis voluptaria. Suavitate reformidans qui ut. Eos cu choro deserunt, vis admodum singulis pertinacia in. Id vidisse argumentum qui, vis nulla postea ceteros at. Ea sea erant consulatu.
</div>
</div>
<div>
Some other content here...
</div>

<script language="javascript" type="text/javascript">

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

function hideDiv(id) {
document.getElementById(id).style.display = "none";
}

</script>

</html>

Aqualung

I can make that script working in a html/javascript block a textmodifer to show/hide (hover here) - BUT that is not exactly what I'm looking for.
I've attached 2 screenshots so you can see what I plan on doing.

The first problem is that the content that's inside the block is a php script and it has to be saved in a php block. It does not work in a HTML block.
The second problem is that I want the block to be collapsed by default when you first enter the site (when people expand/collapse it gets stored in their cache, but I need the block to be forced to be collapsed upon the first visit)
What I want then is to view only the title bar / header text and onmouseover use the expand option, then on mouseout use the collapse option.

Onmouseout - http://i49.tinypic.com/2coflao.png
Onmouseover - http://i47.tinypic.com/wtggpd.png

Freddy

Well you can add attributes on the fly, but you need some way to hook into the layout.  The title bar of the blocks do not have an id attribute, so you cannot pop any new attributes in there as far as I can see.

If the title of the block had an id it could be done, but alas not....I will think on it some more, but I don't think there is a way without modifying TP.

Freddy

This is the closest I can get.  It hides the block content on page load.  After that the only way to see it is by hovering over the expand/collapse button - because this is the only element that has an id I can hook in to.

This is used on block11 as it is the one you have on your site.  Try it out on some fresh block first maybe, but don't forget to change the block numbers...block11 x 3 and blockcollapse11...




echo '
<script language="javascript" type="text/javascript">
hideElement(\'block11\');

addAttributes("blockcollapse11");

function addAttributes(id) {

document.getElementById(id).setAttribute("onmouseover", "showElement(\'block11\');");
document.getElementById(id).setAttribute("onmouseout", "hideElement(\'block11\');");
}

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

function hideElement(id) {
document.getElementById(id).style.display = "none";
}

</script>';

echo 'Some text content or something else here....';

Aqualung

Thanks bud, I'm able to put this to good use.
I was really hoping to be able to use the title.bar as an Id for expand/collapse, but I see that you are right regarding it have to be bound to an ID.

I did try a little workaround though. I centered the expand/collapse images onto the middle of the block, then I made them transparant and increased their height and width for a temp. fix. It seemed good at first, but unfortunately the text written on the titlebar below was not visible through the transparant picture, only the block itself :p

Thanks anyways. I'm quite happy now that the blocks are autocollapsed upon visit.

Freddy


ZarPrime

Interesting how that works Freddy.  I know you've been studying up on your javascript so good job on that. O0 I looked at the right panel on Aqualung's site --> http://www.sacrilegeguild.com/

I tried hovering over the down arrow to the right of the top one (World Bosses) using FireFox and it wouldn't expand.  I had to click the arrow to make it expand.  Moving the mouse off of the arrow though did indeed make it collapse.  Is that how it is supposed to work?

Aqualung, any chance that you could post the code you are using for that one (World Bosses) using the code tags here (#)?  I'd like to see how that works.  I'm still confused on how you were able to do that though.  Did you guys have to edit any of the core TP code to get this to work?

ZarPrime

This website is proudly hosted on Crocweb Cloud Website Hosting.