home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2005 October / Gamestar_77_2005-10_dvd.iso / Programy / nsb-install-8-0.exe / chrome / browser.jar / content / browser / pref / pref-features.js < prev    next >
Encoding:
JavaScript  |  2005-07-29  |  5.8 KB  |  168 lines

  1.  
  2. /*
  3. var _elementIDs = ["tabbedExternalLinks", "hideTabBar", "warnOnClose",
  4.                    "advancedJavaAllow", "enableSoftwareInstall", 
  5.                    "enableJavaScript", "enableImagePref",
  6.                    "popupPolicy", "allowWindowMoveResize", 
  7.                    "allowWindowFlip", "allowControlContextMenu", 
  8.                    "allowHideStatusBar", "allowWindowStatusChange", 
  9.                    "allowImageSrcChange"];
  10. */
  11.  
  12. var _elementIDs = [ "tabbedExternalLinks", "hideTabBar", "warnOnClose",
  13.                     "popupInNewTab", "newTabChoice", "newTabLocation", "doubleClickToCloseTab",
  14.                     "loadTabInBackground", "focusAfterRemoval", "localFileOpen",
  15.                     "historyOpen", "bookmarkOpen", "homePageOpen", "doubleClickTabBarToOpen",
  16.                     "searchBarResultOpen", "personalToolbarButtonOpen", "newWindowAction",
  17.                     "showCloseButtonOnTab", "showSiteControlButtonOnTab" ];
  18.  
  19.                                     // MERC (DP)
  20.                                     // bug in firefox prevents the feature from working
  21.                                     // "newAddressOpen",
  22.                                     
  23.                                     // MERC (Stevo)
  24.                                     // Removed since not used in Netscape 8+
  25.                                     // "linkInPageOpen",
  26.  
  27. var gImagesPref, gImagesEnabled, gImagesRestricted;
  28.  
  29. function Startup()
  30. {
  31.   /*
  32.   updateButtons('popup', 'install', 'javascript');
  33.   
  34.   gImagesPref = document.getElementById("enableImagePref");
  35.   gImagesEnabled = document.getElementById("enableImages");
  36.   gImagesRestricted = document.getElementById("enableRestricted");
  37.   var prefValue = gImagesPref.getAttribute("value");
  38.   if (!prefValue)
  39.     prefValue = "0";
  40.   switch (prefValue) {
  41.   case "1": 
  42.     gImagesRestricted.checked = true;
  43.   case "0": 
  44.     gImagesEnabled.checked = true;
  45.     break;
  46.   }
  47.   if (!gImagesEnabled.checked)
  48.     gImagesRestricted.disabled = true;
  49.  
  50.   if (parent.hPrefWindow.getPrefIsLocked("network.image.imageBehavior")) {  
  51.     gImagesRestricted.disabled = true;
  52.     gImagesEnabled.disabled = true;
  53.   }
  54.   */
  55.   top.hPrefWindow.registerOKCallbackFunc(onPrefFeaturesOK);
  56. }
  57.  
  58. // MERC (DP)
  59. function onPrefFeaturesOK() {
  60.   var browsertabs = top.opener.document.getElementById("browsertabs");
  61.  
  62.   // get pref value before OK clicked
  63.   var oldShowCloseButtonPref = top.hPrefWindow.getPref("bool", "browser.tabs.showCloseButtonOnTab");
  64.   
  65.   // get pref value after OK clicked
  66.   var newShowCloseButtonPrefObj = top.hPrefWindow
  67.                                  .wsm.dataManager.getPageData("chrome://browser/content/pref/pref-features.xul")
  68.                                  .elementIDs["showCloseButtonOnTab"];
  69.   var newShowCloseButtonPref = newShowCloseButtonPrefObj["checked"];
  70.  
  71.   // if pref was changed
  72.   if(oldShowCloseButtonPref != newShowCloseButtonPref) {
  73.     if(newShowCloseButtonPref) {
  74.       browsertabs.setAttribute('showCloseButton', 'true');
  75.     } else {
  76.       browsertabs.removeAttribute('showCloseButton');
  77.     }
  78.   }
  79.  
  80.   // get pref value before OK clicked
  81.   var oldShowSiteControlButtonPref = top.hPrefWindow.getPref("bool", "browser.tabs.showSiteControlButtonOnTab");
  82.   
  83.   // get pref value after OK clicked
  84.   var newShowSiteControlButtonPrefObj = top.hPrefWindow
  85.                                  .wsm.dataManager.getPageData("chrome://browser/content/pref/pref-features.xul")
  86.                                  .elementIDs["showSiteControlButtonOnTab"];
  87.   var newShowSiteControlButtonPref = newShowSiteControlButtonPrefObj["checked"];
  88.  
  89.   // if pref was changed
  90.   if(oldShowSiteControlButtonPref != newShowSiteControlButtonPref) {
  91.     if(newShowSiteControlButtonPref) {
  92.       browsertabs.setAttribute('showSiteControlButton', 'true');
  93.     } else {
  94.       browsertabs.removeAttribute('showSiteControlButton');
  95.     }
  96.   }
  97. }
  98.  
  99. function updateImagePref()
  100. {
  101.   if (!parent.hPrefWindow.getPrefIsLocked("network.image.imageBehavior")) {
  102.     if (!gImagesEnabled.checked) {
  103.       gImagesPref.setAttribute("value", 2)
  104.       gImagesRestricted.disabled = true;
  105.     } else {
  106.       gImagesPref.setAttribute("value", gImagesRestricted.checked ? 1 : 0)
  107.       gImagesRestricted.disabled = false;
  108.     }
  109.   } else {
  110.     gImagesRestricted.disabled = true;
  111.     gImagesEnabled.disabled = true;
  112.   }
  113. }
  114.  
  115. function advancedJavaScript()
  116. {
  117.   openDialog("chrome://browser/content/pref/pref-advancedscripts.xul", "", 
  118.              "chrome,modal");
  119. }
  120.  
  121. function updateButtons()
  122. {
  123.   var i;
  124.   var checkbox;
  125.   var button;
  126.  
  127.   for (i=0; i < arguments.length; ++i) {
  128.     switch (arguments[i]) {
  129.     case "popup":
  130.       checkbox = document.getElementById("popupPolicy");
  131.       button   = document.getElementById("popupPolicyButton");
  132.       break;
  133.     case "install":
  134.       checkbox = document.getElementById("enableSoftwareInstall");
  135.       button   = document.getElementById("enableSoftwareInstallButton");
  136.       break;
  137.     case "javascript":
  138.       checkbox = document.getElementById("enableJavaScript");
  139.       button   = document.getElementById("advancedJavascript");
  140.       break;
  141.     }
  142.     button.disabled = !checkbox.checked;
  143.   }
  144. }
  145.  
  146. var gExceptionsParams = {
  147.   install: { blockVisible: false, sessionVisible: false, allowVisible: true, prefilledHost: "", permissionType: "install" },
  148.   popup:   { blockVisible: false, sessionVisible: false, allowVisible: true, prefilledHost: "", permissionType: "popup"   },
  149.   image:   { blockVisible: true,  sessionVisible: false, allowVisible: true, prefilledHost: "", permissionType: "image"   },
  150. };
  151.  
  152. function showExceptions(aEvent)
  153. {
  154.   var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  155.                      .getService(Components.interfaces.nsIWindowMediator);
  156.   var existingWindow = wm.getMostRecentWindow("exceptions");
  157.   if (existingWindow) {
  158.     existingWindow.setHost("");
  159.     existingWindow.focus();
  160.   }
  161.   else {
  162.     const kURL = "chrome://browser/content/cookieviewer/CookieExceptions.xul";
  163.     var params = gExceptionsParams[aEvent.target.getAttribute("permissiontype")];
  164.     window.openDialog(kURL, "_blank", "chrome,modal,resizable=yes", params);
  165.   }
  166. }
  167.  
  168.