Created a window for address book properties and add the cardDav URL

This commit is contained in:
Alexandre Cloutier
2014-05-15 14:44:31 -04:00
parent d58184af15
commit 07445eb069
12 changed files with 468 additions and 147 deletions
+17 -33
View File
@@ -690,6 +690,7 @@ function addListToOpener (tag, aBookId, aBookName, listId) {
"tag": tag
});
}
function addListToOpenerCallback (http) {
var data = http.callbackData;
var received = http.responseText.evalJSON (true);
@@ -814,6 +815,7 @@ function onAddressBookImport(event) {
div.setStyle({ top: top + "px", left: left + "px" });
div.show();
}
function hideContactsImport(event) {
$("uploadDialog").hide();
}
@@ -821,6 +823,7 @@ function hideContactsImport(event) {
function hideImportResults () {
$("uploadResults").hide();
}
function validateUploadForm () {
rc = false;
if ($("contactsFile").value.length) {
@@ -832,6 +835,7 @@ function validateUploadForm () {
}
return rc;
}
function uploadCompleted(response) {
jQuery('#uploadCancel').show();
var btn = jQuery('#uploadSubmit');
@@ -1058,39 +1062,19 @@ function updateAddressBooksMenus() {
}
function onAddressBookModify(event) {
var folders = $("contactFolders");
var selected = folders.getSelectedNodes()[0];
if (selected.getAttribute("owner") != "nobody") {
var currentName = selected.innerHTML.unescapeHTML();
showPromptDialog(_("Properties"),
_("Address Book Name"),
onAddressBookModifyConfirm,
currentName);
}
}
function onAddressBookModifyConfirm() {
var folders = $("contactFolders");
var selected = folders.getSelectedNodes()[0];
var newName = this.value;
var currentName = this.getAttribute("previousValue");
if (newName && newName.length > 0
&& newName != currentName) {
var url = (URLForFolderID(selected.getAttribute("id"))
+ "/renameFolder?name=" + escape(newName.utf8encode()));
triggerAjaxRequest(url, folderRenameCallback,
{node: selected, name: newName});
}
disposeDialog();
}
function folderRenameCallback(http) {
if (http.readyState == 4) {
if (isHttpStatus204(http.status)) {
var dict = http.callbackData;
dict["node"].innerHTML = dict["name"];
}
}
var folders = $("contactFolders");
var selected = folders.getSelectedNodes()[0];
var addressBookID = selected.getAttribute("id");
var url = ApplicationBaseURL + addressBookID + "/properties";
var windowID = sanitizeWindowName(addressBookID + " properties");
var width = 410;
var height = 410;
$(function() {
var properties = window.open(url, windowID, "width="+width+",height="+height+",resizable=0");
properties.focus();
}).delay(0.1);
}
function onMenuSharing(event) {
@@ -18,6 +18,20 @@ function onLoadCalendarProperties() {
var okButton = $("okButton");
okButton.observe("click", onOKClick);
Event.observe(document, "keydown", onDocumentKeydown);
}
function onDocumentKeydown(event) {
var target = Event.element(event);
if (target.tagName == "INPUT" || target.tagName == "SELECT") {
if (event.keyCode == Event.KEY_RETURN) {
onOKClick(event);
}
}
if (event.keyCode == Event.KEY_ESC) {
onCancelClick();
}
}
function onCancelClick(event) {
@@ -0,0 +1,40 @@
DIV
{ clear: both; }
FIELDSET
{ margin-bottom: 5px;
border: 1px solid #FFFFFF;
border-top: 1px solid #909090;
border-left: 1px solid #909090; }
FIELDSET DIV
{ margin-left: 20px;
margin-right: 10px; }
SPAN.label
{ cursor: default;
width: 55px;
text-align: right;
line-height: 2em;
float: left;
display: block; }
SPAN.content
{ line-height: 1.5em;
vertical-align: middle;
margin-left: 4px; }
SPAN.content INPUT.textField
{ width: 160px; }
DIV#buttons
{ position: absolute;
bottom: 5px;
right: 5px;
padding: 10px;
padding-top: 5px;
text-align: right; }
LABEL
{ white-space: nowrap; }
@@ -0,0 +1,71 @@
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
function onLoadContactFolderProperties() {
var tabsContainer = $("propertiesTabs");
var controller = new SOGoTabsController();
controller.attachToTabsContainer(tabsContainer);
var okButton = $("okButton");
okButton.observe("click", onOKClick);
var cancelButton = $("cancelButton");
cancelButton.observe("click", onCancelClick);
Event.observe(document, "keydown", onDocumentKeydown);
}
function onOKClick(event) {
var AddressBookName = $("addressBookName");
var folders = parent$("contactFolders");
var selected = folders.getSelectedNodes()[0];
if (!AddressBookName.value.blank()) {
var newName = AddressBookName.value;
var currentName = AddressBookName.defaultValue;
if (newName && newName.length > 0 && newName != currentName) {
if (selected.getAttribute("owner") != "nobody") {
var url = (URLForFolderID(selected.getAttribute("id")) + "/renameFolder?name=" + escape(newName.utf8encode()));
triggerAjaxRequest(url, folderRenameCallback, {node: selected, name: newName});
}
else {
alert_("You do not own this address book");
}
}
else
window.close();
}
else
alert(_("Please specify an address book name."));
Event.stop(event);
}
function folderRenameCallback(http) {
if (http.readyState == 4) {
if (isHttpStatus204(http.status)) {
var dict = http.callbackData;
dict["node"].innerHTML = dict["name"];
window.close();
}
}
}
function onCancelClick(event) {
window.close();
}
function onDocumentKeydown(event) {
var target = Event.element(event);
if (target.tagName == "INPUT" || target.tagName == "SELECT") {
if (event.keyCode == Event.KEY_RETURN) {
onOKClick(event);
}
}
if (event.keyCode == Event.KEY_ESC) {
onCancelClick();
}
}
document.observe("dom:loaded", onLoadContactFolderProperties);