Fix bug 489590 - Make views more extensible. r=dbo
This commit is contained in:
Родитель
7f3eacb8ea
Коммит
d545ad582c
|
@ -381,6 +381,10 @@
|
|||
onget="return this.startDate;"/>
|
||||
<property name="endDay" readonly="true"
|
||||
onget="return this.endDate;"/>
|
||||
<property name="supportDisjointDates" readonly="true"
|
||||
onget="return false;"/>
|
||||
<property name="hasDisjointDates" readonly="true"
|
||||
onget="return false;"/>
|
||||
<property name="rangeStartDate"
|
||||
onget="return this.mRangeStartDate;"
|
||||
onset="return (this.mRangeStartDate = val);"/>
|
||||
|
@ -665,20 +669,87 @@
|
|||
}
|
||||
this.daysOffArray = daysOff;
|
||||
]]></body>
|
||||
</method>
|
||||
</method>
|
||||
|
||||
<method name="refreshView">
|
||||
<body><![CDATA[
|
||||
if (!this.startDay || !this.endDay) {
|
||||
// don't refresh if we're not initialized
|
||||
return;
|
||||
}
|
||||
// Just refresh, the goToDay function will notice
|
||||
this.goToDay(this.selectedDay);
|
||||
]]></body>
|
||||
</method>
|
||||
<method name="refreshView">
|
||||
<body><![CDATA[
|
||||
if (!this.startDay || !this.endDay) {
|
||||
// don't refresh if we're not initialized
|
||||
return;
|
||||
}
|
||||
// Just refresh, the goToDay function will notice
|
||||
this.goToDay(this.selectedDay);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- Default implementations follow, these make things easier for
|
||||
extensions that don't need certain features. -->
|
||||
<method name="handlePreference">
|
||||
<parameter name="aSubject"/>
|
||||
<parameter name="aTopic"/>
|
||||
<parameter name="aPref"/>
|
||||
<body><![CDATA[
|
||||
// Do nothing by default
|
||||
]]></body>
|
||||
</method>
|
||||
<method name="setDateRange">
|
||||
<parameter name="aStartDate"/>
|
||||
<parameter name="aEndDate"/>
|
||||
<body><![CDATA[
|
||||
cal.navigationBar.setDateRange(aStartDate, aEndDate);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<property name="selectedDay"
|
||||
onget="return this.startDate"
|
||||
onset="return this.startDate"/>
|
||||
|
||||
<method name="getSelectedItems">
|
||||
<parameter name="aCount"/>
|
||||
<body><![CDATA[
|
||||
aCount.value = this.mSelectedItems.length;
|
||||
return this.mSelectedItems;
|
||||
]]></body>
|
||||
</method>
|
||||
<method name="setSelectedItems">
|
||||
<parameter name="aCount"/>
|
||||
<parameter name="aItems"/>
|
||||
<body><![CDATA[
|
||||
this.mSelectedItems = aItems.concat([]);
|
||||
return this.mSelectedItems;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="setDateList">
|
||||
<parameter name="aCount"/>
|
||||
<parameter name="aDates"/>
|
||||
<body><![CDATA[
|
||||
throw Components.results.NS_ERROR_FAILURE;
|
||||
]]></body>
|
||||
</method>
|
||||
<method name="getDateList">
|
||||
<parameter name="aCount"/>
|
||||
<parameter name="aDates"/>
|
||||
<body><![CDATA[
|
||||
let start = this.startDate.clone();
|
||||
while (start.compare(this.endDate) <= 0) {
|
||||
dates.push(start);
|
||||
start.day++;
|
||||
}
|
||||
aCount.value = dates.length;
|
||||
return dates;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="flashAlarm">
|
||||
<parameter name="aAlarmItem"/>
|
||||
<parameter name="aStop"/>
|
||||
<body><![CDATA[
|
||||
// Do nothing by default
|
||||
]]></body>
|
||||
</method>
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
<handler event="move">
|
||||
<![CDATA[
|
||||
|
|
|
@ -710,6 +710,9 @@
|
|||
this.mStartDate = getWeekInfoService().getStartOfWeek(aStartDate.getInTimezone(this.mTimezone))
|
||||
this.mEndDate = getWeekInfoService().getEndOfWeek(aEndDate.getInTimezone(this.mTimezone));
|
||||
this.refresh();
|
||||
|
||||
// Update the navigation bar.
|
||||
cal.navigationBar.setDateRange(aStartDate, aEndDate);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
|
|
@ -2411,6 +2411,9 @@
|
|||
}
|
||||
this.setDateList(dateList.length, dateList);
|
||||
}
|
||||
|
||||
// Update the navigation bar.
|
||||
cal.navigationBar.setDateRange(startDate, endDate);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
|
|
@ -323,17 +323,37 @@ function switchToView(aViewType) {
|
|||
var command = document.getElementById(commandId);
|
||||
if (view.id == aViewType + "-view") {
|
||||
command.setAttribute("checked", "true");
|
||||
document.getElementById("calendar-nav-control").setAttribute("selectedIndex", i);
|
||||
} else {
|
||||
command.removeAttribute("checked");
|
||||
}
|
||||
}
|
||||
|
||||
// Set the labels for the context-menu
|
||||
var nextCommand = document.getElementById("calendar-view-context-menu-next");
|
||||
nextCommand.setAttribute("label", nextCommand.getAttribute("label-"+aViewType));
|
||||
var previousCommand = document.getElementById("calendar-view-context-menu-previous")
|
||||
previousCommand.setAttribute("label", previousCommand.getAttribute("label-"+aViewType));
|
||||
/**
|
||||
* Sets up a node to use view specific attributes. If there is no view
|
||||
* specific attribute, then <attr>-all is used instead.
|
||||
*
|
||||
* @param id The id of the node to set up.
|
||||
* @param attr The view specific attribute to modify.
|
||||
*/
|
||||
function setupViewNode(id, attr) {
|
||||
let node = document.getElementById(id);
|
||||
if (node.hasAttribute(attr + "-" + aViewType)) {
|
||||
node.setAttribute(attr, node.getAttribute(attr + "-" + aViewType));
|
||||
} else {
|
||||
node.setAttribute(attr, node.getAttribute(attr + "-all"));
|
||||
}
|
||||
}
|
||||
|
||||
// Set up the labels for the context menu
|
||||
["calendar-view-context-menu-next",
|
||||
"calendar-view-context-menu-previous"].forEach(function(x) setupViewNode(x, "label"));
|
||||
|
||||
// Set up the labels for the view navigation
|
||||
["previous-view-button",
|
||||
"today-view-button",
|
||||
"next-view-button"].forEach(function(x) setupViewNode(x, "tooltiptext"));
|
||||
|
||||
|
||||
|
||||
// Disable the menuitem when not in day or week view.
|
||||
var rotated = document.getElementById("calendar_toggle_orientation_command");
|
||||
|
@ -356,10 +376,14 @@ function switchToView(aViewType) {
|
|||
}
|
||||
|
||||
// Anyone wanting to plug in a view needs to follow this naming scheme
|
||||
var view = document.getElementById(aViewType + "-view");
|
||||
let view = document.getElementById(aViewType + "-view");
|
||||
viewDeck.selectedPanel = view;
|
||||
|
||||
var compositeCal = getCompositeCalendar();
|
||||
// Select the corresponding tab
|
||||
let viewTabs = document.getElementById("view-tabs");
|
||||
viewTabs.selectedIndex = getViewDeck().selectedIndex;
|
||||
|
||||
let compositeCal = getCompositeCalendar();
|
||||
if (view.displayCalendar != compositeCal) {
|
||||
view.displayCalendar = compositeCal;
|
||||
view.timezone = calendarDefaultTimezone();
|
||||
|
@ -799,7 +823,7 @@ function selectAllEvents() {
|
|||
|
||||
let cal = cal || {};
|
||||
cal.navigationBar = {
|
||||
setDateRange: function setDateRange(aStartDate, aEndDate, aToolTipTexts) {
|
||||
setDateRange: function setDateRange(aStartDate, aEndDate) {
|
||||
let docTitle = "";
|
||||
if (aStartDate) {
|
||||
let intervalLabel = document.getElementById("intervalDescription");
|
||||
|
@ -819,9 +843,6 @@ cal.navigationBar = {
|
|||
weekLabel.value = calGetString("calendar", "severalShortCalendarWeeks", [firstWeekNo, secondWeekNo]);
|
||||
weekLabel.tooltipText = calGetString("calendar", "severalLongCalendarWeeks", [firstWeekNo, secondWeekNo]);
|
||||
}
|
||||
document.getElementById("previous-view-button").setAttribute("tooltiptext", aToolTipTexts[0]);
|
||||
document.getElementById("today-view-button").setAttribute("tooltiptext", aToolTipTexts[1]);
|
||||
document.getElementById("next-view-button").setAttribute("tooltiptext", aToolTipTexts[2]);
|
||||
docTitle = intervalLabel.value;
|
||||
}
|
||||
if (document.getElementById("modeBroadcaster").getAttribute("mode") == "calendar") {
|
||||
|
|
|
@ -63,9 +63,6 @@
|
|||
<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>
|
||||
|
@ -104,9 +101,6 @@
|
|||
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>
|
||||
|
@ -170,9 +164,6 @@
|
|||
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>
|
||||
|
@ -215,9 +206,6 @@
|
|||
|
||||
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>
|
||||
|
@ -267,4 +255,4 @@
|
|||
</method>
|
||||
</implementation>
|
||||
</binding>
|
||||
</bindings>
|
||||
</bindings>
|
||||
|
|
|
@ -53,19 +53,32 @@
|
|||
<hbox id="calendar-nav-control">
|
||||
<vbox flex="1">
|
||||
<hbox flex="1" class="navigation-inner-box" align="end">
|
||||
<!-- If you are extending a view, add attributes to these
|
||||
nodes for your view. i.e if your view has the id
|
||||
"foobar-view", then you need to add the attribute
|
||||
tooltiptext-foobar="..." -->
|
||||
<toolbarbutton id="previous-view-button"
|
||||
class="view-navigation-button"
|
||||
chromedir="&locale.dir;"
|
||||
type="prev"
|
||||
tooltiptext-day="&calendar.navigation.prevday.tooltip;"
|
||||
tooltiptext-week="&calendar.navigation.prevweek.tooltip;"
|
||||
tooltiptext-multiweek="&calendar.navigation.prevweek.tooltip;"
|
||||
tooltiptext-month="&calendar.navigation.prevmonth.tooltip;"
|
||||
command="calendar_view_prev_command"/>
|
||||
<toolbarbutton id="today-view-button"
|
||||
class="today-navigation-button"
|
||||
label="&calendar.today.button.label;"
|
||||
tooltiptext-all="&calendar.today.button.tooltip;"
|
||||
command="calendar_view_today_command"/>
|
||||
<toolbarbutton id="next-view-button"
|
||||
class="view-navigation-button"
|
||||
chromedir="&locale.dir;"
|
||||
type="next"
|
||||
tooltiptext-day="&calendar.navigation.nextday.tooltip;"
|
||||
tooltiptext-week="&calendar.navigation.nextweek.tooltip;"
|
||||
tooltiptext-multiweek="&calendar.navigation.nextweek.tooltip;"
|
||||
tooltiptext-month="&calendar.navigation.nextmonth.tooltip;"
|
||||
command="calendar_view_next_command"/>
|
||||
<label id="intervalDescription"
|
||||
class="view-header"
|
||||
|
|
|
@ -933,8 +933,8 @@
|
|||
if (this.mObservesComposite == false) {
|
||||
getCompositeCalendar().addObserver(this);
|
||||
this.mObservesComposite = true;
|
||||
this.getItems()
|
||||
}
|
||||
this.getItems()
|
||||
} else {
|
||||
if (this.mObservesComposite == true) {
|
||||
getCompositeCalendar().removeObserver(this);
|
||||
|
@ -1113,6 +1113,10 @@
|
|||
<handlers>
|
||||
<handler event="DOMMouseScroll">
|
||||
<![CDATA[
|
||||
if (this.mIsReadOnly) {
|
||||
// No scrolling on readonly months
|
||||
return;
|
||||
}
|
||||
var rows = event.detail;
|
||||
if (rows == NSUIEvent.SCROLL_PAGE_UP) {
|
||||
rows = -1;
|
||||
|
|
|
@ -100,6 +100,13 @@
|
|||
<!ENTITY calendar.nextmonth.button.tooltip "Next Month" >
|
||||
<!ENTITY calendar.prevmonth.button.tooltip "Previous Month" >
|
||||
|
||||
<!ENTITY calendar.navigation.nextday.tooltip "One Day Forward" >
|
||||
<!ENTITY calendar.navigation.prevday.tooltip "One Day Back" >
|
||||
<!ENTITY calendar.navigation.nextweek.tooltip "One Week Forward" >
|
||||
<!ENTITY calendar.navigation.prevweek.tooltip "One Week Back" >
|
||||
<!ENTITY calendar.navigation.nextmonth.tooltip "One Month Forward" >
|
||||
<!ENTITY calendar.navigation.prevmonth.tooltip "One Month Back" >
|
||||
|
||||
<!ENTITY calendar.newevent.button.label "New Event" >
|
||||
<!ENTITY calendar.newtask.button.label "New Task" >
|
||||
<!ENTITY calendar.print.button.label "Print" >
|
||||
|
|
|
@ -488,14 +488,6 @@ singleShortCalendarWeek=CW: %1$S
|
|||
# %2$S will be replaced with the index of the end-week
|
||||
severalShortCalendarWeeks=CWs: %1$S-%2$S
|
||||
|
||||
oneDayBack=One Day Back
|
||||
oneDayForward=One Day Forward
|
||||
oneMonthBack=One Month Back
|
||||
oneMonthForward=One Month Forward
|
||||
oneWeekBack=One Week Back
|
||||
oneWeekForward=One Week Forward
|
||||
gotoToday=Go to Today
|
||||
|
||||
# Task tree, "Due In" column.
|
||||
# LOCALIZATION NOTE (dueInDays, dueInHours): Semi-colon list of plural
|
||||
# forms. See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
|
|
Загрузка…
Ссылка в новой задаче