home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Complet / thunderbird / chrome / mail.jar / content / xbl-marquee / xbl-marquee.xml < prev   
Encoding:
Extensible Markup Language  |  2003-03-17  |  9.7 KB  |  314 lines

  1. <?xml version="1.0"?>
  2. <!-- ***** BEGIN LICENSE BLOCK *****
  3.    - Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.    -
  5.    - The contents of this file are subject to the Mozilla Public License Version
  6.    - 1.1 (the "License"); you may not use this file except in compliance with
  7.    - the License. You may obtain a copy of the License at
  8.    - http://www.mozilla.org/MPL/
  9.    -
  10.    - Software distributed under the License is distributed on an "AS IS" basis,
  11.    - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.    - for the specific language governing rights and limitations under the
  13.    - License.
  14.    -
  15.    - The Original Code is Netscape's XBL Marquee Emulation code.
  16.    -
  17.    - The Initial Developer of the Original Code is
  18.    - Netscape Communications Corporation.
  19.    - Portions created by the Initial Developer are Copyright (C) 2002
  20.    - the Initial Developer. All Rights Reserved.
  21.    -
  22.    - Contributor(s):
  23.    -   Doron Rosenberg <doron@netscape.com>
  24.    -   L. David Baron <dbaron@dbaron.org>
  25.    -
  26.    - Alternatively, the contents of this file may be used under the terms of
  27.    - either the GNU General Public License Version 2 or later (the "GPL"), or
  28.    - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29.    - in which case the provisions of the GPL or the LGPL are applicable instead
  30.    - of those above. If you wish to allow use of your version of this file only
  31.    - under the terms of either the GPL or the LGPL, and not to allow others to
  32.    - use your version of this file under the terms of the MPL, indicate your
  33.    - decision by deleting the provisions above and replace them with the notice
  34.    - and other provisions required by the LGPL or the GPL. If you do not delete
  35.    - the provisions above, a recipient may use your version of this file under
  36.    - the terms of any one of the MPL, the GPL or the LGPL.
  37.    -
  38.    - ***** END LICENSE BLOCK ***** -->
  39.  
  40. <bindings id="marqueeBindings"
  41.           xmlns="http://www.mozilla.org/xbl"
  42.           xmlns:html="http://www.w3.org/1999/xhtml"
  43.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  44.           xmlns:xbl="http://www.mozilla.org/xbl">
  45.  
  46.  
  47.   <binding id="marquee">
  48.  
  49.     <implementation>
  50.  
  51.       <property name="scrollAmount">
  52.         <getter>
  53.           if (this.hasAttribute("scrollamount"))
  54.             return this.getAttribute("scrollamount");
  55.           return 6; //default value is 6 pixels
  56.         </getter>
  57.         <setter>
  58.           this.setAttribute("scrollamount", val);
  59.         </setter>
  60.       </property>
  61.  
  62.       <property name="scrollDelay">
  63.         <getter>
  64.           <![CDATA[
  65.           if (!this.hasAttribute("scrolldelay"))
  66.             return 85; //default value is 85 ms
  67.  
  68.           var myScrollDelay = this.getAttribute('scrolldelay');
  69.  
  70.           //marquee doesn't allow anything shorter than 40 ms
  71.           if (myScrollDelay < 40)
  72.             return 40;
  73.           return myScrollDelay;
  74.           ]]>
  75.         </getter>
  76.         <setter>
  77.           this.setAttribute("scrolldelay", val);
  78.         </setter>
  79.       </property>
  80.  
  81.       <property name="direction">
  82.         <getter>
  83.           if (this.hasAttribute("direction"))
  84.             return this.getAttribute("direction");
  85.           return "left"; //default value is "left"
  86.         </getter>
  87.       </property>
  88.  
  89.       <property name="behavior">
  90.         <getter>
  91.           if (this.hasAttribute("behavior"))
  92.             return this.getAttribute("behavior");
  93.           return "scroll"; //default value is "scroll"
  94.         </getter>
  95.       </property>
  96.  
  97.       <field name="dirsign">1</field>
  98.       <field name="startAt">0</field>
  99.       <field name="stopAt">0</field>
  100.       <field name="newPosition">0</field>
  101.       <field name="runId">0</field>
  102.  
  103.       <field name="scrollStarted">0</field>
  104.  
  105.       <property name="outerDiv"
  106.         onget="return document.getAnonymousNodes(this)[0]"
  107.       />
  108.  
  109.       <property name="height"
  110.         onget="return this.getAttribute('height');"
  111.       />
  112.  
  113.       <property name="width">
  114.         <getter>
  115.           <![CDATA[
  116.           if (this.hasAttribute("width"))
  117.             return this.getAttribute("width");
  118.           else if (this.parentNode.offsetWidth > 0)
  119.             return this.parentNode.offsetWidth;
  120.           else if (this.parentNode.parentNode.offsetWidth > 0)
  121.             return this.parentNode.parentNode.offsetWidth;
  122.           else
  123.             return 1;
  124.           ]]>
  125.         </getter>
  126.       </property> 
  127.  
  128.       <!-- For sniffing purposes -->
  129.       <field name="nsMarqueeVersion">"0.9.6"</field>
  130.   
  131.       <method name="start">
  132.         <body>
  133.         <![CDATA[
  134.  
  135.           this.stop();
  136.  
  137.           if (this.scrollStarted == 0)
  138.           {
  139.             this.scrollStarted = 1; //we only want this to run once
  140.  
  141.             switch (this.direction)
  142.             {
  143.               case "up":
  144.                 this.dirsign = 1;
  145.                 this.startAt = 0;
  146.                 this.stopAt  = this.innerDiv.offsetHeight -
  147.                                parseInt(this.outerDiv.style.height);
  148.               break;
  149.  
  150.               case "down":
  151.                 this.dirsign = -1;
  152.                 this.startAt = this.innerDiv.offsetHeight -
  153.                                parseInt(this.outerDiv.style.height);
  154.                 this.stopAt  = 0;
  155.               break;
  156.  
  157.               case "left":
  158.                 this.dirsign = 1;
  159.                 this.startAt = this.innerDiv.offsetLeft - this.outerDiv.offsetWidth;
  160.                 this.stopAt  = this.outerDiv.offsetWidth + this.innerDiv.offsetWidth + this.startAt;
  161.               break;
  162.  
  163.               case "right":
  164.               default:
  165.                 this.dirsign = -1;
  166.                 this.stopAt  = this.innerDiv.offsetLeft - this.outerDiv.offsetWidth;
  167.                 this.startAt = this.outerDiv.offsetWidth + this.innerDiv.offsetWidth + this.stopAt;              
  168.               break;
  169.             }
  170.             this.newPosition = this.startAt;
  171.           } //end if
  172.  
  173.           this.newPosition = parseInt(this.newPosition) + (this.dirsign * this.scrollAmount);
  174.  
  175.           if ((this.dirsign == 1 && this.newPosition > this.stopAt) ||
  176.               (this.dirsign == -1 && this.newPosition < this.stopAt))
  177.           {
  178.             if (this.behavior == "alternate")
  179.             {
  180.               this.dirsign = -1 * this.dirsign;
  181.               var temp     = this.stopAt;
  182.               this.stopAt  = this.startAt;
  183.               this.startAt = temp;
  184.             }
  185.             else
  186.             {
  187.               this.newPosition = this.startAt;
  188.             }
  189.           }
  190.  
  191.           switch(this.direction)
  192.           {
  193.             case "up":
  194.             case "down":
  195.               this.outerDiv.scrollTop = this.newPosition;
  196.             break;
  197.  
  198.             case "left":
  199.             case "right":
  200.             default:
  201.               this.outerDiv.scrollLeft = this.newPosition;
  202.             break;
  203.           }
  204.  
  205.           var myThis = this;
  206.           var myTimeOut = function myTimeOutFunction(){myThis.start();}
  207.  
  208.           this.runId = window.setTimeout(myTimeOut, this.scrollDelay);
  209.         ]]>
  210.         </body>
  211.       </method>
  212.  
  213.       <method name="stop">
  214.         <body>
  215.         <![CDATA[
  216.           if (this.runId != 0)
  217.             clearTimeout(this.runId);
  218.  
  219.           this.runId = 0;
  220.         ]]>
  221.         </body>
  222.       </method>
  223.  
  224.       <method name="init">
  225.         <body>
  226.         <![CDATA[
  227.           var height;
  228.  
  229.           if ((this.direction == "up") || (this.direction == "down")) {
  230.             height = "200px";
  231.             this.outerDiv.style.height = height;
  232.           }
  233.           else {
  234.             this.innerDiv.style.whiteSpace = "nowrap";          
  235.           }
  236.  
  237.           if (this.hasAttribute('height')) {
  238.             height = this.getAttribute('height');
  239.             this.outerDiv.style.height = height + "px";
  240.           }
  241.  
  242.           this.outerDiv.style.width = this.width + "px";
  243.  
  244.           if ((this.direction == "up") || (this.direction == "down")) {
  245.             this.innerDiv.style.padding = height + "px" + " 0";
  246.           }
  247.   
  248.           // Some sites access the element via the evil IE way of elementID.foo()
  249.           if (this.hasAttribute('id'))
  250.             window[this.getAttribute('id')] = this;
  251.  
  252.           this.start();
  253.         ]]>
  254.         </body>
  255.       </method>
  256.  
  257.       <constructor>
  258.         <![CDATA[
  259.           var myThis = this;
  260.           var lambda = function myScopeFunction() { myThis.init(); }
  261.  
  262.           //init needs to be run after the page has loaded in order to calculate the correct
  263.           //height/width
  264.           window.addEventListener("load", lambda, false);
  265.         ]]>
  266.       </constructor>
  267.     </implementation>
  268.  
  269.   </binding>
  270.  
  271.   <binding id="marquee-horizontal"
  272.            extends="chrome://xbl-marquee/content/xbl-marquee.xml#marquee">
  273.  
  274.     <implementation>
  275.  
  276.       <property name="innerDiv"
  277.         onget="return document.getAnonymousNodes(this)[0].firstChild.firstChild"
  278.       />
  279.  
  280.     </implementation>
  281.  
  282.     <content>
  283.       <html:div xbl:inherits="" style="overflow: -moz-scrollbars-none">
  284.         <xul:hbox style="margin: 0 100%;">
  285.           <html:div>
  286.             <children/>
  287.           </html:div>
  288.         </xul:hbox>
  289.       </html:div>
  290.     </content>
  291.  
  292.   </binding>
  293.  
  294.   <binding id="marquee-vertical"
  295.            extends="chrome://xbl-marquee/content/xbl-marquee.xml#marquee">
  296.  
  297.     <implementation>
  298.       <property name="innerDiv"
  299.         onget="return document.getAnonymousNodes(this)[0].firstChild"
  300.       />
  301.     </implementation>
  302.  
  303.     <content>
  304.       <html:div xbl:inherits="" style="overflow: -moz-scrollbars-none">
  305.         <html:div>
  306.           <children/>
  307.         </html:div>
  308.       </html:div>
  309.     </content>
  310.  
  311.   </binding>
  312.  
  313. </bindings>
  314.