Update quick event adding interface.
authorJan Schneider <jan@horde.org>
Tue, 3 Nov 2009 16:28:27 +0000 (17:28 +0100)
committerJan Schneider <jan@horde.org>
Tue, 3 Nov 2009 16:28:27 +0000 (17:28 +0100)
kronolith/js/kronolith.js
kronolith/lib/Kronolith.php
kronolith/templates/index/index.inc
kronolith/themes/screen.css

index 352a453..016693d 100644 (file)
@@ -804,6 +804,23 @@ KronolithCore = {
     },
 
     /**
+     * Propagates a SELECT drop down list with the editable calendars.
+     *
+     * @param string id  The id of the SELECT element.
+     */
+    updateCalendarDropDown: function(id)
+    {
+        $(id).update();
+        $H(Kronolith.conf.calendars.internal).each(function(cal) {
+            if (cal.value.edit) {
+                $(id).insert(new Element('OPTION', { 'value': cal.key })
+                             .setStyle({ 'backgroundColor': cal.value.bg, 'color': cal.value.fg })
+                             .update(cal.value.name.escapeHTML()));
+            }
+        });
+    },
+
+    /**
      * Sets the load signature and show the loading spinner.
      *
      * @param string cal    The loading calendar.
@@ -1897,6 +1914,7 @@ KronolithCore = {
                 return;
 
             case 'kronolithQuickEvent':
+                this.updateCalendarDropDown('kronolithQuickinsertCalendars');
                 $('kronolithQuickinsert').appear({
                     duration: 0.3,
                     afterFinish: function() {
index 6f69873..5078b08 100644 (file)
@@ -148,15 +148,20 @@ class Kronolith
             // Turn debugging on?
             'debug' => !empty($conf['js']['debug']),
         );
-        foreach ($GLOBALS['all_calendars'] as $id => $calendar) {
-            $owner = $calendar->get('owner') == Horde_Auth::getAuth();
-            $code['conf']['calendars']['internal'][$id] = array(
-                'name' => ($owner ? '' : '[' . Horde_Auth::convertUsername($calendar->get('owner'), false) . '] ')
-                    . $calendar->get('name'),
-                'owner' => $owner,
-                'fg' => self::foregroundColor($calendar),
-                'bg' => self::backgroundColor($calendar),
-                'show' => in_array($id, $GLOBALS['display_calendars']));
+        foreach (array(true, false) as $my) {
+            foreach ($GLOBALS['all_calendars'] as $id => $calendar) {
+                $owner = $calendar->get('owner') == Horde_Auth::getAuth();
+                if (($my && $owner) || (!$my && !$owner)) {
+                    $code['conf']['calendars']['internal'][$id] = array(
+                        'name' => ($owner ? '' : '[' . Horde_Auth::convertUsername($calendar->get('owner'), false) . '] ')
+                            . $calendar->get('name'),
+                        'owner' => $owner,
+                        'fg' => self::foregroundColor($calendar),
+                        'bg' => self::backgroundColor($calendar),
+                        'show' => in_array($id, $GLOBALS['display_calendars']),
+                        'edit' => $calendar->hasPermission(Horde_Auth::getAuth(), PERMS_READ));
+                }
+            }
         }
         foreach ($GLOBALS['all_external_calendars'] as $api => $categories) {
             foreach ($categories as $id => $name) {
index b16a7d4..69e4687 100644 (file)
@@ -34,7 +34,7 @@
 <!-- ini menu -->
 <div id="kronolithMenu">
   <div id="kronolithAddEvents">
-    <span id="kronolithNewEvent"><?php echo _("_New event") ?></span>
+    <span id="kronolithNewEvent" class="button"><?php echo _("_New event") ?></span>
     <span id="kronolithQuickEvent" title="<?php echo _("Quick _insert") ?>">+</span>
   </div>
 
@@ -133,10 +133,17 @@ require dirname(__FILE__) . '/agenda.inc';
 
 <div id="kronolithQuickinsert" style="display:none">
   <form id="kronolithQuickinsertForm" action="">
-    <input type="text" id="kronolithQuickinsertQ" value="" />
-    <input type="submit" id="kronolithQuickinsertSave" value="<?php echo _("Add") ?>" class="button ok" />
-    <input type="submit" id="kronolithQuickinsertCancel" value="x" class="button cancel" /><br />
-    <?php echo _("I.e. Dinner with John tomorrow 10am") ?><br />
+    <input type="text" id="kronolithQuickinsertQ" size="35" value="" class="kronolithLongField" /><br />
+    <span class="kronolithFormInfo"><?php echo _("I.e. Dinner with John
+tomorrow 10am") ?></span><br />
+
+    <label><?php echo _("Add to") ?>:</label>
+    <select id="kronolithQuickinsertCalendars">
+    </select>
+    <span class="kronolithSep">|</span>
+    <input type="button" id="kronolithQuickinsertSave" value="<?php echo _("Save") ?>" class="button ok" />
+    <span class="kronolithSep"><?php echo _("or") ?></span>
+    <a href="#" id="kronolithQuickinsertCancel" class="kronolithFormCancel"><?php echo _("Cancel") ?></a><br />
   </form>
 </div>
 
index b2175e0..401e893 100644 (file)
@@ -468,12 +468,17 @@ body.kronolithAjax {
 }
 #kronolithAddEvents span {
     /* We need some style here. */
-    margin-bottom: 5px;
-    padding-right: 10px;
+    float: left;
     font-weight: bold;
     cursor: pointer;
 }
+span#kronolithNewEvent {
+    width: 121px;
+    margin-right: 10px;
+    text-align: center;
+}
 span#kronolithQuickEvent {
+    width: 16px;
     background: transparent url("graphics/new.png") no-repeat;
     color: transparent;
 }
@@ -490,10 +495,10 @@ span#kronolithQuickEvent {
 #kronolithQuickinsert {
     position: absolute;
     z-index: 110;
-    left: 105px;
+    left: 163px;
     top: 10px;
-    width: 250px;
-    height: 75px;
+    width: 350px;
+    height: auto;
     margin: 0;
     padding: 0;
     background: transparent url("graphics/back_quick.png") no-repeat left top;
@@ -502,9 +507,6 @@ span#kronolithQuickEvent {
     padding:  5px;
     margin: 5px 5px 5px 15px;
 }
-#kronolithQuickinsertQ {
-    width: 150px;
-}
 
 /* Navigation bar */
 #kronolithBar {