зеркало из https://github.com/mozilla/gecko-dev.git
Bug 940116 - part 3: update XUL buttons to have a dynamic tooltip that includes a shortcut (Australis), r=jaws
This commit is contained in:
Родитель
be768e4e7c
Коммит
ca03b6db29
|
@ -15,6 +15,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
|||
"resource://gre/modules/Task.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "CharsetMenu",
|
||||
"resource://gre/modules/CharsetMenu.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ShortcutUtils",
|
||||
"resource://gre/modules/ShortcutUtils.jsm");
|
||||
|
||||
const nsIWebNavigation = Ci.nsIWebNavigation;
|
||||
|
||||
|
@ -4821,6 +4823,44 @@ var gHomeButton = {
|
|||
},
|
||||
};
|
||||
|
||||
const nodeToTooltipMap = {
|
||||
"bookmarks-menu-button": "bookmarksMenuButton.tooltip",
|
||||
#ifdef XP_MACOSX
|
||||
"print-button": "printButton.tooltip",
|
||||
#endif
|
||||
"new-window-button": "newWindowButton.tooltip",
|
||||
"fullscreen-button": "fullscreenButton.tooltip",
|
||||
"tabview-button": "tabviewButton.tooltip",
|
||||
};
|
||||
const nodeToShortcutMap = {
|
||||
"bookmarks-menu-button": "manBookmarkKb",
|
||||
#ifdef XP_MACOSX
|
||||
"print-button": "printKb",
|
||||
#endif
|
||||
"new-window-button": "key_newNavigator",
|
||||
"fullscreen-button": "key_fullScreen",
|
||||
"tabview-button": "key_tabview",
|
||||
};
|
||||
const gDynamicTooltipCache = new Map();
|
||||
function UpdateDynamicShortcutTooltipText(popupTriggerNode) {
|
||||
let label = document.getElementById("dynamic-shortcut-tooltip-label");
|
||||
let nodeId = popupTriggerNode.id;
|
||||
if (!gDynamicTooltipCache.has(nodeId) && nodeId in nodeToTooltipMap) {
|
||||
let strId = nodeToTooltipMap[nodeId];
|
||||
let args = [];
|
||||
if (nodeId in nodeToShortcutMap) {
|
||||
let shortcutId = nodeToShortcutMap[nodeId];
|
||||
let shortcut = document.getElementById(shortcutId);
|
||||
if (shortcut) {
|
||||
args.push(ShortcutUtils.prettifyShortcut(shortcut));
|
||||
}
|
||||
}
|
||||
gDynamicTooltipCache.set(nodeId, gNavigatorBundle.getFormattedString(strId, args));
|
||||
}
|
||||
let desiredLabel = gDynamicTooltipCache.get(nodeId);
|
||||
label.setAttribute("value", desiredLabel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the selected text in the active browser. Leading and trailing
|
||||
* whitespace is removed, and consecutive whitespace is replaced by a single
|
||||
|
|
|
@ -463,6 +463,11 @@
|
|||
<vbox id="downloads-indicator-notification"/>
|
||||
</vbox>
|
||||
</hbox>
|
||||
|
||||
<tooltip id="dynamic-shortcut-tooltip"
|
||||
onpopupshowing="UpdateDynamicShortcutTooltipText(this.triggerNode)">
|
||||
<label id="dynamic-shortcut-tooltip-label"/>
|
||||
</tooltip>
|
||||
</popupset>
|
||||
|
||||
#ifdef CAN_DRAW_IN_TITLEBAR
|
||||
|
@ -744,7 +749,7 @@
|
|||
removable="true"
|
||||
type="menu-button"
|
||||
label="&bookmarksMenuButton.label;"
|
||||
tooltiptext="&bookmarksMenuButton.tooltip;"
|
||||
tooltip="dynamic-shortcut-tooltip"
|
||||
anchor="dropmarker"
|
||||
ondragenter="PlacesMenuDNDHandler.onDragEnter(event);"
|
||||
ondragover="PlacesMenuDNDHandler.onDragOver(event);"
|
||||
|
@ -964,17 +969,17 @@
|
|||
|
||||
<toolbarbutton id="print-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
|
||||
#ifdef XP_MACOSX
|
||||
command="cmd_print"
|
||||
command="cmd_print" tooltip="dynamic-shortcut-tooltip"
|
||||
#else
|
||||
command="cmd_printPreview"
|
||||
command="cmd_printPreview" tooltiptext="&printButton.tooltip;"
|
||||
#endif
|
||||
label="&printButton.label;" tooltiptext="&printButton.tooltip;"/>
|
||||
label="&printButton.label;"/>
|
||||
|
||||
|
||||
<toolbarbutton id="new-window-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
|
||||
label="&newNavigatorCmd.label;"
|
||||
command="key_newNavigator"
|
||||
tooltiptext="&newWindowButton.tooltip;"
|
||||
tooltip="dynamic-shortcut-tooltip"
|
||||
ondrop="newWindowButtonObserver.onDrop(event)"
|
||||
ondragover="newWindowButtonObserver.onDragOver(event)"
|
||||
ondragenter="newWindowButtonObserver.onDragOver(event)"
|
||||
|
@ -984,7 +989,7 @@
|
|||
observes="View:FullScreen"
|
||||
type="checkbox"
|
||||
label="&fullScreenCmd.label;"
|
||||
tooltiptext="&fullScreenButton.tooltip;"/>
|
||||
tooltip="dynamic-shortcut-tooltip"/>
|
||||
|
||||
#ifdef MOZ_SERVICES_SYNC
|
||||
<toolbarbutton id="sync-button"
|
||||
|
|
|
@ -184,7 +184,6 @@ These should match what Safari and other Apple applications use on OS X Lion. --
|
|||
<!ENTITY bookmarksCmd.commandkey "b">
|
||||
|
||||
<!ENTITY bookmarksMenuButton.label "Bookmarks">
|
||||
<!ENTITY bookmarksMenuButton.tooltip "Display your bookmarks">
|
||||
<!ENTITY bookmarksMenuButton.unsorted.label "Unsorted Bookmarks">
|
||||
<!ENTITY viewBookmarksSidebar2.label "View Bookmarks Sidebar">
|
||||
<!ENTITY viewBookmarksToolbar.label "View Bookmarks Toolbar">
|
||||
|
|
|
@ -232,11 +232,27 @@ refreshBlocked.goButton.accesskey=A
|
|||
refreshBlocked.refreshLabel=%S prevented this page from automatically reloading.
|
||||
refreshBlocked.redirectLabel=%S prevented this page from automatically redirecting to another page.
|
||||
|
||||
# General bookmarks button
|
||||
# LOCALIZATION NOTE (bookmarksMenuButton.tooltip):
|
||||
# %S is the keyboard shortcut for "Show All Bookmarks"
|
||||
bookmarksMenuButton.tooltip=Show your bookmarks (%S)
|
||||
# Star button
|
||||
starButtonOn.tooltip=Edit this bookmark
|
||||
starButtonOff.tooltip=Bookmark this page
|
||||
starButtonOverflowed.label=Bookmark This Page
|
||||
|
||||
# Print button tooltip on OS X
|
||||
# LOCALIZATION NOTE (printButton.tooltip):
|
||||
# Use the unicode ellipsis char, \u2026,
|
||||
# or use "..." if \u2026 doesn't suit traditions in your locale.
|
||||
# %S is the keyboard shortcut for "Print"
|
||||
printButton.tooltip=Print this page… (%S)
|
||||
|
||||
# New Window button tooltip
|
||||
# LOCALIZATION NOTE (newWindowButton.tooltip):
|
||||
# %S is the keyboard shortcut for "New Window"
|
||||
newWindowButton.tooltip=Open a new window (%S)
|
||||
|
||||
# Offline web applications
|
||||
offlineApps.available=This website (%S) is asking to store data on your computer for offline use.
|
||||
offlineApps.allow=Allow
|
||||
|
@ -358,6 +374,9 @@ tabview.title=%S - Group Your Tabs
|
|||
# #2 is the number of remaining tabs.
|
||||
tabview.moveToUnnamedGroup.label=#1 and 1 more;#1 and #2 more
|
||||
|
||||
# LOCALIZATION NOTE (tabviewButton.tooltip): %S is the keyboard shortcut for tab groups
|
||||
tabviewButton.tooltip=Group your tabs (%S)
|
||||
|
||||
extensions.{972ce4c6-7e08-4474-a285-3208198ce6fd}.name=Default
|
||||
extensions.{972ce4c6-7e08-4474-a285-3208198ce6fd}.description=The default theme.
|
||||
|
||||
|
@ -414,6 +433,9 @@ fullscreen.entered=%S is now fullscreen.
|
|||
# LOCALIZATION NOTE (fullscreen.rememberDecision): displayed when we enter HTML5 fullscreen mode, %S is the domain name of the focused website (e.g. mozilla.com).
|
||||
fullscreen.rememberDecision=Remember decision for %S
|
||||
|
||||
# LOCALIZATION NOTE (fullscreenButton.tooltip): %S is the keyboard shortcut for full screen
|
||||
fullscreenButton.tooltip=Display the window in full screen (%S)
|
||||
|
||||
service.toolbarbutton.label=Services
|
||||
service.toolbarbutton.tooltiptext=Services
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче