Common.js
From Sonic Retro
Revision as of 09:20, 21 May 2017 by Scarred Sun (talk | contribs)
Revision as of 09:20, 21 May 2017 by Scarred Sun (talk | contribs)
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
// PootTabs - it poots 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) {
poot.find('.poot-tabs-titletext').html(poot.attr('originalTitle') + ' — ' + pootTabsHere.getTab(poot, poot.attr('pootSelected')).html());
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);
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);
// End of PootTabs