Add support for calendar input values
authorJoey Schulze <joey@infodrom.org>
Mon, 1 Mar 2010 15:39:27 +0000 (16:39 +0100)
committerJoey Schulze <joey@infodrom.org>
Mon, 1 Mar 2010 15:39:27 +0000 (16:39 +0100)
images/icons/calendar.gif [new file with mode: 0644]
lib/functions.js
lib/mask.php
stylesheet.css

diff --git a/images/icons/calendar.gif b/images/icons/calendar.gif
new file mode 100644 (file)
index 0000000..dc1f31c
Binary files /dev/null and b/images/icons/calendar.gif differ
index ea1d587..6fee4ab 100644 (file)
@@ -189,3 +189,32 @@ function grid_update(grid, filter, value)
     grid.buffer.fetch(-1);
 }
 
+var calendars = new Array();
+function calendar_callback(value)
+{
+    this.input.value = value;
+}
+
+function calendar(name,event)
+{
+    var input = document.getElementById(name);
+    if (!input) return;
+
+    if (calendars[name] == undefined) {
+        calendars[name] = new Rico.CalendarControl('calendar_'+name,
+                                                  {startAt: 1,
+                                                   dateFmt: 'dd.mm.yyyy',
+                                                   showWeekNumber: 1});
+        calendars[name].atLoad();
+        calendars[name].returnValue = calendar_callback;
+        RicoUtil.positionCtlOverIcon(calendars[name].container,input);
+        calendars[name].open(input.value);
+       calendars[name].input = input;
+    } else {
+        if (Element.visible(calendars[name].container))
+            calendars[name].close();
+        else
+            calendars[name].open(input.value);
+    }
+    Event.stop(event);
+}
index e3c7eab..2df8cfb 100644 (file)
@@ -35,6 +35,11 @@ function build_form($name, $fields)
       $v[] = 'type="'.($info['type']=='passwd'?'password':'text').'"';
       $ret[] = sprintf('<label for="edit_%s">%s</label><br>', $id, $info['name']);
       $ret[] = sprintf('<input %s>', implode(' ', $v));
+    } elseif ($info['type'] == 'date') {
+      $ret[] = sprintf('<label for="edit_%s">%s</label><br>', $id, $info['name']);
+      $ret[] = sprintf('<input id="edit_%s" name="%s" size="8">&nbsp;'.
+                      '<img class="calendar" src="images/icons/calendar.gif" onclick="calendar(\'edit_%s\',event)" />',
+                      $id, $id, $id);
     } elseif ($info['type'] == 'boolean') {
       $ret[] = sprintf('<label for="edit_%s">%s</label><br>', $id, $info['name']);
       $ret[] = sprintf('<input type="checkbox" id="edit_%s" name="%s">', $id, $id);
index aa55690..543605c 100644 (file)
@@ -62,6 +62,10 @@ div.form div.buttons span {
     margin-left: 5px;
 }
 
+div.form img.calendar {
+    margin-bottom: -6px;
+}
+
 span#form_status {
     font-size: 80%;
 }