Use a button instead of onchange events to add users/groups.
authorJan Schneider <jan@horde.org>
Wed, 19 May 2010 17:21:36 +0000 (19:21 +0200)
committerJan Schneider <jan@horde.org>
Wed, 19 May 2010 17:28:10 +0000 (19:28 +0200)
kronolith/js/kronolith.js
kronolith/templates/chunks/permissions.inc

index d5cc6b6..d5e16f5 100644 (file)
@@ -3005,13 +3005,11 @@ KronolithCore = {
 
         var tr = elm.up('tr'),
             row = tr.cloneNode(true).store('remove', true),
-            td = row.down('td');
+            td = row.down('td'),
+            clearName = elm.tagName == 'SELECT' ? elm.options[elm.selectedIndex].text: elm.getValue();
 
-        td.down('label').remove();
-        // For some strange prototype/firefox box, an instance .remove()
-        // doesn't work here.
-        Element.remove(td.down(elm.tagName));
-        td.insert((elm.tagName == 'SELECT' ? elm.options[elm.selectedIndex].text: elm.getValue()).escapeHTML())
+        td.update();
+        td.insert(clearName.escapeHTML())
             .insert(new Element('input', { type: 'hidden', name: (what == 'user' ? 'u' : 'g') + '_names[' + value + ']', value: value }));
         row.select('input[type=checkbox]').each(function(input) {
             input.writeAttribute('name', input.name.replace(/\[.*?$/, '[' + value + ']'))
@@ -3746,6 +3744,14 @@ KronolithCore = {
                 }
                 break;
 
+            case 'kronolithCinternalPUAdd':
+            case 'kronolithCinternalPGAdd':
+            case 'kronolithCtasklistsPUAdd':
+            case 'kronolithCtasklistsPGAdd':
+                var info = id.match(/kronolithC(.*)P(.)/);
+                this.insertGroupOrUser(info[1], info[2] == 'U' ? 'user' : 'group');
+                break;
+
             case 'kronolithNavDay':
             case 'kronolithNavWeek':
             case 'kronolithNavMonth':
index 79c7eb1..49b8cba 100644 (file)
@@ -183,10 +183,10 @@ if (count($groups) > 1) {
       </thead>
       <tbody>
       <tr>
-        <td>
+        <td class="nowrap">
           <label for="kronolithC<?php echo $type ?>PUNew" class="hidden"><?php echo _("User to add") ?>:</label>
           <?php if ($auth->hasCapability('list') && ($GLOBALS['conf']['auth']['list_users'] == 'list' || $GLOBALS['conf']['auth']['list_users'] == 'both')): ?>
-          <select id="kronolithC<?php echo $type ?>PUNew" name="u_names[||new]" onchange="KronolithCore.insertGroupOrUser('<?php echo $type ?>', 'user')">
+          <select id="kronolithC<?php echo $type ?>PUNew" name="u_names[||new]">
             <option value=""><?php echo _("Select a user") ?></option>
             <?php foreach ($auth->listUsers() as $user): ?>
             <?php if ($user != Horde_Auth::getAuth()): ?>
@@ -195,8 +195,9 @@ if (count($groups) > 1) {
             <?php endforeach; ?>
           </select>
           <?php else: ?>
-          <input type="text" id="kronolithC<?php echo $type ?>PUNew" name="u_names[||new]" onchange="KronolithCore.insertGroupOrUser('<?php echo $type ?>', 'user')" size="30" />
+          <input type="text" id="kronolithC<?php echo $type ?>PUNew" name="u_names[||new]" size="20" />
           <?php endif; ?>
+          <input type="button" id="kronolithC<?php echo $type ?>PUAdd" value="<?php echo _("Add") ?>" />
         </td>
         <td>
           <input type="checkbox" id="kronolithC<?php echo $type ?>PUshow_new" name="u_show[||new]" />
@@ -234,14 +235,15 @@ if (count($groups) > 1) {
       </thead>
       <tbody>
       <tr>
-        <td>
+        <td class="nowrap">
           <label for="kronolithC<?php echo $type ?>PGNew" class="hidden"><?php echo _("Select a group to add:") ?></label>
-          <select id="kronolithC<?php echo $type ?>PGNew" name="g_names[||new]" onchange="KronolithCore.insertGroupOrUser('<?php echo $type ?>', 'group')">
+          <select id="kronolithC<?php echo $type ?>PGNew" name="g_names[||new]">
             <option value=""><?php echo _("Select a group") ?></option>
             <?php foreach ($groups as $id => $group): ?>
             <option value="<?php echo $id ?>"><?php echo htmlspecialchars($group) ?></option>
             <?php endforeach; ?>
           </select>
+          <input type="button" id="kronolithC<?php echo $type ?>PGAdd" value="<?php echo _("Add") ?>" />
         </td>
         <td>
           <input type="checkbox" id="kronolithC<?php echo $type ?>PGshow_new" name="g_show[||new]" />