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

  1. <?xml version="1.0"?>
  2.  
  3. <!-- -*- Mode: HTML -*- -->
  4.  
  5. <!-- The contents of this file are subject to the Netscape Public
  6. License Version 1.1 (the "License"); you may not use this file
  7. except in compliance with the License. You may obtain a copy of
  8. the License at http://www.mozilla.org/NPL/
  9.  
  10. Software distributed under the License is distributed on an "AS
  11. IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  12. implied. See the License for the specific language governing
  13. rights and limitations under the License.
  14.  
  15. The Original Code is Mozilla Communicator client code, released
  16. March 31, 1998.
  17.  
  18. The Initial Developer of the Original Code is Netscape
  19. Communications Corporation. Portions created by Netscape are
  20. Copyright (C) 1998-2000 Netscape Communications Corporation. All
  21. Rights Reserved.
  22.  
  23. Original Author:
  24.   Ben Goodger <ben@netscape.com>
  25.  
  26. Contributor(s): 
  27.  
  28. -->
  29.  
  30.  
  31. <bindings id="toolbarBindings"
  32.           xmlns="http://www.mozilla.org/xbl"
  33.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  34.  
  35.   <binding id="toolbargrippy" extends="xul:button">
  36.     <implementation>
  37.       <property name="collapsed">
  38.         <getter>
  39.           return this.getAttribute("moz_grippy_collapsed");
  40.         </getter>
  41.         <setter>
  42.           this.setAttribute("moz_grippy_collapsed", val);
  43.           return val;
  44.         </setter>
  45.       </property>
  46.       <method name="returnNode">
  47.         <parameter name="aNodeA"/>
  48.         <parameter name="aNodeB"/>
  49.         <body>
  50.         <![CDATA[
  51.           var node = this.parentNode;
  52.           while (node && node.localName != "window" && 
  53.                  (node.localName != aNodeA && (node.localName != aNodeB)))  {
  54.             node = node.parentNode;
  55.           }
  56.           return node;
  57.         ]]>
  58.         </body>
  59.       </method>
  60.       <method name="grippyClicked">
  61.         <body>
  62.         <![CDATA[
  63.           var toolbox = this.returnNode("toolbox");
  64.           var toolbar = this.returnNode("toolbar", "menubar");
  65.           if (this.collapsed) 
  66.             toolbox.expandToolbar(this.id);
  67.           else
  68.             toolbox.collapseToolbar(toolbar);
  69.         ]]>
  70.         </body>
  71.       </method>
  72.     </implementation>  
  73.     <handlers>
  74.       <handler event="click">
  75.       <![CDATA[
  76.         this.grippyClicked();
  77.       ]]>
  78.       </handler>
  79.     </handlers>
  80.   </binding>  
  81.  
  82.   <binding id="toolbox" extends="xul:box">
  83.     <content orient="vertical">
  84.       <xul:box orient="vertical" flex="1" class="toolbar-internal-box">
  85.         <children/>
  86.       </xul:box>
  87.       <xul:box tbattr="collapsed-tray-holder" class="collapsed-tray-holder" moz-collapsed="true">
  88.         <xul:box tbattr="collapsed-tray" class="collapsed-tray"/>
  89.         <xul:spring flex="1" class="collapsed-tray-spring"/>
  90.       </xul:box>
  91.     </content>
  92.     <implementation>
  93.       <method name="collapseToolbar">
  94.         <parameter name="toolbar"/>
  95.         <body>
  96.         <![CDATA[
  97.           const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  98.           try {
  99.             this.createCollapsedGrippy(toolbar);
  100.             toolbar.setAttribute("moz-collapsed", "true");
  101.             document.persist(toolbar.id, "moz-collapsed");
  102.           }
  103.           catch(e) {
  104.           }
  105.         ]]>
  106.         </body>
  107.       </method>
  108.       <method name="expandToolbar">
  109.         <parameter name="aGrippyID"/>
  110.         <body>
  111.         <![CDATA[
  112.           var idString = aGrippyID.substring("moz_tb_collapsed_".length, aGrippyID.length);
  113.           var toolbar = document.getElementById(idString);
  114.           toolbar.setAttribute("moz-collapsed", "false");
  115.           var collapsedTray = this.findNodeByAttribute("tbattr", "collapsed-tray");
  116.           var collapsedToolbar = document.getElementById("moz_tb_collapsed_" + toolbar.id);
  117.           collapsedTray.removeChild(collapsedToolbar);
  118.           if (!collapsedTray.hasChildNodes()) 
  119.             this.findNodeByAttribute("tbattr", "collapsed-tray-holder").setAttribute("moz-collapsed", "true");
  120.           document.persist(toolbar.id, "moz-collapsed");
  121.         ]]>
  122.         </body>
  123.       </method>
  124.       <method name="findNodeByAttribute">
  125.         <parameter name="aAttribute"/>
  126.         <parameter name="aValue"/>
  127.         <body>
  128.         <![CDATA[
  129.           var nodes = document.getAnonymousNodes(this);
  130.           for (var i = 0; i < nodes.length; i++) {
  131.             if (nodes[i].getAttribute(aAttribute) == aValue)
  132.               return nodes[i];
  133.             else {
  134.               var subnodes = nodes[i].getElementsByAttribute(aAttribute, aValue);
  135.               if (!subnodes.length) continue;
  136.               return subnodes[0];
  137.             }
  138.           }
  139.           return null;
  140.         ]]>
  141.         </body>
  142.       </method>
  143.       <method name="createCollapsedGrippy">
  144.         <parameter name="aToolbar"/>
  145.         <body>
  146.         <![CDATA[
  147.           const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  148.           try {
  149.             var grippy = aToolbar.findNodeByAttribute("tbattr", "toolbar-grippy");
  150.             var boxObject = grippy.boxObject.QueryInterface(Components.interfaces.nsIBoxObject);
  151.             var collapsedGrippy = document.createElementNS(XUL_NS, "toolbargrippy");
  152.             if (collapsedGrippy) {
  153.               var width = boxObject.height > 20 ? boxObject.height : 23;
  154.               var height = boxObject.width > 10 ? boxObject.width : 12;
  155.               var styleString = "width: " + width + "px; height: " + height + "px;";
  156.               collapsedGrippy.setAttribute("style", styleString);
  157.               collapsedGrippy.setAttribute("tooltip", aToolbar.getAttribute("grippytooltip"));
  158.               collapsedGrippy.setAttribute("tooltiptext", aToolbar.getAttribute("grippytooltiptext"));
  159.               collapsedGrippy.setAttribute("id", "moz_tb_collapsed_" + aToolbar.id);
  160.               collapsedGrippy.collapsed = true;
  161.               collapsedGrippy.setAttribute("tbgrippy-collapsed", "true");
  162.               var collapsedTrayHolder = this.findNodeByAttribute("tbattr", "collapsed-tray-holder");
  163.               if (collapsedTrayHolder.getAttribute("moz-collapsed") == "true")
  164.                 collapsedTrayHolder.removeAttribute("moz-collapsed");
  165.               this.findNodeByAttribute("tbattr", "collapsed-tray").appendChild(collapsedGrippy);
  166.               collapsedGrippy = document.getElementById("moz_tb_collapsed_" + aToolbar.id);
  167.             }
  168.           }
  169.           catch (e) {
  170.             throw e;
  171.           }
  172.         ]]>        
  173.         </body>
  174.       </method>
  175.       <method name="init">
  176.         <parameter name="aEvent"/>
  177.         <body>
  178.         <![CDATA[
  179.           for (var i = 0; i < this.childNodes.length; i++) {
  180.             if (this.childNodes[i].getAttribute("moz-collapsed") == "true")
  181.               this.createCollapsedGrippy(this.childNodes[i]);
  182.           }
  183.         ]]>
  184.         </body>
  185.       </method>
  186.       <property name="deferAttached">
  187.         <getter>
  188.           return this.getAttribute("deferattached");
  189.         </getter>
  190.         <setter>
  191.           this.setAttribute("deferattached", val);
  192.           return val;
  193.         </setter>
  194.       </property>
  195.     </implementation>
  196.     <handlers>
  197.       <handler event="bindingattached">
  198.         this.init(event);
  199.       </handler>
  200.     </handlers>
  201.   </binding>
  202.  
  203.   <binding id="toolbar" extends="xul:box">
  204.     <content>
  205.       <xul:toolbargrippy inherits="tooltiptext=grippytooltiptext,tooltip=grippytooltip,last-toolbar"
  206.                          tbattr="toolbar-grippy"
  207.                          class="toolbar-grippy"/>
  208.       <xul:box flex="1" class="toolbar-holder" inherits="collapsed,last-toolbar,orient=tborient,autostretch=tbautostretch" autostretch="never">
  209.         <children/>
  210.       </xul:box>
  211.     </content>
  212.     <implementation>
  213.       <method name="findNodeByAttribute">
  214.         <parameter name="aAttribute"/>
  215.         <parameter name="aValue"/>
  216.         <body>
  217.         <![CDATA[
  218.           var nodes = document.getAnonymousNodes(this);
  219.           for (var i = 0; i < nodes.length; i++) {
  220.             if (nodes[i].getAttribute(aAttribute) == aValue)
  221.               return nodes[i];
  222.             else {
  223.               var subnodes = nodes[i].getElementsByAttribute(aAttribute, aValue);
  224.               return subnodes.length ? subnodes[0] : null;
  225.             }
  226.           }
  227.           return null;
  228.         ]]>
  229.         </body>
  230.       </method>
  231.     </implementation>
  232.   </binding>
  233.  
  234.   <binding id="menubar" extends="xul:menubar">
  235.     <content>
  236.       <xul:toolbargrippy inherits="tooltiptext=grippytooltiptext,tooltip=grippytooltip,last-toolbar"
  237.                          tbattr="toolbar-grippy" class="toolbar-grippy"/>
  238.       <xul:box flex="1" class="toolbar-holder" inherits="collapsed,last-toolbar" autostretch="never">
  239.         <children/>
  240.       </xul:box>
  241.     </content>
  242.     <implementation>
  243.       <method name="findNodeByAttribute">
  244.         <parameter name="aAttribute"/>
  245.         <parameter name="aValue"/>
  246.         <body>
  247.         <![CDATA[
  248.           var nodes = document.getAnonymousNodes(this);
  249.           for (var i = 0; i < nodes.length; i++) {
  250.             if (nodes[i].getAttribute(aAttribute) == aValue)
  251.               return nodes[i];
  252.             else {
  253.               var subnodes = nodes[i].getElementsByAttribute(aAttribute, aValue);
  254.               return subnodes.length ? subnodes[0] : null;
  255.             }
  256.           }
  257.           return null;
  258.         ]]>
  259.         </body>
  260.       </method>
  261.     </implementation>
  262.   </binding>
  263.           
  264. </bindings>          
  265.