Commit 4e1807e4 authored by CardBook's avatar CardBook

version 34.6

parent df2200e4
......@@ -368,14 +368,37 @@ if ("undefined" == typeof(wdw_cardEdition)) {
}
},
loadCategories: function (aCategoryList) {
var categoryPanel = document.getElementById("categoriesPanel");
categoryPanel.loadItems("category", "0", cardbookRepository.cardbookAccountsCategories[wdw_cardEdition.workingCard.dirPrefId], aCategoryList);
loadCategories: function (aCategoryChecked) {
let categoryList = cardbookRepository.cardbookAccountsCategories[wdw_cardEdition.workingCard.dirPrefId].concat(aCategoryChecked);
categoryList = cardbookUtils.cleanCategories(categoryList);
categoryList = cardbookUtils.sortArrayByString(categoryList,1);
let listRows = document.getElementById('categoriesMenupopup');
for (let i = listRows.childNodes.length -1; i >= 0; i--) {
let child = listRows.childNodes[i];
if (child.tagName != "textbox" && child.tagName != "menuseparator") {
listRows.removeChild(child);
}
}
for (let cat of categoryList) {
let item = document.createElement("menuitem");
item.setAttribute("class", "menuitem-iconic cardbook-item");
item.setAttribute("label", cat);
item.setAttribute("value", cat);
item.setAttribute("type", "checkbox");
if (aCategoryChecked.includes(cat)) {
item.setAttribute("checked", "true");
}
listRows.appendChild(item);
}
cardbookUtils.updateComplexMenulist('category', 'categoriesMenupopup');
},
getCategories: function () {
var categoryPanel = document.getElementById("categoriesPanel");
return categoryPanel.itemsLabel;
let categoryList = document.getElementById("categoriesMenupopup").querySelectorAll("menuitem.cardbook-item[checked]");
return Array.from(categoryList, cat => cat.getAttribute("value"));
},
display40: function (aCardVersion, aReadOnly) {
......@@ -588,6 +611,8 @@ if ("undefined" == typeof(wdw_cardEdition)) {
var menuItem = document.createElement("menuitem");
menuItem.setAttribute("label", "");
menuItem.setAttribute("value", "");
menuItem.setAttribute("class", "menuitem-iconic");
menuItem.setAttribute("type", "radio");
myPopup.appendChild(menuItem);
document.getElementById('contactMenulist').selectedIndex = 0;
var mySortedContacts = [];
......@@ -602,6 +627,8 @@ if ("undefined" == typeof(wdw_cardEdition)) {
var menuItem = document.createElement("menuitem");
menuItem.setAttribute("label", mySortedContacts[i][0]);
menuItem.setAttribute("value", mySortedContacts[i][1]);
menuItem.setAttribute("class", "menuitem-iconic");
menuItem.setAttribute("type", "radio");
myPopup.appendChild(menuItem);
}
wdw_cardEdition.contactNotLoaded = false;
......
......@@ -118,8 +118,15 @@
<groupbox id="categoriesReadWriteGroupbox" flex="1">
<caption label="&categoriesGroupboxLabel;" class="header"/>
<hbox align="center" flex="1" style="min-height:36px;">
<menulist id="categoriesMenulist" type="cardbookCategoriesPanelMenulist" flex="1" onkeydown="cardbookUtils.enterPanelMenulist('category', event, this);">
<panel id="categoriesPanel" type="cardbookItemCategoryPanel"/>
<menulist id="categoriesMenulist" flex="1" onkeydown="cardbookUtils.panelMenulistKeydown(event, 'category', 'categoriesMenupopup');"
onkeyup="cardbookUtils.panelMenulistKeyup(event, 'category', 'categoriesMenupopup');">
<menupopup id="categoriesMenupopup"
onpopuphiding="return cardbookUtils.panelMenupopupHiding(event, 'category', this.id);" ignorekeys="true">
<textbox id="categoriesTextbox"
placeholder="&categoriesTextboxLabel;"
onkeydown="cardbookUtils.panelTextboxKeydown(event, 'category', 'categoriesMenupopup');"/>
<menuseparator/>
</menupopup>
</menulist>
</hbox>
</groupbox>
......
......@@ -29,14 +29,14 @@ if ("undefined" == typeof(cardbookDates)) {
} else {
switch(myFieldValue.length) {
// datetimes
// 20180904T161908Z
// the mozilla parser does not parse 20180904T161908Z or 20180904T161908
case 15:
case 16:
// the mozilla parser does not parse 20180904T161908Z
if (myFieldValue.length == 16) {
myFieldValue = myFieldValue.slice(0,4) + "-" + myFieldValue.slice(4,6) + "-" + myFieldValue.slice(6,11) + ":" + myFieldValue.slice(11,13) + ":" + myFieldValue.slice(13,16);
}
// 2018-09-04T16:19:08Z
case 17:
case 18:
case 19:
case 20:
myFieldValue = cardbookDates.getCorrectDatetime(myFieldValue);
var myDate = new Date(Date.parse(myFieldValue));
if (isNaN(myDate)) {
return new Date(Date.UTC('666', '6', '6'));
......@@ -70,14 +70,14 @@ if ("undefined" == typeof(cardbookDates)) {
} else {
switch(myFieldValue.length) {
// datetimes
// 20180904T161908Z
// the mozilla parser does not parse 20180904T161908Z or 20180904T161908
case 15:
case 16:
// the mozilla parser does not parse 20180904T161908Z
if (myFieldValue.length == 16) {
myFieldValue = myFieldValue.slice(0,4) + "-" + myFieldValue.slice(4,6) + "-" + myFieldValue.slice(6,11) + ":" + myFieldValue.slice(11,13) + ":" + myFieldValue.slice(13,16);
}
// 2018-09-04T16:19:08Z
case 17:
case 18:
case 19:
case 20:
myFieldValue = cardbookDates.getCorrectDatetime(myFieldValue);
return cardbookDates.getFormattedDateTimeForDateTimeString(myFieldValue, cardbookRepository.dateDisplayedFormat);
break;
......@@ -217,6 +217,31 @@ if ("undefined" == typeof(cardbookDates)) {
}
},
getCorrectDatetime: function (aValue) {
// 20190208T000004
// 20190208T000004Z
if (aValue.length == 15 ||aValue.length == 16) {
aValue = aValue.slice(0,4) + "-" + aValue.slice(4,6) + "-" + aValue.slice(6,11) + ":" + aValue.slice(11,13) + ":" + aValue.slice(13,15) + "Z";
// 2019-02-08T000004
} else if (aValue.length == 17 && aValue.includes("-")) {
aValue = aValue.slice(0,4) + "-" + aValue.slice(5,7) + "-" + aValue.slice(8,13) + ":" + aValue.slice(13,15) + ":" + aValue.slice(15,17) + "Z";
// 20190208T00:00:04
} else if (aValue.length == 17 && aValue.includes(":")) {
aValue = aValue.slice(0,4) + "-" + aValue.slice(4,6) + "-" + aValue.slice(6,17) + "Z";
// 2019-02-08T000004Z
} else if (aValue.length == 18 && aValue.includes("-")) {
aValue = aValue.slice(0,4) + "-" + aValue.slice(5,7) + "-" + aValue.slice(8,13) + ":" + aValue.slice(13,15) + ":" + aValue.slice(15,17) + "Z";
// 20190208T00:00:04Z
} else if (aValue.length == 18 && aValue.includes(":")) {
aValue = aValue.slice(0,4) + "-" + aValue.slice(4,6) + "-" + aValue.slice(6,17) + "Z";
// 2019-02-08T00:00:04
} else if (aValue.length == 19) {
aValue = aValue + "Z";
}
// 2019-02-08T00:00:04Z
return aValue;
},
getSeparator: function (aDateFormat) {
switch(aDateFormat) {
case "YYYY-MM-DD":
......@@ -243,11 +268,9 @@ if ("undefined" == typeof(cardbookDates)) {
convertDateStringToDate: function (aDateString, aDateFormat) {
try {
// datetimes
// the mozilla parser does not parse 20180904T161908Z
if (aDateString.length == 16 || aDateString.length == 20) {
if (aDateString.length == 16) {
aDateString = aDateString.slice(0,4) + "-" + aDateString.slice(4,6) + "-" + aDateString.slice(6,11) + ":" + aDateString.slice(11,13) + ":" + aDateString.slice(13,16);
}
// the mozilla parser does not parse 20180904T161908Z or 20180904T161908
if (aDateString.length >= 15 && aDateString.length <= 20) {
aDateString = cardbookDates.getCorrectDatetime(aDateString);
var myDate = new Date(Date.parse(aDateString));
if (isNaN(myDate)) {
return "WRONGDATE";
......
This diff is collapsed.
......@@ -311,19 +311,41 @@ if ("undefined" == typeof(cardbookTypes)) {
}
var myLineTypeType = [];
var myPanel = document.getElementById(aType + '_' + aIndex + '_PanelType');
var itemsListbox = document.getElementById(aType + '_' + aIndex + '_MenulistType');
var myTypes = [];
if (itemsListbox) {
var item = itemsListbox.querySelectorAll("menuitem.cardbook-item[checked]");
if (item[0]) {
var myValue = item[0].getAttribute('value').trim();
myTypes = [myValue, "PG"];
var ABType = cardbookPreferences.getType(wdw_cardEdition.workingCard.dirPrefId);
var ABTypeFormat = cardbookRepository.getABTypeFormat(ABType);
for (var i = 0; i < cardbookRepository.cardbookCoreTypes[ABTypeFormat][aType].length; i++) {
if (myValue == cardbookRepository.cardbookCoreTypes[ABTypeFormat][aType][i][0]) {
var prefPossibility = cardbookRepository.cardbookCoreTypes[ABTypeFormat][aType][i][1].split(";")[0];
if (cardbookRepository.cardbookCoreTypes[ABTypeFormat][aType][i][2] && cardbookRepository.cardbookCoreTypes[ABTypeFormat][aType][i][2] == "PG") {
myTypes = [prefPossibility, "PG"];
} else {
myTypes = [prefPossibility, "NOPG"];
}
}
}
} else {
myTypes = [];
}
}
var myOutputPg = [];
var myPgName = "";
if (myPanel) {
if (myPanel.types.length != 0) {
if (myPanel.types[1] == "PG") {
myOutputPg = [ "X-ABLABEL:" + myPanel.types[0] ];
myPgName = "ITEM1";
} else {
myLineTypeType.push("TYPE=" + myPanel.types[0]);
}
if (myTypes.length != 0) {
if (myTypes[1] == "PG") {
myOutputPg = [ "X-ABLABEL:" + myTypes[0] ];
myPgName = "ITEM1";
} else {
myLineTypeType.push("TYPE=" + myTypes[0]);
}
}
if (myLineTypeType.length > 0) {
myLineTypeResult = myLineTypeResult.concat(myLineTypeType);
myLineTypeResult = cardbookUtils.unescapeArray(cardbookUtils.formatTypes(cardbookUtils.escapeArray(myLineTypeResult)));
......
......@@ -124,96 +124,132 @@ if ("undefined" == typeof(cardbookUtils)) {
}
},
// allow the keyboard navigation for the type and category panel
enterPanelMenulist: function (aType, aEvent, aMenulist) {
let myPanel = document.getElementById(aMenulist.id.replace("Menulist", "Panel"));
let myListBox = document.getAnonymousElementByAttribute(myPanel, "anonid", "itemsListbox");
let myTextBox = document.getAnonymousElementByAttribute(myPanel, "anonid", "addItemTextbox");
if (aEvent.key == "Tab" && !aEvent.shiftKey) {
if (myTextBox.hasAttribute("focused")) {
if (myListBox.itemCount != 0) {
if (!myListBox.selectedItem) {
myListBox.selectedItem = myListBox.firstChild;
}
myListBox.selectedItem.focus();
aEvent.stopImmediatePropagation();
} else {
myPanel.hidePopup();
cardbookUtils.updatePanelMenulist(aType, myPanel);
aMenulist.focus();
}
} else {
myPanel.hidePopup();
cardbookUtils.updatePanelMenulist(aType, myPanel);
aMenulist.focus();
}
} else if (aEvent.key == "Tab" && aEvent.shiftKey) {
if (myTextBox.hasAttribute("focused")) {
myPanel.hidePopup();
}
} else if (aEvent.key == "Escape") {
aMenulist.focus();
cardbookUtils.updatePanelMenulist(aType, myPanel);
aEvent.stopPropagation();
} else if (myTextBox.hasAttribute("focused")) {
aEvent.stopPropagation();
} else if (((aEvent.key == "ArrowDown") || (aEvent.key == "ArrowUp")) && (document.commandDispatcher.focusedElement == aMenulist)) {
myPanel.openPopup(aEvent.target, 'after_start');
if (aType === "type") {
if (!myListBox.selectedItem) {
myListBox.selectedItem = myListBox.firstChild;
}
myListBox.focus();
panelMenupopupHiding: function (aEvent, aType, aMenupopupName) {
cardbookUtils.updateComplexMenulist(aType, aMenupopupName);
if (aType === "type") {
return true;
} else {
return aEvent.explicitOriginalTarget.localName != "menuitem";
}
},
panelMenulistKeydown: function (aEvent, aType, aMenupopupName) {
let myMenupopup = document.getElementById(aMenupopupName);
let myTextbox = document.getElementById(aMenupopupName.replace("Menupopup", "Textbox"));
switch (aEvent.key) {
case "ArrowDown":
case "ArrowUp":
myMenupopup.openPopup(myMenupopup, "after_start", 0, 0, false, false);
setTimeout(function() {
myTextbox.focus();
}, 0);
aEvent.preventDefault();
return;
default:
return;
}
},
panelMenulistKeyup: function (aEvent, aType, aMenupopupName) {
let myMenupopup = document.getElementById(aMenupopupName);
let myMenulist = document.getElementById(aMenupopupName.replace("Menupopup", "Menulist"));
var myLabel = myMenulist.getAttribute('label');
if (aType == "category") {
if (myLabel == cardbookRepository.strBundle.GetStringFromName("multipleCategories")) {
return;
}
} else if (aType == "type") {
if (myLabel == cardbookRepository.strBundle.GetStringFromName("multipleTypes")) {
return;
}
}
for (var i = 0; i < myMenupopup.childNodes.length; i++) {
var child = myMenupopup.childNodes[i];
if (child.getAttribute('label') == myLabel) {
child.setAttribute("checked", "true");
} else {
myTextBox.focus();
}
} else if ((aEvent.key != "ArrowDown") && (aEvent.key != "ArrowUp")) {
if (!myTextBox.hasAttribute("focused")) {
let found = false;
// first try to find if there is a matching entry
for (var i = 0; i < myListBox.itemCount; i++) {
var myItem = myListBox.getItemAtIndex(i);
if (myItem.getAttribute("label").substr(0,1).toLowerCase() == aEvent.key.toLowerCase()) {
myItem.checked = !myListBox.getItemAtIndex(i).checked;
if (myItem.checked) {
myPanel.validateCheckboxes(myItem.getAttribute("id"));
}
myListBox.selectedItem = myListBox.getItemAtIndex(i);
found = true;
break;
}
}
if (!found) {
// if not open the popup
myPanel.openPopup(aEvent.target, 'after_start');
if (!myListBox.selectedItem) {
myListBox.selectedItem = myListBox.firstChild;
}
myListBox.focus();
child.removeAttribute("checked");
}
}
},
panelTextboxKeydown: function (aEvent, aType, aMenupopupName) {
let itemValue = aEvent.target.value;
let myMenupopup = document.getElementById(aMenupopupName);
let myMenulist = document.getElementById(aMenupopupName.replace("Menupopup", "Menulist"));
switch (aEvent.key) {
case "Escape":
if (itemValue) {
aEvent.target.value = "";
} else {
cardbookUtils.updatePanelMenulist(aType, myPanel);
myMenupopup.hidePopup();
}
setTimeout(function() {
myMenulist.focus();
}, 0);
aEvent.preventDefault();
return;
case "Enter":
itemValue = itemValue.trim();
if (itemValue != "") {
break;
}
return;
default:
return;
}
aEvent.preventDefault();
let itemList = myMenupopup.querySelectorAll("menuitem.cardbook-item");
let items = Array.from(itemList, item => item.getAttribute("value"));
let newIndex = items.indexOf(itemValue);
if (newIndex > -1) {
itemList[newIndex].setAttribute("checked", true);
} else {
items.push(itemValue);
items = cardbookUtils.sortArrayByString(items,1);
newIndex = items.indexOf(itemValue);
let item = document.createElement("menuitem");
item.setAttribute("class", "menuitem-iconic cardbook-item");
item.setAttribute("label", itemValue);
item.setAttribute("value", itemValue);
if (aType == "type") {
item.setAttribute("type", "radio");
} else {
item.setAttribute("type", "checkbox");
}
item.setAttribute("checked", true);
myMenupopup.insertBefore(item, itemList[newIndex]);
}
aEvent.target.value = "";
// By pushing this to the end of the event loop, the other checked items in the list
// are cleared, where only one category is allowed.
setTimeout(function() {
cardbookUtils.updateComplexMenulist(aType, aMenupopupName);
}, 0);
},
updatePanelMenulist: function (aType, aPanel) {
let myMenulist = document.getElementById(aPanel.id.replace("Panel", "Menulist"));
updateComplexMenulist: function (aType, aMenupopupName) {
let myMenupopup = document.getElementById(aMenupopupName);
let myMenulist = document.getElementById(aMenupopupName.replace("Menupopup", "Menulist"));
let label = "";
let itemsList = aPanel.itemsLabel;
let itemsList = myMenupopup.querySelectorAll("menuitem.cardbook-item[checked]");
if (itemsList.length > 1) {
if (aType === "category") {
if (aType == "category") {
label = cardbookRepository.strBundle.GetStringFromName("multipleCategories");
} else if (aType === "type") {
} else if (aType == "type") {
label = cardbookRepository.strBundle.GetStringFromName("multipleTypes");
}
} else if (itemsList.length == 1) {
label = itemsList[0];
label = itemsList[0].getAttribute("label");
} else {
if (aType === "category") {
if (aType == "category") {
label = cardbookRepository.strBundle.GetStringFromName("none");
} else if (aType === "type") {
} else if (aType == "type") {
// label = cardbookRepository.strBundle.GetStringFromName("noType");
// better empty
label = "";
......@@ -522,17 +558,6 @@ if ("undefined" == typeof(cardbookUtils)) {
return vArrayNew;
},
escapeArraySemiColon: function (vArray) {
vArrayNew = [];
vArrayNew = JSON.parse(JSON.stringify(vArray));
for (let i = 0; i<vArrayNew.length; i++){
if (vArrayNew[i] && vArrayNew[i] != ""){
vArrayNew[i] = vArrayNew[i].replace(/;/g,"@ESCAPEDSEMICOLON@");
}
}
return vArrayNew;
},
escapeStringSemiColon: function (vString) {
return vString.replace(/;/g,"@ESCAPEDSEMICOLON@");
},
......@@ -2936,6 +2961,7 @@ if ("undefined" == typeof(cardbookUtils)) {
var myMenuItem = document.createElement("menuitem");
myMenuItem.setAttribute("id", myCategory);
myMenuItem.setAttribute("type", "checkbox");
myMenuItem.setAttribute("class", "menuitem-iconic");
myMenuItem.addEventListener("command", function(aEvent) {
if (this.getAttribute("checked") == "true") {
wdw_cardbook.addCategoryToSelectedCards(this.id, false);
......
......@@ -500,7 +500,7 @@
<groupbox>
<caption label="&customFieldsTabLabel;"/>
<hbox align="center">
<radiogroup id="customFieldsCategoryRadiogroup" orient="horizontal" onselect="wdw_cardbookConfiguration.sortTrees(null, 'customFields');">
<radiogroup id="customFieldsCategoryRadiogroup" orient="horizontal" onselect="wdw_cardbookConfiguration.sortTrees(null, 'customFieldsTree');">
<radio value="pers" label="&customFieldsPersTitleLabel;" accesskey="&customFieldsPersTitleAccesskey;" selected="true"/>
<radio value="org" label="&customFieldsOrgTitleLabel;" accesskey="&customFieldsOrgTitleAccesskey;"/>
</radiogroup>
......@@ -509,15 +509,15 @@
<hbox flex="1">
<vbox flex="1">
<hbox flex="1">
<tree id="customFields" class="cardbookTreeChildrenConfigClass" hidecolumnpicker="true" flex="1" seltype="single" enableColumnDrag="false" onselect="wdw_cardbookConfiguration.selectCustomFields();" sortDirection="ascending" sortResource="customFieldsRank">
<tree id="customFieldsTree" class="cardbookTreeChildrenConfigClass" hidecolumnpicker="true" flex="1" seltype="single" enableColumnDrag="false" onselect="wdw_cardbookConfiguration.selectCustomFields();" sortDirection="ascending" sortResource="customFieldsRank">
<treecols id="customFieldsTreeCols">
<treecol id="customFieldsRank" label="&customFieldRankLabel;" onclick="wdw_cardbookConfiguration.sortTreesFromCol(event, this, 'customFields');" persist="width ordinal hidden" style="text-align:left"/>
<treecol id="customFieldsRank" label="&customFieldRankLabel;" onclick="wdw_cardbookConfiguration.sortTreesFromCol(event, this, 'customFieldsTree');" persist="width ordinal hidden" style="text-align:left"/>
<splitter class="tree-splitter"/>
<treecol id="customFieldsCode" label="&customFieldCodeLabel;" onclick="wdw_cardbookConfiguration.sortTreesFromCol(event, this, 'customFields');" persist="width ordinal hidden" style="text-align:left"/>
<treecol id="customFieldsCode" label="&customFieldCodeLabel;" onclick="wdw_cardbookConfiguration.sortTreesFromCol(event, this, 'customFieldsTree');" persist="width ordinal hidden" style="text-align:left"/>
<splitter class="tree-splitter"/>
<treecol id="customFieldsLabel" label="&customFieldLabelLabel;" onclick="wdw_cardbookConfiguration.sortTreesFromCol(event, this, 'customFields');" flex="1" persist="width ordinal hidden" style="text-align:left"/>
<treecol id="customFieldsLabel" label="&customFieldLabelLabel;" onclick="wdw_cardbookConfiguration.sortTreesFromCol(event, this, 'customFieldsTree');" flex="1" persist="width ordinal hidden" style="text-align:left"/>
</treecols>
<treechildren id="customFieldsTreeChildren" ondblclick="wdw_cardbookConfiguration.doubleClickTree(event, 'customFields');"/>
<treechildren id="customFieldsTreeChildren" ondblclick="wdw_cardbookConfiguration.doubleClickTree(event, 'customFieldsTree');"/>
</tree>
</hbox>
</vbox>
......@@ -540,7 +540,16 @@
<separator class="thin"/>
<hbox flex="1">
<vbox flex="1">
<listbox rows="8" id="orgListbox" onselect="wdw_cardbookConfiguration.selectOrg();" ondblclick="wdw_cardbookConfiguration.renameOrg();"/>
<hbox flex="1">
<tree id="orgTree" class="cardbookTreeChildrenConfigClass" hidecolumnpicker="true" flex="1" seltype="single" enableColumnDrag="false" editable="true" onselect="wdw_cardbookConfiguration.selectOrg();" sortDirection="ascending" sortResource="orgRank">
<treecols id="orgTreeCols">
<treecol id="orgRank" label="&orgRankLabel;" onclick="wdw_cardbookConfiguration.sortTreesFromCol(event, this, 'orgTree');" persist="width ordinal hidden" style="text-align:left"/>
<splitter class="tree-splitter"/>
<treecol id="orgLabel" label="&orgLabelLabel;" onclick="wdw_cardbookConfiguration.sortTreesFromCol(event, this, 'orgTree');" flex="1" persist="width ordinal hidden" style="text-align:left"/>
</treecols>
<treechildren id="orgTreeChildren" ondblclick="wdw_cardbookConfiguration.doubleClickTree(event, 'orgTree');"/>
</tree>
</hbox>
</vbox>
<hbox align="top">
<vbox flex="1">
......
......@@ -101,7 +101,7 @@ if ("undefined" == typeof(ovl_synchro)) {
prefs.setCharPref("accountsShown", "all");
prefs.setCharPref("accountShown", "");
prefs.setCharPref("uncategorizedCards", "");
prefs.setCharPref("addonVersion", "34.5");
prefs.setCharPref("addonVersion", "34.6");
prefs.setCharPref("defaultRegion", "NOTSET");
prefs.setBoolPref("localDataEncryption", false);
......
......@@ -1866,12 +1866,6 @@ if ("undefined" == typeof(wdw_cardbook)) {
},
enableOrDisableAddressbook: function (aDirPrefId, aValue) {
if (cardbookUtils.isMyAccountSyncing(aDirPrefId)) {
return;
}
cardbookSynchronization.initMultipleOperations(aDirPrefId);
wdw_cardbook.setNoComplexSearchMode();
wdw_cardbook.setNoSearchMode();
if (!(aDirPrefId != null && aDirPrefId !== undefined && aDirPrefId != "")) {
var myTree = document.getElementById('accountsOrCatsTree');
if (myTree.currentIndex != -1) {
......@@ -1881,6 +1875,12 @@ if ("undefined" == typeof(wdw_cardbook)) {
return;
}
}
if (cardbookUtils.isMyAccountSyncing(aDirPrefId)) {
return;
}
cardbookSynchronization.initMultipleOperations(aDirPrefId);
wdw_cardbook.setNoComplexSearchMode();
wdw_cardbook.setNoSearchMode();
if (!aValue) {
cardbookSynchronization.removePeriodicSync(aDirPrefId);
cardbookRepository.removeAccountFromCollected(aDirPrefId);
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- adapted from Lightning -->
<!DOCTYPE dialog [
<!ENTITY % cardbookCategoryPanelDTD SYSTEM "chrome://cardbook/locale/wdw_categoriesEdition.dtd"> %cardbookCategoryPanelDTD;
]>
<bindings id="cardbookCategoryPanel"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<!-- Unfortunately, the normal menulist binding doesn't allow a panel child
This binding replaces the usual menulist to allow a panel -->
<binding id="cardbookCategoriesPanelMenulist" extends="chrome://global/content/bindings/menulist.xml#menulist">
<content sizetopopup="pref">
<xul:hbox class="menulist-label-box" flex="1">
<xul:image class="menulist-icon" xbl:inherits="src=image,src"/>
<xul:label class="menulist-label" xbl:inherits="value=label,crop,accesskey" crop="right" flex="1"/>
</xul:hbox>
<xul:dropmarker class="menulist-dropmarker" type="menu" xbl:inherits="disabled,open"/>
<children includes="menupopup|panel"/>
</content>
</binding>
<binding id="cardbookItemCategoryPanel" extends="chrome://global/content/bindings/popup.xml#panel">
<resources>
<stylesheet src="chrome://cardbook/skin/cardbookCategoryPanel.css"/>
<!-- for the small-button class -->
<stylesheet src="chrome://messenger/skin/searchDialog.css"/>
</resources>
<content>
<xul:hbox flex="1">
<xul:textbox anonid="addItemTextbox"
class="addItemTextboxClass"
type="search"
searchbutton="true"
oncommand="document.getBindingParent(this).addNewItem();"
flex="1"/>
</xul:hbox>
<xul:listbox anonid="itemsListbox" class="itemsListboxClass" selType="single"/>
</content>
<implementation>
<field name="type"></field>
<field name="index"></field>
<field name="dirPrefId"></field>
<!-- sourceItems : [ value0, ...] -->
<field name="sourceItems">[]</field>
<!-- checkedItems : [ value0, ...] -->
<field name="checkedItems">[]</field>
<property name="itemsValue" readonly="true">
<getter><![CDATA[
return this.getItems('value');
]]></getter>
</property>
<property name="itemsLabel" readonly="true">
<getter><![CDATA[
return this.getItems('label');
]]></getter>
</property>
<method name="getItems">
<!-- aValue : value|label -->
<parameter name="aValue"/>
<body><![CDATA[
let itemsListbox = document.getAnonymousElementByAttribute(this, "anonid", "itemsListbox");
let myItemList = [];
for (var i=0; i<itemsListbox.itemCount; i++) {
var aItem = itemsListbox.getItemAtIndex(i);
var aItemChecked = aItem.getAttribute('checked');
aItemChecked = typeof aItemChecked == "boolean" ? aItemChecked : (aItemChecked == 'true' ? true : false);
if (aItemChecked) {
myItemList.push(aItem.getAttribute(aValue).trim());
}
}
return myItemList;
]]></body>
</method>
<method name="addNewItem">
<body><![CDATA[
let addItemTextbox = document.getAnonymousElementByAttribute(this, "anonid", "addItemTextbox");
let newItem = addItemTextbox.value;
if (!newItem) {
return;
}
addItemTextbox.value = "";
this.sourceItems.push(newItem);
this.checkedItems = JSON.parse(JSON.stringify(this.itemsValue));
this.checkedItems.push(newItem);
this.checkedItems = cardbookUtils.sortArrayByString(this.checkedItems,1);
this.loadItems(this.type, this.index, this.sourceItems, this.checkedItems);
]]></body>
</method>
<method name="validateCheckboxes">
<parameter name="aItemId"/>
<body><![CDATA[
return;
]]></body>
</method>
<method name="addLine">
<parameter name="aLabel"/>
<parameter name="aCode"/>
<body><![CDATA[
var itemsListbox = document.getAnonymousElementByAttribute(this, "anonid", "itemsListbox");
var aItem = itemsListbox.appendItem(aLabel, aCode);
aItem.setAttribute('id', this.type + '_' + this.index + '_' + aCode);
aItem.setAttribute('type', 'checkbox');
var this_ = this;
aItem.addEventListener("command", function() {
cardbookUtils.updatePanelMenulist("category", this_);
}, false);
]]></body>
</method>
<method name="displayItems">
<!-- aSourceList : [ [label0, value0] , ...] -->
<parameter name="aSourceList"/>
<!-- aCheckedSourceList : [ value0, ...] -->