Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin Tips & Tricks
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
BBCode manager Suggestion: (Nested Spoiler Example)
techtir
Join Date: Sep 2009
Posts: 17

 

Ireland
Show Printable Version Email this Page Subscription
techtir techtir is offline 09-28-2009, 10:00 PM

I was recently adding a spoiler BB code from the site here.

(Sadly I forget which thread I found it).

It didn't work as expected. I was using it to "fold Sections"
Demo http://www.techtir.ie/forums/showthread.php?t=19

Examination suggested that using {option} or {param} in a javascript called function is simply not going to work sensibly if there are multiple instances in the same page. The BB Code will expand and put the javascript function multiple times. Any {option} or {param} in the last instance on the page will "fill in" the values when you click anywhere.

Also I realised that if a BB code has a Javascript function, it will be inserted N times on the page for N instances of the object.

So for now I put the function in headinclude

The BB code manager only has the instance code that calls it with {option} as a parameter to the javascript function.

My suggestions:
  1. NEVER use {option} or {param} in a function.
  2. A later version of BB manager should have an "include once in header" tag for a function.

For those interested here is the code.
(Make sure the <img src= paths match your install from root of web site, both in the javascript function and in the BB code definition that calls it.)
It allows nested folded sections/spoilers
Code:
<script language='JavaScript' type='text/javascript'>
        <!--
            function spoiler(obj,hdtit)
            {

                  for (var i = 0; i < obj.childNodes.length; i++)
                  {
                        if (obj.childNodes[i].id == 'idTitle')
                            titleRow = obj.childNodes[i];
                    if (obj.childNodes[i].id == 'idSpoiler')
                    {
                        if (obj.childNodes[i].style.display != 'none')
                        {
                            obj.childNodes[i].style.display = 'none';
                          // bug next line align="absmiddle"
                        titleRow.innerHTML = '<img src="/forums/images/buttons/collapse_tcat_collapsed.gif" align="absmiddle">&nbsp;'+hdtit;  
                        }
                        else
                        {
                            obj.childNodes[i].style.display = 'block';
                         // bug next line  align="absmiddle"
                         titleRow.innerHTML = '<img src="/forums/images/buttons/collapse_tcat.gif" align="absmiddle">&nbsp;'+hdtit;                           
                        }
                    }
                }
            }
        //--></script>
In the BB code Manager
Answers
Ans

Code:
<div align=center style=""><div align=left onclick="spoiler(this.parentNode,'{option}');" id="idTitle" style="width: 90%; margin-top: 6px; clear: both; border: solid #0B198C; border-width: 1px 1px 1px 1px; padding: 5px 8px 5px; line-height: 15px; font-weight: bold; background: #5C7099 url(/forums/images/gradients/gradient_tcat.gif) repeat-x top left; color: #FFFFFF; font: bold 11px tahoma, verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; cursor: pointer; "><img src="/forums/images/buttons/collapse_tcat_collapsed.gif"  align="absmiddle">&nbsp;{option}</div><div align=left id="idSpoiler" style="display: none; width: 90%; padding: 5px 8px 5px;  border-left: 1px solid #0B198C; border-right: 1px solid #0B198C; border-bottom: 1px solid #0B198C; background: #F5F5F5; color: #000000; font: 10pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; font-weight: normal;">{param} </a></div></div>

[ANS=Some suitable Title]Lots of body, inc BBcode for images, tables & video[/ANS]
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:31 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03528 seconds
  • Memory Usage 2,191KB
  • Queries Executed 16 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete