MDL-12389 Added a new getElementsByClassName function in lib/javascript.php, added the selectallornone formslib element, modified the advcheckbox element to support the group variable, and implemented the new element in grade_export_form
This commit is contained in:
@@ -87,5 +87,34 @@ function inserttext(text) {
|
||||
$focus=false; // Prevent themes from adding it to body tag which breaks addonload(), MDL-10249
|
||||
} ?>
|
||||
|
||||
function getElementsByClassName(oElm, strTagName, oClassNames){
|
||||
var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
|
||||
var arrReturnElements = new Array();
|
||||
var arrRegExpClassNames = new Array();
|
||||
if(typeof oClassNames == "object"){
|
||||
for(var i=0; i<oClassNames.length; i++){
|
||||
arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
|
||||
}
|
||||
}
|
||||
else{
|
||||
arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
|
||||
}
|
||||
var oElement;
|
||||
var bMatchesAll;
|
||||
for(var j=0; j<arrElements.length; j++){
|
||||
oElement = arrElements[j];
|
||||
bMatchesAll = true;
|
||||
for(var k=0; k<arrRegExpClassNames.length; k++){
|
||||
if(!arrRegExpClassNames[k].test(oElement.className)){
|
||||
bMatchesAll = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(bMatchesAll){
|
||||
arrReturnElements.push(oElement);
|
||||
}
|
||||
}
|
||||
return (arrReturnElements)
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user