Monotone-Parent: b71cb031b6d81c362bbb5a411baf4cd30bcf1b01

Monotone-Revision: f0e01017c45580ffb00a3ec0ea376689e815bd26

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2006-11-07T16:13:03
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2006-11-07 16:13:03 +00:00
parent 53d90d404c
commit 0885f51b6f
10 changed files with 221 additions and 25 deletions
+6
View File
@@ -1,3 +1,9 @@
2006-11-07 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/WebServerResources/UIxAppointmentEditor.js,
UI/WebServerResources/UIxTaskEditor.js: added code to manage start
date change.
2006-11-03 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/Scheduler/UIxComponentEditor.m ([UIxComponentEditor
@@ -10,6 +10,7 @@
var:name="dateID"
var:id="dateID"
var:dateFormat="jsDateFormat"
var:shadow-value="formattedDateString"
var:value="formattedDateString"
size="12"
/><a href="#"
@@ -145,6 +145,15 @@
</div>
</div>
<script type="text/javascript">
initTimeWidgets( { 'start': { 'hour': document.forms['editform']['startTime_time_hour'],
'minute': document.forms['editform']['startTime_time_minute'],
'date': document.forms['editform']['startTime_date'] },
'due': { 'hour': document.forms['editform']['dueTime_time_hour'],
'minute': document.forms['editform']['dueTime_time_minute'],
'date': document.forms['editform']['dueTime_date'] } } );
</script>
<!-- div id="buttons">
<input
type="submit"
@@ -17,7 +17,7 @@
/>
<var:if condition="displayTimeControl">
<var:if condition="disabled">
<select var:name="hourSelectId" const:disabled="disabled">
<select var:shadow-value="hour" var:name="hourSelectId" const:disabled="disabled">
<var:foreach list="selectableHours" item="hourOption"
><var:if condition="isCurrentHour"
><option var:value="hourValue" selected="selected"
@@ -28,7 +28,7 @@
/></option></var:if>
</var:foreach
></select>
<select var:name="minuteSelectId" const:disabled="disabled">
<select var:shadow-value="minute" var:name="minuteSelectId" const:disabled="disabled">
<var:foreach list="selectableMinutes" item="minuteOption"
><var:if condition="isCurrentMinute"
><option var:value="minuteValue" selected="selected"
@@ -43,7 +43,7 @@
</var:if
><var:if condition="disabled" const:negate="YES">
<select var:name="hourSelectId">
<select var:shadow-value="hour" var:name="hourSelectId">
<var:foreach list="selectableHours" item="hourOption"
><var:if condition="isCurrentHour"
><option var:value="hourValue" selected="selected"
@@ -54,7 +54,7 @@
/></option></var:if>
</var:foreach
></select>
<select var:name="minuteSelectId">
<select var:shadow-value="minute" var:name="minuteSelectId">
<var:foreach list="selectableMinutes" item="minuteOption"
><var:if condition="isCurrentMinute"
><option var:value="minuteValue" selected="selected"
+14 -9
View File
@@ -16,16 +16,17 @@ HTMLInputElement.prototype.assignReplica = function(otherInput) {
}
HTMLInputElement.prototype.valueAsDate = function () {
var newDate;
var date = this.value.split("/");
if (date.length == 3)
newDate = new Date(date[2], date[1] - 1, date[0]);
else {
date = this.value.split("-");
newDate = new Date(date[0], date[1] - 1, date[2]);
}
return this.value.asDate();
}
return newDate;
HTMLInputElement.prototype.setValueAsDate = function(dateValue) {
if (!this.dateSeparator)
this._detectDateSeparator();
this.value = dateValue.stringWithSeparator(this.dateSeparator);
}
HTMLInputElement.prototype.updateShadowValue = function () {
this.setAttribute("shadow-value", this.value);
}
HTMLInputElement.prototype._detectDateSeparator = function() {
@@ -68,3 +69,7 @@ HTMLSelectElement.prototype.assignReplica = function(otherSelect) {
}
this.replica = otherSelect;
}
HTMLSelectElement.prototype.updateShadowValue = function () {
this.setAttribute("shadow-value", this.value);
}
@@ -17,6 +17,19 @@ String.prototype.decodeEntities = function() {
});
}
String.prototype.asDate = function () {
var newDate;
var date = this.split("/");
if (date.length == 3)
newDate = new Date(date[2], date[1] - 1, date[0]);
else {
date = this.split("-");
newDate = new Date(date[0], date[1] - 1, date[2]);
}
return newDate;
}
Date.prototype.sogoDayName = function() {
var dayName = "";
@@ -55,12 +68,22 @@ Date.prototype.daysUpTo = function(otherDate) {
return days;
}
Date.prototype.sogoFreeBusyStringWithSeparator = function(separator) {
var str = this.sogoDayName() + ", ";
Date.prototype.stringWithSeparator = function(separator) {
var month = '' + (this.getMonth() + 1);
var day = '' + this.getDate();
if (month.length == 1)
month = '0' + month;
if (day.length == 1)
day = '0' + day;
if (separator == '-')
str += (this.getYear() + 1900) + '-' + (this.getMonth() + 1) + '-' + this.getDate();
str = (this.getYear() + 1900) + '-' + month + '-' + day;
else
str += this.getDate() + '/' + (this.getMonth() + 1) + '/' + (this.getYear() + 1900);
str = day + '/' + month + '/' + (this.getYear() + 1900);
return str;
}
Date.prototype.sogoFreeBusyStringWithSeparator = function(separator) {
return this.sogoDayName() + ", " + this.stringWithSeparator(separator);
}
+8 -6
View File
@@ -24,12 +24,14 @@ function newEvent(sender, type) {
day = currentDay;
var hour = sender.getAttribute("hour");
if (!hour)
hour = '0800';
var urlstr = (ApplicationBaseURL + "new"
+ type
+ "?day=" + day
+ "&hm=" + hour);
var urlstr = ApplicationBaseURL + "new" + type;
var params = new Array();
if (day)
params.push("day=" + day);
if (hour)
params.push("hm=" + hour);
if (params.length > 0)
urlstr += "?" + params.join("&");
window.open(urlstr, "", "width=620,height=600,resizable=0");
@@ -182,3 +182,75 @@ function startDayAsShortString() {
function endDayAsShortString() {
return $('endTime_date').valueAsShortDateString();
}
this._getDate = function(which) {
var date = window.timeWidgets[which]['date'].valueAsDate();
date.setHours( window.timeWidgets[which]['hour'].value );
date.setMinutes( window.timeWidgets[which]['minute'].value );
return date;
}
this._getShadowDate = function(which) {
var date = window.timeWidgets[which]['date'].getAttribute("shadow-value").asDate();
var intValue = parseInt(window.timeWidgets[which]['hour'].getAttribute("shadow-value"));
date.setHours(intValue);
intValue = parseInt(window.timeWidgets[which]['minute'].getAttribute("shadow-value"));
date.setMinutes(intValue);
// window.alert("shadow: " + date);
return date;
}
this.getStartDate = function() {
return this._getDate('start');
}
this.getEndDate = function() {
return this._getDate('end');
}
this.getShadowStartDate = function() {
return this._getShadowDate('start');
}
this.getShadowEndDate = function() {
return this._getShadowDate('end');
}
this._setDate = function(which, newDate) {
window.timeWidgets[which]['date'].setValueAsDate(newDate);
window.timeWidgets[which]['hour'].value = newDate.getHours();
var minutes = newDate.getMinutes();
if (minutes % 15)
minutes += (15 - minutes % 15);
window.timeWidgets[which]['minute'].value = minutes;
}
this.setStartDate = function(newStartDate) {
this._setDate('start', newStartDate);
}
this.setEndDate = function(newEndDate) {
// window.alert(newEndDate);
this._setDate('end', newEndDate);
}
this.onAdjustEndTime = function(event) {
var dateDelta = (window.getStartDate().valueOf()
- window.getShadowStartDate().valueOf());
// window.alert(window.getEndDate().valueOf() + ' ' + dateDelta);
var newEndDate = new Date(window.getEndDate().valueOf() + dateDelta);
window.setEndDate(newEndDate);
window.timeWidgets['start']['date'].updateShadowValue();
window.timeWidgets['start']['hour'].updateShadowValue();
window.timeWidgets['start']['minute'].updateShadowValue();
}
this.initTimeWidgets = function (widgets) {
this.timeWidgets = widgets;
widgets['start']['date'].addEventListener("change", this.onAdjustEndTime, false);
widgets['start']['hour'].addEventListener("change", this.onAdjustEndTime, false);
widgets['start']['minute'].addEventListener("change", this.onAdjustEndTime, false);
}
@@ -270,8 +270,13 @@ function resetAllFreeBusys()
displayFreeBusyForNode(awaitingFreeBusyRequests.shift());
}
function initTimeWidgets(widgets)
{
if (this.initTimeWidgets)
this.oldInitTimeWidgets = this.initTimeWidgets;
this.initTimeWidgets = function(widgets) {
if (this.oldInitTimeWidgets)
this.oldInitTimeWidgets(widgets);
this.timeWidgets = widgets;
widgets['start']['hour'].addEventListener("change", onTimeWidgetChange, false);
+73
View File
@@ -201,3 +201,76 @@ function startDayAsShortString() {
function dueDayAsShortString() {
return dayAsShortDateString($('dueTime_date'));
}
this._getDate = function(which) {
var date = window.timeWidgets[which]['date'].valueAsDate();
date.setHours( window.timeWidgets[which]['hour'].value );
date.setMinutes( window.timeWidgets[which]['minute'].value );
return date;
}
this._getShadowDate = function(which) {
var date = window.timeWidgets[which]['date'].getAttribute("shadow-value").asDate();
var intValue = parseInt(window.timeWidgets[which]['hour'].getAttribute("shadow-value"));
date.setHours(intValue);
intValue = parseInt(window.timeWidgets[which]['minute'].getAttribute("shadow-value"));
date.setMinutes(intValue);
// window.alert("shadow: " + date);
return date;
}
this.getStartDate = function() {
return this._getDate('start');
}
this.getDueDate = function() {
return this._getDate('due');
}
this.getShadowStartDate = function() {
return this._getShadowDate('start');
}
this.getShadowDueDate = function() {
return this._getShadowDate('due');
}
this._setDate = function(which, newDate) {
window.timeWidgets[which]['date'].setValueAsDate(newDate);
window.timeWidgets[which]['hour'].value = newDate.getHours();
var minutes = newDate.getMinutes();
if (minutes % 15)
minutes += (15 - minutes % 15);
window.timeWidgets[which]['minute'].value = minutes;
}
this.setStartDate = function(newStartDate) {
this._setDate('start', newStartDate);
}
this.setDueDate = function(newDueDate) {
// window.alert(newDueDate);
this._setDate('due', newDueDate);
}
this.onAdjustDueTime = function(event) {
if (!window.timeWidgets['due']['date'].disabled) {
var dateDelta = (window.getStartDate().valueOf()
- window.getShadowStartDate().valueOf());
var newDueDate = new Date(window.getDueDate().valueOf() + dateDelta);
window.setDueDate(newDueDate);
}
window.timeWidgets['start']['date'].updateShadowValue();
window.timeWidgets['start']['hour'].updateShadowValue();
window.timeWidgets['start']['minute'].updateShadowValue();
}
this.initTimeWidgets = function (widgets) {
this.timeWidgets = widgets;
widgets['start']['date'].addEventListener("change", this.onAdjustDueTime, false);
widgets['start']['hour'].addEventListener("change", this.onAdjustDueTime, false);
widgets['start']['minute'].addEventListener("change", this.onAdjustDueTime, false);
}