home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 August / PCpro_2005_08.ISO / files / firefox / ScrapBook.xpi / chrome / scrapbook.jar / content / overlay.js < prev    next >
Encoding:
JavaScript  |  2005-06-04  |  3.5 KB  |  104 lines

  1. /**************************************************
  2. // overlay.js
  3. // Implementation file for overlay.xul
  4. // 
  5. // Description: 
  6. // Author: Gomita
  7. // Contributors: 
  8. // 
  9. // Version: 
  10. // License: see LICENSE.txt
  11. **************************************************/
  12.  
  13.  
  14.  
  15. function SBcapture_branchContextMenu()
  16. {
  17.     document.getElementById("ScrapBookContextMenu1").hidden = !gContextMenu.isTextSelected;
  18.     document.getElementById("ScrapBookContextMenu2").hidden = !gContextMenu.isTextSelected;
  19.     document.getElementById("ScrapBookContextMenu3").hidden = gContextMenu.isTextSelected;
  20.     document.getElementById("ScrapBookContextMenu4").hidden = gContextMenu.isTextSelected;
  21.     document.getElementById("ScrapBookContextMenu5").hidden = (!gContextMenu.inFrame || gContextMenu.isTextSelected);
  22.     document.getElementById("ScrapBookContextMenu6").hidden = (!gContextMenu.inFrame || gContextMenu.isTextSelected);
  23.     document.getElementById("ScrapBookContextMenu7").hidden = (!gContextMenu.onLink || gContextMenu.onMailtoLink);
  24.     document.getElementById("ScrapBookContextMenu8").hidden = (!gContextMenu.onLink || gContextMenu.onMailtoLink);
  25. }
  26.  
  27.  
  28. function SBcapture_initContextMenu()
  29. {
  30.     document.getElementById("contentAreaContextMenu").removeEventListener("popupshowing", SBcapture_branchContextMenu, true);
  31.     document.getElementById("contentAreaContextMenu").addEventListener("popupshowing",    SBcapture_branchContextMenu, true);
  32.     if ( SBcommon.getBoolPref("scrapbook.browser.submenu", false) )
  33.     {
  34.         document.getElementById("ScrapBookContextSubmenu").hidden = false;
  35.         for ( var i = 1; i <= 8; i++ )
  36.         {
  37.             document.getElementById("ScrapBookContextSubmenu").firstChild.appendChild(document.getElementById("ScrapBookContextMenu" + i));
  38.         }
  39.     }
  40. }
  41.  
  42.  
  43. window.removeEventListener("load", SBcapture_initContextMenu, true);
  44. window.addEventListener("load",    SBcapture_initContextMenu, true);
  45.  
  46.  
  47.  
  48.  
  49. var SB_lastFocusedURL = "";
  50.  
  51. function SB_initStatusbarPanel()
  52. {
  53.     try {
  54.         var curURL = window._content.location.href;
  55.     } catch(ex) {
  56.         return;
  57.     }
  58.     if ( curURL != SB_lastFocusedURL )
  59.     {
  60.         var isEditable = ( curURL.match(/^file/) && curURL.match(/\/data\/\d{14}\/index\.html$/) );
  61.         document.getElementById("ScrapBookStatusPanel").src    = isEditable ? "chrome://scrapbook/skin/status_edit.png" : "";
  62.         document.getElementById("ScrapBookStatusPanel").hidden = !isEditable;
  63.         SB_lastFocusedURL = curURL;
  64.     }
  65. }
  66.  
  67.  
  68. window.removeEventListener("load" , SB_initStatusbarPanel, true);
  69. window.removeEventListener("focus", SB_initStatusbarPanel, true);
  70. window.addEventListener("load" , SB_initStatusbarPanel, true);
  71. window.addEventListener("focus", SB_initStatusbarPanel, true);
  72.  
  73.  
  74.  
  75. function SBcommand_captureWindow(frameOnly, selectionOnly, showDetail)
  76. {
  77.     var targetWindow = frameOnly ? SBcommon.getFocusedWindow() : window._content;
  78.     SBcapture.doCaptureDocument(targetWindow, selectionOnly, showDetail, "urn:scrapbook:root", 0);
  79. }
  80.  
  81.  
  82. function SBcommand_captureTarget(showDetail)
  83. {
  84.     var linkURL = gContextMenu.linkURL();
  85.     if ( !linkURL ) return;
  86.     window.openDialog(
  87.         "chrome://scrapbook/content/capture.xul", "", "chrome,centerscreen,all,resizable,dialog=no",
  88.         [linkURL], document.popupNode.ownerDocument.location.href, showDetail, false, "urn:scrapbook:root", 0
  89.     );
  90. }
  91.  
  92.  
  93.  
  94. function SB_enterEditingMode()
  95. {
  96.     var curURL = window._content.location.href;
  97.     if ( curURL.match(/^file/) && curURL.match(/\/data\/(\d{14})\/index\.html$/) )
  98.     {
  99.         SBcommon.loadURL("chrome://scrapbook/content/edit.xul?id=" + RegExp.$1, false);
  100.     }
  101. }
  102.  
  103.  
  104.