home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / komunikace / kmeleon / K-Meleon1.1.3en-US.exe / chrome / embed.jar / kmprefs / content / pref-appearance.xul < prev    next >
Extensible Markup Language  |  2007-04-23  |  12KB  |  340 lines

  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type="text/css" href="chrome://global/skin/"?>
  3. <?xul-overlay href="chrome://kmprefs/content/kmprefs/ovrl-popups.xul"?>
  4. <?xul-overlay href="chrome://kmprefs/content/kplugins/fullscreen.xul"?>
  5. <!DOCTYPE page SYSTEM "chrome://kmprefs/locale/pref-appearance.dtd">
  6. <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 
  7. id="prefAppearance" onload="init()">
  8.  
  9. <stringbundle id="pref_bundle" src="chrome://kmprefs/locale/pref.properties"/>
  10.  
  11. <script type="application/x-javascript" src="chrome://kmprefs/content/pref.js"/>
  12. <script type="application/x-javascript">
  13. <![CDATA[
  14. var prefBndl = document.getElementById("pref_bundle");
  15. var buttons  = document.getElementsByTagName("button");
  16. var txtboxs  = document.getElementsByTagName("textbox");
  17. function init() {
  18.     const bmp = "kmeleon.plugins.bmpmenu.load";
  19.     if(kPlugin.absent("bmpmenu")) {
  20.         var elem = document.getElementById(bmp);
  21.         elem.parentNode.removeChild(elem);
  22.     } else
  23.     initCheckbox(bmp);
  24.     initCheckbox("kmeleon.display.accelInMenus");
  25.     initTextbox("kmeleon.display.title",false);
  26.  
  27.     kFullscreen.init();
  28.  
  29.     if(kPlugin.absent("fullscreen")) {
  30.         var elem = document.getElementById("kmeleon.plugins.fullscreen.auto").parentNode;
  31.         elem.parentNode.removeChild(elem);
  32.     }
  33.     initFullscreenPlugin();
  34.     initThrobber();
  35.  
  36.     for(var j=0,b=document.getElementById("popups.appearance").getElementsByTagName("checkbox");j<b.length;j++)
  37.         initCheckbox(b[j].id);
  38. }
  39. function initFullscreenPlugin() {
  40.     if(!kPlugin.absent("fullscreen"))
  41.         for(var j=3,r=document.getElementsByTagName("radio");j<6;j++) {
  42.             // r[j].disabled = !enabled;
  43.             // bug: Option "Never fullscreen at startup" doesn't work
  44.             r[j].disabled = (j==4) ? true : !kFullscreen.load;
  45.     }
  46.     initWindow(initMaximized(initFullscreen(kFullscreen.load)));
  47. }
  48. function initWindow(off) {
  49.     for(var j=1;j<5;j++) {
  50.         txtboxs[j].disabled = off;
  51.         txtboxs[j].setAttribute("readonly",true);
  52.         txtboxs[j].value = getIntUserPref(txtboxs[j].id,"");
  53.     }
  54.     buttons[0].label = prefBndl.getString("edit");
  55.     buttons[0].disabled = off;
  56.     buttons[1].disabled = off;
  57.     buttons[2].label = prefBndl.getString("edit");
  58.     buttons[2].disabled = off;
  59.     buttons[3].disabled = off;
  60.     buttons[4].disabled = off ? off : !((getIntUserPref(txtboxs[1].id,"")) && (getIntUserPref(txtboxs[2].id,"")));
  61. }
  62.  
  63. function center() {
  64.     var w = parseInt(getIntUserPref(txtboxs[1].id,""));
  65.     var h = parseInt(getIntUserPref(txtboxs[2].id,""));
  66.     clear(3,4);
  67.     addToUserPrefs("user_pref(\""+txtboxs[4].id+"\", "+Math.floor((screen.height-h)/2).toString(10)+");");
  68.     addToUserPrefs("user_pref(\""+txtboxs[3].id+"\", "+Math.floor((screen.width-w)/2).toString(10)+");");
  69.     initFullscreenPlugin();
  70. }
  71. function clear(start,end) {
  72.     for(var j=start;j<end+1;j++)
  73.         removeFromFile(getFile(getFolder("ProfD"),UserPrefs),"user_pref[\\s]*\\([\\s]*."+txtboxs[j].id+".[\\s]*,[\\s]*[\\d]+[\\s]*\\)[\\s]*;");
  74. }
  75. function editSave(elem,start,end) {
  76.     for(var j=0;j<buttons.length;j++)
  77.         buttons[j].disabled = true;
  78.     if(elem.label == prefBndl.getString("save")) {
  79.         for(var j=start;j<end+1;j++)
  80.             txtboxs[j].setAttribute("readonly",true);
  81.         clear(start,end);
  82.         for(var j=end,val;j>start-1;j--) {
  83.             val = parseInt(txtboxs[j].value);
  84.             if(!isNaN(val))
  85.                 addToUserPrefs("user_pref(\""+txtboxs[j].id+"\", "+val.toString(10)+");");
  86.             else
  87.                 txtboxs[j].value = "";
  88.         }
  89.         initFullscreenPlugin();
  90.     } else {
  91.         for(var j=start;j<end+1;j++)
  92.             txtboxs[j].removeAttribute("readonly");
  93.         txtboxs[start].focus();
  94.         elem.label = prefBndl.getString("save");
  95.         buttons[start-1].disabled = false;
  96.         if(!kPlugin.absent("fullscreen")) document.getElementById("kmeleon.plugins.fullscreen.auto").disabled = true;
  97.         document.getElementById("kmeleon.display.maximized").disabled = true;
  98.     }
  99. }
  100.  
  101. // handle Fullscreen
  102. const fullscreenImport1 = "user_pref(\"kmeleon.plugins.fullscreen.auto\", ";
  103. const fullscreenImport2 = ");";
  104. const fullscreenRegExp1 = "user_pref[\\s]*\\([\\s]*.kmeleon.plugins.fullscreen.auto.[\\s]*,[\\s]*";
  105. const fullscreenRegExp2 = "[\\s]*\\)[\\s]*;";
  106. var fullscreenImport = new Array(fullscreenImport1+"false"+fullscreenImport2,fullscreenImport1+"true"+fullscreenImport2);
  107. var fullscreenRegExp = new Array(fullscreenRegExp1+"false"+fullscreenRegExp2,fullscreenRegExp1+"true"+fullscreenRegExp2);
  108. function initFullscreen(on) {
  109.     var txt = getFileContents(getFile(getFolder("ProfD"),UserPrefs));
  110.     var off = testMultiline(txt,fullscreenRegExp[1]);
  111.  
  112.     if(!kPlugin.absent("fullscreen")) {
  113.         var grp = document.getElementById("kmeleon.plugins.fullscreen.auto");
  114.  
  115.         if(off)
  116.                 grp.selectedIndex = 0;
  117.         else
  118.             if(testMultiline(txt,fullscreenRegExp[0]))
  119.                 grp.selectedIndex = 1;
  120.             else
  121.                 grp.selectedIndex = 2;
  122.     }
  123.     return on && off;
  124. }
  125. function toggleFullscreen(elem) {
  126.     var fil = getFile(getFolder("ProfD"),UserPrefs);
  127.  
  128.     removeFromFile(fil,fullscreenRegExp[0]);
  129.     removeFromFile(fil,fullscreenRegExp[1]);
  130.  
  131.     if(elem.value)
  132.         addToUserPrefs(fullscreenImport1+elem.value+fullscreenImport2);
  133.     else
  134.         pref.setBoolPref(elem.id,false);
  135.     initFullscreenPlugin();
  136. }
  137.  
  138. // handle Maximized
  139. const maximizedImport1 = "user_pref(\"kmeleon.display.maximized\", ";
  140. const maximizedImport2 = ");";
  141. const maximizedRegExp1 = "user_pref[\\s]*\\([\\s]*.kmeleon.display.maximized.[\\s]*,[\\s]*";
  142. const maximizedRegExp2 = "[\\s]*\\)[\\s]*;";
  143. var maximizedImport = new Array(maximizedImport1+"false"+maximizedImport2,maximizedImport1+"true"+maximizedImport2);
  144. var maximizedRegExp = new Array(maximizedRegExp1+"false"+maximizedRegExp2,maximizedRegExp1+"true"+maximizedRegExp2);
  145. function initMaximized(on) {
  146.     var txt = getFileContents(getFile(getFolder("ProfD"),UserPrefs));
  147.     var grp = document.getElementById("kmeleon.display.maximized");
  148.     var off = testMultiline(txt,maximizedRegExp[1]);
  149.  
  150.     if(off)
  151.             grp.selectedIndex = 0;
  152.     else
  153.         if(testMultiline(txt,maximizedRegExp[0]))
  154.             grp.selectedIndex = 1;
  155.         else
  156.             grp.selectedIndex = 2;
  157.     grp.disabled = on;
  158.     return on || off;
  159. }
  160. function toggleMaximized(elem) {
  161.     var fil = getFile(getFolder("ProfD"),UserPrefs);
  162.  
  163.     removeFromFile(fil,maximizedRegExp[0]);
  164.     removeFromFile(fil,maximizedRegExp[1]);
  165.  
  166.     if(elem.value) {
  167.         addToUserPrefs(maximizedImport1+elem.value+maximizedImport2);
  168.     } else
  169.         pref.setBoolPref(elem.id,false);
  170.     initFullscreenPlugin();
  171. }
  172.  
  173. // handle Throbber
  174. const throbberImport1 = "user_pref(\"kmeleon.toolband.Throbber.visibility\", ";
  175. const throbberImport2 = ");";
  176. const throbberRegExp1 = "user_pref[\\s]*\\([\\s]*.kmeleon.toolband.Throbber.visibility.[\\s]*,[\\s]*";
  177. const throbberRegExp2 = "[\\s]*\\)[\\s]*;";
  178. var throbberImport = new Array(throbberImport1+"false"+throbberImport2,throbberImport1+"true"+throbberImport2);
  179. var throbberRegExp = new Array(throbberRegExp1+"false"+throbberRegExp2,throbberRegExp1+"true"+throbberRegExp2);
  180. function initThrobber() {
  181.     var txt = getFileContents(getFile(getFolder("ProfD"),UserPrefs));
  182.     var box = document.getElementById("kmeleon.toolband.Throbber.visibility");
  183.  
  184.     if(testMultiline(txt,throbberRegExp[0]))
  185.         box.checked = false;
  186.     else
  187.         if(testMultiline(txt,throbberRegExp[1]))
  188.             box.checked = true;
  189.         else
  190.             initCheckbox("kmeleon.toolband.Throbber.visibility");
  191. }
  192. function toggleThrobber(elem) {
  193.     var fil = getFile(getFolder("ProfD"),UserPrefs);
  194.  
  195.     removeFromFile(fil,throbberRegExp[0]);
  196.     removeFromFile(fil,throbberRegExp[1]);
  197.  
  198.     if(elem.checked) {
  199.         pref.setBoolPref(elem.id,true);
  200.     } else
  201.         addToUserPrefs(throbberImport[0]);
  202.     initThrobber();
  203. }
  204. ]]>
  205. </script>
  206.  
  207. <vbox flex="1" style="overflow:auto">
  208.   <dialogheader title="&appearance.header;"/>
  209.   <separator class="thin"/>
  210.   <tabcontrol flex="1">
  211.     <tabbox flex="1">
  212.       <tabs>
  213.         <tab label="&general;"/>
  214.         <tab label="&appearance.startup;" oncommand="initFullscreenPlugin()"/>
  215.         <tab label="&popups.label;"/>
  216.       </tabs>
  217.       <tabpanels flex="1">
  218.         <tabpanel flex="1" orient="vertical" style="overflow:auto">
  219. <!-- General Appearance -->
  220. <separator class="thin"/>
  221. <checkbox oncommand="toggleCheckbox(this.id)" id="kmeleon.plugins.bmpmenu.load" label="&appearance.menuIcons;"/>
  222. <checkbox oncommand="toggleCheckbox(this.id)" id="kmeleon.display.accelInMenus" label="&appearance.menuAccels;"/>
  223. <separator class="thin"/>
  224. <checkbox oncommand="toggleThrobber(this)" id="kmeleon.toolband.Throbber.visibility" label="&appearance.throbber;"/>
  225. <separator class="thick"/>
  226. <hbox align="center">
  227.   <label value="&appearance.windowTitle;" style="padding-left:1em"/>
  228.   <textbox id="kmeleon.display.title" flex="1" class="uri-element" oninput="setCharPref(this.id,this.value)"/>
  229. </hbox>
  230. <separator class="thick"/>
  231. <vbox>
  232.   <groupbox id="kFullscreenDisplay" flex="1"/>
  233.   <separator class="thick"/>
  234. </vbox>
  235. <description>&restartNote1;</description>
  236. <!-- General Appearance -->
  237.     </tabpanel>
  238.         <tabpanel flex="1" orient="vertical" style="overflow:auto">
  239. <!-- Startup Appearance -->
  240. <separator class="thin"/>
  241. <groupbox>
  242.   <caption label="&window.size;"/>
  243.   <separator class="thin"/>
  244.   <hbox align="center">
  245.     <grid>
  246.       <columns>
  247.         <column/>
  248.         <column/>
  249.         <column/>
  250.       </columns>
  251.       <rows>
  252.         <row align="center">
  253.           <label value="&width;"/>
  254.           <textbox id="kmeleon.display.width" size="4" class="uri-element" oninput="setIntPref(this.id,this.value)"/>
  255.           <label value="&pixels;"/>
  256.         </row>
  257.         <row align="center">
  258.           <label value="&height;"/>
  259.           <textbox id="kmeleon.display.height" size="4" class="uri-element" oninput="setIntPref(this.id,this.value)"/>
  260.           <label value="&pixels;"/>
  261.         </row>
  262.       </rows>
  263.     </grid>
  264.     <hbox>
  265.       <button oncommand="editSave(this,1,2)"/>
  266.       <button label="&clear;" oncommand="clear(1,2);initFullscreenPlugin()"/>
  267.       <hbox flex="1"/>
  268.     </hbox>
  269.   </hbox>
  270.   <separator class="thin"/>
  271.   <hbox>
  272.     <groupbox>
  273.       <caption label="&maximized;"/>
  274.       <radiogroup id="kmeleon.display.maximized" oncommand="toggleMaximized(this)">
  275.         <radio value="true" label="&always;"/>
  276.         <radio value="false" label="&never;"/>
  277.         <radio value="" label="&asClosed;"/>
  278.       </radiogroup>
  279.     </groupbox>
  280.     <groupbox>
  281.       <caption label="&fullscreen;"/>
  282.       <radiogroup id="kmeleon.plugins.fullscreen.auto" oncommand="toggleFullscreen(this)">
  283.         <radio value="true" label="&always;"/>
  284.         <radio value="false" label="&never;"/>
  285.         <radio value="" label="&asClosed;"/>
  286.       </radiogroup>
  287.     </groupbox>
  288.   </hbox>
  289. </groupbox>
  290. <groupbox>
  291.   <caption label="&window.position;"/>
  292.   <separator class="thin"/>
  293.   <hbox align="center">
  294.     <grid>
  295.       <columns>
  296.         <column/>
  297.         <column/>
  298.         <column/>
  299.       </columns>
  300.       <rows>
  301.         <row align="center">
  302.           <label value="&left;"/>
  303.           <textbox id="kmeleon.display.XPos" size="4" class="uri-element" oninput="setIntPref(this.id,this.value)"/>
  304.           <label value="&pixels;"/>
  305.         </row>
  306.         <row align="center">
  307.           <label value="⊤"/>
  308.           <textbox id="kmeleon.display.YPos" size="4" class="uri-element" oninput="setIntPref(this.id,this.value)"/>
  309.           <label value="&pixels;"/>
  310.         </row>
  311.       </rows>
  312.     </grid>
  313.     <hbox>
  314.       <button oncommand="editSave(this,3,4)"/>
  315.       <button label="&clear;" oncommand="clear(3,4);initFullscreenPlugin()"/>
  316.       <hbox flex="1"/>
  317.     </hbox>
  318.   </hbox>
  319.   <separator class="thin"/>
  320.   <hbox>
  321.     <button label="¢er;" oncommand="center()"/>
  322.     <hbox flex="1"/>
  323.   </hbox>
  324. </groupbox>
  325. <separator class="thick"/>
  326. <description>&restartNote1;</description>
  327. <!-- Startup Appearance -->
  328.     </tabpanel>
  329.         <tabpanel flex="1" orient="vertical" style="overflow:auto">
  330. <!-- Popup Appearance -->
  331. <separator class="thin"/>
  332. <groupbox id="popups.appearance"/>
  333. <!-- Popup Appearance -->
  334.     </tabpanel>
  335.       </tabpanels>
  336.     </tabbox>
  337.   </tabcontrol>
  338. </vbox>
  339.  
  340. </page>