2009-07-19 18:41:42 +02:00
|
|
|
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2008-08-28 16:48:45 +02:00
|
|
|
|
2008-04-22 01:04:26 +02:00
|
|
|
function onLoadCalendarProperties() {
|
2010-06-29 22:21:48 +02:00
|
|
|
var tabsContainer = $("propertiesTabs");
|
|
|
|
var controller = new SOGoTabsController();
|
|
|
|
controller.attachToTabsContainer(tabsContainer);
|
|
|
|
|
2009-11-04 23:13:20 +01:00
|
|
|
var colorButton = $("colorButton");
|
|
|
|
var calendarColor = $("calendarColor");
|
2013-11-15 21:50:46 +01:00
|
|
|
colorButton.setStyle({ "backgroundColor": colorButton.readAttribute('data-color') });
|
2009-11-04 23:13:20 +01:00
|
|
|
colorButton.observe("click", onColorClick);
|
|
|
|
|
2013-11-15 21:50:46 +01:00
|
|
|
$('colorPickerDialog').on('click', 'span', onColorPickerChoice);
|
|
|
|
$(document.body).on("click", onBodyClickHandler);
|
|
|
|
|
2009-11-04 23:13:20 +01:00
|
|
|
var cancelButton = $("cancelButton");
|
|
|
|
cancelButton.observe("click", onCancelClick);
|
|
|
|
|
|
|
|
var okButton = $("okButton");
|
|
|
|
okButton.observe("click", onOKClick);
|
2014-05-15 20:44:31 +02:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
2008-04-22 01:04:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onCancelClick(event) {
|
2009-11-04 23:13:20 +01:00
|
|
|
window.close();
|
2008-04-22 01:04:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onOKClick(event) {
|
|
|
|
var calendarName = $("calendarName");
|
|
|
|
var calendarColor = $("calendarColor");
|
|
|
|
var calendarID = $("calendarID");
|
2009-08-18 03:03:05 +02:00
|
|
|
var save = true;
|
2009-08-19 02:26:55 +02:00
|
|
|
var tag = $("calendarSyncTag");
|
2009-08-18 03:03:05 +02:00
|
|
|
var originalTag = $("originalCalendarSyncTag");
|
|
|
|
var allTags = $("allCalendarSyncTags");
|
2008-04-22 01:04:26 +02:00
|
|
|
|
2011-07-08 17:48:55 +02:00
|
|
|
if (calendarName.value.blank()) {
|
|
|
|
alert(_("Please specify a calendar name."));
|
|
|
|
save = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (save
|
|
|
|
&& allTags)
|
2009-08-18 03:03:05 +02:00
|
|
|
allTags = allTags.value.split(",");
|
|
|
|
|
2011-07-08 17:48:55 +02:00
|
|
|
if (save
|
|
|
|
&& tag
|
2009-08-19 02:26:55 +02:00
|
|
|
&& $("synchronizeCalendar").checked) {
|
|
|
|
if (tag.value.blank()) {
|
2010-06-02 21:11:15 +02:00
|
|
|
alert(_("tagNotDefined"));
|
2009-08-18 03:03:05 +02:00
|
|
|
save = false;
|
|
|
|
}
|
|
|
|
else if (allTags
|
2009-08-19 02:26:55 +02:00
|
|
|
&& allTags.indexOf(tag.value) > -1) {
|
2010-06-02 21:11:15 +02:00
|
|
|
alert(_("tagAlreadyExists"));
|
2009-08-18 03:03:05 +02:00
|
|
|
save = false;
|
|
|
|
}
|
|
|
|
else if (originalTag
|
2009-08-18 03:55:49 +02:00
|
|
|
&& !originalTag.value.blank()) {
|
2009-08-19 02:26:55 +02:00
|
|
|
if (tag.value != originalTag.value)
|
2010-06-02 21:11:15 +02:00
|
|
|
save = confirm(_("tagHasChanged"));
|
2009-08-18 03:55:49 +02:00
|
|
|
}
|
|
|
|
else
|
2010-06-02 21:11:15 +02:00
|
|
|
save = confirm(_("tagWasAdded"));
|
2009-08-18 03:03:05 +02:00
|
|
|
}
|
2011-07-08 17:48:55 +02:00
|
|
|
else if (save
|
|
|
|
&& originalTag
|
2009-08-18 03:03:05 +02:00
|
|
|
&& !originalTag.value.blank())
|
2010-06-02 21:11:15 +02:00
|
|
|
save = confirm(_("tagWasRemoved"));
|
2009-08-18 03:03:05 +02:00
|
|
|
|
2009-11-04 23:13:20 +01:00
|
|
|
if (save) {
|
2009-08-18 03:03:05 +02:00
|
|
|
window.opener.updateCalendarProperties(calendarID.value,
|
|
|
|
calendarName.value,
|
|
|
|
calendarColor.value);
|
2009-11-04 23:13:20 +01:00
|
|
|
$("propertiesform").submit();
|
|
|
|
}
|
2009-08-18 03:03:05 +02:00
|
|
|
else
|
|
|
|
Event.stop(event);
|
2008-04-22 01:04:26 +02:00
|
|
|
}
|
|
|
|
|
2013-11-15 21:50:46 +01:00
|
|
|
function onBodyClickHandler(event) {
|
|
|
|
var target = getTarget(event);
|
|
|
|
if (!target.hasClassName('colorBox'))
|
|
|
|
$("colorPickerDialog").hide();
|
|
|
|
}
|
|
|
|
|
2008-04-22 01:04:26 +02:00
|
|
|
function onColorClick(event) {
|
2013-11-15 21:50:46 +01:00
|
|
|
var cellPosition = this.cumulativeOffset();
|
|
|
|
var cellDimensions = this.getDimensions();
|
|
|
|
var div = $('colorPickerDialog');
|
|
|
|
var divDimensions = div.getDimensions();
|
|
|
|
var left = cellPosition[0] + cellDimensions["width"] + 4;
|
|
|
|
var top = cellPosition[1] - 5;
|
|
|
|
div.setStyle({ left: left + "px", top: top + "px" });
|
|
|
|
div.show();
|
|
|
|
|
|
|
|
preventDefault(event);
|
2008-04-22 01:04:26 +02:00
|
|
|
}
|
|
|
|
|
2013-11-15 21:50:46 +01:00
|
|
|
function onColorPickerChoice(event) {
|
|
|
|
var span = getTarget(event);
|
|
|
|
var newColor = "#" + span.className.substr(4);
|
|
|
|
var colorButton = $("colorButton");
|
|
|
|
colorButton.setStyle({ "backgroundColor": newColor });
|
|
|
|
$("calendarColor").value = newColor;
|
2008-04-22 01:04:26 +02:00
|
|
|
}
|
|
|
|
|
2009-03-12 22:09:14 +01:00
|
|
|
document.observe("dom:loaded", onLoadCalendarProperties);
|