Bug 244371 - Show a tooltip in Bookmarks and History sidebars, r=mak

This commit is contained in:
Gabriele Best 2009-09-05 01:36:07 +02:00
parent 1e69abea85
commit cbf7124ed0
6 changed files with 56 additions and 25 deletions

View File

@ -464,7 +464,7 @@
onpopupshowing="HistoryMenu.onPopupShowing(event);"
onpopuphidden="HistoryMenu.onPopupHidden(event);"
place="place:redirectsMode=2&sort=4&maxResults=10"
tooltip="btTooltip">
tooltip="bhTooltip">
<menuitem id="historyMenuBack"
label="&backCmd.label;"
#ifdef XP_MACOSX
@ -526,7 +526,7 @@
oncommand="BookmarksEventHandler.onCommand(event);"
onclick="BookmarksEventHandler.onClick(event);"
onpopupshowing="BookmarksEventHandler.onPopupShowing(event);"
tooltip="btTooltip">
tooltip="bhTooltip">
<menuitem id="menu_bookmarkThisPage"
label="&bookmarkThisPageCmd.label;"
command="Browser:AddBookmarkAs"

View File

@ -920,26 +920,47 @@ var BookmarksEventHandler = {
}
},
fillInBTTooltip: function(aTipElement) {
if (!aTipElement.node)
fillInBHTooltip: function(aDocument, aEvent) {
var node;
var cropped = false;
if (aDocument.tooltipNode.localName == "treechildren") {
var tree = aDocument.tooltipNode.parentNode;
var row = {}, column = {};
var tbo = tree.treeBoxObject;
tbo.getCellAt(aEvent.clientX, aEvent.clientY, row, column, {});
node = tree.view.nodeForTreeIndex(row.value);
cropped = tbo.isCellCropped(row.value, column.value);
}
else
node = aDocument.tooltipNode.node;
if (!node)
return false;
//Show tooltips only for URL items
if (!PlacesUtils.nodeIsURI(aTipElement.node))
var title = node.title;
var url;
// Show URL only for URI-type nodes.
if (PlacesUtils.nodeIsURI(node))
url = node.uri;
// Show tooltip for containers only if their title is cropped.
if (!cropped && !url)
return false;
var title = aTipElement.node.title;
var url = aTipElement.node.uri;
var tooltipTitle = document.getElementById("btTitleText");
tooltipTitle.hidden = !title || (title == url);
var tooltipTitle = aDocument.getElementById("bhtTitleText");
tooltipTitle.hidden = (!title || (title == url));
if (!tooltipTitle.hidden)
tooltipTitle.textContent = title;
var tooltipUrl = document.getElementById("btUrlText");
tooltipUrl.value = url;
var tooltipUrl = aDocument.getElementById("bhtUrlText");
tooltipUrl.hidden = !url;
if (!tooltipUrl.hidden)
tooltipUrl.value = url;
//Show tooltip
// Show tooltip.
return true;
}
};

View File

@ -284,14 +284,8 @@
</panel>
</popupset>
<!-- bookmarks toolbar tooltip -->
<tooltip id="btTooltip" noautohide="true"
onpopupshowing="return BookmarksEventHandler.fillInBTTooltip(document.tooltipNode)">
<vbox id="btTooltipTextBox" flex="1">
<label id="btTitleText" class="tooltip-label" />
<label id="btUrlText" crop="center" class="tooltip-label" />
</vbox>
</tooltip>
<!-- Bookmarks and history tooltip -->
<tooltip id="bhTooltip"/>
<toolbox id="navigator-toolbox" class="toolbox-top" mode="icons"
#ifdef WINCE
@ -457,7 +451,7 @@
onclick="BookmarksEventHandler.onClick(event);"
oncommand="BookmarksEventHandler.onCommand(event);"
onpopupshowing="BookmarksEventHandler.onPopupShowing(event);"
tooltip="btTooltip"/>
tooltip="bhTooltip"/>
</toolbaritem>
<toolbarbutton id="downloads-button" class="toolbarbutton-1 chromeclass-toolbar-additional"

View File

@ -61,6 +61,9 @@
<commandset id="editMenuCommands"/>
<popup id="placesContext"/>
<!-- Bookmarks and history tooltip -->
<tooltip id="bhTooltip"/>
<hbox align="center">
<label value="&search.label;" accesskey="&search.accesskey;" control="search-box"/>
<textbox id="search-box" flex="1" type="search" class="compact"
@ -79,6 +82,7 @@
<treecols>
<treecol id="title" flex="1" primary="true" hideheader="true"/>
</treecols>
<treechildren id="bookmarks-view-children" view="bookmarks-view" class="sidebar-placesTreechildren" flex="1"/>
<treechildren id="bookmarks-view-children" view="bookmarks-view"
class="sidebar-placesTreechildren" flex="1" tooltip="bhTooltip"/>
</tree>
</page>

View File

@ -77,6 +77,9 @@
<!-- required to overlay the context menu -->
<popup id="placesContext" />
<!-- Bookmarks and history tooltip -->
<tooltip id="bhTooltip"/>
<hbox align="center">
<label value="&find.label;" accesskey="&find.accesskey;"
control="search-box"/>
@ -122,6 +125,6 @@
<treecols>
<treecol id="title" flex="1" primary="true" hideheader="true"/>
</treecols>
<treechildren class="sidebar-placesTreechildren" flex="1"/>
<treechildren class="sidebar-placesTreechildren" flex="1" tooltip="bhTooltip"/>
</tree>
</page>

View File

@ -60,6 +60,15 @@
<script type="application/x-javascript"
src="chrome://global/content/nsDragAndDrop.js"/>
<!-- Bookmarks and history tooltip -->
<tooltip id="bhTooltip" noautohide="true"
onpopupshowing="return window.top.BookmarksEventHandler.fillInBHTooltip(document, event)">
<vbox id="bhTooltipTextBox" flex="1">
<label id="bhtTitleText" class="tooltip-label" />
<label id="bhtUrlText" crop="center" class="tooltip-label" />
</vbox>
</tooltip>
<commandset id="placesCommands"
commandupdater="true"
events="focus,sort,places"