[LON-CAPA-cvs] cvs: loncom /interface lonpreferences.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Sun, 13 May 2007 22:04:09 -0000
This is a MIME encoded message
--raeburn1179093849
Content-Type: text/plain
raeburn Sun May 13 18:04:09 2007 EDT
Modified files:
/loncom/interface lonpreferences.pm
Log:
Bug 5266. Various clarifications to interface - see comment on bug report.
- Added some <label>s and some non-breakng <span>s for checkboxes.
--raeburn1179093849
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20070513180409.txt"
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.103 loncom/interface/lonpreferences.pm:1.104
--- loncom/interface/lonpreferences.pm:1.103 Tue May 8 14:26:54 2007
+++ loncom/interface/lonpreferences.pm Sun May 13 18:04:06 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Preferences
#
-# $Id: lonpreferences.pm,v 1.103 2007/05/08 18:26:54 raeburn Exp $
+# $Id: lonpreferences.pm,v 1.104 2007/05/13 22:04:06 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -578,7 +578,7 @@
foad => 'Forwarding Address(es)',
mnot => 'Message Notification Email Address(es)',
chg => 'Change',
- email => 'The e-mail address you entered',
+ email => 'The e-mail address entered in row ',
notv => 'is not a valid e-mail address',
toen => "To enter multiple addresses, enter one address at a time, click 'Change' and then add the next one",
prme => 'Back to preferences menu',
@@ -595,28 +595,56 @@
my $jscript = qq|
<script type="text/javascript">
function validate() {
- var checkaddress = 0;
for (var i=0; i<document.prefs.numnotify.value; i++) {
+ var checkaddress = 0;
var addr = document.prefs.elements['address_'+i].value;
+ var rownum = i+1;
if (i < document.prefs.numnotify.value-1) {
- if (document.prefs.elements['del_notify_'+i].value == false) {
+ if (document.prefs.elements['modify_notify_'+i].checked) {
checkaddress = 1;
- }
+ }
} else {
if (document.prefs.elements['add_notify_'+i].checked == true) {
checkaddress = 1;
}
}
- if (checkaddress== 1) {
+ if (checkaddress == 1) {
var addr = document.prefs.elements['address_'+i].value;
if (validmail(document.prefs.elements['address_'+i]) == false) {
- alert("$lt{'email'}: "+addr+" $lt{'notv'}.\\n($lt{'toen'}).");
+ var multimsg = '';
+ if (addr.indexOf(",") >= 0) {
+ multimsg = "\\n($lt{'toen'}).";
+ }
+ alert("$lt{'email'} "+rownum+": '"+addr+"' $lt{'notv'}."+multimsg);
return;
}
}
}
document.prefs.submit();
}
+
+function address_changes (adnum) {
+ if (!document.prefs.elements['del_notify_'+adnum].checked) {
+ document.prefs.elements['modify_notify_'+adnum].checked = true;
+ }
+}
+
+function new_address(adnum) {
+ document.prefs.elements['add_notify_'+adnum].checked = true;
+}
+
+function delete_address(adnum) {
+ if (document.prefs.elements['del_notify_'+adnum].checked) {
+ document.prefs.elements['modify_notify_'+adnum].checked = false;
+ }
+}
+
+function modify_address(adnum) {
+ if (document.prefs.elements['modify_notify_'+adnum].checked) {
+ document.prefs.elements['del_notify_'+adnum].checked = false;
+ }
+}
+
$validatescript
</script>
|;
@@ -634,18 +662,28 @@
my @sortforwards = sort (keys(%allnot));
my $output = &Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
+ '<th> </th>'.
'<th>'.&mt('Action').'</th>'.
'<th>'.&mt('Notification address').'</th><th>'.
- &mt('Messages to forward').'</th><th>'.
- &mt('Excerpt retains HTML tags included in message').'</th>'.
+ &mt('Types of message to forward to this address').'</th><th>'.
+ &mt('Excerpt retains HTML tags in message').'</th>'.
&Apache::loncommon::end_data_table_header_row();
my $num = 0;
+ my $counter = 1;
foreach my $item (@sortforwards) {
$output .= &Apache::loncommon::start_data_table_row().
- '<td><input type="checkbox" name="del_notify_'.$num.'" />'.
- &mt('Delete').'</td>'.
+ '<td><b>'.$counter.'</b></td>'.
+ '<td><span class="LC_nobreak"><label>'.
+ '<input type="checkbox" name="modify_notify_'.
+ $num.'" onclick="javscript:modify_address('."'$num'".')" />'.
+ &mt('Modify').'</label></span> '.
+ '<span class="LC_nobreak"><label>'.
+ '<input type="checkbox" name="del_notify_'.$num.
+ '" onclick="javscript:delete_address('."'$num'".')" />'.
+ &mt('Delete').'</label></span></td>'.
'<td><input type="text" value="'.$item.'" name="address_'.
- $num.'" /></td><td>';
+ $num.'" onFocus="javascript:address_changes('."'$num'".
+ ')" /></td><td>';
my %chk;
if (defined($allnot{$item}{'crit'})) {
if (defined($allnot{$item}{'reg'})) {
@@ -659,7 +697,9 @@
foreach my $type ('all','crit','reg') {
$output .= '<span class="LC_nobreak"><label>'.
'<input type="radio" name="notify_type_'.$num.
- '" value="'.$type.'" '.$chk{$type}.'/>'.$lt{$type}.'</label></span> ';
+ '" value="'.$type.'" '.$chk{$type}.
+ ' onchange="javascript:address_changes('."'$num'".')" />'.
+ $lt{$type}.'</label></span> ';
}
my $htmlon = '';
my $htmloff = '';
@@ -669,11 +709,16 @@
$htmloff = 'checked="checked" ';
}
$output .= '</td><td><label><input type="radio" name="html_'.$num.
- '" value="1" '.$htmlon.'/>'.&mt('Yes').'</label> '.
+ '" value="1" '.$htmlon.
+ ' onchange="javascript:address_changes('."'$num'".')" />'.
+ &mt('Yes').'</label> '.
'<label><input type="radio" name="html_'.$num.'" value="0" '.
- $htmloff.'/>'.&mt('No').'</label></td>'.
+ $htmloff. ' onchange="javascript:address_changes('."'$num'".
+')" />'.
+ &mt('No').'</label></td>'.
&Apache::loncommon::end_data_table_row();
$num ++;
+ $counter ++;
}
my %defchk = (
all => 'checked="checked" ',
@@ -681,10 +726,12 @@
reg => '',
);
$output .= &Apache::loncommon::start_data_table_row().
- '<td><input type="checkbox" name="add_notify_'.$num.'" />'.
- &mt('Add').'</td>'.
+ '<td><b>'.$counter.'</b></td>'.
+ '<td><span class="LC_nobreak"><label>'.
+ '<input type="checkbox" name="add_notify_'.$num.
+ '" value="1" />'.&mt('Add new address').'</label></span></td>'.
'<td><input type="text" value="" name="address_'.$num.
- '" /></td><td>';
+ '" onFocus="javascript:new_address('."'$num'".')" /></td><td>';
foreach my $type ('all','crit','reg') {
$output .= '<span class="LC_nobreak"><label>'.
'<input type="radio" name="notify_type_'.$num.
@@ -757,9 +804,10 @@
my $notification;
my $notify_with_html;
my $lastnotify = $env{'form.numnotify'}-1;
+ my $totaladdresses = 0;
for (my $i=0; $i<$env{'form.numnotify'}; $i++) {
if ((!defined($env{'form.del_notify_'.$i})) &&
- ((($i==$lastnotify) && (defined($env{'form.add_notify_'.$lastnotify}))) ||
+ ((($i==$lastnotify) && ($env{'form.add_notify_'.$lastnotify} == 1)) ||
($i<$lastnotify))) {
if (defined($env{'form.address_'.$i})) {
if ($env{'form.notify_type_'.$i} eq 'all') {
@@ -773,6 +821,7 @@
if ($env{'form.html_'.$i} eq '1') {
$notify_with_html .= $env{'form.address_'.$i}.',';
}
+ $totaladdresses ++;
}
}
}
@@ -798,7 +847,7 @@
} else {
&Apache::lonnet::del('environment',['critnotification']);
&Apache::lonnet::delenv('environment\.critnotification');
- $message.=&mt('Critical message notification set to off').'<br />';
+ $message.=&mt("Critical message notification set to 'off'.").'<br />';
}
if ($critnotification || $notification) {
if ($notify_with_html) {
@@ -808,7 +857,11 @@
} else {
&Apache::lonnet::del('environment',['notifywithhtml']);
&Apache::lonnet::delenv('environment\.notifywithhtml');
- $message.=&mt("Set all notification address(es) to receive excerpts with html stripped.").'<br />';
+ if ($totaladdresses == 1) {
+ $message.=&mt("Set notification address to receive excerpts with html stripped.");
+ } else {
+ $message.=&mt("Set all notification addresses to receive excerpts with html stripped.");
+ }
}
} else {
&Apache::lonnet::del('environment',['notifywithhtml']);
--raeburn1179093849--