2
Copyright (C) 2000-2005 SKYRIX Software AG
4
This file is part of SOPE.
6
SOPE 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
SOPE 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 SOPE; see the file COPYING. If not, write to the
18
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22
#include <NGObjWeb/WODynamicElement.h>
26
< scriptName (obligatory !!!)
30
Generates an ShiftClick JavaScript for CheckBoxes.
35
ShiftClickScript: JSShiftClick {
36
scriptName = scriptName;
39
Repetition: WORepetition {
40
list = (1, 2, 3, 4, 5, 6, 7, 8, 9);
43
CheckBox: WOCheckBox {
45
value = index; // = index" this must be done !!!
46
onClick = scriptCall; // = "scriptName(index)" this must be done !!!
62
@interface JSShiftClick : WODynamicElement
64
WOAssociation *identifier;
65
WOAssociation *prefix;
66
WOAssociation *scriptName;
71
#include <NGObjWeb/WEClientCapabilities.h>
73
static NSString *JSShiftClick_Script =
74
@"<script language=\"JavaScript\">\n"
76
@"var ns = (document.layers) ? true : false;\n"
77
@"var ie = (document.all) ? true : false;\n"
79
@"function shiftClick%@SearchElement(el) { \n"
80
@" for (i = 0; i < document.forms.length; i++) { \n"
81
@" for (j = 0; j < document.forms[i].elements.length; j++) { \n"
82
@" if (document.forms[i].elements[j].value == el) { \n"
83
@" return document.forms[i].elements[j]; \n"
89
@"function shiftClick%@(z) {\n"
91
@" var plusShift = window.event.shiftKey;\n"
92
@" if (plusShift && last >= 0) {\n"
93
@" var actEl = shiftClick%@SearchElement('%@'+last); \n"
95
@" var actState = actEl.checked;\n"
96
@" if (z<last) { var e1 = z; var e2 = last; }\n"
97
@" else { var e1 = last; var e2 = z; }\n"
98
@" for (idx = e1; idx<= e2; idx++) {\n"
99
@" actEl = shiftClick%@SearchElement('%@' + idx); \n"
100
@" actEl.checked = actState;\n"
110
@implementation JSShiftClick
112
- (id)initWithName:(NSString *)_name
113
associations:(NSDictionary *)_config
114
template:(WOElement *)_tmp
116
if ((self = [super initWithName:_name associations:_config template:_tmp])) {
117
self->identifier = WOExtGetProperty(_config, @"identifier");
118
self->prefix = WOExtGetProperty(_config, @"prefix");
119
self->scriptName = WOExtGetProperty(_config, @"scriptName");
125
[self->identifier release];
126
[self->prefix release];
127
[self->scriptName release];
131
/* response generation */
133
- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
134
WEClientCapabilities *ccaps = nil;
136
NSString *prfx = nil;
138
if ([_ctx isRenderingDisabled]) return;
140
ccaps = [[_ctx request] clientCapabilities];
142
eid = [self->identifier stringValueInComponent:[_ctx component]];
143
eid = (eid) ? eid : [_ctx elementID];
144
eid = [[eid componentsSeparatedByString:@"."]
145
componentsJoinedByString:@"_"];
147
prfx = [self->prefix stringValueInComponent:[_ctx component]];
148
prfx = (prfx != nil) ? prfx : (NSString *)@"";
150
if ([ccaps isJavaScriptBrowser]) {
153
s = [[NSString alloc] initWithFormat:JSShiftClick_Script,
154
eid, eid, eid, prfx, eid, prfx];
155
[_response appendContentString:s];
158
if ([self->scriptName isValueSettable]) {
159
NSString *sName = nil;
161
sName = [@"shiftClick" stringByAppendingString:eid];
162
[self->scriptName setValue:sName inComponent:[_ctx component]];
166
NSLog(@"Warning: JSShiftClick: 'scriptName' is not settable!!!");
171
@end /* JSShiftClick */