source: josm/trunk/tools/japicc/modules/Internals/Js/Tabs.js@ 19229

Last change on this file since 19229 was 11682, checked in by Don-vip, 8 years ago

update to japi-compliance-checker 2.1

File size: 2.5 KB
RevLine 
[11682]1function initTabs()
2{
3 var url = window.location.href;
4 if(url.indexOf('_Source_')!=-1 || url.indexOf('#Source')!=-1)
5 {
6 var tab1 = document.getElementById('BinaryID');
7 var tab2 = document.getElementById('SourceID');
8 tab1.className='tab disabled';
9 tab2.className='tab active';
10 }
11
12 var sets = document.getElementsByTagName('div');
13 for (var i = 0; i < sets.length; i++)
14 {
15 if (sets[i].className.indexOf('tabset') != -1)
16 {
17 var tabs = [];
18 var links = sets[i].getElementsByTagName('a');
19 for (var j = 0; j < links.length; j++)
20 {
21 if (links[j].className.indexOf('tab') != -1)
22 {
23 tabs.push(links[j]);
24 links[j].tabs = tabs;
25 var tab = document.getElementById(links[j].href.substr(links[j].href.indexOf('#') + 1));
26 //reset all tabs on start
27 if (tab)
28 {
29 if (links[j].className.indexOf('active')!=-1) {
30 tab.style.display = 'block';
31 }
32 else {
33 tab.style.display = 'none';
34 }
35 }
36 links[j].onclick = function()
37 {
38 var tab = document.getElementById(this.href.substr(this.href.indexOf('#') + 1));
39 if (tab)
40 {
41 //reset all tabs before change
42 for (var k = 0; k < this.tabs.length; k++)
43 {
44 document.getElementById(this.tabs[k].href.substr(this.tabs[k].href.indexOf('#') + 1)).style.display = 'none';
45 this.tabs[k].className = this.tabs[k].className.replace('active', 'disabled');
46 }
47 this.className = 'tab active';
48 tab.style.display = 'block';
49 // window.location.hash = this.id.replace('ID', '');
50 return false;
51 }
52 }
53 }
54 }
55 }
56 }
57
58 if(url.indexOf('#')!=-1) {
59 location.href=location.href;
60 }
61}
62
63if (window.addEventListener) window.addEventListener('load', initTabs, false);
64else if (window.attachEvent) window.attachEvent('onload', initTabs);
Note: See TracBrowser for help on using the repository browser.