0,0 → 1,82 |
var MoveToFolder = { |
onLoad: function() |
{ |
if(!this.initialized) { |
window.document.getElementById("threadTree").addEventListener( |
"select", this.updateButton, false) |
this.initialized = true; |
this.updateButton(); |
} |
}, |
|
onUnload: function() |
{ |
if(this.initialized) { |
window.document.getElementById("threadTree").removeEventListener( |
"select", this.updateButton, false) |
this.initialized = false; |
} |
}, |
|
doCommand: function() { |
var messages = GetSelectedMessages(); |
if(!messages || messages.length == 0) return; |
|
var prefs = new MoveToFolderPrefs(); |
var dst = prefs.getToFolderURI(); |
|
if(dst) { |
SetNextMessageAfterDelete(); |
this.moveMessages(messages, messenger.msgHdrFromURI(messages[0]).folder.URI, dst); |
this.updateButton(); |
} |
}, |
|
moveMessages: function(msgURIs, srcFolderURI, dstFolderURI) { |
var messages = Components |
.classes["@mozilla.org/supports-array;1"] |
.createInstance(Components.interfaces.nsISupportsArray); |
|
for(var i in msgURIs) { |
if(msgURIs[i]) { |
messages.AppendElement(messenger.msgHdrFromURI(msgURIs[i])); |
} |
} |
|
if(messages.Count() > 0) { |
var dstFolder = GetMsgFolderFromUri(dstFolderURI); |
var srcFolder = GetMsgFolderFromUri(srcFolderURI); |
|
try { |
dstFolder.copyMessages(srcFolder, messages, true, msgWindow, null, false, true); |
} |
catch(ex) { |
alert("Error moving messages from " + srcFolderURI |
+ " to " + dstFolderURI + ": " + ex.message); |
return; |
} |
} |
}, |
|
updateButton: function() { |
var button = document.getElementById("movetofolder-button"); |
if(!button) return; |
|
var messages = GetSelectedMessages(); |
var prefs = new MoveToFolderPrefs(); |
var dst = prefs.getToFolderURI(); |
|
button.disabled = (!dst || !messages || messages.length == 0); |
|
if(dst) { |
button.setAttribute("tooltiptext", "Move to the spam folder"); |
} |
else { |
button.setAttribute("tooltiptext", "Please configure the folder first"); |
} |
} |
} |
|
window.addEventListener("load", function(e) { MoveToFolder.onLoad(); }, false); |
window.addEventListener("unload", function(e) { MoveToFolder.onUnload(); }, false); |
|