2 Copyright (C) 2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 var contactSelectorAction = 'calendars-contacts';
24 function uixEarlierDate(date1, date2) {
25 // can this be done in a sane way?
27 if (date1.getYear() < date2.getYear()) return date1;
28 if (date1.getYear() > date2.getYear()) return date2;
30 // cuicui += '/month';
31 if (date1.getMonth() < date2.getMonth()) return date1;
32 if (date1.getMonth() > date2.getMonth()) return date2;
35 if (date1.getDate() < date2.getDate()) return date1;
36 if (date1.getDate() > date2.getDate()) return date2;
41 function validateAptEditor() {
42 var e, startdate, enddate, tmpdate;
45 if (e.value.length == 0) {
46 if (!confirm(labels.validate_notitle.decodeEntities()))
50 e = $('startTime_date');
51 if (e.value.length != 10) {
52 alert(labels.validate_invalid_startdate.decodeEntities());
55 startdate = e.calendar.prs_date(e.value);
56 if (startdate == null) {
57 alert(labels.validate_invalid_startdate.decodeEntities());
61 e = $('endTime_date');
62 if (e.value.length != 10) {
63 alert(labels.validate_invalid_enddate.decodeEntities());
66 enddate = e.calendar.prs_date(e.value);
67 if (enddate == null) {
68 alert(labels.validate_invalid_enddate.decodeEntities());
72 tmpdate = uixEarlierDate(startdate, enddate);
73 if (tmpdate == enddate) {
74 // window.alert(cuicui);
75 alert(labels.validate_endbeforestart.decodeEntities());
78 else if (tmpdate == null /* means: same date */) {
82 start = parseInt(document.forms[0]['startTime_time_hour'].value);
83 end = parseInt(document.forms[0]['endTime_time_hour'].value);
86 alert(labels.validate_endbeforestart.decodeEntities());
89 else if (start == end) {
90 start = parseInt(document.forms[0]['startTime_time_minute'].value);
91 end = parseInt(document.forms[0]['endTime_time_minute'].value);
93 alert(labels.validate_endbeforestart.decodeEntities());
102 function toggleDetails() {
103 var div = $("details");
104 var buttons = $("buttons");
105 var buttonsHeight = buttons.clientHeight * 3;
107 if (div.style.visibility) {
108 div.style.visibility = null;
109 window.resizeBy(0, -(div.clientHeight + buttonsHeight));
110 $("detailsButton").innerHTML = labels["Show Details"];
112 div.style.visibility = 'visible;';
113 window.resizeBy(0, (div.clientHeight + buttonsHeight));
114 $("detailsButton").innerHTML = labels["Hide Details"];
120 function toggleCycleVisibility(node, nodeName, hiddenValue) {
121 var spanNode = $(nodeName);
122 var newVisibility = ((node.value == hiddenValue) ? null : 'visible;');
123 spanNode.style.visibility = newVisibility;
125 if (nodeName == 'cycleSelectionFirstLevel') {
126 var otherSpanNode = $('cycleSelectionSecondLevel');
129 otherSpanNode.superVisibility = otherSpanNode.style.visibility;
130 otherSpanNode.style.visibility = null;
134 otherSpanNode.style.visibility = otherSpanNode.superVisibility;
135 otherSpanNode.superVisibility = null;
140 function addContact(tag, fullContactName, contactId, contactName, contactEmail) {
141 var uids = $('uixselector-participants-uidList');
142 log ("contactId: " + contactId);
145 var re = new RegExp("(^|,)" + contactId + "($|,)");
147 log ("uids: " + uids);
148 if (!re.test(uids.value))
150 log ("no match... realling adding");
151 if (uids.value.length > 0)
152 uids.value += ',' + contactId;
154 uids.value = contactId;
156 var names = $('uixselector-participants-display');
157 names.innerHTML += ('<li onmousedown="return false;"'
158 + ' onclick="onRowClick(event);"><img src="'
159 + ResourcesURL + '/abcard.gif" />'
160 + contactName + '</li>');
163 log ("match... ignoring contact");
169 function saveEvent(sender) {
170 if (validateAptEditor())
171 document.forms['editform'].submit();
176 function startDayAsShortString() {
177 return $('startTime_date').valueAsShortDateString();
180 function endDayAsShortString() {
181 return $('endTime_date').valueAsShortDateString();
184 this._getDate = function(which) {
185 var date = window.timeWidgets[which]['date'].valueAsDate();
186 date.setHours( window.timeWidgets[which]['hour'].value );
187 date.setMinutes( window.timeWidgets[which]['minute'].value );
192 this._getShadowDate = function(which) {
193 var date = window.timeWidgets[which]['date'].getAttribute("shadow-value").asDate();
194 var intValue = parseInt(window.timeWidgets[which]['hour'].getAttribute("shadow-value"));
195 date.setHours(intValue);
196 intValue = parseInt(window.timeWidgets[which]['minute'].getAttribute("shadow-value"));
197 date.setMinutes(intValue);
198 // window.alert("shadow: " + date);
203 this.getStartDate = function() {
204 return this._getDate('start');
207 this.getEndDate = function() {
208 return this._getDate('end');
211 this.getShadowStartDate = function() {
212 return this._getShadowDate('start');
215 this.getShadowEndDate = function() {
216 return this._getShadowDate('end');
219 this._setDate = function(which, newDate) {
220 window.timeWidgets[which]['date'].setValueAsDate(newDate);
221 window.timeWidgets[which]['hour'].value = newDate.getHours();
222 var minutes = newDate.getMinutes();
224 minutes += (15 - minutes % 15);
225 window.timeWidgets[which]['minute'].value = minutes;
228 this.setStartDate = function(newStartDate) {
229 this._setDate('start', newStartDate);
232 this.setEndDate = function(newEndDate) {
233 // window.alert(newEndDate);
234 this._setDate('end', newEndDate);
237 this.onAdjustEndTime = function(event) {
238 var dateDelta = (window.getStartDate().valueOf()
239 - window.getShadowStartDate().valueOf());
240 // window.alert(window.getEndDate().valueOf() + ' ' + dateDelta);
241 var newEndDate = new Date(window.getEndDate().valueOf() + dateDelta);
242 window.setEndDate(newEndDate);
243 window.timeWidgets['start']['date'].updateShadowValue();
244 window.timeWidgets['start']['hour'].updateShadowValue();
245 window.timeWidgets['start']['minute'].updateShadowValue();
248 this.initTimeWidgets = function (widgets) {
249 this.timeWidgets = widgets;
251 widgets['start']['date'].addEventListener("change", this.onAdjustEndTime, false);
252 widgets['start']['hour'].addEventListener("change", this.onAdjustEndTime, false);
253 widgets['start']['minute'].addEventListener("change", this.onAdjustEndTime, false);