home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / mozil06.zip / bin / chrome / toolkit.jar / content / global / tabBindings.xml < prev    next >
Extensible Markup Language  |  2001-02-14  |  6KB  |  189 lines

  1. <?xml version="1.0"?>
  2.  
  3. <bindings id="tabBindings"
  4.           xmlns="http://www.mozilla.org/xbl"
  5.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  6.  
  7.   <binding id="tabcontrol" extends="xul:box">
  8.     <content orient="vertical"/>
  9.     <!-- pass-through implementation -->
  10.     <implementation>
  11.       <property name="selectedTab">
  12.         <setter>
  13.         <![CDATA[
  14.           var tabbox = this.getElementsByTagName("tabbox");
  15.           tabbox = tabbox.length ? tabbox[0] : null;
  16.           if (tabbox) tabbox.selectedTab = val;
  17.           return val;
  18.         ]]>
  19.         </setter>
  20.         <getter>
  21.         <![CDATA[
  22.           var tabbox = this.getElementsByTagName("tabbox");
  23.           tabbox = tabbox.length ? tabbox[0] : null;
  24.           return tabbox ? tabbox.selectedTab : null;
  25.         ]]>
  26.         </getter>
  27.       </property>
  28.     </implementation>
  29.   </binding>
  30.  
  31.   <binding id="tabbox" extends="xul:box">
  32.     <implementation>
  33.       <property name="selectedTab">
  34.         <getter>
  35.         <![CDATA[
  36.           for (var i = 0; i < this.childNodes.length; i++)
  37.             {
  38.               if (this.childNodes[i].selected || 
  39.                   this.childNodes[i].getAttribute("selected") == "true")
  40.                 return this.childNodes[i];
  41.             }
  42.         ]]>
  43.         </getter>
  44.         <setter>
  45.         <![CDATA[
  46.           if (!val.selected) val.selected = true;
  47.           var selectedIndex = 0;
  48.           for (var i = 0; i < this.childNodes.length; i++)
  49.             {
  50.               if (this.childNodes[i].selected)
  51.                 {
  52.                   if (this.childNodes[i] != val)
  53.                     {
  54.                       this.childNodes[i].selected = false;
  55.                       this.childNodes[i].removeAttribute("selected");
  56.                     }
  57.                   else 
  58.                     selectedIndex = i;
  59.                 }
  60.             }
  61.           var tabpanel = this.parentNode.getElementsByTagName("tabpanel");
  62.           tabpanel = tabpanel.length ? tabpanel[0] : null;
  63.           if (tabpanel) tabpanel.index = selectedIndex;
  64.           return val;
  65.         ]]>
  66.         </setter>
  67.       </property>
  68.       
  69.       <method name="advanceSelectedTab">
  70.         <parameter name="aDir"/>
  71.         <body>
  72.         <![CDATA[
  73.           var next = null;
  74.           if (aDir == -1) 
  75.               next = this.selectedTab.previousSibling;
  76.           else if (aDir == 1) 
  77.               next = this.selectedTab.nextSibling;
  78.           if (next) {
  79.             this.selectedTab = next;
  80.             next.focus();
  81.           }
  82.         ]]>
  83.         </body>
  84.       </method>
  85.     </implementation>
  86.     <handlers>
  87.       <handler event="bindingattached">
  88.       <![CDATA[
  89.         // first and last tabs need to be able to have unique styles
  90.         // and also need to select first tab on startup.
  91.         var tabs = this.getElementsByTagName("tab");
  92.         if (tabs.length) {
  93.           if (tabs.length > 1) {
  94.             tabs[0].setAttribute("first-tab", "true");
  95.             tabs[tabs.length - 1].setAttribute("last-tab", "true");
  96.           }
  97.           else if (tabs.length == 1)
  98.             tabs[0].setAttribute("first-tab", "true");
  99.         }
  100.         this.selectedTab = tabs[0];
  101.         var o = this.getAttribute("orient");
  102.         if (!o || o == "") this.setAttribute("orient", "horizontal");
  103.       ]]>
  104.       </handler>
  105.     </handlers>
  106.   </binding>
  107.   
  108.   <binding id="tabpanel" extends="xul:deck">
  109.     <implementation>
  110.       <!-- should be defined on deck! -->
  111.       <property name="index"
  112.                 onget="return this.getAttribute('index');"
  113.                 onset="this.setAttribute('index',val); return val;"/>
  114.     </implementation>
  115.   </binding>
  116.  
  117.   <binding id="tab" extends="xul:button">
  118.     <content>
  119.       <xul:box class="tab-box" flex="1" autostretch="never" orient="horizontal">
  120.         <xul:image class="tab-image" inherits="src"/>
  121.         <xul:text class="tab-text" inherits="value,accesskey,crop"/>
  122.       </xul:box>
  123.     </content>
  124.     <implementation>
  125.       <property name="value">
  126.         <getter>
  127.           return this.getAttribute("value");
  128.         </getter>
  129.         <setter>  
  130.           this.setAttribute("value", val);
  131.           return val;
  132.         </setter>
  133.       </property>
  134.       <property name="tabbox" 
  135.                 onget="return this.getAttribute('tabbox');"
  136.                 onset="this.setAttribute('tabbox', val); return val;"/>
  137.       <!-- XXX -->                
  138.       <property name="selected">
  139.         <getter>
  140.           return this.getAttribute("selected") == "true" ? true : false;
  141.         </getter>
  142.         <setter>
  143.           this.setAttribute("selected",val);
  144.           if (this.previousSibling) 
  145.             this.previousSibling.setAttribute("beforeselected",val);
  146.           if (this.nextSibling)
  147.             this.nextSibling.setAttribute("afterselected",val);
  148.           return val;
  149.         </setter>
  150.       </property>
  151.     </implementation>
  152.     <handlers>
  153.       <handler event="click">
  154.       <![CDATA[
  155.         var tabbox = this.parentNode;
  156.         do {
  157.           if (tabbox.localName == "tabbox") break;
  158.           tabbox = tabbox.parentNode;
  159.         } while(tabbox.localName != "tabcontrol");
  160.         tabbox.selectedTab = this;
  161.         if (!this.selected) this.selected = true;
  162.       ]]>
  163.       </handler>
  164.       <handler event="keypress" keycode="vk_left">
  165.       <![CDATA[
  166.         this.parentNode.advanceSelectedTab(-1);
  167.       ]]>
  168.       </handler>
  169.       <handler event="keypress" keycode="vk_right">
  170.       <![CDATA[
  171.         this.parentNode.advanceSelectedTab(1);
  172.       ]]>
  173.       </handler>
  174.       <handler event="keypress" keycode="vk_up">
  175.       <![CDATA[
  176.         this.parentNode.advanceSelectedTab(-1);
  177.       ]]>
  178.       </handler>
  179.       <handler event="keypress" keycode="vk_down">
  180.       <![CDATA[
  181.         this.parentNode.advanceSelectedTab(1);
  182.       ]]>
  183.       </handler>
  184.     </handlers>
  185.   </binding>
  186.   
  187. </bindings>
  188.  
  189.