[ Index ]
 

Code source de e107 0.7.8

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/e107_themes/kubrick/ -> theme.js (source)

   1  // from http://www.kryogenix.org
   2  // by Scott Andrew - http://scottandrew.com
   3  // add an eventlistener to browsers that can do it somehow.
   4  function addEvent(obj, evType, fn)
   5      {
   6      if (obj.addEventListener)
   7          {
   8          obj.addEventListener(evType, fn, false);
   9          return true;
  10          }
  11      else if (obj.attachEvent)
  12          {
  13          var r = obj.attachEvent('on'+evType, fn);
  14          return r;
  15          }
  16      else
  17          {
  18          return false;
  19          }
  20      }
  21  
  22  
  23  // Force IE not to show alternate text as tooltip
  24  function noAltTooltip()
  25      {
  26      images = document.getElementsByTagName('img');
  27      for (var i = 0; i < images.length; i++)
  28          {
  29          var title = images[i].getAttribute('title');
  30          var alt = images[i].getAttribute('alt');
  31          if ((document.all) && (alt) && (!title))
  32              {
  33              images[i].setAttribute('title', '');
  34              }
  35          }
  36      }
  37  
  38  // Nice Titles
  39  
  40  // original code by Stuart Langridge 2003-11
  41  // with additions to the code by other good people
  42  // http://www.kryogenix.org/code/browser/nicetitle/
  43  // thank you, sir
  44  
  45  // modified by Peter Janes 2003-03-25
  46  // http://peterjanes.ca/blog/archives/2003/03/25/nicetitles-for-ins-and-del
  47  // added in ins and del tags
  48  
  49  // modified by Dunstan Orchard 2003-11-18
  50  // http://1976design.com/blog/
  51  // added in accesskey information
  52  // tried ever-so-hard, but couldn't work out how to do what Ethan did
  53  
  54  // final genius touch by by Ethan Marcotte 2003-11-18
  55  // http://www.sidesh0w.com/
  56  // worked out how to delay showing the popups to make them more like the browser's own
  57  
  58  // set the namespace
  59  var XHTMLNS = 'http://www.w3.org/1999/xhtml';
  60  var CURRENT_NICE_TITLE;
  61  
  62  // browser sniff
  63  var browser = new Browser();
  64  
  65  // determine browser and version.
  66  function Browser()
  67      {
  68      var ua, s, i;
  69  
  70      this.isIE = false;
  71      this.isNS = false;
  72      this.version = null;
  73  
  74      ua = navigator.userAgent;
  75  
  76      s = 'MSIE';
  77      if ((i = ua.indexOf(s)) >= 0)
  78          {
  79          this.isIE = true;
  80          this.version = parseFloat(ua.substr(i + s.length));
  81          return;
  82          }
  83  
  84      s = 'Netscape6/';
  85      if ((i = ua.indexOf(s)) >= 0)
  86          {
  87          this.isNS = true;
  88          this.version = parseFloat(ua.substr(i + s.length));
  89          return;
  90          }
  91  
  92      // treat any other 'Gecko' browser as NS 6.1.
  93      s = 'Gecko';
  94      if ((i = ua.indexOf(s)) >= 0)
  95          {
  96          this.isNS = true;
  97          this.version = 6.1;
  98          return;
  99          }
 100      }
 101  
 102  // 2003-11-19 sidesh0w
 103  // set delay vars to emulate normal hover delay
 104  var delay;
 105  var interval = 0.60;
 106  
 107  // this function runs on window load
 108  // it runs through all the links on the page as starts listening for actions
 109  function makeNiceTitles()
 110      {
 111      if (!document.createElement || !document.getElementsByTagName) return;
 112      if (!document.createElementNS)
 113          {
 114          document.createElementNS = function(ns, elt)
 115              {
 116              return document.createElement(elt);
 117              }
 118          }
 119  
 120      // do regular links
 121      if (!document.links)
 122          {
 123          document.links = document.getElementsByTagName('a');
 124          }
 125      for (var ti=0; ti<document.links.length; ti++)
 126          {
 127          var lnk = document.links[ti];
 128          // * I added specific class names here..
 129          if (lnk.title)
 130              {
 131              lnk.setAttribute('nicetitle', lnk.title);
 132              lnk.removeAttribute('title');
 133              addEvent(lnk, 'mouseover', showDelay);
 134              addEvent(lnk, 'mouseout', hideNiceTitle);
 135              addEvent(lnk, 'focus', showDelay);
 136              addEvent(lnk, 'blur', hideNiceTitle);
 137              }
 138          }
 139  
 140      // 2003-03-25 Peter Janes
 141      // do ins and del tags
 142      var tags = new Array(2);
 143      tags[0] = document.getElementsByTagName('ins');
 144      tags[1] = document.getElementsByTagName('del');
 145      for (var tt=0; tt<tags.length; tt++)
 146          {
 147          if (tags[tt])
 148              {
 149              for (var ti=0; ti<tags[tt].length; ti++)
 150                  {
 151                  var tag = tags[tt][ti];
 152                  if (tag.dateTime)
 153                      {
 154                      var strDate = tag.dateTime;
 155                      // HTML/ISO8601 date: yyyy-mm-ddThh:mm:ssTZD (Z, -hh:mm, +hh:mm)
 156                      var month = strDate.substring(5,7);
 157                      var day = strDate.substring(8,10);
 158                      if (month[0] == '0')
 159                          {
 160                          month = month[1];
 161                          }
 162                      if (day[0] == '0')
 163                          {
 164                          day = day[1];
 165                          }
 166                      var dtIns = new Date(strDate.substring(0,4), month-1, day, strDate.substring(11,13), strDate.substring(14,16), strDate.substring(17,19));
 167                      tag.setAttribute('nicetitle', (tt == 0 ? 'Added' : 'Deleted') + ' on ' + dtIns.toString());
 168                      addEvent(tag, 'mouseover', showDelay);
 169                      addEvent(tag, 'mouseout', hideNiceTitle);
 170                      addEvent(tag, 'focus', showDelay);
 171                      addEvent(tag, 'blur', hideNiceTitle);
 172                      }
 173                  }
 174              }
 175          }
 176      }
 177  
 178  function findPosition(oLink)
 179      {
 180      if (oLink.offsetParent)
 181          {
 182          for (var posX = 0, posY = 0; oLink.offsetParent; oLink = oLink.offsetParent)
 183              {
 184              posX += oLink.offsetLeft;
 185              posY += oLink.offsetTop;
 186              }
 187          return [posX, posY];
 188          }
 189      else
 190          {
 191          return [oLink.x, oLink.y];
 192          }
 193      }
 194  
 195  function getParent(el, pTagName)
 196      {
 197      if (el == null)
 198          {
 199          return null;
 200          }
 201      // gecko bug, supposed to be uppercase
 202      else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())
 203          {
 204          return el;
 205          }
 206      else
 207          {
 208          return getParent(el.parentNode, pTagName);
 209          }
 210      }
 211  
 212  // 2003-11-19 sidesh0w
 213  // trailerpark wrapper function
 214  function showDelay(e)
 215      {
 216      if (window.event && window.event.srcElement)
 217          {
 218          lnk = window.event.srcElement
 219          }
 220      else if (e && e.target)
 221          {
 222          lnk = e.target
 223          }
 224      if (!lnk) return;
 225  
 226      // lnk is a textnode or an elementnode that's not ins/del
 227      if (lnk.nodeType == 3 || (lnk.nodeType == 1 && lnk.tagName.toLowerCase() != 'ins' && lnk.tagName.toLowerCase() != 'del'))
 228          {
 229          // ascend parents until we hit a link
 230          lnk = getParent(lnk, 'a');
 231          }
 232  
 233      delay = setTimeout("showNiceTitle(lnk)", interval * 1000);
 234      }
 235  
 236  // build and show the nice titles
 237  function showNiceTitle(link)
 238      {
 239      if (CURRENT_NICE_TITLE) hideNiceTitle(CURRENT_NICE_TITLE);
 240      if (!document.getElementsByTagName) return;
 241  
 242      nicetitle = lnk.getAttribute('nicetitle');
 243  
 244      var d = document.createElementNS(XHTMLNS, 'div');
 245      d.className = 'nicetitle';
 246      var dc = document.createElementNS(XHTMLNS, 'div');
 247      dc.className = 'nicetitle-content';
 248      d.appendChild(dc);
 249      tnt = document.createTextNode(nicetitle);
 250      pat = document.createElementNS(XHTMLNS, 'p');
 251      pat.className = 'titletext';
 252      pat.appendChild(tnt);
 253  
 254      // 2003-11-18 Dunstan Orchard
 255      // added in accesskey info
 256      if (lnk.accessKey)
 257          {
 258          axs = document.createTextNode(' [' + lnk.accessKey + ']');
 259          axsk = document.createElementNS(XHTMLNS, 'span');
 260          axsk.className = 'accesskey';
 261          axsk.appendChild(axs);
 262          pat.appendChild(axsk);
 263          }
 264      dc.appendChild(pat);
 265  
 266      if (lnk.href)
 267          {
 268          tnd = document.createTextNode(lnk.href);
 269          pad = document.createElementNS(XHTMLNS, 'p');
 270          pad.className = 'destination';
 271          pad.appendChild(tnd);
 272          dc.appendChild(pad);
 273          }
 274  
 275      STD_WIDTH = 300;
 276  
 277      if (lnk.href)
 278          {
 279          h = lnk.href.length;
 280          }
 281      else
 282          {
 283          h = nicetitle.length;
 284          }
 285  
 286      if (nicetitle.length)
 287          {
 288          t = nicetitle.length;
 289          }
 290  
 291      h_pixels = h*6;
 292      t_pixels = t*10;
 293  
 294      if (h_pixels > STD_WIDTH)
 295          {
 296          w = h_pixels;
 297          }
 298      else if ((STD_WIDTH>t_pixels) && (t_pixels>h_pixels))
 299          {
 300          w = t_pixels;
 301          }
 302      else if ((STD_WIDTH>t_pixels) && (h_pixels>t_pixels))
 303          {
 304          w = h_pixels;
 305          }
 306      else
 307          {
 308          w = STD_WIDTH;
 309          }
 310  
 311      d.style.width = w + 'px';
 312  
 313      mpos = findPosition(lnk);
 314      mx = mpos[0];
 315      my = mpos[1];
 316  
 317      d.style.left = (mx+15) + 'px';
 318      d.style.top = (my+35) + 'px';
 319  
 320      if (window.innerWidth && ((mx+w) > window.innerWidth))
 321          {
 322          d.style.left = (window.innerWidth - w - 25) + 'px';
 323          }
 324      if (document.body.scrollWidth && ((mx+w) > document.body.scrollWidth))
 325          {
 326          d.style.left = (document.body.scrollWidth - w - 25) + 'px';
 327          }
 328  
 329      document.getElementsByTagName('body')[0].appendChild(d);
 330  
 331      CURRENT_NICE_TITLE = d;
 332      }
 333  
 334  function hideNiceTitle(e)
 335      {
 336      // 2003-11-19 sidesh0w
 337      // clearTimeout
 338      if (delay) clearTimeout(delay);
 339      if (!document.getElementsByTagName) return;
 340      if (CURRENT_NICE_TITLE)
 341          {
 342          document.getElementsByTagName('body')[0].removeChild(CURRENT_NICE_TITLE);
 343          CURRENT_NICE_TITLE = null;
 344          }
 345      }
 346  addEvent(window, "load", noAltTooltip);
 347  addEvent(window, "load", makeNiceTitles);
 348  


Généré le : Sun Apr 1 01:23:32 2007 par Balluche grâce à PHPXref 0.7