Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <!-- This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | - License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | <bindings id="scaleBindings" |
michael@0 | 8 | xmlns="http://www.mozilla.org/xbl" |
michael@0 | 9 | xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
michael@0 | 10 | xmlns:xbl="http://www.mozilla.org/xbl"> |
michael@0 | 11 | |
michael@0 | 12 | <binding id="scalethumb" extends="xul:button" role="xul:thumb"> |
michael@0 | 13 | <resources> |
michael@0 | 14 | <stylesheet src="chrome://global/skin/scale.css"/> |
michael@0 | 15 | </resources> |
michael@0 | 16 | </binding> |
michael@0 | 17 | |
michael@0 | 18 | <binding id="scaleslider" display="xul:slider" |
michael@0 | 19 | extends="chrome://global/content/bindings/general.xml#basecontrol"> |
michael@0 | 20 | <resources> |
michael@0 | 21 | <stylesheet src="chrome://global/skin/scale.css"/> |
michael@0 | 22 | </resources> |
michael@0 | 23 | </binding> |
michael@0 | 24 | |
michael@0 | 25 | <binding id="scale" role="xul:scale" |
michael@0 | 26 | extends="chrome://global/content/bindings/general.xml#basecontrol"> |
michael@0 | 27 | <resources> |
michael@0 | 28 | <stylesheet src="chrome://global/skin/scale.css"/> |
michael@0 | 29 | </resources> |
michael@0 | 30 | |
michael@0 | 31 | <content align="center" pack="center"> |
michael@0 | 32 | <xul:slider anonid="slider" class="scale-slider" snap="true" flex="1" |
michael@0 | 33 | xbl:inherits="disabled,orient,dir,curpos=value,minpos=min,maxpos=max,increment,pageincrement,movetoclick"> |
michael@0 | 34 | <xul:thumb class="scale-thumb" xbl:inherits="disabled,orient"/> |
michael@0 | 35 | </xul:slider> |
michael@0 | 36 | </content> |
michael@0 | 37 | |
michael@0 | 38 | <implementation implements="nsISliderListener"> |
michael@0 | 39 | <property name="value" onget="return this._getIntegerAttribute('curpos', 0);" |
michael@0 | 40 | onset="return this._setIntegerAttribute('curpos', val);"/> |
michael@0 | 41 | <property name="min" onget="return this._getIntegerAttribute('minpos', 0);" |
michael@0 | 42 | onset="return this._setIntegerAttribute('minpos', val);"/> |
michael@0 | 43 | <property name="max" onget="return this._getIntegerAttribute('maxpos', 100);" |
michael@0 | 44 | onset="return this._setIntegerAttribute('maxpos', val);"/> |
michael@0 | 45 | <property name="increment" onget="return this._getIntegerAttribute('increment', 1);" |
michael@0 | 46 | onset="return this._setIntegerAttribute('increment', val);"/> |
michael@0 | 47 | <property name="pageIncrement" onget="return this._getIntegerAttribute('pageincrement', 10);" |
michael@0 | 48 | onset="return this._setIntegerAttribute('pageincrement', val);"/> |
michael@0 | 49 | |
michael@0 | 50 | <property name="_slider" readonly="true"> |
michael@0 | 51 | <getter> |
michael@0 | 52 | if (!this._sliderElement) |
michael@0 | 53 | this._sliderElement = document.getAnonymousElementByAttribute(this, "anonid", "slider"); |
michael@0 | 54 | return this._sliderElement; |
michael@0 | 55 | </getter> |
michael@0 | 56 | </property> |
michael@0 | 57 | |
michael@0 | 58 | <constructor> |
michael@0 | 59 | <![CDATA[ |
michael@0 | 60 | this._userChanged = false; |
michael@0 | 61 | var value = parseInt(this.getAttribute("value"), 10); |
michael@0 | 62 | if (!isNaN(value)) |
michael@0 | 63 | this.value = value; |
michael@0 | 64 | else if (this.min > 0) |
michael@0 | 65 | this.value = this.min; |
michael@0 | 66 | else if (this.max < 0) |
michael@0 | 67 | this.value = this.max; |
michael@0 | 68 | ]]> |
michael@0 | 69 | </constructor> |
michael@0 | 70 | |
michael@0 | 71 | <method name="_getIntegerAttribute"> |
michael@0 | 72 | <parameter name="aAttr"/> |
michael@0 | 73 | <parameter name="aDefaultValue"/> |
michael@0 | 74 | <body> |
michael@0 | 75 | var value = this._slider.getAttribute(aAttr); |
michael@0 | 76 | var intvalue = parseInt(value, 10); |
michael@0 | 77 | if (!isNaN(intvalue)) |
michael@0 | 78 | return intvalue; |
michael@0 | 79 | return aDefaultValue; |
michael@0 | 80 | </body> |
michael@0 | 81 | </method> |
michael@0 | 82 | |
michael@0 | 83 | <method name="_setIntegerAttribute"> |
michael@0 | 84 | <parameter name="aAttr"/> |
michael@0 | 85 | <parameter name="aValue"/> |
michael@0 | 86 | <body> |
michael@0 | 87 | <![CDATA[ |
michael@0 | 88 | var intvalue = parseInt(aValue, 10); |
michael@0 | 89 | if (!isNaN(intvalue)) { |
michael@0 | 90 | if (aAttr == "curpos") { |
michael@0 | 91 | if (intvalue < this.min) |
michael@0 | 92 | intvalue = this.min; |
michael@0 | 93 | else if (intvalue > this.max) |
michael@0 | 94 | intvalue = this.max; |
michael@0 | 95 | } |
michael@0 | 96 | this._slider.setAttribute(aAttr, intvalue); |
michael@0 | 97 | } |
michael@0 | 98 | return aValue; |
michael@0 | 99 | ]]> |
michael@0 | 100 | </body> |
michael@0 | 101 | </method> |
michael@0 | 102 | |
michael@0 | 103 | <method name="decrease"> |
michael@0 | 104 | <body> |
michael@0 | 105 | <![CDATA[ |
michael@0 | 106 | var newpos = this.value - this.increment; |
michael@0 | 107 | var startpos = this.min; |
michael@0 | 108 | this.value = (newpos > startpos) ? newpos : startpos; |
michael@0 | 109 | ]]> |
michael@0 | 110 | </body> |
michael@0 | 111 | </method> |
michael@0 | 112 | <method name="increase"> |
michael@0 | 113 | <body> |
michael@0 | 114 | <![CDATA[ |
michael@0 | 115 | var newpos = this.value + this.increment; |
michael@0 | 116 | var endpos = this.max; |
michael@0 | 117 | this.value = (newpos < endpos) ? newpos : endpos; |
michael@0 | 118 | ]]> |
michael@0 | 119 | </body> |
michael@0 | 120 | </method> |
michael@0 | 121 | |
michael@0 | 122 | <method name="decreasePage"> |
michael@0 | 123 | <body> |
michael@0 | 124 | <![CDATA[ |
michael@0 | 125 | var newpos = this.value - this.pageIncrement; |
michael@0 | 126 | var startpos = this.min; |
michael@0 | 127 | this.value = (newpos > startpos) ? newpos : startpos; |
michael@0 | 128 | ]]> |
michael@0 | 129 | </body> |
michael@0 | 130 | </method> |
michael@0 | 131 | <method name="increasePage"> |
michael@0 | 132 | <body> |
michael@0 | 133 | <![CDATA[ |
michael@0 | 134 | var newpos = this.value + this.pageIncrement; |
michael@0 | 135 | var endpos = this.max; |
michael@0 | 136 | this.value = (newpos < endpos) ? newpos : endpos; |
michael@0 | 137 | ]]> |
michael@0 | 138 | </body> |
michael@0 | 139 | </method> |
michael@0 | 140 | |
michael@0 | 141 | <method name="valueChanged"> |
michael@0 | 142 | <parameter name="which"/> |
michael@0 | 143 | <parameter name="newValue"/> |
michael@0 | 144 | <parameter name="userChanged"/> |
michael@0 | 145 | <body> |
michael@0 | 146 | <![CDATA[ |
michael@0 | 147 | switch (which) { |
michael@0 | 148 | case "curpos": |
michael@0 | 149 | this.setAttribute("value", newValue); |
michael@0 | 150 | |
michael@0 | 151 | // in the future, only fire the change event when userChanged |
michael@0 | 152 | // or _userChanged is true |
michael@0 | 153 | var changeEvent = document.createEvent("Events"); |
michael@0 | 154 | changeEvent.initEvent("change", true, true); |
michael@0 | 155 | this.dispatchEvent(changeEvent); |
michael@0 | 156 | break; |
michael@0 | 157 | |
michael@0 | 158 | case "minpos": |
michael@0 | 159 | this.setAttribute("min", newValue); |
michael@0 | 160 | break; |
michael@0 | 161 | |
michael@0 | 162 | case "maxpos": |
michael@0 | 163 | this.setAttribute("max", newValue); |
michael@0 | 164 | break; |
michael@0 | 165 | } |
michael@0 | 166 | ]]> |
michael@0 | 167 | </body> |
michael@0 | 168 | </method> |
michael@0 | 169 | |
michael@0 | 170 | <method name="dragStateChanged"> |
michael@0 | 171 | <parameter name="isDragging"/> |
michael@0 | 172 | <body/> |
michael@0 | 173 | </method> |
michael@0 | 174 | </implementation> |
michael@0 | 175 | |
michael@0 | 176 | <handlers> |
michael@0 | 177 | <handler event="keypress" keycode="VK_LEFT" preventdefault="true"> |
michael@0 | 178 | <![CDATA[ |
michael@0 | 179 | this._userChanged = true; |
michael@0 | 180 | (this.orient != "vertical" && this.dir == "reverse") ? this.increase() : this.decrease(); |
michael@0 | 181 | this._userChanged = false; |
michael@0 | 182 | ]]> |
michael@0 | 183 | </handler> |
michael@0 | 184 | <handler event="keypress" keycode="VK_RIGHT" preventdefault="true"> |
michael@0 | 185 | <![CDATA[ |
michael@0 | 186 | this._userChanged = true; |
michael@0 | 187 | (this.orient != "vertical" && this.dir == "reverse") ? this.decrease() : this.increase(); |
michael@0 | 188 | this._userChanged = false; |
michael@0 | 189 | ]]> |
michael@0 | 190 | </handler> |
michael@0 | 191 | <handler event="keypress" keycode="VK_UP" preventdefault="true"> |
michael@0 | 192 | <![CDATA[ |
michael@0 | 193 | this._userChanged = true; |
michael@0 | 194 | (this.orient == "vertical" && this.dir != "reverse") ? this.decrease() : this.increase(); |
michael@0 | 195 | this._userChanged = false; |
michael@0 | 196 | ]]> |
michael@0 | 197 | </handler> |
michael@0 | 198 | <handler event="keypress" keycode="VK_DOWN" preventdefault="true"> |
michael@0 | 199 | <![CDATA[ |
michael@0 | 200 | this._userChanged = true; |
michael@0 | 201 | (this.orient == "vertical" && this.dir != "reverse") ? this.increase() : this.decrease(); |
michael@0 | 202 | this._userChanged = false; |
michael@0 | 203 | ]]> |
michael@0 | 204 | </handler> |
michael@0 | 205 | <handler event="keypress" keycode="VK_PAGE_UP" preventdefault="true"> |
michael@0 | 206 | <![CDATA[ |
michael@0 | 207 | this._userChanged = true; |
michael@0 | 208 | (this.orient == "vertical" && this.dir != "reverse") ? this.decreasePage() : this.increasePage(); |
michael@0 | 209 | this._userChanged = false; |
michael@0 | 210 | ]]> |
michael@0 | 211 | </handler> |
michael@0 | 212 | <handler event="keypress" keycode="VK_PAGE_DOWN" preventdefault="true"> |
michael@0 | 213 | <![CDATA[ |
michael@0 | 214 | this._userChanged = true; |
michael@0 | 215 | (this.orient == "vertical" && this.dir != "reverse") ? this.increasePage() : this.decreasePage(); |
michael@0 | 216 | this._userChanged = false; |
michael@0 | 217 | ]]> |
michael@0 | 218 | </handler> |
michael@0 | 219 | <handler event="keypress" keycode="VK_HOME" preventdefault="true"> |
michael@0 | 220 | this._userChanged = true; |
michael@0 | 221 | this.value = (this.dir == "reverse") ? this.max : this.min; |
michael@0 | 222 | this._userChanged = false; |
michael@0 | 223 | </handler> |
michael@0 | 224 | <handler event="keypress" keycode="VK_END" preventdefault="true"> |
michael@0 | 225 | this._userChanged = true; |
michael@0 | 226 | this.value = (this.dir == "reverse") ? this.min : this.max; |
michael@0 | 227 | this._userChanged = false; |
michael@0 | 228 | </handler> |
michael@0 | 229 | </handlers> |
michael@0 | 230 | |
michael@0 | 231 | </binding> |
michael@0 | 232 | </bindings> |