gecko/mobile/chrome/content/bindings/setting.xml
Mark Finkle c983fd1e56 Bug 516122: Support more <textbox> styles and a <menulist> widget in settings, r=gavin
--HG--
rename : mobile/chrome/content/checkbox.xml => mobile/chrome/content/bindings/checkbox.xml
rename : mobile/chrome/content/preferences/setting.xml => mobile/chrome/content/bindings/setting.xml
2009-09-17 16:17:57 -04:00

211 lines
8.0 KiB
XML

<?xml version="1.0"?>
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is Mozilla Mobile Browser.
-
- The Initial Developer of the Original Code is
- Mozilla Corporation.
- Portions created by the Initial Developer are Copyright (C) 2008
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Daniel Brooks <db48x@yahoo.com>
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<!DOCTYPE bindings PUBLIC "-//MOZILLA//DTD XBL V1.0//EN" "http://www.mozilla.org/xbl">
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="settings">
<content orient="vertical">
<xul:label class="settings-title" xbl:inherits="value=label" crop="end" flex="1"/>
<children />
</content>
</binding>
<binding id="setting-base">
<implementation>
<constructor>
let prefValue = this.pref.valueFromPreferences;
if (prefValue != null) {
this.pref._setValue(prefValue, false);
this.prefChanged();
}
</constructor>
<method name="fireEvent">
<parameter name="eventName"/>
<parameter name="funcStr"/>
<body>
<![CDATA[
let body = funcStr || this.getAttribute(eventName);
if (!body)
return;
try
{
let event = document.createEvent("Events");
event.initEvent(eventName, true, true);
let f = new Function("event", body);
f.call(this, event);
}
catch (e)
{
Components.utils.reportError(e);
}
]]>
</body>
</method>
<method name="inputChanged">
<body>
this.pref.value = this.value;
this.fireEvent("onsynctopreference");
</body>
</method>
<method name="prefChanged">
<body>
this.value = this.pref.value;
this.fireEvent("onsyncfrompreference");
</body>
</method>
<property name="value" onget="return this.input.value;" onset="return this.input.value = val;"/>
<field name="type">this.getAttribute("type");</field>
<field name="pref">document.getAnonymousElementByAttribute(this, "anonid", "pref");</field>
<field name="input">document.getAnonymousElementByAttribute(this, "anonid", "input");</field>
</implementation>
</binding>
<binding id="setting-bool" extends="chrome://browser/content/bindings/setting.xml#setting-base">
<content>
<xul:box flex="1" class="prefbox">
<xul:vbox flex="1">
<xul:label class="preftitle" xbl:inherits="value=title" crop="end" flex="1"/>
<xul:label class="prefdesc" xbl:inherits="value=desc" crop="end" flex="1">
<children/>
</xul:label>
</xul:vbox>
<xul:hbox anonid="input-container">
<xul:checkbox anonid="input" xbl:inherits="disabled" oncommand="inputChanged();"/>
</xul:hbox>
</xul:box>
<xul:preferences>
<xul:preference anonid="pref" xbl:inherits="name=pref,type,inverted" instantApply="true" onchange="prefChanged();"/>
</xul:preferences>
</content>
<implementation>
<property name="value" onget="return this.input.checked;" onset="return this.input.setChecked(val);"/>
</implementation>
</binding>
<binding id="setting-boolint" extends="chrome://browser/content/bindings/setting.xml#setting-base">
<content>
<xul:box flex="1" class="prefbox">
<xul:vbox flex="1">
<xul:label class="preftitle" xbl:inherits="value=title" crop="end" flex="1"/>
<xul:label class="prefdesc" xbl:inherits="value=desc" crop="end" flex="1">
<children/>
</xul:label>
</xul:vbox>
<xul:hbox anonid="input-container">
<xul:checkbox anonid="input" xbl:inherits="disabled" oncommand="inputChanged();"/>
</xul:hbox>
</xul:box>
<xul:preferences>
<xul:preference anonid="pref" xbl:inherits="name=pref,inverted" type="int" instantApply="true" onchange="prefChanged();"/>
</xul:preferences>
</content>
<implementation>
<method name="inputChanged">
<body>
this.pref.value = this.getAttribute(this.value ? "on" : "off");
this.fireEvent("onsynctopreference");
</body>
</method>
<method name="prefChanged">
<body>
this.value = this.pref.value == this.getAttribute("on");
this.fireEvent("onsyncfrompreference");
</body>
</method>
<property name="value" onget="return this.input.checked;" onset="return this.input.setChecked(val);"/>
</implementation>
</binding>
<binding id="setting-control" extends="chrome://browser/content/bindings/setting.xml#setting-base">
<content>
<xul:box flex="1" class="prefbox">
<xul:vbox flex="1">
<xul:label class="preftitle" xbl:inherits="value=title" crop="end" flex="1"/>
<xul:label class="prefdesc" xbl:inherits="value=desc" crop="end" flex="1">
<children/>
</xul:label>
</xul:vbox>
<xul:hbox anonid="input-container">
<children includes="button|menulist"/>
</xul:hbox>
</xul:box>
<xul:preferences>
<xul:preference anonid="pref" xbl:inherits="name=pref,inverted" type="bool"
instantApply="true" onchange="prefChanged();"/>
</xul:preferences>
</content>
</binding>
<binding id="setting-string" extends="chrome://browser/content/bindings/setting.xml#setting-base">
<content>
<xul:box flex="1" class="prefbox">
<xul:vbox flex="1">
<xul:label class="preftitle" xbl:inherits="value=title" crop="end" flex="1"/>
<xul:label class="prefdesc" xbl:inherits="value=desc" crop="end" flex="1">
<children/>
</xul:label>
</xul:vbox>
<xul:hbox anonid="input-container">
<xul:textbox xbl:inherits="disabled,emptytext,type=inputtype,min,max,increment,hidespinbuttons,wraparound,decimalplaces" anonid="input" oninput="inputChanged();"/>
</xul:hbox>
</xul:box>
<xul:preferences>
<xul:preference anonid="pref" xbl:inherits="name=pref,type,inverted"
instantApply="true" onchange="prefChanged();"/>
</xul:preferences>
</content>
<implementation>
<property name="value" onget="return this.input.value;" onset="return this.input.value=val;"/>
</implementation>
</binding>
</bindings>