<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<?xml-stylesheet type="text/css" href="chrome://global/skin/global.css"?>
<?xml-stylesheet type="text/css" href="chrome://calendar/skin/calendar-event-dialog.css"?>
<?xml-stylesheet type="text/css" href="chrome://calendar/content/calendar-event-dialog.css"?>
<?xml-stylesheet type="text/css" href="chrome://calendar/content/datetimepickers/datetimepickers.css"?>

<!DOCTYPE dialog [
  <!ENTITY % dialogDTD SYSTEM "chrome://calendar/locale/calendar-event-dialog.dtd">
  %dialogDTD;
]>

<dialog id="calendar-event-dialog-recurrence"
        title="&recurrence.title.label;"
        windowtype="Calendar:EventDialog:Recurrence"
        onload="onLoad()"
        ondialogaccept="return onAccept();"
        ondialogcancel="return onCancel();"
        persist="screenX screenY width height"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <!-- Javascript includes -->
  <script type="application/javascript" src="chrome://calendar/content/calendar-event-dialog-recurrence.js"/>
  <script type="application/javascript" src="chrome://calendar/content/calendar-dialog-utils.js"/>
  <script type="application/javascript" src="chrome://calendar/content/calendar-ui-utils.js"/>
  <script type="application/javascript" src="chrome://calendar/content/calUtils.js"/>
  <script type="application/javascript" src="chrome://calendar/content/calendar-statusbar.js"/>

  <!-- recurrence pattern -->
  <groupbox id="recurrence-pattern-groupbox">
    <caption id="recurrence-pattern-caption"
             label="&event.recurrence.pattern.label;"/>
    <grid id="recurrence-pattern-grid">
      <columns id="recurrence-pattern-columns">
        <column id="recurrence-pattern-description-column"/>
        <column id="recurrence-pattern-controls-column"/>
      </columns>
      <rows id="recurrence-pattern-rows">
        <row id="recurrence-pattern-repeat-row" align="center">
          <label value="&event.recurrence.occurs.label;"
                 disable-on-readonly="true"
                 disable-on-occurrence="true"
                 control="period-list"/>
          <menulist id="period-list"
                    oncommand="updateRecurrenceDeck();"
                    disable-on-readonly="true"
                    disable-on-occurrence="true">
            <menupopup id="period-list-menupopup">
              <menuitem id="period-list-day-menuitem"
                        label="&event.recurrence.day.label;"
                        value="0"/>
              <menuitem id="period-list-week-menuitem"
                        label="&event.recurrence.week.label;"
                        value="1"/>
              <menuitem id="period-list-month-menuitem"
                        label="&event.recurrence.month.label;"
                        value="2"/>
              <menuitem id="period-list-year-menuitem"
                        label="&event.recurrence.year.label;"
                        value="3"/>
            </menupopup>
          </menulist>
        </row>
        <row id="recurrence-pattern-period-row" align="top">
          <spacer/>
          <deck id="period-deck" oncommand="updateRecurrenceControls();">

            <!-- Daily -->
            <box id="period-deck-daily-box"
                 orient="vertical"
                 align="top">
              <radiogroup id="daily-group">
                <box id="daily-period-every-box" orient="horizontal" align="center">
                  <radio id="daily-group-every-radio"
                         label="&event.recurrence.pattern.every.label;"
                         disable-on-readonly="true"
                         disable-on-occurrence="true"
                         selected="true"/>
                  <textbox id="daily-days"
                           type="number"
                           value="1"
                           min="1"
                           max="0x7FFF"
                           size="3"
                           onkeyup="updateRecurrenceControls();"
                           disable-on-readonly="true"
                           disable-on-occurrence="true"/>
                  <label id="daily-group-every-units-label"
                         value="&repeat.units.days.both;"
                         disable-on-readonly="true"
                         disable-on-occurrence="true"/>
                  <spacer id="daily-group-spacer" flex="1"/>
                </box>
                <radio id="daily-group-weekday-radio"
                       label="&event.recurrence.pattern.every.weekday.label;"
                       disable-on-readonly="true"
                       disable-on-occurrence="true"/>
              </radiogroup>
            </box>
            <!-- Weekly -->
            <vbox id="period-deck-weekly-box">
              <hbox id="weekly-period-every-box" align="center">
                <label id="weekly-period-every-label"
                       value="&event.recurrence.pattern.weekly.every.label;"
                       disable-on-readonly="true"
                       disable-on-occurrence="true"
                       control="weekly-weeks"/>
                <textbox id="weekly-weeks"
                         type="number"
                         value="1"
                         min="1"
                         max="0x7FFF"
                         size="3"
                         onkeyup="updateRecurrenceControls();"
                         disable-on-readonly="true"
                         disable-on-occurrence="true"/>
                <label id="weekly-period-units-label"
                       value="&repeat.units.weeks.both;"
                       disable-on-readonly="true"
                       disable-on-occurrence="true"/>
              </hbox>
              <hbox align="center">
                <label id="weekly-period-on-label"
                       value="&event.recurrence.on.label;"
                       disable-on-readonly="true"
                       disable-on-occurrence="true"
                       control="daypicker-weekday"/>
                <daypicker-weekday id="daypicker-weekday"
                                   flex="1"
                                   disable-on-readonly="true"
                                   disable-on-occurrence="true"
                                   onselect="updateRecurrenceControls();"/>
              </hbox>
            </vbox>

            <!-- Monthly -->
            <vbox id="period-deck-monthly-box">
              <hbox id="montly-period-every-box" align="center">
                <label id="monthly-period-every-label"
                       value="&event.recurrence.pattern.monthly.every.label;"
                       disable-on-readonly="true"
                       disable-on-occurrence="true"
                       control="monthly-interval"/>
                <textbox id="monthly-interval"
                         type="number"
                         value="1"
                         min="1"
                         max="0x7FFF"
                         size="3"
                         onkeyup="updateRecurrenceControls();"
                         disable-on-readonly="true"
                         disable-on-occurrence="true"/>
                <label id="monthly-period-units-label"
                       value="&repeat.units.months.both;"
                       disable-on-readonly="true"
                       disable-on-occurrence="true"/>
              </hbox>
              <radiogroup id="monthly-group">
                <box id="monthly-period-relative-date-box"
                         orient="horizontal" align="center">
                  <radio id="montly-period-relative-date-radio"
                         selected="true"
                         disable-on-readonly="true"
                         disable-on-occurrence="true"/>
                  <menulist id="monthly-ordinal"
                            disable-on-readonly="true"
                            disable-on-occurrence="true">
                    <menupopup id="montly-ordinal-menupopup">
                      <menuitem id="monthly-ordinal-every-label"
                                label="&event.recurrence.monthly.every.label;"
                                value="0"/>
                      <menuitem id="monthly-ordinal-first-label"
                                label="&event.recurrence.monthly.first.label;"
                                value="1"/>
                      <menuitem id="monthly-ordinal-second-label"
                                label="&event.recurrence.monthly.second.label;"
                                value="2"/>
                      <menuitem id="monthly-ordinal-third-label"
                                label="&event.recurrence.monthly.third.label;"
                                value="3"/>
                      <menuitem id="monthly-ordinal-fourth-label"
                                label="&event.recurrence.monthly.fourth.label;"
                                value="4"/>
                      <menuitem id="monthly-ordinal-fifth-label"
                                label="&event.recurrence.monthly.fifth.label;"
                                value="5"/>
                      <menuitem id="monthly-ordinal-last-label"
                                label="&event.recurrence.monthly.last.label;"
                                value="-1"/>
                    </menupopup>
                  </menulist>
                  <menulist id="monthly-weekday"
                            disable-on-readonly="true"
                            disable-on-occurrence="true">
                    <menupopup id="monthly-weekday-menupopup">
                      <menuitem id="monthly-weekday-1"
                                label="&event.recurrence.pattern.monthly.week.1.label;"
                                value="1"/>
                      <menuitem id="monthly-weekday-2"
                                label="&event.recurrence.pattern.monthly.week.2.label;"
                                value="2"/>
                      <menuitem id="monthly-weekday-3"
                                label="&event.recurrence.pattern.monthly.week.3.label;"
                                value="3"/>
                      <menuitem id="monthly-weekday-4"
                                label="&event.recurrence.pattern.monthly.week.4.label;"
                                value="4"/>
                      <menuitem id="monthly-weekday-5"
                                label="&event.recurrence.pattern.monthly.week.5.label;"
                                value="5"/>
                      <menuitem id="monthly-weekday-6"
                                label="&event.recurrence.pattern.monthly.week.6.label;"
                                value="6"/>
                      <menuitem id="monthly-weekday-7"
                                label="&event.recurrence.pattern.monthly.week.7.label;"
                                value="7"/>
                      <menuitem id="monthly-weekday-dayofmonth"
                                label="&event.recurrence.repeat.dayofmonth.label;"
                                value="-1"/>
                    </menupopup>
                  </menulist>
                </box>
                <box id="monthly-period-specific-date-box"
                     orient="horizontal"
                     align="center">
                  <radio id="montly-period-specific-date-radio"
                         label="&event.recurrence.repeat.recur.label;"
                         disable-on-readonly="true"
                         disable-on-occurrence="true"/>
                  <daypicker-monthday id="monthly-days"
                                      onselect="updateRecurrenceControls();"
                                      disable-on-readonly="true"
                                      disable-on-occurrence="true"/>
                </box>
              </radiogroup>
            </vbox>

            <!-- Yearly -->
            <box id="period-deck-yearly-box"
                 orient="vertical"
                 align="top">
              <hbox id="yearly-period-every-box" align="center">
                <label id="yearly-period-every-label"
                       value="&event.recurrence.every.label;"
                       control="yearly-interval"/>
                <textbox id="yearly-interval"
                         type="number"
                         value="1"
                         min="1"
                         max="0x7FFF"
                         size="3"
                         onkeyup="updateRecurrenceControls();"
                         disable-on-readonly="true"
                         disable-on-occurrence="true"/>
                <label id="yearly-period-units-label" value="&repeat.units.years.both;"/>
              </hbox>
              <radiogroup id="yearly-group">
                <grid id="yearly-period-grid">
                  <columns id="yearly-period-columns">
                    <column id="yearly-period-radio-column"/>
                    <column id="yearly-period-controls-column"/>
                  </columns>
                  <rows id="yearly-period-rows">
                    <row id="yearly-period-absolute-row" align="center">
                      <radio id="yearly-period-absolute-radio"
                             label="&event.recurrence.pattern.yearly.every.month.label;"
                             selected="true"
                             disable-on-readonly="true"
                             disable-on-occurrence="true"/>
                      <box id="yearly-period-absolute-controls"
                           orient="horizontal"
                           align="center">
                        <textbox id="yearly-days"
                                 type="number"
                                 value="1"
                                 min="1"
                                 size="3"
                                 onkeyup="updateRecurrenceControls();"
                                 disable-on-readonly="true"
                                 disable-on-occurrence="true"/>
                        <label id="yearly-period-of-month-label"
                               value="&event.recurrence.pattern.yearly.of.label;"
                               control="yearly-month-ordinal"/>
                        <menulist id="yearly-month-ordinal"
                                  disable-on-readonly="true"
                                  disable-on-occurrence="true">
                          <menupopup id="yearly-month-ordinal-menupopup">
                            <menuitem id="yearly-month-ordinal-1"
                                      label="&event.recurrence.pattern.yearly.month.1.label;"
                                      value="1"/>
                            <menuitem id="yearly-month-ordinal-2"
                                      label="&event.recurrence.pattern.yearly.month.2.label;"
                                      value="2"/>
                            <menuitem id="yearly-month-ordinal-3"
                                      label="&event.recurrence.pattern.yearly.month.3.label;"
                                      value="3"/>
                            <menuitem id="yearly-month-ordinal-4"
                                      label="&event.recurrence.pattern.yearly.month.4.label;"
                                      value="4"/>
                            <menuitem id="yearly-month-ordinal-5"
                                      label="&event.recurrence.pattern.yearly.month.5.label;"
                                      value="5"/>
                            <menuitem id="yearly-month-ordinal-6"
                                      label="&event.recurrence.pattern.yearly.month.6.label;"
                                      value="6"/>
                            <menuitem id="yearly-month-ordinal-7"
                                      label="&event.recurrence.pattern.yearly.month.7.label;"
                                      value="7"/>
                            <menuitem id="yearly-month-ordinal-8"
                                      label="&event.recurrence.pattern.yearly.month.8.label;"
                                      value="8"/>
                            <menuitem id="yearly-month-ordinal-9"
                                      label="&event.recurrence.pattern.yearly.month.9.label;"
                                      value="9"/>
                            <menuitem id="yearly-month-ordinal-10"
                                      label="&event.recurrence.pattern.yearly.month.10.label;"
                                      value="10"/>
                            <menuitem id="yearly-month-ordinal-11"
                                      label="&event.recurrence.pattern.yearly.month.11.label;"
                                      value="11"/>
                            <menuitem id="yearly-month-ordinal-12"
                                      label="&event.recurrence.pattern.yearly.month.12.label;"
                                      value="12"/>
                          </menupopup>
                        </menulist>
                      </box>
                    </row>
                    <row id="yearly-period-relative-row" align="center">
                      <radio id="yearly-period-relative-radio"
                             disable-on-readonly="true"
                             disable-on-occurrence="true"/>
                      <box id="yearly-period-relative-controls"
                           orient="horizontal"
                           align="center">
                        <menulist id="yearly-ordinal"
                                  disable-on-readonly="true"
                                  disable-on-occurrence="true">
                          <menupopup id="yearly-ordinal-menupopup">
                            <menuitem id="yearly-ordinal-every"
                                      label="&event.recurrence.yearly.every.label;"
                                      value="0"/>
                            <menuitem id="yearly-ordinal-first"
                                      label="&event.recurrence.yearly.first.label;"
                                      value="1"/>
                            <menuitem id="yearly-ordinal-second"
                                      label="&event.recurrence.yearly.second.label;"
                                      value="2"/>
                            <menuitem id="yearly-ordinal-third"
                                      label="&event.recurrence.yearly.third.label;"
                                      value="3"/>
                            <menuitem id="yearly-ordinal-fourth"
                                      label="&event.recurrence.yearly.fourth.label;"
                                      value="4"/>
                            <menuitem id="yearly-ordinal-fifth"
                                      label="&event.recurrence.yearly.fifth.label;"
                                      value="5"/>
                            <menuitem id="yearly-ordinal-last"
                                      label="&event.recurrence.yearly.last.label;"
                                      value="-1"/>
                          </menupopup>
                        </menulist>
                        <menulist id="yearly-weekday"
                                  disable-on-readonly="true"
                                  disable-on-occurrence="true">
                          <menupopup id="yearly-weekday-menupopup">
                            <menuitem id="yearly-weekday-1"
                                      label="&event.recurrence.pattern.yearly.week.1.label;"
                                      value="1"/>
                            <menuitem id="yearly-weekday-2"
                                      label="&event.recurrence.pattern.yearly.week.2.label;"
                                      value="2"/>
                            <menuitem id="yearly-weekday-3"
                                      label="&event.recurrence.pattern.yearly.week.3.label;"
                                      value="3"/>
                            <menuitem id="yearly-weekday-4"
                                      label="&event.recurrence.pattern.yearly.week.4.label;"
                                      value="4"/>
                            <menuitem id="yearly-weekday-5"
                                      label="&event.recurrence.pattern.yearly.week.5.label;"
                                      value="5"/>
                            <menuitem id="yearly-weekday-6"
                                      label="&event.recurrence.pattern.yearly.week.6.label;"
                                      value="6"/>
                            <menuitem id="yearly-weekday-7"
                                      label="&event.recurrence.pattern.yearly.week.7.label;"
                                      value="7"/>
                            <menuitem id="yearly-weekday--1"
                                      label="&event.recurrence.pattern.yearly.day.label;"
                                      value="-1"/>
                          </menupopup>
                        </menulist>
                      </box>
                    </row>
                    <row id="yearly-period-monthname-row" align="center">
                      <label id="yearly-period-of-label"
                             value="&event.recurrence.of.label;"
                             control="yearly-month-rule"/>
                      <menulist id="yearly-month-rule"
                                disable-on-readonly="true"
                                disable-on-occurrence="true">
                        <menupopup id="yearly-month-rule-menupopup">
                          <menuitem id="yearly-month-rule-1"
                                    label="&event.recurrence.pattern.yearly.month2.1.label;"
                                    value="1"/>
                          <menuitem id="yearly-month-rule-2"
                                    label="&event.recurrence.pattern.yearly.month2.2.label;"
                                    value="2"/>
                          <menuitem id="yearly-month-rule-3"
                                    label="&event.recurrence.pattern.yearly.month2.3.label;"
                                    value="3"/>
                          <menuitem id="yearly-month-rule-4"
                                    label="&event.recurrence.pattern.yearly.month2.4.label;"
                                    value="4"/>
                          <menuitem id="yearly-month-rule-5"
                                    label="&event.recurrence.pattern.yearly.month2.5.label;"
                                    value="5"/>
                          <menuitem id="yearly-month-rule-6"
                                    label="&event.recurrence.pattern.yearly.month2.6.label;"
                                    value="6"/>
                          <menuitem id="yearly-month-rule-7"
                                    label="&event.recurrence.pattern.yearly.month2.7.label;"
                                    value="7"/>
                          <menuitem id="yearly-month-rule-8"
                                    label="&event.recurrence.pattern.yearly.month2.8.label;"
                                    value="8"/>
                          <menuitem id="yearly-month-rule-9"
                                    label="&event.recurrence.pattern.yearly.month2.9.label;"
                                    value="9"/>
                          <menuitem id="yearly-month-rule-10"
                                    label="&event.recurrence.pattern.yearly.month2.10.label;"
                                    value="10"/>
                          <menuitem id="yearly-month-rule-11"
                                    label="&event.recurrence.pattern.yearly.month2.11.label;"
                                    value="11"/>
                          <menuitem id="yearly-month-rule-12"
                                    label="&event.recurrence.pattern.yearly.month2.12.label;"
                                    value="12"/>
                        </menupopup>
                      </menulist>
                    </row>
                  </rows>
                </grid>
              </radiogroup>
            </box>
          </deck>
        </row>
      </rows>
    </grid>
  </groupbox>

  <!-- range of recurrence -->
  <groupbox id="recurrence-range-groupbox">
    <caption id="recurrence-range-caption"
             label="&event.recurrence.range.label;"/>
    <vbox>
      <radiogroup id="recurrence-duration"
                  oncommand="updateRecurrenceControls()">
        <radio id="recurrence-range-forever"
               label="&event.recurrence.forever.label;"
               value="forever"
               selected="true"
               disable-on-readonly="true"
               disable-on-occurrence="true"/>
        <box id="recurrence-range-count-box"
             orient="horizontal"
             align="center">
          <radio id="recurrence-range-for"
                 label="&event.recurrence.repeat.for.label;"
                 value="ntimes"
                 disable-on-readonly="true"
                 disable-on-occurrence="true"/>
          <textbox id="repeat-ntimes-count"
                   type="number"
                   value="5"
                   min="1"
                   max="0x7FFF"
                   size="3"
                   onkeyup="updateRecurrenceControls();"
                   disable-on-readonly="true"
                   disable-on-occurrence="true"/>
          <label id="repeat-appointments-label"
                 value="&event.recurrence.appointments.label;"
                 disable-on-readonly="true"
                 disable-on-occurrence="true"/>
        </box>
        <box id="recurrence-range-until-box"
             orient="horizontal"
             align="center">
          <radio id="recurrence-range-until"
                 label="&event.repeat.until.label;"
                 value="until"
                 disable-on-readonly="true"
                 disable-on-occurrence="true"
                 control="repeat-until-date"/>
          <datepicker id="repeat-until-date"
                      onchange="checkUntilDate();"
                      disable-on-readonly="true"
                      disable-on-occurrence="true"/>
        </box>
      </radiogroup>
    </vbox>
  </groupbox>

  <!-- preview -->
  <groupbox id="preview-border" flex="1">
    <label id="recurrence-preview-label"
           value="&event.recurrence.preview.label;"
           control="recurrence-preview"/>
    <recurrence-preview id="recurrence-preview" flex="1"/>
  </groupbox>
</dialog>
