[Pkg-mozext-commits] [firetray] 78/399: * options: fix Order preference sync * options: display server types according to Order * cleaning
David Prévot
taffit at alioth.debian.org
Tue Oct 29 18:23:17 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch dfsg-clean
in repository firetray.
commit 4646612fae4e2130bd291b6eeb044186e07c0ce6
Author: foudfou <foudil.newbie+git at gmail.com>
Date: Thu Nov 3 02:51:43 2011 +0100
* options: fix Order preference sync
* options: display server types according to Order
* cleaning
---
src/chrome/content/options.js | 51 ++++++++++++++++++++++++-----------
src/chrome/content/options.xul | 2 +-
src/chrome/locale/en-US/options.dtd | 6 ++---
src/modules/commons.js | 12 ++++++++-
4 files changed, 51 insertions(+), 20 deletions(-)
diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js
index c16187e..eeb9ef2 100644
--- a/src/chrome/content/options.js
+++ b/src/chrome/content/options.js
@@ -39,9 +39,9 @@ firetray.UIOptions = {
function(c) {
LOG("i: "+i+", cell:"+c);
c.removeEventListener(
- 'DOMAttrModified', that._userChangeValueTreeServerTypes, true);
+ 'DOMAttrModified', that._userChangeValueTreeServerTypes, true); // FIXME
c.removeEventListener(
- 'DOMAttrModified', that._userChangeValueTreeAccounts, true);
+ 'DOMAttrModified', that._userChangeValueTreeAccounts, true); // FIXME
});
}
},
@@ -77,16 +77,22 @@ firetray.UIOptions = {
},
_userChangeValueTreeServerTypes: function(event) {
- let checkboxCell = event.originalTarget;
- let tree = document.getElementById("ui_tree_mail_accounts");
+ if (event.attrName === "value") { // checkbox
+ let checkboxCell = event.originalTarget;
+ let tree = document.getElementById("ui_tree_mail_accounts");
+
+ let rows = firetray.Utils.XPath(
+ checkboxCell,
+ 'ancestor::xul:treeitem[1]/descendant::xul:treechildren//xul:treerow');
+ LOG("rows="+rows);
+ for (let i=0; i<rows.length; i++)
+ this._disableTreeRow(rows[i],
+ (checkboxCell.getAttribute("value") === "false"));
+
+ } else if (event.attrName == "label") { // text
+ // TODO: move row to new rank
+ }
- let rows = firetray.Utils.XPath(
- checkboxCell,
- 'ancestor::xul:treeitem[1]/descendant::xul:treechildren//xul:treerow');
- LOG("rows="+rows);
- for (let i=0; i<rows.length; i++)
- this._disableTreeRow(rows[i],
- (checkboxCell.getAttribute("value") === "false"));
this._userChangeValueTreeAccounts(event);
},
@@ -107,9 +113,22 @@ firetray.UIOptions = {
let accountsByServerType = firetray.Messaging.accountsByServerType();
LOG(JSON.stringify(accountsByServerType));
+ // sort serverTypes according to order
+ let serverTypesSorted = Object.keys(serverTypes);
+ serverTypesSorted.sort(function(a,b) {
+ if (serverTypes[a].order
+ < serverTypes[b].order)
+ return -1;
+ if (serverTypes[a].order
+ > serverTypes[b].order)
+ return 1;
+ return 0; // no sorting
+ });
+ LOG("serverTypesSorted: "+serverTypesSorted);
+
let target = document.getElementById("ui_mail_accounts");
- for (let serverTypeName in serverTypes) {
- let name = serverTypes[serverTypeName];
+ for (let i=0; i<serverTypesSorted.length; i++) {
+ let serverTypeName = serverTypesSorted[i];
let item = document.createElement('treeitem');
item.setAttribute("container",true);
@@ -138,7 +157,9 @@ firetray.UIOptions = {
let cellOrder = document.createElement('treecell');
cellOrder.setAttribute('label',serverTypes[serverTypeName].order);
cellOrder.addEventListener( // CAUTION: removeEventListener in onQuit()
- 'DOMAttrModified', that._userChangeValueTreeServerTypes, true);
+ 'DOMAttrModified', function(e) {
+ that._userChangeValueTreeServerTypes(e);
+ }, true);
row.appendChild(cellOrder);
target.appendChild(item);
@@ -209,7 +230,7 @@ firetray.UIOptions = {
tree.view.getCellText(
i, tree.columns.getNamedColumn("account_or_server_type_order")));
- LOG("SUPER: "+accountOrServerTypeName+", "+accountOrServerTypeExcluded);
+ LOG("account: "+accountOrServerTypeName+", "+accountOrServerTypeExcluded);
if (tree.view.getLevel(i) === 0) { // serverTypes
prefObj["serverTypes"][accountOrServerTypeName] =
diff --git a/src/chrome/content/options.xul b/src/chrome/content/options.xul
index c449538..c5af964 100644
--- a/src/chrome/content/options.xul
+++ b/src/chrome/content/options.xul
@@ -62,7 +62,7 @@
<treecol id="account_or_server_type_order" editable="true"
persist="width"
flex="1" hidden= "true" label="&account_or_server_type_order;"
- tooltiptext="&account_or_server_type_name.tooltip;"/>
+ tooltiptext="&account_or_server_type_order.tooltip;"/>
</treecols>
<treechildren id="ui_mail_accounts" flex="1" />
</tree>
diff --git a/src/chrome/locale/en-US/options.dtd b/src/chrome/locale/en-US/options.dtd
index a7ee99a..5054526 100644
--- a/src/chrome/locale/en-US/options.dtd
+++ b/src/chrome/locale/en-US/options.dtd
@@ -12,8 +12,8 @@
<!ENTITY unread_count_account_exceptions.tooltip "Included accounts for unread message count">
<!ENTITY account_or_server_type_name "Account">
-<!ENTITY account_or_server_type_name.tooltip "FIXME">
+<!ENTITY account_or_server_type_name.tooltip "Account name or type">
<!ENTITY account_or_server_type_excluded "Excluded">
-<!ENTITY account_or_server_type_excluded.tooltip "FIXME">
+<!ENTITY account_or_server_type_excluded.tooltip "Includes accounts or types into unread messages count">
<!ENTITY account_or_server_type_order "Order">
-<!ENTITY account_or_server_type_order.tooltip "FIXME">
+<!ENTITY account_or_server_type_order.tooltip "Order in which mail server types are displayed. Double-clic to edit.">
diff --git a/src/modules/commons.js b/src/modules/commons.js
index 2993d66..a3505d7 100644
--- a/src/modules/commons.js
+++ b/src/modules/commons.js
@@ -3,7 +3,7 @@
var EXPORTED_SYMBOLS =
[ "firetray", "Cc", "Ci", "Cu", "LOG", "WARN", "ERROR",
"FIREFOX_ID", "THUNDERBIRD_ID", "SEAMONKEY_ID",
- "isArray", "XPath" ];
+ "XPath", "isArray" ];
const Cc = Components.classes;
const Ci = Components.interfaces;
@@ -173,3 +173,13 @@ firetray.Utils = {
function isArray(o) {
return Object.prototype.toString.call(o) === '[object Array]';
}
+
+// http://stackoverflow.com/questions/18912/how-to-find-keys-of-a-hash
+// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/keys
+if(!Object.keys) Object.keys = function(o){
+ if (o !== Object(o))
+ throw new TypeError('Object.keys called on non-object');
+ var ret=[],p;
+ for(p in o) if(Object.prototype.hasOwnProperty.call(o,p)) ret.push(p);
+ return ret;
+};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firetray.git
More information about the Pkg-mozext-commits
mailing list