home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 2003 November / CD1_JOY_153.iso / demos / NHL2004Demo.exe / fe / nhl / htc / tab / TeamOptionTab.htc < prev   
Text File  |  2003-08-20  |  5KB  |  150 lines

  1. <!-- Copyright (c) 2002 Electronic Arts Inc. All rights reserved. -->
  2.  
  3. <PUBLIC:COMPONENT tagName="Tab">
  4.     <PUBLIC:PROPERTY    NAME="imgSrc"               />
  5.     <PUBLIC:PROPERTY    NAME="caption"                />
  6.     <PUBLIC:PROPERTY    NAME="firstTab"                />
  7.     <PUBLIC:PROPERTY    NAME="group"                />
  8.     <PUBLIC:METHOD        NAME="doSelect"                />        
  9.     <ATTACH   EVENT="ondocumentready"     HANDLER="doInit"        />
  10.     <ATTACH   EVENT="onmousedown"       HANDLER="doMouseDown"   />
  11.     <ATTACH      EVENT="onselectstart"        HANDLER="cancelCursorSelect"    />    
  12.     <PUBLIC:EVENT    NAME="onchange"            ID="OnTabChange"        />        
  13.     <script language="javascript">
  14.     var aButton         = new Array();
  15.     var strImgSrc, strImgPath, strImgName, strText,btnText,btnImg, strGroup;
  16.     
  17.     function doInit()
  18.     {
  19.         strImgSrc  = (imgSrc != null) ? System.getInstallFolder() + imgSrc : "fe/NHL/images/button/controller_config_nml.gif";
  20.         strImgName = strImgSrc.split('/');
  21.         strImgName.reverse();
  22.         strImgName = strImgName[0];
  23.         strImgPath = strImgSrc.substr(0, strImgSrc.length - strImgName.length);
  24.         strText       = (caption !=null) ? nhlMsg(caption) : "";    
  25.         strGroup   = (group != null ) ? group : "00";
  26.         aButton[ "normal" ] = strImgPath + strImgName;
  27.         aButton[ "down"  ] =  aButton[ "normal" ].toString().replace(/nml/ , "dwn" );
  28.         setDefaults();
  29.         createButton();        
  30.         if(firstTab)
  31.             doMouseDown();
  32.     }
  33.     
  34.     function setDefaults() 
  35.     {
  36.         NormalDefault("fontFamily",        "Times New Roman",    "Verdana");
  37.         NormalDefault("fontSize",         "12pt",                "7pt");
  38.         NormalDefault("fontStyle",         "normal",            "normal");        
  39.         NormalDefault("fontWeight",     "400",                "400");
  40.         NormalDefault("cursor",            "auto",                "hand");
  41.         NormalDefault("left",            "0px",                "0px");                
  42.         NormalDefault("top",            "0px",                "0px");            
  43.                 
  44.         CustomDefault('nml-text-color',    'nmlTextColor',    '#666666');
  45.         CustomDefault('dwn-text-color',    'dwnTextColor',    'black');
  46.     }    
  47.     
  48.     function NormalDefault(sCSSName, sIEDefault, sDefault)
  49.     {
  50.        if (currentStyle[sCSSName] == sIEDefault 
  51.            && (style[sCSSName] == "" || style[sCSSName] == null))
  52.        {
  53.            style[sCSSName] = sDefault;
  54.        }
  55.        else style[sCSSName] = currentStyle[sCSSName];
  56.     }        
  57.     
  58.     function CustomDefault(sCSSName, sScriptName, sDefault)
  59.     {
  60.        if (currentStyle[sCSSName] == null)
  61.        {
  62.            style[sCSSName] = sDefault;
  63.        }
  64.        else style[sCSSName] = currentStyle[sCSSName];
  65.        
  66.        style[sScriptName] = style[sCSSName];
  67.     }
  68.     
  69.     function createButton()
  70.     {
  71.         var oImg              = element.document.createElement("IMG");
  72.         oImg.id                  = element.id + "_img";
  73.         oImg.src              = strImgPath + strImgName;
  74.         with(oImg.style)
  75.         {
  76.             position         =         'absolute';
  77.             top                =        '0px';//currentStyle.top;
  78.             left            =        '0px';//currentStyle.left;    
  79.         }
  80.         btnImg = oImg;
  81.         element.appendChild(oImg);
  82.         var oSpan              = element.document.createElement("SPAN");
  83.         oSpan.id              = element.id + "_text";
  84.         oSpan.innerText          =    strText;
  85.         with(oSpan.style)
  86.         {            
  87.             position         =         'absolute';
  88.             fontFamily        =       'verdana';
  89.             color           =       currentStyle.nmlTextColor;
  90.             fontSize           =       '7pt';
  91.             fontStyle          =       currentStyle.fontStyle;
  92.             fontWeight         =       currentStyle.fontWeight;
  93.             height             =         String(oImg.clientHeight) + 'px';
  94.             width             =         String(oImg.clientWidth) + 'px';
  95.             overflowY        =         "hidden";
  96.             overflowX        =         "hidden";    
  97.             paddingTop        =        "3px";    
  98.             paddingLeft        =        "4px";    
  99.             top                =        '0px';//currentStyle.top;
  100.             left            =        '0px';//currentStyle.left;
  101.             textAlign         =         'left';
  102.         }
  103.         btnText = oSpan;
  104.         element.appendChild(oSpan);
  105.     }
  106.     
  107.     function doSelect()
  108.     {
  109.         oAudioInterface.PlayTabSelectSFX();
  110.         doMouseDown( true )
  111.     }
  112.     
  113.     function doMouseDown( NoEvent )
  114.     {
  115.  
  116.         var selectedId      = btnText.parentElement.document.body.getAttribute( "selected_" + strGroup );
  117.         var oPreviousEl     = btnText.parentElement.document.getElementById(selectedId);
  118.  
  119.         if(oPreviousEl != null && btnText.parentElement.id != selectedId)
  120.         {        
  121.              oPreviousEl.childNodes(1).style.color = element.currentStyle.nmlTextColor;
  122.              oPreviousEl.childNodes(0).src           = aButton[ "normal" ];
  123.              oPreviousEl.style.pixelTop = oPreviousEl.style.pixelTop - 1;
  124.  
  125.         }
  126.         if(btnText.parentElement.id != selectedId )
  127.         { 
  128.             btnText.style.color = element.currentStyle.dwnTextColor;
  129.             btnImg.src          = aButton[ "down" ];    
  130.             btnText.parentElement.style.pixelTop = btnText.parentElement.style.pixelTop + 1;    
  131.         }                    
  132.         btnText.parentElement.document.body.setAttribute( "selected_" + strGroup , btnText.parentElement.id );
  133.         //fire event
  134.         if(!NoEvent)
  135.         {
  136.             var oEvent = createEventObject();
  137.             OnTabChange.fire( oEvent );
  138.             event.cancelBubble  = true;
  139.             event.returnValue   = false;
  140.         }
  141.     }
  142.     
  143.     function cancelCursorSelect() 
  144.     { 
  145.         event.cancelBubble  = true;
  146.         event.returnValue   = false;
  147.     }
  148.     </script>
  149.  
  150. </PUBLIC:COMPONENT>