عزيزة فريق العمـــــل *****
التوقيع :
عدد الرسائل : 1394
تاريخ التسجيل : 13/09/2010 وســــــــــام النشــــــــــــــاط : 4
| | بــــــــــــــحـــــــــــــر | |
addEvent(window, "load", initialiserBulles); var lesBalises = new Array; lesBalises[0] = "img"; var XHTMLNS = "http://www.w3.org/1999/xhtml"; var CURRENT_NICE_TITLE; function initialiserBulles() { if (!document.createElement || !document.getElementsByTagName) return; // add namespace methods to HTML DOM; this makes the script work in both // HTML and XML contexts. if(!document.createElementNS){ document.createElementNS = function(ns,elt) { return document.createElement(elt); } } for(var i = 0; i < lesBalises.length; i++){ var balises = document.getElementsByTagName(lesBalises[i]); for (var ti = 0; ti < balises.length ; ti++) { var balise = balises[ti]; if (balise.title) { ajouterBulle(balise); } }}} function ajouterBulle(elem){ elem.setAttribute("bulle",elem.title); elem.removeAttribute("title"); // on ajoute des evenements sur le lien addEvent(elem,"mouseover",montrerBulle); addEvent(elem,"mouseout",cacherBulle); addEvent(elem,"focus",montrerBulle); addEvent(elem,"blur",cacherBulle); } function donnePosition(oLink) { if( oLink.offsetParent ) { for( var posX = 0, posY = 0; oLink.offsetParent; oLink = oLink.offsetParent ) { posX += oLink.offsetLeft; posY += oLink.offsetTop; } return [ posX, posY ]; } else { return [ oLink.x, oLink.y ]; } } function montrerBulle(e) { // si c'est le titre est déjà rempli on le cache if (CURRENT_NICE_TITLE) cacherBulle(CURRENT_NICE_TITLE); var elem; if (window.event && window.event.srcElement) { elem = window.event.srcElement } else if (e && e.target) { elem = e.target } var _textBulle = elem.getAttribute("bulle"); if(_textBulle.charAt(0) == '$'){ _textBulle = eval(_textBulle.substring(1)); } else { _textBulle = "" + _textBulle + ""; } // on ajoute à une div un noeud de texte contenant ce qu'il faut var d = document.createElementNS(XHTMLNS,"div"); d.className = "bulle"; d.innerHTML = _textBulle; d.style.position = 'absolute'; mpos = donnePosition(elem); mx = mpos[0]; my = mpos[1]; d.style.left = (mx - 0) + 'px'; d.style.top = (my + 375) + 'px'; var largeurDiv = d.width; if (window.innerWidth && ((mx+largeurDiv) > window. innerWidth)) { d.style.left = (window.innerWidth - largeurDiv - 25) + "px"; } if (document.body.scrollWidth && ((mx + largeurDiv) > document.body.scrollWidth)) { d.style.left = (document.body.scrollWidth - largeurDiv - 25) + "px"; } document.getElementsByTagName("body")[0].appendChild(d); CURRENT_NICE_TITLE = d; } function cacherBulle(e) { if (!document.getElementsByTagName) return; if (CURRENT_NICE_TITLE) { document.getElementsByTagName("body")[0].removeChild(CURRENT_NICE_TITLE); CURRENT_NICE_TITLE = null; }} // Add an eventListener to navigateurs that can do it somehow. // Originally by the amazing Scott Andrew. function addEvent(obj, evType, fn){ if (obj.addEventListener){ obj.addEventListener(evType, fn, true); return true; } else if (obj.attachEvent){ var r = obj.attachEvent("on"+evType, fn); return r; } else { return false; } } | |
|