home *** CD-ROM | disk | FTP | other *** search
/ ftp.swcp.com / ftp.swcp.com.zip / ftp.swcp.com / mac / mozilla-macos9-1.3.1.sea.bin / Mozilla1.3.1 / Chrome / comm.jar / content / cookie / pref-popups.xul < prev   
Extensible Markup Language  |  2003-06-07  |  7KB  |  191 lines

  1. <?xml version="1.0"?> 
  2.  
  3. <!-- ***** BEGIN LICENSE BLOCK *****
  4.    - Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5.    -
  6.    - The contents of this file are subject to the Mozilla Public License Version
  7.    - 1.1 (the "License"); you may not use this file except in compliance with
  8.    - the License. You may obtain a copy of the License at
  9.    - http://www.mozilla.org/MPL/
  10.    -
  11.    - Software distributed under the License is distributed on an "AS IS" basis,
  12.    - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13.    - for the specific language governing rights and limitations under the
  14.    - License.
  15.    -
  16.    - The Original Code is mozilla.org code.
  17.    -
  18.    - The Initial Developer of the Original Code is
  19.    - Netscape Communications Corporation.
  20.    - Portions created by the Initial Developer are Copyright (C) 2002
  21.    - the Initial Developer. All Rights Reserved.
  22.    -
  23.    - Contributor(s):
  24.    -
  25.    - Alternatively, the contents of this file may be used under the terms of
  26.    - either the GNU General Public License Version 2 or later (the "GPL"), or
  27.    - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.    - in which case the provisions of the GPL or the LGPL are applicable instead
  29.    - of those above. If you wish to allow use of your version of this file only
  30.    - under the terms of either the GPL or the LGPL, and not to allow others to
  31.    - use your version of this file under the terms of the MPL, indicate your
  32.    - decision by deleting the provisions above and replace them with the notice
  33.    - and other provisions required by the LGPL or the GPL. If you do not delete
  34.    - the provisions above, a recipient may use your version of this file under
  35.    - the terms of any one of the MPL, the GPL or the LGPL.
  36.    -
  37.    - ***** END LICENSE BLOCK ***** -->
  38.  
  39. <?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
  40.  
  41. <!DOCTYPE page [
  42. <!ENTITY % prefPopupsDTD SYSTEM "chrome://cookie/locale/pref-popups.dtd" >
  43. %prefPopupsDTD;
  44. ]>
  45.  
  46. <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  47.       id="popupsPanel"
  48.       onload="init()"
  49.       headertitle="&title;">
  50.           
  51.   <script type="application/x-javascript" src="chrome://cookie-/content/cookieOverlay.js"/>
  52.  
  53.   <script type="application/x-javascript">
  54.     <![CDATA[
  55.  
  56.       var _elementIDs = ["popupPolicy","playSound","playSoundUrl","displayIcon"];
  57.  
  58.       var gPolicyButton;
  59.       var gSoundCheckbox;
  60.       var gSoundUrlBox;
  61.       var gSoundUrlButton;
  62.       var gIconCheckbox;
  63.  
  64.       const POPUP_TYPE = 2;
  65.  
  66.       function init() {
  67.         parent.initPanel("chrome://cookie/content/pref-popups.xul");
  68.  
  69.         gPolicyButton = document.getElementById("popupPolicy");
  70.         gSoundCheckbox = document.getElementById("playSound");
  71.         gSoundUrlBox = document.getElementById("playSoundUrl");
  72.         gSoundUrlButton = document.getElementById("selectSound");
  73.         gIconCheckbox = document.getElementById("displayIcon");   
  74.  
  75.         setButtons();
  76.       }
  77.  
  78.       function blacklistEmpty() {
  79.         var permissionmanager = Components.classes["@mozilla.org/permissionmanager;1"]
  80.                                           .getService(Components.interfaces.nsIPermissionManager);
  81.  
  82.         var popupManager = Components.classes["@mozilla.org/PopupWindowManager;1"]
  83.                                      .getService(Components.interfaces.nsIPopupWindowManager);
  84.         var enumerator = popupManager.getEnumerator();
  85.  
  86.         while (enumerator.hasMoreElements()) {
  87.           var permission = enumerator.getNext()
  88.                                      .QueryInterface(Components.interfaces.nsIPermission);
  89.           if (!permission.capability)
  90.             return false;
  91.         }
  92.         return true;
  93.       }
  94.  
  95.       function setButtons() {
  96.         var exceptionsAllow = document.getElementById("exceptionsAllow");
  97.         var exceptionsBlock = document.getElementById("exceptionsBlock");
  98.  
  99.         exceptionsAllow.disabled = (gPolicyButton.value == "true");
  100.         exceptionsBlock.disabled = (!exceptionsAllow.disabled);
  101.  
  102.         if (blacklistEmpty() && (gPolicyButton.value == "false")) {
  103.           gSoundCheckbox.disabled = true;
  104.           gSoundUrlBox.disabled = true;
  105.           gSoundUrlButton.disabled = true;
  106.           gIconCheckbox.disabled = true;
  107.         }
  108.         else {
  109.           gSoundCheckbox.disabled = false;
  110.           gSoundUrlBox.disabled = false;
  111.           gSoundUrlButton.disabled = false;
  112.           gIconCheckbox.disabled = false;
  113.                   
  114.           enableSoundUrl(gSoundCheckbox.checked);
  115.         }
  116.       }
  117.  
  118.       function selectSound() {
  119.         var nsIFilePicker = Components.interfaces.nsIFilePicker;
  120.         var filepicker = Components.classes["@mozilla.org/filepicker;1"]
  121.                                    .createInstance(nsIFilePicker);
  122.  
  123.         filepicker.init(window, document.getElementById("selectSound").getAttribute("filepickertitle"), nsIFilePicker.modeOpen);
  124.         filepicker.appendFilters(nsIFilePicker.filterAll);
  125.  
  126.         var ret = filepicker.show();
  127.         if (ret == nsIFilePicker.returnOK)
  128.           gSoundUrlBox.value = filepicker.file.path;
  129.       }
  130.  
  131.       function enableSoundUrl(soundChecked) {
  132.         gSoundUrlBox.disabled = !soundChecked;
  133.         gSoundUrlButton.disabled = !soundChecked;
  134.       }
  135.  
  136.       function viewPopups() {
  137.         window.openDialog("chrome://communicator/content/popupManager.xul", "",
  138.                           "chrome,resizable=yes,modal=yes", 
  139.                           (gPolicyButton.value == "true"),
  140.                           "",
  141.                           true);
  142.       }
  143.  
  144.     ]]>
  145.   </script>
  146.  
  147.   <groupbox id="popupsArea">
  148.     <caption label="&popupBlocking.label;"/>
  149.     <description>&popupDetails;</description>
  150.     <hbox align="center">      
  151.       <radiogroup id="popupPolicy" preftype="bool" prefstring="dom.disable_open_during_load">
  152.         <vbox flex="1">
  153.           <hbox>
  154.             <radio value="false" label="&popupAllow.label;" 
  155.                    oncommand="setButtons()"/>
  156.             <spacer flex="1"/>
  157.             <button id="exceptionsAllow" label="&popupView.label;"
  158.                     oncommand="viewPopups();"/>
  159.           </hbox>        
  160.           <hbox>
  161.             <radio value="true" label="&popupBlock.label;"
  162.                    oncommand="setButtons()"/>
  163.             <spacer flex="1"/>
  164.             <button id="exceptionsBlock" label="&popupView.label;"
  165.                     oncommand="viewPopups();"/>
  166.           </hbox>
  167.         </vbox>
  168.       </radiogroup>      
  169.     </hbox>
  170.     <separator class="thin"/>
  171.     <description id="whenBlock">&whenBlock.description;</description>
  172.     <hbox align="center">
  173.       <checkbox id="playSound" label="&playSound.label;"
  174.                 oncommand="enableSoundUrl(this.checked);"
  175.                 preftype="bool" prefstring="privacy.popups.sound_enabled"
  176.                 prefattribute="checked"/>
  177.       <textbox flex="1" id="playSoundUrl" prefstring="privacy.popups.sound_url"/>
  178.       <button id="selectSound" label="&selectSound.label;" accesskey="&selectSound.accesskey;"
  179.               filepickertitle="&selectSound.title;" oncommand="selectSound();"/>
  180.     </hbox>
  181.     <hbox align="center">
  182.       <checkbox id="displayIcon" label="&displayIcon.label;"
  183.                 preftype="bool" prefstring="privacy.popups.statusbar_icon_enabled"
  184.                 prefattribute="checked"/>
  185.     </hbox>
  186.     <separator class="thin"/>
  187.     <description>&popupNote.description;</description>
  188.   </groupbox>
  189.  
  190. </page>
  191.