Implement CTRL+enter www/com completion in the URL bar.

This commit is contained in:
hyatt@netscape.com
2002-10-18 20:30:53 +00:00
parent 51a10b3c6c
commit 27ca6c20eb
4 changed files with 18 additions and 21 deletions

View File

@@ -768,10 +768,15 @@ function BrowserLoadURL(aTriggeringEvent)
if (url.match(/^view-source:/)) {
BrowserViewSourceOfURL(url.replace(/^view-source:/, ""), null, null);
} else {
if (aTriggeringEvent && 'ctrlKey' in aTriggeringEvent &&
aTriggeringEvent.ctrlKey)
// Tack www. and .com on.
url = gURLBar.value = "www." + url + ".com";
if (gPrefService && gPrefService.getBoolPref("browser.tabs.opentabfor.urlbar") &&
getBrowser().localName == "tabbrowser" &&
aTriggeringEvent && 'ctrlKey' in aTriggeringEvent &&
aTriggeringEvent.ctrlKey) {
aTriggeringEvent && 'shiftKey' in aTriggeringEvent &&
aTriggeringEvent.shiftKey) {
var t = getBrowser().addTab(getShortcutOrURI(url)); // open link in new tab
getBrowser().selectedTab = t;
}
@@ -4138,7 +4143,7 @@ function openNewTabOrWindow(event, href, linkNode)
if (gPrefService && gPrefService.getBoolPref("browser.tabs.opentabfor.middleclick") &&
("getBrowser" in window) && getBrowser().localName == "tabbrowser") {
var loadInBackground = gPrefService.getBoolPref("browser.tabs.loadInBackground");
if (event.shiftKey)
if (event.ctrlKey)
loadInBackground = !loadInBackground;
var theTab = getBrowser().addTab(href, getReferrer(document));
if (!loadInBackground)
@@ -4173,19 +4178,11 @@ function handleLinkClick(event, href, linkNode)
{
switch (event.button) {
case 0: // if left button clicked
if (event.metaKey || event.ctrlKey) { // and meta or ctrl are down
if (event.metaKey || event.shiftKey) { // and meta or shift are down
if (openNewTabOrWindow(event, href, linkNode))
return true;
}
var saveModifier = true;
if (gPrefService) {
try {
saveModifier = gPrefService.getBoolPref("ui.key.saveLink.shift");
}
catch(ex) {
}
}
saveModifier = saveModifier ? event.shiftKey : event.altKey;
var saveModifier = event.altKey;
if (saveModifier) { // if saveModifier is down
saveURL(href, linkNode ? gatherTextUnder(linkNode) : "");
@@ -4211,8 +4208,8 @@ function middleMousePaste( event )
if (!url)
return false;
// On ctrl-middleclick, open in new window or tab.
if (event.ctrlKey)
// On shift-middleclick, open in new window or tab.
if (event.shiftKey)
return openNewTabOrWindow(event, url, null);
// If ctrl wasn't down, then just load the url in the current win/tab.

View File

@@ -1607,8 +1607,8 @@ var BookmarksUtils = {
var button = aEvent.type == "command" || aEvent.type == "keypress"? 0:aEvent.button;
if (button == 2)
return "";
if (aEvent.metaKey || aEvent.ctrlKey || button == 1)
if (aEvent.shiftKey)
if (aEvent.metaKey || aEvent.shiftKey || button == 1)
if (aEvent.ctrlKey)
return "window";
else
return "tab";

View File

@@ -105,12 +105,12 @@
<tree id="historyTree" flex="1" class="plain"
context="historyMenu" persist="ref"
datasources="rdf:history" ref="NC:HistoryByDate" flags="dont-build-content"
onkeypress="if (event.keyCode == 13) OpenURL(event.ctrlKey || event.metaKey);"
onkeypress="if (event.keyCode == 13) OpenURL(event.shiftKey || event.metaKey);"
onselect="this.treeBoxObject.view.selectionChanged();
historyOnSelect();"
hidecolumnpicker="true"
ondraggesture="if (event.originalTarget.localName == 'treechildren') nsDragAndDrop.startDrag(event, historyDNDObserver);"
ondblclick="if (validClickConditions(event)) OpenURL(event.ctrlKey || event.metaKey);">
ondblclick="if (validClickConditions(event)) OpenURL(event.shiftKey || event.metaKey);">
<template>
<rule>
<treechildren>

View File

@@ -3,7 +3,7 @@
<!ENTITY autoHide.label "Hide the tab bar when only one tab is open">
<!ENTITY background.label "Load links in the background">
<!ENTITY openTabs.label "Open tabs instead of windows for">
<!ENTITY middleClick.label "Middle-click or control-click of links in a Web page">
<!ENTITY urlbar.label "Control+Enter in the Location bar">
<!ENTITY middleClick.label "Middle-click or shift-click of links in a Web page">
<!ENTITY urlbar.label "Shift+Enter in the Location bar">
<!ENTITY openFolder.label "When opening a bookmark folder in tabs">
<!ENTITY openFolderReplace.label "Replace the current set of tabs">