1
0
mirror of https://github.com/moparisthebest/FireTray synced 2024-12-22 13:58:48 -05:00

* cleaning

* options: prepare disabling rows (styling)
This commit is contained in:
foudfou 2011-11-02 19:57:17 +01:00
parent 5ad5b3c3d4
commit 92180a9146
4 changed files with 78 additions and 47 deletions

View File

@ -19,8 +19,7 @@ firetray.UIOptions = {
onLoad: function() {
if(firetray.Handler.inMailApp) {
Cu.import("resource://firetray/FiretrayMessaging.jsm");
this.populateTreeServerTypes();
this.insertMailAccountsExcluded(this.accountBoxId);
this.populateTreeAccountsOrServerTypes();
} else {
this.hideElement("mail_tab");
}
@ -35,12 +34,12 @@ firetray.UIOptions = {
let items = document.getElementById("ui_mail_accounts").childNodes;
for (let i=0; i < items.length; i++) {
let cells = items[i].getElementsByTagName("treecell");
// col 2 and 3: server_type_excluded, server_type_order
// col 2 and 3: account_or_server_type_excluded, account_or_server_type_order
[cells[1], cells[2]].map(
function(c) {
LOG("i: "+i+", cell:"+c);
c.removeEventListener(
'DOMAttrModified', that._userChangeValueTreeServerTypes, true);
'DOMAttrModified', that._userChangeValueTreeAccountsOrServerTypes, true);
});
}
},
@ -59,10 +58,20 @@ firetray.UIOptions = {
}
},
_disableRow: function(row) {
try {
let cells = row.childNodes; //.getElementsByTagName('treecell');
for (let i=0; i< cells.length; i++)
cells[i].setAttribute('properties', "disabled");
} catch(e) {
ERROR(e);
}
},
/**
* needed for triggering actual preference change and saving
*/
_userChangeValueTreeServerTypes: function(event) {
_userChangeValueTreeAccountsOrServerTypes: function(event) {
if (event.attrName == "label") LOG("label changed!");
if (event.attrName == "value") LOG("value changed!");
document.getElementById("pane1")
@ -73,7 +82,7 @@ firetray.UIOptions = {
* NOTE: account exceptions for unread messages count are *stored* in
* preferences as excluded, but *shown* as "not included"
*/
populateTreeServerTypes: function() {
populateTreeAccountsOrServerTypes: function() {
let that = this;
let prefPane = document.getElementById("pane1");
@ -96,27 +105,27 @@ firetray.UIOptions = {
let row = document.createElement('treerow');
item.appendChild(row);
// server_type_name
// account_or_server_type_name
let cell = document.createElement('treecell');
cell.setAttribute('label',serverTypeName);
cell.setAttribute('editable',false);
row.appendChild(cell);
// server_type_excluded => checkbox
// account_or_server_type_excluded => checkbox
cell = document.createElement('treecell');
cell.setAttribute('value',!serverTypes[serverTypeName].excluded);
cell.addEventListener( // CAUTION: removeEventListener in onQuit()
'DOMAttrModified', function(e) {
that._userChangeValueTreeServerTypes(e);
that._userChangeValueTreeAccountsOrServerTypes(e);
firetray.Messaging.updateUnreadMsgCount();
}, true);
row.appendChild(cell);
// server_type_order
// account_or_server_type_order
cell = document.createElement('treecell');
cell.setAttribute('label',serverTypes[serverTypeName].order);
cell.addEventListener( // CAUTION: removeEventListener in onQuit()
'DOMAttrModified', that._userChangeValueTreeServerTypes, true);
'DOMAttrModified', that._userChangeValueTreeAccountsOrServerTypes, true);
row.appendChild(cell);
target.appendChild(item);
@ -132,28 +141,29 @@ firetray.UIOptions = {
let subItem = document.createElement('treeitem');
let subRow = document.createElement('treerow');
// server_type_name
// account_or_server_type_name
cell = document.createElement('treecell');
cell.setAttribute('id', typeAccounts[i].key);
cell.setAttribute('label',typeAccounts[i].name);
cell.setAttribute('editable',false);
subRow.appendChild(cell);
// server_type_excluded => checkbox
// account_or_server_type_excluded => checkbox
let cell = document.createElement('treecell');
cell.setAttribute('value',(accountsExcluded.indexOf(typeAccounts[i].key) < 0));
cell.addEventListener( // CAUTION: removeEventListener in onQuit()
'DOMAttrModified', function(e) {
that._userChangeValueTreeServerTypes(e);
that._userChangeValueTreeAccountsOrServerTypes(e);
firetray.Messaging.updateUnreadMsgCount();
}, true);
subRow.appendChild(cell);
// server_type_order - UNUSED (added for consistency)
// account_or_server_type_order - UNUSED (added for consistency)
cell = document.createElement('treecell');
cell.setAttribute('editable',false);
subRow.appendChild(cell);
// this._disableRow(subRow);
subItem.appendChild(subRow);
subChildren.appendChild(subItem);
}
@ -162,37 +172,37 @@ firetray.UIOptions = {
}
let tree = document.getElementById("ui_tree_mail_accounts");
tree.addEventListener("keypress", that.onKeyPressTreeServerTypes, true);
tree.addEventListener("keypress", that.onKeyPressTreeAccountsOrServerTypes, true);
},
/*
* Save the "mail_accounts" preference. This is called by the pref's system
* when the GUI element is altered.
*/
saveTreeServerTypes: function() {
saveTreeAccountsOrServerTypes: function() {
let tree = document.getElementById("ui_tree_mail_accounts");
LOG("VIEW="+ tree.view + ", rowCount="+tree.view.rowCount);
let prefObj = {"serverTypes":{}, "excludedAccounts":[]};
for (let i=0; i < tree.view.rowCount; i++) {
// TODO: rename server_type_* to account_or_server_type
let serverTypeName = tree.view.getCellText(
i, tree.columns.getNamedColumn("server_type_name"));
let serverTypeExcluded = (
let accountOrServerTypeName = tree.view.getCellText(
i, tree.columns.getNamedColumn("account_or_server_type_name"));
let accountOrServerTypeExcluded = (
tree.view.getCellValue(
i, tree.columns.getNamedColumn("server_type_excluded"))
i, tree.columns.getNamedColumn("account_or_server_type_excluded"))
!== 'true');
let serverTypeOrder = parseInt(tree.view.getCellText(
i, tree.columns.getNamedColumn("server_type_order")));
let accountOrServerTypeOrder = parseInt(
tree.view.getCellText(
i, tree.columns.getNamedColumn("account_or_server_type_order")));
LOG("SUPER: "+serverTypeName+", "+serverTypeExcluded);
LOG("SUPER: "+accountOrServerTypeName+", "+accountOrServerTypeExcluded);
if (tree.view.getLevel(i) === 0) { // serverTypes
prefObj["serverTypes"][serverTypeName] =
{ order: serverTypeOrder, excluded: serverTypeExcluded };
prefObj["serverTypes"][accountOrServerTypeName] =
{ order: accountOrServerTypeOrder, excluded: accountOrServerTypeExcluded };
} else if (tree.view.getLevel(i) === 1) { // excludedAccounts
if (!serverTypeExcluded)
if (!accountOrServerTypeExcluded)
continue;
let rowNode = tree.view.getItemAtIndex(i).firstChild; // treerow
let rowCells = rowNode.getElementsByTagName('treecell');
@ -211,13 +221,13 @@ firetray.UIOptions = {
return prefStr;
},
onKeyPressTreeServerTypes: function(event) {
onKeyPressTreeAccountsOrServerTypes: function(event) {
LOG("TREE KEYPRESS: "+event.originalTarget);
let tree = document.getElementById("ui_tree_mail_accounts");
let col = tree.editingColumn; // col.index
// only int allowed
if (col == tree.columns.getNamedColumn("server_type_order")) {
if (col == tree.columns.getNamedColumn("account_or_server_type_order")) {
let charCode = event.which || event.keyCode;
let charStr = String.fromCharCode(charCode);
if (!/\d/.test(charStr))

View File

@ -49,20 +49,20 @@
seltype="single" editable="true"
preference-editable="true"
preference="pref_string_mail_accounts"
onsynctopreference="return firetray.UIOptions.saveTreeServerTypes();">
onsynctopreference="return firetray.UIOptions.saveTreeAccountsOrServerTypes();">
<treecols>
<treecol id="server_type_name" editable="false" flex="2"
persist="width" primary="true" label="&server_type_name;"
tooltiptext="&server_type_name.tooltip;"/>
<treecol id="account_or_server_type_name" editable="false" flex="2"
persist="width" primary="true" label="&account_or_server_type_name;"
tooltiptext="&account_or_server_type_name.tooltip;"/>
<splitter class="tree-splitter" resizeafter="grow"/>
<treecol id="server_type_excluded" type="checkbox" editable="true"
label="&server_type_excluded;" flex="1" persist="width"
tooltiptext="&server_type_excluded.tooltip;"/>
<treecol id="account_or_server_type_excluded" type="checkbox" editable="true"
label="&account_or_server_type_excluded;" flex="1" persist="width"
tooltiptext="&account_or_server_type_excluded.tooltip;"/>
<splitter class="tree-splitter" resizeafter="grow"/>
<treecol id="server_type_order" editable="true"
<treecol id="account_or_server_type_order" editable="true"
persist="width"
flex="1" hidden= "true" label="&server_type_order;"
tooltiptext="&server_type_name.tooltip;"/>
flex="1" hidden= "true" label="&account_or_server_type_order;"
tooltiptext="&account_or_server_type_name.tooltip;"/>
</treecols>
<treechildren id="ui_mail_accounts" flex="1" />
</tree>

View File

@ -11,9 +11,9 @@
<!ENTITY unread_count_account_exceptions "Included accounts">
<!ENTITY unread_count_account_exceptions.tooltip "Included accounts for unread message count">
<!ENTITY server_type_name "Account">
<!ENTITY server_type_name.tooltip "FIXME">
<!ENTITY server_type_excluded "Excluded">
<!ENTITY server_type_excluded.tooltip "FIXME">
<!ENTITY server_type_order "Order">
<!ENTITY server_type_order.tooltip "FIXME">
<!ENTITY account_or_server_type_name "Account">
<!ENTITY account_or_server_type_name.tooltip "FIXME">
<!ENTITY account_or_server_type_excluded "Excluded">
<!ENTITY account_or_server_type_excluded.tooltip "FIXME">
<!ENTITY account_or_server_type_order "Order">
<!ENTITY account_or_server_type_order.tooltip "FIXME">

View File

@ -1,4 +1,25 @@
treechildren::-moz-tree-checkbox {
list-style-image: none;
-moz-box-align: center;
}
treechildren::-moz-tree-checkbox(checked) {
/* css for checked cells */
list-style-image: url("chrome://global/skin/checkbox/cbox-check.gif");
list-style-image: url("chrome://firetray/skin/cbox-check.gif");
}
treechildren::-moz-tree-checkbox(disabled) {
/* css for disabled checkboxes */
list-style-image: url("chrome://firetray/skin/cbox-disabled.gif");
}
/* properties="disabled" */
treechildren::-moz-tree-cell-text(disabled) {
color: GrayText;
}
/*
treechildren::-moz-tree-cell(disabled) {
background-color: #eeeeee;
}
*/