<?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/. -->

<!DOCTYPE overlay
[
  <!ENTITY % dtd1 SYSTEM "chrome://lightning/locale/lightning.dtd" > %dtd1;
  <!ENTITY % dtd2 SYSTEM "chrome://calendar/locale/menuOverlay.dtd" > %dtd2;
  <!ENTITY % dtd3 SYSTEM "chrome://calendar/locale/calendar.dtd" > %dtd3;
  <!ENTITY % dtd4 SYSTEM "chrome://lightning/locale/lightning-toolbar.dtd" > %dtd4;
  <!ENTITY % messengerDTD SYSTEM "chrome://messenger/locale/messenger.dtd"> %messengerDTD;
]>

<?xml-stylesheet href="chrome://lightning/skin/lightning.css" type="text/css"?>

<?xml-stylesheet href="chrome://calendar/content/calendar-view-bindings.css" type="text/css"?>
<?xml-stylesheet href="chrome://calendar/content/datetimepickers/datetimepickers.css" type="text/css"?>

<?xul-overlay href="chrome://calendar/content/calendar-calendars-list.xul"?>
<?xul-overlay href="chrome://calendar/content/calendar-common-sets.xul"?>
<?xul-overlay href="chrome://calendar/content/calendar-views.xul"?>

<?xul-overlay href="chrome://lightning/content/lightning-toolbar.xul"?>
<?xul-overlay href="chrome://lightning/content/lightning-menus.xul"?>

<overlay id="ltnSidebarOverlay"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <!-- NEEDED FOR MULTIPLE CALENDAR SUPPORT -->
  <script type="application/javascript" src="chrome://calendar/content/calendar-management.js"/>

  <!-- NEEDED FOR CLIPBOARD SUPPORT -->
  <script type="application/javascript" src="chrome://calendar/content/calendar-clipboard.js"/>

  <!-- NEEDED FOR IMPORT / EXPORT SUPPORT -->
  <script type="application/javascript" src="chrome://calendar/content/import-export.js"/>

  <!-- NEEDED FOR PUBLICATION SUPPORT -->
  <script type="application/javascript" src="chrome://calendar/content/publish.js"/>

  <script type="application/javascript" src="chrome://calendar/content/calendar-item-editing.js"/>
  <script type="application/javascript" src="chrome://calendar/content/calendar-chrome-startup.js"/>
  <script type="application/javascript" src="chrome://calendar/content/calUtils.js"/>
  <script type="application/javascript" src="chrome://calendar/content/mouseoverPreviews.js"/>
  <script type="application/javascript" src="chrome://calendar/content/calendar-views.js"/>
  <script type="application/javascript" src="chrome://calendar/content/calendar-ui-utils.js"/>
  <script type="application/javascript" src="chrome://calendar/content/calendar-creation.js"/>
  <script type="application/javascript" src="chrome://calendar/content/calendar-dnd-listener.js"/>
  <script type="application/javascript" src="chrome://calendar/content/calendar-statusbar.js"/>
  <script type="application/javascript" src="chrome://global/content/nsDragAndDrop.js"/>

  <!-- NEEDED FOR TASK VIEW/LIST SUPPORT -->
  <script type="application/javascript" src="chrome://calendar/content/calendar-task-editing.js"/>

  <script type="application/javascript" src="chrome://calendar/content/calendar-extract.js"/>

  <script type="application/javascript" src="chrome://lightning/content/lightning-utils.js"/>
  <script type="application/javascript" src="chrome://lightning/content/messenger-overlay-sidebar.js"/>
  <script type="application/javascript" src="chrome://calendar/content/calendar-invitations-manager.js"/>

  <window id="messengerWindow">
    <!-- Be sure to keep these sets, since they will be overlayed by
         calendar/base/content/calendar-common-sets.xul -->
    <commandset id="calendar_commands">
      <command id="agenda_delete_event_command" oncommand="agendaListbox.deleteSelectedItem(false);"/>
      <command id="agenda_edit_event_command" oncommand="agendaListbox.editSelectedItem(event);"/>
      <command id="switch2calendar"
               oncommand="document.getElementById('tabmail').openTab('calendar', { title: document.getElementById('calendar-tab-button').getAttribute('title') })"/>
      <command id="switch2task"
               oncommand="document.getElementById('tabmail').openTab('tasks', { title: document.getElementById('task-tab-button').getAttribute('title') })"/>
      <command id="new_calendar_tab"
               oncommand="document.getElementById('tabmail').openTab('calendar', { title: document.getElementById('calendar-tab-button').getAttribute('title') })"/>
      <command id="new_task_tab"
               oncommand="document.getElementById('tabmail').openTab('tasks', { title: document.getElementById('task-tab-button').getAttribute('title') })"/>
      <command id="calendar_go_to_today_command"
               observes="calendar_mode_calendar"
               oncommand="document.getElementById('tabmail').openTab('calendar', { title: document.getElementById('calendar-tab-button').getAttribute('title') }); goToDate(now())"/>
    </commandset>

    <commandset id="mailCommands">
      <command id="cmd_CustomizeMailToolbar"
               oncommand="CustomizeMailToolbar(document.getElementById('modeBroadcaster').getAttribute('mode') + '-toolbox', 'CustomizeMailToolbar')"/>
    </commandset>

    <keyset id="calendar-keys">
      <key id="openLightningKey"
           key="&lightning.keys.event.showCalendar.key;"
           modifiers="accel, shift"
           observes="new_calendar_tab"/>
      <key id="openTasksKey"
           key="&lightning.keys.event.showTasks.key;"
           modifiers="accel, shift"
           command="new_task_tab"/>
      <key id="todaypanekey" command="calendar_toggle_todaypane_command" keycode="VK_F11"/>
      <key id="calendar-new-event-key" key="&lightning.keys.event.new;" modifiers="accel" command="calendar_new_event_command"/>
      <key id="calendar-new-todo-key" key="&lightning.keys.todo.new;" modifiers="accel" command="calendar_new_todo_command"/>
    </keyset>

    <broadcasterset id="calendar_broadcasters">
      <broadcaster id="filterBroadcaster" value="all"/>
    </broadcasterset>

    <popupset id="calendar-popupset"/>
  </window>

  <toolbar id="tabbar-toolbar">
    <toolbarbutton id="calendar-tab-button"
                   class="toolbarbutton-1"
                   title="&lightning.toolbar.calendar.label;"
                   tooltiptext="&lightning.toolbar.calendar.tooltip;"
                   command="new_calendar_tab"/>
    <toolbarbutton id="task-tab-button"
                   class="toolbarbutton-1"
                   title="&lightning.toolbar.task.label;"
                   tooltiptext="&lightning.toolbar.task.tooltip;"
                   command="new_task_tab"/>
  </toolbar>

  <tabpanels id="tabpanelcontainer">
    <vbox id="calendarTabPanel">
      <!-- Unfortunately we use the same panel for task and calendar tabs, so
           we need to differ which toolbar is being shown. The actual toolbar
           content will be added via a further overlay -->
      <modevbox id="calendar-toolbox-container" mode="calendar" broadcaster="modeBroadcaster">
        <toolbox id="calendar-toolbox"/>
      </modevbox>
      <modevbox id="task-toolbox-container" mode="task" broadcaster="modeBroadcaster">
        <toolbox id="task-toolbox"/>
      </modevbox>
      <hbox id="calendarContent" flex="1">
        <vbox id="ltnSidebar"
              width="200"
              persist="collapsed width">
          <modevbox id="minimonth-pane" mode="calendar,task" broadcaster="modeBroadcaster" refcontrol="calendar_toggle_minimonthpane_command">
            <vbox align="center">
              <hbox id="calMinimonthBox" pack="center">
                <minimonth id="calMinimonth" onchange="minimonthPick(this.value);" freebusy="true"/>
              </hbox>
            </vbox>
          </modevbox>
          <separator id="minimonth-splitter" minwidth="100"/>
          <vbox id="calendar-panel" flex="1">
            <modevbox id="task-filter-pane" mode="task" broadcaster="modeBroadcaster" refcontrol="calendar_toggle_filter_command">
              <treenode-checkbox id="task-tree-filter-header"
                               checked="true"
                               class="treenode-checkbox"
                               label="&calendar.task.filter.title.label;"/>
              <modevbox id="task-filtertree-pane" flex="1" mode="task" broadcaster="modeBroadcaster" refcontrol="task-tree-filter-header">
                 <radiogroup id="task-tree-filtergroup" class="task-tree-subpane"
                             persist="value">
                   <observes element="filterBroadcaster"
                             attribute="value"
                             onbroadcast="checkRadioControl(this.parentNode, document.getElementById('filterBroadcaster').getAttribute('value'));"/>
                   <radio id="opt_throughcurrent_filter" label="&calendar.task.filter.current.label;" value="throughcurrent" command="calendar_task_filter_command"/>
                   <radio id="opt_today_filter" label="&calendar.task.filter.today.label;" value="throughtoday" command="calendar_task_filter_command"/>
                   <radio id="opt_next7days_filter" label="&calendar.task.filter.next7days.label;" value="throughsevendays" command="calendar_task_filter_command"/>
                   <radio id="opt_notstarted_filter" label="&calendar.task.filter.notstarted.label;" value="notstarted" command="calendar_task_filter_command"/>
                   <radio id="opt_overdue_filter" label="&calendar.task.filter.overdue.label;" value="overdue" command="calendar_task_filter_command"/>
                   <radio id="opt_completed_filter" label="&calendar.task.filter.completed.label;" value="completed" command="calendar_task_filter_command"/>
                   <radio id="opt_open_filter" label="&calendar.task.filter.open.label;" value="open" command="calendar_task_filter_command"/>
                   <radio id="opt_all_filter" label="&calendar.task.filter.all.label;" value="all" command="calendar_task_filter_command"/>
                 </radiogroup>
              </modevbox>
            </modevbox>
            <modevbox id="calendar-list-pane" flex="1" mode="calendar,task" broadcaster="modeBroadcaster"
                      refcontrol="calendar_toggle_calendarlist_command">
              <treenode-checkbox id="calendar-list-header"
                               checked="true"
                               class="treenode-checkbox"
                               ondrop="return document.getElementById('calendar-list-tree-widget').foreignDrop(event)"
                               ondragenter="return document.getElementById('calendar-list-tree-widget').foreignCanDrop(event)"
                               ondragover="return document.getElementById('calendar-list-tree-widget').foreignCanDrop(event)"
                               label="&calendar.list.header.label;"/>
              <modevbox id="calendar-listtree-pane" flex="1" mode="calendar,task" broadcaster="modeBroadcaster"
                        refcontrol="calendar-list-header">

                <calendar-list-tree id="calendar-list-tree-widget"
                                    class="task-tree-subpane"
                                    flex="1"/>
              </modevbox>
          </modevbox>
          </vbox>
        </vbox>

        <splitter id="calsidebar_splitter"
                  collapse="before"
                  persist="state"
                  class="calendar-sidebar-splitter"/>

        <deck id="calendarDisplayDeck" flex="1">
          <!-- vbox "calendar-view-box will be overlayed..." -->
          <vbox id="calendar-view-box"/>
        </deck>
      </hbox>
    </vbox>
  </tabpanels>

  <hbox id="tabmail-container">
    <splitter id="today-splitter"
              collapse="after"
              resizebefore="closest"
              state="collapsed"
              class="calendar-sidebar-splitter"
              oncommand="TodayPane.onCommandTodaySplitter();">
      <grippy/>
    </splitter>
    <modevbox id="today-pane-panel" />
  </hbox>

  <statusbar id="status-bar">
    <statusbarpanel id="calendar-show-todaypane-panel"
                    pack="center">
      <toolbarbutton id="calendar-status-todaypane-button"
                     todaypane="true"
                     type="checkbox"
                     label="&todaypane.statusButton.label;"
                     tooltiptext="&calendar.todaypane.button.tooltip;"
                     observes="calendar_toggle_todaypane_command"
                     command="calendar_toggle_todaypane_command"/>
    </statusbarpanel>
    <statusbarpanel id="calendar-invitations-panel"
                    insertbefore="unreadMessageCount,totalMessageCount"
                    oncommand="openInvitationsDialog()">
      <label id="calendar-invitations-label"
             class="text-link"
             onclick="openInvitationsDialog()"
             onkeypress="if (event.keyCode == event.VK_RETURN) {
                             openInvitationsDialog(); }"/>
    </statusbarpanel>
  </statusbar>
</overlay>
