Difference between revisions of "User:Lexar/sandbox/Page.js"

From Team Fortress Wiki
Jump to: navigation, search
m
m (removing the setting of the first tab, removing the container variable)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
//my js page for general screwin around
 
//my js page for general screwin around
$('head').append('<link href="https://dl.dropboxusercontent.com/u/32668357/wiki_stuff/tempres/style.css" rel="stylesheet" type="text/css" />');
+
//$('head').append('<link href="https://dl.dropboxusercontent.com/u/32668357/wiki_stuff/tempres/style.css" rel="stylesheet" type="text/css" />');
var WeaponGradesTable = {
+
//Start weapon wear table tabs -----
tabSwitch: function(th,tab,weapons,weapon) {
+
var WeaponWearTable = {
if (!th.hasClass('current')) {
+
tabSwitch: function($this,tab,weapons,weapon) {
var tabIndex = th.parent().index(th);
+
if (!$this.hasClass('current')) {
th.parent().find('.current').removeClass('current');
+
var tabIndex = $this.index();
th.addClass('current');
+
$this.parent().find('.current').removeClass('current');
 +
$this.addClass('current');
 
weapons.find('.current').removeClass('current');
 
weapons.find('.current').removeClass('current');
 
weapon.eq(tabIndex).addClass('current');
 
weapon.eq(tabIndex).addClass('current');
Line 12: Line 13:
 
},
 
},
 
init: function() {
 
init: function() {
var container = $('.weapon-grade-table');
+
$('.weapon-wear-table').each(function(){
container.each(function(){
+
var $this = $(this),
var th = $(this), tabs = th.children('.tabs'), tab = tabs.children('li'), weapons = th.children('.weapons'), weapon = weapons.children('li');
+
tabs = $this.children('.tabs'),
tab.first().addClass('current');
+
tab = tabs.children('li'),
weapon.first().addClass('current');
+
weapons = $this.children('.weapons'),
tab.click(function(){WeaponGradesTable.tabSwitch($(this),tab,weapons,weapon);});
+
weapon = weapons.children('li');
 +
tab.click(function(){
 +
WeaponWearTable.tabSwitch($(this),tab,weapons,weapon);
 +
});
 
});
 
});
//
 
 
}
 
}
 
};
 
};
$(WeaponGradesTable.init);
+
$(WeaponWearTable.init);
 +
//End weapon wear table tabs -----

Latest revision as of 06:03, 16 July 2015

//my js page for general screwin around
//$('head').append('<link href="https://dl.dropboxusercontent.com/u/32668357/wiki_stuff/tempres/style.css" rel="stylesheet" type="text/css" />');
//Start weapon wear table tabs -----
var WeaponWearTable = {
	tabSwitch: function($this,tab,weapons,weapon) {
		if (!$this.hasClass('current')) {
			var tabIndex = $this.index();
			$this.parent().find('.current').removeClass('current');
			$this.addClass('current');
			weapons.find('.current').removeClass('current');
			weapon.eq(tabIndex).addClass('current');
		}
	},
	init: function() {
		$('.weapon-wear-table').each(function(){
			var $this = $(this),
			tabs = $this.children('.tabs'),
			tab = tabs.children('li'),
			weapons = $this.children('.weapons'),
			weapon = weapons.children('li');
			tab.click(function(){
				WeaponWearTable.tabSwitch($(this),tab,weapons,weapon);
			});
		});
	}
};
$(WeaponWearTable.init);
//End weapon wear table tabs -----