(function($) {
/**
* Questa parte e` facoltativa
* Serve a raccogliere dalla url il parametro #nometab
* cosi` da poter far aprire la pagina con una specifica
* tab gia` in mostra al posto di un altra.
* Se non la si vuole questa feature basta eliminare il
* blocco qui di seguito.
*/
let pageHash = self.location.hash;
if (pageHash != '') {
let selectedTab = pageHash.substr(1);
$('#tabs > div').removeClass('active');
$('#tabs > div[data-tabname="'+ selectedTab +'"]').addClass('active');
}
/**
* Adesso registriamo l'azione dei tastini
* Questo e` il funzionamento standard
*/
let animationInProgress = false;
$('#labels > a').click(function(e) {
//> Annullo l'azione del click del browser
e.preventDefault();
//> Evitiamo che il click forsennato sulle label causi brutte cose
if (animationInProgress) {
return;
}
//> Raccolgo il nome della tab richiesta e di quella gia` attiva
let tabName = $(this).attr('href').substr(1);
let tabActive = $("#tabs > div.active").data('tabname');
//> Se i nomi non coincidono proseguo ad attivare la tab richiesta
if (tabName !== tabActive) {
//> faccio sparire quella attiva
animationInProgress = true;
$("#tabs > div.active").fadeOut(300, function() {
//> e appena finita l'animazione avvio quella richiesta
$('#tabs > div[data-tabname="'+ tabName +'"]').fadeIn(300, function() {
//> Fine opera: riassegno il class .active
$('#tabs > div').removeClass('active');
$('#tabs > div[data-tabname="'+ tabName +'"]').addClass('active');
animationInProgress = false;
});
});
}
});
})(jQuery);
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.