MediaWiki:Common.js

From Before Darkness Falls Wiki
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
$(".bdf-infobox-section-tab").click(function(){
	if (!this.classList.contains('bdf-infobox-section-tab-selected')){
		var tabs = this.parentElement.children
	
		var selected_tab = -1
	
		for (var i = 0; i < tabs.length; i++){
			if (tabs[i].classList.contains('bdf-infobox-section-tab-selected')){
				tabs[i].classList.remove('bdf-infobox-section-tab-selected');
			}
			if (tabs[i] == this){
				selected_tab = i;
			}
		}
		this.classList.add('bdf-infobox-section-tab-selected');
	
		var tabs_content = this.parentElement.parentElement.querySelector('.bdf-infobox-tabs-content').children
		
		for (var o = 0; o < tabs_content.length; o++){
			if (!tabs_content[o].classList.contains('bdf-infobox-section-tab-content-closed')){
				tabs_content[o].classList.add('bdf-infobox-section-tab-content-closed');
			}
		}
		
		tabs_content[selected_tab].classList.remove('bdf-infobox-section-tab-content-closed');
	}
});

$(".bdf-section-tab").click(function(){
	if (!this.classList.contains('bdf-section-tab-selected')){
		var tabs = this.parentElement.children
	
		var selected_tab = -1
	
		for (var i = 0; i < tabs.length; i++){
			if (tabs[i].classList.contains('bdf-section-tab-selected')){
				tabs[i].classList.remove('bdf-section-tab-selected');
			}
			if (tabs[i] == this){
				selected_tab = i;
			}
		}
		this.classList.add('bdf-section-tab-selected');
	
		var tabs_content = this.parentElement.parentElement.querySelector('.bdf-tabs-content').children
		
		for (var o = 0; o < tabs_content.length; o++){
			if (!tabs_content[o].classList.contains('bdf-section-tab-content-closed')){
				tabs_content[o].classList.add('bdf-section-tab-content-closed');
			}
		}
		
		tabs_content[selected_tab].classList.remove('bdf-section-tab-content-closed');
	}
});