home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2000 April / maximum-cd-2000-04.iso / Utilities / InternetTools / dreamweaver3 / data1.cab / App_Files / Configuration / Menus / MM / Modify_EditableRegions.js < prev    next >
Encoding:
JavaScript  |  1999-12-09  |  2.0 KB  |  63 lines

  1. // Copyright 1999 Macromedia, Inc. All rights reserved.
  2.  
  3.    var idPrefix = "DWMenu_Modify_EditableRegion_";
  4.    var noneID = "DWMenu_Modify_EditableRegion_none";
  5.  
  6.    function indexFromID(itemID)
  7.    {
  8.       // Get the part of the ID which represents the index.
  9.      var prefixLen = idPrefix.length;
  10.        var number = itemID.substring(prefixLen, itemID.length);
  11.  
  12.      return number;
  13.    }
  14.  
  15.    function receiveArguments()
  16.    {
  17.      var index = indexFromID(arguments[0]);
  18.      if (dw.getDocumentDOM() != null){
  19.        var regionList = dw.getDocumentDOM().getEditableRegionList();
  20.        var node = regionList[index];
  21.  
  22.        dw.getDocumentDOM().setSelectedNode(node, true, true);
  23.      }
  24.    }
  25.  
  26.    function canAcceptCommand()
  27.    {
  28.       return (dw.getDocumentDOM() != null && !site.windowIsFrontmost() && arguments[0] != noneID);
  29.    }
  30.  
  31.    function isCommandChecked()
  32.    {
  33.       // See if the index matches the selected editable region.
  34.       return (dw.getDocumentDOM() != null && indexFromID(arguments[0]) == dw.getDocumentDOM().getSelectedEditableRegion())
  35.    }
  36.  
  37.    // getDynamicContent returns the contents of a dynamically generated menu.
  38.    // returns an array of strings to be placed in the menu, with a unique
  39.    // identifier for each item separated from the menu string by a semicolon.
  40.    //
  41.    // return null from this routine to indicate that you are not adding any
  42.    // items to the menu
  43.    function getDynamicContent(itemID)
  44.    {
  45.      var regionList = null;
  46.      if (dw.getDocumentDOM() != null){
  47.        regionList = dw.getDocumentDOM().getEditableRegionList();
  48.        if (regionList && regionList.length > 0)
  49.        {
  50.          var i;
  51.          for (i=0; i<regionList.length; i++)
  52.          {
  53.            regionList[i] = unescape(regionList[i].name) + ";id='" + escQuotes(idPrefix + i) + "'";
  54.          }
  55.        }
  56.        else
  57.        {
  58.          regionList[0] = MENU_NoEditableRegions + ";id='" + noneID +"'";
  59.        }
  60.      }
  61.      return regionList;
  62.    }
  63.