view RollUp.js @ 74:d9490757a111

Aide pour IE: Classes explicites et pas de syntaxe XHTML. Le selecteur [id^='Gest'], bien que pratique, n'est pas supporter par IE6. En conséquence, j'ai ajouté une classe Gestion sur l'ensemble des div concernés et j'ai remplacé cela par un très classique div.Gestion. D'autre part, visiblement, le <label /> faisait plus que troubler IE, qui ne comprenait par conséquent pas bien ou ce dernier ce finissait. Le problème a été réglé en décompactant la balise.
author Franck Deroche <webmaster@defr.org>
date Mon, 31 Mar 2008 14:53:49 +0200
parents 629389204276
children
line wrap: on
line source
  var styleSwitch = {
	set:function(title) {
	  var i, a, main;
	  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("Style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if(a.getAttribute("title") == title) a.disabled = false;
		}
	  }
	  document._currentStyleSheet = title;
	},
	
	get:function() {
	  return document._currentStyleSheet;
	},
	
	getPref:function() {
	  var a = document.getElementsByTagName("link");
	  for(var i=0; a[i]; i++) {
		if(a[i].getAttribute("rel").indexOf("Style") != -1 && a[i].getAttribute("rel").indexOf("Alt") == -1 && a[i].getAttribute("title"))
			return a[i].getAttribute("title");
	  }
	  return null;
	},
	
	unload:function() {
	  var date = new Date();
	  date.setTime(date.getTime() + 365 * 24 * 3600 * 1000);
	  document.cookie="style=" + document._currentStyleSheet +";expires=" + date.toGMTString() + ";path=/";
	}
  }
  
  var arContent = new Array();
  var arTitle = new Array();
  
  window.onload = function() {
   var shownSection = 'About', i, x;
   x=document.getElementsByTagName('dt');
   for(i=0;i<x.length;i++) {
	if(x[i].parentNode.id == 'SideBar') {
		x[i].onclick=ToggleDisp;
		arTitle[arTitle.length] = x[i];
	}
   }
   x=document.getElementsByTagName('dd');
   for (i=0;i<x.length;i++) {
    if(x[i].parentNode.id == 'SideBar') {
	arContent[arContent.length] = x[i];
	if(arTitle[arContent.length - 1].id!=shownSection) {
		x[i].style.display='none';
	} else {
		arTitle[arContent.length - 1].className='Actif';
	}
    }
   }
   var ad = document.getElementById('Adresse');
   ad.onclick = ToggleLink;
   arContent[arContent.length] = document.getElementById("Link");
   arTitle[arTitle.length] = ad;
   
   styleSwitch.set(styleSwitch.getPref());
/*   var dS = document.styleSheets;
   if(dS && dS[dS.length - 1].title) {
	  for(var i =0; i < dS.length; i++)
		{
		if(dS[i].title=='Somatic') {
			if(dS[i].insertRule)
				dS[i].insertRule("@import url('/blog/Somatic_JS.css');", 0);
			else
				dS[i].addImport('Somatic_JS.css');
		}
		}
  }
  else if(dS && styleSwitch.get() == "Somatic") {
	dS[dS.length - 1].insertRule("@import url(/blog/Somatic_JS.css);", 0);
	//for(j in dS[0]) alert(j);
  }*/
 }

 window.onunload = function() {
	styleSwitch.unload();
	return true;
 }


  function ToggleDisp(e) {
   for(var i=0; i<arTitle.length; i++) arTitle[i].className='';
   var targetAc;
   if(!e) e=window.event;
   if(e.target) targetAc=e.target;
   else targetAc=e.srcElement;
   //Parait que la ligne suivante est utile pour Safari ^^;... Sauf qu'Opera retourne en plus le ns dans le nodeName...
   while(targetAc.nodeName.toLowerCase() != 'dt' && targetAc.nodeName.toLowerCase() != 'html:dt') targetAc=targetAc.parentNode;
   targetAc.className = 'Actif';
   var nextSib=targetAc.nextSibling;
   while(nextSib.nodeType!=1) {nextSib=nextSib.nextSibling;}
   if(styleSwitch.get() != "Somatic") {
	var nextSibDisp=(nextSib.style.display=='none') ? 'block' : 'none';
	nextSib.style.display=nextSibDisp;
   } else {
	for(i=0;i<arContent.length;i++) arContent[i].style.display = 'none';
	nextSib.style.display='block';
   }
  }
  
  function ToggleLink() {
   var obj=document.getElementById('Link');
   if(styleSwitch.get() == "Somatic") {
   	for(i=0; i<arTitle.length; i++) arTitle[i].className='';
	arTitle[arTitle.length - 1].className='Actif';
	for(i=0;i<arContent.length;i++) arContent[i].style.display='none';
	obj.style.display='block';
    } else {
	obj.style.display=(obj.style.display=='block') ? 'none' : 'block';
   }
  }
  
  function pop_config() {
   alert('Vouip, je sais, faut qu\'j\'remette ca, mais faut l\'updater d\'abord ^^;;');
  }