Difference between revisions of "User:Lexar/sandbox/Page.js"
< User:Lexar | sandbox
m (Protected "User:Lexar/sandbox/Page.js" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))) |
m (changed th to $this) |
||
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 WeaponWearTable = { | var WeaponWearTable = { | ||
− | tabSwitch: function( | + | tabSwitch: function($this,tab,weapons,weapon) { |
− | if (! | + | if (!$this.hasClass('current')) { |
− | var tabIndex = | + | var tabIndex = $this.index(); |
− | + | $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 14: | Line 14: | ||
var container = $('.weapon-wear-table, .weapon-wear-table-2'); | var container = $('.weapon-wear-table, .weapon-wear-table-2'); | ||
container.each(function(){ | container.each(function(){ | ||
− | var | + | var $this = $(this), tabs = $this.children('.tabs'), tab = tabs.children('li'), weapons = $this.children('.weapons'), weapon = weapons.children('li'); |
tab.first().addClass('current'); | tab.first().addClass('current'); | ||
weapon.first().addClass('current'); | weapon.first().addClass('current'); |
Revision as of 02:18, 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" />'); 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() { var container = $('.weapon-wear-table, .weapon-wear-table-2'); container.each(function(){ var $this = $(this), tabs = $this.children('.tabs'), tab = tabs.children('li'), weapons = $this.children('.weapons'), weapon = weapons.children('li'); tab.first().addClass('current'); weapon.first().addClass('current'); tab.click(function(){WeaponWearTable.tabSwitch($(this),tab,weapons,weapon);}); }); // } }; $(WeaponWearTable.init);