Commit 5f9c9b78 authored by CardBook's avatar CardBook

version 26.8

parent 708c8bf9
......@@ -282,7 +282,9 @@ if ("undefined" == typeof(wdw_addressbooksAdd)) {
},
constructComplexSearch: function () {
cardbookElementTools.loadAddressBooks("addressbookMenupopup", "addressbookMenulist", wdw_addressbooksAdd.gSearchDefinition.searchAB, true, true, true, false);
var ABList = document.getElementById('addressbookMenulist');
var ABPopup = document.getElementById('addressbookMenupopup');
cardbookElementTools.loadAddressBooks(ABPopup, ABList, wdw_addressbooksAdd.gSearchDefinition.searchAB, true, true, true, false, false);
cardbookComplexSearch.loadMatchAll(wdw_addressbooksAdd.gSearchDefinition.matchAll);
cardbookComplexSearch.constructDynamicRows("searchTerms", wdw_addressbooksAdd.gSearchDefinition.rules, "3.0");
document.getElementById('searchTerms_0_valueBox').focus();
......
......@@ -6,6 +6,7 @@ if ("undefined" == typeof(wdw_addressbooksEdit)) {
initialDateFormat: "",
loadFnFormula: function () {
document.getElementById("fnFormulaTextBox").value = cardbookPreferences.getFnFormula(window.arguments[0].dirPrefId);
var strBundle = document.getElementById("cardbook-strings");
var orgStructure = cardbookPreferences.getStringPref("extensions.cardbook.orgStructure");
if (orgStructure != "") {
......@@ -69,7 +70,6 @@ if ("undefined" == typeof(wdw_addressbooksEdit)) {
document.getElementById('syncTab').setAttribute("collapsed", true);
}
document.getElementById("fnFormulaTextBox").value = cardbookPreferences.getFnFormula(window.arguments[0].dirPrefId);
wdw_addressbooksEdit.loadFnFormula();
},
......
......@@ -773,8 +773,10 @@ if ("undefined" == typeof(wdw_cardEdition)) {
wdw_cardEdition.workingCard = new cardbookCardParser();
cardbookUtils.cloneCard(window.arguments[0].cardIn, wdw_cardEdition.workingCard);
cardbookElementTools.loadAddressBooks("addressbookMenupopup", "addressbookMenulist", wdw_cardEdition.workingCard.dirPrefId, true, false,
(window.arguments[0].editionMode == "ViewContact" || window.arguments[0].editionMode == "ViewList"), false);
var ABList = document.getElementById('addressbookMenulist');
var ABPopup = document.getElementById('addressbookMenupopup');
cardbookElementTools.loadAddressBooks(ABPopup, ABList, wdw_cardEdition.workingCard.dirPrefId, true, false,
(window.arguments[0].editionMode == "ViewContact" || window.arguments[0].editionMode == "ViewList"), false, false);
if (wdw_cardEdition.workingCard.dirPrefId == "") {
wdw_cardEdition.workingCard.dirPrefId = document.getElementById('addressbookMenulist').selectedItem.value;
}
......
......@@ -321,15 +321,15 @@
hidecolumnpicker="false" persist="height sortDirection sortResource" sortDirection="ascending" sortResource="availableCardsName"
onclick="wdw_cardEdition.sortTrees(event, 'availableCards');">
<treecols id="availableCardsTreeCols">
<treecol id="availableCardsName" label="&nameColumnLabel;" flex="1" persist="width ordinal hidden" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
<treecol id="availableCardsName" label="&nameLabel;" flex="1" persist="width ordinal hidden" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
<splitter class="tree-splitter"/>
<treecol id="availableCardsUid" label="&uidColumnLabel;" flex="1" persist="width ordinal hidden" hidden="true" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
<treecol id="availableCardsUid" label="&uidLabel;" flex="1" persist="width ordinal hidden" hidden="true" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
<splitter class="tree-splitter"/>
<treecol id="availableCardsFn" label="&fnColumnLabel;" flex="1" persist="width ordinal hidden" hidden="true" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
<treecol id="availableCardsFn" label="&fnLabel;" flex="1" persist="width ordinal hidden" hidden="true" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
<splitter class="tree-splitter"/>
<treecol id="availableCardsLastname" label="&lastnameColumnLabel;" flex="1" persist="width ordinal hidden" hidden="true" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
<treecol id="availableCardsLastname" label="&lastnameLabel;" flex="1" persist="width ordinal hidden" hidden="true" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
<splitter class="tree-splitter"/>
<treecol id="availableCardsFirstname" label="&firstnameColumnLabel;" flex="1" persist="width ordinal hidden" hidden="true" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
<treecol id="availableCardsFirstname" label="&firstnameLabel;" flex="1" persist="width ordinal hidden" hidden="true" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
</treecols>
<treechildren id="availableCardsTreeChildren" ondblclick="wdw_cardEdition.modifyLists(this);"/>
</tree>
......@@ -352,15 +352,15 @@
hidecolumnpicker="false" persist="height sortDirection sortResource" sortDirection="ascending" sortResource="addedCardsName"
onclick="wdw_cardEdition.sortTrees(event, 'addedCards');">
<treecols id="addedCardsTreeCols">
<treecol id="addedCardsName" label="&nameColumnLabel;" flex="1" persist="width ordinal hidden" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
<treecol id="addedCardsName" label="&nameLabel;" flex="1" persist="width ordinal hidden" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
<splitter class="tree-splitter"/>
<treecol id="addedCardsUid" label="&uidColumnLabel;" flex="1" persist="width ordinal hidden" hidden="true" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
<treecol id="addedCardsUid" label="&uidLabel;" flex="1" persist="width ordinal hidden" hidden="true" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
<splitter class="tree-splitter"/>
<treecol id="addedCardsFn" label="&fnColumnLabel;" flex="1" persist="width ordinal hidden" hidden="true" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
<treecol id="addedCardsFn" label="&fnLabel;" flex="1" persist="width ordinal hidden" hidden="true" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
<splitter class="tree-splitter"/>
<treecol id="addedCardsLastname" label="&lastnameColumnLabel;" flex="1" persist="width ordinal hidden" hidden="true" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
<treecol id="addedCardsLastname" label="&lastnameLabel;" flex="1" persist="width ordinal hidden" hidden="true" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
<splitter class="tree-splitter"/>
<treecol id="addedCardsFirstname" label="&firstnameColumnLabel;" flex="1" persist="width ordinal hidden" hidden="true" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
<treecol id="addedCardsFirstname" label="&firstnameLabel;" flex="1" persist="width ordinal hidden" hidden="true" style="text-align:left" class="sortDirectionIndicator" sortDirection="ascending"/>
</treecols>
<treechildren id="addedCardsTreeChildren" ondblclick="wdw_cardEdition.modifyLists(this);"/>
</tree>
......
......@@ -29,10 +29,10 @@ if ("undefined" == typeof(cardbookCardParser)) {
this.nickname = "";
this.bday = "";
this.gender = "";
this.birthplace= "";
this.anniversary= "";
this.deathdate= "";
this.deathplace= "";
this.birthplace = "";
this.anniversary = "";
this.deathdate = "";
this.deathplace = "";
this.adr = [];
this.tel = [];
this.email = [];
......@@ -65,20 +65,6 @@ if ("undefined" == typeof(cardbookCardParser)) {
this.kind = "";
this.member = [];
this.dispadr = "";
this.disphomeadr = "";
this.dispworkadr = "";
this.disptel = "";
this.disphometel = "";
this.dispworktel = "";
this.dispcelltel = "";
this.dispemail = "";
this.disphomeemail = "";
this.dispworkemail = "";
this.dispimpp = "";
this.dispurl = "";
this.dispcategories = "";
this.pgname = "";
this.pg = {};
},
......
......@@ -9,10 +9,13 @@ if ("undefined" == typeof(cardbookElementTools)) {
},
deleteRows: function (aObjectName) {
var aListRows = document.getElementById(aObjectName);
while (aListRows.firstChild) {
aListRows.removeChild(aListRows.firstChild);
}
// for anonid this does not work
try {
var aListRows = document.getElementById(aObjectName);
while (aListRows.firstChild) {
aListRows.removeChild(aListRows.firstChild);
}
} catch (e) {}
},
addCaption: function (aType, aParent) {
......@@ -24,10 +27,14 @@ if ("undefined" == typeof(cardbookElementTools)) {
aCaption.setAttribute('class', 'header');
},
addTreeSplitter: function (aParent) {
addTreeSplitter: function (aParent, aParameters) {
var aSplitter = document.createElement('splitter');
aParent.appendChild(aSplitter);
aSplitter.setAttribute('class', 'tree-splitter');
for (var prop in aParameters) {
aSplitter.setAttribute(prop, aParameters[prop]);
}
},
addTreecol: function (aParent, aId, aLabel, aParameters) {
......@@ -193,9 +200,9 @@ if ("undefined" == typeof(cardbookElementTools)) {
document.getElementById(aMenuName).selectedIndex = defaultIndex;
},
loadAddressBooks: function (aPopupName, aMenuName, aDefaultId, aExclusive, aAddAllABs, aIncludeReadOnly, aIncludeSearch, aInclRestrictionList, aExclRestrictionList) {
var myPopup = document.getElementById(aPopupName);
cardbookElementTools.deleteRows(aPopupName);
loadAddressBooks: function (aPopup, aMenu, aDefaultId, aExclusive, aAddAllABs, aIncludeReadOnly, aIncludeSearch, aIncludeDisabled,
aInclRestrictionList, aExclRestrictionList) {
cardbookElementTools.deleteRows(aPopup.id);
var defaultIndex = 0;
var j = 0;
if (aAddAllABs) {
......@@ -203,7 +210,7 @@ if ("undefined" == typeof(cardbookElementTools)) {
var menuItem = document.createElement("menuitem");
menuItem.setAttribute("label", strBundle.GetStringFromName("allAddressBooks"));
menuItem.setAttribute("value", "allAddressBooks");
myPopup.appendChild(menuItem);
aPopup.appendChild(menuItem);
if ("allAddressBooks" == aDefaultId) {
defaultIndex=j;
}
......@@ -211,8 +218,9 @@ if ("undefined" == typeof(cardbookElementTools)) {
}
var sortedAddressBooks = [];
for (var i = 0; i < cardbookRepository.cardbookAccounts.length; i++) {
if (cardbookRepository.cardbookAccounts[i][1] && cardbookRepository.cardbookAccounts[i][5] && (aIncludeReadOnly || !cardbookRepository.cardbookAccounts[i][7])
&& (aIncludeSearch || (cardbookRepository.cardbookAccounts[i][6] !== "SEARCH"))) {
if (cardbookRepository.cardbookAccounts[i][1] && (aIncludeDisabled || cardbookRepository.cardbookAccounts[i][5])
&& (aIncludeReadOnly || !cardbookRepository.cardbookAccounts[i][7])
&& (aIncludeSearch || (cardbookRepository.cardbookAccounts[i][6] !== "SEARCH"))) {
if (aExclRestrictionList && aExclRestrictionList[cardbookRepository.cardbookAccounts[i][4]]) {
continue;
}
......@@ -250,13 +258,13 @@ if ("undefined" == typeof(cardbookElementTools)) {
menuItem.setAttribute("value", sortedAddressBooks[i][1]);
menuItem.setAttribute("ABtype", sortedAddressBooks[i][2]);
menuItem.setAttribute("class", "menuitem-iconic");
myPopup.appendChild(menuItem);
aPopup.appendChild(menuItem);
if (sortedAddressBooks[i][1] == aDefaultId) {
defaultIndex=j;
}
j++;
}
document.getElementById(aMenuName).selectedIndex = defaultIndex;
aMenu.selectedIndex = defaultIndex;
},
loadCategories: function (aPopupName, aMenuName, aDefaultPrefId, aDefaultCatId, aAddAllCats, aAddOnlyCats, aAddNoCats, aAddEmptyCats, aInclRestrictionList, aExclRestrictionList) {
......
......@@ -290,7 +290,9 @@ if ("undefined" == typeof(cardBookObserver)) {
case "cardbook.preferencesChanged":
cardbookRepository.loadCustoms();
wdw_cardbook.loadCssRules();
wdw_cardbook.addCustomColumns();
var myColumns = cardbookUtils.getColumnsState().split(',');
wdw_cardbook.addTreeColumns();
cardbookUtils.setColumnsState(myColumns);
wdw_cardbook.refreshWindow();
break;
case "cardbook.catAddedDirect":
......@@ -310,4 +312,19 @@ if ("undefined" == typeof(cardBookObserver)) {
}
}
};
var cardBookWindowMutationObserver = {
register: function() {
var observer = new MutationObserver(function handleMutations(mutations) {
if (cardbookRepository.cardbookReorderMode == "NOREORDER") {
cardbookUtils.saveColumnsState();
}
});
observer.observe(document.getElementById("cardsTreecols"), {
attributes: true,
subtree: true,
attributeFilter: ["hidden", "ordinal"]
});
}
};
};
......@@ -23,10 +23,13 @@ var cardbookRepository = {
["url", ["url"] ] ],
"note": ["note"],
"calculated": ["age", "ABName"],
"technical": ["version", "rev"] },
"technical": ["version", "rev"],
"technicalForTree": ["cardIcon", "name", "dirPrefId", "uid", "cbid", "class1", "etag", "geo", "mailer",
"prodid", "tz", "sortstring", "kind"] },
dateFormats : ["YYYY-MM-DD", "YYYY.MM.DD", "YYYY/MM/DD", "YYYYMMDD", "DD-MM-YYYY", "DD.MM.YYYY", "DD/MM/YYYY", "DDMMYYYY", "MM-DD-YYYY", "MM.DD.YYYY", "MM/DD/YYYY", "MMDDYYYY"],
defaultDisplayedColumns : "cardIcon,fn,email.0.all,tel.0.all,bday,rev",
defaultAutocompleteRestrictSearchFields : "firstname|lastname",
defaultFnFormula : "({{1}} |)({{2}} |)({{3}} |)({{4}} |)({{5}} |)({{6}} |)",
defaultAdrFormula : "",
......@@ -135,6 +138,7 @@ var cardbookRepository = {
cardbookServerChangedPwd : {},
cardbookReorderMode : "NOREORDER",
cardbookSearchMode : "NOSEARCH",
cardbookSearchValue : "",
cardbookComplexSearchMode : "NOSEARCH",
......
......@@ -2649,6 +2649,8 @@ if ("undefined" == typeof(cardbookSynchronization)) {
k = 0;
}
// a final blank line
output = output + "\r\n";
cardbookSynchronization.writeContentToFile(aFileName, output, "UTF8");
if (aListofCard.length > 1) {
......
This diff is collapsed.
......@@ -218,7 +218,7 @@ if ("undefined" == typeof(wdw_cardbookConfiguration)) {
if (wdw_cardbookConfiguration.autocompleteRestrictSearchFields == "") {
wdw_cardbookConfiguration.autocompleteRestrictSearchFields = cardbookRepository.defaultAutocompleteRestrictSearchFields;
}
document.getElementById('autocompleteRestrictSearchFieldsTextBox').value = wdw_cardbookConfiguration.translateSearchFields(wdw_cardbookConfiguration.autocompleteRestrictSearchFields);
document.getElementById('autocompleteRestrictSearchFieldsTextBox').value = wdw_csvTranslator.translateFields(wdw_cardbookConfiguration.autocompleteRestrictSearchFields);
},
chooseAutocompleteRestrictSearchFieldsButton: function () {
......@@ -231,13 +231,13 @@ if ("undefined" == typeof(wdw_cardbookConfiguration)) {
result.push(myArgs.template[i][0]);
}
wdw_cardbookConfiguration.autocompleteRestrictSearchFields = result.join('|');
document.getElementById('autocompleteRestrictSearchFieldsTextBox').value = wdw_cardbookConfiguration.translateSearchFields(wdw_cardbookConfiguration.autocompleteRestrictSearchFields);
document.getElementById('autocompleteRestrictSearchFieldsTextBox').value = wdw_csvTranslator.translateFields(wdw_cardbookConfiguration.autocompleteRestrictSearchFields);
}
},
resetAutocompleteRestrictSearchFieldsButton: function () {
wdw_cardbookConfiguration.autocompleteRestrictSearchFields = cardbookRepository.defaultAutocompleteRestrictSearchFields;
document.getElementById('autocompleteRestrictSearchFieldsTextBox').value = wdw_cardbookConfiguration.translateSearchFields(wdw_cardbookConfiguration.autocompleteRestrictSearchFields);
document.getElementById('autocompleteRestrictSearchFieldsTextBox').value = wdw_csvTranslator.translateFields(wdw_cardbookConfiguration.autocompleteRestrictSearchFields);
},
validateAutocompleteRestrictSearchFields: function () {
......
......@@ -14,7 +14,9 @@ if ("undefined" == typeof(wdw_cardbookConfigurationAddEmails)) {
if (window.arguments[0].context === "Collection") {
aIncludeSearch = false;
}
cardbookElementTools.loadAddressBooks("CardBookABMenupopup", "CardBookABMenulist", window.arguments[0].addressBookId, true, false, true, aIncludeSearch);
var ABList = document.getElementById('CardBookABMenulist');
var ABPopup = document.getElementById('CardBookABMenupopup');
cardbookElementTools.loadAddressBooks(ABPopup, ABList, window.arguments[0].addressBookId, true, false, true, aIncludeSearch, false);
},
loadCategories: function () {
......
......@@ -6,7 +6,9 @@ if ("undefined" == typeof(wdw_cardbookConfigurationAddVcards)) {
},
loadAB: function () {
cardbookElementTools.loadAddressBooks("CardBookABMenupopup", "CardBookABMenulist", window.arguments[0].addressBookId, true, false, true, false);
var ABList = document.getElementById('CardBookABMenulist');
var ABPopup = document.getElementById('CardBookABMenupopup');
cardbookElementTools.loadAddressBooks(ABPopup, ABList, window.arguments[0].addressBookId, true, false, true, false, false);
},
loadContacts: function () {
......
......@@ -705,12 +705,13 @@ if ("undefined" == typeof(wdw_cardbookContactsSidebar)) {
loadAB: function () {
wdw_cardbookContactsSidebar.loadRestrictions();
var ABList = document.getElementById('CardBookABMenulist');
var ABPopup = document.getElementById('CardBookABMenupopup');
if (ABList.value != null && ABList.value !== undefined && ABList.value != "") {
var ABDefaultValue = ABList.value;
} else {
var ABDefaultValue = 0;
}
cardbookElementTools.loadAddressBooks("CardBookABMenupopup", "CardBookABMenulist", ABDefaultValue, cardbookPreferences.getBoolPref("extensions.cardbook.exclusive"), true, true, true,
cardbookElementTools.loadAddressBooks(ABPopup, ABList, ABDefaultValue, cardbookPreferences.getBoolPref("extensions.cardbook.exclusive"), true, true, true, false,
wdw_cardbookContactsSidebar.ABInclRestrictions, wdw_cardbookContactsSidebar.ABExclRestrictions);
wdw_cardbookContactsSidebar.onABChange();
......@@ -787,7 +788,7 @@ if ("undefined" == typeof(wdw_cardbookContactsSidebar)) {
lTimerMsgIdentity.cancel();
}
}
}, 1000, Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
}, 500, Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
},
onCategoryChange: function () {
......
......@@ -17,6 +17,15 @@ if ("undefined" == typeof(wdw_csvTranslator)) {
return result;
},
translateFields: function (aFieldList) {
var myFieldArray = aFieldList.split('|');
var result = [];
for (var i = 0; i < myFieldArray.length; i++) {
result.push(wdw_csvTranslator.getTranslatedField(myFieldArray[i]));
}
return cardbookUtils.cleanArray(result).join('|');
},
getTranslatedField: function (aField, aLocale) {
if (aLocale != null && aLocale !== undefined && aLocale != "") {
var strBundle = Services.strings.createBundle("resource://" + aLocale + "/cardbook.properties");
......
......@@ -6,8 +6,6 @@ if ("undefined" == typeof(ovl_cardbookComposeMsg)) {
LoadIdentity: function() {
var outerID = GetCurrentEditorElement().outerWindowID;
cardbookRepository.composeMsgIdentity[outerID] = document.getElementById("msgIdentity").selectedItem.getAttribute("identitykey");
// this event is used only when the identity is changed, not for the initial start
cardbookUtils.notifyObservers("cardbook.identityChanged", outerID);
},
newInCardBook: function() {
......
This diff is collapsed.
......@@ -46,12 +46,10 @@ if ("undefined" == typeof(ovl_synchro)) {
prefs.setBoolPref("firstRun", true);
prefs.setBoolPref("firstOpen", true);
prefs.setBoolPref("firstOpenModern", true);
prefs.setBoolPref("iconsMigrated", false);
prefs.setCharPref("kindCustom", "X-ADDRESSBOOKSERVER-KIND");
prefs.setCharPref("memberCustom", "X-ADDRESSBOOKSERVER-MEMBER");
prefs.setCharPref("customColumnsShown", "");
prefs.setCharPref("orgStructure", "");
......@@ -91,7 +89,7 @@ if ("undefined" == typeof(ovl_synchro)) {
prefs.setCharPref("accountsShown", "all");
prefs.setCharPref("accountShown", "");
prefs.setCharPref("uncategorizedCards", "");
prefs.setCharPref("addonVersion", "26.7");
prefs.setCharPref("addonVersion", "26.8");
},
lEventTimerSync : { notify: function(lTimerSync) {
......
......@@ -768,9 +768,13 @@ if ("undefined" == typeof(cardbookPreferences)) {
},
getFnFormula: function (aDirPrefId) {
let fnFormula = this.getStringPref(this.prefCardBookData + aDirPrefId + "." + "fnFormula");
if (fnFormula != null && fnFormula !== undefined && fnFormula != "") {
return fnFormula;
if (aDirPrefId != null && aDirPrefId !== undefined && aDirPrefId != "") {
let fnFormula = this.getStringPref(this.prefCardBookData + aDirPrefId + "." + "fnFormula");
if (fnFormula != null && fnFormula !== undefined && fnFormula != "") {
return fnFormula;
} else {
return cardbookRepository.defaultFnFormula;
}
} else {
return cardbookRepository.defaultFnFormula;
}
......@@ -782,6 +786,25 @@ if ("undefined" == typeof(cardbookPreferences)) {
}
},
getDisplayedColumns: function (aDirPrefId) {
if (aDirPrefId != null && aDirPrefId !== undefined && aDirPrefId != "") {
let displayedColumns = this.getStringPref(this.prefCardBookData + aDirPrefId + "." + "displayedColumns");
if (displayedColumns != null && displayedColumns !== undefined && displayedColumns != "") {
return displayedColumns;
} else {
return cardbookRepository.defaultDisplayedColumns;
}
} else {
return cardbookRepository.defaultDisplayedColumns;
}
},
setDisplayedColumns: function (aDirPrefId, aDisplayedColumns) {
if (aDisplayedColumns != null && aDisplayedColumns !== undefined && aDisplayedColumns != "") {
this.setStringPref(this.prefCardBookData + aDirPrefId + "." + "displayedColumns", aDisplayedColumns);
}
},
delBranch: function (aDirPrefId) {
try {
Services.prefs.deleteBranch(this.prefCardBookData + aDirPrefId);
......
......@@ -25,14 +25,6 @@ if ("undefined" == typeof(wdw_cardbook)) {
cardbookPreferences.setBoolPref("extensions.cardbook.technicalTabView", false);
cardbookPreferences.setBoolPref("extensions.cardbook.vcardTabView", false);
}
var firstOpenModern = cardbookPreferences.getBoolPref("extensions.cardbook.firstOpenModern");
var panesView = cardbookPreferences.getStringPref("extensions.cardbook.panesView");
if (firstOpenModern && panesView == "modern") {
document.getElementById('dispadr').setAttribute('hidden', 'true');
document.getElementById('disptel').setAttribute('hidden', 'true');
document.getElementById('dispemail').setAttribute('hidden', 'true');
cardbookPreferences.setBoolPref("extensions.cardbook.firstOpenModern", false);
}
wdw_cardbook.showCorrectTabs();
},
......@@ -65,54 +57,28 @@ if ("undefined" == typeof(wdw_cardbook)) {
document.getElementById('cardbookTabbox').selectedTab = document.getElementById("generalTab");
},
checkCustomColumns: function () {
var myTreecols = document.getElementById('cardsTreecols');
var childNodes = myTreecols.childNodes;
var toKeep = [];
for (var i = 0; i < childNodes.length; i++) {
var child = childNodes[i];
if (child.getAttribute('id').startsWith("X-")) {
if (child.getAttribute('hidden') == "false") {
toKeep.push(child.getAttribute('id'));
}
}
}
cardbookPreferences.setStringPref("extensions.cardbook.customColumnsShown", toKeep.join(','));
},
addCustomColumns: function () {
var myTreecols = document.getElementById('cardsTreecols');
// first delete all custom columns
var childNodes = myTreecols.childNodes;
var toDelete = [];
for (var i = 0; i < childNodes.length; i++) {
var child = childNodes[i];
if (child.getAttribute('id').startsWith("X-")) {
toDelete.push(child);
}
}
for (var i = 0; i < toDelete.length; i++) {
var oldChild = myTreecols.removeChild(toDelete[i]);
}
// then add custom according to their persistence
var customColumnsShown = cardbookPreferences.getStringPref("extensions.cardbook.customColumnsShown");
var customColumnsShownArray = customColumnsShown.split(',');
for (var i in cardbookRepository.customFields) {
for (let j = 0; j < cardbookRepository.customFields[i].length; j++) {
var myCode = cardbookRepository.customFields[i][j][0];
var myLabel = cardbookRepository.customFields[i][j][1];
cardbookElementTools.addTreeSplitter(myTreecols);
var aHidden = "true";
for (let k = 0; k < customColumnsShownArray.length; k++) {
if (myCode == customColumnsShownArray[k]) {
var aHidden = "false";
break;
}
addTreeColumns: function () {
if (cardbookRepository.cardbookReorderMode == "NOREORDER") {
cardbookRepository.cardbookReorderMode = "REORDER";
var myTreecols = document.getElementById('cardsTreecols');
var myColumns = cardbookUtils.getAllAvailableColumns("cardstree");
cardbookElementTools.deleteRows(myTreecols.id)
var myOrdinal = 0;
for (var i = 0; i < myColumns.length; i++) {
var myCode = myColumns[i][0];
var myLabel = myColumns[i][1];
cardbookElementTools.addTreeSplitter(myTreecols, {ordinal: myOrdinal++});
if (myCode == "cardIcon") {
cardbookElementTools.addTreecol(myTreecols, myCode, myLabel, {fixed: 'true', persist: 'width ordinal hidden', style: 'text-align:left', hidden: 'true',
class: 'sortDirectionIndicator', sortDirection: 'ascending', ordinal: myOrdinal++});
} else {
cardbookElementTools.addTreecol(myTreecols, myCode, myLabel, {flex: '1', persist: 'width ordinal hidden', style: 'text-align:left', hidden: 'true',
class: 'sortDirectionIndicator', sortDirection: 'ascending', ordinal: myOrdinal++});
}
cardbookElementTools.addTreecol(myTreecols, myCode, myLabel, {flex: '1', persist: 'width ordinal hidden', style: 'text-align:left', hidden: aHidden,
class: 'sortDirectionIndicator', sortDirection: 'ascending'});
}
}
cardbookRepository.cardbookReorderMode = "NOREORDER";
},
setAccountsTreeMenulist: function () {
......@@ -123,6 +89,7 @@ if ("undefined" == typeof(wdw_cardbook)) {
loadFirstWindow: function () {
cardBookPrefObserver.register();
cardBookWindowObserver.register();
cardBookWindowMutationObserver.register();
// for versions <= 20.4
wdw_cardbook.migrateIcons();
wdw_cardbook.setSyncControl();
......@@ -135,8 +102,10 @@ if ("undefined" == typeof(wdw_cardbook)) {
wdw_cardbook.firstOpen();
// in case of opening a new window without having a reload
wdw_cardbook.loadCssRules();
wdw_cardbook.addTreeColumns();
wdw_cardbook.refreshAccountsInDirTree();
var accountShown = cardbookPreferences.getStringPref("extensions.cardbook.accountShown");
cardbookUtils.setColumnsStateForAccount(accountShown);
cardbookUtils.setSelectedAccount(accountShown, wdw_cardbook.currentFirstVisibleRow, wdw_cardbook.currentLastVisibleRow);
},
......@@ -175,57 +144,16 @@ if ("undefined" == typeof(wdw_cardbook)) {
getCellProperties: function(row, column) {
return this.getRowProperties(row);
},
getCellText: function(row,column){
getCellText: function(row, column){
if (column.id == "cardIcon") return "";
else if (column.id == "name") return cardbookUtils.getName(aCardList[row]);
else if (column.id == "lastname") return aCardList[row].lastname;
else if (column.id == "firstname") return aCardList[row].firstname;
else if (column.id == "othername") return aCardList[row].othername;
else if (column.id == "prefixname") return aCardList[row].prefixname;
else if (column.id == "suffixname") return aCardList[row].suffixname;
else if (column.id == "fn") return aCardList[row].fn;
else if (column.id == "nickname") return aCardList[row].nickname;
else if (column.id == "gender") return cardbookRepository.currentTypes.gender[aCardList[row].gender];
else if (column.id == "bday") return cardbookDates.getFormattedDateForCard(aCardList[row], column.id);
else if (column.id == "dispadr") return aCardList[row].dispadr;
else if (column.id == "disphomeadr") return aCardList[row].disphomeadr;
else if (column.id == "dispworkadr") return aCardList[row].dispworkadr;
else if (column.id == "disptel") return aCardList[row].disptel;
else if (column.id == "disphometel") return aCardList[row].disphometel;
else if (column.id == "dispworktel") return aCardList[row].dispworktel;
else if (column.id == "dispcelltel") return aCardList[row].dispcelltel;
else if (column.id == "dispemail") return aCardList[row].dispemail;
else if (column.id == "disphomeemail") return aCardList[row].disphomeemail;
else if (column.id == "dispworkemail") return aCardList[row].dispworkemail;
else if (column.id == "mailer") return aCardList[row].mailer;
else if (column.id == "tz") return aCardList[row].tz;
else if (column.id == "geo") return aCardList[row].geo;
else if (column.id == "title") return aCardList[row].title;
else if (column.id == "role") return aCardList[row].role;
else if (column.id == "org") return aCardList[row].org;
else if (column.id == "dispcategories") return aCardList[row].dispcategories;
else if (column.id == "note") return aCardList[row].note;
else if (column.id == "prodid") return aCardList[row].prodid;
else if (column.id == "sortstring") return aCardList[row].sortstring;
else if (column.id == "uid") return aCardList[row].uid;
else if (column.id == "cbid") return aCardList[row].cbid;
else if (column.id == "dispurl") return aCardList[row].dispurl;
else if (column.id == "version") return aCardList[row].version;
else if (column.id == "class1") return aCardList[row].class1;
else if (column.id == "dispimpp") return aCardList[row].dispimpp;
else if (column.id == "dirPrefId") return aCardList[row].dirPrefId;
else if (column.id == "kind") return aCardList[row].kind;
else if (column.id == "rev") return aCardList[row].rev;
else if (column.id == "cardurl") return aCardList[row].cardurl;
else if (column.id == "etag") return aCardList[row].etag;
else if (column.id == "birthplace") return aCardList[row].birthplace;
else if (column.id == "anniversary") return cardbookDates.getFormattedDateForCard(aCardList[row], column.id);
else if (column.id == "deathdate") return cardbookDates.getFormattedDateForCard(aCardList[row], column.id);
else if (column.id == "deathplace") return aCardList[row].deathplace;
else return cardbookUtils.getCardValueByField(aCardList[row], column.id);
}
}
wdw_cardbook.addCustomColumns();
cardbookRepository.showNameAs = cardbookPreferences.getStringPref("extensions.cardbook.showNameAs");
cardbookRepository.dateDisplayedFormat = cardbookPreferences.getStringPref("extensions.cardbook.dateDisplayedFormat");
document.getElementById('cardsTree').view = accountsOrCatsTreeView;
......@@ -259,7 +187,9 @@ if ("undefined" == typeof(wdw_cardbook)) {
var myAccountId = myTree.view.getCellText(0, {id: "accountId"});
}
wdw_cardbook.clearCard();
cardbookPreferences.setStringPref("extensions.cardbook.accountShown", cardbookUtils.getAccountId(myAccountId));
var myDirPrefId = cardbookUtils.getAccountId(myAccountId);
cardbookPreferences.setStringPref("extensions.cardbook.accountShown", myDirPrefId);
cardbookUtils.setColumnsStateForAccount(myDirPrefId);
wdw_cardbook.refreshWindow("accountid:" + myAccountId);
},
......@@ -2900,8 +2830,6 @@ if ("undefined" == typeof(wdw_cardbook)) {
'cardbookAccountMenu', 'cardbookContactsMenu', 'cardbookToolsMenu', 'cardbookToolbarComplexSearch', 'cardbookToolbarPrintButton'], false);
wdw_cardbook.updateStatusInformation();
wdw_cardbook.updateStatusProgressInformationField();
// to save custom columns persistency
wdw_cardbook