mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-29 21:25:35 +00:00
Bug 337941 unify some common elements of view switching/control code, r1=dmose, r2=mvl
This commit is contained in:
parent
4d789580db
commit
0b6ed036d2
184
calendar/base/content/calendar-views.js
Normal file
184
calendar/base/content/calendar-views.js
Normal file
@ -0,0 +1,184 @@
|
||||
/* ***** 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 Calendar views code
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* the Mozilla Calendar Squad
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir.vukicevic@oracle.com>
|
||||
* Joey Minta <jminta@gmail.com>
|
||||
* Michael Buettner <michael.buettner@sun.com>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
var calendarViewController = {
|
||||
QueryInterface: function(aIID) {
|
||||
if (!aIID.equals(Components.interfaces.calICalendarViewController) &&
|
||||
!aIID.equals(Components.interfaces.nsISupports)) {
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
createNewEvent: function (aCalendar, aStartTime, aEndTime) {
|
||||
// XXX If we're adding an item from the view, let's make sure that
|
||||
// XXX the calendar in question is visible!
|
||||
// XXX unify these
|
||||
if (!aCalendar) {
|
||||
if ("ltnSelectedCalendar" in window) {
|
||||
aCalendar = ltnSelectedCalendar();
|
||||
} else {
|
||||
aCalendar = getSelectedCalendarOrNull();
|
||||
}
|
||||
}
|
||||
|
||||
// if we're given both times, skip the dialog
|
||||
if (aStartTime && aEndTime && !aStartTime.isDate && !aEndTime.isDate) {
|
||||
var event = createEvent();
|
||||
event.startDate = aStartTime;
|
||||
event.endDate = aEndTime;
|
||||
var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"]
|
||||
.getService(Components.interfaces.nsIStringBundleService);
|
||||
var props = sbs.createBundle("chrome://calendar/locale/calendar.properties");
|
||||
event.title = props.GetStringFromName("newEvent");
|
||||
setDefaultAlarmValues(event);
|
||||
doTransaction('add', event, aCalendar, null, null);
|
||||
} else if (aStartTime && aStartTime.isDate) {
|
||||
var event = createEvent();
|
||||
event.startDate = aStartTime;
|
||||
setDefaultAlarmValues(event);
|
||||
doTransaction('add', event, aCalendar, null, null);
|
||||
} else {
|
||||
// default pop up the dialog
|
||||
//XXX unify these
|
||||
if ("newEvent" in window) {
|
||||
// Sunbird specific code
|
||||
newEvent();
|
||||
} else {
|
||||
// Lightning specific code
|
||||
var date = document.getElementById("calendar-view-box").selectedPanel.selectedDay.clone();
|
||||
date.isDate = false;
|
||||
createEventWithDialog(aCalendar, date, date);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
modifyOccurrence: function (aOccurrence, aNewStartTime, aNewEndTime) {
|
||||
// if we can modify this thing directly (e.g. just the time changed),
|
||||
// then do so; otherwise pop up the dialog
|
||||
var itemToEdit = getOccurrenceOrParent(aOccurrence);
|
||||
if (aNewStartTime && aNewEndTime && !aNewStartTime.isDate && !aNewEndTime.isDate) {
|
||||
|
||||
var instance = itemToEdit.clone();
|
||||
|
||||
// if we're about to modify the parentItem, we need to account
|
||||
// for the possibility that the item passed as argument was
|
||||
// some other occurrence, but the user said she would like to
|
||||
// modify all ocurrences instead. In that case, we need to figure
|
||||
// out how much the occurrence moved, and move the occurrence by
|
||||
// that amount.
|
||||
if (instance.parentItem.hasSameIds(instance)) {
|
||||
//XXX bad! Don't modify in-params!
|
||||
var startDiff = instance.startDate.subtractDate(aOccurrence.startDate);
|
||||
aNewStartTime.addDuration(startDiff);
|
||||
var endDiff = instance.endDate.subtractDate(aOccurrence.endDate);
|
||||
aNewEndTime.addDuration(endDiff);
|
||||
}
|
||||
|
||||
instance.startDate = aNewStartTime;
|
||||
instance.endDate = aNewEndTime;
|
||||
|
||||
doTransaction('modify', instance, instance.calendar, itemToEdit, null);
|
||||
} else {
|
||||
//XXX unify these
|
||||
if ("editEvent" in window) {
|
||||
// Sunbird specific code
|
||||
editEvent();
|
||||
} else {
|
||||
// Lightning specific code
|
||||
modifyEventWithDialog(itemToEdit);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
deleteOccurrence: function (aOccurrence) {
|
||||
var itemToDelete = getOccurrenceOrParent(aOccurrence);
|
||||
if (!itemToDelete.parentItem.hasSameIds(itemToDelete)) {
|
||||
var event = itemToDelete.parentItem.clone();
|
||||
event.recurrenceInfo.removeOccurrenceAt(itemToDelete.recurrenceId);
|
||||
doTransaction('modify', event, event.calendar, itemToDelete.parentItem, null);
|
||||
} else {
|
||||
doTransaction('delete', itemToDelete, itemToDelete.calendar, null, null);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function switchToView(aViewType) {
|
||||
var viewDeck = getViewDeck();
|
||||
var selectedDay;
|
||||
try {
|
||||
var selectedDay = viewDeck.selectedPanel.selectedDay;
|
||||
} catch(ex) {
|
||||
// This dies if no view has even been chosen this session, but that's
|
||||
// ok because we'll just use now() below.
|
||||
}
|
||||
|
||||
if (!selectedDay)
|
||||
selectedDay = now();
|
||||
|
||||
// Anyone wanting to plug in a view needs to follow this naming scheme
|
||||
var view = document.getElementById(aViewType+"-view");
|
||||
viewDeck.selectedPanel = view;
|
||||
|
||||
var compositeCal = getCompositeCalendar();
|
||||
if (view.displayCalendar != compositeCal) {
|
||||
view.displayCalendar = compositeCal;
|
||||
view.timezone = calendarDefaultTimezone();
|
||||
view.controller = calendarViewController;
|
||||
}
|
||||
|
||||
view.goToDay(selectedDay);
|
||||
}
|
||||
|
||||
function moveView(aNumber) {
|
||||
getViewDeck().selectedPanel.moveView(aNumber);
|
||||
}
|
||||
|
||||
// Helper function to get the view deck in a neutral way, regardless of whether
|
||||
// we're in Sunbird or Lightning.
|
||||
function getViewDeck() {
|
||||
var sbDeck = document.getElementById("view-deck");
|
||||
var ltnDeck = document.getElementById("calendar-view-box");
|
||||
return sbDeck || ltnDeck;
|
||||
}
|
||||
|
||||
function currentView() {
|
||||
return getViewDeck().selectedPanel;
|
||||
}
|
@ -176,12 +176,6 @@ function ltnOnLoad(event)
|
||||
return;
|
||||
}
|
||||
|
||||
function currentView()
|
||||
{
|
||||
var calendarViewBox = document.getElementById("calendar-view-box");
|
||||
return calendarViewBox.selectedPanel;
|
||||
}
|
||||
|
||||
function showCalendarView(type)
|
||||
{
|
||||
// If we got this call while a mail-view is being shown, we need to
|
||||
@ -207,28 +201,8 @@ function showCalendarView(type)
|
||||
gMsgFolderSelected = null;
|
||||
msgWindow.openFolder = null;
|
||||
}
|
||||
|
||||
document.getElementById("displayDeck").selectedPanel = calendarViewBox;
|
||||
var calendarViewBox = document.getElementById("calendar-view-box");
|
||||
|
||||
var selectedDay;
|
||||
try {
|
||||
var selectedDay = calendarViewBox.selectedPanel.selectedDay;
|
||||
} catch(ex) {} // This dies if no view has even been chosen this session
|
||||
|
||||
if (!selectedDay)
|
||||
selectedDay = today();
|
||||
|
||||
calendarViewBox.selectedPanel = document.getElementById(type+"-view");
|
||||
var view = calendarViewBox.selectedPanel;
|
||||
|
||||
if (view.displayCalendar != getCompositeCalendar()) {
|
||||
view.displayCalendar = getCompositeCalendar();
|
||||
view.timezone = calendarDefaultTimezone();
|
||||
view.controller = ltnCalendarViewController;
|
||||
}
|
||||
|
||||
view.goToDay(selectedDay);
|
||||
switchToView(type);
|
||||
|
||||
// Set the labels for the context-menu
|
||||
var nextCommand = document.getElementById("context_next");
|
||||
@ -300,15 +274,15 @@ function ltnFinish() {
|
||||
}
|
||||
|
||||
function ltnEditSelectedItem() {
|
||||
ltnCalendarViewController.modifyOccurrence(currentView().selectedItem);
|
||||
calendarViewController.modifyOccurrence(currentView().selectedItem);
|
||||
}
|
||||
|
||||
function ltnDeleteSelectedItem() {
|
||||
ltnCalendarViewController.deleteOccurrence(currentView().selectedItem);
|
||||
calendarViewController.deleteOccurrence(currentView().selectedItem);
|
||||
}
|
||||
|
||||
function ltnCreateEvent() {
|
||||
ltnCalendarViewController.createNewEvent(ltnSelectedCalendar());
|
||||
calendarViewController.createNewEvent(ltnSelectedCalendar());
|
||||
}
|
||||
|
||||
// Preference observer, watches for changes to any 'calendar.' pref
|
||||
|
@ -68,7 +68,7 @@
|
||||
<script type="application/x-javascript" src="chrome://lightning/content/lightning-utils.js"/>
|
||||
<script type="application/x-javascript" src="chrome://lightning/content/calendar-management.js"/>
|
||||
<script type="application/x-javascript" src="chrome://lightning/content/messenger-overlay-sidebar.js"/>
|
||||
|
||||
<script type="application/x-javascript" src="chrome://calendar/content/calendar-views.js"/>
|
||||
<window id="messengerWindow">
|
||||
<commandset id="calendar_commands">
|
||||
<command id="publish_calendar" oncommand="ltnPublishCalendar()"/>
|
||||
|
@ -44,6 +44,7 @@ calendar.jar:
|
||||
content/calendar/calendar-decorated-month-view.xml (/calendar/base/content/calendar-decorated-month-view.xml)
|
||||
content/calendar/calendar-decorated-views.css (/calendar/base/content/calendar-decorated-views.css)
|
||||
content/calendar/calendar-view-bindings.css (/calendar/base/content/calendar-view-bindings.css)
|
||||
content/calendar/calendar-views.js (/calendar/base/content/calendar-views.js)
|
||||
content/calendar/calendar-multiday-view.xml (/calendar/base/content/calendar-multiday-view.xml)
|
||||
content/calendar/calendar-month-view.xml (/calendar/base/content/calendar-month-view.xml)
|
||||
content/calendar/calendar-view-core.xml (/calendar/base/content/calendar-view-core.xml)
|
||||
|
@ -224,7 +224,7 @@ function deleteCalendar(event)
|
||||
result);
|
||||
|
||||
if (ok) {
|
||||
getDisplayComposite().removeCalendar(calendar.uri);
|
||||
getCompositeCalendar().removeCalendar(calendar.uri);
|
||||
var calMgr = getCalendarManager();
|
||||
calMgr.unregisterCalendar(calendar);
|
||||
// Delete file?
|
||||
@ -589,7 +589,7 @@ function openLocalCalendar() {
|
||||
|
||||
var url = fp.fileURL.spec;
|
||||
var calMgr = getCalendarManager();
|
||||
var composite = getDisplayComposite();
|
||||
var composite = getCompositeCalendar();
|
||||
var openCalendar = calMgr.createCalendar("ics", makeURL(url));
|
||||
calMgr.registerCalendar(openCalendar);
|
||||
|
||||
|
@ -60,7 +60,7 @@ var calCalendarManagerObserver = {
|
||||
|
||||
onCalendarRegistered: function(aCalendar) {
|
||||
// Enable new calendars by default
|
||||
getDisplayComposite().addCalendar(aCalendar);
|
||||
getCompositeCalendar().addCalendar(aCalendar);
|
||||
setCalendarManagerUI();
|
||||
document.getElementById("new_command").removeAttribute("disabled");
|
||||
document.getElementById("new_todo_command").removeAttribute("disabled");
|
||||
@ -190,9 +190,9 @@ function onCalendarCheckboxClick(event) {
|
||||
|
||||
var cal = event.target.calendar;
|
||||
if (checkElem.getAttribute('checked') == "true") {
|
||||
getDisplayComposite().removeCalendar(cal.uri);
|
||||
getCompositeCalendar().removeCalendar(cal.uri);
|
||||
} else {
|
||||
getDisplayComposite().addCalendar(cal);
|
||||
getCompositeCalendar().addCalendar(cal);
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
@ -207,7 +207,7 @@ function setCalendarManagerUI()
|
||||
calendarList.removeChild(child);
|
||||
}
|
||||
|
||||
var composite = getDisplayComposite();
|
||||
var composite = getCompositeCalendar();
|
||||
var calmgr = getCalendarManager();
|
||||
var calendars = calmgr.getCalendars({});
|
||||
var hasRefreshableCal = false;
|
||||
@ -256,13 +256,13 @@ function onCalendarListSelect() {
|
||||
if (!selectedCalendar) {
|
||||
return;
|
||||
}
|
||||
getDisplayComposite().defaultCalendar = selectedCalendar;
|
||||
getCompositeCalendar().defaultCalendar = selectedCalendar;
|
||||
}
|
||||
|
||||
function initCalendarManager()
|
||||
{
|
||||
var calMgr = getCalendarManager();
|
||||
var composite = getDisplayComposite();
|
||||
var composite = getCompositeCalendar();
|
||||
if (calMgr.getCalendars({}).length == 0) {
|
||||
var homeCalendar = calMgr.createCalendar("storage", makeURL("moz-profile-calendar://"));
|
||||
calMgr.registerCalendar(homeCalendar);
|
||||
@ -314,7 +314,7 @@ function getDefaultCalendar()
|
||||
|
||||
function reloadCalendars()
|
||||
{
|
||||
getDisplayComposite().refresh();
|
||||
getCompositeCalendar().refresh();
|
||||
}
|
||||
|
||||
function getCalendarStyleSheet() {
|
||||
@ -412,6 +412,17 @@ var categoryPrefObserver =
|
||||
}
|
||||
}
|
||||
|
||||
var gCompositeCalendar = null;
|
||||
function getCompositeCalendar()
|
||||
{
|
||||
if (!gCompositeCalendar) {
|
||||
gCompositeCalendar = Components.classes["@mozilla.org/calendar/calendar;1?type=composite"]
|
||||
.createInstance(Components.interfaces.calICompositeCalendar);
|
||||
gCompositeCalendar.prefPrefix = 'calendar-main';
|
||||
}
|
||||
return gCompositeCalendar;
|
||||
}
|
||||
|
||||
var calPrefObserver =
|
||||
{
|
||||
observe: function(aSubject, aTopic, aPrefName)
|
||||
|
@ -47,17 +47,6 @@ function getCalendarManager()
|
||||
return calendarManager;
|
||||
}
|
||||
|
||||
var gDisplayComposite = null;
|
||||
function getDisplayComposite()
|
||||
{
|
||||
if (!gDisplayComposite) {
|
||||
gDisplayComposite = Components.classes["@mozilla.org/calendar/calendar;1?type=composite"]
|
||||
.createInstance(Components.interfaces.calICompositeCalendar);
|
||||
gDisplayComposite.prefPrefix = 'calendar-main';
|
||||
}
|
||||
return gDisplayComposite;
|
||||
}
|
||||
|
||||
function openCalendarWizard(callback)
|
||||
{
|
||||
openDialog("chrome://calendar/content/calendarCreation.xul", "caEditServer", "chrome,titlebar,modal", callback);
|
||||
|
@ -41,90 +41,6 @@
|
||||
* C A L E N D A R C L A S S E S
|
||||
*/
|
||||
|
||||
function calViewController() {}
|
||||
|
||||
calViewController.prototype.QueryInterface = function(aIID) {
|
||||
if (!aIID.equals(Components.interfaces.nsISupports) &&
|
||||
!aIID.equals(Components.interfaces.calICalendarViewController)) {
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
calViewController.prototype.createNewEvent = function (aCalendar, aStartTime, aEndTime) {
|
||||
if (aStartTime && aEndTime && !aStartTime.isDate && !aEndTime.isDate) {
|
||||
var event = createEvent();
|
||||
event.startDate = aStartTime;
|
||||
event.endDate = aEndTime;
|
||||
event.title = calGetString("calendar", "newEvent");
|
||||
setDefaultAlarmValues(event);
|
||||
doTransaction('add', event, aCalendar, null, null);
|
||||
} else if (aStartTime && aStartTime.isDate) {
|
||||
var event = createEvent();
|
||||
event.startDate = aStartTime;
|
||||
setDefaultAlarmValues(event);
|
||||
doTransaction('add', event, aCalendar, null, null);
|
||||
} else {
|
||||
newEvent();
|
||||
}
|
||||
}
|
||||
|
||||
calViewController.prototype.modifyOccurrence = function (aOccurrence, aNewStartTime, aNewEndTime) {
|
||||
if (aNewStartTime && aNewEndTime && !aNewStartTime.isDate
|
||||
&& !aNewEndTime.isDate) {
|
||||
var itemToEdit = getOccurrenceOrParent(aOccurrence);
|
||||
if (!itemToEdit) {
|
||||
return;
|
||||
}
|
||||
var instance = itemToEdit.clone();
|
||||
|
||||
var newStartTime = aNewStartTime;
|
||||
var newEndTime = aNewEndTime;
|
||||
|
||||
// if we're about to modify the parentItem, we need to account
|
||||
// for the possibility that the item passed as argument was
|
||||
// some other occurrence, but the user said she would like to
|
||||
// modify all occurrences instead.
|
||||
if (instance.parentItem == instance) {
|
||||
var instanceStart = instance.startDate || instance.entryDate;
|
||||
var occurrenceStart = aOccurrence.startDate || aOccurrence.entryDate;
|
||||
var startDiff = instanceStart.subtractDate(occurrenceStart);
|
||||
aNewStartTime.addDuration(startDiff);
|
||||
var instanceEnd = instance.endDate || instance.dueDate;
|
||||
var occurrenceEnd = aOccurrence.endDate || aOccurrence.dueDate;
|
||||
var endDiff = instanceEnd.subtractDate(occurrenceEnd);
|
||||
aNewEndTime.addDuration(endDiff);
|
||||
}
|
||||
|
||||
if (instance instanceof Components.interfaces.calIEvent) {
|
||||
instance.startDate = aNewStartTime;
|
||||
instance.endDate = aNewEndTime;
|
||||
} else {
|
||||
instance.entryDate = aNewStartTime;
|
||||
instance.dueDate = aNewEndTime;
|
||||
}
|
||||
doTransaction('modify', instance, instance.calendar, itemToEdit, null);
|
||||
} else {
|
||||
editEvent();
|
||||
}
|
||||
}
|
||||
|
||||
calViewController.prototype.deleteOccurrence = function (aOccurrence) {
|
||||
var itemToDelete = getOccurrenceOrParent(aOccurrence);
|
||||
if (!itemToDelete) {
|
||||
return;
|
||||
}
|
||||
if (itemToDelete.parentItem != itemToDelete) {
|
||||
var event = itemToDelete.parentItem.clone();
|
||||
event.recurrenceInfo.removeOccurrenceAt(itemToDelete.recurrenceId);
|
||||
doTransaction('modify', event, event.calendar, itemToDelete.parentItem, null);
|
||||
} else {
|
||||
doTransaction('delete', itemToDelete, itemToDelete.calendar, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
var gViewController = new calViewController();
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
* CalendarWindow Class
|
||||
*
|
||||
@ -148,7 +64,11 @@ function CalendarWindow( )
|
||||
{
|
||||
//setup the calendar event selection
|
||||
this.EventSelection = new CalendarEventSelection( this );
|
||||
gViewController.selectionManager = this.EventSelection;
|
||||
calendarViewController.selectionManager = this.EventSelection;
|
||||
|
||||
// Extension authors can tweak this array to make gCalendarWindow.switchToView
|
||||
// play nicely with any additional views
|
||||
this.availableViews = ["day", "week", "multiweek", "month"];
|
||||
|
||||
/** This object only exists to keep too many things from breaking during the
|
||||
* switch to the new views
|
||||
@ -203,83 +123,21 @@ function CalendarWindow( )
|
||||
switch( SelectedIndex )
|
||||
{
|
||||
case "1":
|
||||
this.switchToWeekView();
|
||||
this.switchToView('week');
|
||||
break;
|
||||
case "2":
|
||||
this.switchToMultiweekView();
|
||||
this.switchToView('multiweek');
|
||||
break;
|
||||
case "3":
|
||||
this.switchToMonthView();
|
||||
this.switchToView('month');
|
||||
break;
|
||||
case "0":
|
||||
default:
|
||||
this.switchToDayView();
|
||||
this.switchToView('day');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Switch to the day view if it isn't already the current view
|
||||
*/
|
||||
|
||||
CalendarWindow.prototype.switchToDayView = function calWin_switchToDayView( )
|
||||
{
|
||||
document.getElementById("month_view_command").removeAttribute("checked");
|
||||
document.getElementById("multiweek_view_command").removeAttribute("checked");
|
||||
document.getElementById("week_view_command").removeAttribute("checked");
|
||||
document.getElementById("day_view_command").setAttribute("checked", true);
|
||||
document.getElementById("menu-numberofweeks-inview").setAttribute("disabled", true);
|
||||
this.switchToView('day-view');
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Switch to the week view if it isn't already the current view
|
||||
*/
|
||||
|
||||
CalendarWindow.prototype.switchToWeekView = function calWin_switchToWeekView( )
|
||||
{
|
||||
document.getElementById("month_view_command").removeAttribute("checked");
|
||||
document.getElementById("multiweek_view_command").removeAttribute("checked");
|
||||
document.getElementById("day_view_command").removeAttribute("checked");
|
||||
document.getElementById("week_view_command").setAttribute("checked", true);
|
||||
document.getElementById("menu-numberofweeks-inview").setAttribute("disabled", true);
|
||||
this.switchToView('week-view');
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Switch to the month view if it isn't already the current view
|
||||
*/
|
||||
|
||||
CalendarWindow.prototype.switchToMonthView = function calWin_switchToMonthView( )
|
||||
{
|
||||
document.getElementById("week_view_command").removeAttribute("checked");
|
||||
document.getElementById("multiweek_view_command").removeAttribute("checked");
|
||||
document.getElementById("day_view_command").removeAttribute("checked");
|
||||
document.getElementById("month_view_command").setAttribute("checked", true);
|
||||
document.getElementById("menu-numberofweeks-inview").setAttribute("disabled", true);
|
||||
this.switchToView('month-view');
|
||||
}
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Switch to the multiweek view if it isn't already the current view
|
||||
*/
|
||||
|
||||
CalendarWindow.prototype.switchToMultiweekView = function calWin_switchToMultiweekView( )
|
||||
{
|
||||
document.getElementById("month_view_command").removeAttribute("checked");
|
||||
document.getElementById("week_view_command").removeAttribute("checked");
|
||||
document.getElementById("day_view_command").removeAttribute("checked");
|
||||
document.getElementById("multiweek_view_command").setAttribute("checked", true);
|
||||
document.getElementById("menu-numberofweeks-inview").removeAttribute("disabled");
|
||||
this.switchToView('multiweek-view');
|
||||
}
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Display today in the current view
|
||||
@ -309,28 +167,6 @@ CalendarWindow.prototype.pickAndGoToDate = function calWin_pickAndGoToDate( )
|
||||
"chrome,modal", args);
|
||||
}
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Go to the next period in the current view
|
||||
*/
|
||||
|
||||
CalendarWindow.prototype.goToNext = function calWin_goToNext( value )
|
||||
{
|
||||
document.getElementById("view-deck").selectedPanel.moveView(value);
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Go to the previous period in the current view
|
||||
*/
|
||||
|
||||
CalendarWindow.prototype.goToPrevious = function calWin_goToPrevious( value )
|
||||
{
|
||||
document.getElementById("view-deck").selectedPanel.moveView(-1*value);
|
||||
}
|
||||
|
||||
|
||||
/** PUBLIC
|
||||
*
|
||||
* Go to today in the current view
|
||||
@ -373,33 +209,31 @@ CalendarWindow.prototype.getSelectedDate = function calWin_getSelectedDate( )
|
||||
|
||||
CalendarWindow.prototype.switchToView = function calWin_switchToView( newView )
|
||||
{
|
||||
var viewElement = document.getElementById(newView);
|
||||
|
||||
// If this is the first time we've shown the view, (or if someone changed
|
||||
// our composite), then we need to set all this stuff.
|
||||
if (viewElement.displayCalendar != getDisplayComposite()) {
|
||||
viewElement.controller = gViewController;
|
||||
viewElement.displayCalendar = getDisplayComposite();
|
||||
viewElement.timezone = calendarDefaultTimezone();
|
||||
this.EventSelection.addObserver(viewElement.selectionObserver);
|
||||
// Set up the commands
|
||||
for each (var view in this.availableViews) {
|
||||
var command = document.getElementById(view+"_view_command");
|
||||
if (view == newView) {
|
||||
command.setAttribute("checked", true);
|
||||
} else {
|
||||
command.removeAttribute("checked");
|
||||
}
|
||||
}
|
||||
|
||||
var deck = document.getElementById("view-deck");
|
||||
var day;
|
||||
try {
|
||||
day = deck.selectedPanel.selectedDay;
|
||||
} catch(ex) {} // Fails if no view has ever been shown this session
|
||||
var mwWeeksCommand = document.getElementById("menu-numberofweeks-inview")
|
||||
if (newView == "multiweek") {
|
||||
mwWeeksCommand.removeAttribute("disabled");
|
||||
} else {
|
||||
mwWeeksCommand.setAttribute("disabled", true);
|
||||
}
|
||||
|
||||
// Should only happen on first startup
|
||||
if (!day)
|
||||
day = now();
|
||||
deck.selectedPanel = viewElement;
|
||||
deck.selectedPanel.goToDay(day);
|
||||
// Call the common view switching code in calendar-views.js
|
||||
switchToView(newView);
|
||||
|
||||
var labelAttribute = "label-"+newView+"-view";
|
||||
var prevCommand = document.getElementById("calendar-go-menu-previous");
|
||||
prevCommand.setAttribute("label", prevCommand.getAttribute("label-"+newView));
|
||||
prevCommand.setAttribute("label", prevCommand.getAttribute(labelAttribute));
|
||||
var nextCommand = document.getElementById("calendar-go-menu-next");
|
||||
nextCommand.setAttribute("label", nextCommand.getAttribute("label-"+newView));
|
||||
nextCommand.setAttribute("label", nextCommand.getAttribute(labelAttribute));
|
||||
}
|
||||
|
||||
CalendarWindow.prototype.onMouseUpCalendarSplitter = function calWinOnMouseUpCalendarSplitter()
|
||||
|
@ -102,7 +102,7 @@ function loadCalendarPrintDialog()
|
||||
|
||||
|
||||
function printCalendar() {
|
||||
var ccalendar = getDisplayComposite();
|
||||
var ccalendar = getCompositeCalendar();
|
||||
var start;
|
||||
var end;
|
||||
var eventList;
|
||||
|
@ -259,7 +259,7 @@ function prepareCalendarUnifinder( )
|
||||
|
||||
// set up our calendar event observer
|
||||
|
||||
var ccalendar = getDisplayComposite();
|
||||
var ccalendar = getCompositeCalendar();
|
||||
ccalendar.addObserver(unifinderObserver);
|
||||
|
||||
kDefaultTimezone = calendarDefaultTimezone();
|
||||
@ -277,7 +277,7 @@ function prepareCalendarUnifinder( )
|
||||
|
||||
function finishCalendarUnifinder( )
|
||||
{
|
||||
var ccalendar = getDisplayComposite();
|
||||
var ccalendar = getCompositeCalendar();
|
||||
ccalendar.removeObserver(unifinderObserver);
|
||||
}
|
||||
|
||||
@ -681,7 +681,7 @@ function refreshEventTree( eventArray )
|
||||
var StartDate = new Date( Today.getFullYear(), Today.getMonth(), Today.getDate(), 0, 0, 0 );
|
||||
var EndDate;
|
||||
|
||||
var ccalendar = getDisplayComposite();
|
||||
var ccalendar = getCompositeCalendar();
|
||||
var filter = 0;
|
||||
|
||||
filter |= ccalendar.ITEM_FILTER_TYPE_EVENT;
|
||||
|
@ -120,7 +120,7 @@ var unifinderToDoDataSourceObserver =
|
||||
|
||||
function prepareCalendarToDoUnifinder()
|
||||
{
|
||||
var ccalendar = getDisplayComposite();
|
||||
var ccalendar = getCompositeCalendar();
|
||||
ccalendar.addObserver(unifinderToDoDataSourceObserver);
|
||||
toDoUnifinderRefresh();
|
||||
}
|
||||
@ -131,7 +131,7 @@ function prepareCalendarToDoUnifinder()
|
||||
|
||||
function finishCalendarToDoUnifinder()
|
||||
{
|
||||
var ccalendar = getDisplayComposite();
|
||||
var ccalendar = getCompositeCalendar();
|
||||
ccalendar.removeObserver(unifinderToDoDataSourceObserver);
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ function toDoUnifinderRefresh()
|
||||
}
|
||||
};
|
||||
|
||||
var ccalendar = getDisplayComposite();
|
||||
var ccalendar = getCompositeCalendar();
|
||||
var filter = 0;
|
||||
if (hideCompleted)
|
||||
filter |= ccalendar.ITEM_FILTER_COMPLETED_NO;
|
||||
|
@ -76,6 +76,7 @@
|
||||
<script type="application/x-javascript" src="chrome://calendar/content/mouseoverPreviews.js"/>
|
||||
<script type="application/x-javascript" src="chrome://calendar/content/unifinder.js"/>
|
||||
<script type="application/x-javascript" src="chrome://calendar/content/unifinderToDo.js"/>
|
||||
<script type="application/x-javascript" src="chrome://calendar/content/calendar-views.js"/>
|
||||
|
||||
<!-- NEEDED FOR APPLICATION SUPPORT -->
|
||||
<script type="application/x-javascript" src="chrome://calendar/content/applicationUtil.js"/>
|
||||
|
@ -76,10 +76,10 @@
|
||||
<command id="go_today_command" oncommand="gCalendarWindow.goToToday()"/>
|
||||
<command id="go_date_command" oncommand="gCalendarWindow.pickAndGoToDate()"/>
|
||||
|
||||
<command id="day_view_command" oncommand="gCalendarWindow.switchToDayView()"/>
|
||||
<command id="week_view_command" oncommand="gCalendarWindow.switchToWeekView()"/>
|
||||
<command id="month_view_command" oncommand="gCalendarWindow.switchToMonthView()"/>
|
||||
<command id="multiweek_view_command" oncommand="gCalendarWindow.switchToMultiweekView()"/>
|
||||
<command id="day_view_command" oncommand="gCalendarWindow.switchToView('day')"/>
|
||||
<command id="week_view_command" oncommand="gCalendarWindow.switchToView('week')"/>
|
||||
<command id="month_view_command" oncommand="gCalendarWindow.switchToView('month')"/>
|
||||
<command id="multiweek_view_command" oncommand="gCalendarWindow.switchToView('multiweek')"/>
|
||||
|
||||
<command id="import_command" oncommand="loadEventsFromFile()"/>
|
||||
<command id="export_command" oncommand="saveEventsToFile(gCalendarWindow.EventSelection.selectedEvents)" disabled="true" disabledwhennoeventsselected="true"/>
|
||||
|
Loading…
Reference in New Issue
Block a user