[ Index ]
 

Code source de Seagull 0.6.1

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

title

Body

[fermer]

/js/ -> TreeMenu.js (source)

   1  // +-----------------------------------------------------------------------+
   2  // | Copyright (c) 2002-2003, Richard Heyes, Harald Radi                        |
   3  // | All rights reserved.                                                  |
   4  // |                                                                       |
   5  // | Redistribution and use in source and binary forms, with or without    |
   6  // | modification, are permitted provided that the following conditions    |
   7  // | are met:                                                              |
   8  // |                                                                       |
   9  // | o Redistributions of source code must retain the above copyright      |
  10  // |   notice, this list of conditions and the following disclaimer.       |
  11  // | o Redistributions in binary form must reproduce the above copyright   |
  12  // |   notice, this list of conditions and the following disclaimer in the |
  13  // |   documentation and/or other materials provided with the distribution.|
  14  // | o The names of the authors may not be used to endorse or promote      |
  15  // |   products derived from this software without specific prior written  |
  16  // |   permission.                                                         |
  17  // |                                                                       |
  18  // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |
  19  // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |
  20  // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
  21  // | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |
  22  // | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
  23  // | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |
  24  // | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
  25  // | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
  26  // | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |
  27  // | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
  28  // | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |
  29  // |                                                                       |
  30  // +-----------------------------------------------------------------------+
  31  // | Author: Richard Heyes <richard@phpguru.org>                           |
  32  // |         Harald Radi <harald.radi@nme.at>                              |
  33  // +-----------------------------------------------------------------------+
  34  //
  35  // $Id: TreeMenu.js,v 1.2 2005/05/09 23:33:40 demian Exp $
  36  
  37  
  38  /**
  39  * TreeMenu class
  40  */
  41      function TreeMenu(iconpath, myname, linkTarget, defaultClass, usePersistence, noTopLevelImages)
  42      {
  43          // Properties
  44          this.iconpath         = iconpath;
  45          this.myname           = myname;
  46          this.linkTarget       = linkTarget;
  47          this.defaultClass     = defaultClass;
  48          this.usePersistence   = usePersistence;
  49          this.noTopLevelImages = noTopLevelImages;
  50          this.n                = new Array();
  51      
  52          this.nodeRefs       = new Array();
  53          this.branches       = new Array();
  54          this.branchStatus   = new Array();
  55          this.layerRelations = new Array();
  56          this.childParents   = new Array();
  57          this.cookieStatuses = new Array();
  58  
  59          this.preloadImages();
  60      }
  61  
  62  /**
  63  * Adds a node to the tree
  64  */
  65      TreeMenu.prototype.addItem = function (newNode)
  66      {
  67          newIndex = this.n.length;
  68          this.n[newIndex] = newNode;
  69          
  70          return this.n[newIndex];
  71      }
  72  
  73  /**
  74  * Preload images hack for Mozilla
  75  */
  76      TreeMenu.prototype.preloadImages = function ()
  77      {
  78          var plustop    = new Image; plustop.src    = this.iconpath + '/plustop.gif';
  79          var plusbottom = new Image; plusbottom.src = this.iconpath + '/plusbottom.gif';
  80          var plus       = new Image; plus.src       = this.iconpath + '/plus.gif';
  81      
  82          var minustop    = new Image; minustop.src    = this.iconpath + '/minustop.gif';
  83          var minusbottom = new Image; minusbottom.src = this.iconpath + '/minusbottom.gif';
  84          var minus       = new Image; minus.src       = this.iconpath + '/minus.gif';
  85      
  86          var branchtop    = new Image; branchtop.src    = this.iconpath + '/branchtop.gif';
  87          var branchbottom = new Image; branchbottom.src = this.iconpath + '/branchbottom.gif';
  88          var branch       = new Image; branch.src       = this.iconpath + '/branch.gif';
  89      
  90          var linebottom = new Image; linebottom.src = this.iconpath + '/linebottom.gif';
  91          var line       = new Image; line.src       = this.iconpath + '/line.gif';
  92      }
  93  
  94  /**
  95  * Main function that draws the menu and assigns it
  96  * to the layer (or document.write()s it)
  97  */
  98      TreeMenu.prototype.drawMenu = function ()// OPTIONAL ARGS: nodes = [], level = [], prepend = '', expanded = false, visbility = 'inline', parentLayerID = null
  99      {
 100          /**
 101          * Necessary variables
 102          */
 103          var output        = '';
 104          var modifier      = '';
 105          var layerID       = '';
 106          var parentLayerID = '';
 107      
 108          /**
 109          * Parse any optional arguments
 110          */
 111          var nodes         = arguments[0] ? arguments[0] : this.n
 112          var level         = arguments[1] ? arguments[1] : [];
 113          var prepend       = arguments[2] ? arguments[2] : '';
 114          var expanded      = arguments[3] ? arguments[3] : false;
 115          var visibility    = arguments[4] ? arguments[4] : 'inline';
 116          var parentLayerID = arguments[5] ? arguments[5] : null;
 117      
 118          var currentlevel  = level.length;
 119      
 120          for (var i=0; i<nodes.length; i++) {
 121          
 122              level[currentlevel] = i+1;
 123              layerID = this.myname + '_' + 'node_' + this.implode('_', level);
 124      
 125              /**
 126              * Store this object in the nodeRefs array
 127              */
 128              this.nodeRefs[layerID] = nodes[i];
 129  
 130              /**
 131              * Store the child/parent relationship
 132              */
 133              this.childParents[layerID] = parentLayerID;
 134      
 135              /**
 136              * Gif modifier
 137              */
 138              if (i == 0 && parentLayerID == null) {
 139                  modifier = nodes.length > 1 ? "top" : 'single';
 140              } else if (i == (nodes.length-1)) {
 141                  modifier = "bottom";
 142              } else {
 143                  modifier = "";
 144              }
 145      
 146              /**
 147              * Single root branch is always expanded
 148              */
 149              if (!this.doesMenu() || (parentLayerID == null && (nodes.length == 1 || this.noTopLevelImages))) {
 150                  expanded = true;
 151      
 152              } else if (nodes[i].expanded) {
 153                  expanded = true;
 154      
 155              } else {
 156                  expanded = false;
 157              }
 158      
 159              /**
 160              * Make sure visibility is correct based on parent status
 161              */
 162              visibility =  this.checkParentVisibility(layerID) ? visibility : 'none';
 163      
 164              /**
 165              * Setup branch status and build an indexed array
 166              * of branch layer ids
 167              */
 168              if (nodes[i].n.length > 0) {
 169                  this.branchStatus[layerID] = expanded;
 170                  this.branches[this.branches.length] = layerID;
 171              }
 172      
 173              /**
 174              * Setup toggle relationship
 175              */
 176              if (!this.layerRelations[parentLayerID]) {
 177                  this.layerRelations[parentLayerID] = new Array();
 178              }
 179              this.layerRelations[parentLayerID][this.layerRelations[parentLayerID].length] = layerID;
 180      
 181              /**
 182              * Branch images
 183              */
 184              var gifname = nodes[i].n.length && this.doesMenu() && nodes[i].isDynamic ? (expanded ? 'minus' : 'plus') : 'branch';
 185              var iconimg = nodes[i].icon ? this.stringFormat('<img src="{0}/{1}" width="20" height="20" align="top" id="icon_{2}">', this.iconpath, nodes[i].icon, layerID) : '';
 186              
 187              /**
 188              * Add event handlers
 189              */
 190              var eventHandlers = "";
 191              for (j in nodes[i].events) {
 192                  eventHandlers += this.stringFormat('{0}="{1}" ', j, nodes[i].events[j]);
 193              }
 194  
 195              /**
 196              * Build the html to write to the document
 197              * IMPORTANT:
 198              * document.write()ing the string: '<div style="display:...' will screw up nn4.x
 199              */
 200              var layerTag  = this.doesMenu() ? this.stringFormat('<div id="{0}" style="display: {1}" class="{2}">', layerID, visibility, (nodes[i].cssClass ? nodes[i].cssClass : this.defaultClass)) : this.stringFormat('<div class="{0}">', nodes[i].cssClass ? nodes[i].cssClass : this.defaultClass);
 201              var onMDown   = this.doesMenu() && nodes[i].n.length  && nodes[i].isDynamic ? this.stringFormat('onmousedown="{0}.toggleBranch(\'{1}\', true)" style="cursor: pointer; cursor: hand"', this.myname, layerID) : '';
 202              var imgTag    = this.stringFormat('<img src="{0}/{1}{2}.gif" width="20" height="20" align="top" border="0" name="img_{3}" {4}>', this.iconpath, gifname, modifier, layerID, onMDown);
 203              var linkTarget= nodes[i].linkTarget ? nodes[i].linkTarget : this.linkTarget;
 204              var linkStart = nodes[i].link ? this.stringFormat('<a href="{0}" target="{1}">', nodes[i].link, linkTarget) : '';
 205              var linkEnd   = nodes[i].link ? '</a>' : '';
 206  
 207              output = this.stringFormat('{0}<nobr>{1}{2}{3}{4}<span {5}>{6}</span>{7}</nobr><br></div>',
 208                                layerTag,
 209                                prepend,
 210                                parentLayerID == null && (nodes.length == 1 || this.noTopLevelImages) ? '' : imgTag,
 211                                iconimg,
 212                                linkStart,
 213                                eventHandlers,
 214                                nodes[i].title,
 215                                linkEnd);
 216      
 217              /**
 218              * Write out the HTML. Uses document.write for speed over layers and
 219              * innerHTML. This however means no dynamic adding/removing nodes on
 220              * the client side. This could be conditional I guess if dynamic
 221              * adding/removing is required.
 222              */
 223              document.write(output + "\r\n");
 224  
 225              /**
 226              * Traverse sub nodes ?
 227              */
 228              if (nodes[i].n.length) {
 229                  /**
 230                  * Determine what to prepend. If there is only one root
 231                  * node then the prepend to pass to children is nothing.
 232                  * Otherwise it depends on where we are in the tree.
 233                  */
 234                  if (parentLayerID == null && (nodes.length == 1 || this.noTopLevelImages)) {
 235                      var newPrepend = '';
 236      
 237                  } else if (i < (nodes.length - 1)) {
 238                      var newPrepend = prepend + this.stringFormat('<img src="{0}/line.gif" width="20" height="20" align="top">', this.iconpath);
 239      
 240                  } else {
 241                      var newPrepend = prepend + this.stringFormat('<img src="{0}/linebottom.gif" width="20" height="20" align="top">', this.iconpath);
 242                  }
 243      
 244                  this.drawMenu(nodes[i].n,
 245                                level,
 246                                newPrepend,
 247                                nodes[i].expanded,
 248                                expanded ? 'inline' : 'none',
 249                                layerID);
 250              }
 251          }
 252      }
 253  
 254  /**
 255  * Toggles a branches visible status. Called from resetBranches()
 256  * and also when a +/- graphic is clicked.
 257  */
 258      TreeMenu.prototype.toggleBranch = function (layerID, updateStatus) // OPTIONAL ARGS: fireEvents = true
 259      {
 260          var currentDisplay = this.getLayer(layerID).style.display;
 261          var newDisplay     = (this.branchStatus[layerID] && currentDisplay == 'inline') ? 'none' : 'inline';
 262          var fireEvents     = arguments[2] != null ? arguments[2] : true;
 263      
 264          for (var i=0; i<this.layerRelations[layerID].length; i++) {
 265      
 266              if (this.branchStatus[this.layerRelations[layerID][i]]) {
 267                  this.toggleBranch(this.layerRelations[layerID][i], false);
 268              }
 269      
 270              this.getLayer(this.layerRelations[layerID][i]).style.display = newDisplay;
 271          }
 272      
 273          if (updateStatus) {
 274              this.branchStatus[layerID] = !this.branchStatus[layerID];
 275      
 276              /**
 277              * Persistence
 278              */
 279              if (this.doesPersistence() && !arguments[2] && this.usePersistence) {
 280                  this.setExpandedStatusForCookie(layerID, this.branchStatus[layerID]);
 281              }
 282  
 283              /**
 284              * Fire custom events
 285              */
 286              if (fireEvents) {
 287                  nodeObject = this.nodeRefs[layerID];
 288      
 289                  if (nodeObject.ontoggle != null) {
 290                      eval(nodeObject.ontoggle);
 291                  }
 292                  
 293                  if (newDisplay == 'none' && nodeObject.oncollapse != null) {
 294                      eval(nodeObject.oncollapse);
 295                  } else if (newDisplay == 'inline' && nodeObject.onexpand != null){
 296                      eval(nodeObject.onexpand);
 297                  }
 298              }
 299  
 300              // Swap image
 301              this.swapImage(layerID);
 302          }
 303  
 304          // Swap icon
 305          this.swapIcon(layerID);
 306      }
 307  
 308  /**
 309  * Swaps the plus/minus branch images
 310  */
 311      TreeMenu.prototype.swapImage = function (layerID)
 312      {
 313          var imgSrc = document.images['img_' + layerID].src;
 314      
 315          var re = /^(.*)(plus|minus)(bottom|top|single)?.gif$/
 316          if (matches = imgSrc.match(re)) {
 317      
 318              document.images['img_' + layerID].src = this.stringFormat('{0}{1}{2}{3}',
 319                                                              matches[1],
 320                                                              matches[2] == 'plus' ? 'minus' : 'plus',
 321                                                              matches[3] ? matches[3] : '',
 322                                                              '.gif');
 323          }
 324      }
 325  
 326  /**
 327  * Swaps the icon for the expanded icon if one
 328  * has been supplied.
 329  */
 330      TreeMenu.prototype.swapIcon = function (layerID)
 331      {
 332          if (document.images['icon_' + layerID]) {
 333              var imgSrc = document.images['icon_' + layerID].src;
 334      
 335              if (this.nodeRefs[layerID].icon && this.nodeRefs[layerID].expandedIcon) {
 336                  //alert(imgSrc.indexOf(this.nodeRefs[layerID].expandedIcon));
 337                  var newSrc = (imgSrc.indexOf(this.nodeRefs[layerID].expandedIcon) == -1 ? this.nodeRefs[layerID].expandedIcon : this.nodeRefs[layerID].icon);
 338      
 339                  document.images['icon_' + layerID].src = this.iconpath + '/' + newSrc;
 340              }
 341          }
 342      }
 343  
 344  /**
 345  * Can the browser handle the dynamic menu?
 346  */
 347      TreeMenu.prototype.doesMenu = function ()
 348      {
 349          return (is_ie4up || is_nav6up || is_gecko || is_opera7);
 350      }
 351  
 352  /**
 353  * Can the browser handle save the branch status
 354  */
 355      TreeMenu.prototype.doesPersistence = function ()
 356      {
 357          return (is_ie4up || is_gecko || is_nav6up || is_opera7);
 358      }
 359  
 360  /**
 361  * Returns the appropriate layer accessor
 362  */
 363      TreeMenu.prototype.getLayer = function (layerID)
 364      {
 365          if (is_ie4) {
 366              return document.all(layerID);
 367      
 368          } else if (document.getElementById(layerID)) {
 369              return document.getElementById(layerID);
 370      
 371          } else if (document.all(layerID)) {
 372              return document.all(layerID);
 373          }
 374      }
 375  
 376  /**
 377  * Save the status of the layer
 378  */
 379      TreeMenu.prototype.setExpandedStatusForCookie = function (layerID, expanded)
 380      {
 381          this.cookieStatuses[layerID] = expanded;
 382          this.saveCookie();
 383      }
 384  
 385  /**
 386  * Load the status of the layer
 387  */
 388      TreeMenu.prototype.getExpandedStatusFromCookie = function (layerID)
 389      {
 390          if (this.cookieStatuses[layerID]) {
 391              return this.cookieStatuses[layerID];
 392          }
 393  
 394          return false;
 395      }
 396  
 397  /**
 398  * Saves the cookie that holds which branches are expanded.
 399  * Only saves the details of the branches which are expanded.
 400  */
 401      TreeMenu.prototype.saveCookie = function ()
 402      {
 403          var cookieString = new Array();
 404  
 405          for (var i in this.cookieStatuses) {
 406              if (this.cookieStatuses[i] == true) {
 407                  cookieString[cookieString.length] = i;
 408              }
 409          }
 410          
 411          document.cookie = 'TreeMenuBranchStatus=' + cookieString.join(':') + '; path=/';
 412      }
 413  
 414  /**
 415  * Reads cookie parses it for status info and
 416  * stores that info in the class member.
 417  */
 418      TreeMenu.prototype.loadCookie = function ()
 419      {
 420          var cookie = document.cookie.split('; ');
 421  
 422          for (var i=0; i < cookie.length; i++) {
 423              var crumb = cookie[i].split('=');
 424              if ('TreeMenuBranchStatus' == crumb[0] && crumb[1]) {
 425                  var expandedBranches = crumb[1].split(':');
 426                  for (var j=0; j<expandedBranches.length; j++) {
 427                      this.cookieStatuses[expandedBranches[j]] = true;
 428                  }
 429              }
 430          }
 431      }
 432  
 433  /**
 434  * Reset branch status
 435  */
 436      TreeMenu.prototype.resetBranches = function ()
 437      {
 438          if (!this.doesPersistence()) {
 439              return false;
 440          }
 441  
 442          this.loadCookie();
 443  
 444          for (var i=0; i<this.branches.length; i++) {
 445              var status = this.getExpandedStatusFromCookie(this.branches[i]);
 446              // Only update if it's supposed to be expanded and it's not already
 447              if (status == true && this.branchStatus[this.branches[i]] != true) {
 448                  if (this.checkParentVisibility(this.branches[i])) {
 449                      this.toggleBranch(this.branches[i], true, false);
 450                  } else {
 451                      this.branchStatus[this.branches[i]] = true;
 452                      this.swapImage(this.branches[i]);
 453                  }
 454              }
 455          }
 456      }
 457  
 458  /**
 459  * Checks whether a branch should be open
 460  * or not based on its parents' status
 461  */
 462      TreeMenu.prototype.checkParentVisibility = function (layerID)
 463      {
 464          if (this.in_array(this.childParents[layerID], this.branches)
 465              && this.branchStatus[this.childParents[layerID]]
 466              && this.checkParentVisibility(this.childParents[layerID]) ) {
 467              
 468              return true;
 469      
 470          } else if (this.childParents[layerID] == null) {
 471              return true;
 472          }
 473          
 474          return false;
 475      }
 476  
 477  /**
 478  * New C# style string formatter
 479  */
 480      TreeMenu.prototype.stringFormat = function (strInput)
 481      {
 482          var idx = 0;
 483      
 484          for (var i=1; i<arguments.length; i++) {
 485              while ((idx = strInput.indexOf('{' + (i - 1) + '}', idx)) != -1) {
 486                  strInput = strInput.substring(0, idx) + arguments[i] + strInput.substr(idx + 3);
 487              }
 488          }
 489          
 490          return strInput;
 491      }
 492  
 493  /**
 494  * Also much adored, the PHP implode() function
 495  */
 496      TreeMenu.prototype.implode = function (seperator, input)
 497      {
 498          var output = '';
 499      
 500          for (var i=0; i<input.length; i++) {
 501              if (i == 0) {
 502                  output += input[i];
 503              } else {
 504                  output += seperator + input[i];
 505              }
 506          }
 507          
 508          return output;
 509      }
 510  
 511  /**
 512  * Aah, all the old favourites are coming out...
 513  */
 514      TreeMenu.prototype.in_array = function (item, arr)
 515      {
 516          for (var i=0; i<arr.length; i++) {
 517              if (arr[i] == item) {
 518                  return true;
 519              }
 520          }
 521      
 522          return false;
 523      }
 524  
 525  /**
 526  * TreeNode Class
 527  */
 528      function TreeNode(title, icon, link, expanded, isDynamic, cssClass, linkTarget, expandedIcon)
 529      {
 530          this.title        = title;
 531          this.icon         = icon;
 532          this.expandedIcon = expandedIcon;
 533          this.link         = link;
 534          this.expanded     = expanded;
 535          this.isDynamic    = isDynamic;
 536          this.cssClass     = cssClass;
 537          this.linkTarget   = linkTarget;
 538          this.n            = new Array();
 539          this.events       = new Array();
 540          this.handlers     = null;
 541          this.oncollapse   = null;
 542          this.onexpand     = null;
 543          this.ontoggle     = null;
 544      }
 545  
 546  /**
 547  * Adds a node to an already existing node
 548  */
 549      TreeNode.prototype.addItem = function (newNode)
 550      {
 551          newIndex = this.n.length;
 552          this.n[newIndex] = newNode;
 553          
 554          return this.n[newIndex];
 555      }
 556  
 557  /**
 558  * Sets an event for this particular node
 559  */
 560      TreeNode.prototype.setEvent = function (eventName, eventHandler)
 561      {
 562          switch (eventName.toLowerCase()) {
 563              case 'onexpand':
 564                  this.onexpand = eventHandler;
 565                  break;
 566  
 567              case 'oncollapse':
 568                  this.oncollapse = eventHandler;
 569                  break;
 570  
 571              case 'ontoggle':
 572                  this.ontoggle = eventHandler;
 573                  break;
 574  
 575              default:
 576                  this.events[eventName] = eventHandler;
 577          }
 578      }
 579  
 580  /**
 581  * That's the end of the tree classes. What follows is
 582  * the browser detection code.
 583  */
 584      
 585  
 586  //<!--
 587  // Ultimate client-side JavaScript client sniff. Version 3.03
 588  // (C) Netscape Communications 1999-2001.  Permission granted to reuse and distribute.
 589  // Revised 17 May 99 to add is_nav5up and is_ie5up (see below).
 590  // Revised 20 Dec 00 to add is_gecko and change is_nav5up to is_nav6up
 591  //                      also added support for IE5.5 Opera4&5 HotJava3 AOLTV
 592  // Revised 22 Feb 01 to correct Javascript Detection for IE 5.x, Opera 4,
 593  //                      correct Opera 5 detection
 594  //                      add support for winME and win2k
 595  //                      synch with browser-type-oo.js
 596  // Revised 26 Mar 01 to correct Opera detection
 597  // Revised 02 Oct 01 to add IE6 detection
 598  
 599  // Everything you always wanted to know about your JavaScript client
 600  // but were afraid to ask. Creates "is_" variables indicating:
 601  // (1) browser vendor:
 602  //     is_nav, is_ie, is_opera, is_hotjava, is_webtv, is_TVNavigator, is_AOLTV
 603  // (2) browser version number:
 604  //     is_major (integer indicating major version number: 2, 3, 4 ...)
 605  //     is_minor (float   indicating full  version number: 2.02, 3.01, 4.04 ...)
 606  // (3) browser vendor AND major version number
 607  //     is_nav2, is_nav3, is_nav4, is_nav4up, is_nav6, is_nav6up, is_gecko, is_ie3,
 608  //     is_ie4, is_ie4up, is_ie5, is_ie5up, is_ie5_5, is_ie5_5up, is_ie6, is_ie6up, is_hotjava3, is_hotjava3up,
 609  //     is_opera2, is_opera3, is_opera4, is_opera5, is_opera5up
 610  // (4) JavaScript version number:
 611  //     is_js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...)
 612  // (5) OS platform and version:
 613  //     is_win, is_win16, is_win32, is_win31, is_win95, is_winnt, is_win98, is_winme, is_win2k
 614  //     is_os2
 615  //     is_mac, is_mac68k, is_macppc
 616  //     is_unix
 617  //     is_sun, is_sun4, is_sun5, is_suni86
 618  //     is_irix, is_irix5, is_irix6
 619  //     is_hpux, is_hpux9, is_hpux10
 620  //     is_aix, is_aix1, is_aix2, is_aix3, is_aix4
 621  //     is_linux, is_sco, is_unixware, is_mpras, is_reliant
 622  //     is_dec, is_sinix, is_freebsd, is_bsd
 623  //     is_vms
 624  //
 625  // See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and
 626  // http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html
 627  // for detailed lists of userAgent strings.
 628  //
 629  // Note: you don't want your Nav4 or IE4 code to "turn off" or
 630  // stop working when new versions of browsers are released, so
 631  // in conditional code forks, use is_ie5up ("IE 5.0 or greater")
 632  // is_opera5up ("Opera 5.0 or greater") instead of is_ie5 or is_opera5
 633  // to check version in code which you want to work on future
 634  // versions.
 635  
 636  /**
 637  * Severly curtailed all this as only certain elements
 638  * are required by TreeMenu, specifically:
 639  *  o is_ie4up
 640  *  o is_nav6up
 641  *  o is_gecko
 642  */
 643  
 644      // convert all characters to lowercase to simplify testing
 645      var agt=navigator.userAgent.toLowerCase();
 646  
 647      // *** BROWSER VERSION ***
 648      // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
 649      var is_major = parseInt(navigator.appVersion);
 650      var is_minor = parseFloat(navigator.appVersion);
 651  
 652      // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
 653      // If you want to allow spoofing, take out the tests for opera and webtv.
 654      var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
 655                  && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
 656                  && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
 657      var is_nav6up = (is_nav && (is_major >= 5));
 658      var is_gecko = (agt.indexOf('gecko') != -1);
 659  
 660  
 661      var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
 662      var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
 663      var is_ie4up  = (is_ie && (is_major >= 4));
 664      
 665      var is_opera  = (agt.indexOf("opera") != -1);
 666      var is_opera7 = is_opera && (agt.indexOf("opera 7") != -1);
 667  //--> end hide JavaScript


Généré le : Fri Mar 30 01:27:52 2007 par Balluche grâce à PHPXref 0.7