home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / xulrunner-1.9.0.14 / chrome / toolkit.jar / content / global / bindings / progressmeter.xml < prev    next >
Encoding:
Extensible Markup Language  |  2008-07-08  |  4.8 KB  |  147 lines

  1. <?xml version="1.0"?>
  2.  
  3. <bindings id="progressmeterBindings"
  4.    xmlns="http://www.mozilla.org/xbl"
  5.    xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  6.    xmlns:xbl="http://www.mozilla.org/xbl">
  7.  
  8.   <binding id="progressmeter">
  9.     <resources>
  10.       <stylesheet src="chrome://global/skin/progressmeter.css"/>
  11.     </resources>
  12.  
  13.     <content>
  14.       <xul:spacer class="progress-bar" xbl:inherits="mode"/>
  15.       <xul:spacer class="progress-remainder" xbl:inherits="mode"/>
  16.     </content>
  17.     
  18.     <implementation implements="nsIAccessibleProvider">
  19.       <property name="mode" onset="if (this.mode != val) this.setAttribute('mode', val); return val;"
  20.                             onget="return this.getAttribute('mode');"/>
  21.  
  22.       <property name="value" onget="return this.getAttribute('value') || '0';">
  23.         <setter><![CDATA[
  24.           var p = Math.round(val);
  25.           if (p < 0)
  26.             p = 0;
  27.           else if (p > 100)
  28.             p = 100;
  29.           var c = this.value; 
  30.           if (p != c) {
  31.             var delta = p - c;
  32.             if (delta < 0)
  33.               delta = -delta;
  34.             if (delta > 3 || p == 0 || p == 100) {
  35.               this.setAttribute("value", p);
  36.               // Fire DOM event so that accessible value change events occur
  37.               var event = document.createEvent('Events');
  38.               event.initEvent('ValueChange', true, true);
  39.               this.dispatchEvent(event);
  40.             }
  41.           }
  42.           
  43.           return val;
  44.         ]]></setter>
  45.       </property>
  46.  
  47.       <property name="accessibleType" readonly="true">
  48.         <getter>
  49.           <![CDATA[
  50.             return Components.interfaces.nsIAccessibleProvider.XULProgressMeter;
  51.           ]]>
  52.         </getter>
  53.       </property>
  54.     </implementation>
  55.   </binding>
  56.  
  57.   <binding id="progressmeter-undetermined"
  58.            extends="chrome://global/content/bindings/progressmeter.xml#progressmeter">
  59.     <content>
  60.       <xul:stack class="progress-remainder" flex="1" anonid="stack" style="overflow: -moz-hidden-unscrollable;">
  61.         <xul:spacer class="progress-bar" anonid="spacer" top="0" style="margin-right: -1000px;"/>
  62.       </xul:stack>
  63.     </content>
  64.  
  65.     <implementation>
  66.       <field name="_alive">true</field>
  67.       <method name="_init">
  68.         <body><![CDATA[
  69.           var stack = document.getAnonymousElementByAttribute(this, "anonid", "stack");
  70.           var spacer = document.getAnonymousElementByAttribute(this, "anonid", "spacer");
  71.           var self = this;
  72.  
  73.           var isLTR = 
  74.            document.defaultView.getComputedStyle(this, null).direction == "ltr";
  75.  
  76.           var position = isLTR ? 4 : -1;
  77.           var interval = setInterval(function nextStep() {
  78.             try {
  79.               var width = stack.boxObject.width;
  80.               if (!width) {
  81.                 // Maybe we've been removed from the document.
  82.                 if (!self._alive)
  83.                   clearInterval(interval);
  84.                 return;
  85.               }
  86.               width = width >> 2;
  87.               spacer.height = stack.boxObject.height;
  88.               spacer.width = width;
  89.               spacer.left = width * position;
  90.               if (isLTR) {
  91.                 position += 15 / (width + 150);
  92.                 if (position >= 4)
  93.                   position = -1;
  94.               }
  95.               else {
  96.                 position -= 15 / (width + 150);
  97.                 if (position < 0)
  98.                   position = 4;
  99.               }
  100.             } catch (e) {
  101.               clearInterval(interval);
  102.             }
  103.           }, 20);
  104.         ]]></body>
  105.       </method>
  106.  
  107.       <constructor>this._init();</constructor>
  108.     </implementation>
  109.   </binding>
  110.  
  111.   <binding id="progressmeter-periodic-redraw"
  112.            extends="chrome://global/content/bindings/progressmeter.xml#progressmeter">
  113.     <content>
  114.       <xul:spacer anonid="visibility-detector" flex="1"/>
  115.     </content>
  116.     <implementation>
  117.       <field name="_alive">true</field>
  118.       <method name="_init">
  119.         <body><![CDATA[
  120.           var step = 0;
  121.           var self = this;
  122.           var spacer = document.getAnonymousElementByAttribute(this, "anonid", "visibility-detector");
  123.           var interval = setInterval(function nextStep() {
  124.             try {
  125.               // Only bother redrawing when we're visible
  126.               var width = spacer.boxObject.width;
  127.               if (!width) {
  128.                 // Maybe we've been removed from the document.
  129.                 if (!self._alive)
  130.                   clearInterval(interval);
  131.                 return;
  132.               }
  133.               // Trigger redraw by changing the step attribute
  134.               step = 1 - step;
  135.               self.setAttribute('step', step);
  136.             } catch (e) {
  137.               clearInterval(interval);
  138.             }
  139.           }, 1000/30);
  140.         ]]></body>
  141.       </method>
  142.       <constructor>this._init();</constructor>
  143.     </implementation>
  144.   </binding>
  145.  
  146. </bindings>
  147.