зеркало из https://github.com/mozilla/pjs.git
6085, middle mouse should load link in new window (r=alecf,puetzk@iastate.edu);
24571, middle-mouse paste should be pref-able (r=mcafee); plus nonmodal pref window (r=pavlov).
This commit is contained in:
Родитель
6d367fc652
Коммит
5e239d84f5
|
@ -877,19 +877,58 @@ function BrowserEditBookmarks()
|
|||
return url;
|
||||
}
|
||||
|
||||
function browserLoadClipboardURL(target)
|
||||
function enclosingLink(node)
|
||||
{
|
||||
if (!((target.tagName.toUpperCase() == "INPUT"
|
||||
&& (target.type == "" || target.type.toUpperCase() == "TEXT"))
|
||||
|| target.tagName.toUpperCase() == "TEXTAREA"))
|
||||
while (node)
|
||||
{
|
||||
var url = readFromClipboard();
|
||||
dump ("URL on clipboard: '" + url + "'; length = " + url.length + "\n");
|
||||
if (url.length > 0)
|
||||
var nodeName = node.nodeName;
|
||||
if (nodeName == "")
|
||||
return "";
|
||||
nodeName = nodeName.toLowerCase();
|
||||
if (nodeName == "" || nodeName == "body"
|
||||
|| nodeName == "html" || nodeName == "#document")
|
||||
return "";
|
||||
var href = node.href;
|
||||
if (nodeName == "a" && href != "")
|
||||
return href;
|
||||
node = node.parentNode;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function browserHandleMiddleClick(event)
|
||||
{
|
||||
var target = event.target;
|
||||
if (pref.GetBoolPref("middlemouse.openNewWindow"))
|
||||
{
|
||||
var href = enclosingLink(target);
|
||||
if (href != "")
|
||||
{
|
||||
var urlBar = document.getElementById("urlbar");
|
||||
urlBar.value = url;
|
||||
BrowserLoadURL();
|
||||
openNewWindowWith(href);
|
||||
event.preventBubble();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (pref.GetBoolPref("middlemouse.paste"))
|
||||
{
|
||||
var tagName = target.tagName;
|
||||
if (tagName) tagName = tagName.toLowerCase();
|
||||
var type = target.type;
|
||||
if (type) type = type.toLowerCase();
|
||||
if (!((tagName == "input"
|
||||
&& (type == "" || type == "text" || type == "password"))
|
||||
|| tagName == "textarea"))
|
||||
{
|
||||
var url = readFromClipboard();
|
||||
//dump ("Loading URL on clipboard: '" + url + "'; length = " + url.length + "\n");
|
||||
if (url.length > 0)
|
||||
{
|
||||
var urlBar = document.getElementById("urlbar");
|
||||
urlBar.value = url;
|
||||
BrowserLoadURL();
|
||||
event.preventBubble();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -422,7 +422,7 @@ Contributor(s): ______________________________________. -->
|
|||
<splitter id="sidebar-splitter" chromeclass="extrachrome" />
|
||||
|
||||
<box id="appcontent" align="vertical" flex="100%"
|
||||
onclick="if (event.button==2) browserLoadClipboardURL(event.target);"
|
||||
onclick="if (event.button==2) browserHandleMiddleClick(event);"
|
||||
ondragover="return DragOverContentArea(event);"
|
||||
ondragdrop="return DropOnContentArea(event);">
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче