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

  1. // Copyright 1999 Macromedia, Inc. All rights reserved.
  2.  
  3. //******************* GLOBALS **********************
  4.  
  5. var CMD_TO_LAUNCH = "Design Notes.htm";
  6.  
  7. //***************** API  ******************
  8.  
  9. function canAcceptCommand() {
  10.   var retVal = true;             //always true for document window
  11.     
  12.   if (site.windowIsFrontmost()) { //if called for site window
  13.     retVal = getSiteSelFile();    //true only if single-selection
  14.   } else if (dw.getDocumentDOM() == null) retVal = false;
  15.  
  16.   return retVal;
  17. }
  18.  
  19. //***************** LOCAL FUNCTIONS  ******************
  20.  
  21. function initializeUI() {
  22.   var filePath = "", src, metafile;
  23.  
  24.   //ensure file is saved
  25.  
  26.   if (site.windowIsFrontmost()) {                    //if called for site window
  27.     if (site.getFocus().toLowerCase() != "remote") { //local or map file selected
  28.       src = getSiteSelFile();
  29.       if (src) {                                   //single selection
  30.         var fObj = new File(src);
  31.         if (fObj.canWrite()) {  
  32.           filePath = fObj.getAbsolutePath(); //resolve the local path of the selection
  33.         } else {
  34.           alert(MSG_ReadOnlyFile);
  35.         }
  36.       }
  37.     } else {
  38.       alert(MSG_RemoteFileSel);
  39.     }
  40.  
  41.   } else {                        //called for doc window
  42.     filePath = dreamweaver.getDocumentPath("document");
  43.     if (!filePath) {
  44.       if (confirm(MSG_WantSave) && dw.canSaveDocument(dreamweaver.getDocumentDOM('document'))) {
  45.         dw.saveDocument(dreamweaver.getDocumentDOM('document'));
  46.         filePath = dreamweaver.getDocumentPath("document");
  47.       }
  48.     } else { //file exists, ensure it's writeable
  49.       var fObj = new File(filePath);
  50.       if (!fObj.canWrite()) {
  51.         filePath = "";           //clear, because we can't edit
  52.         alert(MSG_ReadOnlyFile);
  53.       }
  54.     }
  55.   }
  56.  
  57.   if (filePath) {
  58.     metafile = (MMNotes.open(filePath));  //open, or create metafile
  59.     if (metafile) {                            //if okay to open
  60.       MMNotes.close(metafile);                  //close it
  61.       MMNotes.FileInfo_filePath = filePath;     //store the filePath as a global
  62.       dreamweaver.popupCommand(CMD_TO_LAUNCH); //launch the command
  63.     } else {
  64.       alert(MSG_MetaDisabled);
  65.     }
  66.   }
  67. }
  68.  
  69.  
  70. function getSiteSelFile() {
  71.   var fileList = site.getSelection();
  72.   return ((fileList.length == 1)? fileList[0] : false);
  73. }
  74.