From d1240b90a789f67f575bb6e3f62eed88265a8eea Mon Sep 17 00:00:00 2001 From: "ben%bengoodger.com" Date: Mon, 1 Dec 2003 06:33:00 +0000 Subject: [PATCH] Downloads Button D&D --- browser/base/content/browser-sets.inc | 4 +++- browser/base/content/browser.js | 34 +++++++++++++++++++++++++-- browser/base/content/browser.xul | 4 ++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/browser/base/content/browser-sets.inc b/browser/base/content/browser-sets.inc index 7a6c1dc13918..2c2e075f5878 100644 --- a/browser/base/content/browser-sets.inc +++ b/browser/base/content/browser-sets.inc @@ -93,7 +93,9 @@ - + #ifdef XP_MACOSX diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index a789609b634c..c5bb563c0c00 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1601,6 +1601,34 @@ var goButtonObserver = { } } +var DownloadsButtonDNDObserver = { + ///////////////////////////////////////////////////////////////////////////// + // nsDragAndDrop + onDragOver: function (aEvent, aFlavour, aDragSession) + { + aDragSession.canDrop = (aFlavour.contentType == "text/x-moz-url" || + aFlavour.contentType == "text/unicode"); + }, + + onDrop: function (aEvent, aXferData, aDragSession) + { + var split = aXferData.data.split("\n"); + var url = split[0]; + if (url != aXferData.data) { //do nothing, not a valid URL + var name = split[1]; + saveURL(url, name, null, true, true); + } + }, + + getSupportedFlavours: function () + { + var flavourSet = new FlavourSet(); + flavourSet.appendFlavour("text/x-moz-url"); + flavourSet.appendFlavour("text/unicode"); + return flavourSet; + } +} + function focusSearchBar() { var searchBar = document.getElementById("search-bar"); @@ -1790,14 +1818,16 @@ function toJavaScriptConsole() toOpenWindowByType("global:console", "chrome://global/content/console.xul"); } -function toOpenWindowByType(inType, uri) +function toOpenWindowByType(inType, uri, features) { var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(); var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator); var topWindow = windowManagerInterface.getMostRecentWindow(inType); - if ( topWindow ) + if (topWindow) topWindow.focus(); + else if (features) + window.open(uri, "_blank", features); else window.open(uri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar"); } diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index 682997291521..7ba386a95257 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -460,6 +460,10 @@