From 91826d00aaee6161d23473d1b93a86ba438c2948 Mon Sep 17 00:00:00 2001 From: "bugzilla%standard8.demon.co.uk" Date: Sun, 8 Jan 2006 19:45:04 +0000 Subject: [PATCH] Bug 237592 Bookmarks should always show tooltip when hovering with mouse (xpfe version - Bv6a-SM). Patch by Serge GAUTHERIE , r/sr=neil.parkwaycc.co.uk --- xpfe/browser/resources/content/navigator.js | 6 +-- xpfe/browser/resources/content/navigator.xul | 16 +++--- .../resources/content/navigatorOverlay.xul | 18 +++---- .../bookmarks/resources/bookmarksMenu.js | 52 +++++++++---------- 4 files changed, 47 insertions(+), 45 deletions(-) diff --git a/xpfe/browser/resources/content/navigator.js b/xpfe/browser/resources/content/navigator.js index 39b2f94d49f..dba6c482be3 100644 --- a/xpfe/browser/resources/content/navigator.js +++ b/xpfe/browser/resources/content/navigator.js @@ -1010,10 +1010,11 @@ function addGroupmarkAs() BookmarksUtils.addBookmarkForTabBrowser(gBrowser, true); } -function updateGroupmarkMenuitem(id) +function updateGroupmarkCommand() { const disabled = gBrowser.browsers.length == 1; - document.getElementById(id).setAttribute("disabled", disabled); + document.getElementById("Browser:AddGroupmarkAs") + .setAttribute("disabled", disabled); } function readRDFString(aDS,aRes,aProp) @@ -1022,7 +1023,6 @@ function readRDFString(aDS,aRes,aProp) return n ? n.QueryInterface(Components.interfaces.nsIRDFLiteral).Value : ""; } - function ensureDefaultEnginePrefs(aRDF,aDS) { var mPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); diff --git a/xpfe/browser/resources/content/navigator.xul b/xpfe/browser/resources/content/navigator.xul index 2eab196bc95..b65b1c7a03b 100644 --- a/xpfe/browser/resources/content/navigator.xul +++ b/xpfe/browser/resources/content/navigator.xul @@ -291,16 +291,16 @@ label="&bookmarksButton.label;" datasources="rdf:bookmarks rdf:files rdf:localsearch rdf:internetsearch" ref="NC:BookmarksRoot" container="true" flags="dont-test-empty" - oncommand="BookmarksMenu.loadBookmark(event, this.database)" + tooltip="btTooltip" + oncommand="BookmarksMenu.loadBookmark(event, this.database);" onclick="BookmarksMenu.loadBookmarkMiddleClick(event, this.database)" template="bookmarksMenuTemplate" ondraggesture="if (event.target.id=='bookmarks-button') event.preventBubble()"> - - - - - - + + + + + @@ -310,6 +310,7 @@ context="bookmarks-context-menu" template="bookmarksMenuTemplate" datasources="rdf:bookmarks rdf:files rdf:localsearch rdf:internetsearch" ref="NC:PersonalToolbarFolder" flags="dont-test-empty" + tooltip="btTooltip" oncommand="BookmarksUtils.loadBookmarkBrowser(event, this.database)" onclick="BookmarksMenu.loadBookmarkMiddleClick(event, this.database)" rdf:type="http://home.netscape.com/NC-rdf#Folder"> @@ -321,6 +322,7 @@ datasources="rdf:bookmarks rdf:files rdf:localsearch rdf:internetsearch" template="bookmarksMenuTemplate" ref="NC:PersonalToolbarFolder" flags="dont-test-empty" + tooltip="btTooltip" oncommand="BookmarksUtils.loadBookmarkBrowser(event, this.database)" onclick="BookmarksMenu.loadBookmarkMiddleClick(event, this.database)"> + - - - - + onpopupshowing="updateGroupmarkCommand();"> + + + + diff --git a/xpfe/components/bookmarks/resources/bookmarksMenu.js b/xpfe/components/bookmarks/resources/bookmarksMenu.js index 774b5a8293a..2f4c5bbd8b2 100644 --- a/xpfe/components/bookmarks/resources/bookmarksMenu.js +++ b/xpfe/components/bookmarks/resources/bookmarksMenu.js @@ -39,7 +39,6 @@ var BookmarksMenu = { _selection:null, _target:null, _orientation:null, - ////////////////////////////////////////////////////////////////////////// // Fill a context menu popup with menuitems appropriate for the current @@ -53,17 +52,17 @@ var BookmarksMenu = { this._target = this.getBTTarget(target, this._orientation); BookmarksCommand.createContextMenu(aEvent, this._selection); this.onCommandUpdate(); - aEvent.target.addEventListener("mousemove", BookmarksMenuController.onMouseMove, false) + aEvent.target.addEventListener("mousemove", BookmarksMenuController.onMouseMove, false); }, ///////////////////////////////////////////////////////////////////////// // Clean up after closing the context menu popup destroyContextMenu: function (aEvent) { - if (content) - content.focus() + if (content) + content.focus(); BookmarksMenuDNDObserver.onDragRemoveFeedBack(document.popupNode); // needed on cancel - aEvent.target.removeEventListener("mousemove", BookmarksMenuController.onMouseMove, false) + aEvent.target.removeEventListener("mousemove", BookmarksMenuController.onMouseMove, false); }, ///////////////////////////////////////////////////////////////////////////// @@ -277,6 +276,8 @@ var BookmarksMenu = { BookmarksUtils.loadBookmarkBrowser(aEvent, aDS); }, + //////////////////////////////////////////////// + // loads a bookmark with the middle mouse button loadBookmarkMiddleClick: function (aEvent, aDS) { if (aEvent.type != "click" || aEvent.button != 1) @@ -781,33 +782,32 @@ var BookmarksToolbar = } }, - // Fill in tooltips for personal toolbar + // Fill in tooltips for personal toolbar (and Bookmarks menu). fillInBTTooltip: function (tipElement) { + // Don't show a tooltip for non bookmark related elements. + if (!/bookmark/.test(tipElement.className)) + return false; var title = tipElement.label; var url = tipElement.statusText; - if (!title && !url) { - // bail out early if there is nothing to show + // Don't show a tooltip without any data. + if (!title && !url) return false; - } - var tooltipTitle = document.getElementById("btTitleText"); - var tooltipUrl = document.getElementById("btUrlText"); - if (title && title != url) { - tooltipTitle.removeAttribute("hidden"); - tooltipTitle.setAttribute("value", title); - } else { - tooltipTitle.setAttribute("hidden", "true"); - } - if (url) { - tooltipUrl.removeAttribute("hidden"); - tooltipUrl.setAttribute("value", url); - } else { - tooltipUrl.setAttribute("hidden", "true"); - } - return true; // show tooltip + var tooltipElement = document.getElementById("btTitleText"); + tooltipElement.hidden = !title || (title == url); + if (!tooltipElement.hidden) + tooltipElement.setAttribute("value", title); + + tooltipElement = document.getElementById("btUrlText"); + tooltipElement.hidden = !url; + if (!tooltipElement.hidden) + tooltipElement.setAttribute("value", url); + + // Show the tooltip. + return true; } } @@ -826,13 +826,13 @@ var BookmarksToolbarRDFObserver = onChange: function (aDataSource, aSource, aProperty, aOldTarget, aNewTarget) {}, onMove: function (aDataSource, aOldSource, aNewSource, aProperty, aTarget) {}, onBeginUpdateBatch: function (aDataSource) {}, - onEndUpdateBatch: function (aDataSource) { + onEndUpdateBatch: function (aDataSource) + { if (this._overflowTimerInEffect) return; this._overflowTimerInEffect = true; setTimeout(BookmarksToolbar.resizeFunc, 0, null); }, - _overflowTimerInEffect: false, setOverflowTimeout: function (aSource, aProperty) {