home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 October / Chip Ekim 2003.iso / prog / code / contr / setup.exe / Disk1 / data1.cab / Configuration_En / Commands / ccHR.js < prev    next >
Encoding:
JavaScript  |  2003-07-18  |  3.0 KB  |  144 lines

  1. //  Copyright 2002, 2003 Macromedia, Inc. All rights reserved.
  2.  
  3. var helpDoc = MM.HELP_objHorizontalRule;
  4.  
  5. function receiveArguments()
  6. {
  7. }
  8.  
  9. function canAcceptCommand()
  10. {
  11.     if ( dw.getDocumentDOM().getCCSharedSetting_TextOnlyInNonTemplates() )
  12.         return false;
  13.     return true;
  14. }
  15.  
  16. function commandButtons()
  17. {
  18. /*   return new Array(MM.BTN_OK,         "run()",
  19.                     MM.BTN_Cancel,     "window.close()",
  20.                     MM.BTN_Help,       "displayHelp()" );
  21. */
  22.  
  23.      return new Array( "PutButtonsOnBottom",
  24.                          "OkButton", MM.BTN_OK,     "run()", 
  25.                          "CancelButton", MM.BTN_Cancel,  "window.close()",
  26.                          "PutButtonOnLeft", MM.BTN_Help,    "displayHelp()");
  27. }
  28.  
  29. function initializeUI()
  30. {
  31.     var node = dw.getDocumentDOM().getSelectedNode();
  32.  
  33.     var width = node.getAttribute("width");
  34.     if(width != null && width != "")
  35.     {
  36.         var indexPercent = width.indexOf("%");
  37.         if(indexPercent > 0)
  38.         {
  39.             width = width.substr(0, indexPercent);
  40.  
  41.             document.theForm.Units.options[1].selected = true;
  42.         }
  43.         document.theForm.Width.value = width;
  44.     }
  45.     else
  46.     {
  47.         document.theForm.Width.value = "";
  48.     }
  49.  
  50.     var height = node.getAttribute("size");
  51.     if(height != null && height != "")
  52.     {
  53.         document.theForm.Height.value = height;
  54.     }
  55.     else
  56.     {
  57.         document.theForm.Height.value = "";
  58.     }
  59.  
  60.     if(node.getAttribute("noshade"))
  61.     {
  62.         document.theForm.Shading.checked = false;
  63.     }
  64. }
  65.  
  66. function verifyHRAttrs(widthValue, heightValue)
  67. {
  68.     var retVal = '';
  69.  
  70.     var width = parseInt(widthValue);
  71.     var height = parseInt(heightValue);
  72.  
  73.     if ( (!isNaN(width) && (width < 1) )  
  74.       || (width != widthValue && widthValue != '') )
  75.     {
  76.         retVal = errMsg(MM.Error_Invalid_Field, widthValue);
  77.     }
  78.  
  79.     if ( (!isNaN(height) && (height < 1) )  
  80.       || (height != heightValue && heightValue != '') )
  81.     {
  82.         retVal = errMsg(MM.Error_Invalid_Field, heightValue);
  83.     }
  84.  
  85.  
  86.     return retVal;
  87. }
  88.  
  89. function run()
  90. {
  91.     var node = dw.getDocumentDOM().getSelectedNode();
  92.  
  93.     var widthValue=document.forms[0].Width.value;
  94.     var heightValue=document.forms[0].Height.value;
  95.  
  96.     var errStr = '';
  97.     errStr = verifyHRAttrs(widthValue, heightValue);
  98.  
  99.     if(errStr.length < 1)
  100.     {
  101.         if ((widthValue != null) && (widthValue != ''))
  102.         {
  103.             var widthType = document.forms[0].Units.selectedIndex;
  104.             if(widthType == 1)
  105.             {
  106.                 widthValue += "%";
  107.             }
  108.             node.width = widthValue;
  109.         }
  110.         else if (node.getAttribute("width"))
  111.         {
  112.             node.removeAttribute("width");
  113.         }
  114.  
  115.         if ((heightValue != null) && (heightValue != ''))
  116.         {
  117.             node.size = heightValue;
  118.         }
  119.         else if (node.getAttribute("size"))
  120.         {
  121.             node.removeAttribute("size");
  122.         }
  123.  
  124.         var shading=document.forms[0].Shading.checked;
  125.         if(!shading)
  126.         {
  127.             node.noshade = "true";
  128.         }
  129.         else
  130.         {
  131.             if(node.getAttribute("noshade"))
  132.             {
  133.                 node.removeAttribute("noshade");
  134.             }
  135.         }
  136.         window.close();
  137.     }
  138.     else
  139.     {
  140.         alert(errStr);
  141.         document.forms[0].Width.focus();
  142.     }
  143. }
  144.