* applied matts datepicker patches
authorWilfried Göesgens <willi@citadel.org>
Sun, 4 May 2008 20:37:10 +0000 (20:37 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 4 May 2008 20:37:10 +0000 (20:37 +0000)
webcit/calendar_tools.c
webcit/calendar_view.c
webcit/event.c
webcit/static/datepicker-dev.js
webcit/static/wclib.js

index f06b8e09fd6f7401a3301942646226db28127e19..45fcef8d2e03b3d387e7fecd40c8ee84b2f828c3 100644 (file)
@@ -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("<script type=\"text/javascript\">\n");
-       wprintf("       var dpck = new DatePicker({\n           ");
-       wprintf("relative: '");
+       wprintf("<script type=\"text/javascript\">");
+       wprintf("attachDatePicker('");
        wprintf(prefix);
-       wprintf("',\n   language: 'en',\n");
-       wprintf("disableFutureDate:     false\n});</script>");
+       wprintf("');\n");
+       wprintf("</script>");
        wprintf(_("Hour: "));
        wprintf("<SELECT NAME=\"%s_hour\" SIZE=\"1\">\n", prefix);
        for (i=0; i<=23; ++i) {
index 0cb0273d19a429edaf1094482cc4854e688f7fd1..d0858d27e8206401e7a5cd037cb7d71e2c228132 100644 (file)
@@ -1488,7 +1488,7 @@ void do_tasks_view(void) {
        if (WC->num_cal) for (i=0; i<(WC->num_cal); ++i) {
                wprintf("<tr><td>");
                icalproperty_status todoStatus = icalcomponent_get_status(WC->disp_cal[i].cal);
-               wprintf("<input style=\"text-align: center;\" type=\"checkbox\" name=\"completed\" value=\"completed\" ");
+               wprintf("<input type=\"checkbox\" name=\"completed\" value=\"completed\" ");
                if (todoStatus == ICAL_STATUS_COMPLETED) {
                        wprintf("checked=\"checked\" ");
                }
index d1a6e6e366744f7f32aed6401baaad1a5ec934d5..f2575508b12dd72a280c40c8a940bdbf68071449 100644 (file)
@@ -78,35 +78,6 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
 
        wprintf("<div id=\"content\" class=\"service\">\n");
 
-       wprintf("<script type=\"text/javascript\">"
-               "function grey_all_day() { "
-                       "if (document.EventForm.alldayevent.checked) {"
-                               "document.EventForm.dtstart_hour.value='0';"
-                               "document.EventForm.dtstart_hour.disabled = true;"
-                               "document.EventForm.dtstart_minute.value='0';"
-                               "document.EventForm.dtstart_minute.disabled = true;"
-                               "document.EventForm.dtend_hour.value='0';"
-                               "document.EventForm.dtend_hour.disabled = true;"
-                               "document.EventForm.dtend_minute.value='0';"
-                               "document.EventForm.dtend_minute.disabled = true;"
-                               "document.EventForm.dtend_month.disabled = true;"
-                               "document.EventForm.dtend_day.disabled = true;"
-                               "document.EventForm.dtend_year.disabled = true;"
-                       "}"
-                       "else {"
-                               "document.EventForm.dtstart_hour.disabled = false;"
-                               "document.EventForm.dtstart_minute.disabled = false;"
-                               "document.EventForm.dtend_hour.disabled = false;"
-                               "document.EventForm.dtend_minute.disabled = false;"
-                               "document.EventForm.dtend_month.disabled = false;"
-                               "document.EventForm.dtend_day.disabled = false;"
-                               "document.EventForm.dtend_year.disabled = false;"
-                       "}"
-               "}"
-               "</script>\n"
-       );
-
-
        wprintf("<div class=\"fix_scrollbar_bug\">"
                "<table  class=\"event_background\"><tr><td>\n");
 
@@ -200,10 +171,10 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        }
        display_icaltimetype_as_webform(&t_start, "dtstart");
 
-       wprintf("<INPUT TYPE=\"checkbox\" NAME=\"alldayevent\" "
-               "VALUE=\"yes\" onClick=\"grey_all_day();\""
+       wprintf("<INPUT TYPE=\"checkbox\" id=\"alldayevent\" NAME=\"alldayevent\" "
+               "VALUE=\"yes\" onclick=\"eventEditAllDay();\""
                " %s >%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("<TR><TD><B>");
        wprintf(_("End"));
-       wprintf("</B></TD><TD>\n");
+       wprintf("</B></TD><TD id=\"dtendcell\">\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("</td></tr></table></div>\n");
        wprintf("<script type=\"text/javascript\">"
-               "grey_all_day();"
+               "eventEditAllDay();"
                "</script>\n"
        );
        
index c558ff82daefdb468bfd0ca34bdc1113100e283a..71095caadfebad96cec3acc73bea49a02dc1a93b 100644 (file)
@@ -194,6 +194,9 @@ DatePicker.prototype        = {
   'zh' : '&#20851;&#32;&#38381',
   'sv' : 'st&#228;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 = '<table><thead><tr>'+((this._enableYearBrowse) ? '<th width="10px" id="'+this._id_datepicker_prev_year+'" style="cursor: pointer;">&nbsp;&lt;&nbsp;</th>' : '')+'<th width="10px" id="'+this._id_datepicker_prev+'" style="cursor: pointer;">&nbsp;&lt;&lt;&nbsp;</th><th id="'+this._id_datepicker_hdr+'" colspan="'+((this._enableYearBrowse) ? 3 : 5 )+'"></th><th width="10px" id="'+this._id_datepicker_next+'" style="cursor: pointer;">&nbsp;&gt;&gt;&nbsp;</th>'+((this._enableYearBrowse) ? '<th width="10px" id="'+this._id_datepicker_next_year+'" style="cursor: pointer;">&nbsp;&gt;&nbsp;</th>' : '')+'</tr></thead><tbody id="'+this._id_datepicker+'-tbody"></tbody><tfoot><td colspan="7" id="'+this._id_datepicker_ftr+'"></td></tfoot></table>';
+  this._div.innerHTML = '<table><thead><tr>'+((this._enableYearBrowse) ? '<th width="10px" id="'+this._id_datepicker_prev_year+'" style="cursor: pointer;">&nbsp;&lt;&nbsp;</th>' : '')+'<th width="10px" id="'+this._id_datepicker_prev+'" style="cursor: pointer;">&nbsp;&lt;&lt;&nbsp;</th><th id="'+this._id_datepicker_hdr+'" colspan="'+((this._enableYearBrowse) ? 3 : 5 )+'"></th><th width="10px" id="'+this._id_datepicker_next+'" style="cursor: pointer;">&nbsp;&gt;&gt;&nbsp;</th>'+((this._enableYearBrowse) ? '<th width="10px" id="'+this._id_datepicker_next_year+'" style="cursor: pointer;">&nbsp;&gt;&nbsp;</th>' : '')+'</tr></thead><tbody id="'+this._id_datepicker+'-tbody"></tbody><tfoot><tr><td colspan="7" id="'+this._id_datepicker_ftr+'"></td></tr><tr><td colspan="7" id="'+this._id_datepicker_rst+'"></td></tr></tfoot></table>';
   /* 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
   */
index 931d8e241893ec66731233dbfb613ed8380b8d33..853f01b353721f78f4a0f51e536f0176c77f6f62 100644 (file)
@@ -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 = "";
+       }
+}