1 | |
---|
2 | /** |
---|
3 | * some code copied and adapted from Thunderbird Sources |
---|
4 | * thanks to all Thunderbird Developers |
---|
5 | */ |
---|
6 | |
---|
7 | /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
---|
8 | * ***** BEGIN LICENSE BLOCK ***** |
---|
9 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
---|
10 | * |
---|
11 | * The contents of this file are subject to the Mozilla Public License Version |
---|
12 | * 1.1 (the "License"); you may not use this file except in compliance with |
---|
13 | * the License. You may obtain a copy of the License at |
---|
14 | * http://www.mozilla.org/MPL/ |
---|
15 | * |
---|
16 | * Software distributed under the License is distributed on an "AS IS" basis, |
---|
17 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
---|
18 | * for the specific language governing rights and limitations under the |
---|
19 | * License. |
---|
20 | * |
---|
21 | * The Original Code is Mozilla Communicator client code, released |
---|
22 | * March 31, 1998. |
---|
23 | * |
---|
24 | * The Initial Developer of the Original Code is |
---|
25 | * Netscape Communications Corporation. |
---|
26 | * Portions created by the Initial Developer are Copyright (C) 1998-1999 |
---|
27 | * the Initial Developer. All Rights Reserved. |
---|
28 | * |
---|
29 | * Contributor(s): |
---|
30 | * |
---|
31 | * Alternatively, the contents of this file may be used under the terms of |
---|
32 | * either of the GNU General Public License Version 2 or later (the "GPL"), |
---|
33 | * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
---|
34 | * in which case the provisions of the GPL or the LGPL are applicable instead |
---|
35 | * of those above. If you wish to allow use of your version of this file only |
---|
36 | * under the terms of either the GPL or the LGPL, and not to allow others to |
---|
37 | * use your version of this file under the terms of the MPL, indicate your |
---|
38 | * decision by deleting the provisions above and replace them with the notice |
---|
39 | * and other provisions required by the GPL or the LGPL. If you do not delete |
---|
40 | * the provisions above, a recipient may use your version of this file under |
---|
41 | * the terms of any one of the MPL, the GPL or the LGPL. |
---|
42 | * |
---|
43 | * ***** END LICENSE BLOCK ***** */ |
---|
44 | |
---|
45 | virtualIdentityExtension.ns(function() { with (virtualIdentityExtension.LIB) { |
---|
46 | |
---|
47 | function InitFolderDisplays(msgFolder, accountPickerId, folderPickerId) { |
---|
48 | var accountPicker = document.getElementById(accountPickerId); |
---|
49 | var folderPicker = document.getElementById(folderPickerId); |
---|
50 | InitFolderDisplay(msgFolder.server.rootFolder, accountPicker); |
---|
51 | InitFolderDisplay(msgFolder, folderPicker); |
---|
52 | } |
---|
53 | |
---|
54 | // Initialize the folder display based on prefs values |
---|
55 | function InitFolderDisplay(folder, folderPicker) { |
---|
56 | try { |
---|
57 | folderPicker.firstChild.selectFolder(folder); |
---|
58 | } catch(ex) { |
---|
59 | folderPicker.setAttribute("label", folder.prettyName); |
---|
60 | } |
---|
61 | folderPicker.folder = folder; |
---|
62 | } |
---|
63 | |
---|
64 | // Capture any menulist changes |
---|
65 | function noteSelectionChange(radioItemId, aEvent) |
---|
66 | { |
---|
67 | var checkedElem = document.getElementById(radioItemId); |
---|
68 | var folder = aEvent.target._folder; |
---|
69 | var modeValue = checkedElem.value; |
---|
70 | var radioGroup = checkedElem.radioGroup.getAttribute("id"); |
---|
71 | var picker; |
---|
72 | switch (radioGroup) |
---|
73 | { |
---|
74 | case "VIdent_doFcc" : |
---|
75 | gFccRadioElemChoice = modeValue; |
---|
76 | picker = document.getElementById("msgFccFolderPicker"); |
---|
77 | break; |
---|
78 | |
---|
79 | case "VIdent_messageDrafts" : |
---|
80 | gDraftsRadioElemChoice = modeValue; |
---|
81 | picker = document.getElementById("msgDraftsFolderPicker"); |
---|
82 | break; |
---|
83 | |
---|
84 | case "VIdent_messageTemplates" : |
---|
85 | gTmplRadioElemChoice = modeValue; |
---|
86 | picker = document.getElementById("msgStationeryFolderPicker"); |
---|
87 | break; |
---|
88 | } |
---|
89 | picker.folder = folder; |
---|
90 | picker.setAttribute("label", folder.prettyName); |
---|
91 | } |
---|
92 | |
---|
93 | // Save folder settings and radio element choices |
---|
94 | function SaveFolderSettings(radioElemChoice, |
---|
95 | radioGroupId, |
---|
96 | folderSuffix, |
---|
97 | accountPickerId, |
---|
98 | folderPickerId, |
---|
99 | folderElementId, |
---|
100 | folderPickerModeId) |
---|
101 | { |
---|
102 | var formElement = document.getElementById(folderElementId); |
---|
103 | var uri = ""; |
---|
104 | |
---|
105 | switch (radioElemChoice) |
---|
106 | { |
---|
107 | case "0" : |
---|
108 | uri = document.getElementById(accountPickerId).selectedItem._folder.URI; |
---|
109 | if (uri) { |
---|
110 | // Create Folder URI |
---|
111 | uri = uri + folderSuffix; |
---|
112 | } |
---|
113 | break; |
---|
114 | |
---|
115 | case "1" : |
---|
116 | uri = document.getElementById(folderPickerId).folder.URI; |
---|
117 | break; |
---|
118 | |
---|
119 | default : |
---|
120 | break; |
---|
121 | } |
---|
122 | formElement.setAttribute("value", uri); |
---|
123 | |
---|
124 | formElement = document.getElementById(folderPickerModeId); |
---|
125 | formElement.setAttribute("value", radioElemChoice); |
---|
126 | } |
---|
127 | vI.InitFolderDisplays = InitFolderDisplays; |
---|
128 | vI.SaveFolderSettings = SaveFolderSettings; |
---|
129 | }}); |
---|