Fix UI issues when removing events from month view and using max_events.
authorJan Schneider <jan@horde.org>
Fri, 21 May 2010 16:57:37 +0000 (18:57 +0200)
committerJan Schneider <jan@horde.org>
Fri, 21 May 2010 17:18:43 +0000 (19:18 +0200)
kronolith/js/kronolith.js

index 7d160df..bad00cf 100644 (file)
@@ -1383,7 +1383,7 @@ KronolithCore = {
             break;
         }
 
-        var day = dates[0].clone(), date;
+        var day = dates[0].clone(), date, more;
         while (!day.isAfter(dates[1])) {
             date = day.dateString();
             switch (view) {
@@ -1429,6 +1429,12 @@ KronolithCore = {
                         }
                         this.holidays.push(event.key);
                     }
+                    if (Kronolith.conf.max_events) {
+                        more = $('kronolithMonthDay' + date).down('.kronolithMore');
+                        if (more) {
+                            more.remove();
+                        }
+                    }
                     if (view == 'month' && Kronolith.conf.max_events) {
                         var events = $('kronolithMonthDay' + date).select('.kronolithEvent');
                         if (events.size() >= Kronolith.conf.max_events) {
@@ -1509,6 +1515,7 @@ KronolithCore = {
                                     }
                                 }
                             }
+                            this.insertMore(date);
                         }
                     }
                     break;
@@ -3661,6 +3668,10 @@ KronolithCore = {
                     eventid = $F('kronolithEventId'),
                     view = this.view,
                     date = this.date;
+                $('kronolithBody').select('div').findAll(function(el) {
+                    return el.retrieve('calendar') == cal &&
+                        el.retrieve('eventid') == eventid;
+                }).invoke('hide');
                 this.doAction('deleteEvent',
                               { cal: cal, id: eventid },
                               function(r) {
@@ -3673,16 +3684,21 @@ KronolithCore = {
                                       }).invoke('toggle');
                                   }
                                   if (view == this.view &&
-                                      date.equals(this.date) &&
-                                      (view == 'week' || view == 'day')) {
+                                      date.equals(this.date)) {
                                       // Re-render.
-                                      this.insertEvents(this.viewDates(this.date, view), view);
+                                      switch (view) {
+                                      case 'week':
+                                      case 'day':
+                                          this.insertEvents(this.viewDates(this.date, view), view);
+                                          break;
+                                      case 'month':
+                                          if (Kronolith.conf.max_events) {
+                                              this.insertEvents(this.viewDates(this.date, view), view, cal);
+                                          }
+                                          break;
+                                      }
                                   }
                               }.bind(this));
-                $('kronolithBody').select('div').findAll(function(el) {
-                    return el.retrieve('calendar') == cal &&
-                        el.retrieve('eventid') == eventid;
-                }).invoke('hide');
                 this.closeRedBox();
                 window.history.back();
                 e.stop();