mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
*** empty log message ***
This commit is contained in:
parent
4b5c8f24db
commit
d01a38cb06
2 changed files with 45 additions and 27 deletions
|
@ -793,8 +793,8 @@ function validate_' . $this->_attributes['id'] . '(frm) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function getLockOptionStartScript(){
|
|
||||||
|
|
||||||
|
function getLockOptionEndScript(){
|
||||||
$js = '<script type="text/javascript" language="javascript">'."\n";
|
$js = '<script type="text/javascript" language="javascript">'."\n";
|
||||||
$js .= "var ".$this->getAttribute('id')."items= {";
|
$js .= "var ".$this->getAttribute('id')."items= {";
|
||||||
foreach ($this->_dependencies as $dependentOn => $elements){
|
foreach ($this->_dependencies as $dependentOn => $elements){
|
||||||
|
@ -809,14 +809,33 @@ function validate_' . $this->_attributes['id'] . '(frm) {
|
||||||
};
|
};
|
||||||
$js=rtrim($js, ",\n");
|
$js=rtrim($js, ",\n");
|
||||||
$js .= '};'."\n";
|
$js .= '};'."\n";
|
||||||
|
$js .="lockoptionsallsetup('".$this->getAttribute('id')."');\n";
|
||||||
$js .='</script>'."\n";
|
$js .='</script>'."\n";
|
||||||
return $js;
|
return $js;
|
||||||
}
|
}
|
||||||
function getLockOptionEndScript(){
|
|
||||||
$js = '<script type="text/javascript" language="javascript">'."\n";
|
function _getElNamesRecursive(&$element, $group=null){
|
||||||
$js .="lockoptionsall('".$this->getAttribute('id')."');\n";
|
if ($group==null){
|
||||||
$js .='</script>'."\n";
|
$el=$this->getElement($element);
|
||||||
return $js;
|
} else {
|
||||||
|
$el=&$element;
|
||||||
|
}
|
||||||
|
if (is_a($el, 'HTML_QuickForm_group')){
|
||||||
|
$group=$el;
|
||||||
|
$elsInGroup=$group->getElements();
|
||||||
|
$elNames=array();
|
||||||
|
foreach ($elsInGroup as $elInGroup){
|
||||||
|
$elNames = array_merge($elNames, $this->_getElNamesRecursive($elInGroup, $group));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if ($group==null){
|
||||||
|
$elNames=array($el->getName());
|
||||||
|
} else {
|
||||||
|
$elNames=array($group->getElementName($el->getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $elNames;
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Adds a dependency for $elementName which will be disabled if $condition is met.
|
* Adds a dependency for $elementName which will be disabled if $condition is met.
|
||||||
|
@ -831,23 +850,11 @@ function validate_' . $this->_attributes['id'] . '(frm) {
|
||||||
* @param string $condition the condition to check
|
* @param string $condition the condition to check
|
||||||
*/
|
*/
|
||||||
function addDependency($elementName, $dependentOn, $condition='notchecked'){
|
function addDependency($elementName, $dependentOn, $condition='notchecked'){
|
||||||
$el=$this->getElement($elementName);
|
$dependents=$this->_getElNamesRecursive($elementName);
|
||||||
if (is_a($el, 'HTML_QuickForm_group')){
|
foreach ($dependents as $dependent){
|
||||||
$group=$el;
|
|
||||||
$els=$group->getElements();
|
$this->_dependencies[$dependentOn][]=array('dependent'=>$dependent,
|
||||||
foreach (array_keys($els) as $elkey){
|
'condition'=>$condition);
|
||||||
$dependentNames[]=array('dependent'=>$group->getElementName($elkey),
|
|
||||||
'condition'=>$condition);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$dependentNames=array(array('dependent'=>$el->getName(),
|
|
||||||
'condition'=>$condition));
|
|
||||||
}
|
|
||||||
foreach ($dependentNames as $dependentName){
|
|
||||||
$dependentOnEl=$this->getElement($dependentOn);
|
|
||||||
$name=$dependentOnEl->getName();
|
|
||||||
$dependentOnEl->updateAttributes(array('onClick'=>"return lockoptionsall('".$this->getAttribute('id')."');\n"));
|
|
||||||
$this->_dependencies[$name][]=$dependentName;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -975,10 +982,7 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{
|
||||||
}
|
}
|
||||||
function finishForm(&$form){
|
function finishForm(&$form){
|
||||||
parent::finishForm($form);
|
parent::finishForm($form);
|
||||||
// add a validation script
|
// add a lockoptions script
|
||||||
if ('' != ($script = $form->getLockOptionStartScript())) {
|
|
||||||
$this->_html = $script . "\n" . $this->_html;
|
|
||||||
}
|
|
||||||
if ('' != ($script = $form->getLockOptionEndScript())) {
|
if ('' != ($script = $form->getLockOptionEndScript())) {
|
||||||
$this->_html = $this->_html . "\n" . $script;
|
$this->_html = $this->_html . "\n" . $script;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,20 @@ function lockoptionsall(formid) {
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function lockoptionsallsetup(formid) {
|
||||||
|
var items=eval(formid+'items');
|
||||||
|
var form=document.forms[formid];
|
||||||
|
for (var master in items){
|
||||||
|
form.elements[master].oldonclick = ((form.elements[master].onclick) ? form.elements[master].onclick : function () {});
|
||||||
|
form.elements[master].oldonblur = ((form.elements[master].onblur) ? form.elements[master].onblur : function () {});
|
||||||
|
form.elements[master].oldonchange = ((form.elements[master].onchange) ? form.elements[master].onchange : function () {});
|
||||||
|
form.elements[master].oldonkeypress = ((form.elements[master].onkeypress) ? form.elements[master].onkeypress : function () {});
|
||||||
|
form.elements[master].onclick = function(){this.oldonclick(); return lockoptionsall(this.form.id);};
|
||||||
|
form.elements[master].onblur = function(){this.oldonblur(); return lockoptionsall(this.form.id);};
|
||||||
|
form.elements[master].onchange = function(){this.oldonchange(); return lockoptionsall(this.form.id);};
|
||||||
|
}
|
||||||
|
return lockoptionsall(formid);
|
||||||
|
}
|
||||||
|
|
||||||
function lockoption(form,item) {
|
function lockoption(form,item) {
|
||||||
eval("document."+form+"."+item+".disabled=true");/* IE thing */
|
eval("document."+form+"."+item+".disabled=true");/* IE thing */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue