MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
from team fortress wiki
imported>StarlightFantasy
(Created page with "→‎Any JavaScript here will be loaded for all users on every page load.: /** * Keep code in MediaWiki:Common.js to a minimum as it is unconditionally * loaded for all users on every wiki page. If possible create a gadget that is * enabled by default instead of adding it here (since gadgets are fully * optimized ResourceLoader modules with possibility to add dependencies etc.) * * Since Common.js isn't a gadget, there is no place to declare its * dependencies, so...")
imported>Logoarto
(from team fortress wiki)
Line 323: Line 323:
/*Discord widget*/
/*Discord widget*/
$( "#discord-widget" ).html('<iframe src="https://discord.com/widget?id=333345832059273216&theme=dark" width="100%" height="255px" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>');
$( "#discord-widget" ).html('<iframe src="https://discord.com/widget?id=333345832059273216&theme=dark" width="100%" height="255px" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>');
// PootTabs by User:WindPower~
// It puts tabs on pages.
var pootTabsHere = {
    animationsEnabled: $.support.opacity,
getTab:function(poot, index) {
return $(poot.children('.poot-tabs').children('ul').children('li')[parseInt(index)]);
},
changeTab:function(poot, index, duration, force) {
if(index == parseInt(poot.attr('pootSelected')) && !force && duration) return;
if(!pootTabsHere.animationsEnabled) {
duration = 0;
}
poot.attr('pootSelected', index.toString());
var babies = poot.children('.poot-tabs-content').children();
babies.each(function() {
$(this).fadeOut(duration, function(){
$(this).removeClass('poot-tabs-selected');
});
});
$(babies[index]).each(function() {
$(this).fadeIn(duration, function(){
$(this).addClass('poot-tabs-selected');
});
});
var cowtabs = poot.children('.poot-tabs').children('ul').children('li');
cowtabs.removeClass('poot-tabs-selected');
$(cowtabs[index]).addClass('poot-tabs-selected');
pootTabsHere.updatePoot(poot, $(babies[index]).height());
},
updatePoot:function(poot, babysize) {
if(poot.hasClass('poot-tabs-notitle')) {
poot.find('.poot-tabs-titletext').html(pootTabsHere.getTab(poot, poot.attr('pootSelected')).html());
} else {
poot.find('.poot-tabs-titletext').html(poot.attr('originalTitle') + ' &mdash; ' + pootTabsHere.getTab(poot, poot.attr('pootSelected')).html());
}
if(poot.has('.poot-tabs-edittabs') && poot.has('.poot-tabs-navbar')) {
try {
poot.find('.poot-tabs-navbar').html($(poot.children('.poot-tabs-edittabs').children('span')[parseInt(poot.attr('pootSelected'))]).html());
} catch(e) {}
}
var bestHeight = Math.max(poot.children('.poot-tabs-content').height(), Math.max(poot.children('.poot-tabs').height(), babysize)).toString() + 'px';
poot.children('.poot-tabs-content').css('height', bestHeight);
if(poot.attr('vertical')) {
poot.children('.poot-tabs').css('height', bestHeight);
}
},
toggleCollapse:function(poot) {
var pootLinkText = poot.children('.poot-tabs-showhide').text().split(';');
var duration = pootTabsHere.animationsEnabled ? parseInt(poot.attr('pootslideduration')) : 0;
if(poot.attr('pootcollapse') != 'true') {
poot.attr('pootcollapse', 'true');
poot.find('.poot-tabs-hidelink a').text(pootLinkText[0]);
poot.children('.poot-tabs, .poot-tabs-content').slideUp(duration);
}
else {
poot.attr('pootcollapse', '');
poot.find('.poot-tabs-hidelink a').text(pootLinkText[1]);
poot.children('.poot-tabs, .poot-tabs-content').slideDown(duration);
}
},
delayHeight:function(poot, selected) {
setTimeout(function() {
poot.attr('pootselected', selected.toString());
pootTabsHere.changeTab(poot, selected, 0, true);
if(poot.hasClass('poot-tabs-collapsed')) {
pootTabsHere.toggleCollapse(poot);
}
}, 100);
},
poot:function() {
var dis = $(this);
dis.removeClass('poot-tabs-nojs'); // If this thing runs, JS is on
var ind = 0;
dis.attr('originalTitle', dis.find('.poot-tabs-titletext').html());
var selected = /poot-tabs-selected-(\d+)/i.exec(dis.attr('class'));
if(selected) {
pootTabsHere.delayHeight(dis, parseInt(selected[1])-1);
}
else {
pootTabsHere.delayHeight(dis, 0);
}
var duration = dis.hasClass('poot-tabs-noanimations') ? 0 : 200;
dis.attr('pootslideduration', dis.hasClass('poot-tabs-noanimations') ? '0' : '75');
dis.children('.poot-tabs').children('ul').children('li').each(function(){
var thisInd = ind;
$(this).click(function(){
pootTabsHere.changeTab(dis, thisInd, duration, false);
$(this).blur();
$(this).find('*').blur();
return false;
});
ind++;
});
var isVertical = dis.hasClass('poot-tabs-vertical');
dis.attr('pootvertical', isVertical ? 'true' : '');
if(isVertical) {
var teenie = dis.children('.poot-tabs').width().toString() + 'px';
dis.children('.poot-tabs-content').css('margin-left', teenie);
}
dis.attr('pootcollapse', ''); // False
dis.find('.poot-tabs-hidelink a').click(function(){
pootTabsHere.toggleCollapse(dis);
return false;
});
},
init:function() {
$('.poot-tabs-container').each(pootTabsHere.poot);
}
};
$(pootTabsHere.init);
Anonymous user

Navigation menu