home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / web_dev / files / mwjpp516.exe / %MAINDIR% / Tools / Toolbars / Bookmarks.script < prev    next >
Encoding:
Text File  |  2001-06-19  |  8.0 KB  |  162 lines

  1. !!Script
  2. // Copyright ⌐ 2001 - Miguel Angel Rojas G.
  3. // Copyright ⌐ 2001 - Modelworks Software
  4. // @Modified build 498 - cm20010305
  5. // @Modified build 501 - cm20010316
  6.  
  7. /**
  8. @Tool: Bookmarks~defines a toolbar with a list of buttons for navigate through bookmarks. 
  9. @Summary: Bookmarks~defines Navigator of Bookmarks
  10. */
  11.  
  12. var gOutput = getOutput();
  13. var gBookmarkMap = getMapFile( "Bookmarks" );
  14.  
  15. function OnNotify()
  16. {
  17.     var bookmarkCount = gBookmarkMap.count;
  18.     var toolBar = getGlobal("BookmarkToolbar", null);
  19.     if (toolBar)
  20.     {        
  21.         toolBar.enableButton(getGlobal("BookmarkToolbar.GotoFirstCommandID"), bookmarkCount > 0);
  22.         toolBar.enableButton(getGlobal("BookmarkToolbar.GotoNextCommandID"), bookmarkCount > 0);
  23.         toolBar.enableButton(getGlobal("BookmarkToolbar.GotoLastCommandID"), bookmarkCount > 0);
  24.         toolBar.enableButton(getGlobal("BookmarkToolbar.ChooseCommandID"), bookmarkCount > 0);
  25.         toolBar.enableButton(getGlobal("BookmarkToolbar.DeleteCurrentCommandID"), bookmarkCount > 0);
  26.         toolBar.enableButton(getGlobal("BookmarkToolbar.RemoveCommandID"), bookmarkCount > 0);
  27.         toolBar.enableButton(getGlobal("BookmarkToolbar.DeleteAllCommandID"), bookmarkCount > 0);
  28.         toolBar.enableButton(getGlobal("BookmarkToolbar.GotoPrevCommandID"), bookmarkCount > 0);
  29.         
  30.         var editor = getActiveEditor();
  31.         if (editor)
  32.         {
  33.             toolBar.enableButton(getGlobal("BookmarkToolbar.InsertNamedCommandID"), true);
  34.             toolBar.enableButton(getGlobal("BookmarkToolbar.InsertCommandID"), true);
  35.             var editorBookmarkCount = editor.getBookmarkCount();
  36.             toolBar.enableButton(getGlobal("BookmarkToolbar.GoUpCommandID"), editorBookmarkCount > 0);
  37.             toolBar.enableButton(getGlobal("BookmarkToolbar.GoDownCommandID"), editorBookmarkCount > 0);
  38.         }
  39.         else
  40.         {
  41.             toolBar.enableButton(getGlobal("BookmarkToolbar.InsertNamedCommandID"), false);
  42.             toolBar.enableButton(getGlobal("BookmarkToolbar.InsertCommandID"), false);
  43.             toolBar.enableButton(getGlobal("BookmarkToolbar.GoUpCommandID"), false);
  44.             toolBar.enableButton(getGlobal("BookmarkToolbar.GoDownCommandID"), false);
  45.         }
  46.     }
  47. }
  48.  
  49. function DoCommand()
  50. {
  51.     var gToolsPath = File.getToolsPath();
  52.  
  53.     var toolBar = newToolBar( "Bookmarks" );
  54.     setGlobal("BookmarkToolbar", toolBar);
  55.     
  56.     gBookmarkMap.registerNotify(getScriptPath());
  57.     Application.registerNotify(getScriptPath(), "editor.changed");
  58.     
  59.     var toolBarIconIButton = newToolBarButton( "icon" );
  60.     toolBarIconIButton.scriptPath  = "\\Bookmark\\insertBookmark.script";
  61.     toolBarIconIButton.imagePath   = gToolsPath + "\\Bookmark\\images\\insert.bmp";
  62.     toolBarIconIButton.description = "Insert Bookmark";
  63.     toolBarIconIButton.toolTipText = "Insert Bookmark";
  64.     var InsertCommandID = toolBar.appendButton( toolBarIconIButton );
  65.     setGlobal("BookmarkToolbar.InsertCommandID", InsertCommandID);
  66.     
  67.     var toolBarIconIButton = newToolBarButton( "icon" );
  68.     toolBarIconIButton.scriptPath  = "\\Bookmark\\addBookmark.script";
  69.     toolBarIconIButton.imagePath   = gToolsPath + "\\Bookmark\\images\\insertNamed.bmp";
  70.     toolBarIconIButton.description = "Insert Named Bookmark...";
  71.     toolBarIconIButton.toolTipText = "Insert Named Bookmark...";
  72.     var InsertNamedCommandID = toolBar.appendButton( toolBarIconIButton );
  73.     setGlobal("BookmarkToolbar.InsertNamedCommandID", InsertNamedCommandID);
  74.  
  75.     var toolBarIconDownButton = newToolBarButton( "icon" );
  76.     toolBarIconDownButton.scriptPath  = "\\Bookmark\\goDown.script";
  77.     toolBarIconDownButton.imagePath   = gToolsPath + "\\Bookmark\\images\\goDown.bmp";
  78.     toolBarIconDownButton.description = "Go down to next bookmark in file";
  79.     toolBarIconDownButton.toolTipText = "Go down to next bookmark in file";
  80.     var GoDownCommandID = toolBar.appendButton( toolBarIconDownButton );
  81.     setGlobal("BookmarkToolbar.GoDownCommandID", GoDownCommandID);
  82.     
  83.     var toolBarIconUpButton = newToolBarButton( "icon" );
  84.     toolBarIconUpButton.scriptPath  = "\\Bookmark\\goUp.script";
  85.     toolBarIconUpButton.imagePath   = gToolsPath + "\\Bookmark\\images\\goUp.bmp";
  86.     toolBarIconUpButton.description = "Go up to next bookmark in file";
  87.     toolBarIconUpButton.toolTipText = "Go up to next bookmark in file";
  88.     var GoUpCommandID = toolBar.appendButton( toolBarIconUpButton );
  89.     setGlobal("BookmarkToolbar.GoUpCommandID", GoUpCommandID);
  90.  
  91.     var toolBarIconFButton = newToolBarButton( "icon" );
  92.     toolBarIconFButton.scriptPath  = "\\Bookmark\\gotoFirst.script";
  93.     toolBarIconFButton.imagePath   = gToolsPath + "\\Bookmark\\images\\gotoFirst.bmp";
  94.     toolBarIconFButton.description = "Go to First Bookmark";
  95.     toolBarIconFButton.toolTipText = "Go to First Bookmark";
  96.     var GotoFirstCommandID = toolBar.appendButton( toolBarIconFButton );
  97.     setGlobal("BookmarkToolbar.GotoFirstCommandID", GotoFirstCommandID);
  98.     
  99.     var toolBarIconPButton = newToolBarButton( "icon" );
  100.     toolBarIconPButton.scriptPath  = "\\Bookmark\\gotoPrevious.script";
  101.     toolBarIconPButton.imagePath   = gToolsPath + "\\Bookmark\\images\\gotoPrevious.bmp";
  102.     toolBarIconPButton.description = "Go to Previous Bookmark";
  103.     toolBarIconPButton.toolTipText = "Go to Previous Bookmark";
  104.     var GotoPrevCommandID = toolBar.appendButton( toolBarIconPButton );
  105.     setGlobal("BookmarkToolbar.GotoPrevCommandID", GotoPrevCommandID);
  106.     
  107.     var toolBarIconNButton = newToolBarButton( "icon" );
  108.     toolBarIconNButton.scriptPath  = "\\Bookmark\\gotoNext.script";
  109.     toolBarIconNButton.imagePath   = gToolsPath + "\\Bookmark\\images\\gotoNext.bmp";
  110.     toolBarIconNButton.description = "Go to Next Bookmark";
  111.     toolBarIconNButton.toolTipText = "Go to Next Bookmark";
  112.     var GotoNextCommandID = toolBar.appendButton( toolBarIconNButton );
  113.     setGlobal("BookmarkToolbar.GotoNextCommandID", GotoNextCommandID);
  114.     
  115.     var toolBarIconLButton = newToolBarButton( "icon" );
  116.     toolBarIconLButton.scriptPath  = "\\Bookmark\\gotoLast.script";
  117.     toolBarIconLButton.imagePath   = gToolsPath + "\\Bookmark\\images\\gotoLast.bmp";
  118.     toolBarIconLButton.description = "Go to Last Bookmark";
  119.     toolBarIconLButton.toolTipText = "Go to Last Bookmark";
  120.     var GotoLastCommandID = toolBar.appendButton( toolBarIconLButton );
  121.     setGlobal("BookmarkToolbar.GotoLastCommandID", GotoLastCommandID);
  122.     
  123.     var toolBarIconWButton = newToolBarButton( "icon" );
  124.     toolBarIconWButton.scriptPath  = "\\Bookmark\\chooseBookmark.script";
  125.     toolBarIconWButton.imagePath   = gToolsPath + "\\Bookmark\\images\\choose.bmp";
  126.     toolBarIconWButton.description = "Choose and Go to Selected Bookmark";
  127.     toolBarIconWButton.toolTipText = "Choose and Go to Selected Bookmark";
  128.     var ChooseCommandID = toolBar.appendButton( toolBarIconWButton );
  129.     setGlobal("BookmarkToolbar.ChooseCommandID", ChooseCommandID);
  130.     
  131.     var toolBarIconDButton = newToolBarButton( "icon" );
  132.     toolBarIconDButton.scriptPath  = "\\Bookmark\\deleteCurrentBookmark.script";
  133.     toolBarIconDButton.imagePath   = gToolsPath + "\\Bookmark\\images\\delete.bmp";
  134.     toolBarIconDButton.description = "Delete Current Bookmark";
  135.     toolBarIconDButton.toolTipText = "Delete Current Bookmark";
  136.     var DeleteCurrentCommandID = toolBar.appendButton( toolBarIconDButton );
  137.     setGlobal("BookmarkToolbar.DeleteCurrentCommandID", DeleteCurrentCommandID);
  138.     
  139.     var toolBarIconAButton = newToolBarButton( "icon" );
  140.     toolBarIconAButton.scriptPath  = "\\Bookmark\\removeBookmark.script";
  141.     toolBarIconAButton.imagePath   = gToolsPath + "\\Bookmark\\images\\remove.bmp";
  142.     toolBarIconAButton.description = "Choose Bookmarks to Remove...";
  143.     toolBarIconAButton.toolTipText = "Choose Bookmarks to Remove...";
  144.     var RemoveCommandID = toolBar.appendButton( toolBarIconAButton );
  145.     setGlobal("BookmarkToolbar.RemoveCommandID", RemoveCommandID);
  146.  
  147.     var toolBarIconAButton = newToolBarButton( "icon" );
  148.     toolBarIconAButton.scriptPath  = "\\Bookmark\\deleteAllBookmarks.script";
  149.     toolBarIconAButton.imagePath   = gToolsPath + "\\Bookmark\\images\\deleteAll.bmp";
  150.     toolBarIconAButton.description = "Delete All Bookmarks";
  151.     toolBarIconAButton.toolTipText = "Delete All Bookmarks";
  152.     var DeleteAllCommandID = toolBar.appendButton( toolBarIconAButton );
  153.     setGlobal("BookmarkToolbar.DeleteAllCommandID", DeleteAllCommandID);
  154.     
  155.     toolBar.restoreState();
  156.     
  157.     
  158.     OnNotify();
  159. }
  160.  
  161. !!/Script
  162.