- (NSString *)jsCode {
static NSString *script = \
- @"function toggleRowSelectionStatus(sender) {\n"
- @"}\n"
- @"";
+ @"var rowSelectionCount = 0;\n"
+ @"\n"
+ @"validateControls();\n"
+ @"\n"
+ @"function showElement(e, shouldShow) {\n"
+ @" e.style.display = shouldShow ? \"\" : \"none\";\n"
+ @"}\n"
+ @"\n"
+ @"function enableElement(e, shouldEnable) {\n"
+ @" if(!e)\n"
+ @" return;\n"
+ @" if(shouldEnable) {\n"
+ @" if(e.hasAttribute(\"disabled\"))\n"
+ @" e.removeAttribute(\"disabled\");\n"
+ @" }\n"
+ @" else {\n"
+ @" e.setAttribute(\"disabled\", \"1\");\n"
+ @" }\n"
+ @"}\n"
+ @"\n"
+ @"function toggleRowSelectionStatus(sender) {\n"
+ @" rowID = sender.value;\n"
+ @" tr = document.getElementById(rowID);\n"
+ @" if(sender.checked) {\n"
+ @" tr.className = \"tableview_selected\";\n"
+ @" rowSelectionCount += 1;\n"
+ @" }\n"
+ @" else {\n"
+ @" tr.className = \"tableview\";\n"
+ @" rowSelectionCount -= 1;\n"
+ @" }\n"
+ @" this.validateControls();\n"
+ @"}\n"
+ @"\n"
+ @"function validateControls() {\n"
+ @" var e = document.getElementById(\"moveto\");\n"
+ @" this.enableElement(e, rowSelectionCount > 0);\n"
+ @"}\n"
+ @"\n"
+ @"function moveTo(uri) {\n"
+ @" alert(\"MoveTo: \" + uri);\n"
+ @"}\n"
+ @"";
return script;
}
</script>
<table border="0" width="100%" cellspacing="0" cellpadding="1">
<tr class="tableview">
- <!-- TODO: see AB for sorting -->
<td class="tbtv_headercell" width="17">
<var:entity const:name="nbsp" />
</td>
<td>
<input type="checkbox"
var:value="msgRowID"
+ const:checked="NO"
+ const:name="selectedRows"
onclick="javascript:toggleRowSelectionStatus(this);"
/>
</td>
</td>
</tr>
</var:foreach>
- <span id="selected_uids" style="visibility: hidden;">
- </span>
+ <tr class="tableview">
+ <td colspan="6" class="tbtv_actcell">
+ <!-- actions -->
+ <var:component className="UIxMailMoveToPopUp"
+ const:identifier="moveto"
+ const:callback="moveTo"
+ rootNodes="clientObject.treeNavigationNodes"
+ />
+ </td>
+ </tr>
</table>
+ <span id="selected_uids" style="visibility: hidden;">
+ </span>
</div>
</div>
+ <!--
+ <div>
+ <pre>
+ tnn: <var:string value="clientObject.treeNavigationNodes" />
+ </pre>
+ </div>
+ -->
</var:component>
--- /dev/null
+/*
+ Copyright (C) 2000-2004 SKYRIX Software AG
+
+ This file is part of OGo
+
+ OGo is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with OGo; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+ */
+// $Id$
+
+
+#include <NGObjWeb/NGObjWeb.h>
+
+@interface UIxMailMoveToPopUp : WOComponent
+{
+ NSString *identifier;
+ NSString *callback;
+ id rootNodes;
+ id item;
+}
+
+- (NSString *)itemDisplayString;
+- (NSString *)itemURL;
+
+- (void)_appendEntriesFromNodeDict:(NSDictionary *)_dict
+ toList:(NSMutableArray *)_list
+ withPrefix:(NSString *)_pathPrefix;
+@end
+
+#include "common.h"
+
+@implementation UIxMailMoveToPopUp
+
+- (void)dealloc {
+ [self->identifier release];
+ [self->callback release];
+ [self->rootNodes release];
+ [self->item release];
+ [super dealloc];
+}
+
+- (void)setIdentifier:(NSString *)_identifier {
+ ASSIGN(self->identifier, _identifier);
+}
+- (NSString *)identifier {
+ return self->identifier;
+}
+
+- (void)setCallback:(NSString *)_callback {
+ ASSIGN(self->callback, _callback);
+}
+- (NSString *)callback {
+ return self->callback;
+}
+
+- (void)setRootNodes:(id)_rootNodes {
+ ASSIGN(self->rootNodes, _rootNodes);
+}
+- (id)rootNodes {
+ return self->rootNodes;
+}
+
+- (void)setItem:(id)_item {
+ ASSIGN(self->item, _item);
+}
+- (id)item {
+ return self->item;
+}
+
+- (NSArray *)sortedNodes {
+ NSMutableArray *r;
+ NSDictionary *dict;
+
+ r = [NSMutableArray arrayWithCapacity:10];
+ /* INBOX node */
+ dict = [[self->rootNodes objectForKey:@"children"] objectAtIndex:0];
+ [self _appendEntriesFromNodeDict:dict toList:r withPrefix:nil];
+ return r;
+}
+
+- (void)_appendEntriesFromNodeDict:(NSDictionary *)_dict
+ toList:(NSMutableArray *)_list
+ withPrefix:(NSString *)_pathPrefix
+{
+ NSMutableDictionary *e;
+ NSString *title, *link;
+ NSArray *children;
+ unsigned count, i;
+
+ title = [_dict objectForKey:@"title"];
+ link = [_dict objectForKey:@"link"];
+ e = [[NSMutableDictionary alloc] initWithCapacity:2];
+ if(!_pathPrefix)
+ _pathPrefix = title;
+ else
+ _pathPrefix = [NSString stringWithFormat:@"%@.%@", _pathPrefix, title];
+ [e setObject:_pathPrefix forKey:@"title"];
+ [e setObject:link forKey:@"link"];
+ [_list addObject:e];
+ [e release];
+
+ children = [_dict objectForKey:@"children"];
+ count = [children count];
+ for(i = 0; i < count; i++) {
+ NSDictionary *dict;
+
+ dict = [children objectAtIndex:i];
+ [self _appendEntriesFromNodeDict:dict
+ toList:_list
+ withPrefix:_pathPrefix];
+ }
+}
+
+- (NSString *)itemDisplayString {
+ return [self->item objectForKey:@"title"];
+}
+
+- (NSString *)itemURL {
+ return [self->item objectForKey:@"link"];
+}
+
+- (NSString *)itemDisabledValue {
+ return [[self itemURL] isEqualToString:@"."] ? @" disabled" : @"";
+}
+
+/* JavaScript */
+
+- (NSString *)selectItemJS {
+ static NSString *selectJS = \
+ @"javascript:if(!this.hasAttribute('disabled')) %@('%@');";
+ return [NSString stringWithFormat:selectJS,
+ self->callback,
+ [self itemURL]];
+}
+
+@end
--- /dev/null
+<?xml version='1.0' standalone='yes'?>
+
+<select xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:var="http://www.skyrix.com/od/binding"
+ xmlns:const="http://www.skyrix.com/od/constant"
+ xmlns:uix="OGo:uix"
+ xmlns:rsrc="OGo:url"
+ xmlns:label="OGo:label"
+ var:name="identifier"
+ var:id="identifier"
+ const:disabled="1"
+>
+ <option value="title"
+ checked="1"
+ read="1"
+ ><var:string label:value="MoveTo" const:escapeHTML="NO" /></option>
+ <var:foreach list="sortedNodes" item="item" >
+ <option var:value="itemURL"
+ var:onClick="selectItemJS"
+ var:otherTagString="itemDisabledValue"
+ ><var:string value="itemDisplayString" /></option>
+ </var:foreach>
+ <option value="all" disabled="1" >All</option>
+</select>
\ No newline at end of file