releases-comm-central/calendar/base/content/calendar-views.xml

270 строки
12 KiB
XML

<?xml version="1.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 Sun Microsystems code.
-
- The Initial Developer of the Original Code is Sun Microsystems.
- Portions created by the Initial Developer are Copyright (C) 2009
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Berend Cornelius <berend.cornelius@sun.com>
- Joey Minta <jminta@gmail.com>
- Markus Adrario <MarkusAdrario@web.de>
- Philipp Kewisch <mozilla@kewis.ch>
- Dan Mosedale <dan.mosedale@oracle.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 *****
-->
<bindings id="calendar-specific-view-bindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="calendar-day-view"
extends="chrome://calendar/content/calendar-multiday-view.xml#calendar-multiday-view">
<implementation implements="calICalendarView">
<property name="observerID">
<getter><![CDATA[
return "day-view-observer";
]]></getter>
</property>
<!--Public methods-->
<method name="goToDay">
<parameter name="aDate"/>
<body><![CDATA[
aDate = aDate.getInTimezone(this.timezone);
this.setDateRange(aDate, aDate);
var toolTips = calGetStringArray("calendar",
["oneDayBack", "gotoToday", "oneDayForward"]);
cal.navigationBar.setDateRange(aDate, aDate, toolTips);
this.selectedDay = aDate;
]]></body>
</method>
<method name="moveView">
<parameter name="aNumber"/>
<body><![CDATA[
if (!aNumber) {
this.goToDay(now());
} else {
var currentDay = this.startDay.clone();
currentDay.day += aNumber;
this.goToDay(currentDay);
}
]]></body>
</method>
</implementation>
</binding>
<binding id="calendar-week-view"
extends="chrome://calendar/content/calendar-multiday-view.xml#calendar-multiday-view">
<implementation implements="calICalendarView">
<property name="observerID">
<getter><![CDATA[
return "week-view-observer";
]]></getter>
</property>
<!--Public methods-->
<method name="goToDay">
<parameter name="aDate"/>
<body><![CDATA[
this.displayDaysOff = !this.mWorkdaysOnly;
aDate = aDate.getInTimezone(this.timezone);
var d1 = getWeekInfoService().getStartOfWeek(aDate);
var d2 = d1.clone();
d2.day += 6;
this.setDateRange(d1, d2);
var toolTips = calGetStringArray("calendar",
["oneWeekBack", "gotoToday", "oneWeekForward"]);
cal.navigationBar.setDateRange(d1, d2, toolTips);
this.selectedDay = aDate;
]]></body>
</method>
<method name="moveView">
<parameter name="aNumber"/>
<body><![CDATA[
if (!aNumber) {
this.goToDay(now());
} else {
var d1 = this.selectedDay.clone();
d1.day += 7 * aNumber;
this.goToDay(d1);
}
]]></body>
</method>
</implementation>
</binding>
<binding id="calendar-multiweek-view" extends="chrome://calendar/content/calendar-month-view.xml#calendar-month-base-view">
<implementation implements="calICalendarView">
<constructor><![CDATA[
this.mWeeksInView = getPrefSafe("calendar.weeks.inview", 4);
]]></constructor>
<field name="mWeeksInView">4</field>
<property name="weeksInView">
<getter><![CDATA[
return this.mWeeksInView;
]]></getter>
<setter><![CDATA[
this.mWeeksInView = val;
setPref("calendar.weeks.inview", val);
this.refreshView();
return val;
]]></setter>
</property>
<property name="observerID">
<getter><![CDATA[
return "multiweek-view-observer";
]]></getter>
</property>
<!--Public methods-->
<method name="goToDay">
<parameter name="aDate"/>
<body><![CDATA[
this.showFullMonth = false;
this.displayDaysOff = !this.mWorkdaysOnly;
aDate = aDate.getInTimezone(this.timezone);
// Get the first date that should be shown. This is the
// start of the week of the day that we're centering around
// adjusted for the day the week starts on and the number
// of previous weeks we're supposed to display.
let d1 = getWeekInfoService().getStartOfWeek(aDate);
d1.day -= (7 * getPrefSafe("calendar.previousweeks.inview", 0));
// The last day we're supposed to show
let d2 = d1.clone();
d2.day += ((7 * this.mWeeksInView) - 1);
this.setDateRange(d1,d2);
let toolTips = calGetStringArray("calendar",
["oneWeekBack", "gotoToday", "oneWeekForward"]);
cal.navigationBar.setDateRange(d1,d2, toolTips);
this.selectedDay = aDate;
]]></body>
</method>
<method name="moveView">
<parameter name="aNumber"/>
<body><![CDATA[
if (!aNumber) {
let date = now();
this.goToDay(date);
this.selectedDay = date;
} else {
let d1 = this.startDay.clone();
let savedSelectedDay = this.selectedDay.clone();
// aNumber only corresponds to the number of weeks to move
// make sure to compensate for previous weeks in view too
d1.day += 7 * (aNumber + getPrefSafe("calendar.previousweeks.inview", 4));
this.goToDay(d1);
savedSelectedDay.day += 7 * aNumber;
this.selectedDay = savedSelectedDay;
}
]]></body>
</method>
</implementation>
</binding>
<binding id="calendar-month-view" extends="chrome://calendar/content/calendar-month-view.xml#calendar-month-base-view">
<implementation implements="calICalendarView">
<property name="observerID">
<getter><![CDATA[
return "month-view-observer";
]]></getter>
</property>
<!--Public methods-->
<method name="goToDay">
<parameter name="aDate"/>
<body><![CDATA[
this.displayDaysOff = !this.mWorkdaysOnly;
aDate = aDate.getInTimezone(this.timezone);
this.setDateRange(aDate.startOfMonth, aDate.endOfMonth);
let toolTips = calGetStringArray("calendar",
["oneMonthBack", "gotoToday", "oneMonthForward"]);
cal.navigationBar.setDateRange(aDate.startOfMonth, aDate.endOfMonth, toolTips);
this.showDate(aDate);
this.selectedDay = aDate;
]]></body>
</method>
<method name="getRangeDescription">
<body><![CDATA[
let monthName = calGetString("dateFormat", "month." + (this.rangeStartDate.month + 1) + ".name");
return calGetString("calendar", "monthInYear", [monthName, this.rangeStartDate.year]);
]]></body>
</method>
<method name="moveView">
<parameter name="aNumber"/>
<body><![CDATA[
let dates = this.getDateList({});
this.displayDaysOff = !this.mWorkdaysOnly;
if (!aNumber) {
let date = now();
this.goToDay(date);
this.selectedDay = date;
} else {
// The first few dates in this list are likely in the month
// prior to the one actually being shown (since the month
// probably doesn't start on a Sunday). The 7th item must
// be in correct month though.
let date = dates[6].clone();
date.month += aNumber;
// Need to store this before we move
let oldSelectedDay = this.selectedDay;
this.goToDay(date);
// Most of the time we want to select the date with the
// same day number in the next month
let newSelectedDay = oldSelectedDay.clone();
newSelectedDay.month += aNumber;
// correct for accidental rollover into the next month
if ((newSelectedDay.month - aNumber + 12) % 12 != oldSelectedDay.month) {
newSelectedDay.month -= 1;
newSelectedDay.day = newSelectedDay.endOfMonth.day;
}
this.selectedDay = newSelectedDay;
}
]]></body>
</method>
</implementation>
</binding>
</bindings>