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

From Team Fortress Wiki
Jump to: navigation, search
m
m
Line 2: Line 2:
 
$('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 = {
 
var WeaponGradesTable = {
 +
tabSwitch: function(th,tab,weapons,weapon) {
 +
if (!th.hassClass('current')) {
 +
var tabIndex = th.parent().index(th);
 +
th.parent().find('.current').removeClass('current');
 +
th.addClass('current');
 +
weapons.find('.current').removeClass('current');
 +
weapon.eq(tabIndex).addClass('current');
 +
}
 +
},
 
init: function() {
 
init: function() {
 
var container = $('.weapon-grade-table'), tabs = container.children('.tabs'), tab = tabs.children('li'), weapons = container.children('.weapons'), weapon = weapons.children('li');
 
var container = $('.weapon-grade-table'), tabs = container.children('.tabs'), tab = tabs.children('li'), weapons = container.children('.weapons'), weapon = weapons.children('li');
tab.first().addClass('current');
+
container.each(function(){
weapon.first().addClass('current');
+
tab.first().addClass('current');
//tab.click(function(){tabSwitch($(this),tab,weapons,weapon);});
+
weapon.first().addClass('current');
 +
tab.click(function(){tabSwitch($(this),tab,weapons,weapon);});
 +
});
 
}
 
}
 
};
 
};
 
$(WeaponGradesTable.init);
 
$(WeaponGradesTable.init);

Revision as of 04:51, 4 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" />');
var WeaponGradesTable = {
	tabSwitch: function(th,tab,weapons,weapon) {
		if (!th.hassClass('current')) {
			var tabIndex = th.parent().index(th);
			th.parent().find('.current').removeClass('current');
			th.addClass('current');
			weapons.find('.current').removeClass('current');
			weapon.eq(tabIndex).addClass('current');
		}
	},
	init: function() {
		var container = $('.weapon-grade-table'), tabs = container.children('.tabs'), tab = tabs.children('li'), weapons = container.children('.weapons'), weapon = weapons.children('li');
		container.each(function(){
			tab.first().addClass('current');
			weapon.first().addClass('current');
			tab.click(function(){tabSwitch($(this),tab,weapons,weapon);});
		});
	}
};
$(WeaponGradesTable.init);