home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / firefox-3.0.14 / chrome / browser.jar / content / browser / bookmarks / sidebarUtils.js < prev   
Encoding:
JavaScript  |  2008-03-14  |  3.4 KB  |  90 lines

  1. //@line 39 "/build/buildd/firefox-3.0-3.0.14+build2+nobinonly/build-tree/mozilla/browser/components/places/content/sidebarUtils.js"
  2.  
  3. var SidebarUtils = {
  4.   handleTreeClick: function SU_handleTreeClick(aTree, aEvent, aGutterSelect) {
  5.     // right-clicks are not handled here
  6.     if (aEvent.button == 2)
  7.       return;
  8.  
  9.     var tbo = aTree.treeBoxObject;
  10.     var row = { }, col = { }, obj = { };
  11.     tbo.getCellAt(aEvent.clientX, aEvent.clientY, row, col, obj);
  12.  
  13.     if (row.value == -1 || obj.value == "twisty")
  14.       return;
  15.  
  16.     var mouseInGutter = false;
  17.     if (aGutterSelect) {
  18.       var x = { }, y = { }, w = { }, h = { };
  19.       tbo.getCoordsForCellItem(row.value, col.value, "image",
  20.                                x, y, w, h);
  21.       mouseInGutter = aEvent.clientX < x.value;
  22.     }
  23.  
  24. //@line 64 "/build/buildd/firefox-3.0-3.0.14+build2+nobinonly/build-tree/mozilla/browser/components/places/content/sidebarUtils.js"
  25.     var modifKey = aEvent.ctrlKey || aEvent.shiftKey;
  26. //@line 66 "/build/buildd/firefox-3.0-3.0.14+build2+nobinonly/build-tree/mozilla/browser/components/places/content/sidebarUtils.js"
  27.  
  28.     var isContainer = tbo.view.isContainer(row.value);
  29.     var openInTabs = isContainer &&
  30.                      (aEvent.button == 1 ||
  31.                       (aEvent.button == 0 && modifKey)) &&
  32.                      PlacesUtils.hasChildURIs(tbo.view.nodeForTreeIndex(row.value));
  33.  
  34.     if (aEvent.button == 0 && isContainer && !openInTabs) {
  35.       tbo.view.toggleOpenState(row.value);
  36.       return;
  37.     }
  38.     else if (!mouseInGutter && openInTabs &&
  39.             aEvent.originalTarget.localName == "treechildren") {
  40.       tbo.view.selection.select(row.value);
  41.       PlacesUIUtils.openContainerNodeInTabs(aTree.selectedNode, aEvent);
  42.     }
  43.     else if (!mouseInGutter && !isContainer &&
  44.              aEvent.originalTarget.localName == "treechildren") {
  45.       // Clear all other selection since we're loading a link now. We must
  46.       // do this *before* attempting to load the link since openURL uses
  47.       // selection as an indication of which link to load.
  48.       tbo.view.selection.select(row.value);
  49.       PlacesUIUtils.openNodeWithEvent(aTree.selectedNode, aEvent);
  50.     }
  51.   },
  52.  
  53.   handleTreeKeyPress: function SU_handleTreeKeyPress(aEvent) {
  54.     if (aEvent.keyCode == KeyEvent.DOM_VK_RETURN)
  55.       PlacesUIUtils.openNodeWithEvent(aEvent.target.selectedNode, aEvent);
  56.   },
  57.  
  58.   /**
  59.    * The following function displays the URL of a node that is being
  60.    * hovered over.
  61.    */
  62.   handleTreeMouseMove: function SU_handleTreeMouseMove(aEvent) {
  63.     if (aEvent.target.localName != "treechildren")
  64.       return;
  65.  
  66.     var tree = aEvent.target.parentNode;
  67.     var tbo = tree.treeBoxObject;
  68.     var row = { }, col = { }, obj = { };
  69.     tbo.getCellAt(aEvent.clientX, aEvent.clientY, row, col, obj);
  70.  
  71.     // row.value is -1 when the mouse is hovering an empty area within the tree.
  72.     // To avoid showing a URL from a previously hovered node,
  73.     // for a currently hovered non-url node, we must clear the URL from the
  74.     // status bar in these cases.
  75.     if (row.value != -1) {
  76.       var cell = tree.view.nodeForTreeIndex(row.value);
  77.       if (PlacesUtils.nodeIsURI(cell))
  78.         window.top.XULBrowserWindow.setOverLink(cell.uri, null);
  79.       else
  80.         this.clearURLFromStatusBar();
  81.     }
  82.     else
  83.       this.clearURLFromStatusBar();
  84.   },
  85.  
  86.   clearURLFromStatusBar: function SU_clearURLFromStatusBar() {
  87.     window.top.XULBrowserWindow.setOverLink("", null);  
  88.   }
  89. };
  90.