Commit c61fe5d6 authored by CardBook's avatar CardBook

pre version 19.1

parent 1fae13df
......@@ -13,7 +13,10 @@ locale cardbook pl chrome/locale/pl/
locale cardbook pt-PT chrome/locale/pt-PT/
locale cardbook ru chrome/locale/ru/
skin cardbook classic/1.0 chrome/skin/
skin cardbook classic/1.0 chrome/skin/
skin cardbook-os classic/1.0 chrome/skin/unix/ os=Linux
skin cardbook-os classic/1.0 chrome/skin/windows/ os=WINNT
skin cardbook-os classic/1.0 chrome/skin/mac/ os=Darwin
# support for customizing toolbars
style chrome://global/content/customizeToolbar.xul chrome://cardbook/skin/toolbarButton.css
......
......@@ -194,11 +194,14 @@
<caption label="&locationSearchPage.label;"/>
<vbox id="searchTerms" flex="3" persist="height">
<vbox>
<hbox align="center">
<hbox align="center" flex="1">
<label value="&abSearchHeading.label;" accesskey="&abSearchHeading.accesskey;" control="abPopup"/>
<menulist id="addressbookMenulist">
<menulist id="addressbookMenulist" flex="1">
<menupopup id="addressbookMenupopup"/>
</menulist>
<spacer flex="1"/>
<spacer flex="1"/>
<spacer flex="1"/>
</hbox>
</vbox>
......@@ -210,8 +213,8 @@
</hbox>
<hbox flex="1">
<groupbox id="searchTermsGroupbox" flex="1"/>
</hbox>
<spacer flex="100"/>
</hbox>
<spacer flex="100"/>
</vbox>
</groupbox>
</wizardpage>
......
......@@ -219,13 +219,17 @@ if ("undefined" == typeof(wdw_cardEdition)) {
loadCategories: function (aCategoryList) {
var categoryPanel = document.getElementById("categoriesPanel");
categoryPanel.loadCategories(wdw_cardEdition.listOfCategories, aCategoryList);
cardbookUtils.updateCategoryMenulist(categoryPanel);
var itemsList = [];
for (var i = 0; i < wdw_cardEdition.listOfCategories.length; i++) {
itemsList.push([wdw_cardEdition.listOfCategories[i], wdw_cardEdition.listOfCategories[i]]);
}
categoryPanel.loadItems("", itemsList, aCategoryList, false);
cardbookUtils.updatePanelMenulist("category", categoryPanel);
},
getCategories: function () {
var categoryPanel = document.getElementById("categoriesPanel");
return categoryPanel.categories;
return categoryPanel.itemsLabel;
},
loadSourceCategories: function (aDirPrefId) {
......
......@@ -8,7 +8,8 @@
<?xml-stylesheet href="chrome://calendar/skin/widgets/calendar-widgets.css" type="text/css"?>
<?xml-stylesheet href="chrome://calendar/content/widgets/calendar-widget-bindings.css" type="text/css"?>
<?xml-stylesheet href="chrome://calendar-common/skin/widgets/minimonth.css" type="text/css"?>
<!-- for the preference star -->
<?xml-stylesheet href="chrome://cardbook-os/skin/cardbookPrefStar.css" type="text/css"?>
<?xul-overlay href="chrome://cardbook/content/ovl_cardbookStringBundle.xul"?>
<!DOCTYPE window [
......@@ -86,7 +87,7 @@
<vbox flex="1">
<groupbox id="addressbookMenulistGroupbox" flex="1">
<caption id="addressbookMenulistLabel" class="header"/>
<hbox align="center" flex="1">
<hbox align="center" flex="1" style="min-height:36px;">
<menulist id="addressbookMenulist" flex="1" oncommand="wdw_cardEdition.changeAddressbook();">
<menupopup id="addressbookMenupopup" flex="1"/>
</menulist>
......@@ -94,13 +95,13 @@
</groupbox>
<groupbox id="categoriesReadOnlyGroupbox">
<caption label="&categoriesGroupboxLabel;" class="header"/>
<textbox id="categoriesTextBox" flex="1"/>
<textbox id="categoriesTextBox" flex="1" style="min-height:36px;"/>
</groupbox>
<groupbox id="categoriesReadWriteGroupbox" flex="1">
<caption label="&categoriesGroupboxLabel;" class="header"/>
<hbox align="center" flex="1">
<hbox align="center" flex="1" style="min-height:36px;">
<menulist id="categoriesMenulist" type="cardbookPanelMenulist" flex="1">
<panel id="categoriesPanel" type="cardbookCategoryPanel" onpopuphiding="cardbookUtils.updateCategoryMenulist(this);"/>
<panel id="categoriesPanel" type="cardbookItemPanel" onpopuphiding="cardbookUtils.updatePanelMenulist('category', this);"/>
</menulist>
</hbox>
</groupbox>
......
......@@ -116,7 +116,7 @@ if ("undefined" == typeof(cardbookElementTools)) {
var identity = account.identities.queryElementAt ? account.identities.queryElementAt(k, Components.interfaces.nsIMsgIdentity) : account.identities.GetElementAt(k).QueryInterface(Components.interfaces.nsIMsgIdentity);
var mailAccountServer = account.incomingServer;
if (mailAccountServer.type == "pop3" || mailAccountServer.type == "imap") {
sortedEmailAccounts.push([mailAccountServer.prettyName, identity.key]);
sortedEmailAccounts.push([identity.email, identity.key]);
}
}
}
......@@ -238,10 +238,10 @@ if ("undefined" == typeof(cardbookElementTools)) {
var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"].getService(Components.interfaces.nsIStringBundleService);
var strBundle = stringBundleService.createBundle("chrome://cardbook/locale/cardbook.properties");
var menuItem = document.createElement("menuitem");
menuItem.setAttribute("label", strBundle.GetStringFromName("noCategories"));
menuItem.setAttribute("value", "noCategories");
menuItem.setAttribute("label", strBundle.GetStringFromName("noCategory"));
menuItem.setAttribute("value", "noCategory");
myPopup.appendChild(menuItem);
if ("noCategories" == aDefaultCatId) {
if ("noCategory" == aDefaultCatId) {
defaultIndex=j;
}
j++;
......@@ -295,7 +295,7 @@ if ("undefined" == typeof(cardbookElementTools)) {
document.getElementById(aMenuName).selectedIndex = defaultIndex;
},
addMenuIMPPlist: function (aParent, aType, aIndex, aArray, aImppDefault, aCode, aProtocol) {
addMenuIMPPlist: function (aParent, aType, aIndex, aArray, aCode, aProtocol) {
var aMenulist = document.createElement('menulist');
aParent.appendChild(aMenulist);
aMenulist.setAttribute('id', aType + '_' + aIndex + '_menulistIMPP');
......@@ -310,22 +310,15 @@ if ("undefined" == typeof(cardbookElementTools)) {
menuItem.setAttribute("label", aArray[i][1]);
menuItem.setAttribute("value", aArray[i][0]);
aMenupopup.appendChild(menuItem);
if (aImppDefault != null && aImppDefault !== undefined && aImppDefault != "") {
if (aImppDefault == aArray[i][0]) {
if (aCode != "") {
if (aArray[i][0].toLowerCase() == aCode.toLowerCase()) {
aMenulist.selectedIndex = i;
found = true;
}
} else {
if (aCode != "") {
if (aArray[i][0] == aCode) {
aMenulist.selectedIndex = i;
found = true;
}
} else if (aProtocol != "") {
if (aArray[i][2] == aProtocol) {
aMenulist.selectedIndex = i;
found = true;
}
} else if (aProtocol != "") {
if (aArray[i][2].toLowerCase() == aProtocol.toLowerCase()) {
aMenulist.selectedIndex = i;
found = true;
}
}
}
......@@ -335,6 +328,58 @@ if ("undefined" == typeof(cardbookElementTools)) {
return found;
},
addPrefStar: function (aParent, aType, aIndex, aValue) {
var strBundle = document.getElementById("cardbook-strings");
var aPrefButton = document.createElement('button');
aParent.appendChild(aPrefButton);
aPrefButton.setAttribute('id', aType + '_' + aIndex + '_PrefImage');
aPrefButton.setAttribute('class', 'small-button cardbookPrefStarClass');
if (aValue) {
aPrefButton.setAttribute('haspref', 'true');
} else {
aPrefButton.removeAttribute('haspref');
}
aPrefButton.setAttribute('tooltiptext', strBundle.getString("prefLabel"));
function firePrefCheckBox(event) {
var myIdArray = this.id.split('_');
var myPrefWeightBoxLabel = document.getElementById(myIdArray[0] + '_' + myIdArray[1] + '_prefWeightBoxLabel');
var myPrefWeightBox = document.getElementById(myIdArray[0] + '_' + myIdArray[1] + '_prefWeightBox');
if (this.getAttribute('haspref')) {
this.removeAttribute('haspref');
myPrefWeightBoxLabel.disabled = false;
myPrefWeightBox.disabled = false;
} else {
this.setAttribute('haspref', 'true');
myPrefWeightBoxLabel.disabled = true;
myPrefWeightBox.disabled = true;
}
myPrefWeightBox.value = "";
};
aPrefButton.addEventListener("command", firePrefCheckBox, false);
return aPrefButton;
},
addMenuTypelist: function (aParent, aType, aIndex, aArray, aCheckedArray) {
var aMenulist = document.createElement('menulist');
aParent.appendChild(aMenulist);
aMenulist.setAttribute('id', aType + '_' + aIndex + '_MenulistType');
aMenulist.setAttribute('type', 'cardbookPanelMenulist');
var aPanel = document.createElement('panel');
aPanel.setAttribute('id', aType + '_' + aIndex + '_PanelType');
aPanel.setAttribute('type', 'cardbookItemPanel');
aMenulist.appendChild(aPanel);
// need to wait this end of load to populate
aPanel.addEventListener("load", function() {
this.loadItems(aType + '_' + aIndex, aArray, aCheckedArray, true);
cardbookUtils.updatePanelMenulist("type", this);
}, false);
function firePopuphiding(event) {
cardbookUtils.updatePanelMenulist('type', this);
};
aPanel.addEventListener("popuphiding", firePopuphiding, false);
},
addMenuCaselist: function (aParent, aType, aIndex, aValue) {
var strBundle = document.getElementById("cardbook-strings");
var aMenulist = document.createElement('menulist');
......
......@@ -23,6 +23,8 @@ var cardbookRepository = {
defaultFnFormula : "({{1}} |)({{2}} |)({{3}} |)({{4}} |)({{5}} |)({{6}} |)",
typesSeed : {"adr": ["HOME","WORK"], "email": ["HOME","WORK"], "impp": ["HOME","WORK"], "tel": ["CELL", "FAX", "HOME","WORK"], "url": ["HOME","WORK"]},
preferEmailPref : true,
cardbookAccounts : [],
......@@ -280,7 +282,9 @@ var cardbookRepository = {
}
}
if (notfound) {
cardbookPrefService.insertUrlSeedTypes();
for (var i = 0; i < cardbookRepository.typesSeed.url.length; i++) {
cardbookPrefService.setTypes("url", i, cardbookRepository.typesSeed.url[i]);
}
}
// for file opened with version <= 4.8
var notfound = true;
......@@ -292,7 +296,9 @@ var cardbookRepository = {
}
}
if (notfound) {
cardbookPrefService.insertTelSeedTypes();
for (var i = 0; i < cardbookRepository.typesSeed.tel.length; i++) {
cardbookPrefService.setTypes("tel", i, cardbookRepository.typesSeed.tel[i]);
}
}
// for file opened with version <= 4.8
var notfound = true;
......@@ -304,7 +310,9 @@ var cardbookRepository = {
}
}
if (notfound) {
cardbookPrefService.insertImppSeedTypes();
for (var i = 0; i < cardbookRepository.typesSeed.impp.length; i++) {
cardbookPrefService.setTypes("impp", i, cardbookRepository.typesSeed.impp[i]);
}
}
// for file opened with version <= 4.8
var notfound = true;
......@@ -316,7 +324,9 @@ var cardbookRepository = {
}
}
if (notfound) {
cardbookPrefService.insertEmailSeedTypes();
for (var i = 0; i < cardbookRepository.typesSeed.email.length; i++) {
cardbookPrefService.setTypes("email", i, cardbookRepository.typesSeed.email[i]);
}
}
// for file opened with version <= 11.6
var notfound = true;
......@@ -328,7 +338,9 @@ var cardbookRepository = {
}
}
if (notfound) {
cardbookPrefService.insertAdrSeedTypes();
for (var i = 0; i < cardbookRepository.typesSeed.adr.length; i++) {
cardbookPrefService.setTypes("adr", i, cardbookRepository.typesSeed.adr[i]);
}
}
// for file opened with version <= 15.3
var myIMPPs = [];
......
This diff is collapsed.
......@@ -104,18 +104,26 @@ if ("undefined" == typeof(cardbookUtils)) {
return myResult;
},
updateCategoryMenulist: function (aPanel) {
updatePanelMenulist: function (aType, aPanel) {
var strBundle = document.getElementById("cardbook-strings");
let myMenulist = document.getElementById(aPanel.id.replace("Panel", "Menulist"));
let label;
let categoryList = aPanel.categories;
if (categoryList.length > 1) {
label = strBundle.getString("multipleCategories");
} else if (categoryList.length == 1) {
label = categoryList[0];
let label = "";
let itemsList = aPanel.itemsLabel;
if (itemsList.length > 1) {
if (aType === "category") {
label = strBundle.getString("multipleCategories");
} else if (aType === "type") {
label = strBundle.getString("multipleTypes");
}
} else if (itemsList.length == 1) {
label = itemsList[0];
} else {
label = strBundle.getString("None");
if (aType === "category") {
label = strBundle.getString("none");
} else if (aType === "type") {
label = strBundle.getString("noType");
}
}
myMenulist.setAttribute("label", label);
},
......
......@@ -264,7 +264,7 @@ if ("undefined" == typeof(wdw_cardbookContactsSidebar)) {
if (cardbookRepository.verifyABRestrictions(myDirPrefId, searchAB, wdw_cardbookContactsSidebar.ABExclRestrictions, wdw_cardbookContactsSidebar.ABInclRestrictions)) {
var myDirPrefName = cardbookUtils.getPrefNameFromPrefId(myDirPrefId);
// All No Only categories
if ((searchCategory === "allCategories") || (searchCategory === "noCategories") || (searchCategory === "onlyCategories")) {
if ((searchCategory === "allCategories") || (searchCategory === "noCategory") || (searchCategory === "onlyCategories")) {
if (searchCategory !== "onlyCategories") {
for (var j in cardbookRepository.cardbookCardSearch2[myDirPrefId]) {
if (j.indexOf(searchInput) >= 0 || searchInput == "") {
......@@ -309,7 +309,7 @@ if ("undefined" == typeof(wdw_cardbookContactsSidebar)) {
}
}
}
if (searchCategory !== "noCategories") {
if (searchCategory !== "noCategory") {
for (var j = 0; j < cardbookRepository.cardbookAccountsCategories[myDirPrefId].length; j++) {
var myCategory = cardbookRepository.cardbookAccountsCategories[myDirPrefId][j];
if (cardbookRepository.verifyCatRestrictions(myDirPrefId, myCategory, searchInput, wdw_cardbookContactsSidebar.ABExclRestrictions,
......
......@@ -4,6 +4,8 @@
<?xml-stylesheet href="chrome://cardbook/skin/cardbookButtons.css" type="text/css"?>
<?xml-stylesheet href="chrome://cardbook/skin/cardbookCheckboxes.css" type="text/css"?>
<?xml-stylesheet href="chrome://cardbook/skin/cardbookTreeChildrens.css" type="text/css"?>
<!-- for the preference star -->
<?xml-stylesheet href="chrome://cardbook-os/skin/cardbookPrefStar.css" type="text/css"?>
<?xul-overlay href="chrome://cardbook/content/ovl_cardbookStringBundle.xul"?>
<?xul-overlay href="chrome://cardbook/content/ovl_cardbookBar.xul"?>
......@@ -199,7 +201,7 @@
<groupbox id="fnGroupbox">
<caption id="fnLabel" label="&fnLabel;" class="header"/>
<hbox flex="1">
<image id="dummyFnPrefBox" class="cardbookNotPrefClass"/>
<image id="dummyFnPrefBox" class="cardbookNoPrefStarClass"/>
<textbox id="fnTextBox" flex="1"/>
</hbox>
</groupbox>
......@@ -209,7 +211,7 @@
<groupbox id="persGroupbox" flex="1">
<caption label="&persTitleLabel;" class="header"/>
<hbox flex="1">
<image id="dummyPersPrefBox" class="cardbookNotPrefClass"/>
<image id="dummyPersPrefBox" class="cardbookNoPrefStarClass"/>
<grid align="center" flex="1">
<columns>
<column/>
......@@ -266,7 +268,7 @@
<groupbox id="orgGroupbox" flex="1">
<caption label="&orgTitleLabel;" class="header"/>
<hbox flex="1">
<image id="dummyOrgPrefBox" class="cardbookNotPrefClass"/>
<image id="dummyOrgPrefBox" class="cardbookNoPrefStarClass"/>
<grid align="center" flex="1">
<columns>
<column/>
......@@ -299,7 +301,7 @@
<groupbox id="categoriesGroupbox" flex="1">
<caption label="&categoriesGroupboxLabel;" class="header"/>
<hbox flex="1">
<image id="dummyCatPrefBox" class="cardbookNotPrefClass"/>
<image id="dummyCatPrefBox" class="cardbookNoPrefStarClass"/>
<textbox id="categoriesTextBox" flex="1"/>
</hbox>
</groupbox>
......@@ -316,7 +318,7 @@
<groupbox id="noteGroupbox" flex="1">
<caption label="&noteTabLabel;" class="header"/>
<hbox flex="1">
<image id="dummyNotePrefBox" class="cardbookNotPrefClass"/>
<image id="dummyNotePrefBox" class="cardbookNoPrefStarClass"/>
<vbox flex="1">
<textbox id="noteTextBox" multiline="true"/>
</vbox>
......
......@@ -107,33 +107,6 @@ cardbookPreferenceService.prototype = {
}
},
insertAdrSeedTypes: function () {
this.setTypes("adr",1,"HOME");
this.setTypes("adr",2,"WORK");
},
insertEmailSeedTypes: function () {
this.setTypes("email",1,"HOME");
this.setTypes("email",2,"WORK");
},
insertImppSeedTypes: function () {
this.setTypes("impp",1,"HOME");
this.setTypes("impp",2,"WORK");
},
insertTelSeedTypes: function () {
this.setTypes("tel",1,"CELL");
this.setTypes("tel",2,"FAX");
this.setTypes("tel",3,"HOME");
this.setTypes("tel",4,"WORK");
},
insertUrlSeedTypes: function () {
this.setTypes("url",1,"HOME");
this.setTypes("url",2,"WORK");
},
insertIMPPsSeed: function () {
var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"].getService(Components.interfaces.nsIStringBundleService);
var strBundle = stringBundleService.createBundle("chrome://cardbook/locale/cardbook.properties");
......@@ -817,23 +790,6 @@ cardbookPreferenceService.prototype = {
this._setBoolPref("urnuuid", aUrnuuid);
},
getPrefLabel: function () {
let prefLabel = this.mPreferencesService.getComplexValue(this.prefCardBookRoot + "preferenceLabel", Components.interfaces.nsISupportsString).data;
if (prefLabel != null && prefLabel !== undefined && prefLabel != "") {
return prefLabel;
} else {
let stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"].getService(Components.interfaces.nsIStringBundleService);
let strBundle = stringBundleService.createBundle("chrome://cardbook/locale/cardbook.properties");
return strBundle.GetStringFromName("prefLabel");
}
},
setPrefLabel: function (aPrefLabel) {
var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
str.data = aPrefLabel;
this.mPreferencesService.setComplexValue(this.prefCardBookRoot + "preferenceLabel", Components.interfaces.nsISupportsString, str);
},
getPrefValueLabel: function () {
let prefValueLabel = this.mPreferencesService.getComplexValue(this.prefCardBookRoot + "preferenceValueLabel", Components.interfaces.nsISupportsString).data;
if (prefValueLabel != null && prefValueLabel !== undefined && prefValueLabel != "") {
......@@ -845,12 +801,6 @@ cardbookPreferenceService.prototype = {
}
},
setPrefValueLabel: function (aPrefValueLabel) {
var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
str.data = aPrefValueLabel;
this.mPreferencesService.setComplexValue(this.prefCardBookRoot + "aPrefValueLabel", Components.interfaces.nsISupportsString, str);
},
delBranch: function () {
try {
this.mPreferencesService.deleteBranch(this.prefPath);
......
......@@ -224,7 +224,7 @@ if ("undefined" == typeof(cardbookPrint)) {
cardbookPrint.closeTag("td", false);
}
if (cardbookUtils.getPrefBooleanFromTypes(aListOfCards[i][myField][m][1]) && aColumnChoice.types) {
var myCheck = "";
var myCheck = "";
} else {
var myCheck = "";
}
......
......@@ -204,7 +204,7 @@ if ("undefined" == typeof(wdw_cardbookConfiguration)) {
var identity = account.identities.queryElementAt ? account.identities.queryElementAt(j, Components.interfaces.nsIMsgIdentity) : account.identities.GetElementAt(j).QueryInterface(Components.interfaces.nsIMsgIdentity);
var mailAccountServer = account.incomingServer;
if (mailAccountServer.type == "pop3" || mailAccountServer.type == "imap") {
var accountPrettyName = mailAccountServer.prettyName; // gets mail account name
var accountPrettyName = identity.email; // gets mail account name
var enabled = cardbookPrefService.getMailAccountEnabled(identity.key);
var filename = cardbookPrefService.getMailAccountFileName(identity.key);
var dirPrefId = cardbookPrefService.getMailAccountDirPrefId(identity.key);
......@@ -710,10 +710,6 @@ if ("undefined" == typeof(wdw_cardbookConfiguration)) {
},
loadPref: function () {
if (document.getElementById('preferenceTextbox').value == "") {
var cardbookPrefService = new cardbookPreferenceService();
document.getElementById('preferenceTextbox').value = cardbookPrefService.getPrefLabel();
}
if (document.getElementById('preferenceValueTextbox').value == "") {
document.getElementById('preferenceValueTextbox').value = cardbookPrefService.getPrefValueLabel();
}
......@@ -737,7 +733,7 @@ if ("undefined" == typeof(wdw_cardbookConfiguration)) {
var mailAccountServer = account.incomingServer;
if (mailAccountServer.type == "pop3" || mailAccountServer.type == "imap") {
if (aEmailAccountId == identity.key) {
return mailAccountServer.prettyName;
return identity.email;
}
}
}
......@@ -1092,7 +1088,20 @@ if ("undefined" == typeof(wdw_cardbookConfiguration)) {
var myArgs = {code: "", label: "", typeAction: ""};
var myWindow = window.openDialog("chrome://cardbook/content/wdw_cardbookAddType.xul", "", "chrome,modal,resizable,centerscreen", myArgs);
if (myArgs.typeAction == "SAVE") {
wdw_cardbookConfiguration.allTypes[type].push([myArgs.code, myArgs.label]);
var result = [];
var already = false;
for (let i = 0; i < wdw_cardbookConfiguration.allTypes[type].length; i++) {
if (myArgs.code === wdw_cardbookConfiguration.allTypes[type][i][0]) {
result.push([myArgs.code, myArgs.label]);
already = true;
} else {
result.push(wdw_cardbookConfiguration.allTypes[type][i]);
}
}
if (!already) {
result.push([myArgs.code, myArgs.label]);
}
wdw_cardbookConfiguration.allTypes[type] = JSON.parse(JSON.stringify(result));
wdw_cardbookConfiguration.allTypes[type] = cardbookUtils.sortArrayByString(wdw_cardbookConfiguration.allTypes[type],1,1);
wdw_cardbookConfiguration.sortTrees(null, "typesTree");
}
......@@ -1111,7 +1120,7 @@ if ("undefined" == typeof(wdw_cardbookConfiguration)) {
if (myArgs.typeAction == "SAVE") {
var result = [];
for (let i = 0; i < wdw_cardbookConfiguration.allTypes[type].length; i++) {
if (myCode === wdw_cardbookConfiguration.allTypes[type][i][0]) {
if (myArgs.code === wdw_cardbookConfiguration.allTypes[type][i][0]) {
result.push([myArgs.code, myArgs.label]);
} else {
result.push(wdw_cardbookConfiguration.allTypes[type][i]);
......@@ -1142,6 +1151,19 @@ if ("undefined" == typeof(wdw_cardbookConfiguration)) {
}
},
resetType: function () {
var result = [];
var strBundle = document.getElementById("cardbook-strings");
var type = document.getElementById('typesCategoryRadiogroup').selectedItem.value;
for (var i = 0; i < cardbookRepository.typesSeed[type].length; i++) {
var myCode = cardbookRepository.typesSeed[type][i];
var myLabel = strBundle.getString("types." + type + "." + myCode.toLowerCase());
result.push([myCode, myLabel]);
}
wdw_cardbookConfiguration.allTypes[type] = JSON.parse(JSON.stringify(result));
wdw_cardbookConfiguration.sortTrees(null, "typesTree");
},
validateTypes: function () {
var cardbookPrefService = new cardbookPreferenceService();
cardbookPrefService.delTypes();
......
......@@ -58,8 +58,6 @@
name="extensions.cardbook.fnFormula" type="string"/>
<preference id="extensions.cardbook.localizeTarget"
name="extensions.cardbook.localizeTarget" type="string"/>
<preference id="extensions.cardbook.preferenceLabel"
name="extensions.cardbook.preferenceLabel" type="string"/>
<preference id="extensions.cardbook.preferenceValueLabel"
name="extensions.cardbook.preferenceValueLabel" type="string"/>
<preference id="extensions.cardbook.kindCustom"
......@@ -299,7 +297,7 @@
id="fnFormula"/>
<textbox id="fnFormulaTextBox"
preference="extensions.cardbook.fnFormula"/>
<button id="resetFnFormulaButton" label="&resetfnFormulaLabel;" accesskey="&resetFnFormulaAccesskey;"
<button id="resetFnFormulaButton" label="&resetFnFormulaLabel;" accesskey="&resetFnFormulaAccesskey;"
oncommand="wdw_cardbookConfiguration.resetFnFormula();"/>
</row>
<row align="center">
......@@ -379,21 +377,13 @@
<button id="addTypeLabel" label="&addTypeLabel;" accesskey="&addTypeAccesskey;" oncommand="wdw_cardbookConfiguration.addType();"/>
<button id="renameTypeLabel" label="&renameTypeLabel;" accesskey="&renameTypeAccesskey;" oncommand="wdw_cardbookConfiguration.renameType();" disabled="true"/>
<button id="deleteTypeLabel" label="&deleteTypeLabel;" accesskey="&deleteTypeAccesskey;" oncommand="wdw_cardbookConfiguration.deleteType();" disabled="true"/>
<button id="resetTypeLabel" label="&resetTypeLabel;" accesskey="&resetTypeAccesskey;" oncommand="wdw_cardbookConfiguration.resetType();"/>
</vbox>
</hbox>
</hbox>
</groupbox>
<groupbox>
<caption label="&preferenceGroupboxLabel;"/>
<hbox flex="1" align="center">
<label value="&preferenceLabel;"
accesskey="&preferenceAccesskey;"
control="preferenceTextbox"
id="preferenceLabel"/>
<textbox id="preferenceTextbox"
preference="extensions.cardbook.preferenceLabel"/>
</hbox>
<separator class="thin"/>
<hbox flex="1" align="center">
<label value="&preferenceValueLabel;"
accesskey="&preferenceValueAccesskey;"
......
......@@ -22,88 +22,157 @@
</content>
</binding>
<binding id="cardbookCategoryPanel" extends="chrome://global/content/bindings/popup.xml#panel">
<binding id="cardbookItemPanel" extends="chrome://global/content/bindings/popup.xml#panel">
<resources>
<stylesheet src="chrome://cardbook/skin/cardbookWidgets.css"/>
</resources>
<content>
<xul:textbox anonid="categoryTextbox"
class="categoriesTextboxClass"
<xul:textbox anonid="addItemTextbox"
class="addItemTextboxClass"
type="search"
searchbutton="true"
placeholder="&categoryTextboxLabel;"
oncommand="document.getBindingParent(this).addNewCategory();"
placeholder="&addItemTextboxLabel;"
oncommand="document.getBindingParent(this).addNewItem();"
flex="1"/>
<xul:listbox anonid="categoriesListbox" class="categoriesListboxClass" selType="multiple">
<xul:listbox anonid="itemsListbox" class="itemsListboxClass" selType="multiple">
<children/>
</xul:listbox>
</content>
<implementation>
<field name="sourceCategories">[]</field>
<property name="categories" readonly="true">
<field name="prefixId"></field>
<!-- sourceItems : [ [label0, value0], ...] -->
<field name="sourceItems">[]</field>
<property name="itemsCode" readonly="true">
<getter><![CDATA[
return this.getCategories();
return this.getItems('code');
]]></getter>
</property>
<method name="addNewCategory">
<property name="itemsLabel" readonly="true">
<getter><![CDATA[
return this.getItems('label');
]]></getter>
</property>
<property name="types" readonly="true">
<getter><![CDATA[
return this.getTypes();
]]></getter>
</property>
<property name="pg" readonly="true">
<getter><![CDATA[
return this.getPg();
]]></getter>
</property>
<!-- only used for categories -->
<method name="addNewItem">
<body><![CDATA[
let categoryListbox = document.getAnonymousElementByAttribute(this, "anonid", "categoriesListbox");
let categoryTextbox = document.getAnonymousElementByAttribute(this, "anonid", "categoryTextbox");
let category = categoryTextbox.value;
let itemsListbox = document.getAnonymousElementByAttribute(this, "anonid", "itemsListbox");
let addItemTextbox = document.getAnonymousElementByAttribute(this, "anonid", "addItemTextbox");
let newItem = addItemTextbox.value;
if (!category) {
if (!newItem) {
return;
}
this.sourceCategories.push(category);
this.sourceCategories = cardbookUtils.sortArrayByString(cardbookRepository.arrayUnique(this.sourceCategories),-1,1);
let itemCategories = this.getCategories();
itemCategories.push(category);
itemCategories = cardbookUtils.sortArrayByString(cardbookRepository.arrayUnique(itemCategories),-1,1);
this.sourceItems.push([newItem, newItem]);
this.sourceItems = cardbookUtils.sortArrayByString(cardbookUtils.arrayUnique2D(this.sourceItems),0,1);
let allItems = this.getItems('value');
allItems.push(newItem);
allItems = cardbookUtils.sortArrayByString(cardbookRepository.arrayUnique(allItems),-1,1);