objectify the event edit javascript to avoid name clashes
authorMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 13 Feb 2009 18:24:37 +0000 (13:24 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 13 Feb 2009 18:24:37 +0000 (13:24 -0500)
kronolith/lib/Driver.php
kronolith/templates/edit/edit.inc
kronolith/templates/edit/edit_timespan.inc
kronolith/templates/edit/javascript.inc

index e4d78ec..1ea063b 100644 (file)
@@ -1995,7 +1995,7 @@ class Kronolith_Event {
             for ($i = $hour_min; $i < $hour_max; ++$i) {
                 $options[$i] = $i;
             }
-            $attributes = ' onchange="document.eventform.whole_day.checked = false; updateEndDate();"';
+            $attributes = ' onchange="document.eventform.whole_day.checked = false; KronolithEventForm.updateEndDate();"';
             $label = _("Start Hour");
             break;
 
@@ -2005,7 +2005,7 @@ class Kronolith_Event {
                 $min = sprintf('%02d', $i * 5);
                 $options[$min] = $min;
             }
-            $attributes = ' onchange="document.eventform.whole_day.checked = false; updateEndDate();"';
+            $attributes = ' onchange="document.eventform.whole_day.checked = false; KronolithEventForm.updateEndDate();"';
             $label = _("Start Minute");
             break;
 
@@ -2042,7 +2042,7 @@ class Kronolith_Event {
             for ($i = $hour_min; $i < $hour_max; ++$i) {
                 $options[$i] = $i;
             }
-            $attributes = ' onchange="updateDuration(); document.eventform.end_or_dur[0].checked = true"';
+            $attributes = ' onchange="KronolithEventForm.updateDuration(); document.eventform.end_or_dur[0].checked = true"';
             $label = _("End Hour");
             break;
 
@@ -2053,7 +2053,7 @@ class Kronolith_Event {
                 $min = sprintf('%02d', $i * 5);
                 $options[$min] = $min;
             }
-            $attributes = ' onchange="updateDuration(); document.eventform.end_or_dur[0].checked = true"';
+            $attributes = ' onchange="KronolithEventForm.updateDuration(); document.eventform.end_or_dur[0].checked = true"';
             $label = _("End Minute");
             break;
 
@@ -2146,24 +2146,24 @@ class Kronolith_Event {
         case 'start[year]':
         case 'start[day]':
         case 'start':
-            return 'updateWday(\'start_wday\'); document.eventform.whole_day.checked = false; updateEndDate();';
+            return 'KronolithEventForm.updateWday(\'start_wday\'); document.eventform.whole_day.checked = false; KronolithEventForm.updateEndDate();';
 
         case 'end[month]':
         case 'end[year]':
         case 'end[day]':
         case 'end':
-            return 'updateWday(\'end_wday\'); updateDuration(); document.eventform.end_or_dur[0].checked = true;';
+            return 'KronolithEventForm.updateWday(\'end_wday\'); updateDuration(); document.eventform.end_or_dur[0].checked = true;';
 
         case 'recur_enddate[month]':
         case 'recur_enddate[year]':
         case 'recur_enddate[day]':
         case 'recur_enddate':
-            return 'updateWday(\'recur_end_wday\'); document.eventform.recur_enddate_type[1].checked = true;';
+            return 'KronolithEventForm.updateWday(\'recur_end_wday\'); document.eventform.recur_enddate_type[1].checked = true;';
 
         case 'dur_day':
         case 'dur_hour':
         case 'dur_min':
-            return 'document.eventform.whole_day.checked = false; updateEndDate(); document.eventform.end_or_dur[1].checked = true;';
+            return 'document.eventform.whole_day.checked = false; KronolithEventForm.updateEndDate(); document.eventform.end_or_dur[1].checked = true;';
         }
     }
 
index 5c37d5d..80132e5 100644 (file)
@@ -33,8 +33,8 @@
  <td></td>
  <td colspan="4" class="warning">
   <?php echo _("This is a recurring event. Edit the current event only, this occurrence<br />and all future occurences, all occurences, or save this event as new?") ?><br /><br />
-  <input type="radio" name="edit_recur" value="current" id="edit_current" onclick="setStartDate($F('recur_ex'))" /> <?php echo Horde::label('edit_current', _("Current")) ?>
-  <input type="radio" name="edit_recur" value="future" id="edit_future" onclick="setStartDate($F('recur_ex'))" /> <?php echo Horde::label('edit_future', _("Future")) ?>
+  <input type="radio" name="edit_recur" value="current" id="edit_current" onclick="KronolithEventForm.setStartDate($F('recur_ex'))" /> <?php echo Horde::label('edit_current', _("Current")) ?>
+  <input type="radio" name="edit_recur" value="future" id="edit_future" onclick="KronolithEventForm.setStartDate($F('recur_ex'))" /> <?php echo Horde::label('edit_future', _("Future")) ?>
   <input type="radio" name="edit_recur" value="all" id="edit_all" checked="checked" /> <?php echo Horde::label('edit_all', _("All")) ?>
   <input type="radio" name="edit_recur" value="copy" id="edit_copy" /> <?php echo Horde::label('edit_copy', _("Save As New")) ?>
   <input type="hidden" name="recur_ex" id="recur_ex" value="<?php echo Util::getFormData('datetime') ?>" />
@@ -48,7 +48,7 @@
  <td colspan="4">
   <?php echo implode("\n", $buttons) ?>
   <?php echo Horde::link(htmlspecialchars($cancelurl), '', 'button') . _("Cancel") . '</a>' ?>
-  <input type="button" name="resetButton" class="button" value="<?php echo _("Reset to Defaults") ?>" onclick="document.eventform.reset(); updateWday('start_wday'); updateWday('end_wday');" />
+  <input type="button" name="resetButton" class="button" value="<?php echo _("Reset to Defaults") ?>" onclick="document.eventform.reset(); KronolithEventForm.updateWday('start_wday'); KronolithEventForm.updateWday('end_wday');" />
  </td>
 </tr>
 
@@ -144,7 +144,7 @@ if ($event->alarm) {
 }
 ?>
 <tr>
- <td colspan="5" class="control toggle" onclick="toggleSection('alarm')">
+ <td colspan="5" class="control toggle" onclick="KronolithEventForm.toggleSection('alarm')">
   <?php echo Horde::img('tree/blank.png', '', array('id' => 'toggle_alarm'), $GLOBALS['registry']->getImageDir('horde')) . ' <strong>' . Horde::label('alarm', _("_Alarm")) ?></strong>
   <span class="extra" id="extra_alarm"><?php if ($alarm_set) printf(_("%d %s before the event starts"), $alarm_value, $alarm_unit_title); ?></span>
 </td>
@@ -179,8 +179,8 @@ if ($event->alarm) {
   <strong><?php echo _("Notification") ?></strong>
  </td>
  <td valign="top">
-  <input id="nooverwrite" name="alarm_change_method" type="radio" class="checkbox" value="0"<?php if (empty($event->methods)) echo ' checked="checked"' ?> onclick="toggleAlarmMethods()" /><br />
-  <input id="yesoverwrite" name="alarm_change_method" type="radio" class="checkbox" value="1"<?php if (!empty($event->methods)) echo ' checked="checked"' ?> onclick="toggleAlarmMethods()" />
+  <input id="nooverwrite" name="alarm_change_method" type="radio" class="checkbox" value="0"<?php if (empty($event->methods)) echo ' checked="checked"' ?> onclick="KronolithEventForm.toggleAlarmMethods()" /><br />
+  <input id="yesoverwrite" name="alarm_change_method" type="radio" class="checkbox" value="1"<?php if (!empty($event->methods)) echo ' checked="checked"' ?> onclick="KronolithEventForm.toggleAlarmMethods()" />
  </td>
  <td>&nbsp;</td>
  <td valign="top" colspan="2">
@@ -210,7 +210,7 @@ if ($event->alarm) {
 
 <!-- description -->
 <tr>
- <td colspan="5" class="control toggle" onclick="toggleSection('description')">
+ <td colspan="5" class="control toggle" onclick="KronolithEventForm.toggleSection('description')">
   <?php echo Horde::img('tree/blank.png', '', array('id' => 'toggle_description'), $GLOBALS['registry']->getImageDir('horde')) . ' <strong>' . Horde::label('description', _("Descri_ption")) ?></strong>
   <span class="extra" id="extra_description"><?php echo htmlspecialchars(substr(str_replace(array("\r", "\n"), '', $event->getDescription()), 0, 80)) ?></span>
 </td>
@@ -223,7 +223,7 @@ if ($event->alarm) {
 
 <!-- attendees -->
 <tr>
- <td colspan="5" class="control toggle" onclick="toggleSection('attendees')">
+ <td colspan="5" class="control toggle" onclick="KronolithEventForm.toggleSection('attendees')">
   <?php echo Horde::img('tree/blank.png', '', array('id' => 'toggle_attendees'), $GLOBALS['registry']->getImageDir('horde')) . ' <strong>' . _("Attendees") ?></strong>
   <span class="extra"><?php echo htmlspecialchars(Kronolith::attendeeList()) ?></span>
  </td>
@@ -240,7 +240,7 @@ if ($event->alarm) {
 
 <!-- recurrence -->
 <tr>
- <td colspan="5" class="control toggle" onclick="toggleSection('recurrence')">
+ <td colspan="5" class="control toggle" onclick="KronolithEventForm.toggleSection('recurrence')">
   <?php echo Horde::img('tree/blank.png', '', array('id' => 'toggle_recurrence'), $GLOBALS['registry']->getImageDir('horde')) . ' <strong>' . _("Recurrence") ?></strong>
   <span class="extra" id="extra_recurrence"><?php echo $event->getRecurName(); if ($event->recurs()) echo $event->recurrence->hasRecurEnd() ? sprintf(_(" until %s"), $event->recurrence->recurEnd->strftime($GLOBALS['prefs']->getValue('date_format')) . ($this->event->recurrence->recurEnd->hour == 23 && $this->event->recurrence->recurEnd->min == 59 ? '' : ' ' . $this->event->recurrence->recurEnd->format($GLOBALS['prefs']->getValue('twentyFour') ? 'G:i' : 'g:ia'))) : ($event->recurrence->getRecurCount() ? sprintf(_(", %d times"), $event->recurrence->getRecurCount()) : _(" without end")) ?></span>
  </td>
@@ -252,57 +252,57 @@ if ($event->alarm) {
   <table cellspacing="0" width="100%">
    <tr>
     <td class="nowrap">
-     <input id="recurnone" type="radio" class="checkbox" name="recur" onclick="clearFields(0);" value="<?php echo Horde_Date_Recurrence::RECUR_NONE ?>"<?php if (!$event->recurs()) echo ' checked="checked"' ?> /><label for="recurnone"> <?php echo _("No recurrence") ?></label>
+     <input id="recurnone" type="radio" class="checkbox" name="recur" onclick="KronolithEventForm.clearFields(0);" value="<?php echo Horde_Date_Recurrence::RECUR_NONE ?>"<?php if (!$event->recurs()) echo ' checked="checked"' ?> /><label for="recurnone"> <?php echo _("No recurrence") ?></label>
     </td>
    </tr>
    <tr>
     <td class="nowrap">
-     <input id="recurdaily" type="radio" class="checkbox" name="recur" onclick="setInterval('recur_daily_interval');" value="<?php echo Horde_Date_Recurrence::RECUR_DAILY ?>"<?php if ($event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_DAILY)) echo ' checked="checked"' ?> /><label for="recurdaily"> <?php echo _("Daily: Recurs every") ?>&nbsp;</label>
-     <input type="text" id="recur_daily_interval" name="recur_daily_interval" size="2" onkeypress="setRecur(1);" onchange="setRecur(1);" value="<?php echo $event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_DAILY) ? $event->recurrence->getRecurInterval() : '' ?>" />&nbsp;<?php echo Horde::label('recur_daily_interval', _("day(s)")) ?>
+     <input id="recurdaily" type="radio" class="checkbox" name="recur" onclick="KronolithEventForm.setInterval('recur_daily_interval');" value="<?php echo Horde_Date_Recurrence::RECUR_DAILY ?>"<?php if ($event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_DAILY)) echo ' checked="checked"' ?> /><label for="recurdaily"> <?php echo _("Daily: Recurs every") ?>&nbsp;</label>
+     <input type="text" id="recur_daily_interval" name="recur_daily_interval" size="2" onkeypress="KronolithEventForm.setRecur(1);" onchange="KronolithEventForm.setRecur(1);" value="<?php echo $event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_DAILY) ? $event->recurrence->getRecurInterval() : '' ?>" />&nbsp;<?php echo Horde::label('recur_daily_interval', _("day(s)")) ?>
     </td>
    </tr>
    <tr>
     <td class="nowrap">
-     <input id="recurweekly" type="radio" class="checkbox" name="recur" onclick="setInterval('recur_weekly_interval');" value="<?php echo Horde_Date_Recurrence::RECUR_WEEKLY ?>"<?php if ($event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_WEEKLY)) echo ' checked="checked"' ?> /><label for="recurweekly"> <?php echo _("Weekly: Recurs every") ?>&nbsp;</label>
-     <input type="text" id="recur_weekly_interval" name="recur_weekly_interval" size="2" onkeypress="setRecur(2);" onchange="setRecur(2);" value="<?php echo $event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_WEEKLY) ? $event->recurrence->getRecurInterval() : '' ?>" />&nbsp;
+     <input id="recurweekly" type="radio" class="checkbox" name="recur" onclick="KronolithEventForm.setInterval('recur_weekly_interval');" value="<?php echo Horde_Date_Recurrence::RECUR_WEEKLY ?>"<?php if ($event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_WEEKLY)) echo ' checked="checked"' ?> /><label for="recurweekly"> <?php echo _("Weekly: Recurs every") ?>&nbsp;</label>
+     <input type="text" id="recur_weekly_interval" name="recur_weekly_interval" size="2" onkeypress="KronolithEventForm.setRecur(2);" onchange="KronolithEventForm.setRecur(2);" value="<?php echo $event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_WEEKLY) ? $event->recurrence->getRecurInterval() : '' ?>" />&nbsp;
      <?php echo Horde::label('recur_weekly_interval', _("week(s) on:")) ?><br />
-     <label for="mo"><?php echo _("Mo") ?></label><input id="mo" type="checkbox" class="checkbox" name="weekly[]" onclick="setInterval('recur_weekly_interval');setRecur(2);" value="<?php echo Horde_Date::MASK_MONDAY ?>"<?php if ($event->recurs() && $event->recurrence->recurOnDay(Horde_Date::MASK_MONDAY)) echo ' checked="checked"' ?> />&nbsp;
-     <label for="tu"><?php echo _("Tu") ?></label><input id="tu" type="checkbox" class="checkbox" name="weekly[]" onclick="setInterval('recur_weekly_interval');setRecur(2);" value="<?php echo Horde_Date::MASK_TUESDAY ?>"<?php if ($event->recurs() && $event->recurrence->recurOnDay(Horde_Date::MASK_TUESDAY)) echo ' checked="checked"' ?> />&nbsp;
-     <label for="we"><?php echo _("We") ?></label><input id="we" type="checkbox" class="checkbox" name="weekly[]" onclick="setInterval('recur_weekly_interval');setRecur(2);" value="<?php echo Horde_Date::MASK_WEDNESDAY ?>"<?php if ($event->recurs() && $event->recurrence->recurOnDay(Horde_Date::MASK_WEDNESDAY)) echo ' checked="checked"' ?> />&nbsp;
-     <label for="th"><?php echo _("Th") ?></label><input id="th" type="checkbox" class="checkbox" name="weekly[]" onclick="setInterval('recur_weekly_interval');setRecur(2);" value="<?php echo Horde_Date::MASK_THURSDAY ?>"<?php if ($event->recurs() && $event->recurrence->recurOnDay(Horde_Date::MASK_THURSDAY)) echo ' checked="checked"' ?> />&nbsp;
-     <label for="fr"><?php echo _("Fr") ?></label><input id="fr" type="checkbox" class="checkbox" name="weekly[]" onclick="setInterval('recur_weekly_interval');setRecur(2);" value="<?php echo Horde_Date::MASK_FRIDAY ?>"<?php if ($event->recurs() && $event->recurrence->recurOnDay(Horde_Date::MASK_FRIDAY)) echo ' checked="checked"' ?> />&nbsp;
-     <label for="sa"><?php echo _("Sa") ?></label><input id="sa" type="checkbox" class="checkbox" name="weekly[]" onclick="setInterval('recur_weekly_interval');setRecur(2);" value="<?php echo Horde_Date::MASK_SATURDAY ?>"<?php if ($event->recurs() && $event->recurrence->recurOnDay(Horde_Date::MASK_SATURDAY)) echo ' checked="checked"' ?> />&nbsp;
-     <label for="su"><?php echo _("Su") ?></label><input id="su" type="checkbox" class="checkbox" name="weekly[]" onclick="setInterval('recur_weekly_interval');setRecur(2);" value="<?php echo Horde_Date::MASK_SUNDAY ?>"<?php if ($event->recurs() && $event->recurrence->recurOnDay(Horde_Date::MASK_SUNDAY)) echo ' checked="checked"' ?> />&nbsp;
+     <label for="mo"><?php echo _("Mo") ?></label><input id="mo" type="checkbox" class="checkbox" name="weekly[]" onclick="KronolithEventForm.setInterval('recur_weekly_interval');KronolithEventForm.setRecur(2);" value="<?php echo Horde_Date::MASK_MONDAY ?>"<?php if ($event->recurs() && $event->recurrence->recurOnDay(Horde_Date::MASK_MONDAY)) echo ' checked="checked"' ?> />&nbsp;
+     <label for="tu"><?php echo _("Tu") ?></label><input id="tu" type="checkbox" class="checkbox" name="weekly[]" onclick="KronolithEventForm.setInterval('recur_weekly_interval');KronolithEventForm.setRecur(2);" value="<?php echo Horde_Date::MASK_TUESDAY ?>"<?php if ($event->recurs() && $event->recurrence->recurOnDay(Horde_Date::MASK_TUESDAY)) echo ' checked="checked"' ?> />&nbsp;
+     <label for="we"><?php echo _("We") ?></label><input id="we" type="checkbox" class="checkbox" name="weekly[]" onclick="KronolithEventForm.setInterval('recur_weekly_interval');KronolithEventForm.setRecur(2);" value="<?php echo Horde_Date::MASK_WEDNESDAY ?>"<?php if ($event->recurs() && $event->recurrence->recurOnDay(Horde_Date::MASK_WEDNESDAY)) echo ' checked="checked"' ?> />&nbsp;
+     <label for="th"><?php echo _("Th") ?></label><input id="th" type="checkbox" class="checkbox" name="weekly[]" onclick="KronolithEventForm.setInterval('recur_weekly_interval');KronolithEventForm.setRecur(2);" value="<?php echo Horde_Date::MASK_THURSDAY ?>"<?php if ($event->recurs() && $event->recurrence->recurOnDay(Horde_Date::MASK_THURSDAY)) echo ' checked="checked"' ?> />&nbsp;
+     <label for="fr"><?php echo _("Fr") ?></label><input id="fr" type="checkbox" class="checkbox" name="weekly[]" onclick="KronolithEventForm.setInterval('recur_weekly_interval');KronolithEventForm.setRecur(2);" value="<?php echo Horde_Date::MASK_FRIDAY ?>"<?php if ($event->recurs() && $event->recurrence->recurOnDay(Horde_Date::MASK_FRIDAY)) echo ' checked="checked"' ?> />&nbsp;
+     <label for="sa"><?php echo _("Sa") ?></label><input id="sa" type="checkbox" class="checkbox" name="weekly[]" onclick="KronolithEventForm.setInterval('recur_weekly_interval');KronolithEventForm.setRecur(2);" value="<?php echo Horde_Date::MASK_SATURDAY ?>"<?php if ($event->recurs() && $event->recurrence->recurOnDay(Horde_Date::MASK_SATURDAY)) echo ' checked="checked"' ?> />&nbsp;
+     <label for="su"><?php echo _("Su") ?></label><input id="su" type="checkbox" class="checkbox" name="weekly[]" onclick="KronolithEventForm.setInterval('recur_weekly_interval');KronolithEventForm.setRecur(2);" value="<?php echo Horde_Date::MASK_SUNDAY ?>"<?php if ($event->recurs() && $event->recurrence->recurOnDay(Horde_Date::MASK_SUNDAY)) echo ' checked="checked"' ?> />&nbsp;
     </td>
    </tr>
    <tr>
     <td class="nowrap">
-     <input id="recurmonthday" type="radio" class="checkbox" name="recur" onclick="setInterval('recur_day_of_month_interval');" value="<?php echo Horde_Date_Recurrence::RECUR_MONTHLY_DATE ?>"<?php if ($event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_MONTHLY_DATE)) echo ' checked="checked"' ?> /><label for="recurmonthday"> <?php echo _("Monthly: Recurs every") ?>&nbsp;</label>
-     <input type="text" id="recur_day_of_month_interval" name="recur_day_of_month_interval" size="2" onkeypress="setRecur(3);" onchange="setRecur(3);" value="<?php echo $event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_MONTHLY_DATE) ? $event->recurrence->getRecurInterval() : '' ?>" />&nbsp;<?php echo Horde::label('recur_day_of_month_interval', _("month(s)") . ' ' . _("on the same date")) ?>
+     <input id="recurmonthday" type="radio" class="checkbox" name="recur" onclick="KronolithEventForm.setInterval('recur_day_of_month_interval');" value="<?php echo Horde_Date_Recurrence::RECUR_MONTHLY_DATE ?>"<?php if ($event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_MONTHLY_DATE)) echo ' checked="checked"' ?> /><label for="recurmonthday"> <?php echo _("Monthly: Recurs every") ?>&nbsp;</label>
+     <input type="text" id="recur_day_of_month_interval" name="recur_day_of_month_interval" size="2" onkeypress="KronolithEventForm.setRecur(3);" onchange="KronolithEventForm.setRecur(3);" value="<?php echo $event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_MONTHLY_DATE) ? $event->recurrence->getRecurInterval() : '' ?>" />&nbsp;<?php echo Horde::label('recur_day_of_month_interval', _("month(s)") . ' ' . _("on the same date")) ?>
     </td>
    </tr>
    <tr>
     <td class="nowrap">
-     <input id="recurmonthweek" type="radio" class="checkbox" name="recur" onclick="setInterval('recur_week_of_month_interval');" value="<?php echo Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY ?>"<?php if ($event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY)) echo ' checked="checked"' ?> /><label for="recurmonthweek"> <?php echo _("Monthly: Recurs every") ?>&nbsp;</label>
-     <input type="text" id="recur_week_of_month_interval" name="recur_week_of_month_interval" size="2" onkeypress="setRecur(4);" onchange="setRecur(4);" value="<?php echo $event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY) ? $event->recurrence->getRecurInterval() : '' ?>" />&nbsp;<?php echo Horde::label('recur_week_of_month_interval', _("month(s)") . ' ' . _("on the same weekday")) ?>
+     <input id="recurmonthweek" type="radio" class="checkbox" name="recur" onclick="KronolithEventForm.setInterval('recur_week_of_month_interval');" value="<?php echo Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY ?>"<?php if ($event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY)) echo ' checked="checked"' ?> /><label for="recurmonthweek"> <?php echo _("Monthly: Recurs every") ?>&nbsp;</label>
+     <input type="text" id="recur_week_of_month_interval" name="recur_week_of_month_interval" size="2" onkeypress="KronolithEventForm.setRecur(4);" onchange="KronolithEventForm.setRecur(4);" value="<?php echo $event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY) ? $event->recurrence->getRecurInterval() : '' ?>" />&nbsp;<?php echo Horde::label('recur_week_of_month_interval', _("month(s)") . ' ' . _("on the same weekday")) ?>
     </td>
    </tr>
    <tr>
     <td class="nowrap">
-     <input id="recuryear" type="radio" class="checkbox" name="recur" onclick="setInterval('recur_yearly_interval');" value="<?php echo Horde_Date_Recurrence::RECUR_YEARLY_DATE ?>"<?php if ($event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_YEARLY_DATE)) echo ' checked="checked"' ?> /><label for="recuryear"> <?php echo _("Yearly: Recurs every") ?>&nbsp;</label>
-     <input type="text" id="recur_yearly_interval" name="recur_yearly_interval" size="2" onkeypress="setRecur(5);" onchange="setRecur(5);" value="<?php echo $event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_YEARLY_DATE) ? $event->recurrence->getRecurInterval() : '' ?>" />&nbsp;<?php echo Horde::label('recur_yearly_interval', _("year(s) on the same date")) ?>
+     <input id="recuryear" type="radio" class="checkbox" name="recur" onclick="KronolithEventForm.setInterval('recur_yearly_interval');" value="<?php echo Horde_Date_Recurrence::RECUR_YEARLY_DATE ?>"<?php if ($event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_YEARLY_DATE)) echo ' checked="checked"' ?> /><label for="recuryear"> <?php echo _("Yearly: Recurs every") ?>&nbsp;</label>
+     <input type="text" id="recur_yearly_interval" name="recur_yearly_interval" size="2" onkeypress="KronolithEventForm.setRecur(5);" onchange="KronolithEventForm.setRecur(5);" value="<?php echo $event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_YEARLY_DATE) ? $event->recurrence->getRecurInterval() : '' ?>" />&nbsp;<?php echo Horde::label('recur_yearly_interval', _("year(s) on the same date")) ?>
     </td>
    </tr>
    <tr>
     <td class="nowrap">
-     <input id="recuryearday" type="radio" class="checkbox" name="recur" onclick="setInterval('recur_yearly_day_interval');" value="<?php echo Horde_Date_Recurrence::RECUR_YEARLY_DAY ?>"<?php if ($event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_YEARLY_DAY)) echo ' checked="checked"' ?> /><label for="recuryearday"> <?php echo _("Yearly: Recurs every") ?>&nbsp;</label>
-     <input type="text" id="recur_yearly_day_interval" name="recur_yearly_day_interval" size="2" onkeypress="setRecur(6);" onchange="setRecur(6);" value="<?php echo $event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_YEARLY_DAY) ? $event->recurrence->getRecurInterval() : '' ?>" />&nbsp;<?php echo Horde::label('recur_yearly_day_interval', _("year(s) on the same day of the year")) ?>
+     <input id="recuryearday" type="radio" class="checkbox" name="recur" onclick="KronolithEventForm.setInterval('recur_yearly_day_interval');" value="<?php echo Horde_Date_Recurrence::RECUR_YEARLY_DAY ?>"<?php if ($event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_YEARLY_DAY)) echo ' checked="checked"' ?> /><label for="recuryearday"> <?php echo _("Yearly: Recurs every") ?>&nbsp;</label>
+     <input type="text" id="recur_yearly_day_interval" name="recur_yearly_day_interval" size="2" onkeypress="KronolithEventForm.KronolithEventForm.setRecur(6);" onchange="KronolithEventForm.setRecur(6);" value="<?php echo $event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_YEARLY_DAY) ? $event->recurrence->getRecurInterval() : '' ?>" />&nbsp;<?php echo Horde::label('recur_yearly_day_interval', _("year(s) on the same day of the year")) ?>
     </td>
    </tr>
    <tr>
     <td class="nowrap">
-     <input id="recuryearweekday" type="radio" class="checkbox" name="recur" onclick="setInterval('recur_yearly_weekday_interval');" value="<?php echo Horde_Date_Recurrence::RECUR_YEARLY_WEEKDAY ?>"<?php if ($event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_YEARLY_WEEKDAY)) echo ' checked="checked"' ?> /><label for="recuryearweekday"> <?php echo _("Yearly: Recurs every") ?>&nbsp;</label>
-     <input type="text" id="recur_yearly_weekday_interval" name="recur_yearly_weekday_interval" size="2" onkeypress="setRecur(7);" onchange="setRecur(7);" value="<?php echo $event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_YEARLY_WEEKDAY) ? $event->recurrence->getRecurInterval() : '' ?>" />&nbsp;<?php echo Horde::label('recur_yearly_weekday_interval', _("year(s) on the same weekday and month of the year")) ?>
+     <input id="recuryearweekday" type="radio" class="checkbox" name="recur" onclick="KronolithEventForm.setInterval('recur_yearly_weekday_interval');" value="<?php echo Horde_Date_Recurrence::RECUR_YEARLY_WEEKDAY ?>"<?php if ($event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_YEARLY_WEEKDAY)) echo ' checked="checked"' ?> /><label for="recuryearweekday"> <?php echo _("Yearly: Recurs every") ?>&nbsp;</label>
+     <input type="text" id="recur_yearly_weekday_interval" name="recur_yearly_weekday_interval" size="2" onkeypress="KronolithEventForm.setRecur(7);" onchange="KronolithEventForm.setRecur(7);" value="<?php echo $event->recurs() && $event->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_YEARLY_WEEKDAY) ? $event->recurrence->getRecurInterval() : '' ?>" />&nbsp;<?php echo Horde::label('recur_yearly_weekday_interval', _("year(s) on the same weekday and month of the year")) ?>
     </td>
    </tr>
   </table>
@@ -328,7 +328,7 @@ if ($event->alarm) {
   <?php echo $event->html('recur_enddate[year]') ?> - <?php echo $event->html('recur_enddate[month]') ?> - <?php echo $event->html('recur_enddate[day]') ?>
 <?php if ($GLOBALS['browser']->hasFeature('dom')): ?>
   <span id="recur_end_wday"></span>
-  <script type="text/javascript">updateWday('recur_end_wday');</script>
+  <script type="text/javascript">KronolithEventForm.updateWday('recur_end_wday');</script>
  </td>
  <td>
 <?php
@@ -365,7 +365,7 @@ endif;
 
 <!-- tags  -->
 <tr>
-<td colspan="5" class="control toggle" onclick="toggleSection('tags')">
+<td colspan="5" class="control toggle" onclick="KronolithEventForm.toggleSection('tags')">
  <?php echo Horde::img('tree/blank.png', '', array('id' => 'toggle_tags'), $GLOBALS['registry']->getImageDir('horde')) . ' <strong>' . _("Tags") ?></strong>
   <span class="extra" id="extra_tags"><?php echo (!empty($tags) ? htmlspecialchars($tags) : '');?></span>
   </td>
@@ -399,7 +399,7 @@ endif;
  <td colspan="4">
   <?php echo implode("\n", $buttons) ?>
   <?php echo Horde::link(htmlspecialchars($cancelurl), '', 'button') . _("Cancel") . '</a>' ?>
-  <input type="button" name="resetButton" class="button" value="<?php echo _("Reset to Defaults") ?>" onclick="document.eventform.reset(); updateWday('start_wday'); updateWday('end_wday');" />
+  <input type="button" name="resetButton" class="button" value="<?php echo _("Reset to Defaults") ?>" onclick="document.eventform.reset(); KronolithEventForm.updateWday('start_wday'); KronolithEventForm.updateWday('end_wday');" />
   </td>
  </tr>
 </table>
index 9926617..cd27f7a 100644 (file)
@@ -20,7 +20,7 @@
 <?php if ($GLOBALS['browser']->hasFeature('dom')): ?>
   <span id="start_wday"></span>
   <script type="text/javascript">
-   updateWday('start_wday');
+  KronolithEventForm.updateWday('start_wday');
   </script>
  </td>
  <td>
@@ -46,8 +46,8 @@
           $pm = ' checked="checked"';
       }
   ?>
-  <input id="am" type="radio" class="checkbox" name="am_pm" value="AM"<?php echo $am ?> onclick="$('allday').checked=false;updateEndDate();" /><label for="am" onclick="$('allday').checked=false;updateEndDate();">AM</label>
-  <input id="pm" type="radio" class="checkbox" name="am_pm" value="PM"<?php echo $pm ?> onclick="$('allday').checked=false;updateEndDate();" /><label for="pm" onclick="$('allday').checked=false;updateEndDate();">PM</label>
+  <input id="am" type="radio" class="checkbox" name="am_pm" value="AM"<?php echo $am ?> onclick="$('allday').checked=false;KronolithEventForm.updateEndDate();" /><label for="am" onclick="$('allday').checked=false;KronolithEventForm.updateEndDate();">AM</label>
+  <input id="pm" type="radio" class="checkbox" name="am_pm" value="PM"<?php echo $pm ?> onclick="$('allday').checked=false;KronolithEventForm.updateEndDate();" /><label for="pm" onclick="$('allday').checked=false;KronolithEventForm.updateEndDate();">PM</label>
   <?php } ?>
  </td>
 </tr>
@@ -70,7 +70,7 @@
 <?php if ($GLOBALS['browser']->hasFeature('dom')): ?>
   <span id="end_wday"></span>
   <script type="text/javascript">
-   updateWday('end_wday');
+  KronolithEventForm.updateWday('end_wday');
   </script>
   </td>
   <td rowspan="2" valign="top">
@@ -101,8 +101,8 @@ endif;
           $pm = ' checked="checked"';
       }
   ?>
-  <input id="eam" type="radio" class="checkbox" name="end_am_pm" value="AM"<?php echo $am ?> onclick="$('end').checked=true;updateDuration()" /><label for="eam" onclick="$('end').checked=true;updateDuration()">AM</label>
-  <input id="epm" type="radio" class="checkbox" name="end_am_pm" value="PM"<?php echo $pm ?> onclick="$('end').checked=true;updateDuration()" /><label for="epm" onclick="$('end').checked=true;updateDuration()">PM</label>
+  <input id="eam" type="radio" class="checkbox" name="end_am_pm" value="AM"<?php echo $am ?> onclick="$('end').checked=true;KronolithEventForm.updateDuration()" /><label for="eam" onclick="$('end').checked=true;KronolithEventForm.updateDuration()">AM</label>
+  <input id="epm" type="radio" class="checkbox" name="end_am_pm" value="PM"<?php echo $pm ?> onclick="$('end').checked=true;KronolithEventForm.updateDuration()" /><label for="epm" onclick="$('end').checked=true;KronolithEventForm.updateDuration()">PM</label>
   <?php } ?>
  </td>
 </tr>
@@ -115,7 +115,7 @@ endif;
  </td>
  <td>&nbsp;</td>
  <td valign="top">
-  <input id="allday" name="whole_day" type="checkbox" class="checkbox" value="1" onclick="setWholeDay(this.value); updateEndDate(); $('duration').checked = true"<?php $dur = $event->getDuration(); if ($dur->wholeDay) echo ' checked="checked"' ?> />
+  <input id="allday" name="whole_day" type="checkbox" class="checkbox" value="1" onclick="KronolithEventForm.setWholeDay(this.value); KronolithEventForm.updateEndDate(); $('duration').checked = true"<?php $dur = $event->getDuration(); if ($dur->wholeDay) echo ' checked="checked"' ?> />
   <?php echo Horde::label('allday', _("All day")) ?><br />
   <?php printf(_("%s Day(s) %s Hour(s) %s Minutes"), $event->html('dur_day'), $event->html('dur_hour'), $event->html('dur_min')) ?>
 <?php if ($GLOBALS['browser']->hasFeature('dom')): ?>
index 58d1209..a7c3100 100644 (file)
@@ -1,28 +1,28 @@
 <script type="text/javascript">
 
 <?php if (!Util::nonInputVar('issearch')): ?>
-
-function setInterval(field)
+KronolithEventForm = new Object();
+KronolithEventForm.setInterval = function(field)
 {
     elt = document.eventform[field];
     if (elt.value == "") {
         elt.value = 1;
     }
 
-    if (field == 'recur_daily_interval') clearFields(1);
-    else if (field == 'recur_weekly_interval') clearFields(2);
-    else if (field == 'recur_day_of_month_interval') clearFields(3);
-    else if (field == 'recur_week_of_month_interval') clearFields(4);
-    else if (field == 'recur_yearly_interval') clearFields(5);
+    if (field == 'recur_daily_interval') KronolithEventForm.clearFields(1);
+    else if (field == 'recur_weekly_interval') KronolithEventForm.clearFields(2);
+    else if (field == 'recur_day_of_month_interval') KronolithEventForm.clearFields(3);
+    else if (field == 'recur_week_of_month_interval') KronolithEventForm.clearFields(4);
+    else if (field == 'recur_yearly_interval') KronolithEventForm.clearFields(5);
 }
 
-function setRecur(index)
+KronolithEventForm.setRecur = function(index)
 {
     document.eventform.recur[index].checked = true;
-    clearFields(index);
+    KronolithEventForm.clearFields(index);
 }
 
-function clearFields(index)
+KronolithEventForm.clearFields = function(index)
 {
     var f = document.eventform;
     if (index != 1) f.recur_daily_interval.value = '';
@@ -41,7 +41,7 @@ function clearFields(index)
 
 <?php endif; ?>
 
-function setWholeDay(wholeDay)
+KronolithEventForm.setWholeDay = function(wholeDay)
 {
     if (wholeDay == 1) {
 <?php if ($GLOBALS['prefs']->getValue('twentyFour')): ?>
@@ -57,7 +57,7 @@ function setWholeDay(wholeDay)
     }
 }
 
-function updateWday(span)
+KronolithEventForm.updateWday = function(span)
 {
 <?php if ($GLOBALS['browser']->hasFeature('dom')): ?>
     wdays = [
@@ -94,7 +94,7 @@ function updateWday(span)
 <?php if (!$GLOBALS['prefs']->getValue('twentyFour')): ?>
 
 // Converts a 12 hour based number to its 24 hour format
-function convertTo24Hour(in_hour, pm_elementName)
+KronolithEventForm.convertTo24Hour = function(in_hour, pm_elementName)
 {
     if ($F(pm_elementName)) {
         if (in_hour != 12) {
@@ -108,13 +108,13 @@ function convertTo24Hour(in_hour, pm_elementName)
 }
 <?php endif; ?>
 
-function updateDuration()
+KronolithEventForm.updateDuration = function()
 {
     var startHour = parseInt($F('start_hour'));
     var endHour = parseInt($F('end_hour'));
 <?php if (!$GLOBALS['prefs']->getValue('twentyFour')): ?>
-    startHour = convertTo24Hour(startHour, 'pm');
-    endHour = convertTo24Hour(endHour, 'epm');
+    startHour = KronolithEventForm.convertTo24Hour(startHour, 'pm');
+    endHour = KronolithEventForm.convertTo24Hour(endHour, 'epm');
 <?php endif; ?>
     var startDate = Date.UTC($F('start_year'),
                              $F('start_month') - 1,
@@ -143,7 +143,7 @@ function updateDuration()
 
             // Recalculate end time.
             var endHour = parseInt($F('end_hour'));
-            endHour = convertTo24Hour(endHour, 'epm');
+            endHour = KronolithEventForm.convertTo24Hour(endHour, 'epm');
             endDate = Date.UTC($F('end_year'),
                                $F('end_month') - 1,
                                $F('end_day'),
@@ -168,16 +168,16 @@ function updateDuration()
     $('dur_min').selectedIndex = durMin;
     $('allday').checked = false;
     if (failed) {
-        updateEndDate();
+       KronolithEventForm.updateEndDate();
     }
 }
 
-function updateEndDate()
+KronolithEventForm.updateEndDate = function()
 {
     var yearDiff = <?php echo date('Y') - 1 ?>;
     var startHour = parseInt($F('start_hour'));
 <?php if (!$GLOBALS['prefs']->getValue('twentyFour')): ?>
-    startHour = convertTo24Hour(startHour, 'pm');
+    startHour = KronolithEventForm.convertTo24Hour(startHour, 'pm');
 <?php endif; ?>
     var startDate = new Date($F('start_year'),
                              $F('start_month') - 1,
@@ -214,10 +214,10 @@ function updateEndDate()
 <?php endif; ?>
     $('end_hour').selectedIndex = endHour;
     $('end_min').selectedIndex = endDate.getMinutes() / 5;
-    updateWday('end_wday');
+    KronolithEventForm.updateWday('end_wday');
 }
 
-function toggleAlarmMethods()
+KronolithEventForm.toggleAlarmMethods = function()
 {
     if ($('nooverwrite').checked) {
         $('notification_options').hide();
@@ -227,7 +227,7 @@ function toggleAlarmMethods()
     }
 }
 
-function setStartDate(date)
+KronolithEventForm.setStartDate = function(date)
 {
     var year = parseInt(date.substr(0, 4));
     var month = parseInt(date.substr(4, 2));
@@ -236,7 +236,7 @@ function setStartDate(date)
     $('start_year').value = year;
     $('start_month').selectedIndex = month - 1;
     $('start_day').selectedIndex = day - 1;
-    updateEndDate();
+    KronolithEventForm.updateEndDate();
 
     // Uncheck recurring weekdays.
     $('mo').checked = false;
@@ -254,7 +254,7 @@ Event.observe(window, 'load', function() {
 });
 <?php endif; ?>
 
-function toggleSection(section)
+KronolithEventForm.toggleSection = function(section)
 {
     var dir = '<?php echo $GLOBALS['registry']->getImageDir() ?>';
     $('section_' + section).toggle();
@@ -273,11 +273,11 @@ function toggleSection(section)
     }
 }
 Event.observe(window, 'load', function() {
-    toggleSection('alarm');
-    toggleSection('description');
-    toggleSection('attendees');
-    toggleSection('recurrence');
-    toggleSection('tags');
+       KronolithEventForm.toggleSection('alarm');
+       KronolithEventForm.toggleSection('description');
+       KronolithEventForm.toggleSection('attendees');
+       KronolithEventForm.toggleSection('recurrence');
+       KronolithEventForm.toggleSection('tags');
 });
 
 </script>