home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Dreamweaver 3 / Configuration / Menus / MM / Editors_Dynamic.js < prev    next >
Encoding:
Text File  |  1999-12-01  |  3.0 KB  |  103 lines

  1. // Copyright 1999 Macromedia, Inc. All rights reserved.
  2.  
  3.     function receiveArguments()
  4.     {
  5.         var editorURL="";
  6.         var menuItem = arguments[0];
  7.  
  8.         for (i=0; i < dw.constructor.gMenuIDs.length-1; i++)
  9.         {
  10.             if (menuItem == dw.constructor.gMenuIDs[i])
  11.                 editorURL = dw.constructor.gExternalEditors[i*2 + 1];        
  12.         }
  13.  
  14.         if (editorURL != "")
  15.         {
  16.             dw.openWithApp(site.getSelection(), editorURL);
  17.             return true;
  18.         }
  19.         else
  20.         {
  21.             dw.openWithBrowseDialog(site.getSelection());
  22.             return true;
  23.         }
  24.     }
  25.  
  26.     function canAcceptCommand()
  27.     {
  28.         var selItems = site.getSelection();
  29.         if (selItems.length > 1 || selItems.length == 0 || !DWfile.exists(selItems[0]))
  30.             return false;
  31.         else
  32.             return (DWfile.getAttributes(selItems[0]) != "D");
  33.     }
  34.  
  35.    function getDynamicContent()
  36.    {
  37.       var selItems = site.getSelection();
  38.       if (selItems.length > 1 || selItems.length == 0)
  39.          return "";
  40.  
  41.     // get the primary external editor for the selected item    
  42.       var primaryEditorArray = dw.getPrimaryExtensionEditor(selItems[0]);
  43.       if (primaryEditorArray.length == 1)
  44.       {
  45.           dw.constructor.gPrimaryEditorName = "";
  46.           dw.constructor.gPrimaryEditorURL = "";
  47.       }
  48.       else
  49.       {
  50.           dw.constructor.gPrimaryEditorName = primaryEditorArray[0];
  51.           dw.constructor.gPrimaryEditorURL = primaryEditorArray[1];
  52.       }
  53.     // get the external editors for the selected item    
  54.       var externalEditorArray = dw.getExtensionEditorList(selItems[0]);
  55.       if (externalEditorArray.length <= 1)
  56.           dw.constructor.gExternalEditors = new Array("");      
  57.       else if (externalEditorArray.length == 2 && dw.constructor.gPrimaryEditorName != "")
  58.           dw.constructor.gExternalEditors = new Array("");
  59.       else
  60.       {
  61.         dw.constructor.gExternalEditors = new Array(externalEditorArray.length-2);
  62.         var index=0;
  63.           for (i=0; i < externalEditorArray.length; i++)
  64.           {
  65.             // don't add the primary editor to the list of editors
  66.             if (externalEditorArray[i+1] == dw.constructor.gPrimaryEditorURL)
  67.                i++;
  68.             else
  69.                 dw.constructor.gExternalEditors[index++] = externalEditorArray[i];
  70.           }
  71.       }
  72.       
  73.     // put the names of the editors in the menu
  74.       var menuItems;
  75.       var i;
  76.       if (dw.constructor.gExternalEditors.length == 1)
  77.       {
  78.         // we should have pairs... if we don't then just add Browse... to the list
  79.         menuItems = new Array(1);
  80.         dw.constructor.gMenuIDs = new Array(1);
  81.         i=0;
  82.       }
  83.       else
  84.       {
  85.           // we have pairs of editor names and editor paths
  86.         // put the names in the menu and remember the paths
  87.         menuItems = new Array(dw.constructor.gExternalEditors.length/2 + 1);
  88.         dw.constructor.gMenuIDs = new Array(dw.constructor.gExternalEditors.length/2 + 1);
  89.         for (i=0; i < dw.constructor.gExternalEditors.length/2; i++)
  90.         {
  91.             // add non-primary editors to the list of editors
  92.             dw.constructor.gMenuIDs[i] = "Editor" + i;
  93.             menuItems[i] = dw.constructor.gExternalEditors[i*2] + ";id='" + escQuotes(dw.constructor.gMenuIDs[i]) + "'";
  94.         }
  95.       }
  96.       
  97.       // always add Browse... to the bottom of the list
  98.       dw.constructor.gMenuIDs[i] = "ExtEd:Browse";
  99.       menuItems[i] = MENU_Browse + ";id='" + escQuotes(dw.constructor.gMenuIDs[i]) + "'";
  100.  
  101.       return menuItems;
  102.    }
  103.