/thunderbird/movetofolder/trunk/chrome/content/movetofolder.js |
---|
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); |
/thunderbird/movetofolder/trunk/chrome/content/options.xul |
---|
0,0 → 1,34 |
<?xml version="1.0"?> |
<?xml-stylesheet href="chrome://movetofolder/skin/options.css" type="text/css"?> |
<?xul-overlay href="chrome://messenger/content/msgFolderPickerOverlay.xul"?> |
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
xmlns:nc="http://home.netscape.com/NC-rdf#" |
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
title="MoveToFolder Options" |
onload="onLoadOptions();" |
buttons="accept,cancel" |
ondialogaccept="return onSaveOptions();"> |
<script type="application/x-javascript" src="chrome://movetofolder/content/prefs.js"/> |
<script type="application/x-javascript" src="chrome://movetofolder/content/options.js" /> |
<script type="application/x-javascript" src="chrome://messenger/content/widgetglue.js"/> |
<stringbundleset id="stringbundleset"> |
<stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/> |
</stringbundleset> |
<vbox> |
<hbox align="baseline"> |
<label value="Folder" control="toFolder"/> |
<menulist id="toFolder" class="folderMenuItem" label=" " |
context="folderPaneContext" minwidth="170" crop="center" flex="1"> |
<menupopup id="toFolderPopup" class="folderLocationPopup" height="400" flex="1" |
oncommand="onSelectFolder(this, 'toFolder')"/> |
</menulist> |
</hbox> |
</vbox> |
</dialog> |
/thunderbird/movetofolder/trunk/chrome/content/options.js |
---|
0,0 → 1,23 |
function onLoadOptions() { |
var prefs = new MoveToFolderPrefs(); |
var toFolderPopup = document.getElementById('toFolderPopup').tree; |
toFolderPopup.database.AddDataSource( |
Components.classes["@mozilla.org/rdf/datasource;1?name=msgaccountmanager"].createInstance()); |
toFolderPopup.database.AddDataSource( |
Components.classes["@mozilla.org/rdf/datasource;1?name=mailnewsfolders"].getService()); |
toFolderPopup.setAttribute("ref", "msgaccounts:/"); |
SetFolderPicker(prefs.getToFolderURI(), "toFolder"); |
} |
function onSaveOptions() { |
var prefs = new MoveToFolderPrefs(); |
prefs.setToFolderURI(document.getElementById("toFolder").getAttribute("uri")); |
} |
function onSelectFolder(menulist, folderName) { |
SetFolderPicker(menulist.getAttribute("uri"), folderName); |
} |
/thunderbird/movetofolder/trunk/chrome/content/prefs.js |
---|
0,0 → 1,20 |
function MoveToFolderPrefs() { |
var svc = Components.classes["@mozilla.org/preferences-service;1"] |
.getService(Components.interfaces.nsIPrefService); |
this.prefs = svc.getBranch("extensions.movetofolder."); |
} |
MoveToFolderPrefs.prototype = { |
getToFolderURI: function() { |
try { |
return this.prefs.getCharPref("toFolderURI"); |
} |
catch(ex) { |
return ""; |
} |
}, |
setToFolderURI: function(value) { |
this.prefs.setCharPref("toFolderURI", value); |
}, |
} |
/thunderbird/movetofolder/trunk/chrome/content/movetofolder.xul |
---|
0,0 → 1,21 |
<?xml version="1.0"?> |
<?xml-stylesheet href="chrome://movetofolder/skin/movetofolder.css" type="text/css"?> |
<overlay id="movetofolder" |
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
<script type="application/x-javascript" src="chrome://movetofolder/content/prefs.js"/> |
<script type="application/x-javascript" src="chrome://movetofolder/content/movetofolder.js"/> |
<toolbarpalette id="MailToolbarPalette"> |
<toolbaritem id="movetofolder-toolbar"> |
<deck id="movetofolder-deck"> |
<toolbarbutton id="movetofolder-button" class="toolbarbutton-1" |
label="Spam" |
tooltiptext="Move to the spam folder" |
oncommand="MoveToFolder.doCommand()" /> |
</deck> |
</toolbaritem> |
</toolbarpalette> |
</overlay> |
/thunderbird/movetofolder/trunk/chrome/skin/icons/spam_small_disabled.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/thunderbird/movetofolder/trunk/chrome/skin/icons/spam.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/thunderbird/movetofolder/trunk/chrome/skin/icons/spam_disabled.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/thunderbird/movetofolder/trunk/chrome/skin/icons/spam_small.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/thunderbird/movetofolder/trunk/chrome/skin/movetofolder.css |
---|
0,0 → 1,15 |
#movetofolder-button { |
list-style-image: url("chrome://movetofolder/skin/icons/spam.png"); |
} |
#movetofolder-button[disabled="true"] { |
list-style-image: url("chrome://movetofolder/skin/icons/spam_disabled.png"); |
} |
toolbar[iconsize="small"] #movetofolder-button { |
list-style-image: url("chrome://movetofolder/skin/icons/spam_small.png"); |
} |
toolbar[iconsize="small"] #movetofolder-button[disabled="true"] { |
list-style-image: url("chrome://movetofolder/skin/icons/spam_small_disabled.png"); |
} |
/thunderbird/movetofolder/trunk/chrome/skin/options.css |
---|
0,0 → 1,12 |
@import url("chrome://messenger/skin/"); |
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); |
.specialFolderPickerGrid { |
-moz-margin-start: 20px; |
} |
.folderLocationPopup { |
display: -moz-popup; |
-moz-binding: url("chrome://messenger/content/mailWidgets.xml#locationpopup"); |
visibility: visible; |
} |