Bug 516802 - Refactor & cleanup mode and calendar view switching + today pane code. r=Fallen
This commit is contained in:
Родитель
fc127193c5
Коммит
97734170c8
|
@ -43,7 +43,7 @@ function commonInitCalendar() {
|
|||
loadCalendarManager();
|
||||
|
||||
// Restore the last shown calendar view
|
||||
selectCalendarView(getLastCalendarView());
|
||||
switchCalendarView(getLastCalendarView(), false);
|
||||
|
||||
// set up the unifinder
|
||||
prepareCalendarToDoUnifinder();
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Martin Schroeder <mschroeder@mozilla.x-home.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
@ -76,6 +77,11 @@ var calendarController = {
|
|||
"calendar_toggle_orientation_command": true,
|
||||
"calendar_toggle_workdays_only_command": true,
|
||||
|
||||
"calendar_day-view_command": true,
|
||||
"calendar_week-view_command": true,
|
||||
"calendar_multiweek-view_command": true,
|
||||
"calendar_month-view_command": true,
|
||||
|
||||
"calendar_task_filter_command": true,
|
||||
"calendar_reload_remote_calendars": true,
|
||||
"calendar_show_unifinder_command": true,
|
||||
|
@ -190,6 +196,10 @@ var calendarController = {
|
|||
|
||||
// The following commands need calendar mode, be careful when
|
||||
// changing things.
|
||||
case "calendar_day-view_command":
|
||||
case "calendar_week-view_command":
|
||||
case "calendar_multiweek-view_command":
|
||||
case "calendar_month-view_command":
|
||||
case "calendar_show_unifinder_command":
|
||||
case "calendar_mode_calendar":
|
||||
return this.isInMode("calendar");
|
||||
|
@ -364,6 +374,20 @@ var calendarController = {
|
|||
case "calendar_toggle_workdays_only_command":
|
||||
toggleWorkdaysOnly();
|
||||
break;
|
||||
|
||||
case "calendar_day-view_command":
|
||||
switchCalendarView("day", true);
|
||||
break;
|
||||
case "calendar_week-view_command":
|
||||
switchCalendarView("week", true);
|
||||
break;
|
||||
case "calendar_multiweek-view_command":
|
||||
switchCalendarView("multiweek", true);
|
||||
break;
|
||||
case "calendar_month-view_command":
|
||||
switchCalendarView("month", true);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (this.defaultController && !this.isCalendarInForeground()) {
|
||||
// If calendar is not in foreground, let the default controller take
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
- Contributor(s):
|
||||
- Simon Paquet <bugzilla@babylonsounds.com>
|
||||
- Berend Cornelius <berend.cornelius@sun.com>
|
||||
- Martin Schroeder <mschroeder@mozilla.x-home.org>
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
@ -90,10 +91,10 @@
|
|||
|
||||
<command id="calendar_show_unifinder_command" oncommand="goDoCommand('calendar_show_unifinder_command')"/>
|
||||
<!-- The dash instead of the underscore is intended. the 'xxx-view' part should be the id of the view in the deck -->
|
||||
<command id="calendar_day-view_command" oncommand="showCalendarView('day')"/>
|
||||
<command id="calendar_week-view_command" oncommand="showCalendarView('week')"/>
|
||||
<command id="calendar_multiweek-view_command" oncommand="showCalendarView('multiweek')"/>
|
||||
<command id="calendar_month-view_command" oncommand="showCalendarView('month')"/>
|
||||
<command id="calendar_day-view_command" oncommand="goDoCommand('calendar_day-view_command')"/>
|
||||
<command id="calendar_week-view_command" oncommand="goDoCommand('calendar_week-view_command')"/>
|
||||
<command id="calendar_multiweek-view_command" oncommand="goDoCommand('calendar_multiweek-view_command')"/>
|
||||
<command id="calendar_month-view_command" oncommand="goDoCommand('calendar_month-view_command')"/>
|
||||
<command id="calendar_task_category_command" oncommand="contextChangeTaskCategory(event);"/>
|
||||
<command id="calendar_toggle_completed_command" oncommand="toggleCompleted(event)"/>
|
||||
<command id="calendar_percentComplete-0_command" oncommand="contextChangeTaskProgress(event, 0)"/>
|
||||
|
|
|
@ -273,34 +273,17 @@ var calendarViewController = {
|
|||
|
||||
/**
|
||||
* This function provides a neutral way to switch between views.
|
||||
* XXX Kind of confusing. This function calls the app specific function, which
|
||||
* again calls the common switchToView function. They should be consolidated in
|
||||
* a different bug.
|
||||
*
|
||||
* @param type The type of view to show
|
||||
* @param event (optional) A DOM event that caused the view to show.
|
||||
* @param aType The type of view to select.
|
||||
* @param aShow If true, the calendar view is forced to be shown, i.e.
|
||||
* bringing the view to the front if the application is
|
||||
* showing other elements (Lightning).
|
||||
*/
|
||||
function showCalendarView(type, event) {
|
||||
if (isSunbird()) {
|
||||
sbSwitchToView(type, event);
|
||||
} else if (document.getElementById('switch2calendar').getAttribute('checked')) {
|
||||
ltnShowCalendarView(type, event);
|
||||
}
|
||||
onCalendarViewResize(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function acts like showCalendarView, but does not bring the view to the front
|
||||
* if the application is showing other elements (i.e Lightning).
|
||||
*
|
||||
* @see showCalendarView
|
||||
* @param type The type of view to select.
|
||||
*/
|
||||
function selectCalendarView(type) {
|
||||
if (isSunbird()) {
|
||||
sbSwitchToView(type);
|
||||
function switchCalendarView(aType, aShow) {
|
||||
if (cal.isSunbird()) {
|
||||
sbSwitchToView(aType);
|
||||
} else {
|
||||
ltnSelectCalendarView(type);
|
||||
ltnSwitchCalendarView(aType, aShow);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,6 +370,8 @@ function switchToView(aViewType) {
|
|||
|
||||
view.goToDay(selectedDay);
|
||||
view.setSelectedItems(currentSelection.length, currentSelection);
|
||||
|
||||
onCalendarViewResize();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Lightning code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Oracle Corporation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mike Shaver <shaver@mozilla.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#calendar-view-box {
|
||||
visibility: collapse;
|
||||
}
|
|
@ -195,9 +195,6 @@ function ltnOnLoad(event) {
|
|||
// Take care of common initialization
|
||||
commonInitCalendar();
|
||||
|
||||
// Hide the calendar view so it doesn't push the status-bar offscreen
|
||||
collapseElement(document.getElementById("calendar-view-box"));
|
||||
|
||||
// Add an unload function to the window so we don't leak any listeners
|
||||
window.addEventListener("unload", ltnFinish, false);
|
||||
|
||||
|
@ -249,34 +246,25 @@ function refreshUIBits() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Select the calendar view in the background, not switching to calendar mode if
|
||||
* in mail mode.
|
||||
* Switch the calendar view, and optionally switch to calendar mode.
|
||||
*
|
||||
* @param aType The type of view to select.
|
||||
* @param aShow If true, the mode will be switched to calendar if not
|
||||
* already there.
|
||||
*/
|
||||
function ltnSelectCalendarView(type) {
|
||||
gLastShownCalendarView = type;
|
||||
function ltnSwitchCalendarView(aType, aShow) {
|
||||
gLastShownCalendarView = aType;
|
||||
|
||||
// Sunbird/Lightning Common view switching code
|
||||
switchToView(type);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the calendar view, also switching to calendar mode if in mail mode
|
||||
*/
|
||||
function ltnShowCalendarView(type)
|
||||
{
|
||||
gLastShownCalendarView = type;
|
||||
|
||||
if (gCurrentMode != 'calendar') {
|
||||
// This function in turn calls showCalendarView(), so return afterwards.
|
||||
if (aShow && gCurrentMode != "calendar") {
|
||||
// This function in turn calls switchToView(), so return afterwards.
|
||||
ltnSwitch2Calendar();
|
||||
return;
|
||||
}
|
||||
|
||||
ltnSelectCalendarView(type);
|
||||
// Sunbird/Lightning common view switching code
|
||||
switchToView(aType);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function has the sole responsibility to switch back to
|
||||
* mail mode (by calling ltnSwitch2Mail()) if we are getting
|
||||
|
@ -402,7 +390,6 @@ function openInvitationsDialog() {
|
|||
/**
|
||||
* the current mode is set to a string defining the current
|
||||
* mode we're in. allowed values are:
|
||||
* - 'mode'
|
||||
* - 'mail'
|
||||
* - 'calendar'
|
||||
* - 'task'
|
||||
|
@ -415,13 +402,6 @@ var gCurrentMode = 'mail';
|
|||
|
||||
function ltnSwitch2Mail() {
|
||||
if (gCurrentMode != 'mail') {
|
||||
var switch2mail = document.getElementById("switch2mail");
|
||||
var switch2calendar = document.getElementById("switch2calendar");
|
||||
var switch2task = document.getElementById("switch2task");
|
||||
switch2mail.setAttribute("checked", "true");
|
||||
switch2calendar.removeAttribute("checked");
|
||||
switch2task.removeAttribute("checked");
|
||||
|
||||
gCurrentMode = 'mail';
|
||||
document.getElementById("modeBroadcaster").setAttribute("mode", gCurrentMode);
|
||||
|
||||
|
@ -436,24 +416,15 @@ function ltnSwitch2Mail() {
|
|||
|
||||
function ltnSwitch2Calendar() {
|
||||
if (gCurrentMode != 'calendar') {
|
||||
var switch2mail = document.getElementById("switch2mail");
|
||||
var switch2calendar = document.getElementById("switch2calendar");
|
||||
var switch2task = document.getElementById("switch2task");
|
||||
switch2mail.removeAttribute("checked");
|
||||
switch2calendar.setAttribute("checked", "true");
|
||||
switch2task.removeAttribute("checked");
|
||||
|
||||
gCurrentMode = 'calendar';
|
||||
document.getElementById("modeBroadcaster").setAttribute("mode", gCurrentMode);
|
||||
|
||||
// display the calendar panel on the display deck
|
||||
var viewBox = document.getElementById("calendar-view-box");
|
||||
uncollapseElement(viewBox);
|
||||
var deck = document.getElementById("calendarDisplayDeck");
|
||||
deck.selectedPanel = viewBox;
|
||||
let deck = document.getElementById("calendarDisplayDeck");
|
||||
deck.selectedPanel = document.getElementById("calendar-view-box");
|
||||
|
||||
// show the last displayed type of calendar view
|
||||
showCalendarView(gLastShownCalendarView);
|
||||
switchToView(gLastShownCalendarView);
|
||||
|
||||
document.commandDispatcher.updateCommands('calendar_commands');
|
||||
window.setCursor("auto");
|
||||
|
@ -466,21 +437,12 @@ function ltnSwitch2Calendar() {
|
|||
|
||||
function ltnSwitch2Task() {
|
||||
if (gCurrentMode != 'task') {
|
||||
var switch2mail = document.getElementById("switch2mail");
|
||||
var switch2calendar = document.getElementById("switch2calendar");
|
||||
var switch2task = document.getElementById("switch2task");
|
||||
switch2mail.removeAttribute("checked");
|
||||
switch2calendar.removeAttribute("checked");
|
||||
switch2task.setAttribute("checked", "true");
|
||||
|
||||
gCurrentMode = 'task';
|
||||
document.getElementById("modeBroadcaster").setAttribute("mode", gCurrentMode);
|
||||
|
||||
// display the task panel on the display deck
|
||||
var taskBox = document.getElementById("calendar-task-box");
|
||||
uncollapseElement(taskBox);
|
||||
var deck = document.getElementById("calendarDisplayDeck");
|
||||
deck.selectedPanel = taskBox;
|
||||
let deck = document.getElementById("calendarDisplayDeck");
|
||||
deck.selectedPanel = document.getElementById("calendar-task-box");
|
||||
|
||||
document.commandDispatcher.updateCommands('calendar_commands');
|
||||
window.setCursor("auto");
|
||||
|
|
|
@ -168,38 +168,39 @@
|
|||
</menupopup>
|
||||
</menu>
|
||||
<menu id="ltnCalendarMenu"
|
||||
observes="calendar_in_foreground"
|
||||
insertbefore="viewSortMenuSeparator"
|
||||
label="&lightning.menu.view.calendar.label;"
|
||||
accesskey="&lightning.menu.view.calendar.accesskey;">
|
||||
<menupopup id="ltnTasksMenuPopup">
|
||||
<menupopup id="ltnCalendarMenuPopup">
|
||||
<menuitem id="ltnChangeViewDay"
|
||||
label="&lightning.toolbar.day.label;"
|
||||
accesskey="&lightning.toolbar.day.accesskey;"
|
||||
type="radio"
|
||||
name="calendarMenuViews"
|
||||
key="calendar-day-view-key"
|
||||
observes="calendar_day-view_command"/>
|
||||
command="calendar_day-view_command"/>
|
||||
<menuitem id="ltnChangeViewWeek"
|
||||
label="&lightning.toolbar.week.label;"
|
||||
accesskey="&lightning.toolbar.week.accesskey;"
|
||||
type="radio"
|
||||
name="calendarMenuViews"
|
||||
key="calendar-week-view-key"
|
||||
observes="calendar_week-view_command"/>
|
||||
command="calendar_week-view_command"/>
|
||||
<menuitem id="ltnChangeViewMultiweek"
|
||||
label="&lightning.toolbar.multiweek.label;"
|
||||
accesskey="&lightning.toolbar.multiweek.accesskey;"
|
||||
type="radio"
|
||||
name="calendarMenuViews"
|
||||
key="calendar-multiweek-view-key"
|
||||
observes="calendar_multiweek-view_command"/>
|
||||
command="calendar_multiweek-view_command"/>
|
||||
<menuitem id="ltnChangeViewMonth"
|
||||
label="&lightning.toolbar.month.label;"
|
||||
accesskey="&lightning.toolbar.month.accesskey;"
|
||||
type="radio"
|
||||
name="calendarMenuViews"
|
||||
key="calendar-month-view-key"
|
||||
observes="calendar_month-view_command"/>
|
||||
command="calendar_month-view_command"/>
|
||||
<menuseparator id="ltnBeforeCalendarViewSection"/>
|
||||
<menuitem id="ltnTasksViewMinimonth"
|
||||
type="checkbox"
|
||||
|
@ -381,15 +382,27 @@
|
|||
observes="calendar_new_todo_command"/>
|
||||
<menuseparator id="before-Calendar-Mode-Section"/>
|
||||
<menuitem id="ltnMenuSwitchToCalendar"
|
||||
type="checkbox"
|
||||
label="&lightning.toolbar.calendar.label;"
|
||||
accesskey="&lightning.toolbar.calendar.accesskey;"
|
||||
command="switch2calendar"
|
||||
key="openLightningKey"/>
|
||||
key="openLightningKey"
|
||||
autocheck="false">
|
||||
<observes element="modeBroadcaster"
|
||||
attribute="mode"
|
||||
onbroadcast="this.parentNode.setAttribute('checked', '' + document.getElementById('modeBroadcaster').getAttribute('mode') == 'calendar')"/>
|
||||
</menuitem>
|
||||
<menuitem id="ltnMenuSwitchToTask"
|
||||
type="checkbox"
|
||||
label="&lightning.toolbar.task.label;"
|
||||
accesskey="&lightning.toolbar.task.accesskey;"
|
||||
command="switch2task"
|
||||
key="openTasksKey"/>
|
||||
key="openTasksKey"
|
||||
autocheck="false">
|
||||
<observes element="modeBroadcaster"
|
||||
attribute="mode"
|
||||
onbroadcast="this.parentNode.setAttribute('checked', '' + document.getElementById('modeBroadcaster').getAttribute('mode') == 'task')"/>
|
||||
</menuitem>
|
||||
<menuseparator id="ltnBeforeCalendarSection"/>
|
||||
<!-- Menuitems have different schema just to match sunbird -->
|
||||
<menuitem id="calendar-export-menu"
|
||||
|
@ -452,9 +465,6 @@
|
|||
<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="switch2mail"
|
||||
checked="true"
|
||||
oncommand="document.getElementById('tabmail').selectTabByMode('folder')"/>
|
||||
<command id="switch2calendar"
|
||||
oncommand="document.getElementById('tabmail').openTab('calendar', { title: document.getElementById('calendar-tab-button').getAttribute('tooltiptext') })"/>
|
||||
<command id="switch2task"
|
||||
|
|
|
@ -35,7 +35,6 @@ lightning.jar:
|
|||
content/lightning/lightning-utils.js (content/lightning-utils.js)
|
||||
content/lightning/lightning-widgets.css (content/lightning-widgets.css)
|
||||
content/lightning/lightning-widgets.xml (content/lightning-widgets.xml)
|
||||
content/lightning/messenger-overlay-sidebar.css (content/messenger-overlay-sidebar.css)
|
||||
content/lightning/messenger-overlay-accountCentral.xul (content/messenger-overlay-accountCentral.xul)
|
||||
content/lightning/messenger-overlay-messageWindow.xul (content/messenger-overlay-messageWindow.xul)
|
||||
* content/lightning/messenger-overlay-sidebar.js (content/messenger-overlay-sidebar.js)
|
||||
|
|
|
@ -389,7 +389,7 @@
|
|||
accesskey="&calendar.addons.accesskey;"
|
||||
command="Tools:Addons"/>
|
||||
<menuseparator id="devToolsSeparator"/>
|
||||
<menuitem id="javascriptConsole"
|
||||
<menuitem id="javascriptConsole"
|
||||
label="&errorConsoleCmd.label;"
|
||||
accesskey="&errorConsoleCmd.accesskey;"
|
||||
oncommand="toJavaScriptConsole();"/>
|
||||
|
|
Загрузка…
Ссылка в новой задаче