|
Post by Wormopolis on Apr 15, 2012 23:47:34 GMT -8
browsers tested: IE, FF and Chrome placement: global footer This code allows you to put a tabbed table in a post that will organize content. lots of class names included for CSS madness! <style = "text/css"> .PT_table {width: 90%; border: #000000 1px solid;} .PT_table_header {text-align: center; font-weight:bold; font-size:20px;} .PT_tabs {text-align:center; background-color: #4444CC} .PT_tabs_selected {text-align:center; background-color: #9999CC} .PT_tabs_hover {text-align:center; background-color: #44CC44} .PT_tabs_selected_hover {text-align:center; background-color: #44CC44} .PT_spots {background-color:#222222;} </style>
<script type="text/javascript"> <!-- // Tabbed Tables in posts // v1.5 // By Wormopolis - [url]www.wormocodes.com[/url] // keep header intact - do not repost
// surround all content with [PTabbedContent] [/PTabbedContent] // optional Table name using [PTabbedContent=Table Name]
// surround each tab content with [PTab=Tab Name] [/PTab]
var maxTabsAcross=3; var openFirstTabByDefault=true;
(function(){ if (pb_action.match(/display|recent|search2/)) { var loopbreaker=0, tablecount=0; for (td=document.getElementsByTagName('td'), tt=0; tt<td.length; tt++) { if (td[tt].width=='80%' && td[tt].className.match(/windowbg/) && td[tt].vAlign=='top' && td[tt].innerHTML.match(/\[PTabbedContent/) && !td[tt].innerHTML.match(/\[norunubbc\]/)) { var newTabTable=td[tt].innerHTML.replace(/\n/g,'').match(/\[PTabbedContent(=(.*?))?\](.*?|\n)\[\/PTabbedContent\]/m); var PT_Title = (newTabTable[1] ? newTabTable[2] : ''); var PT_content = newTabTable[3].split('[/PTab]'); if (!PT_content[PT_content.length-1].match(/\[PTab\]/)) PT_content.pop(); var PT_tabs_final='<table width="100%"><tr>'; var PT_final='<table class="PT_table"><tr>'+ (PT_Title ? '<td class="PT_table_header">' + PT_Title + '</td></tr><tr>' : '')+'<td>replaceLater</td></tr>'; for (tb=0; tb<PT_content.length; tb++) { var temp=PT_content[tb].match(/\[PTab=(.*?)\]/); var PT_tabName= temp[1]; PT_content[tb]=PT_content[tb].replace(/\[PTab=(.*?)\]/,''); var temp2=100 / (parseInt(PT_content.length<maxTabsAcross ? PT_content.length : maxTabsAcross)); PT_tabs_final+='<td ' + (tb==0 ? 'id="firstTab'+tablecount+'"' : '') + ' class="PT_tabs" name="PT_tabs" width="' + temp2 + '%" onmouseover="this.className=this.className+\'_hover\';" onmouseout="this.className=this.className.replace(\'_hover\',\'\');" onclick="PT_tabSelect(this);">' + PT_tabName + '</td>'; if ((tb+1)%maxTabsAcross==0) PT_tabs_final += '</tr><tr>'; PT_final+='<tr id="' + PT_tabName.replace(/\s+?/g,'') + '" style="display:none" class="PT_spots"><td>' + PT_content[tb] + '</td></tr>'; } PT_tabs_final+='</tr></table>'; PT_final+='</table>'; PT_final=PT_final.replace('replaceLater',PT_tabs_final); td[tt].innerHTML=td[tt].innerHTML.replace(/\n/g,'').replace(/\[PTabbedContent(=(.*?))?\](.|\n)*?\[\/PTabbedContent\]/m,PT_final); tt--; if ((loopbreaker++)>10) {alert('infinite loop again'); break;} if (openFirstTabByDefault) PT_tabSelect(document.getElementById('firstTab'+tablecount)); tablecount++; } } } })(); function PT_tabSelect(selected_tab) { keepthis=selected_tab.parentNode.parentNode; for (pt_tabs=keepthis.getElementsByTagName('td'), wtb=0; wtb<pt_tabs.length; wtb++) { pt_tabs[wtb].className='PT_tabs'; } selected_tab.className='PT_tabs_selected'; keepthis=keepthis.parentNode.parentNode.parentNode.parentNode; var tempname=selected_tab.innerHTML.replace(/\s+?/g,''); pt_spots= keepthis.getElementsByTagName('tr'); for (pts=0; pts<pt_spots.length; pts++) { if (pt_spots[pts].className && pt_spots[pts].className=='PT_spots') pt_spots[pts].style.display='none'; } document.getElementById(tempname).style.display=''; } // --> </script>
Preview: wormocodes.com/index.cgi?action=display&board=ttip&thread=1504
|
|
|
Post by Wormopolis on Apr 16, 2012 21:05:43 GMT -8
version update 1.2: now works in IE and has variable for opening first tab by default.
|
|
|
Post by Wormopolis on Apr 21, 2012 11:43:11 GMT -8
version update 1.3: fixed bug that occured for multiple tables in a thread.
|
|
|
Post by Wormopolis on Apr 21, 2012 15:09:55 GMT -8
If anyone has ideas for UBBC button tray images, Im open to suggestion
|
|
hitotsumami
Not New Member
Posts: 13
hitotsumami said 0 great things
|
Post by hitotsumami on Jul 18, 2012 13:43:55 GMT -8
Hi, I'm having a problem with this code.
The 2nd tab has what I typed in it, but then it repeats the info in the first tab and the third tab.
I've tested this code with simple information in each tab, like a single line of text. However, when I use a lot of information, multiple lines of text, using mutliple bold, italics, underlines, and colors, it gives me that weird glitch where the 2nd tab repeats the 1st and 3rd tab informations.
If you need any information, let me know.
|
|
|
Post by Wormopolis on Jul 18, 2012 18:19:26 GMT -8
does the demo page do the same thing for you? can you give me a link to your post?
|
|
hitotsumami
Not New Member
Posts: 13
hitotsumami said 0 great things
|
Post by hitotsumami on Jul 18, 2012 18:51:42 GMT -8
|
|
|
Post by Wormopolis on Jul 18, 2012 19:26:55 GMT -8
Im looking now. you may have found a bug I wasnt aware of...
|
|
|
Post by Wormopolis on Jul 18, 2012 23:54:15 GMT -8
version update 1.5: bug fix that hitotsunami found, as well as added a class for the sections content appears in. also fixed the bug that caused all tables on page to hide content if any tabs were selected in a different table.
|
|
hitotsumami
Not New Member
Posts: 13
hitotsumami said 0 great things
|
Post by hitotsumami on Jul 18, 2012 23:56:50 GMT -8
Thanks so much, it works great now!
Awesome code
|
|
|
Post by Wormopolis on Jul 19, 2012 6:18:10 GMT -8
thank you for the help!
|
|