aboutsummaryrefslogtreecommitdiff
path: root/files/zh-tw/mozilla/preferences
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-tw/mozilla/preferences')
-rw-r--r--files/zh-tw/mozilla/preferences/index.html48
-rw-r--r--files/zh-tw/mozilla/preferences/preferences_system/index.html40
-rw-r--r--files/zh-tw/mozilla/preferences/preferences_system/new_attributes/index.html55
3 files changed, 143 insertions, 0 deletions
diff --git a/files/zh-tw/mozilla/preferences/index.html b/files/zh-tw/mozilla/preferences/index.html
new file mode 100644
index 0000000000..1169ecabf1
--- /dev/null
+++ b/files/zh-tw/mozilla/preferences/index.html
@@ -0,0 +1,48 @@
+---
+title: Preferences
+slug: Mozilla/Preferences
+tags:
+ - NeedsTranslation
+ - TopicStub
+translation_of: Mozilla/Preferences
+---
+<p>The preference system makes it possible to store data for Mozilla applications using a key/value pairing system. These articles provide information about how to use the preference system.</p>
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h2 class="Documentation" id="Documentation" name="Documentation">Documentation</h2>
+ <dl>
+ <dt><a href="/en-US/docs/Preferences/Preferences_system" title="Preferences/Preferences system">Preferences system</a></dt>
+ <dd>An introduction to using the preference system in Mozilla.</dd>
+ <dt><a href="/en-US/docs/XUL_School/Handling_Preferences" title="XUL School/Handling Preferences">XUL School: Handling preferences</a></dt>
+ <dd>The XUL School tutorial chapter on preferences.</dd>
+ <dt><a href="/en-US/docs/Preferences/Preference_reference" title="Preferences/Preference_reference">Mozilla preference reference</a></dt>
+ <dd>A reference guide to all Mozilla preferences; currently a work in progress.</dd>
+ <dt><a href="/en-US/docs/Preferences/A_brief_guide_to_Mozilla_preferences" title="Preferences/A brief guide to Mozilla preferences">A brief guide to Mozilla preferences</a></dt>
+ <dd>An introductory guide to where preferences are stored and other useful information about the core preference system.</dd>
+ <dt><a href="/en-US/docs/Preferences/Using_preferences_from_application_code" title="Preferences/Using preferences from application code">Using preferences from application code</a> {{gecko_minversion_inline("6.0")}}</dt>
+ <dd>Firefox 6 introduced static functions for accessing preferences efficiently from within application code. This API is not available for add-ons, but if you're working on a Gecko application, this API is the preferred way to access preferences.</dd>
+ <dt><a href="/en-US/docs/Preferences/Mozilla_networking_preferences" title="Preferences/Mozilla networking preferences">Mozilla networking preferences</a></dt>
+ <dd>A guide to key networking-related preferences.</dd>
+ <dt><a href="/en-US/docs/Preferences/Mozilla_preferences_for_uber-geeks" title="Preferences/Mozilla preferences for uber-geeks">Mozilla preferences for uber-geeks</a></dt>
+ <dd>A guide to preferences that only truly elite geeks should play with.</dd>
+ </dl>
+ <p><span class="alllinks"><a href="/en-US/docs/tag/Preferences" title="tag/Preferences">View all pages tagged with "Preferences"...</a></span></p>
+ </td>
+ <td>
+ <h2 class="Community" id="Examples" name="Examples">Examples</h2>
+ <dl>
+ <dt><a href="/en-US/docs/Code_snippets/Preferences" title="Code snippets/Preferences">Code snippets</a></dt>
+ <dd>Preference-related code snippets.</dd>
+ <dt><a href="/en-US/docs/Adding_preferences_to_an_extension" title="Adding preferences to an extension">Adding preferences to an extension</a></dt>
+ <dd>How to add preferences to an existing extension.</dd>
+ </dl>
+ <h2 class="Related_Topics" id="Related_Topics" name="Related_Topics">Related Topics</h2>
+ <ul>
+ <li><a href="/en-US/docs/XUL" title="XUL">XUL</a>, <a href="/en-US/docs/JavaScript" title="JavaScript">JavaScript</a>, <a href="/en-US/docs/XPCOM" title="XPCOM">XPCOM</a>, <a href="/en-US/docs/Extensions" title="Extensions">Extensions</a>, <a href="/en-US/docs/Developer_Guide" title="Developing_Mozilla">Developing Mozilla</a></li>
+ </ul>
+ </td>
+ </tr>
+ </tbody>
+</table>
diff --git a/files/zh-tw/mozilla/preferences/preferences_system/index.html b/files/zh-tw/mozilla/preferences/preferences_system/index.html
new file mode 100644
index 0000000000..965cd97480
--- /dev/null
+++ b/files/zh-tw/mozilla/preferences/preferences_system/index.html
@@ -0,0 +1,40 @@
+---
+title: Preferences system
+slug: Mozilla/Preferences/Preferences_system
+tags:
+ - NeedsTranslation
+ - Preferences system
+ - TopicStub
+ - XUL
+translation_of: Mozilla/Preferences/Preferences_system
+---
+<p>This document describes Toolkit's preferences system. Using this system it is possible to create preferences windows that display and operate appropriately on various platforms (Windows, MacOS X and GNOME).</p>
+
+<p>The system is implemented through a few <a href="/en/XUL" title="en/XUL">XUL</a> elements and attributes. Reference information about them is available below:</p>
+<div class="moreinfo"> <p><strong><a href="/en-US/docs/Preferences_System">Preferences System</a> documentation:</strong></p> <ul> <li>Introduction: <a href="/en-US/docs/Preferences_System/Getting_Started">Getting Started</a> | <a href="/en-US/docs/Preferences_System/Examples">Examples</a> | <a href="/en-US/docs/Preferences_System/Troubleshooting">Troubleshooting</a></li> <li>Reference: <code><a href="/zh-TW/docs/Mozilla/Tech/XUL/prefwindow" title="prefwindow">prefwindow</a></code> | <code><a href="/zh-TW/docs/Mozilla/Tech/XUL/prefpane" title="prefpane">prefpane</a></code> | <code><a href="/zh-TW/docs/Mozilla/Tech/XUL/preferences" title="preferences">preferences</a></code> | <code><a href="/zh-TW/docs/Mozilla/Tech/XUL/preference" title="preference">preference</a></code> | <a href="/en-US/docs/Preferences_System/New_attributes">XUL attributes</a></li> </ul></div>
+<h3 id="Use">Use</h3>
+<p>Code for a typical preferences window may look like this:</p>
+<pre>&lt;prefwindow id="appPreferences"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;
+ &lt;prefpane id="pane1" label="&amp;pane1.title;"&gt;
+ &lt;preferences&gt;
+ &lt;preference id="pref1" name="pref.name" type="bool"/&gt;
+ &lt;/preferences&gt;
+
+ .. UI elements that refer to the preferences above, e.g.:
+ &lt;checkbox id="check1" preference="pref1"
+ label="&amp;check1.label;" accesskey="&amp;check1.accesskey;"/&gt;
+ &lt;/prefpane&gt;
+
+ &lt;prefpane id="pane2" label="&amp;pane2.title;" src="chrome://uri/to/pane.xul"/&gt;
+&lt;/prefwindow&gt;
+</pre>
+<p>Pane content can be specified inline or an external chrome URI supplied for pane content to be loaded in via a dynamic overlay. You should be careful to read the <a class="external" href="http://en.wikipedia.org/wiki/Human_interface_guidelines" title="http://en.wikipedia.org/wiki/Human_interface_guidelines">HIGs</a> for the platforms you are targeting and use the XUL preprocessor if necessary to set different window titles as appropriate. You should also be careful to specify the width of the window (in em) as appropriate using the preprocessor for each targeted platform, as well as the height (in em) for platforms where the window size does not change as the selected panel is changed (e.g. Windows).</p>
+<h3 id="Usage_in_XULRunner_applications" name="Usage_in_XULRunner_applications">Usage in XULRunner applications</h3>
+<p>When calling openDialog() to open a preferences dialog, "toolbar" should be included in the features string.  Not using "toolbar" will cause the preferences dialog to only display one preference pane.</p>
+<p>Example:</p>
+<pre class="eval">var features = "chrome,titlebar,toolbar,centerscreen,modal";
+window.openDialog(url, "Preferences", features);
+</pre>
+<h3 id="Bugzilla">Bugzilla</h3>
+<p>The component for bugs in the Preferences bindings (but not in Firefox/Thunderbird Options UI) is Toolkit:Preferences (<a class="link-https" href="https://bugzilla.mozilla.org/enter_bug.cgi?product=Toolkit">file a bug</a> <a class="link-https" href="https://bugzilla.mozilla.org/buglist.cgi?query_format=advanced&amp;product=Toolkit&amp;component=Preferences&amp;resolution=---&amp;chfieldto=Now">list open bugs</a>)</p>
diff --git a/files/zh-tw/mozilla/preferences/preferences_system/new_attributes/index.html b/files/zh-tw/mozilla/preferences/preferences_system/new_attributes/index.html
new file mode 100644
index 0000000000..f583b29b26
--- /dev/null
+++ b/files/zh-tw/mozilla/preferences/preferences_system/new_attributes/index.html
@@ -0,0 +1,55 @@
+---
+title: Preference XUL Attributes
+slug: Mozilla/Preferences/Preferences_system/New_attributes
+translation_of: Mozilla/Preferences/Preferences_system/New_attributes
+---
+<p> </p>
+<p><code><a href="/en-US/docs/XUL/prefwindow">&lt;prefwindow&gt;</a></code> 裡的 Widgets 可能有下述屬性 (除此以外,尚有標準屬性).</p>
+<h3 id="preference" name="preference">preference</h3>
+<p>Specifies id of the linked <code><a href="/en-US/docs/XUL/preference">&lt;preference&gt;</a></code> element. preference 和 widget 兩者的 <code>value</code> 將保持同步.</p>
+<p>如下例,當 pane 被載入時, textbox 從名稱 extensions.example.mypref 的 preference 來自動初始化它的 <code>value</code> ;反過來說,當使用者改變 textbox 的 value 時,<code>&lt;preference&gt;</code>元素的 value 會同步更新,並將在適當的時候儲存至 preferences system.</p>
+<pre class="eval">&lt;preference id="my_pref" name="extensions.example.mypref" type="unichar"/&gt;
+&lt;textbox preference="my_pref"/&gt;
+</pre>
+<h3 id="preference-editable" name="preference-editable">preference-editable</h3>
+<p>By default, the <code><a href="/en-US/docs/XUL/preference">&lt;preference&gt;</a></code> element will automatically modify the value of a few standard widgets: checkbox, colorpicker, radiogroup, textbox, listitem, listbox, and menulist.</p>
+<p>If you wish it to update the value of an element with different local name, for example your own XBL widget, you need to set the <code>preference-editable="true"</code> attribute on it.</p>
+<p>For your widget to modify the <code>&lt;preference&gt;</code>'s value, you need to make sure a <code>change</code>, <code>command</code>, or <code>input</code> event is fired after the widget's value changes.</p>
+<p><span class="comment">bug # or any testcases ? Note: this does not currently work on the tree widget. It may not work on anything so far (the API says it is to be available in version 1.8).</span></p>
+<h3 id="onsyncfrompreference.2Fonsynctopreference" name="onsyncfrompreference.2Fonsynctopreference">onsyncfrompreference/onsynctopreference</h3>
+<p>Often you will have UI whose construction does not map easily to a given preference type. 例如,你可能有一個 checkbox,當一個整數值是 3 時它被打勾,是 2 時不被打勾。為了初始化這個 UI 元素,你不能依賴預設的 initialization routine,因為這兩個數值對 checkbox 元素來說是無意義的. 你需要寫轉換函數來轉換 preference value 成 UI 元素可用的初始值,並且也轉換 UI 元素的 value 成某些格式來儲存至 preferences file. 這就是 onsyncfrompreference/onsynctopreference 的作用.</p>
+<p><code>onsyncfrompreference</code> 被呼叫,當一個元素從 preferences 被初始化。 明確地說, 當一個 preference 元素的 value 被載入, 所有使用那個 preference 的元素將使他們的 <span style="font-family: 'Courier New', 'Andale Mono', monospace; line-height: normal;">onsyncfrompreference </span><span style="line-height: 1.5;">handler 被呼叫.</span></p>
+<div class="warning">
+ Be careful when writing <span style="font-family: 'Courier New', 'Andale Mono', monospace; line-height: normal;">onsyncfrompreference </span><span style="line-height: 1.5;">handlers.  </span><span style="font-family: 'Courier New', 'Andale Mono', monospace; line-height: normal;">&lt;preference&gt; </span><span style="line-height: 1.5;">elements defined after the preference<em> <strong>element</strong></em>  being dealt with will not yet have their </span><span style="font-family: 'Courier New', 'Andale Mono', monospace; line-height: normal;">value</span><span style="line-height: 1.5;"> set, so referring to them from the handler will lead to a null result. Reorder the </span><span style="font-family: 'Courier New', 'Andale Mono', monospace; line-height: normal;">&lt;preference&gt; </span><span style="line-height: 1.5;">elements or directly fetch the preference value via </span><span style="font-family: 'Courier New', 'Andale Mono', monospace; line-height: normal;">Services.prefs</span></div>
+<p><span style="line-height: 1.5;">If you supply an implementation of this event, your implementation will be invoked during initialization and you can return the value with which to initialize the UI element with, or </span><code style="font-size: 14px;">undefined</code><span style="line-height: 1.5;"> to tell the preferences system to initialize the UI element with the default value (i.e. to attempt to initialize with the preference value). In the above example, you might write the checkbox like this:</span></p>
+<pre>&lt;checkbox preference="foo.bar" onsyncfrompreference="return onsyncfrompreference();"/&gt;
+
+.. script:
+function onsyncfrompreference()
+{
+ var preference = document.getElementById("foo.bar");
+ // .value === undefined means the preference is set to the default value
+ var actualValue = preference.value !== undefined ?
+ preference.value : preference.defaultValue;
+ // actualValue may be |null| here if the pref didn't have the default value.
+ return preference.value == 3;
+
+ // If foo.bar was boolean and we wanted to use its value to initialize
+ // the checkbox, we could still implement this method if we wanted to
+ // perform any other initialization actions at this time.
+}
+</pre>
+<p><code>onsynctopreference</code> is called when preferences are being written - the preferences system asks each element to translate its current state into a value suitable for writing to the specified preference. You can return a special value or <code>undefined</code> to tell the preferences system to use its standard means for obtaining the value. In the above example:</p>
+<pre>&lt;checkbox preference="foo.bar" onsynctopreference="return onsynctopreference();"/&gt;
+.. script:
+function onsynctopreference()
+{
+ var checkbox = document.getElementById("checkbox");
+ return checkbox.checked ? 3 : 2;
+}
+
+// If foo.bar was boolean and we wanted to use its value to write to
+// preferences, we could still implement this method if we wanted to
+// perform any other initialization actions at this time.
+</pre>
+<div class="moreinfo"> <p><strong><a href="/en-US/docs/Preferences_System">Preferences System</a> documentation:</strong></p> <ul> <li>Introduction: <a href="/en-US/docs/Preferences_System/Getting_Started">Getting Started</a> | <a href="/en-US/docs/Preferences_System/Examples">Examples</a> | <a href="/en-US/docs/Preferences_System/Troubleshooting">Troubleshooting</a></li> <li>Reference: <code><a href="/zh-TW/docs/Mozilla/Tech/XUL/prefwindow" title="prefwindow">prefwindow</a></code> | <code><a href="/zh-TW/docs/Mozilla/Tech/XUL/prefpane" title="prefpane">prefpane</a></code> | <code><a href="/zh-TW/docs/Mozilla/Tech/XUL/preferences" title="preferences">preferences</a></code> | <code><a href="/zh-TW/docs/Mozilla/Tech/XUL/preference" title="preference">preference</a></code> | <a href="/en-US/docs/Preferences_System/New_attributes">XUL attributes</a></li> </ul></div>