1 /* -*- Mode: javascript; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is Calendar Code.
16 *
17 * The Initial Developer of the Original Code is
18 * Michiel van Leeuwen <mvl@exedo.nl>.
19 * Portions created by the Initial Developer are Copyright (C) 2005
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Philipp Kewisch <mozilla@kewis.ch>
24 * Daniel Boelzle <daniel.boelzle@sun.com>
25 *
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
37 *
38 * ***** END LICENSE BLOCK ***** */
39
40 /**
41 * To open the window, use an object as argument.
42 * This object needs two properties: calendar and onOk.
43 * (where onOk can be null)
44 */
45
46 var gCalendar;
47
loadCalendarPropertiesDialog
48 function loadCalendarPropertiesDialog()
49 {
50 var args = window.arguments[0];
51
52 gCalendar = args.calendar;
53
54 document.getElementById("calendar-name").value = gCalendar.name;
55 var calColor = gCalendar.getProperty('color');
56 if (calColor) {
57 document.getElementById("calendar-color").color = calColor;
58 }
59 document.getElementById("calendar-uri").value = gCalendar.uri.spec;
60 document.getElementById("read-only").checked = gCalendar.readOnly;
61
62 // start focus on title
63 document.getElementById("calendar-name").focus();
64
65 // set up the cache field
66 var cacheBox = document.getElementById("cache");
67 var canCache = (gCalendar.getProperty("cache.supported") !== false);
68 cacheBox.disabled = !canCache;
69 cacheBox.checked = (canCache && gCalendar.getProperty("cache.enabled"));
70
71 // Set up the show alarms row and checkbox
72 var suppressAlarmsRow = document.getElementById("calendar-suppressAlarms-row");
73 var suppressAlarms = gCalendar.getProperty('suppressAlarms');
74 document.getElementById("fire-alarms").checked = !suppressAlarms;
75
76 suppressAlarmsRow.hidden =
77 (gCalendar.getProperty("capabilities.alarms.popup.supported") === false);
78
79 sizeToContent();
80 }
81
onOKCommand
82 function onOKCommand()
83 {
84 gCalendar.name = document.getElementById("calendar-name").value;
85
86 var newUri = makeURL(document.getElementById("calendar-uri").value);
87 if (!newUri.equals(gCalendar.uri))
88 gCalendar.uri = newUri;
89
90 gCalendar.setProperty('color', document.getElementById("calendar-color").color);
91 gCalendar.readOnly = document.getElementById("read-only").checked;
92 var fireAlarms = document.getElementById("fire-alarms").checked;
93 gCalendar.setProperty('suppressAlarms', !fireAlarms);
94 gCalendar.setProperty("cache.enabled", document.getElementById("cache").checked);
95
96 // tell standard dialog stuff to close the dialog
97 return true;
98 }
99
checkURL
100 function checkURL() {
101 document.getElementById("calendar-properties-dialog")
102 .getButton("accept").removeAttribute("disabled");
103 try {
104 makeURL(document.getElementById("calendar-uri").value);
105 }
106 catch (ex) {
107 document.getElementById("calendar-properties-dialog")
108 .getButton("accept").setAttribute("disabled", true);
109 }
110 }