2007-03-22 10:30:00 -07:00
|
|
|
<?xml version="1.0"?>
|
2012-05-21 04:12:37 -07:00
|
|
|
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
<bindings id="scaleBindings"
|
|
|
|
xmlns="http://www.mozilla.org/xbl"
|
|
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
|
|
xmlns:xbl="http://www.mozilla.org/xbl">
|
|
|
|
|
2009-05-11 08:20:03 -07:00
|
|
|
<binding id="scalethumb" extends="xul:button">
|
2007-03-22 10:30:00 -07:00
|
|
|
<resources>
|
|
|
|
<stylesheet src="chrome://global/skin/scale.css"/>
|
|
|
|
</resources>
|
2009-05-10 22:30:40 -07:00
|
|
|
|
|
|
|
<implementation implements="nsIAccessibleProvider">
|
|
|
|
<property name="accessibleType" readonly="true">
|
|
|
|
<getter>
|
2009-05-11 08:20:03 -07:00
|
|
|
return Components.interfaces.nsIAccessibleProvider.XULThumb;
|
2009-05-10 22:30:40 -07:00
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
</implementation>
|
2007-03-22 10:30:00 -07:00
|
|
|
</binding>
|
|
|
|
|
2009-05-11 08:20:03 -07:00
|
|
|
<binding id="scaleslider" display="xul:slider"
|
|
|
|
extends="chrome://global/content/bindings/general.xml#basecontrol">
|
|
|
|
<resources>
|
|
|
|
<stylesheet src="chrome://global/skin/scale.css"/>
|
|
|
|
</resources>
|
|
|
|
</binding>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<binding id="scale"
|
|
|
|
extends="chrome://global/content/bindings/general.xml#basecontrol">
|
|
|
|
<resources>
|
|
|
|
<stylesheet src="chrome://global/skin/scale.css"/>
|
|
|
|
</resources>
|
|
|
|
|
|
|
|
<content align="center" pack="center">
|
|
|
|
<xul:slider anonid="slider" class="scale-slider" snap="true" flex="1"
|
2009-03-31 11:11:35 -07:00
|
|
|
xbl:inherits="disabled,orient,dir,curpos=value,minpos=min,maxpos=max,increment,pageincrement,movetoclick">
|
2007-03-22 10:30:00 -07:00
|
|
|
<xul:thumb class="scale-thumb" xbl:inherits="disabled,orient"/>
|
|
|
|
</xul:slider>
|
|
|
|
</content>
|
|
|
|
|
2009-01-14 10:21:58 -08:00
|
|
|
<implementation implements="nsIAccessibleProvider, nsISliderListener">
|
2007-08-03 22:27:27 -07:00
|
|
|
<property name="accessibleType" readonly="true">
|
|
|
|
<getter>
|
|
|
|
return Components.interfaces.nsIAccessibleProvider.XULScale;
|
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<property name="value" onget="return this._getIntegerAttribute('curpos', 0);"
|
|
|
|
onset="return this._setIntegerAttribute('curpos', val);"/>
|
|
|
|
<property name="min" onget="return this._getIntegerAttribute('minpos', 0);"
|
|
|
|
onset="return this._setIntegerAttribute('minpos', val);"/>
|
|
|
|
<property name="max" onget="return this._getIntegerAttribute('maxpos', 100);"
|
|
|
|
onset="return this._setIntegerAttribute('maxpos', val);"/>
|
|
|
|
<property name="increment" onget="return this._getIntegerAttribute('increment', 1);"
|
|
|
|
onset="return this._setIntegerAttribute('increment', val);"/>
|
|
|
|
<property name="pageIncrement" onget="return this._getIntegerAttribute('pageincrement', 10);"
|
|
|
|
onset="return this._setIntegerAttribute('pageincrement', val);"/>
|
|
|
|
|
2009-01-14 10:21:58 -08:00
|
|
|
<field name="_userChanged">false</field>
|
2007-03-22 10:30:00 -07:00
|
|
|
<field name="_sliderElement"/>
|
|
|
|
<property name="_slider" readonly="true">
|
|
|
|
<getter>
|
|
|
|
if (!this._sliderElement)
|
|
|
|
this._sliderElement = document.getAnonymousElementByAttribute(this, "anonid", "slider");
|
|
|
|
return this._sliderElement;
|
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
2007-04-09 15:39:57 -07:00
|
|
|
<constructor>
|
|
|
|
<![CDATA[
|
|
|
|
var value = parseInt(this.getAttribute("value"), 10);
|
|
|
|
if (!isNaN(value))
|
|
|
|
this.value = value;
|
|
|
|
else if (this.min > 0)
|
|
|
|
this.value = this.min;
|
|
|
|
else if (this.max < 0)
|
|
|
|
this.value = this.max;
|
|
|
|
]]>
|
|
|
|
</constructor>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<method name="_getIntegerAttribute">
|
|
|
|
<parameter name="aAttr"/>
|
|
|
|
<parameter name="aDefaultValue"/>
|
|
|
|
<body>
|
|
|
|
var value = this._slider.getAttribute(aAttr);
|
|
|
|
var intvalue = parseInt(value, 10);
|
|
|
|
if (!isNaN(intvalue))
|
|
|
|
return intvalue;
|
|
|
|
return aDefaultValue;
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_setIntegerAttribute">
|
|
|
|
<parameter name="aAttr"/>
|
|
|
|
<parameter name="aValue"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var intvalue = parseInt(aValue, 10);
|
|
|
|
if (!isNaN(intvalue)) {
|
|
|
|
if (aAttr == "curpos") {
|
|
|
|
if (intvalue < this.min)
|
|
|
|
intvalue = this.min;
|
|
|
|
else if (intvalue > this.max)
|
|
|
|
intvalue = this.max;
|
|
|
|
}
|
|
|
|
this._slider.setAttribute(aAttr, intvalue);
|
|
|
|
}
|
|
|
|
return aValue;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="decrease">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var newpos = this.value - this.increment;
|
|
|
|
var startpos = this.min;
|
|
|
|
this.value = (newpos > startpos) ? newpos : startpos;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
<method name="increase">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var newpos = this.value + this.increment;
|
|
|
|
var endpos = this.max;
|
|
|
|
this.value = (newpos < endpos) ? newpos : endpos;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="decreasePage">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var newpos = this.value - this.pageIncrement;
|
|
|
|
var startpos = this.min;
|
|
|
|
this.value = (newpos > startpos) ? newpos : startpos;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
<method name="increasePage">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var newpos = this.value + this.pageIncrement;
|
|
|
|
var endpos = this.max;
|
|
|
|
this.value = (newpos < endpos) ? newpos : endpos;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2009-01-14 10:21:58 -08:00
|
|
|
<method name="valueChanged">
|
|
|
|
<parameter name="which"/>
|
|
|
|
<parameter name="newValue"/>
|
|
|
|
<parameter name="userChanged"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
switch (which) {
|
|
|
|
case "curpos":
|
|
|
|
this.setAttribute("value", newValue);
|
|
|
|
|
|
|
|
// in the future, only fire the change event when userChanged
|
|
|
|
// or _userChanged is true
|
|
|
|
var changeEvent = document.createEvent("Events");
|
|
|
|
changeEvent.initEvent("change", true, true);
|
|
|
|
this.dispatchEvent(changeEvent);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "minpos":
|
|
|
|
this.setAttribute("min", newValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "maxpos":
|
|
|
|
this.setAttribute("max", newValue);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2009-05-20 22:27:01 -07:00
|
|
|
<method name="dragStateChanged">
|
|
|
|
<parameter name="isDragging"/>
|
|
|
|
<body/>
|
|
|
|
</method>
|
2007-03-22 10:30:00 -07:00
|
|
|
</implementation>
|
|
|
|
|
|
|
|
<handlers>
|
|
|
|
<handler event="keypress" keycode="VK_LEFT" preventdefault="true">
|
2009-01-15 10:44:38 -08:00
|
|
|
<![CDATA[
|
|
|
|
this._userChanged = true;
|
|
|
|
(this.orient != "vertical" && this.dir == "reverse") ? this.increase() : this.decrease();
|
|
|
|
this._userChanged = false;
|
|
|
|
]]>
|
2007-03-22 10:30:00 -07:00
|
|
|
</handler>
|
|
|
|
<handler event="keypress" keycode="VK_RIGHT" preventdefault="true">
|
2009-01-15 10:44:38 -08:00
|
|
|
<![CDATA[
|
|
|
|
this._userChanged = true;
|
|
|
|
(this.orient != "vertical" && this.dir == "reverse") ? this.decrease() : this.increase();
|
|
|
|
this._userChanged = false;
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
<handler event="keypress" keycode="VK_UP" preventdefault="true">
|
|
|
|
<![CDATA[
|
|
|
|
this._userChanged = true;
|
|
|
|
(this.orient == "vertical" && this.dir != "reverse") ? this.decrease() : this.increase();
|
|
|
|
this._userChanged = false;
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
<handler event="keypress" keycode="VK_DOWN" preventdefault="true">
|
|
|
|
<![CDATA[
|
|
|
|
this._userChanged = true;
|
|
|
|
(this.orient == "vertical" && this.dir != "reverse") ? this.increase() : this.decrease();
|
|
|
|
this._userChanged = false;
|
|
|
|
]]>
|
2007-03-22 10:30:00 -07:00
|
|
|
</handler>
|
|
|
|
<handler event="keypress" keycode="VK_PAGE_UP" preventdefault="true">
|
2009-01-15 10:44:38 -08:00
|
|
|
<![CDATA[
|
|
|
|
this._userChanged = true;
|
|
|
|
(this.orient == "vertical" && this.dir != "reverse") ? this.decreasePage() : this.increasePage();
|
|
|
|
this._userChanged = false;
|
|
|
|
]]>
|
2007-03-22 10:30:00 -07:00
|
|
|
</handler>
|
|
|
|
<handler event="keypress" keycode="VK_PAGE_DOWN" preventdefault="true">
|
2009-01-15 10:44:38 -08:00
|
|
|
<![CDATA[
|
|
|
|
this._userChanged = true;
|
|
|
|
(this.orient == "vertical" && this.dir != "reverse") ? this.increasePage() : this.decreasePage();
|
|
|
|
this._userChanged = false;
|
|
|
|
]]>
|
2007-03-22 10:30:00 -07:00
|
|
|
</handler>
|
|
|
|
<handler event="keypress" keycode="VK_HOME" preventdefault="true">
|
2009-01-14 10:21:58 -08:00
|
|
|
this._userChanged = true;
|
2007-04-09 15:39:57 -07:00
|
|
|
this.value = (this.dir == "reverse") ? this.max : this.min;
|
2009-01-14 10:21:58 -08:00
|
|
|
this._userChanged = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
</handler>
|
|
|
|
<handler event="keypress" keycode="VK_END" preventdefault="true">
|
2009-01-14 10:21:58 -08:00
|
|
|
this._userChanged = true;
|
2007-04-09 15:39:57 -07:00
|
|
|
this.value = (this.dir == "reverse") ? this.min : this.max;
|
2009-01-14 10:21:58 -08:00
|
|
|
this._userChanged = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
</handler>
|
|
|
|
</handlers>
|
|
|
|
|
|
|
|
</binding>
|
|
|
|
</bindings>
|