Auto-show for the Links Toolbar. Bug 102832. Patch by sballard@netreach.net (Stuart Ballard). r=gerv, sr=hewitt, a=asa.

git-svn-id: svn://10.0.0.236/trunk@210931 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
gerv%gerv.net 2006-09-14 06:00:27 +00:00
parent 131ee8e690
commit 79399171cd
5 changed files with 68 additions and 11 deletions

View File

@ -21,6 +21,7 @@
* Contributor(s):
* Christopher Hoess <choess@force.stwing.upenn.edu>
* Tim Taylor <tim@tool-man.org>
* Stuart Ballard <sballard@netreach.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -47,6 +48,7 @@
function LinkToolbarHandler()
{
this.items = new Array();
this.hasItems = false;
}
LinkToolbarHandler.prototype.handleLinks =
@ -74,6 +76,8 @@ function(element)
if (linkElement.isIgnored()) return;
this.hasItems = true;
var relAttributes = linkElement.rel.split(" ");
for (var i = 0; i < relAttributes.length; i++) {
var linkType = LinkToolbarHandler.getLinkType(relAttributes[i]);
@ -159,6 +163,7 @@ function()
{
for (var linkType in this.items)
this.items[linkType].clear();
this.hasItems = false;
}
const linkToolbarHandler = new LinkToolbarHandler();

View File

@ -22,6 +22,7 @@
* Christopher Hoess <choess@force.stwing.upenn.edu>
* Tim Taylor <tim@tool-man.org>
* Henri Sivonen <henris@clinet.fi>
* Stuart Ballard <sballard@netreach.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -62,10 +63,10 @@ function()
LinkToolbarUI.prototype.isLinkToolbarEnabled =
function()
{
if (document.getElementById("cmd_viewlinktoolbar").getAttribute("checked") == "true")
return true;
else
if (document.getElementById("linktoolbar").getAttribute("hidden") == "true")
return false;
else
return true;
}
LinkToolbarUI.prototype.doRefresh =
@ -102,6 +103,9 @@ function()
currentNode = currentNode.nextSibling;
}
}
document.getElementById("linktoolbar").
setAttribute("hasitems", linkToolbarHandler.hasItems);
}
LinkToolbarUI.prototype.getLinkElements =
@ -146,6 +150,9 @@ function()
LinkToolbarUI.prototype.clicked =
function(event)
{
// Only handle primary click. Change this if we get a context menu
if (0 != event.button) return;
// Return if this is one of the menubuttons.
if (event.target.getAttribute("type") == "menu") return;
@ -168,9 +175,9 @@ function(event)
// functions for twiddling XUL elements in the toolbar
LinkToolbarUI.prototype.toggleLinkToolbar =
function()
function(checkedItem)
{
goToggleToolbar('linktoolbar', 'cmd_viewlinktoolbar');
this.goToggleTristateToolbar("linktoolbar", checkedItem);
if (this.isLinkToolbarEnabled())
this.doRefresh();
else
@ -188,5 +195,25 @@ function()
{
document.getElementById("misc-seperator").setAttribute("collapsed", "true");
}
LinkToolbarUI.prototype.initLinkbarVisibilityMenu =
function()
{
var state = document.getElementById("linktoolbar").getAttribute("hidden");
if (!state)
state = "maybe";
var checkedItem = document.getElementById("cmd_viewlinktoolbar_" + state);
checkedItem.setAttribute("checked", true);
checkedItem.checked = true;
}
LinkToolbarUI.prototype.goToggleTristateToolbar =
function(id, checkedItem)
{
var toolbar = document.getElementById(id);
if (toolbar)
{
toolbar.setAttribute("hidden", checkedItem.value);
document.persist(id, "hidden");
}
}
const linkToolbarUI = new LinkToolbarUI;

View File

@ -22,6 +22,7 @@
- Contributor(s):
- Christopher Hoess <choess@force.stwing.upenn.edu>
- Tim Taylor <tim@tool-man.org>
- Stuart Ballard <sballard@netreach.net>
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
@ -38,6 +39,7 @@
- ***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://navigator/skin/linkToolbar.css" type="text/css"?>
<?xml-stylesheet href="chrome://navigator/content/navigator.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://navigator/locale/linkToolbar.dtd">
@ -61,18 +63,28 @@
]]>
</script>
<broadcasterset id="navBroadcasters">
<broadcaster id="cmd_viewlinktoolbar" oncommand="linkToolbarUI.toggleLinkToolbar();" checked="true" />
</broadcasterset>
<menupopup id="view_toolbars_popup">
<menuitem label="&linkToolbar.label;" class="menuitem-iconic" type="checkbox" observes="cmd_viewlinktoolbar" position="3" />
<menu label="&linkToolbar.label;" position="3"
oncommand="linkToolbarUI.toggleLinkToolbar(event.target)"
onpopupshowing="linkToolbarUI.initLinkbarVisibilityMenu()">
<menupopup>
<menuitem label="&linkToolbarAlways.label;"
class="menuitem-iconic" type="radio" value="false"
name="cmd_viewlinktoolbar" id="cmd_viewlinktoolbar_false" />
<menuitem label="&linkToolbarAsNeeded.label;"
class="menuitem-iconic" type="radio" value="maybe"
name="cmd_viewlinktoolbar" id="cmd_viewlinktoolbar_maybe" />
<menuitem label="&linkToolbarNever.label;"
class="menuitem-iconic" type="radio" value="true"
name="cmd_viewlinktoolbar" id="cmd_viewlinktoolbar_true" />
</menupopup>
</menu>
</menupopup>
<toolbox id="navigator-toolbox">
<toolbar id="linktoolbar" class="chromeclass-directories"
onclick="event.preventBubble(); return linkToolbarUI.clicked(event);"
tbautostretch="always">
tbautostretch="always" hidden="maybe">
<toolbarbutton id="link-top" class="bookmark-item"
label="&topButton.label;" disabled="true" tooltip="aTooltip" />

View File

@ -27,6 +27,13 @@ window[chromehidden~="extrachrome"] .chromeclass-extrachrome {
display: none;
}
/* ::::: Hide the link toolbar if it is set to autohide and has no items. ::::: */
#linktoolbar[hidden="maybe"][hasitems="false"]
{
display: none;
}
/* ::::: urlbar autocomplete ::::: */
#urlbar {

View File

@ -20,6 +20,7 @@
-
- Contributor(s):
- Eric Hodel <drbrain@segment7.net>
- Stuart Ballard <sballard@netreach.net>
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
@ -38,6 +39,11 @@
<!-- Link Toolbar Title -->
<!ENTITY linkToolbar.label "Link Toolbar">
<!-- Link Toolbar visibility options -->
<!ENTITY linkToolbarAlways.label "Show Always">
<!ENTITY linkToolbarAsNeeded.label "Show Only As Needed">
<!ENTITY linkToolbarNever.label "Hide Always">
<!-- Toolbar buttons, menus, and menuitems -->
<!ENTITY topButton.label "Top">
<!ENTITY upButton.label "Up">