From ea230140336e78737202146d954900608de81c92 Mon Sep 17 00:00:00 2001 From: "scott%scott-macgregor.org" Date: Wed, 9 Jul 2003 22:15:43 +0000 Subject: [PATCH] Make a single UBER drag and drop listener for the entire mail compose envelope. Based on the drag flavor, re-route the drop to either the attachment bucket or to the addressing envelope. This means you can now drag addresses, files, web pages, etc. anywhere in the compose envelope and we will do the right thing. --- .../compose/content/MsgComposeCommands.js | 20 ++++++++++++++----- .../compose/content/messengercompose.xul | 14 ++++++------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/mail/components/compose/content/MsgComposeCommands.js b/mail/components/compose/content/MsgComposeCommands.js index dad0dacaae85..f4662fa4e4fe 100644 --- a/mail/components/compose/content/MsgComposeCommands.js +++ b/mail/components/compose/content/MsgComposeCommands.js @@ -2604,7 +2604,8 @@ function AttachmentBucketClicked(event) goDoCommand('cmd_attachFile'); } -var attachmentBucketObserver = { +// we can drag and drop addresses, files, messages and urls into the compose envelope +var envelopeDragObserver = { canHandleMultipleItems: true, @@ -2622,6 +2623,8 @@ var attachmentBucketObserver = { var prettyName; var rawData = item.data; + // We could be dropping an attachment OR an address, check and do the right thing.. + if (item.flavour.contentType == "text/x-moz-url" || item.flavour.contentType == "text/x-moz-message" || item.flavour.contentType == "application/x-moz-file") @@ -2676,22 +2679,28 @@ var attachmentBucketObserver = { attachment.url = rawData; attachment.name = prettyName; AddAttachment(attachment); + + var attachmentBox = document.getElementById("attachments-box"); + attachmentBox.hidden = false; + document.getElementById("attachmentbucket-sizer").hidden=false; } } } + else if (item.flavour.contentType == "text/x-moz-address") + { + // process the address + if (rawData) + DropRecipient(aEvent.target, rawData); + } } }, onDragOver: function (aEvent, aFlavour, aDragSession) { - var attachmentBucket = document.getElementById("attachmentBucket"); - attachmentBucket.setAttribute("dragover", "true"); }, onDragExit: function (aEvent, aDragSession) { - var attachmentBucket = document.getElementById("attachmentBucket"); - attachmentBucket.removeAttribute("dragover"); }, getSupportedFlavours: function () @@ -2700,6 +2709,7 @@ var attachmentBucketObserver = { flavourSet.appendFlavour("text/x-moz-url"); flavourSet.appendFlavour("text/x-moz-message"); flavourSet.appendFlavour("application/x-moz-file", "nsIFile"); + flavourSet.appendFlavour("text/x-moz-address"); return flavourSet; } }; diff --git a/mail/components/compose/content/messengercompose.xul b/mail/components/compose/content/messengercompose.xul index e89da69e254a..0cc4134b6cca 100644 --- a/mail/components/compose/content/messengercompose.xul +++ b/mail/components/compose/content/messengercompose.xul @@ -503,7 +503,10 @@ + customizable="true" + ondragover="nsDragAndDrop.dragOver(event, envelopeDragObserver);" + ondragdrop="nsDragAndDrop.drop(event, envelopeDragObserver);" + ondragexit="nsDragAndDrop.dragExit(event, envelopeDragObserver);"> @@ -514,9 +517,7 @@ + onclick="awClickEmptySpace(event.originalTarget, true)"> @@ -566,10 +567,7 @@ + onclick="AttachmentBucketClicked(event);"/>