2007-03-22 10:30:00 -07:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
<bindings id="progressmeterBindings"
|
|
|
|
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">
|
|
|
|
|
|
|
|
<binding id="progressmeter">
|
|
|
|
<resources>
|
|
|
|
<stylesheet src="chrome://global/skin/progressmeter.css"/>
|
|
|
|
</resources>
|
|
|
|
|
|
|
|
<content>
|
|
|
|
<xul:spacer class="progress-bar" xbl:inherits="mode"/>
|
|
|
|
<xul:spacer class="progress-remainder" xbl:inherits="mode"/>
|
|
|
|
</content>
|
|
|
|
|
|
|
|
<implementation implements="nsIAccessibleProvider">
|
|
|
|
<property name="mode" onset="if (this.mode != val) this.setAttribute('mode', val); return val;"
|
|
|
|
onget="return this.getAttribute('mode');"/>
|
|
|
|
|
2007-04-23 06:19:30 -07:00
|
|
|
<property name="value" onget="return this.getAttribute('value') || '0';">
|
2007-03-22 10:30:00 -07:00
|
|
|
<setter><![CDATA[
|
|
|
|
var p = Math.round(val);
|
2008-10-30 02:34:23 -07:00
|
|
|
var max = Math.round(this.max);
|
2007-04-23 06:19:30 -07:00
|
|
|
if (p < 0)
|
|
|
|
p = 0;
|
2008-10-30 02:34:23 -07:00
|
|
|
else if (p > max)
|
|
|
|
p = max;
|
2007-03-22 10:30:00 -07:00
|
|
|
var c = this.value;
|
|
|
|
if (p != c) {
|
|
|
|
var delta = p - c;
|
|
|
|
if (delta < 0)
|
|
|
|
delta = -delta;
|
2008-10-30 02:34:23 -07:00
|
|
|
if (delta > 3 || p == 0 || p == max) {
|
2007-03-22 10:30:00 -07:00
|
|
|
this.setAttribute("value", p);
|
|
|
|
// Fire DOM event so that accessible value change events occur
|
|
|
|
var event = document.createEvent('Events');
|
|
|
|
event.initEvent('ValueChange', true, true);
|
|
|
|
this.dispatchEvent(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-23 06:19:30 -07:00
|
|
|
return val;
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></setter>
|
|
|
|
</property>
|
2008-10-30 02:34:23 -07:00
|
|
|
<property name="max"
|
|
|
|
onget="return this.getAttribute('max') || '100';"
|
2008-10-30 05:25:42 -07:00
|
|
|
onset="this.setAttribute('max', isNaN(val) ? 100 : Math.max(val, 1));
|
2008-10-30 02:34:23 -07:00
|
|
|
this.value = this.value;
|
|
|
|
return val;" />
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
<property name="accessibleType" readonly="true">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
return Components.interfaces.nsIAccessibleProvider.XULProgressMeter;
|
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="progressmeter-undetermined"
|
|
|
|
extends="chrome://global/content/bindings/progressmeter.xml#progressmeter">
|
|
|
|
<content>
|
|
|
|
<xul:stack class="progress-remainder" flex="1" anonid="stack" style="overflow: -moz-hidden-unscrollable;">
|
|
|
|
<xul:spacer class="progress-bar" anonid="spacer" top="0" style="margin-right: -1000px;"/>
|
|
|
|
</xul:stack>
|
|
|
|
</content>
|
|
|
|
|
|
|
|
<implementation>
|
2008-06-29 18:31:01 -07:00
|
|
|
<field name="_alive">true</field>
|
2007-04-23 06:19:30 -07:00
|
|
|
<method name="_init">
|
2007-03-22 10:30:00 -07:00
|
|
|
<body><![CDATA[
|
|
|
|
var stack = document.getAnonymousElementByAttribute(this, "anonid", "stack");
|
|
|
|
var spacer = document.getAnonymousElementByAttribute(this, "anonid", "spacer");
|
2008-06-29 18:31:01 -07:00
|
|
|
var self = this;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
var isLTR =
|
|
|
|
document.defaultView.getComputedStyle(this, null).direction == "ltr";
|
|
|
|
|
|
|
|
var position = isLTR ? 4 : -1;
|
|
|
|
var interval = setInterval(function nextStep() {
|
|
|
|
try {
|
2008-03-07 05:48:06 -08:00
|
|
|
var width = stack.boxObject.width;
|
|
|
|
if (!width) {
|
|
|
|
// Maybe we've been removed from the document.
|
2008-06-29 18:31:01 -07:00
|
|
|
if (!self._alive)
|
2008-03-07 05:48:06 -08:00
|
|
|
clearInterval(interval);
|
2008-06-29 18:31:01 -07:00
|
|
|
return;
|
2008-03-07 05:48:06 -08:00
|
|
|
}
|
|
|
|
width = width >> 2;
|
2007-03-22 10:30:00 -07:00
|
|
|
spacer.height = stack.boxObject.height;
|
|
|
|
spacer.width = width;
|
|
|
|
spacer.left = width * position;
|
|
|
|
if (isLTR) {
|
|
|
|
position += 15 / (width + 150);
|
|
|
|
if (position >= 4)
|
|
|
|
position = -1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
position -= 15 / (width + 150);
|
|
|
|
if (position < 0)
|
|
|
|
position = 4;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
clearInterval(interval);
|
|
|
|
}
|
|
|
|
}, 20);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2007-04-23 06:19:30 -07:00
|
|
|
<constructor>this._init();</constructor>
|
2007-03-22 10:30:00 -07:00
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
2008-04-07 15:56:43 -07:00
|
|
|
<binding id="progressmeter-periodic-redraw"
|
|
|
|
extends="chrome://global/content/bindings/progressmeter.xml#progressmeter">
|
2008-06-29 18:31:01 -07:00
|
|
|
<content>
|
|
|
|
<xul:spacer anonid="visibility-detector" flex="1"/>
|
|
|
|
</content>
|
2008-04-07 15:56:43 -07:00
|
|
|
<implementation>
|
2008-06-29 18:31:01 -07:00
|
|
|
<field name="_alive">true</field>
|
2008-04-07 15:56:43 -07:00
|
|
|
<method name="_init">
|
|
|
|
<body><![CDATA[
|
|
|
|
var step = 0;
|
|
|
|
var self = this;
|
2008-06-29 18:31:01 -07:00
|
|
|
var spacer = document.getAnonymousElementByAttribute(this, "anonid", "visibility-detector");
|
2008-04-07 15:56:43 -07:00
|
|
|
var interval = setInterval(function nextStep() {
|
|
|
|
try {
|
2008-06-29 18:31:01 -07:00
|
|
|
// Only bother redrawing when we're visible
|
|
|
|
var width = spacer.boxObject.width;
|
|
|
|
if (!width) {
|
|
|
|
// Maybe we've been removed from the document.
|
|
|
|
if (!self._alive)
|
|
|
|
clearInterval(interval);
|
|
|
|
return;
|
|
|
|
}
|
2008-04-07 15:56:43 -07:00
|
|
|
// Trigger redraw by changing the step attribute
|
2008-06-29 18:31:01 -07:00
|
|
|
step = 1 - step;
|
2008-04-07 15:56:43 -07:00
|
|
|
self.setAttribute('step', step);
|
|
|
|
} catch (e) {
|
|
|
|
clearInterval(interval);
|
|
|
|
}
|
|
|
|
}, 1000/30);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
<constructor>this._init();</constructor>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
</bindings>
|