home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 2003 November / CD1_JOY_153.iso / demos / NHL2004Demo.exe / fe / nhl / js / ComboBox.js < prev    next >
Text File  |  2003-08-20  |  2KB  |  79 lines

  1. // Copyright (c) 2003 Electronic Arts Inc. All rights reserved.
  2. var oGameFace           = window.external.GameInterface;
  3. var oAudioInterface        = oGameFace.AudioInterface;
  4.  
  5. function ComboBox(id, x, y, width, height, dropHeight, divId, isUp)
  6. {
  7.     this.id            = id;
  8.     this.x            = x;
  9.     this.y            = y;
  10.     this.width        = width;
  11.     this.height        = height;
  12.     this.dropHeight    = dropHeight;
  13.  
  14.     this.isUp        = isUp;
  15.     this.write(divId);
  16. };
  17.  
  18. ComboBox.prototype.write = function (divId)
  19. {
  20.     var s = "";
  21.  
  22.     s += "<DIV id='' style='DISPLAY: inline; OVERFLOW: hidden; CURSOR: hand;' tabIndex='-1' noWrap>";
  23.     s += "<SPAN onmouseleave='" + this.id + " .OnMouseLeave()'>";
  24.     s += "<OBJECT ID='" + this.id + "' CLASSID='CLSID:A656E343-CDF7-4BB3-BE94-2FBB1D993BD0' style='position:absolute;width:" + this.width + "px;height:" + this.height + "px;top:" + this.x + "px;left:" + this.y + "px;'>";
  25.     s += "</OBJECT></SPAN></DIV>";
  26.  
  27.     s += "<SCRIPT LANGUAGE='javascript' FOR='" + this.id + "' EVENT='DropDown()'>";
  28.     s += "comboBoxOnDropDown('" + this.id + "', " + this.height + ", " + this.x + ", " + this.isUp + ")";
  29.     s += "</SCRIPT>";
  30.  
  31.     s += "<SCRIPT LANGUAGE='javascript' FOR='" + this.id + "' EVENT='PullUp()'>";
  32.     s += "comboBoxOnPullUp('" + this.id + "', " + this.height + ", " + this.x + ")";
  33.     s += "</SCRIPT>";
  34.  
  35.     var divComboBox = document.getElementById(divId);
  36.     divComboBox.innerHTML = s;
  37. };
  38.  
  39. ComboBox.prototype.addString = function (str)
  40. {
  41.     var drpObj = document.getElementById(this.id);
  42.     drpObj.AddString(str);
  43. };
  44.  
  45.  
  46. function comboBoxOnDropDown(id, height, x, isUp)
  47. {
  48.     oAudioInterface.PlaySFX(1095);
  49.     
  50.     var drpObj = document.getElementById(id);
  51.  
  52.     if (drpObj.Lists < 6)
  53.     {
  54.         drpObj.style.height = height*(drpObj.Lists+1);
  55.     }
  56.     else
  57.     {
  58.         drpObj.style.height = height*(7);
  59.     }
  60.  
  61.     var nHeight = parseInt(drpObj.style.height);
  62.  
  63.     if (isUp)
  64.     {
  65.         drpObj.style.top = x + height - nHeight;
  66.         drpObj.SetListUp(1);
  67.     }
  68.  
  69.     drpObj.style.zIndex = 100;
  70. }
  71.  
  72. function comboBoxOnPullUp(id, height, x)
  73. {    
  74.     var drpObj = document.getElementById(id);
  75.     drpObj.style.height=height;
  76.     drpObj.style.pixelTop = x;
  77.     drpObj.style.zIndex=0;
  78. }
  79.