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 >
Wrap
Extensible Markup Language
|
2005-07-29
|
10KB
|
224 lines
<?xml version="1.0" encoding="UTF-8"?>
<xbl:bindings
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<xbl:binding id="spui_ticker">
<xbl:content>
<bulletinboard anonid="ticker-container" style="width: 400px; height:20px; overflow:-moz-scrollbars-none;">
<box flex="1" anonid="ticker-subcontainer">
<xbl:children/>
</box>
</bulletinboard>
</xbl:content>
<xbl:implementation>
<xbl:constructor><![CDATA[
this._container = document.getAnonymousElementByAttribute(this,"anonid","ticker-container");
this._subcontainer = document.getAnonymousElementByAttribute(this,"anonid","ticker-subcontainer");
this._paused = false;
this._pauseStart = 0;
this._active = false;
this._speed = 5;
this._block = 0;
if (this.id == ""){
this.id = "id"+Math.random()+Math.random();
}
if (this.getAttribute("interval")!=""){
interval = this.getAttribute("interval");
}
else {
interval = 100;
}
if (this.getAttribute("pause-interval")!=""){
pauseInterval = this.getAttribute("pause-interval");
}
else {
pauseInterval = 1000;
}
this._key = null;
this._breakPointArray = null;
this._mode = "horizontal";
if (this.getAttribute("mode")!=""){
this.mode = this.getAttribute("mode");
}
else {
this.mode = "horizontal";
}
]]></xbl:constructor>
<xbl:method name="initializeTicker">
<xbl:body><![CDATA[
alert("InitializeTicker called");
this._childNodes = this.childNodes;
this._block = 0;
if (this._mode == "vertical"){
for (var i=0;i<this.childNodes.length;i++){
var item = this.childNodes.item(i);
item.height = this._container.height;
}
this._subcontainer.flex=0;
this._subcontainer.height = this.childNodes.length * this._container.height;
this._subcontainer.left = 0;
this._subcontainer.top = 0;
}
else {
for (var i=0;i<this.childNodes.length;i++){
var item = this.childNodes.item(i);
item.flex=0;
}
this._subcontainer.flex=1;
this._subcontainer.left = 0;
this._subcontainer.top = 0;
//this._subcontainer.height = this.childNodes.length * this._container.height;
}
this._breakPointArray = this.getBreakPointArray();
]]></xbl:body>
</xbl:method>
<xbl:method name="getBreakPointArray">
<xbl:parameter name="block"/>
<xbl:body><![CDATA[
bpArray = new Array();
bpPosition = 0;
bpArray.push(0);
alert(this._mode);
for (var index = 0;index<this.childNodes.length - 1;index++){
switch(this._mode){
case "horizontal":bpPosition += this.childNodes.item(index).boxObject.width;break;
case "vertical":bpPosition += this.childNodes.item(index).boxObject.height;break;
}
bpArray.push(bpPosition);
}
return bpArray;
]]></xbl:body>
</xbl:method>
<xbl:method name="updateTicker">
<xbl:body><![CDATA[
switch(this._mode){
case "horizontal":
var oldLeft = this._subcontainer.boxObject.x;
var delta = - (2 + this._speed);
var newLeft = oldLeft + delta;
var itemLeft = this._breakPointArray[this._block];
if (newLeft <= - itemLeft && oldLeft > - itemLeft){
if (this._pauseStart == 0){
this._pauseStart = (new Date()).valueOf();
return false;
}
else {
if ((new Date()).valueOf() - this._pauseStart >this._pauseInterval){
this._pauseStart = 0;
this._block++;
}
else {
return false;
}
}
}
var newRight = newLeft + this._subcontainer.boxObject.width;
this._subcontainer.left = newLeft;
if (newRight < 0){
this._subcontainer.left = this._container.boxObject.width;
this._block = 0;
}
break;
case "vertical":
var oldTop = this._subcontainer.boxObject.y;
var delta = - (this._speed - 1);
var newTop = oldTop + delta;
var itemTop = this._breakPointArray[this._block];
if (newTop <= - itemTop && oldTop > - itemTop){
if (this._pauseStart == 0){
this._pauseStart = (new Date()).valueOf();
return false;
}
else {
if ((new Date()).valueOf() - this._pauseStart >this._pauseInterval){
this._pauseStart = 0;
this._block++;
}
else {
return false;
}
}
}
var newBottom = newTop + this._subcontainer.boxObject.height;
this._subcontainer.top = newTop;
if (newBottom < 0){
this._subcontainer.top = this._container.boxObject.height;
this._block = 0;
}
break;
}
]]></xbl:body>
</xbl:method>
<xbl:method name="start">
<xbl:body><![CDATA[
this.initializeTicker();
this._key = setInterval("document.getElementById('"+this.id+"').updateTicker()",this.interval);
this._active = true;
]]></xbl:body>
</xbl:method>
<xbl:method name="stop">
<xbl:body><![CDATA[
clearInterval(this._key);
this._active = false;
this._key = null;
]]></xbl:body>
</xbl:method>
<xbl:property name="active">
<xbl:getter>
return this._active;
</xbl:getter>
<xbl:setter><![CDATA[
if (val){
this.start();
}
else {
this.stop();
}
]]></xbl:setter>
</xbl:property>
<xbl:property name="mode">
<xbl:getter><![CDATA[
return this._mode;
]]></xbl:getter>
<xbl:setter><![CDATA[
this._mode=val;
if (this._key != null){
this.stop();
this._subcontainer.orient = this._mode;
this.initializeTicker();
this.start();
}
else {
this._subcontainer.orient = this._mode;
this.initializeTicker();
}
]]></xbl:setter>
</xbl:property>
<xbl:property name="speed">
<xbl:getter>
return this._speed;
</xbl:getter>
<xbl:setter>
this._speed = parseInt(val);
</xbl:setter>
</xbl:property>
<xbl:property name="pauseInterval">
<xbl:getter><![CDATA[
return this._pauseInterval;
]]></xbl:getter>
<xbl:setter><![CDATA[
this._pauseInterval=parseInt(val);
]]></xbl:setter>
</xbl:property>
<xbl:property name="interval">
<xbl:getter><![CDATA[
return this._interval;
]]></xbl:getter>
<xbl:setter><![CDATA[
this._interval=parseInt(val);
]]></xbl:setter>
</xbl:property>
</xbl:implementation>
</xbl:binding>
</xbl:bindings>