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.
This commit is contained in:
scott%scott-macgregor.org 2003-07-09 22:15:43 +00:00
Родитель 84f8a30ac2
Коммит ea23014033
2 изменённых файлов: 21 добавлений и 13 удалений

Просмотреть файл

@ -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;
}
};

Просмотреть файл

@ -503,7 +503,10 @@
<toolbox id="headers-box" class="toolbox-top" mode="icons">
<toolbar id="MsgHeadersToolbar" persist="collapsed" flex="1"
tborient="vertical" tbalign="stretch"
customizable="true">
customizable="true"
ondragover="nsDragAndDrop.dragOver(event, envelopeDragObserver);"
ondragdrop="nsDragAndDrop.drop(event, envelopeDragObserver);"
ondragexit="nsDragAndDrop.dragExit(event, envelopeDragObserver);">
<hbox id="msgheaderstoolbar-box" flex="1">
<vbox flex="1" id="addresses-box">
<hbox align="center">
@ -514,9 +517,7 @@
</hbox>
<listbox id="addressingWidget" flex="1" seltype="multiple" rows="4"
onkeydown="awKeyDown(event, this)"
onclick="awClickEmptySpace(event.originalTarget, true)"
ondragover="DragOverAddressingWidget(event);"
ondragdrop="return DropOnAddressingWidget(event);">
onclick="awClickEmptySpace(event.originalTarget, true)">
<listcols>
<listcol id="typecol-addressingWidget"/>
<listcol id="textcol-addressingWidget" flex="1"/>
@ -566,10 +567,7 @@
<listbox seltype="multiple" id="attachmentBucket" flex="1" rows="4"
context="msgComposeAttachmentContext"
onkeypress="if (event.keyCode == 8 || event.keyCode == 46) RemoveSelectedAttachment();"
onclick="AttachmentBucketClicked(event);"
ondragover="nsDragAndDrop.dragOver(event, attachmentBucketObserver);"
ondragdrop="nsDragAndDrop.drop(event, attachmentBucketObserver);"
ondragexit="nsDragAndDrop.dragExit(event, attachmentBucketObserver);"/>
onclick="AttachmentBucketClicked(event);"/>
</vbox>
</hbox>
</toolbar>