--- loncom/homework/edit.pm 2005/12/01 18:46:31 1.97
+++ loncom/homework/edit.pm 2005/12/15 23:20:55 1.98
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# edit mode helpers
#
-# $Id: edit.pm,v 1.97 2005/12/01 18:46:31 albertel Exp $
+# $Id: edit.pm,v 1.98 2005/12/15 23:20:55 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -498,6 +498,37 @@ sub insert_script {
return "\n";
}
+sub js_change_detection {
+ my $unsaved=&mt("There are unsaved changes");
+ return (<
+SCRIPT
+}
+
+sub form_change_detection {
+ return ' onsubmit="is_submit=true;" ';
+}
+
+sub element_change_detection {
+ return ' onchange="unClean();" ';
+}
+
sub textarea_sizes {
my ($data)=@_;
my $count=0;
@@ -516,10 +547,11 @@ sub editline {
my ($tag,$data,$description,$size)=@_;
$data=&HTML::Entities::encode($data,'<>&"');
if ($description) { $description="
".$description."
"; }
+ my $change_code = &element_change_detection();
my $result = <<"END";
$description
+ value="$data" size="$size" $change_code />
END
return $result;
}
@@ -544,7 +576,7 @@ sub editfield {
return $description."\n".' '.
($usehtmlarea?&Apache::lonhtmlcommon::spelllink('lonhomework',
'homework_edit_'.$Apache::lonxml::curdepth):'')."\n";
@@ -652,7 +684,7 @@ sub checked_arg {
last;
}
}
- $result.=" />$text\n";
+ $result.=&element_change_detection()." />$text\n";
}
return $result;
}
@@ -663,7 +695,8 @@ sub text_arg {
if (!defined $size) { $size=20; }
my $arg=$token->[2]{$name};
$result=&mt($description).' ';
+ '" type="text" value="'.$arg.'" size="'.$size.'" '.
+ &element_change_detection().'/>';
return ''.$result.'';
}
@@ -689,7 +722,7 @@ sub select_arg {
}
}
$result.=''.$description.' ';
return $result;
@@ -722,6 +755,7 @@ sub select_or_text_arg {
((!$found)?' selected="selected"':'').
">".&mt('Type-in value')."\n";
#
+ my $change_code=&element_change_detection();
my $element=&html_element_name($name);
my $selectelement='select_list_'.$element;
my $typeinelement='type_in_'.$element;
@@ -746,7 +780,7 @@ $optionlist
value="$typeinvalue"
onChange="$hiddenvalue=$typedinvalue;"
onFocus="$selectedindex=$selecttypeinindex-1;" />
-
+
ENDSELECTORTYPE
}