--- loncom/homework/edit.pm 2005/12/15 23:20:55 1.98 +++ loncom/homework/edit.pm 2006/04/18 22:36:23 1.101 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # edit mode helpers # -# $Id: edit.pm,v 1.98 2005/12/15 23:20:55 albertel Exp $ +# $Id: edit.pm,v 1.101 2006/04/18 22:36:23 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -504,11 +504,14 @@ sub js_change_detection { <script type="text/javascript"> var clean = true; var is_submit = false; +var still_ask = false; function compareForm(event_) { if (!event_ && window.event) { event_ = window.event; } - if (!is_submit && !clean) { + if ((!is_submit || (is_submit && still_ask)) && !clean) { + still_ask = false; + is_submit = false; event_.returnValue = "$unsaved"; return "$unsaved"; } @@ -529,6 +532,10 @@ sub element_change_detection { return ' onchange="unClean();" '; } +sub submit_ask_anyway { + return ' onclick="still_ask=true;" '; +} + sub textarea_sizes { my ($data)=@_; my $count=0; @@ -570,8 +577,8 @@ sub editfield { if ($rows < $minheight) { $rows = $minheight; } if ($description) { $description="<br />".$description."<br />"; } if ($usehtmlarea) { - push @Apache::lonxml::htmlareafields,'homework_edit_'. - $Apache::lonxml::curdepth; + &Apache::lonhtmlcommon::add_htmlareafields('homework_edit_'. + $Apache::lonxml::curdepth); } return $description."\n".' <textarea style="width:100%" rows="'.$rows. '" cols="'.$cols.'" name="homework_edit_'. @@ -676,7 +683,7 @@ sub checked_arg { $text=$option; $value='value="'.$option.'"'; } - $result.="<nobr><input type='checkbox' $value name='". + $result.="<nobr><label><input type='checkbox' $value name='". &html_element_name($name)."'"; foreach my $selected (split(/,/,$allselected)) { if ( $selected eq $option ) { @@ -684,7 +691,7 @@ sub checked_arg { last; } } - $result.=&element_change_detection()." />$text</nobr>\n"; + $result.=&element_change_detection()." />$text</label></nobr>\n"; } return $result; }