MediaWiki:Common.js

De Magic Quest
Révision datée du 14 mai 2013 à 22:09 par Nical (discussion | contributions) (Page créée avec « Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. : /////////////////////////////////////////////////////// // Codesnippet ... »)
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)
Sauter à la navigation Sauter à la recherche

Note : après avoir enregistré vos modifications, il se peut que vous deviez forcer le rechargement complet du cache de votre navigateur pour voir les changements.

  • Firefox / Safari : maintenez la touche Maj (Shift) en cliquant sur le bouton Actualiser ou pressez Ctrl-F5 ou Ctrl-R (⌘-R sur un Mac)
  • Google Chrome : appuyez sur Ctrl-Maj-R (⌘-Shift-R sur un Mac)
  • Internet Explorer : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5
  • Opera : allez dans Menu → Settings (Opera → Préférences sur un Mac) et ensuite à Confidentialité & sécurité → Effacer les données d’exploration → Images et fichiers en cache.
/* Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. */
///////////////////////////////////////////////////////
// Codesnippet to make your sidebaritems expandable  //
// Use this code ONLY for monobook-Style.            //
///////////////////////////////////////////////////////
 
$(document).ready(function(){
 
  //set the default expanded Items by their headline
  var defaultExpandItems= ['Navigation', 'Orga'];
  //set the basic-name for the cookies, which save the current state of expanding
  var expandCookieName = "disdance_project_wiki_nav_expanded_";
 
  var maxHeights=[]
  var expandeds=[];
  var labels=[];
  initNav();
});
 
function initNav(){
    $('#p-logo').css({'position':'relative', 'display':'block'});;
    $('.generated-sidebar h5,#p-tb h5 ').each(function(i){
 
          var id = $(this).parent().attr('id');           
          maxHeights[id]=$(this).next('div').height();
          var str = $(this).html();
          labels[id]=str;     
 
          if ($.cookie(expandCookieName+id)=='false'  ){               
                expandeds[id]=false;
                minimize( $(this));
 
         } else if ($.cookie(expandCookieName+id)=='true'  ){
                expandeds[id]=true;
                maximize( $(this));
 
         } else if (defaultExpandItems.indexOf(str)==-1){
                expandeds[id]=false;
                minimize( $(this));
         } else {
                expandeds[id]=true;
                maximize( $(this));
         }
         $(this).css({'cursor':'pointer'});
         $(this).click(toggleNav);
    });
}
 
function minimize(target){
    var id=$(target).parent().attr('id');
    //You can change the expires-parameter to save the Cookie longer/shorter than 7 days like in this Code
    $.cookie(expandCookieName+id,'false', { expires: 7});
    var str = labels[id]+"  ►";
    $(target).next('div').animate({'height':'0px'});
    $(target).html(str);    
}
 
function maximize(target){
    var id=$(target).parent().attr('id');
    //You can change the expires-parameter to save the Cookie longer/shorter than 7 days like in this Code
    $.cookie(expandCookieName+id,'true', { expires: 7});
    var str = labels[id]+"  ▼";
    var  newHeight = maxHeights[id];
    $(target).next('div').animate({'height':newHeight+'px'});
    $(target).html(str);    
}
 
function toggleNav(e){
    var id=$(e.target).parent().attr('id');
    expandeds[id]=!expandeds[id];
    if(expandeds[id]==true){ 
       maximize(e.target);
    } 
    else{ 
       minimize(e.target);
    }
} 
 
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////