2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OGo
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 #include <SOGoUI/UIxComponent.h>
29 Modifiable list of uids used to select multiple calendars for viewing at once.
32 @interface AnaisUidSelector : UIxComponent
34 NSArray *calendarUIDs;
39 - (NSString *)prettyUid;
40 - (NSString *)userUid;
41 - (NSString *)_colorizedUid:(NSString *)_uid;
42 - (NSString *)showHref;
49 #include <NGObjWeb/SoUser.h>
51 @implementation AnaisUidSelector
61 [self->calendarUIDs release];
63 [self->userUid release];
67 - (void)setCalendarUIDs:(NSArray *)_calendarUIDs {
68 ASSIGN(self->calendarUIDs, _calendarUIDs);
70 - (NSArray *)calendarUIDs {
71 return self->calendarUIDs;
73 - (void)setUid:(NSString *)_uid {
74 ASSIGN(self->uid, _uid);
79 - (NSString *)prettyUid {
80 if([self->calendarUIDs objectAtIndex:0] == self->uid)
81 return [self _colorizedUid:self->uid];
82 return [NSString stringWithFormat:@", %@", [self _colorizedUid:self->uid]];
85 - (NSString *)_colorizedUid:(NSString *)_uid {
86 if([_uid isEqualToString:[self userUid]]) {
87 _uid = [NSString stringWithFormat:@"<span class=\""
88 @"anais_me\">%@</span>",
96 - (NSString *)showHref {
97 return [self completeHrefForMethod:@"show"];
103 - (NSString *)userUid {
105 return self->userUid;
107 ASSIGN(self->userUid, [[self user] login]);
108 return self->userUid;
111 - (NSString *)calendarUIDString {
112 return [[self calendarUIDs] componentsJoinedByString:@","];
115 /* this is to determine the initial visibility of the 'addMeToo' button */
116 - (NSString *)meTooStyle {
117 if([[self calendarUIDs] containsObject:userUid])
118 return @"visibility:hidden";
119 return @"visibility:visible";
124 - (NSString *)jsCode {
125 static NSString *script = \
126 @"function clearElementWithId(elemId) {\n"
127 @" var o = document.getElementById(elemId);\n"
128 @" var dst = o.parentNode;\n"
129 @" var n = document.createElement('td');\n"
130 @" n.setAttribute('id', elemId);\n"
131 @" n.setAttribute('align', 'left');\n"
132 @" n.setAttribute('class', 'anais_uids');\n"
133 @" dst.replaceChild(n, o);\n"
135 @"function clearUidList() {\n"
136 @" clearElementWithId('anaisUIDList');\n"
137 @" var e = document.getElementById('anaisUIDString');\n"
138 @" e.setAttribute('value', '');\n"
139 @" var td = document.getElementById('addMeToo');\n"
140 @" td.setAttribute('style', 'visibility:visible');\n"
141 @" td = document.getElementById('clearUidList');\n"
142 @" td.setAttribute('style', 'visibility:hidden');\n"
143 @" td = document.getElementById('showUidList');\n"
144 @" td.setAttribute('style', 'visibility:hidden');\n"
146 @"function addMeToo() {\n"
147 @" addUid('', '', '', '', '%@', '');\n"
148 @" var td = document.getElementById('addMeToo');\n"
149 @" td.setAttribute('style', 'visibility:hidden');\n"
151 @"function addUidFromAnais() {\n"
152 @" var uid = arguments[2]; \n"
154 @" addUid('','','','',uid,''); \n"
156 @"function addUid(division, cn, dn, email, uid, sn) {\n"
159 @" var e = document.getElementById('anaisUIDString');\n"
160 @" var s = e.getAttribute('value');\n"
162 @" s = s + ',' + uid;\n"
165 @" e.setAttribute('value', s);\n"
166 @" var td = document.getElementById('anaisUIDList');\n"
168 @" if(td.hasChildNodes()) {\n"
169 @" text = document.createTextNode(', ');\n"
170 @" td.appendChild(text);\n"
172 @" text = document.createTextNode(uid);\n"
173 @" if(uid == '%@') {\n"
174 @" var span = document.createElement('span');\n"
175 @" span.setAttribute('class', 'anais_me');\n"
176 @" span.appendChild(text);\n"
177 @" td.appendChild(span);\n"
180 @" td.appendChild(text);\n"
182 @" td = document.getElementById('clearUidList');\n"
183 @" td.setAttribute('style', 'visibility:visible');\n"
184 @" td = document.getElementById('showUidList');\n"
185 @" td.setAttribute('style', 'visibility:visible');\n"
189 return [NSString stringWithFormat:script,
190 [self userUid], [self userUid]];