зеркало из https://github.com/mozilla/pjs.git
Make day + week views respect default start and end time preferences (bug 321769). r=<jminta@gmail.com>
This commit is contained in:
Родитель
7d743ba10e
Коммит
76c017c302
|
@ -21,6 +21,7 @@
|
|||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- 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
|
||||
|
@ -54,6 +55,76 @@
|
|||
</content>
|
||||
|
||||
<implementation implements="calIDecoratedView">
|
||||
<constructor><![CDATA[
|
||||
var pb2 = Components.classes
|
||||
["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch2);
|
||||
|
||||
// get default start/end times from prefs and set on the
|
||||
// view. if we hit an error (eg because sunbird's pref
|
||||
// infrastructure hasn't created the pref yet), the
|
||||
// defaults will do
|
||||
try {
|
||||
this.mStartMin = pb2.getIntPref(
|
||||
"calendar.view.defaultstarthour") * 60;
|
||||
this.mEndMin = pb2.getIntPref(
|
||||
"calendar.view.defaultendhour") * 60;
|
||||
} catch (ex) {
|
||||
}
|
||||
|
||||
var viewElement = document.getAnonymousElementByAttribute(
|
||||
this, "anonid", "view-element");
|
||||
viewElement.setStartEndMinutes(this.mStartMin,
|
||||
this.mEndMin);
|
||||
|
||||
// add a preference observer to monitor changes
|
||||
pb2.addObserver("calendar.view.", this.mPrefObserver, false);
|
||||
return;
|
||||
]]></constructor>
|
||||
|
||||
<destructor><![CDATA[
|
||||
var pb2 = Components.classes
|
||||
["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch2);
|
||||
pb2.removeObserver("calendar.view.", this.mPrefObserver);
|
||||
return;
|
||||
]]></destructor>
|
||||
|
||||
<field name="mStartMin">8 * 60</field>
|
||||
<field name="mEndMin">17 * 60</field>
|
||||
|
||||
<field name="mPrefObserver"><![CDATA[
|
||||
({ calView: this,
|
||||
observe: function calDecWeekViewPrefChange(subj, topic, pref) {
|
||||
|
||||
subj.QueryInterface(Components.interfaces.nsIPrefBranch2);
|
||||
|
||||
switch (pref) {
|
||||
|
||||
case "calendar.view.defaultstarthour":
|
||||
this.calView.mStartMin = subj.getIntPref(pref) * 60;
|
||||
var viewElem = document.getAnonymousElementByAttribute(
|
||||
this.calView, "anonid", "view-element");
|
||||
viewElem.setStartEndMinutes(this.calView.mStartMin,
|
||||
this.calView.mEndMin);
|
||||
break;
|
||||
|
||||
case "calendar.view.defaultendhour":
|
||||
this.calView.mEndMin = subj.getIntPref(pref) * 60;
|
||||
viewElem = document.getAnonymousElementByAttribute(
|
||||
this.calView, "anonid", "view-element");
|
||||
viewElem.setStartEndMinutes(this.calView.mStartMin,
|
||||
this.calView.mEndMin);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
})
|
||||
]]></field>
|
||||
|
||||
<property name="observerID">
|
||||
<getter><![CDATA[
|
||||
return "day-view-observer";
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- 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
|
||||
|
@ -54,6 +55,76 @@
|
|||
</content>
|
||||
|
||||
<implementation implements="calIDecoratedView">
|
||||
<constructor><![CDATA[
|
||||
var pb2 = Components.classes
|
||||
["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch2);
|
||||
|
||||
// get default start/end times from prefs and set on the
|
||||
// view. if we hit an error (eg because sunbird's pref
|
||||
// infrastructure hasn't created the pref yet), the
|
||||
// defaults will do
|
||||
try {
|
||||
this.mStartMin = pb2.getIntPref(
|
||||
"calendar.view.defaultstarthour") * 60;
|
||||
this.mEndMin = pb2.getIntPref(
|
||||
"calendar.view.defaultendhour") * 60;
|
||||
} catch (ex) {
|
||||
}
|
||||
|
||||
var viewElement = document.getAnonymousElementByAttribute(
|
||||
this, "anonid", "view-element");
|
||||
viewElement.setStartEndMinutes(this.mStartMin,
|
||||
this.mEndMin);
|
||||
|
||||
// add a preference observer to monitor changes
|
||||
pb2.addObserver("calendar.view.", this.mPrefObserver, false);
|
||||
return;
|
||||
]]></constructor>
|
||||
|
||||
<destructor><![CDATA[
|
||||
var pb2 = Components.classes
|
||||
["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch2);
|
||||
pb2.removeObserver("calendar.view.", this.mPrefObserver);
|
||||
return;
|
||||
]]></destructor>
|
||||
|
||||
<field name="mStartMin">8 * 60</field>
|
||||
<field name="mEndMin">17 * 60</field>
|
||||
|
||||
<field name="mPrefObserver"><![CDATA[
|
||||
({ calView: this,
|
||||
observe: function calDecWeekViewPrefChange(subj, topic, pref) {
|
||||
|
||||
subj.QueryInterface(Components.interfaces.nsIPrefBranch2);
|
||||
|
||||
switch (pref) {
|
||||
|
||||
case "calendar.view.defaultstarthour":
|
||||
this.calView.mStartMin = subj.getIntPref(pref) * 60;
|
||||
var viewElem = document.getAnonymousElementByAttribute(
|
||||
this.calView, "anonid", "view-element");
|
||||
viewElem.setStartEndMinutes(this.calView.mStartMin,
|
||||
this.calView.mEndMin);
|
||||
break;
|
||||
|
||||
case "calendar.view.defaultendhour":
|
||||
this.calView.mEndMin = subj.getIntPref(pref) * 60;
|
||||
viewElem = document.getAnonymousElementByAttribute(
|
||||
this.calView, "anonid", "view-element");
|
||||
viewElem.setStartEndMinutes(this.calView.mStartMin,
|
||||
this.calView.mEndMin);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
})
|
||||
]]></field>
|
||||
|
||||
<property name="observerID">
|
||||
<getter><![CDATA[
|
||||
return "week-view-observer";
|
||||
|
|
|
@ -16,11 +16,12 @@
|
|||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Oracle Corporation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir.vukicevic@oracle.com>
|
||||
* 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
|
||||
|
@ -44,6 +45,13 @@ interface calIDateTime;
|
|||
interface calICalendarViewController;
|
||||
interface calIItemBase;
|
||||
|
||||
/**
|
||||
* An interface for view widgets containing calendaring data.
|
||||
*
|
||||
* @note Code that implements this interface is intended to be pure
|
||||
* widgetry and thus not have any preference dependencies.
|
||||
* Preferences and pref observers should live in the decorated views.
|
||||
*/
|
||||
[scriptable, uuid(3e567ccb-2ecf-4f59-b7ca-bf42b0fbf24a)]
|
||||
interface calICalendarView : nsISupports
|
||||
{
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Joey Minta <jminta@gmail.com>
|
||||
* Dan Mosedale <dan.mosedale@oracle.com>
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
@ -49,6 +51,12 @@ interface calIItemBase;
|
|||
* Because it contains a calICalendarView as an anonymous node, not easily
|
||||
* accessible, it must therefore expose several of that interface's methods and
|
||||
* attributes, as well as its own.
|
||||
*
|
||||
* @note Implementations of this interface are intended to be the home
|
||||
* for view preference handling. The lower-level views (ie
|
||||
* implementers of calICalendarView) are intended to be pure widgetry,
|
||||
* and this sort of view should be pluggable, meaning that callers
|
||||
* shouldn't need to know about view-specific preferences.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(229049e0-e36f-4706-9fe1-37eb370273b9)]
|
||||
|
|
|
@ -93,16 +93,6 @@ function ltnOnLoad(event)
|
|||
document.getElementById("messengerWindow")
|
||||
.addEventListener("unload", ltnFinish, false);
|
||||
|
||||
// Set up the multiday-view to start/end at the correct hours, since this
|
||||
// doesn't persist between startups. (Fails if pref undefined)
|
||||
try {
|
||||
var sHour = rootPrefBranch.getIntPref("calendar.view.defaultstarthour");
|
||||
var eHour = rootPrefBranch.getIntPref("calendar.view.defaultendhour");
|
||||
document.getElementById("calendar-multiday-view")
|
||||
.setStartEndMinutes(sHour*60, eHour*60);
|
||||
}
|
||||
catch(ex) {}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -232,17 +222,6 @@ var ltnPrefObserver =
|
|||
rootPrefBranch: null,
|
||||
observe: function(aSubject, aTopic, aPrefName)
|
||||
{
|
||||
switch (aPrefName) {
|
||||
case "calendar.view.defaultstarthour":
|
||||
case "calendar.view.defaultendhour":
|
||||
var sHour = this.rootPrefBranch.getIntPref
|
||||
("calendar.view.defaultstarthour");
|
||||
var eHour = this.rootPrefBranch.getIntPref
|
||||
("calendar.view.defaultendhour");
|
||||
document.getElementById("calendar-multiday-view")
|
||||
.setStartEndMinutes(sHour*60, eHour*60);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
* Contributor(s): Mike Potter <mikep@oeone.com>
|
||||
* ArentJan Banck <ajbanck@planet.nl>
|
||||
* Eric Belhaire <belhaire@ief.u-psud.fr>
|
||||
* 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
|
||||
|
@ -59,8 +60,6 @@ calendarPrefObserver.prototype =
|
|||
// when calendar pref was changed, we reinitialize
|
||||
switch( prefName )
|
||||
{
|
||||
case "calendar.view.defaultstarthour":
|
||||
case "calendar.view.defaultendhour":
|
||||
case "calendar.previousweeks.inview":
|
||||
case "calendar.week.d0sundaysoff":
|
||||
case "calendar.week.d1mondaysoff":
|
||||
|
|
Загрузка…
Ссылка в новой задаче