1
0
mirror of https://github.com/moodle/moodle.git synced 2025-05-01 06:01:12 +02:00
moodle/lib/javascript-static.js
defacer 7678e65cac New useful function submitFormById(). Fires off the form's onsubmit() handler first,
if applicable, and only submits if the handler doesn't exist or returns true.
2005-03-08 04:22:38 +00:00

72 lines
1.7 KiB
JavaScript

function popUpProperties(inobj) {
op = window.open();
op.document.open('text/plain');
for (objprop in inobj) {
op.document.write(objprop + ' => ' + inobj[objprop] + '\n');
}
op.document.close();
}
function fillmessagebox(text) {
document.form.message.value = text;
}
function copyrichtext(textname) {
/// Legacy stub for old editor - to be removed soon
return true;
}
function checkall() {
void(d=document);
void(el=d.getElementsByTagName('INPUT'));
for(i=0;i<el.length;i++)
void(el[i].checked=1)
}
function checknone() {
void(d=document);
void(el=d.getElementsByTagName('INPUT'));
for(i=0;i<el.length;i++)
void(el[i].checked=0)
}
function lockoptions(form, master, subitems) {
// subitems is an array of names of sub items
// requires that each item in subitems has a
// companion hidden item in the form with the
// same name but prefixed by "h"
if (eval("document."+form+"."+master+".checked")) {
for (i=0; i<subitems.length; i++) {
unlockoption(form, subitems[i]);
}
} else {
for (i=0; i<subitems.length; i++) {
lockoption(form, subitems[i]);
}
}
return(true);
}
function lockoption(form,item) {
eval("document."+form+"."+item+".disabled=true");/* IE thing */
eval("document."+form+".h"+item+".value=1");
}
function unlockoption(form,item) {
eval("document."+form+"."+item+".disabled=false");/* IE thing */
eval("document."+form+".h"+item+".value=0");
}
function submitFormById(id) {
var theform = document.getElementById(id);
if(!theform) {
return false;
}
if(theform.tagName != 'FORM') {
return false;
}
if(!theform.onsubmit || theform.onsubmit()) {
return theform.submit();
}
}