add:  function FocusOnFirstAttachment() { var bucketList = document.getElementById("attachmentBucket");  if (bucketList && bucketList.hasChildNodes()) bucketTree.selectItem(bucketList.firstChild); }  function AttachmentElementHasItems() { var element = document.getElementById("bucketList");  return element ? element.childNodes.length : 0; }  function AttachVCard() { dump("AttachVCard()\n"); }  function DetermineHTMLAction(convertible) { var obj; if (! gMsgCompose.composeHTML) { try { obj = new Object; gMsgCompose.CheckAndPopulateRecipients(true, false, obj); } catch(ex) { dump("gMsgCompose.CheckAndPopulateRecipients failed: " + ex + "\n"); } return nsIMsgCompSendFormat.PlainText; }  if (gSendFormat == nsIMsgCompSendFormat.AskUser) {   var noHtmlRecipients; var noHtmlnewsgroups; var preferFormat;   try { obj = new Object; preferFormat = gMsgCompose.CheckAndPopulateRecipients(true, true, obj); noHtmlRecipients = obj.value; } catch(ex) { dump("gMsgCompose.CheckAndPopulateRecipients failed: " + ex + "\n"); var msgCompFields = gMsgCompose.compFields; noHtmlRecipients = msgCompFields.to + "," + msgCompFields.cc + "," + msgCompFields.bcc; preferFormat = nsIAbPreferMailFormat.unknown; } dump("DetermineHTMLAction: preferFormat = " + preferFormat + ", noHtmlRecipients are " + noHtmlRecipients + "\n");   try { noHtmlnewsgroups = gMsgCompose.GetNoHtmlNewsgroups(null); } catch(ex) { noHtmlnewsgroups = gMsgCompose.compFields.newsgroups; }  if (noHtmlRecipients != "" || noHtmlnewsgroups != "") { if (convertible == nsIMsgCompConvertible.Plain) return nsIMsgCompSendFormat.PlainText;  if (noHtmlnewsgroups == "") { switch (preferFormat) { case nsIAbPreferMailFormat.plaintext : return nsIMsgCompSendFormat.PlainText;  default :   var action = sPrefs.getIntPref("mail.default_html_action"); switch (action) { case nsIMsgCompSendFormat.PlainText    : case nsIMsgCompSendFormat.HTML         : case nsIMsgCompSendFormat.Both         : return action; } } } return nsIMsgCompSendFormat.AskUser; } else return nsIMsgCompSendFormat.HTML; } else { try { obj = new Object; gMsgCompose.CheckAndPopulateRecipients(true, false, obj); } catch(ex) { dump("gMsgCompose.CheckAndPopulateRecipients failed: " + ex + "\n"); } }  return gSendFormat; }  function DetermineConvertibility() { if (!gMsgCompose.composeHTML) return nsIMsgCompConvertible.Plain;  try { return gMsgCompose.bodyConvertible(); } catch(ex) {} return nsIMsgCompConvertible.No; }  function LoadIdentity(startup) { var identityElement = document.getElementById("msgIdentity"); var prevIdentity = gCurrentIdentity;  if (identityElement) { var item = identityElement.selectedItem; var idKey = item.getAttribute('id'); gCurrentIdentity = gAccountManager.getIdentity(idKey);  if (!startup && prevIdentity && idKey != prevIdentity.key) { var prefstring = "mail.identity." + prevIdentity.key; RemoveDirectoryServerObserver(prefstring); var prevReplyTo = prevIdentity.replyTo; var prevBcc = ""; var prevReceipt = prevIdentity.requestReturnReceipt; if (prevIdentity.bccSelf) prevBcc += prevIdentity.email; if (prevIdentity.bccOthers) { if (prevBcc != "") prevBcc += "," prevBcc += prevIdentity.bccList; }  var newReplyTo = gCurrentIdentity.replyTo; var newBcc = ""; var newReceipt = gCurrentIdentity.requestReturnReceipt; if (gCurrentIdentity.bccSelf) newBcc += gCurrentIdentity.email; if (gCurrentIdentity.bccOthers) { if (newBcc != "") newBcc += "," newBcc += gCurrentIdentity.bccList; }  var needToCleanUp = false; var msgCompFields = gMsgCompose.compFields;  if (!gReceiptOptionChanged && prevReceipt == msgCompFields.returnReceipt && prevReceipt != newReceipt) { msgCompFields.returnReceipt = newReceipt; document.getElementById("returnReceiptMenu").setAttribute('checked',msgCompFields.returnReceipt); }   if (newReplyTo != prevReplyTo) { needToCleanUp = true; if (prevReplyTo != "") awRemoveRecipients(msgCompFields, "addr_reply", prevReplyTo); if (newReplyTo != "") awAddRecipients(msgCompFields, "addr_reply", newReplyTo); }  if (newBcc != prevBcc) { needToCleanUp = true; if (prevBcc != "") awRemoveRecipients(msgCompFields, "addr_bcc", prevBcc); if (newBcc != "") awAddRecipients(msgCompFields, "addr_bcc", newBcc); }  if (needToCleanUp) awCleanupRows();  try { gMsgCompose.SetSignature(gCurrentIdentity); } catch (ex) { dump("### Cannot set the signature: " + ex + "\n");} }  AddDirectoryServerObserver(false); if (!startup) { try { setupLdapAutocompleteSession(); } catch (ex) {   } } } }  function setupAutocomplete() {  if (!gAutocompleteSession) { gAutocompleteSession = Components.classes["@mozilla.org/autocompleteSession;1?type=addrbook"].getService(Components.interfaces.nsIAbAutoCompleteSession); if (gAutocompleteSession) { var emailAddr = gCurrentIdentity.email; var start = emailAddr.lastIndexOf("@"); gAutocompleteSession.defaultDomain = emailAddr.slice(start + 1, emailAddr.length);      try { if (sPrefs.getIntPref("mail.autoComplete.commentColumn")) { document.getElementById('addressCol2#1').showCommentColumn = true; } } catch (ex) {   }  } else { gAutocompleteSession = 1; } } if (!gSetupLdapAutocomplete) { try { setupLdapAutocompleteSession(); } catch (ex) {   } } }  function subjectKeyPress(event) { switch(event.keyCode) { case 9: if (!event.shiftKey) { window._content.focus(); event.preventDefault(); } break; case 13: window._content.focus(); break; } }  function editorKeyPress(event) { if (event.keyCode == 9) { if (event.shiftKey) { document.getElementById('msgSubject').focus(); event.preventDefault(); } } }  function AttachmentBucketClicked(event) { if (event.button != 0) return;  if (event.originalTarget.localName == "listboxbody") goDoCommand('cmd_attachFile'); }  var attachmentBucketObserver = {  canHandleMultipleItems: true,  onDrop: function (aEvent, aData, aDragSession) { var dataList = aData.dataList; var dataListLength = dataList.length; var errorTitle; var attachment; var errorMsg;  for (var i = 0; i < dataListLength; i++) { var item = dataList[i].first; var prettyName; var rawData = item.data;  if (item.flavour.contentType == "text/x-moz-url" || item.flavour.contentType == "text/x-moz-message-or-folder" || item.flavour.contentType == "application/x-moz-file") { if (item.flavour.contentType == "application/x-moz-file") { var ioService = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService); rawData = ioService.getURLSpecFromFile(rawData); } else { var separator = rawData.indexOf("\n"); if (separator != -1) { prettyName = rawData.substr(separator+1); rawData = rawData.substr(0,separator); } }  if (DuplicateFileCheck(rawData)) { dump("Error, attaching the same item twice\n"); } else { attachment = Components.classes["@mozilla.org/messengercompose/attachment;1"] .createInstance(Components.interfaces.nsIMsgAttachment); attachment.url = rawData; attachment.name = prettyName; AddAttachment(attachment); } } } },  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 () { var flavourSet = new FlavourSet(); flavourSet.appendFlavour("text/x-moz-url"); flavourSet.appendFlavour("text/x-moz-message-or-folder"); flavourSet.appendFlavour("application/x-moz-file", "nsIFile"); return flavourSet; } };  function DisplaySaveFolderDlg(folderURI) { try{ showDialog = gCurrentIdentity.showSaveMsgDlg; } catch (e){ return; }  if (showDialog){ var msgfolder = GetMsgFolderFromUri(folderURI, true); if (!msgfolder) return; var checkbox = {value:0}; var SaveDlgTitle = sComposeMsgsBundle.getString("SaveDialogTitle"); var dlgMsg = sComposeMsgsBundle.getFormattedString("SaveDialogMsg", [msgfolder.name, msgfolder.hostname]);  var CheckMsg = sComposeMsgsBundle.getString("CheckMsg"); if (gPromptService) gPromptService.alertCheck(window, SaveDlgTitle, dlgMsg, CheckMsg, checkbox); else window.alert(dlgMsg); try { gCurrentIdentity.showSaveMsgDlg = !checkbox.value; } catch (e) { return; }  } return; }    function SetMsgAddressingWidgetTreeElementFocus() { SuppressComposeCommandUpdating(true);  var element = document.getElementById("msgRecipient#" + awGetNumberOfRecipients()); awSetFocus(awGetNumberOfRecipients(), element);  }  function SetMsgIdentityElementFocus() {   SuppressComposeCommandUpdating(true); GetMsgIdentityElement().focus(); SuppressComposeCommandUpdating(false); }  function SetMsgSubjectElementFocus() { SuppressComposeCommandUpdating(true); GetMsgSubjectElement().focus(); SuppressComposeCommandUpdating(false); }  function SetMsgAttachmentElementFocus() { SuppressComposeCommandUpdating(true); GetMsgAttachmentElement().focus(); FocusOnFirstAttachment(); SuppressComposeCommandUpdating(false); }  function SetMsgBodyFrameFocus() { SuppressComposeCommandUpdating(true); editorShell.contentWindow.focus(); SuppressComposeCommandUpdating(false); }  function GetMsgAddressingWidgetTreeElement() { if (!gMsgAddressingWidgetTreeElement) gMsgAddressingWidgetTreeElement = document.getElementById("addressingWidgetTree");  return gMsgAddressingWidgetTreeElement; }  function GetMsgIdentityElement() { if (!gMsgIdentityElement) gMsgIdentityElement = document.getElementById("msgIdentity");  return gMsgIdentityElement; }  function GetMsgSubjectElement() { if (!gMsgSubjectElement) gMsgSubjectElement = document.getElementById("msgSubject");  return gMsgSubjectElement; }  function GetMsgAttachmentElement() { if (!gMsgAttachmentElement) gMsgAttachmentElement = document.getElementById("attachmentBucket");  return gMsgAttachmentElement; }  function GetMsgBodyFrame() { if (!gMsgBodyFrame) gMsgBodyFrame = top.frames['browser.message.body'];  return gMsgBodyFrame; }  function GetMsgHeadersToolbarElement() { if (!gMsgHeadersToolbarElement) gMsgHeadersToolbarElement = document.getElementById("MsgHeadersToolbar");  return gMsgHeadersToolbarElement; }  function IsMsgHeadersToolbarCollapsed() { var element = GetMsgHeadersToolbarElement(); if(element) return(element.getAttribute('moz-collapsed') == "true");  return(0); }  function WhichElementHasFocus() { var msgIdentityElement             = GetMsgIdentityElement(); var msgAddressingWidgetTreeElement = GetMsgAddressingWidgetTreeElement(); var msgSubjectElement              = GetMsgSubjectElement(); var msgAttachmentElement           = GetMsgAttachmentElement(); var msgBodyFrame                   = GetMsgBodyFrame();  if (top.document.commandDispatcher.focusedWindow == msgBodyFrame) return msgBodyFrame;  var currentNode = top.document.commandDispatcher.focusedElement; while (currentNode) { if (currentNode == msgIdentityElement || currentNode == msgAddressingWidgetTreeElement || currentNode == msgSubjectElement || currentNode == msgAttachmentElement) return currentNode;  currentNode = currentNode.parentNode; }  return null; }           function SwitchElementFocus(event) { var focusedElement = WhichElementHasFocus();  if (event && event.shiftKey) { if (IsMsgHeadersToolbarCollapsed()) SetMsgBodyFrameFocus(); else if (focusedElement == gMsgAddressingWidgetTreeElement) SetMsgIdentityElementFocus(); else if (focusedElement == gMsgIdentityElement) SetMsgBodyFrameFocus(); else if (focusedElement == gMsgBodyFrame) {   if (AttachmentElementHasItems()) SetMsgAttachmentElementFocus(); else SetMsgSubjectElementFocus(); } else if (focusedElement == gMsgAttachmentElement) SetMsgSubjectElementFocus(); else SetMsgAddressingWidgetTreeElementFocus(); } else { if (IsMsgHeadersToolbarCollapsed()) SetMsgBodyFrameFocus(); else if (focusedElement == gMsgAddressingWidgetTreeElement) SetMsgSubjectElementFocus(); else if (focusedElement == gMsgSubjectElement) {   if (AttachmentElementHasItems()) SetMsgAttachmentElementFocus(); else SetMsgBodyFrameFocus(); } else if (focusedElement == gMsgAttachmentElement) SetMsgBodyFrameFocus(); else if (focusedElement == gMsgBodyFrame) SetMsgIdentityElementFocus(); else SetMsgAddressingWidgetTreeElementFocus(); } } 
context: function RemoveSelectedAttachment(){  var child;  var bucket = document.getElementById("attachmentBucket");  if (bucket.selectedItems.length > 0) {    for (var item = bucket.selectedItems.length - 1; item >= 0; item-- )    {      child = bucket.removeChild(bucket.selectedItems[item]) = null;      // Let's release the attachment object hold by the node else it won't go away until the window is destroyed      child.attachment = null;    }    gContentChanged = true;  }}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/863e5ac62c1bad273e07f6417044f47a68ce4280/MsgComposeCommands.js/buggy/mailnews/compose/resources/content/MsgComposeCommands.js