home *** CD-ROM | disk | FTP | other *** search
/ Minami 80 / MINAMI80.iso / Extra / DivXInstaller.exe / $PLUGINSDIR / GoogleToolbarFirefox.msi / xpi / chrome / google-toolbar.jar / content / toolbar.xml < prev    next >
Extensible Markup Language  |  2006-05-15  |  7KB  |  181 lines

  1. <?xml version="1.0"?>
  2.  
  3. <bindings id="googleToolbarBindings"
  4.    xmlns="http://www.mozilla.org/xbl"
  5.    xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  6.    xmlns:xbl="http://www.mozilla.org/xbl">
  7.  
  8.   <!-- The google toolbar binding exists to ensure that the chevron menu
  9.        is always the last item in the toolbar. -->
  10.   <binding id="google-toolbar"
  11.            extends="chrome://global/content/bindings/toolbar.xml#toolbar">
  12.     <content>
  13.       <children/>
  14.       <xul:toolbarbutton id="gtbChevron"
  15.                          type="menu"
  16.                          class="chevron"
  17.                          mousethrough="never"
  18.                          collapsed="true">
  19.         <xul:menupopup id="gtbChevronMenu"
  20.                        onpopupshowing="if (event.target == this) GTB_Chevron_onShowMenu(event,this);"/>
  21.       </xul:toolbarbutton>
  22.     </content>
  23.   </binding>
  24.  
  25.   <binding id="google-search-resize">
  26.     <content>
  27.       <xul:vbox inherits="tooltiptext"
  28.                 class="google-search-resizer"/>
  29.     </content>
  30.     <implementation>
  31.       <field name="dragging"/>
  32.       <field name="lastX"/>
  33.  
  34.       <!-- This method is called after the toolbar is customized.-->
  35.       <method name="handleCustomize">
  36.         <body><![CDATA[
  37.  
  38.           // Update the splitter visiblities.
  39.           // Constants to track which side of the searchbox
  40.           // this splitter is on
  41.           var side = {"LEFT": 0, "RIGHT" : 1};
  42.  
  43.           // Figure out which side the splitter is on by its ID
  44.           if (this.id == "gtbSearchBoxResizeLeft") {
  45.             splitterSide = side.LEFT;
  46.           }
  47.           else {
  48.             splitterSide = side.RIGHT;
  49.           }
  50.           
  51.           // Go through the current toolbar and find out what the nearest
  52.           // resizeable element on the other side of the searchbox is.
  53.           // This item will be resized when the searchbox is resized, and
  54.           // if the element doesn't exist, the searchbox probably cannot be
  55.           // resized.
  56.           var isResizeable = {"urlbar-container" : 1,
  57.                               "personal-bookmarks" : 1};
  58.           var currentItem = this.parentNode;
  59.           var itemToResize = null;
  60.           while (currentItem) {
  61.             if (isResizeable[currentItem.id]) {
  62.               itemToResize = currentItem;
  63.               break;
  64.             }
  65.             
  66.             currentItem = splitterSide == side.LEFT ? currentItem.previousSibling
  67.                                                      : currentItem.nextSibling;
  68.           }
  69.  
  70.           // If there is no item to resize, the left resizer should always
  71.           // be off, and the right resizer should be off if it's not in the
  72.           // google toolbar.
  73.           if (itemToResize == null &&
  74.               (splitterSide == side.LEFT || 
  75.                (this.parentNode && 
  76.                 this.parentNode.parentNode &&
  77.                 this.parentNode.parentNode.id != "gtbToolbar"))) {
  78.             this.hidden = true;
  79.           }
  80.           else {
  81.             this.hidden = false;
  82.           }
  83.         ]]></body>
  84.       </method>
  85.  
  86.       <!-- This method is called when the mouse is unclicked, to stop
  87.            dragging if necessary.  It's not implemented as a <handler>
  88.            because the mouse may go up outside of the splitter-->
  89.       <method name="globalMouseUp">
  90.         <parameter name="event"/>
  91.         <body><![CDATA[
  92.           if (this.dragging) {
  93.             // All done dragging.
  94.             this.dragging = false;
  95.  
  96.             // Update any chevron menus that may need to be resized.
  97.             if(this.parentNode &&
  98.                this.parentNode.parentNode) {
  99.               if (this.parentNode.parentNode.id == "gtbToolbar") {
  100.                 GTB_getToolbar().chevron.doResize();
  101.               }
  102.               else if (this.parentNode.parentNode.id == "PersonalToolbar") {
  103.                 BookmarksToolbar.resizeFunc();
  104.               }
  105.             }
  106.           }
  107.         ]]></body>
  108.       </method>
  109.  
  110.       <!-- This method is called when the mouse is moved, to handle
  111.            dragging if necessary.  It's nod implemented as a <handler>
  112.            in case the user drags the mouse outside of the splitter-->
  113.       <method name="globalMouseMove">
  114.         <parameter name="event"/>
  115.         <body><![CDATA[
  116.  
  117.           // Only handle mouse move event if the user is currently dragging.
  118.           if (!this.dragging) {
  119.             return;
  120.           }
  121.  
  122.           // Get the amount moved since the last event.
  123.           // if xDiff > 0, the mouse moved LEFT.
  124.           // if xDiff < 0, the mouse moved RIGHT.
  125.           var xDiff = this.lastX - event.screenX;
  126.  
  127.           // Resize the search box based on whether the left or right
  128.           // slider was dragged and how far.
  129.           var computedStyle = document.defaultView.getComputedStyle(this.parentNode, '');
  130.           var computedWidth = parseInt(computedStyle["width"].replace('px', ''));
  131.  
  132.           // Whether to add or subtract the X movement from the item
  133.           // depends on whether we're adjusting the right or left splitter
  134.           // and whether the item is the search box item or the stored item.
  135.           if (this.id == "gtbSearchBoxResizeLeft") {
  136.             computedWidth += xDiff;
  137.           }
  138.           else {
  139.             computedWidth -= xDiff;
  140.           }
  141.  
  142.           // Don't go any wider than this.
  143.           if (computedWidth > 400) {
  144.             computedWidth = 400;
  145.           }
  146.  
  147.           this.parentNode.setAttribute("width", computedWidth);
  148.  
  149.           // Update the stored mouse X position
  150.           this.lastX = event.screenX;
  151.  
  152.         ]]></body>
  153.       </method>
  154.  
  155.       <constructor>
  156.         <![CDATA[
  157.           this.dragging = false;
  158.  
  159.           // Add events for mouse up and mouse out to the window.
  160.           // It's too easy to accidentally drag the mouse out of the
  161.           // slider area if these events are only handled for the slider.
  162.           var localThis = this;
  163.           var eventHandlerFunc = function handlerFunc(evt){ localThis.globalMouseUp(evt); }
  164.           window.addEventListener("mouseup", eventHandlerFunc, true);
  165.           var eventHandlerFunc2 = function handlerFunc2(evt){ localThis.globalMouseMove(evt); }
  166.           window.addEventListener("mousemove", eventHandlerFunc2, true);
  167.         ]]>
  168.       </constructor>
  169.     </implementation>
  170.     <handlers>
  171.       <handler event="mousedown" button="0">
  172.         <![CDATA[
  173.           this.dragging = true;
  174.           this.lastX = event.screenX;
  175.         ]]>
  176.       </handler>
  177.     </handlers>
  178.   </binding>
  179.  
  180. </bindings>
  181.