2006-05-30 13:50:48 +00:00
|
|
|
<?xml version="1.0"?>
|
2012-05-21 11:12:37 +00: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/. -->
|
|
|
|
|
2006-05-30 13:50:48 +00: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">
|
|
|
|
|
2013-07-19 04:13:35 +00:00
|
|
|
<binding id="scalethumb" extends="xul:button" role="xul:thumb">
|
2006-05-30 13:50:48 +00:00
|
|
|
<resources>
|
|
|
|
<stylesheet src="chrome://global/skin/scale.css"/>
|
|
|
|
</resources>
|
|
|
|
</binding>
|
|
|
|
|
2009-05-11 15:20:03 +00: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>
|
|
|
|
|
2013-07-19 04:13:35 +00:00
|
|
|
<binding id="scale" role="xul:scale"
|
2006-05-30 13:50:48 +00:00
|
|
|
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 18:11:35 +00:00
|
|
|
xbl:inherits="disabled,orient,dir,curpos=value,minpos=min,maxpos=max,increment,pageincrement,movetoclick">
|
2006-05-30 13:50:48 +00:00
|
|
|
<xul:thumb class="scale-thumb" xbl:inherits="disabled,orient"/>
|
|
|
|
</xul:slider>
|
|
|
|
</content>
|
|
|
|
|
2013-07-19 04:13:35 +00:00
|
|
|
<implementation implements="nsISliderListener">
|
2006-05-30 13:50:48 +00: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);"/>
|
|
|
|
|
|
|
|
<property name="_slider" readonly="true">
|
|
|
|
<getter>
|
|
|
|
if (!this._sliderElement)
|
|
|
|
this._sliderElement = document.getAnonymousElementByAttribute(this, "anonid", "slider");
|
|
|
|
return this._sliderElement;
|
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
2007-04-09 22:39:57 +00:00
|
|
|
<constructor>
|
|
|
|
<![CDATA[
|
2013-03-21 16:34:36 +00:00
|
|
|
this._userChanged = false;
|
2007-04-09 22:39:57 +00:00
|
|
|
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>
|
|
|
|
|
2006-05-30 13:50:48 +00: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>
|
2007-01-09 16:38:54 +00:00
|
|
|
<![CDATA[
|
2006-05-30 13:50:48 +00:00
|
|
|
var intvalue = parseInt(aValue, 10);
|
2007-01-09 16:38:54 +00:00
|
|
|
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);
|
|
|
|
}
|
2006-05-30 13:50:48 +00:00
|
|
|
return aValue;
|
2007-01-09 16:38:54 +00:00
|
|
|
]]>
|
2006-05-30 13:50:48 +00:00
|
|
|
</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 18:21:58 +00: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-21 05:27:01 +00:00
|
|
|
<method name="dragStateChanged">
|
|
|
|
<parameter name="isDragging"/>
|
|
|
|
<body/>
|
|
|
|
</method>
|
2006-05-30 13:50:48 +00:00
|
|
|
</implementation>
|
|
|
|
|
|
|
|
<handlers>
|
|
|
|
<handler event="keypress" keycode="VK_LEFT" preventdefault="true">
|
2009-01-15 18:44:38 +00:00
|
|
|
<![CDATA[
|
|
|
|
this._userChanged = true;
|
|
|
|
(this.orient != "vertical" && this.dir == "reverse") ? this.increase() : this.decrease();
|
|
|
|
this._userChanged = false;
|
|
|
|
]]>
|
2006-05-30 13:50:48 +00:00
|
|
|
</handler>
|
|
|
|
<handler event="keypress" keycode="VK_RIGHT" preventdefault="true">
|
2009-01-15 18:44:38 +00: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;
|
|
|
|
]]>
|
2006-05-30 13:50:48 +00:00
|
|
|
</handler>
|
|
|
|
<handler event="keypress" keycode="VK_PAGE_UP" preventdefault="true">
|
2009-01-15 18:44:38 +00:00
|
|
|
<![CDATA[
|
|
|
|
this._userChanged = true;
|
|
|
|
(this.orient == "vertical" && this.dir != "reverse") ? this.decreasePage() : this.increasePage();
|
|
|
|
this._userChanged = false;
|
|
|
|
]]>
|
2006-05-30 13:50:48 +00:00
|
|
|
</handler>
|
|
|
|
<handler event="keypress" keycode="VK_PAGE_DOWN" preventdefault="true">
|
2009-01-15 18:44:38 +00:00
|
|
|
<![CDATA[
|
|
|
|
this._userChanged = true;
|
|
|
|
(this.orient == "vertical" && this.dir != "reverse") ? this.increasePage() : this.decreasePage();
|
|
|
|
this._userChanged = false;
|
|
|
|
]]>
|
2006-05-30 13:50:48 +00:00
|
|
|
</handler>
|
|
|
|
<handler event="keypress" keycode="VK_HOME" preventdefault="true">
|
2009-01-14 18:21:58 +00:00
|
|
|
this._userChanged = true;
|
2007-04-09 22:39:57 +00:00
|
|
|
this.value = (this.dir == "reverse") ? this.max : this.min;
|
2009-01-14 18:21:58 +00:00
|
|
|
this._userChanged = false;
|
2006-05-30 13:50:48 +00:00
|
|
|
</handler>
|
|
|
|
<handler event="keypress" keycode="VK_END" preventdefault="true">
|
2009-01-14 18:21:58 +00:00
|
|
|
this._userChanged = true;
|
2007-04-09 22:39:57 +00:00
|
|
|
this.value = (this.dir == "reverse") ? this.min : this.max;
|
2009-01-14 18:21:58 +00:00
|
|
|
this._userChanged = false;
|
2006-05-30 13:50:48 +00:00
|
|
|
</handler>
|
|
|
|
</handlers>
|
|
|
|
|
|
|
|
</binding>
|
|
|
|
</bindings>
|