home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2005 October / Gamestar_77_2005-10_dvd.iso / Programy / nsb-install-8-0.exe / chrome / toolkit.jar / content / global / bindings / ticker.xml < prev    next >
Extensible Markup Language  |  2005-07-29  |  10KB  |  224 lines

  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <xbl:bindings 
  3.     xmlns:xbl="http://www.mozilla.org/xbl"
  4.     xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  5.     <xbl:binding id="spui_ticker">
  6.         <xbl:content>
  7.             <bulletinboard anonid="ticker-container" style="width: 400px;  height:20px; overflow:-moz-scrollbars-none;">
  8.                 <box flex="1" anonid="ticker-subcontainer">
  9.                     <xbl:children/>
  10.                 </box>
  11.             </bulletinboard>
  12.         </xbl:content>
  13.         <xbl:implementation>
  14.             <xbl:constructor><![CDATA[
  15.                 this._container = document.getAnonymousElementByAttribute(this,"anonid","ticker-container");
  16.                 this._subcontainer = document.getAnonymousElementByAttribute(this,"anonid","ticker-subcontainer");
  17.                 this._paused = false;
  18.                 this._pauseStart = 0;
  19.                 this._active = false;
  20.                 this._speed = 5;
  21.                 this._block = 0;
  22.                 if (this.id == ""){
  23.                     this.id = "id"+Math.random()+Math.random();
  24.                     }
  25.                 if (this.getAttribute("interval")!=""){
  26.                     interval = this.getAttribute("interval");
  27.                     }
  28.                 else {
  29.                     interval = 100;
  30.                     }
  31.                 if (this.getAttribute("pause-interval")!=""){
  32.                     pauseInterval = this.getAttribute("pause-interval");
  33.                     }
  34.                 else {
  35.                     pauseInterval = 1000;
  36.                     }
  37.                 this._key = null;
  38.                 this._breakPointArray = null;
  39.                 this._mode = "horizontal";
  40.                 if (this.getAttribute("mode")!=""){
  41.                     this.mode = this.getAttribute("mode");
  42.                 }
  43.                 else {
  44.                     this.mode = "horizontal";
  45.                     }
  46.                 ]]></xbl:constructor>
  47.             <xbl:method name="initializeTicker">
  48.                 <xbl:body><![CDATA[
  49.                     alert("InitializeTicker called");
  50.                     this._childNodes = this.childNodes;
  51.                     this._block = 0;
  52.                     if (this._mode == "vertical"){
  53.                         for (var i=0;i<this.childNodes.length;i++){
  54.                             var item = this.childNodes.item(i);
  55.                             item.height = this._container.height;
  56.                             }
  57.                         this._subcontainer.flex=0;
  58.                         this._subcontainer.height = this.childNodes.length * this._container.height;
  59.                         this._subcontainer.left = 0;
  60.                         this._subcontainer.top = 0;
  61.                     }
  62.                     else {
  63.                         for (var i=0;i<this.childNodes.length;i++){
  64.                             var item = this.childNodes.item(i);
  65.                             item.flex=0;
  66.                             }
  67.                         this._subcontainer.flex=1;
  68.                         this._subcontainer.left = 0;
  69.                         this._subcontainer.top = 0;
  70.                     //this._subcontainer.height = this.childNodes.length * this._container.height;
  71.                         }
  72.                     this._breakPointArray = this.getBreakPointArray();
  73.                     ]]></xbl:body>
  74.             </xbl:method>
  75.             <xbl:method name="getBreakPointArray">
  76.                 <xbl:parameter name="block"/>
  77.                 <xbl:body><![CDATA[
  78.                     bpArray = new Array();
  79.                     bpPosition = 0;
  80.                     bpArray.push(0);
  81.                     alert(this._mode);
  82.                     for (var index = 0;index<this.childNodes.length - 1;index++){
  83.                         switch(this._mode){
  84.                             case "horizontal":bpPosition +=  this.childNodes.item(index).boxObject.width;break;
  85.                             case "vertical":bpPosition +=  this.childNodes.item(index).boxObject.height;break;
  86.                             }
  87.                             bpArray.push(bpPosition);
  88.                         }
  89.                     return bpArray;
  90.                     ]]></xbl:body>
  91.             </xbl:method>
  92.             <xbl:method name="updateTicker">
  93.                 <xbl:body><![CDATA[
  94.                     switch(this._mode){
  95.                       case "horizontal":
  96.                         var oldLeft = this._subcontainer.boxObject.x;
  97.                         var delta = - (2 + this._speed);
  98.                         var newLeft = oldLeft + delta;
  99.                         var itemLeft =  this._breakPointArray[this._block];
  100.                         if (newLeft <= - itemLeft && oldLeft > -  itemLeft){
  101.                             if (this._pauseStart == 0){
  102.                                 this._pauseStart = (new  Date()).valueOf();
  103.                                 return false;
  104.                                 }
  105.                             else {
  106.                                 if ((new Date()).valueOf() -  this._pauseStart >this._pauseInterval){
  107.                                     this._pauseStart = 0;
  108.                                     this._block++;
  109.                                     }
  110.                                 else {
  111.                                     return false;
  112.                                     }
  113.                                 }
  114.                             }
  115.                         var newRight = newLeft +  this._subcontainer.boxObject.width;
  116.                         this._subcontainer.left = newLeft;
  117.                         if (newRight < 0){
  118.                             this._subcontainer.left =  this._container.boxObject.width;
  119.                             this._block = 0;
  120.                             }
  121.                          break;
  122.                     case "vertical":
  123.                         var oldTop = this._subcontainer.boxObject.y;
  124.                         var delta = - (this._speed - 1);
  125.                         var newTop = oldTop + delta;
  126.                         var itemTop = this._breakPointArray[this._block];
  127.                         if (newTop <= - itemTop && oldTop > - itemTop){
  128.                             if (this._pauseStart == 0){
  129.                                 this._pauseStart = (new  Date()).valueOf();
  130.                                 return false;
  131.                                 }
  132.                             else {
  133.                                 if ((new Date()).valueOf() -  this._pauseStart >this._pauseInterval){
  134.                                     this._pauseStart = 0;
  135.                                     this._block++;
  136.                                     }
  137.                                 else {
  138.                                     return false;
  139.                                     }
  140.                                 }
  141.                             }
  142.                         var newBottom = newTop +  this._subcontainer.boxObject.height;
  143.                         this._subcontainer.top = newTop;
  144.                         if (newBottom < 0){
  145.                             this._subcontainer.top =  this._container.boxObject.height;
  146.                             this._block = 0;
  147.                             }
  148.                     break;
  149.                     }
  150.                     ]]></xbl:body>
  151.             </xbl:method>
  152.             <xbl:method name="start">
  153.                 <xbl:body><![CDATA[
  154.                     this.initializeTicker();
  155.                     this._key = setInterval("document.getElementById('"+this.id+"').updateTicker()",this.interval);
  156.                     this._active = true;
  157.                 ]]></xbl:body>
  158.             </xbl:method>
  159.             <xbl:method name="stop">
  160.                 <xbl:body><![CDATA[
  161.                     clearInterval(this._key);
  162.                     this._active = false;
  163.                     this._key = null;
  164.                     ]]></xbl:body>
  165.             </xbl:method>
  166.             <xbl:property name="active">
  167.                 <xbl:getter>
  168.                     return this._active;
  169.                 </xbl:getter>
  170.                 <xbl:setter><![CDATA[
  171.                     if (val){
  172.                         this.start();
  173.                         }
  174.                     else {
  175.                         this.stop();
  176.                         }
  177.                 ]]></xbl:setter>
  178.             </xbl:property>
  179.             <xbl:property name="mode">
  180.                 <xbl:getter><![CDATA[
  181.                     return this._mode;
  182.                 ]]></xbl:getter>
  183.                 <xbl:setter><![CDATA[
  184.                     this._mode=val;
  185.                     if (this._key != null){
  186.                         this.stop();
  187.                         this._subcontainer.orient = this._mode;
  188.                         this.initializeTicker();
  189.                         this.start();
  190.                         }
  191.                     else {
  192.                         this._subcontainer.orient = this._mode;
  193.                         this.initializeTicker();
  194.                         }
  195.                 ]]></xbl:setter>
  196.             </xbl:property>
  197.             <xbl:property name="speed">
  198.                 <xbl:getter>
  199.                     return this._speed;
  200.                 </xbl:getter>
  201.                 <xbl:setter>
  202.                     this._speed = parseInt(val);
  203.                 </xbl:setter>
  204.             </xbl:property>
  205.             <xbl:property name="pauseInterval">
  206.                 <xbl:getter><![CDATA[
  207.                     return this._pauseInterval;
  208.                     ]]></xbl:getter>
  209.                 <xbl:setter><![CDATA[
  210.                     this._pauseInterval=parseInt(val);
  211.                     ]]></xbl:setter>
  212.             </xbl:property>
  213.             <xbl:property name="interval">
  214.                 <xbl:getter><![CDATA[
  215.                     return this._interval;
  216.                     ]]></xbl:getter>
  217.                 <xbl:setter><![CDATA[
  218.                     this._interval=parseInt(val);
  219.                     ]]></xbl:setter>
  220.             </xbl:property>
  221.         </xbl:implementation>
  222.     </xbl:binding>
  223. </xbl:bindings>
  224.