See ChangeLog.

Monotone-Parent: e12dddb9adb7771e7851d3446a599c176338ea41
Monotone-Revision: 28270e2fb73b9d6d39fb855a68f0d46bcbf364db

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2011-04-21T13:33:45
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Francis Lachapelle 2011-04-21 13:33:45 +00:00
parent 0d0bd168f2
commit 6572fcf6ff
7 changed files with 136 additions and 65 deletions

View file

@ -1,3 +1,21 @@
2011-04-21 Francis Lachapelle <flachapelle@inverse.ca>
* UI/WebServerResources/SchedulerUI.js (deleteEvent): we now show
in the confirmation dialog box which events will be deleted.
* UI/WebServerResources/generic.js (createDialog): the legend
argument can now be a string or an element.
(isWebKit): was isSafari; now consider all WebKit-based browsers together.
* UI/WebServerResources/UIxMailToSelection.js: various
improvements to behave like in Thunderbird.
* UI/WebServerResources/SOGoAutoCompletion.js: idem.
* UI/WebServerResources/UIxMailEditor.js (initAddresses): was
initTabIndex. We were not handling the tab indexes properly which
was causing incorrect behavior in IE.
2011-04-19 Wolfgang Sourdeau <wsourdeau@inverse.ca> 2011-04-19 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* OpenChange/MAPIStoreMailAttachment.m (-): binary properties are * OpenChange/MAPIStoreMailAttachment.m (-): binary properties are

View file

@ -13,8 +13,7 @@
<table id="addressList" cellpadding="0" cellspacing="0" <table id="addressList" cellpadding="0" cellspacing="0"
><tbody ><tbody
><var:foreach list="addressLists" item="addressList" ><var:foreach list="addressLists" item="addressList"
><var:foreach list ><var:foreach list="addressList" item="address">
="addressList" item="address">
<tr class="addressListElement" var:id="currentRowId"> <tr class="addressListElement" var:id="currentRowId">
<td class="headerField"> <td class="headerField">
<var:popup name="currentPopUpId" <var:popup name="currentPopUpId"
@ -46,6 +45,7 @@
<td class="headerInput"> <td class="headerInput">
<span class="headerInput"><input onfocus="fancyAddRow('');" <span class="headerInput"><input onfocus="fancyAddRow('');"
readonly="1" readonly="1"
tabindex="-1"
type="text" type="text"
class="textField" /></span> class="textField" /></span>
</td> </td>

View file

@ -44,12 +44,6 @@ var SOGoAutoCompletionInterface = {
this.writeAttribute("uid", null); this.writeAttribute("uid", null);
if (document.currentPopupMenu) if (document.currentPopupMenu)
hideMenu(document.currentPopupMenu); hideMenu(document.currentPopupMenu);
if (this.readAttribute("container")) {
this.confirmedValue = null;
this.fire("autocompletion:changedlist", this.readAttribute("container"));
}
else
this.fire("autocompletion:changed");
} }
else if (event.keyCode == 0 else if (event.keyCode == 0
|| event.keyCode == Event.KEY_BACKSPACE || event.keyCode == Event.KEY_BACKSPACE
@ -68,7 +62,6 @@ var SOGoAutoCompletionInterface = {
this.value = this.confirmedValue; this.value = this.confirmedValue;
else else
this.writeAttribute("uid", null); this.writeAttribute("uid", null);
$(this).select();
if (document.currentPopupMenu) if (document.currentPopupMenu)
hideMenu(document.currentPopupMenu); hideMenu(document.currentPopupMenu);
this.selectedIndex = -1; this.selectedIndex = -1;
@ -77,7 +70,7 @@ var SOGoAutoCompletionInterface = {
this.fire("autocompletion:changedlist", this.readAttribute("container")); this.fire("autocompletion:changedlist", this.readAttribute("container"));
} }
else else
this.fire("autocompletion:changed"); this.fire("autocompletion:changed", event.keyCode);
} }
else if (this.menu.getStyle('visibility') == 'visible') { else if (this.menu.getStyle('visibility') == 'visible') {
if (event.keyCode == Event.KEY_UP) { // Up arrow if (event.keyCode == Event.KEY_UP) { // Up arrow
@ -118,6 +111,8 @@ var SOGoAutoCompletionInterface = {
this.value = this.confirmedValue; this.value = this.confirmedValue;
if (this.readAttribute("container")) if (this.readAttribute("container"))
this.fire("autocompletion:changedlist", this.readAttribute("container")); this.fire("autocompletion:changedlist", this.readAttribute("container"));
else
this.fire("autocompletion:changed", event.keyCode);
} }
else else
this.writeAttribute("uid", null); this.writeAttribute("uid", null);
@ -264,13 +259,14 @@ var SOGoAutoCompletionInterface = {
if (e.tagName != 'LI') if (e.tagName != 'LI')
e = e.up('LI'); e = e.up('LI');
if (e) { if (e) {
preventDefault(event);
this.value = e.readAttribute("address"); this.value = e.readAttribute("address");
this.writeAttribute("uid", e.readAttribute("uid")); this.writeAttribute("uid", e.readAttribute("uid"));
if (e.readAttribute("container")) if (e.readAttribute("container"))
this.fire("autocompletion:changedlist", e.readAttribute("container")); this.fire("autocompletion:changedlist", e.readAttribute("container"));
else { else {
this.confirmedValue = this.value; this.confirmedValue = this.value;
this.fire("autocompletion:changed"); this.fire("autocompletion:changed", Event.KEY_RETURN);
} }
} }
} }

View file

@ -215,6 +215,7 @@ function deleteEvent() {
var canDelete; var canDelete;
var sortedNodes = []; var sortedNodes = [];
var calendars = []; var calendars = [];
var events = [];
for (var i = 0; i < nodes.length; i++) { for (var i = 0; i < nodes.length; i++) {
canDelete = nodes[i].erasable; canDelete = nodes[i].erasable;
if (canDelete) { if (canDelete) {
@ -223,15 +224,26 @@ function deleteEvent() {
sortedNodes[calendar] = []; sortedNodes[calendar] = [];
calendars.push(calendar); calendars.push(calendar);
} }
sortedNodes[calendar].push(nodes[i].cname); if (sortedNodes[calendar].indexOf(nodes[i].cname) < 0) {
sortedNodes[calendar].push(nodes[i].cname);
events.push(nodes[i].down('td').allTextContent());
}
} }
} }
for (i = 0; i < calendars.length; i++) { for (i = 0; i < calendars.length; i++) {
calendarsOfEventsToDelete.push(calendars[i]); calendarsOfEventsToDelete.push(calendars[i]);
eventsToDelete.push(sortedNodes[calendars[i]]); eventsToDelete.push(sortedNodes[calendars[i]]);
} }
if (i > 0) if (i > 0) {
showConfirmDialog(_("Warning"), label, deleteEventFromListConfirm); var p = createElement("p");
var str = "";
if (Prototype.Browser.IE)
str = label.formatted('<br><br> - <b>' + events.join('</b><br> - <b>') + '</b><br><br>');
else
str = label.formatted('<ul><li>' + events.join('<li>') + '</ul>');
p.innerHTML = str;
showConfirmDialog(_("Warning"), p, deleteEventFromListConfirm, deleteEventCancel);
}
else else
showAlertDialog(_("You don't have the required privileges to perform the operation.")); showAlertDialog(_("You don't have the required privileges to perform the operation."));
} }
@ -251,6 +263,7 @@ function deleteEvent() {
var canDelete; var canDelete;
var sortedNodes = []; var sortedNodes = [];
var calendars = []; var calendars = [];
var events = [];
for (var i = 0; i < selectedCalendarCell.length; i++) { for (var i = 0; i < selectedCalendarCell.length; i++) {
canDelete = selectedCalendarCell[i].erasable; canDelete = selectedCalendarCell[i].erasable;
if (canDelete) { if (canDelete) {
@ -259,7 +272,19 @@ function deleteEvent() {
sortedNodes[calendar] = []; sortedNodes[calendar] = [];
calendars.push(calendar); calendars.push(calendar);
} }
sortedNodes[calendar].push(selectedCalendarCell[i].cname); if (sortedNodes[calendar].indexOf(selectedCalendarCell[i].cname) < 0) {
// Extract event name for confirmation dialog
var content = "";
var event = $(selectedCalendarCell[i]).down("DIV.text");
for (var j = 0; j < event.childNodes.length; j++) {
var node = event.childNodes[j];
if (node.nodeType == Node.TEXT_NODE) {
content += node.nodeValue;
}
}
events.push(content);
sortedNodes[calendar].push(selectedCalendarCell[i].cname);
}
} }
} }
@ -267,9 +292,20 @@ function deleteEvent() {
calendarsOfEventsToDelete.push(calendars[i]); calendarsOfEventsToDelete.push(calendars[i]);
eventsToDelete.push(sortedNodes[calendars[i]]); eventsToDelete.push(sortedNodes[calendars[i]]);
} }
if (i > 0) if (i > 0) {
showConfirmDialog(_("Warning"), _("eventDeleteConfirmation"), var p = createElement("p");
deleteEventFromViewConfirm, deleteEventFromViewCancel); var str = "";
if (Prototype.Browser.IE)
str = label.formatted('<br><br> - <b>' + events.join('</b><br> - <b>') + '</b><br><br>');
else
str = label.formatted('<ul><li>' + events.join('<li>') + '</ul>');
p.innerHTML = str;
showConfirmDialog(_("Warning"), p, deleteEventFromListConfirm);
var p = new Element("p").update(_("eventDeleteConfirmation").formatted('<ul><li>' + events.join("<li>") + '</ul>'));
showConfirmDialog(_("Warning"), p,
deleteEventFromViewConfirm, deleteEventCancel);
}
else else
showAlertDialog(_("You don't have the required privileges to perform the operation.")); showAlertDialog(_("You don't have the required privileges to perform the operation."));
} }
@ -301,7 +337,7 @@ function deleteEventFromViewConfirm() {
disposeDialog(); disposeDialog();
} }
function deleteEventFromViewCancel(event) { function deleteEventCancel(event) {
calendarsOfEventsToDelete = []; calendarsOfEventsToDelete = [];
eventsToDelete = []; eventsToDelete = [];
disposeDialog(); disposeDialog();
@ -1181,23 +1217,25 @@ function scrollDayView(scrollEvent) {
if (scrollEvent) { if (scrollEvent) {
var contentView; var contentView;
var eventRow = $(scrollEvent); var eventRow = $(scrollEvent);
var eventBlocks = selectCalendarEvent(eventRow.calendar, eventRow.cname, eventRow.recurrenceTime); if (eventRow) {
if (eventBlocks) { var eventBlocks = selectCalendarEvent(eventRow.calendar, eventRow.cname, eventRow.recurrenceTime);
var firstEvent = eventBlocks.first(); if (eventBlocks) {
var firstEvent = eventBlocks.first();
if (currentView == "monthview")
contentView = firstEvent.up("DIV.day"); if (currentView == "monthview")
else contentView = firstEvent.up("DIV.day");
contentView = $("daysView"); else
contentView = $("daysView");
// Don't scroll to an all-day event
if (typeof eventRow.hour != "undefined") { // Don't scroll to an all-day event
var top = firstEvent.cumulativeOffset()[1] - contentView.scrollTop; if (typeof eventRow.hour != "undefined") {
// Don't scroll if the event is visible to the user var top = firstEvent.cumulativeOffset()[1] - contentView.scrollTop;
if (top < contentView.cumulativeOffset()[1]) // Don't scroll if the event is visible to the user
contentView.scrollTop = firstEvent.cumulativeOffset()[1] - contentView.cumulativeOffset()[1]; if (top < contentView.cumulativeOffset()[1])
else if (top > contentView.cumulativeOffset()[1] + contentView.getHeight() - firstEvent.getHeight()) contentView.scrollTop = firstEvent.cumulativeOffset()[1] - contentView.cumulativeOffset()[1];
contentView.scrollTop = firstEvent.cumulativeOffset()[1] - contentView.cumulativeOffset()[1]; else if (top > contentView.cumulativeOffset()[1] + contentView.getHeight() - firstEvent.getHeight())
contentView.scrollTop = firstEvent.cumulativeOffset()[1] - contentView.cumulativeOffset()[1];
}
} }
} }
} }
@ -2163,7 +2201,7 @@ function onShowCompletedTasks(event) {
function updateTaskStatus(event) { function updateTaskStatus(event) {
var newStatus = (this.checked ? 1 : 0); var newStatus = (this.checked ? 1 : 0);
if (isSafari() && !isSafari3()) { if (isWebKit() && !isSafari3()) {
newStatus = (newStatus ? 0 : 1); newStatus = (newStatus ? 0 : 1);
} }
_updateTaskCompletion (this.parentNode, newStatus); _updateTaskCompletion (this.parentNode, newStatus);
@ -2174,7 +2212,7 @@ function updateCalendarStatus(event) {
var list = []; var list = [];
var newStatus = (this.checked ? 1 : 0); var newStatus = (this.checked ? 1 : 0);
if (isSafari() && !isSafari3()) { if (isWebKit() && !isSafari3()) {
newStatus = (newStatus ? 0 : 1); newStatus = (newStatus ? 0 : 1);
this.checked = newStatus; this.checked = newStatus;
} }

View file

@ -339,21 +339,20 @@ function onTextMouseDown(event) {
} }
} }
function initTabIndex(addressList, subjectField, msgArea) { function initAddresses() {
var addressList = $("addressList");
var i = 1; var i = 1;
addressList.select("input.textField").each(function (input) { addressList.select("input.textField").each(function (input) {
if (!input.readAttribute("readonly")) { if (!input.readAttribute("readonly")) {
input.writeAttribute("tabindex", i++);
input.addInterface(SOGoAutoCompletionInterface); input.addInterface(SOGoAutoCompletionInterface);
input.uidField = "c_name"; input.uidField = "c_name";
input.observe("focus", addressFieldGotFocus.bind(input)); input.on("focus", addressFieldGotFocus.bind(input));
input.observe("blur", addressFieldLostFocus.bind(input)); input.on("blur", addressFieldLostFocus.bind(input));
input.observe("autocompletion:changedlist", expandContactList); input.on("autocompletion:changedlist", expandContactList);
input.on("autocompletion:changed", addressFieldChanged.bind(input));
//input.onListAdded = expandContactList; //input.onListAdded = expandContactList;
} }
}); });
subjectField.writeAttribute("tabindex", i++);
msgArea.writeAttribute("tabindex", i);
} }
function initMailEditor() { function initMailEditor() {
@ -391,8 +390,7 @@ function initMailEditor() {
textarea.observe(ieEvents[i], onTextIEUpdateCursorPos, false); textarea.observe(ieEvents[i], onTextIEUpdateCursorPos, false);
} }
var subjectField = $$("div#subjectRow input").first(); initAddresses();
initTabIndex($("addressList"), subjectField, textarea);
var focusField = (mailIsReply ? textarea : $("addr_0")); var focusField = (mailIsReply ? textarea : $("addr_0"));
focusField.focus(); focusField.focus();
@ -559,7 +557,7 @@ function onSelectAllAttachments() {
} }
function onSelectOptions(event) { function onSelectOptions(event) {
if (event.button == 0 || (isSafari() && event.button == 1)) { if (event.button == 0 || (isWebKit() && event.button == 1)) {
var node = getTarget(event); var node = getTarget(event);
if (node.tagName != 'A') if (node.tagName != 'A')
node = $(node).up("A"); node = $(node).up("A");

View file

@ -83,15 +83,15 @@ function fancyAddRow(text, type) {
input.id = 'addr_' + currentIndex; input.id = 'addr_' + currentIndex;
input.value = text; input.value = text;
input.stopObserving(); input.stopObserving();
input.addInterface(SOGoAutoCompletionInterface); input.addInterface(SOGoAutoCompletionInterface);
input.focus(); addressList.insertBefore(row, lastChild);
input.select();
input.observe("focus", addressFieldGotFocus.bind(input)); input.observe("focus", addressFieldGotFocus.bind(input));
input.observe("blur", addressFieldLostFocus.bind(input)); input.observe("blur", addressFieldLostFocus.bind(input));
input.observe("autocompletion:changedlist", expandContactList); input.observe("autocompletion:changedlist", expandContactList);
input.on("autocompletion:changed", addressFieldChanged.bind(input));
input.focus();
addressList.insertBefore(row, lastChild); return input;
} }
function expandContactList (e) { function expandContactList (e) {
@ -132,6 +132,8 @@ function addressFieldGotFocus(event) {
idx = getIndexFromIdentifier(this.id); idx = getIndexFromIdentifier(this.id);
if (lastIndex == idx) return; if (lastIndex == idx) return;
removeLastEditedRowIfEmpty(); removeLastEditedRowIfEmpty();
if (Prototype.Browser.IE && this.value.length == 0)
$(this).setCaretTo(0); // IE hack
onWindowResize(null); onWindowResize(null);
return false; return false;
@ -139,7 +141,9 @@ function addressFieldGotFocus(event) {
function addressFieldLostFocus(event) { function addressFieldLostFocus(event) {
lastIndex = getIndexFromIdentifier(this.id); lastIndex = getIndexFromIdentifier(this.id);
}
function addressFieldChanged(event) {
var addresses = this.value.split(/[,;]/); var addresses = this.value.split(/[,;]/);
if (addresses.length > 0) { if (addresses.length > 0) {
var first = true; var first = true;
@ -177,9 +181,18 @@ function addressFieldLostFocus(event) {
} }
} }
} }
onWindowResize(null);
return false; // Verify if a new row should be created
var keyCode = event.memo;
if (keyCode == Event.KEY_RETURN) {
var input = fancyAddRow("");
if (Prototype.Browser.IE)
$(input.id).focus();
else
input.focus();
}
onWindowResize(null);
} }
function removeLastEditedRowIfEmpty() { function removeLastEditedRowIfEmpty() {

View file

@ -449,16 +449,17 @@ function isSafari3() {
return (navigator.appVersion.indexOf("Version") > -1); return (navigator.appVersion.indexOf("Version") > -1);
} }
function isSafari() { function isWebKit() {
//var agt = navigator.userAgent.toLowerCase(); //var agt = navigator.userAgent.toLowerCase();
//var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false; //var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
return (navigator.vendor == "Apple Computer, Inc.") ||
return (navigator.vendor == "Apple Computer, Inc.") || (navigator.userAgent.toLowerCase().indexOf('konqueror') != -1); (navigator.userAgent.toLowerCase().indexOf('konqueror') != -1) ||
(navigator.userAgent.indexOf('AppleWebKit') != -1);
} }
function isHttpStatus204(status) { function isHttpStatus204(status) {
return (status == 204 || // Firefox return (status == 204 || // Firefox
(isSafari() && typeof(status) == 'undefined') || // Safari (isWebKit() && typeof(status) == 'undefined') || // Safari
status == 1223); // IE status == 1223); // IE
} }
@ -498,7 +499,7 @@ function refreshOpener() {
function eventIsLeftClick(event) { function eventIsLeftClick(event) {
var isLeftClick = true; var isLeftClick = true;
if (isMac() && isSafari()) { if (isMac() && isWebKit()) {
if (event.ctrlKey == 1) { if (event.ctrlKey == 1) {
// Control-click is equivalent to right-click under Mac OS X // Control-click is equivalent to right-click under Mac OS X
isLeftClick = false; isLeftClick = false;
@ -1778,9 +1779,13 @@ function createDialog(id, title, legend, content, positionClass) {
var titleh3 = createElement("h3", null, null, null, null, subdiv); var titleh3 = createElement("h3", null, null, null, null, subdiv);
titleh3.appendChild(document.createTextNode(title)); titleh3.appendChild(document.createTextNode(title));
} }
if (legend && legend.length > 0) { if (legend) {
var legendP = createElement("p", null, null, null, null, subdiv); if (Object.isElement(legend))
legendP.appendChild(document.createTextNode(legend)); subdiv.appendChild(legend);
else if (legend.length > 0) {
var legendP = createElement("p", null, null, null, null, subdiv);
legendP.appendChild(document.createTextNode(legend));
}
} }
if (content) if (content)
subdiv.appendChild(content); subdiv.appendChild(content);
@ -1833,7 +1838,10 @@ function _showAlertDialog(label) {
} }
function showConfirmDialog(title, label, callbackYes, callbackNo) { function showConfirmDialog(title, label, callbackYes, callbackNo) {
var dialog = dialogs[title+label]; var key = title;
if (Object.isElement(label)) key += label.allTextContent();
else key += label;
var dialog = dialogs[key];
if (dialog) { if (dialog) {
$("bgDialogDiv").show(); $("bgDialogDiv").show();
@ -1854,7 +1862,7 @@ function showConfirmDialog(title, label, callbackYes, callbackNo) {
fields, fields,
"none"); "none");
document.body.appendChild(dialog); document.body.appendChild(dialog);
dialogs[title+label] = dialog; dialogs[key] = dialog;
} }
dialog.show(); dialog.show();
} }