Difference between revisions of "User:Lexar/sandbox/Page.js"
< User:Lexar | sandbox
m (weapon table concept 2) |
m (naming) |
||
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 | + | var WeaponWearTable = { |
tabSwitch: function(th,tab,weapons,weapon) { | tabSwitch: function(th,tab,weapons,weapon) { | ||
if (!th.hasClass('current')) { | if (!th.hasClass('current')) { | ||
Line 12: | Line 12: | ||
}, | }, | ||
init: function() { | init: function() { | ||
− | var container = $('.weapon- | + | var container = $('.weapon-wear-table, .weapon-wear-table-2'); |
container.each(function(){ | container.each(function(){ | ||
var th = $(this), tabs = th.children('.tabs'), tab = tabs.children('li'), weapons = th.children('.weapons'), weapon = weapons.children('li'); | var th = $(this), tabs = th.children('.tabs'), tab = tabs.children('li'), weapons = th.children('.weapons'), weapon = weapons.children('li'); | ||
tab.first().addClass('current'); | tab.first().addClass('current'); | ||
weapon.first().addClass('current'); | weapon.first().addClass('current'); | ||
− | tab.click(function(){ | + | tab.click(function(){WeaponWearTable.tabSwitch($(this),tab,weapons,weapon);}); |
}); | }); | ||
// | // | ||
} | } | ||
}; | }; | ||
− | $( | + | $(WeaponWearTable.init); |
Revision as of 16:03, 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 WeaponWearTable = { tabSwitch: function(th,tab,weapons,weapon) { if (!th.hasClass('current')) { var tabIndex = th.index(); th.parent().find('.current').removeClass('current'); th.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 th = $(this), tabs = th.children('.tabs'), tab = tabs.children('li'), weapons = th.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);