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/NGObjWeb.h>
23
#include "WEClientCapabilities.h"
27
< scriptName (obligatory !!!)
31
Generates an ShiftClick JavaScript for CheckBoxes.
36
ShiftClickScript: JSShiftClick {
37
scriptName = scriptName;
40
Repetition: WORepetition {
41
list = (1, 2, 3, 4, 5, 6, 7, 8, 9);
44
CheckBox: WOCheckBox {
46
value = index; // = index" this must be done !!!
47
onClick = scriptCall; // = "scriptName(index)" this must be done !!!
63
@interface JSShiftClick : WODynamicElement
65
WOAssociation *identifier;
66
WOAssociation *prefix;
67
WOAssociation *scriptName;
71
static NSString *JSShiftClick_Script =
72
@"<script language=\"JavaScript\">\n"
74
@"var ns = (document.layers) ? true : false;\n"
75
@"var ie = (document.all) ? true : false;\n"
77
@"function shiftClick%@SearchElement(el) { \n"
78
@" for (i = 0; i < document.forms.length; i++) { \n"
79
@" for (j = 0; j < document.forms[i].elements.length; j++) { \n"
80
@" if (document.forms[i].elements[j].value == el) { \n"
81
@" return document.forms[i].elements[j]; \n"
87
@"function shiftClick%@(z) {\n"
89
@" var plusShift = window.event.shiftKey;\n"
90
@" if (plusShift && last >= 0) {\n"
91
@" var actEl = shiftClick%@SearchElement('%@'+last); \n"
93
@" var actState = actEl.checked;\n"
94
@" if (z<last) { var e1 = z; var e2 = last; }\n"
95
@" else { var e1 = last; var e2 = z; }\n"
96
@" for (idx = e1; idx<= e2; idx++) {\n"
97
@" actEl = shiftClick%@SearchElement('%@' + idx); \n"
98
@" 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
ccaps = [[_ctx request] clientCapabilities];
140
eid = [self->identifier stringValueInComponent:[_ctx component]];
141
eid = (eid) ? eid : [_ctx elementID];
142
eid = [[eid componentsSeparatedByString:@"."]
143
componentsJoinedByString:@"_"];
145
prfx = [self->prefix stringValueInComponent:[_ctx component]];
146
prfx = (prfx) ? prfx : @"";
148
if ([ccaps isJavaScriptBrowser]) {
151
s = [[NSString alloc] initWithFormat:JSShiftClick_Script,
152
eid, eid, eid, prfx, eid, prfx];
153
[_response appendContentString:s];
156
if ([self->scriptName isValueSettable]) {
157
NSString *sName = nil;
159
sName = [@"shiftClick" stringByAppendingString:eid];
160
[self->scriptName setValue:sName inComponent:[_ctx component]];
164
NSLog(@"Warning: JSShiftClick: 'scriptName' is not settable!!!");
169
@end /* JSShiftClick */