From 2882ccc967eec7d4d52e600138a2aa6368e1e21f Mon Sep 17 00:00:00 2001 From: "mjudge%netscape.com" Date: Wed, 2 Aug 2000 22:07:00 +0000 Subject: [PATCH] 15665 beta3+ Javascript selecting a link when dragging. --- xpfe/browser/resources/content/navigator.js | 13 +++++--- xpfe/browser/resources/content/navigatorDD.js | 31 ++++++++++++++++++- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/xpfe/browser/resources/content/navigator.js b/xpfe/browser/resources/content/navigator.js index 9eed7aaed57..0522a7aab1d 100644 --- a/xpfe/browser/resources/content/navigator.js +++ b/xpfe/browser/resources/content/navigator.js @@ -1204,17 +1204,17 @@ function BrowserChangeTextSize(newSize) { var nodeName = node.nodeName; if (nodeName == "") - return ""; + return null; nodeName = nodeName.toLowerCase(); if (nodeName == "" || nodeName == "body" || nodeName == "html" || nodeName == "#document") - return ""; + return null; var href = node.href; if (nodeName == "a" && href != "") - return href; + return node; node = node.parentNode; } - return ""; + return null; } function isScrollbar(node) @@ -1236,7 +1236,10 @@ function BrowserChangeTextSize(newSize) var target = event.target; if (pref.GetBoolPref("middlemouse.openNewWindow")) { - var href = enclosingLink(target); + var node = enclosingLink(target); + var href =""; + if (node) + href = node.href; if (href != "") { openNewWindowWith(href); diff --git a/xpfe/browser/resources/content/navigatorDD.js b/xpfe/browser/resources/content/navigatorDD.js index 71095f71e65..1f518883a05 100644 --- a/xpfe/browser/resources/content/navigatorDD.js +++ b/xpfe/browser/resources/content/navigatorDD.js @@ -216,9 +216,38 @@ var contentAreaDNDObserver = { case 'LI': case 'OL': case 'DD': - textstring = enclosingLink(aEvent.target); + var node = enclosingLink(aEvent.target); + textstring = ""; + //select node now! + if (node) + textstring = node.href; if (textstring != "") + { + dump("link hit selecting link\n"); htmlstring = "" + textstring + ""; + var parent = node.parentNode; + if (parent) + { + var nodelist = parent.childNodes; + var index; + for (index = 0; index= nodelist.length) + { + throw Components.results.NS_ERROR_FAILURE; + } + if (domselection) + { + domselection.collapse(parent,index); + domselection.extend(parent,index+1); + } + } + } else throw Components.results.NS_ERROR_FAILURE; break;