Fix whitespace, and a minor problem, in javascript-static.
Also, new, more efficient, variant of the select all checkboxes function, for when they are all in a container with an id.
This commit is contained in:
@@ -219,6 +219,24 @@ function submitFormById(id) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Either check, or uncheck, all checkboxes inside the element with id is
|
||||
* @param id the id of the container
|
||||
* @param checked the new state, either '' or 'checked'.
|
||||
*/
|
||||
function select_all_in_element_with_id(id, checked) {
|
||||
var container = document.getElementById(id);
|
||||
if (!container) {
|
||||
return;
|
||||
}
|
||||
var inputs = container.getElementsByTagName('input');
|
||||
for (var i = 0; i < inputs.length; ++i) {
|
||||
if (inputs[i].type == 'checkbox' || inputs[i].type == 'radio') {
|
||||
inputs[i].checked = checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function select_all_in(elTagName, elClass, elId) {
|
||||
var inputs = document.getElementsByTagName('input');
|
||||
inputs = filterByParent(inputs, function(el) {return findParentNode(el, elTagName, elClass, elId);});
|
||||
@@ -256,12 +274,10 @@ function confirm_if(expr, message) {
|
||||
found.
|
||||
*/
|
||||
function findParentNode(el, elName, elClass, elId) {
|
||||
while(el.nodeName.toUpperCase() != 'BODY') {
|
||||
if(
|
||||
(!elName || el.nodeName.toUpperCase() == elName) &&
|
||||
while (el.nodeName.toUpperCase() != 'BODY') {
|
||||
if ((!elName || el.nodeName.toUpperCase() == elName) &&
|
||||
(!elClass || el.className.indexOf(elClass) != -1) &&
|
||||
(!elId || el.id == elId))
|
||||
{
|
||||
(!elId || el.id == elId)) {
|
||||
break;
|
||||
}
|
||||
el = el.parentNode;
|
||||
@@ -653,9 +669,9 @@ function elementCookieHide(id, strShow, strHide) {
|
||||
|
||||
function filterByParent(elCollection, parentFinder) {
|
||||
var filteredCollection = [];
|
||||
for(var i = 0; i < elCollection.length; ++i) {
|
||||
for (var i = 0; i < elCollection.length; ++i) {
|
||||
var findParent = parentFinder(elCollection[i]);
|
||||
if(findParent.nodeName != 'BODY') {
|
||||
if (findParent.nodeName.toUpperCase != 'BODY') {
|
||||
filteredCollection.push(elCollection[i]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user