TabberDefault

TabberDefault adjusts the initial active tab of tabber instances based on a combination of marked defaults and the URL fragment. This allows users to specify a default tab and, as best as possible, ensures that content of tabs activated by the URL fragment is actually visible. This script only impacts the tabs active upon page load. It should not impact tabs activated by user interaction.
== ==
== ==
In order to mark a tab as the default, the top level of its content must contain an element with the class TabberDefault. The marker may not be nested in the tab's content (ex. it cannot be inside a table) as that would cause issues when trying to resolve nested tabber instances. If more than one tab has a marker in its content, the first tab will be used. Although it doesn't matter what the element is, the following is a simple example which could be made as a template if desired.
=== Tab Selection Process ===
For a given tabber instance, this script does nothing if the initially active tab has been set by tabber's built-in use of the URL fragment. If the instance does not have such a tab, then the script searches for nested instances that do. The active tab is then set to display the first nested tab matching the URL fragment. If the instance does not have any such nested instances, the script then searches the contents of the tabs for default tab markers. Since Tabber instances may be nested, the marker must be placed in the top level of the tab's content. The first tab to contain such a marker is set as the active tab. If no such tab can be found, the script then searches for nested instances that do. If such instances are found, the active tab is set to display the first nested tab with a default marker. If no such instances are found, the first tab is left as the active tab per the default behavior of tabber. When determining which nested tab is "first", the script relies on the order in which elements are returned by functions such as getElementsByClassName. Based on available information, this should result in a pre-order depth-first search.
=== ===
Hide/Show Markup
<tabber>
 |-|Tab 1=This is tab 1.
 |-|Tab 2=This is tab 2.{{#tag: tabber |
 {{!}}-{{!}}Tab 2-1=This is tab 2-1.
 {{!}}-{{!}}Tab 2-2=This is tab 2-2.
 {{!}}-{{!}}Tab 2-3=This is tab 2-3.
 {{!}}-{{!}}Tab 2-4=This is tab 2-4.{{#tag: tabber |
 {{!}}-{{!}}Tab 2-4-1=This is tab 2-4-1.
 {{!}}-{{!}}Tab 2-4-2=This is tab 2-4-2.
 {{!}}-{{!}}Tab 2-4-3=This is tab 2-4-3.
 {{!}}-{{!}}Tab 2-4-4=This is tab 2-4-4.
 {{!}}-{{!}}Tab 2-4-5=This is tab 2-4-5.
 }}
 {{!}}-{{!}}Tab 2-5=This is tab 2-5.
 }}
 |-|Tab 3=This is tab 3.
 |-|Tab 4=This is tab 4.
 |-|Tab 5=This is tab 5.
</tabber>
{{#tag: tabber |
 {{!}}-{{!}}Tab 6=This is tab 6.
 {{!}}-{{!}}Tab 7=This is tab 7.
 {{!}}-{{!}}Tab 8=This is tab 8.
 {{!}}-{{!}}Tab 9=This is tab 9.<tabber>
 |-|Tab 9-1=This is tab 9-1.
 |-|Tab 9-2=This is tab 9-2.
 |-|Tab 9-3=This is tab 9-3.
 |-|Tab 9-4=This is tab 9-4.{{#tag: tabber |
 {{!}}-{{!}}Tab 9-4-1=This is tab 9-4-1.
 {{!}}-{{!}}Tab 9-4-2=This is tab 9-4-2.
 {{!}}-{{!}}Tab 9-4-3=This is tab 9-4-3.
 {{!}}-{{!}}Tab 9-4-4=This is tab 9-4-4.
 {{!}}-{{!}}Tab 9-4-5=This is tab 9-4-5.
 }}
 |-|Tab 9-5=This is tab 9-5.
 </tabber>
 {{!}}-{{!}}Tab 10=This is tab 10.
}}
{{#tag: tabber |
 {{!}}-{{!}}Tab 11=This is tab 11.
 {{!}}-{{!}}Tab 12=This is tab 12.
 {{!}}-{{!}}Tab 13=This is tab 13.{{#tag: tabber |
 {{!}}-{{!}}Tab 2-1=This is tab 2-1.
 {{!}}-{{!}}Tab 2-2=This is tab 2-2.<tabber>
 |-|Tab 2-4-1=This is tab 2-4-1.
 |-|Tab 2-4-2=This is tab 2-4-2.
 |-|Tab 2-4-3=This is tab 2-4-3.
 |-|Tab 2-4-4=This is tab 2-4-4.
 |-|Tab 2-4-5=This is tab 2-4-5.
 </tabber>
 {{!}}-{{!}}Tab 2-3=This is tab 2-3.
 {{!}}-{{!}}Tab 2-4=This is tab 2-4.<tabber>
 |-|Tab 2-4-1=This is tab 2-4-1.
 |-|Tab 2-4-2=This is tab 2-4-2.
 |-|Tab 2-4-3=This is tab 2-4-3.
 |-|Tab 2-4-4=This is tab 2-4-4.
 |-|Tab 2-4-5=This is tab 2-4-5.
 </tabber>
 {{!}}-{{!}}Tab 2-5=This is tab 2-5.
 }}
 {{!}}-{{!}}Tab 14=This is tab 14.
 {{!}}-{{!}}Tab 15=This is tab 15.
}}
<tabber>
 |-|Tab 16=This is tab 16.
 |-|Tab 17=This is tab 17.{{#tag: tabber |
 {{!}}-{{!}}Tab 17-1=This is tab 17-1.
 {{!}}-{{!}}Tab 17-2=This is tab 17-2.
 {{!}}-{{!}}Tab 17-3=This is tab 17-3.
 {{!}}-{{!}}Tab 17-4=This is tab 17-4.{{#tag: tabber |
 {{!}}-{{!}}Tab 17-4-1=This is tab 17-4-1.
 {{!}}-{{!}}Tab 17-4-2=This is tab 17-4-2.
 {{!}}-{{!}}Tab 17-4-3=This is tab 17-4-3.
 {{!}}-{{!}}Tab 17-4-4=This is tab 17-4-4.
 {{!}}-{{!}}Tab 17-4-5=This is tab 17-4-5.
 }}
 {{!}}-{{!}}Tab 17-5=This is tab 17-5.
 }}
 |-|Tab 18=This is tab 18.
 |-|Tab 19=This is tab 19.
 |-|Tab 20=This is tab 20.
</tabber>
<tabber>
 |-|Tab 1=This is tab 1.
 |-|Tab 2=This is tab 2.
 |-|Tab 3=This is tab 3.
 |-|Tab 4=This is tab 4.
 |-|Tab 5=This is tab 5.
</tabber>
<tabber>
 |-|Tab 16=This is tab 16.
 |-|Tab 17=This is tab 17.
 |-|Tab 18=This is tab 18.
 |-|Tab 19=This is tab 19.
 |-|Tab 20=This is tab 20.
</tabber>