From d7c25f23120a33ffd4bbac1aba246413f0d5f045 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Sun, 4 May 2008 20:37:10 +0000 Subject: [PATCH] * applied matts datepicker patches --- webcit/calendar_tools.c | 9 +++---- webcit/calendar_view.c | 2 +- webcit/event.c | 39 ++++-------------------------- webcit/static/datepicker-dev.js | 17 ++++++++++++- webcit/static/wclib.js | 43 +++++++++++++++++++++++++++------ 5 files changed, 62 insertions(+), 48 deletions(-) diff --git a/webcit/calendar_tools.c b/webcit/calendar_tools.c index f06b8e09f..45fcef8d2 100644 --- a/webcit/calendar_tools.c +++ b/webcit/calendar_tools.c @@ -72,12 +72,11 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) { wc_strftime(timebuf, 32, "%d/%m/%Y", &tm); wprintf(timebuf); wprintf("\">"); - wprintf(""); + wprintf("');\n"); + wprintf(""); wprintf(_("Hour: ")); wprintf("\n"); - wprintf("\n" - ); - - wprintf("
" "
\n"); @@ -200,10 +171,10 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, } display_icaltimetype_as_webform(&t_start, "dtstart"); - wprintf("%s", - (t_start.is_date ? "CHECKED" : "" ), + (t_start.is_date ? "CHECKED=\"CHECKED\"" : "" ), _("All day event") ); @@ -216,7 +187,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, */ wprintf("
"); wprintf(_("End")); - wprintf("\n"); + wprintf("\n"); if (t_start.is_date) { t_end = t_start; } @@ -407,7 +378,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, wprintf("
\n"); wprintf("\n" ); diff --git a/webcit/static/datepicker-dev.js b/webcit/static/datepicker-dev.js index c558ff82d..71095caad 100644 --- a/webcit/static/datepicker-dev.js +++ b/webcit/static/datepicker-dev.js @@ -194,6 +194,9 @@ DatePicker.prototype = { 'zh' : '关 闭', 'sv' : 'stäng' }), + _language_reset : $H({ // FILL ME IN + 'en' : 'reset' + }), /* date manipulation */ _todayDate : new Date(), _current_date : null, @@ -232,6 +235,9 @@ DatePicker.prototype = { getLocaleClose : function () { return this._language_close.get(this._language); }, + getLocaleReset : function() { + return this._language_reset.get(this._language); + }, _initCurrentDate : function () { /* Create the DateFormatter */ this._df = new DatePickerFormatter(this._dateFormat[0], this._dateFormat[1]); @@ -309,13 +315,14 @@ DatePicker.prototype = { this._id_datepicker_next_year = this._id_datepicker_next+'-year'; this._id_datepicker_hdr = this._id_datepicker+'-header'; this._id_datepicker_ftr = this._id_datepicker+'-footer'; + this._id_datepicker_rst = this._id_datepicker+'-reset'; /* build up calendar skel */ this._div = new Element('div', { id : this._id_datepicker, className : 'datepicker', style : 'display: none; z-index:'+this._zindex }); - this._div.innerHTML = ''+((this._enableYearBrowse) ? '' : '')+''+((this._enableYearBrowse) ? '' : '')+'
 <  <<  >>  > 
'; + this._div.innerHTML = ''+((this._enableYearBrowse) ? '' : '')+''+((this._enableYearBrowse) ? '' : '')+'
 <  <<  >>  > 
'; /* finally declare the event listener on input field */ Event.observe(this._relative, this._showEvent, this.click.bindAsEventListener(this), false); @@ -370,6 +377,7 @@ DatePicker.prototype = { this._initCurrentDate(); /* set the close locale content */ $(this._id_datepicker_ftr).innerHTML = this.getLocaleClose(); + $(this._id_datepicker_rst).innerHTML = this.getLocaleReset(); /* declare the observers for UI control */ Event.observe($(this._id_datepicker_prev), 'click', this.prevMonth.bindAsEventListener(this), false); @@ -383,6 +391,8 @@ DatePicker.prototype = { } Event.observe($(this._id_datepicker_ftr), 'click', this.close.bindAsEventListener(this), false); + Event.observe($(this._id_datepicker_rst), + 'click', this.reset.bindAsEventListener(this), false); }, /* hack for buggy form elements layering in IE */ _wrap_in_iframe : function ( content ) { @@ -475,6 +485,11 @@ DatePicker.prototype = { } eval(this._afterClose()); }, + // Reset function + reset: function() { + $(this._relative).value = ""; + this._initCurrentDate(); + }, /** * setDateFormat */ diff --git a/webcit/static/wclib.js b/webcit/static/wclib.js index 931d8e241..853f01b35 100644 --- a/webcit/static/wclib.js +++ b/webcit/static/wclib.js @@ -866,24 +866,34 @@ function HandleRSVP(question_divname, title_divname, msgnum, cal_partnum, sc) { new Ajax.Updater(title_divname, 'handle_rsvp', { method: 'post', parameters: p } ); Effect.Fade(question_divname, { duration: 0.5 }); } - +var fakeMouse = document.createEvent("MouseEvents"); +fakeMouse.initMouseEvent("click", true, true, window, + 0,0,0,0,0, false, false, false, false, 0, null); // TODO: Collapse into one function function toggleTaskDtStart(event) { var checkBox = $('nodtstart'); + dtStart = document.getElementById("dtstart"); if (checkBox.checked) { - $('dtstart').disabled = true; - $('dtstart').value = ""; + dtStart.disabled = true; + dtStart.style.textDecoration = "line-through"; } else { - $('dtstart').disabled = false; + dtStart.disabled = false; + dtStart.style.textDecoration = ""; + if (dtStart.value.length == 0) + dtStart.dpck._initCurrentDate(); } } function toggleTaskDue(event) { var checkBox = $('nodue'); + dueField = document.getElementById("due"); if (checkBox.checked) { - $('due').disabled = true; - $('due').value = ""; + dueField.disabled = true; + dueField.style.textDecoration = "line-through"; } else { - $('due').disabled = false; + dueField.disabled = false; + dueField.style.textDecoration = ""; + if (dueField.value.length == 0) + dueField.dpck._initCurrentDate(); } } function ToggleTaskDateOrNoDateActivate(event) { @@ -899,3 +909,22 @@ function TaskViewGatherCategoriesFromTable() { var table = $('taskview'); } +function attachDatePicker(relative) { + var dpck = new DatePicker({ + relative: relative, + language: 'en', // fix please + disableFutureDate: false + }); + document.getElementById(relative).dpck = dpck; // attach a ref to it +} +function eventEditAllDay() { + var allDayCheck = document.getElementById("alldayevent"); + var dtend= document.getElementById("dtendcell"); + if(allDayCheck.checked) { + //dtend.disabled = true; + dtend.style.textDecoration = "line-through"; + } else { + //dtend_day.disabled = false; + dtend.style.textDecoration = ""; + } +} -- 2.30.2