Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
8cef09a7
Commit
8cef09a7
authored
Jan 19, 2009
by
Dries
Browse files
- Patch
#308719
by jpetso, boombatower, et al: sanitze simpletest.js checkbox code.
parent
bca75d35
Changes
1
Hide whitespace changes
Inline
Side-by-side
modules/simpletest/simpletest.js
View file @
8cef09a7
...
...
@@ -61,36 +61,41 @@ Drupal.behaviors.simpleTestMenuCollapse = {
Drupal
.
behaviors
.
simpleTestSelectAll
=
{
attach
:
function
()
{
$
(
'
td.simpletest-select-all
'
).
each
(
function
()
{
var
checkboxes
=
Drupal
.
settings
.
simpleTest
[
'
simpletest-test-group-
'
+
$
(
this
).
attr
(
'
id
'
)].
testNames
,
totalCheckboxes
=
0
,
checkbox
=
$
(
'
<input type="checkbox" class="form-checkbox" id="
'
+
$
(
this
).
attr
(
'
id
'
)
+
'
-select-all" />
'
).
change
(
function
()
{
var
checked
=
!!
(
$
(
this
).
attr
(
'
checked
'
));
for
(
var
i
=
0
;
i
<
checkboxes
.
length
;
i
++
)
{
$
(
'
#
'
+
checkboxes
[
i
]).
attr
(
'
checked
'
,
checked
);
}
self
.
data
(
'
simpletest-checked-tests
'
,
(
checked
?
checkboxes
.
length
:
0
));
}).
data
(
'
simpletest-checked-tests
'
,
0
);
var
self
=
$
(
this
);
for
(
var
i
=
0
;
i
<
checkboxes
.
length
;
i
++
)
{
if
(
$
(
'
#
'
+
checkboxes
[
i
]).
change
(
function
()
{
if
(
checkbox
.
attr
(
'
checked
'
)
==
'
checked
'
)
{
checkbox
.
attr
(
'
checked
'
,
''
);
}
var
data
=
(
!
self
.
data
(
'
simpletest-checked-tests
'
)
?
0
:
self
.
data
(
'
simpletest-checked-tests
'
))
+
(
!!
(
$
(
this
).
attr
(
'
checked
'
))
?
1
:
-
1
);
self
.
data
(
'
simpletest-checked-tests
'
,
data
);
if
(
data
==
checkboxes
.
length
)
{
checkbox
.
attr
(
'
checked
'
,
'
checked
'
);
}
else
{
checkbox
.
removeAttr
(
'
checked
'
);
}
}).
attr
(
'
checked
'
)
==
'
checked
'
)
{
totalCheckboxes
++
;
var
testCheckboxes
=
Drupal
.
settings
.
simpleTest
[
'
simpletest-test-group-
'
+
$
(
this
).
attr
(
'
id
'
)].
testNames
;
var
groupCheckbox
=
$
(
'
<input type="checkbox" class="form-checkbox" id="
'
+
$
(
this
).
attr
(
'
id
'
)
+
'
-select-all" />
'
);
// Each time a single-test checkbox is checked or unchecked, make sure
// that the associated group checkbox gets the right state too.
var
updateGroupCheckbox
=
function
()
{
var
checkedTests
=
0
;
for
(
var
i
=
0
;
i
<
testCheckboxes
.
length
;
i
++
)
{
$
(
'
#
'
+
testCheckboxes
[
i
]).
each
(
function
()
{
if
((
$
(
this
).
attr
(
'
checked
'
)))
{
checkedTests
++
;
}
});
}
$
(
groupCheckbox
).
attr
(
'
checked
'
,
(
checkedTests
==
testCheckboxes
.
length
));
}
if
(
totalCheckboxes
==
checkboxes
.
length
)
{
$
(
checkbox
).
attr
(
'
checked
'
,
'
checked
'
);
// Have the single-test checkboxes follow the group checkbox.
groupCheckbox
.
change
(
function
()
{
var
checked
=
!!
(
$
(
this
).
attr
(
'
checked
'
));
for
(
var
i
=
0
;
i
<
testCheckboxes
.
length
;
i
++
)
{
$
(
'
#
'
+
testCheckboxes
[
i
]).
attr
(
'
checked
'
,
checked
);
}
});
// Have the group checkbox follow the single-test checkboxes.
for
(
var
i
=
0
;
i
<
testCheckboxes
.
length
;
i
++
)
{
$
(
'
#
'
+
testCheckboxes
[
i
]).
change
(
function
()
{
updateGroupCheckbox
();
});
}
$
(
this
).
append
(
checkbox
);
// Initialize status for the group checkbox correctly.
updateGroupCheckbox
();
$
(
this
).
append
(
groupCheckbox
);
});
}
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment