Add holidays through dialog.
authorJan Schneider <jan@horde.org>
Thu, 15 Jul 2010 22:08:27 +0000 (00:08 +0200)
committerJan Schneider <jan@horde.org>
Fri, 16 Jul 2010 10:40:40 +0000 (12:40 +0200)
kronolith/js/kronolith.js
kronolith/templates/chunks/calendar.php
kronolith/templates/index/index.inc

index 1656fa2..81338a4 100644 (file)
@@ -1138,7 +1138,9 @@ KronolithCore = {
         }, this);
 
         $H(Kronolith.conf.calendars.holiday).each(function(cal) {
-            this.insertCalendarInList('holiday', cal.key, cal.value);
+            if (cal.value.show) {
+               this.insertCalendarInList('holiday', cal.key, cal.value);
+            }
         }, this);
     },
 
@@ -2848,6 +2850,20 @@ KronolithCore = {
                     $('kronolithCalendarremoteId').setValue(calendar);
                 }
                 break;
+            case 'holiday':
+                $('kronolithCalendarholidayDriver').update();
+                $H(Kronolith.conf.calendars.holiday).each(function(calendar) {
+                    calendar = calendar.value;
+                    if (calendar.show) {
+                        return;
+                    }
+                    $('kronolithCalendarholidayDriver').insert(
+                        new Element('option', { value: calendar.name })
+                            .setStyle({ color: calendar.fg, backgroundColor: calendar.bg })
+                            .insert(calendar.name)
+                    );
+                });
+                break;
             }
             $('kronolithCalendar' + type + 'Id').clear();
             var color = '#', i;
@@ -3363,6 +3379,16 @@ KronolithCore = {
             this.colorPicker.hide();
         }
         var data = form.serialize({ hash: true });
+
+        if (data.type == 'holiday') {
+            this.insertCalendarInList('holiday', data.driver, Kronolith.conf.calendars.holiday[data.driver]);
+            this.toggleCalendar('holiday', data.driver);
+            form.down('.kronolithCalendarSave').enable();
+            this.closeRedBox();
+            this.go(this.lastLocation);
+            return;
+        }
+
         if (data.name.empty()) {
             this.showNotifications([ { type: 'horde.warning', message: data.type == 'tasklists' ? Kronolith.text.no_tasklist_title : Kronolith.text.no_calendar_title }]);
             $('kronolithCalendar' + data.type + 'Name').focus();
index 3901ccc..6b185b0 100644 (file)
@@ -270,4 +270,29 @@ $file_upload = $GLOBALS['browser']->allowFileUploads();
 
 </form>
 
+<?php if (!empty($GLOBALS['conf']['holidays']['enable']) && class_exists('Date_Holidays')): ?>
+<form id="kronolithCalendarFormholiday" action="">
+<input type="hidden" name="type" value="holiday" />
+<input id="kronolithCalendarholidayId" type="hidden" name="calendar" />
+<input id="kronolithCalendarholidayColor" type="hidden" name="color" />
+<input class="kronolithColorPicker" type="hidden" />
+
+<div class="kronolithCalendarDiv" id="kronolithCalendarholiday1">
+<div>
+  <label><?php echo _("Holidays") ?>:<br />
+    <select id="kronolithCalendarholidayDriver" name="driver">
+    </select>
+  </label>
+</div>
+
+<div class="kronolithFormActions">
+  <input type="button" value="<?php echo _("Save") ?>" class="kronolithCalendarSave button ok" />
+  <input type="button" value="<?php echo _("Delete") ?>" class="kronolithCalendarDelete button ko" />
+  <span class="kronolithSeparator"><?php echo _("or") ?></span> <a class="kronolithFormCancel"><?php echo _("Cancel") ?></a>
+</div>
+</div>
+
+</form>
+<?php endif ?>
+
 </div>
index 8e9a273..c874fa8 100644 (file)
   </div>
 
   <h3>
+    <a href="#" id="kronolithAddholiday" class="kronolithAdd" title="<?php echo _("Add Holidays") ?>">+</a>
     <span><?php echo _("Holidays") ?></span>
   </h3>