The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
[HOW TO - vB4] Making Boxes Collapsible
Start: OK, here's a small guide how to make a boxes/layers collapsible. Let's say, you have a simple div-container you want to make collapsible. The css ids and classes assigned to the elements are completely arbitrary. Code:
<div id="test" class="anything"> <h2 class="blockhead"> <span>Collapse it!</span> </h2> <div class="blockrow"> <p>Let's add a button to collapse this box :-)</p> </div> </div> Step 1: Adding "collapse"-class to surrounding container Code:
<div id="test" class="anything collapse"> Step 2: Adding id to what we want to hide As a second step we have to add an unique id to the element that contains what we want to dissapear. Note: This element can be almost any html-tag that can be hidden (div, ul, ol, p, a - you get the idea). Note also: The element has to have an id that needs to be unique not only on the page, but on the whole site. So make sure you use some unique prefix, suffix or something like that (marked in blue). Code:
<div class="blockrow" id="cel_dummy"> Step 3: Adding collapse-button Inside the header add the code for the collapse-button. You'll have to adapt it according to the id you assigned in step 2 (adaptions needed marked in blue). Make sure the part you add inside the image name variable is not the exact same as the id you added to the container that you want to hide. If you add the exact same, the button will vanish under certain circumstances, too: Code:
<a class="collapse" id="collapse_cel_dummy" href="{vb:raw relpath}#top"><img src="{vb:stylevar imgdir_button}/collapse{vb:raw vbcollapse.collapseimg_cel_dummy_img}_40b.png" alt="{vb:rawphrase collapse_this_category}" /></a> Result: In the end, the code will look like that: Code:
<div id="test" class="block collapse"> <h2 class="blockhead"> <span>Collapse it!</span> <a class="collapse" id="collapse_cel_dummy" href="{vb:raw relpath}#top"><img src="{vb:stylevar imgdir_button}/collapse{vb:raw vbcollapse.collapseimg_cel_dummy_img}_40b.png" alt="{vb:rawphrase collapse_this_category}" /></a> </h2> <div class="blockrow" id="cel_dummy"> <p>Let's add a button to collapse this box :-)</p> </div> </div> Collapsed as default? Yes, but... There is a way default the box to be collapsed by default. But this it's quick and dirty, and really not recommended to use. Basically, you have to add display:none to the style of the collapsing container, like so: Code:
<div class="blockrow" id="cel_dummy" style="display: none;">
Collapse more than one box at a time? Yes, but... Now, functionally this is perfectly possible - just use the same id for every element you want to collapse together. But beware: for valid code you can't use duplicate ids on a page. So if you do that, your code will break xhtml validation! I hope this will be useful for some of you! -c Please note that this article has been written first for alpha 1 version and been updated for beta 3. There still may be changes until gold. For example the button used is clearly marked as beta (_40b in the file name). |
#12
|
||||
|
||||
Quote:
To change positioning, you need to add an additional class as described in the postings right before yours to override the settings in collapse class. |
#13
|
|||
|
|||
Quote:
Thanks for the article. |
#14
|
||||
|
||||
So tell me what is wrong with my code ?
Quote:
|
#15
|
||||
|
||||
Example given in article forces the way how it will be displayed. I want to have collapsable blocks but without blockhead and having collapse image in place where I put it. Now it is not possible. Even if I remove classes blockhead and blockrow my collapse image is not in place where I put it but goes to right side and is inside of collapsable block (what also makes me impossible to have it collapsed by default).
So - what changes I need, to have my collapse image in place where it is set? - not moved to other one like it is now. |
#16
|
||||
|
||||
You need to find out what css definitions make it go to the right. Use a tool like firebug for that. IIRC it is the collapsible-class that forces it to the right. Since you need that class for the collapse javascript to work, you'll need to override it.
|
#17
|
||||
|
||||
I was trying to override it by adding also style attribute, but I fail there. Maybe I was using wrong CSS - as I remember I was playing with position. It didn't work so I thought that maybe there is also some JS which is changing it dynamically... - do you know something about that? Maybe you know which CSS style to use to force it staying in its place?
|
#18
|
||||
|
||||
Did you try looking at it using firebug? I can manipulate positioning by modifying a.collapse img, and the javascript does not mess with positioning as far as I can tell.
|
#19
|
||||
|
||||
I'm trying to collapse my header for smaller monitors and have a cookie set so it remembers the open or closed state like VB does in its collapse buttons. It doesn't seem to work. Can anyone help me get this so it remembers the cookie?
Code:
<div id="vb4_container"> <div id="vb4" style="width:920px"><a id="vb4_link" href="http://www.domain.org/"></a> <div id="vb4_content"> <p>Our club was started as a way for ...</p> <ul> <li><a href="http://www.domain.org/register.php">Click Here to learn MORE!</a></li> </ul> </div> </div> <a id="vb4_close" href="#" onclick=" var v_vob = fetch_object('vb4_container'); if(v_vob) { set_cookie('vb4banner_off', v_vob.className ? '' : 1); v_vob.className = v_vob.className ? '' : 'promo_closed'; } return false; "></a> </div> Code:
/* vB4 Promo */ #vb4_container { background-color:#2d2d2d; /*margin: 0 -35px 10px;*/ margin: 0; padding:10px 0 0 0; position:relative; } #vb4 { margin: auto; background: transparent url(http://www.domain.org/images/minimized/vb4_promo_bg.jpg) no-repeat 0 0; height:176px; position:relative; } .promo_closed #vb4 { margin: auto; background: transparent url(http://www.domain.org/images/minimized/vb4_promo_bg.jpg) no-repeat 0 -78px; height:176px; position:relative; } #vb4_link { position:absolute; top:0; left:0; width:580px; height:132px; outline: none; } #vb4_content { position:absolute; right:0; top:0; width:324px; background: transparent url(http://www.domain.org/images/minimized/vb4_promo_title.png) no-repeat -2px 5px; min-height: 64px; } #vb4_content p { font-family:verdana,geneva,lucida,'lucida grande',arial,helvetica,sans-serif; margin-top:46px; margin-bottom:26px; color:#FFF; font-size:11px; } #vb4_content ul { margin:0px; padding:0; position:absolute; bottom:0; } #vb4_content li { list-style-type:none; display:inline; margin-right:10px; } #vb4_content li a { color:#dd0000; font-family:helvetica,sans-serif; font-weight:bold; font-size:14px; text-decoration:none; outline: none; } #vb4_close { position:absolute; bottom:0; right:0; background: transparent url(http://www.domain.org/images/minimized/vb4_promo_minimize.png) no-repeat 0 0; width: 28px; height: 27px; outline: none; } .promo_closed #vb4_content p { display:none; } .promo_closed #vb4 { height:116px; } .promo_closed #vb4_content { top:52px; bottom:16px; } #vb4_container.promo_closed { margin-top: -64px; } .promo_closed #vb4_close { background: transparent url(http://www.domain.org/images/minimized/vb4_promo_maximize.png); outline: none; } /* End vB4 Promo */ |
#20
|
||||
|
||||
I would think that your code collides with vB's. If you're setting your own cookie anyway, just don't use vB's collapsing method at all. That'll be probably much easier than getting this to work together.
|
#21
|
||||
|
||||
I sure could use your help!
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|