1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is OEone Calendar Code, released October 31st, 2001.
15 *
16 * The Initial Developer of the Original Code is
17 * OEone Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 2001
19 * the Initial Developer. All Rights Reserved.
20 *
21 * Contributor(s): Garth Smedley <garths@oeone.com>
22 * Mike Potter <mikep@oeone.com>
23 * Chris Charabaruk <coldacid@meldstar.com>
24 * Colin Phillips <colinp@oeone.com>
25 * ArentJan Banck <ajbanck@planet.nl>
26 * Curtis Jewell <csjewell@mail.freeshell.org>
27 * Eric Belhaire <eric.belhaire@ief.u-psud.fr>
28 * Mark Swaffer <swaff@fudo.org>
29 * Michael Buettner <michael.buettner@sun.com>
30 * Philipp Kewisch <mozilla@kewis.ch>
31 *
32 * Alternatively, the contents of this file may be used under the terms of
33 * either the GNU General Public License Version 2 or later (the "GPL"), or
34 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
35 * in which case the provisions of the GPL or the LGPL are applicable instead
36 * of those above. If you wish to allow use of your version of this file only
37 * under the terms of either the GPL or the LGPL, and not to allow others to
38 * use your version of this file under the terms of the MPL, indicate your
39 * decision by deleting the provisions above and replace them with the notice
40 * and other provisions required by the GPL or the LGPL. If you do not delete
41 * the provisions above, a recipient may use your version of this file under
42 * the terms of any one of the MPL, the GPL or the LGPL.
43 *
44 * ***** END LICENSE BLOCK ***** */
45
46 /**
47 * Called when the calendar is loaded
48 */
49
prepareCalendarToDoUnifinder
50 function prepareCalendarToDoUnifinder() {
51 const kSUNBIRD_ID = "{718e30fb-e89b-41dd-9da7-e25a45638b28}";
52 var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
53 .getService(Components.interfaces.nsIXULAppInfo);
54 if (appInfo.ID == kSUNBIRD_ID) {
55 document.getElementById("todo-label").removeAttribute("collapsed");
56 }
57 toDoUnifinderRefresh();
58 }
59
60 /**
61 * Called by event observers to update the display
62 */
63
toDoUnifinderRefresh
64 function toDoUnifinderRefresh() {
65 // Set up hiding completed tasks for the unifinder-todo tree
66 var hideCompleted = document.getElementById("hide-completed-checkbox").checked;
67 var tree = document.getElementById("unifinder-todo-tree");
68 tree.hideCompleted = hideCompleted;
69 tree.refresh();
70
71 var deck = getViewDeck();
72 var curview = currentView();
73 var currentViewHideCompleted = !curview.showCompleted;
74 var selectedDay = getSelectedDay();
75
76 // Set up show completed for each view
77 for each (var view in deck.childNodes) {
78 view.showCompleted = !hideCompleted;
79 }
80
81 // Only update view if hide completed has actually changed and tasks are
82 // visible in the view.
83 if (selectedDay &&
84 currentViewHideCompleted != hideCompleted &&
85 curview.tasksInView) {
86 deck.selectedPanel.goToDay(selectedDay);
87 }
88 }
89
getToDoFromEvent
90 function getToDoFromEvent(event) {
91 return document.getElementById(
92 "unifinder-todo-tree").getTaskFromEvent(event);
93 }