[LON-CAPA-cvs] cvs: loncom /interface domainprefs.pm lonhtmlcommon.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Wed, 26 Sep 2007 12:42:32 -0000
This is a MIME encoded message
--raeburn1190810552
Content-Type: text/plain
raeburn Wed Sep 26 08:42:32 2007 EDT
Modified files:
/loncom/interface domainprefs.pm lonhtmlcommon.pm
Log:
lonhtmlcommon.pm
- javascript to get dimensions of user's browser window.
domainprefs.pm
- show background colors, font colors
- add page to selection functionality to display/edit
- choice of one or two column format
- in two-column format, balance items between two columns
--raeburn1190810552
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20070926084232.txt"
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.29 loncom/interface/domainprefs.pm:1.30
--- loncom/interface/domainprefs.pm:1.29 Wed Sep 19 13:36:47 2007
+++ loncom/interface/domainprefs.pm Wed Sep 26 08:42:32 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.29 2007/09/19 17:36:47 raeburn Exp $
+# $Id: domainprefs.pm,v 1.30 2007/09/26 12:42:32 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -61,7 +61,7 @@
&Apache::lonhtmlcommon::clear_breadcrumbs();
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['phase']);
- my $phase = "display";
+ my $phase = 'pickactions';
if ( exists($env{'form.phase'}) ) {
$phase = $env{'form.phase'};
}
@@ -69,91 +69,168 @@
&Apache::lonnet::get_dom('configuration',['login','rolecolors',
'quotas','autoenroll','autoupdate','directorysrch',
'usercreation','contacts'],$dom);
- my @prefs = (
- { text => 'Default color schemes',
- help => 'Default_Color_Schemes',
- action => 'rolecolors',
- header => [{col1 => 'Student Settings',
- col2 => '',},
- {col1 => 'Coordinator Settings',
- col2 => '',},
- {col1 => 'Author Settings',
- col2 => '',},
- {col1 => 'Administrator Settings',
- col2 => '',}],
- },
- { text => 'Log-in page options',
- help => 'Domain_Log-in_Page',
- action => 'login',
- header => [{col1 => 'Item',
- col2 => '',}],
- },
- { text => 'Default quotas for user portfolios',
- help => 'Default_User_Quota',
- action => 'quotas',
- header => [{col1 => 'User type',
- col2 => 'Default quota'}],
- },
- { text => 'Auto-enrollment settings',
- help => 'Domain_Auto_Enrollment',
- action => 'autoenroll',
- header => [{col1 => 'Configuration setting',
- col2 => 'Value(s)'}],
- },
- { text => 'Auto-update settings',
- help => 'Domain_Auto_Update',
- action => 'autoupdate',
- header => [{col1 => 'Setting',
- col2 => 'Value',},
- {col1 => 'User Population',
- col2 => 'Updataeable user data'}],
- },
- { text => 'Institutional directory searches',
- help => 'Domain_Directory_Search',
- action => 'directorysrch',
- header => [{col1 => 'Setting',
- col2 => 'Value',}],
- },
- { text => 'Contact Information',
- help => 'Domain_Contact_Information',
- action => 'contacts',
- header => [{col1 => 'Setting',
- col2 => 'Value',}],
- },
-
- { text => 'User creation',
- help => 'Domain_User_Creation',
- action => 'usercreation',
- header => [{col1 => 'Setting',
- col2 => 'Value',},
- {col1 => 'Context',
- col2 => 'Assignable Authentication Types'}],
- },
+ my @prefs_order = ('rolecolors','login','quotas','autoenroll',
+ 'autoupdate','directorysrch','contacts',
+ 'usercreation');
+ my %prefs = (
+ 'rolecolors' =>
+ { text => 'Default color schemes',
+ help => 'Default_Color_Schemes',
+ header => [{col1 => 'Student Settings',
+ col2 => '',},
+ {col1 => 'Coordinator Settings',
+ col2 => '',},
+ {col1 => 'Author Settings',
+ col2 => '',},
+ {col1 => 'Administrator Settings',
+ col2 => '',}],
+ },
+ 'login' =>
+ { text => 'Log-in page options',
+ help => 'Domain_Log-in_Page',
+ header => [{col1 => 'Item',
+ col2 => '',}],
+ },
+ 'quotas' =>
+ { text => 'Default quotas for user portfolios',
+ help => 'Default_User_Quota',
+ header => [{col1 => 'User type',
+ col2 => 'Default quota'}],
+ },
+ 'autoenroll' =>
+ { text => 'Auto-enrollment settings',
+ help => 'Domain_Auto_Enrollment',
+ header => [{col1 => 'Configuration setting',
+ col2 => 'Value(s)'}],
+ },
+ 'autoupdate' =>
+ { text => 'Auto-update settings',
+ help => 'Domain_Auto_Update',
+ header => [{col1 => 'Setting',
+ col2 => 'Value',},
+ {col1 => 'User Population',
+ col2 => 'Updataeable user data'}],
+ },
+ 'directorysrch' =>
+ { text => 'Institutional directory searches',
+ help => 'Domain_Directory_Search',
+ header => [{col1 => 'Setting',
+ col2 => 'Value',}],
+ },
+ 'contacts' =>
+ { text => 'Contact Information',
+ help => 'Domain_Contact_Information',
+ header => [{col1 => 'Setting',
+ col2 => 'Value',}],
+ },
+
+ 'usercreation' =>
+ { text => 'User creation',
+ help => 'Domain_User_Creation',
+ header => [{col1 => 'Setting',
+ col2 => 'Value',},
+ {col1 => 'Context',
+ col2 => 'Assignable Authentication Types'}],
+ },
);
my @roles = ('student','coordinator','author','admin');
+ my @actions = &Apache::loncommon::get_env_multiple('form.actions');
&Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:changePage(document.$phase,'display')",
- text=>"Domain Configuration"});
+ ({href=>"javascript:changePage(document.$phase,'pickactions')",
+ text=>"Pick functionality"});
my $confname = $dom.'-domainconfig';
if ($phase eq 'process') {
&Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:changePage(document.$phase,'$phase')",
+ ({href=>"javascript:changePage(document.$phase,'display')",
+ text=>"Domain Configuration"},
+ {href=>"javascript:changePage(document.$phase,'$phase')",
text=>"Updated"});
&print_header($r,$phase);
- foreach my $item (@prefs) {
- $r->print('<h3>'.&mt($item->{'text'}).'</h3>'.
- &process_changes($r,$dom,$confname,
- $item->{'action'},\@roles,%domconfig));
+ foreach my $item (@prefs_order) {
+ if (grep(/^\Q$item\E$/,@actions)) {
+ $r->print('<h3>'.&mt($prefs{$item}{'text'}).'</h3>'.
+ &process_changes($r,$dom,$confname,$item,
+ \@roles,%domconfig));
+ }
}
$r->print('<p>');
- &print_footer($r,$phase,'display','Back to actions menu');
+ &print_footer($r,$phase,'display','Back to configuration display',
+ \@actions);
$r->print('</p>');
+ } elsif ($phase eq 'display') {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:changePage(document.$phase,'display')",
+ text=>"Domain Configuration"});
+ &print_header($r,$phase);
+ if (@actions > 0) {
+ my $rowsum = 0;
+ my (%output,%rowtotal,@items);
+ my $halfway = @actions/2;
+ foreach my $item (@prefs_order) {
+ if (grep(/^\Q$item\E$/,@actions)) {
+ push(@items,$item);
+ ($output{$item},$rowtotal{$item}) =
+ &print_config_box($r,$dom,$confname,$phase,
+ $item,$prefs{$item},
+ $domconfig{$item});
+ $rowsum += $rowtotal{$item};
+ }
+ }
+ my $colend;
+ my $halfway = $rowsum/2;
+ my $aggregate = 0;
+ my $sumleft = 0;
+ my $sumright = 0;
+ my $crossover;
+ for (my $i=0; $i<@items; $i++) {
+ $aggregate += $rowtotal{$items[$i]};
+ if ($aggregate > $halfway) {
+ $crossover = $i;
+ last;
+ }
+ }
+ for (my $i=0; $i<$crossover; $i++) {
+ $sumleft += $rowtotal{$items[$i]};
+ }
+ for (my $i=$crossover+1; $i<@items; $i++) {
+ $sumright += $rowtotal{$items[$i]};
+ }
+ if ((@items > 1) && ($env{'form.numcols'} == 2)) {
+ my $sumdiff = $sumright - $sumleft;
+ if ($sumdiff > 0) {
+ $colend = $crossover + 1;
+ } else {
+ $colend = $crossover;
+ }
+ } else {
+ $colend = @items;
+ }
+ $r->print('<p><table class="LC_double_column"><tr><td class="LC_left_col">');
+ for (my $i=0; $i<$colend; $i++) {
+ $r->print($output{$items[$i]});
+ }
+ $r->print('</td><td></td><td class="LC_right_col">');
+ if ($colend < @items) {
+ for (my $i=$colend; $i<@items; $i++) {
+ $r->print($output{$items[$i]});
+ }
+ }
+ $r->print('</td></tr></table></p>');
+ $r->print(&print_footer($r,$phase,'process','Save',\@actions));
+ } else {
+ $r->print('<input type="hidden" name="phase" value="" />'.
+ '<input type="hidden" name="numcols" value="'.
+ $env{'form.numcols'}.'" />'."\n".
+ '<span clas="LC_error">'.&mt('No settings chosen').
+ '</span>');
+ }
+ $r->print('</form>');
+ $r->print(&Apache::loncommon::end_page());
} else {
if ($phase eq '') {
- $phase = 'display';
+ $phase = 'pickactions';
}
- my %helphash;
- my $numprefs = @prefs;
+ my %helphash;
&print_header($r,$phase);
if (keys(%domconfig) == 0) {
my $primarylibserv = &Apache::lonnet::domain($dom,'primary');
@@ -180,25 +257,33 @@
&mt("Thereafter, (with a Domain Coordinator role selected in the domain) you will be able to update settings when logged in to any server in the LON-CAPA network.").'<br />'.
&mt("However, you will still need to switch to the domain's primary library server to upload new images or logos.").'<br /><br />');
if ($switch_server) {
- $r->print($switch_server.' '.&mt('to primary library server for domain: [_1]',$dom));
+ $r->print($switch_server.' '.&mt('to primary library server for domain: [_1]',$dom));
}
return OK;
}
}
}
- $r->print('<table border="0" width="100%" cellpadding="2" cellspacing="4"><tr><td align="left" valign="top" width="45%">');
- foreach my $item (@prefs) {
- if ($item->{'action'} eq 'login') {
- $r->print('</td><td width="6%"> </td><td align="left" valign="top" width="47%">');
- }
- &print_config_box($r,$dom,$confname,$phase,$item->{'action'},
- $item,$domconfig{$item->{'action'}});
- }
- $r->print('
- </td>
- </tr>
- </table>');
- &print_footer($r,$phase,'process','Save changes');
+ $r->print('<h3>'.&mt('Functionality to display/modify').'</h3>');
+ $r->print('<script type="text/javascript">'."\n".
+ &Apache::loncommon::check_uncheck_jscript()."\n".
+ '</script>'."\n".'<p><input type="button" value="check all" '.
+ 'onclick="javascript:checkAll(document.pickactions.actions)"'.
+ ' /> '.
+ '<input type="button" value="uncheck all" '.
+ 'onclick="javascript:uncheckAll(document.pickactions.actions)"'.
+ ' /></p>');
+ foreach my $item (@prefs_order) {
+ $r->print('<p><label><input type="checkbox" name="actions" value="'.$item.'" /> '.$prefs{$item}->{'text'}.'</label></p>');
+ }
+ $r->print('<h3>'.&mt('Display options').'</h3>'."\n".
+ '<p><span class="LC_nobreak">'.&mt('Display using: ')."\n".
+ '<label><input type="radio" name="numcols" value="1">'.
+ &mt('one column').'</label> '.
+ '<input type="radio" name="numcols" value="2">'.
+ &mt('two columns').'</label></span></p>');
+ $r->print(&print_footer($r,$phase,'display','Go'));
+ $r->print('</form>');
+ $r->print(&Apache::loncommon::end_page());
}
return OK;
}
@@ -229,34 +314,38 @@
sub print_config_box {
my ($r,$dom,$confname,$phase,$action,$item,$settings) = @_;
- $r->print('
- <table class="LC_nested_outer">
+ my $rowtotal = 0;
+ my $output =
+ '<table class="LC_nested_outer">
<tr>
- <th>'.&mt($item->{text}).' </th></tr>');
+ <th align="left"><span class="LC_nobreak">'.&mt($item->{text}).
+ ' </span></th></tr>';
#
# FIXME - put the help link back in when the help files exist
# <th>'.&mt($item->{text}).' '.
# &Apache::loncommon::help_open_topic($item->{'help'}).'</th>
# </tr>');
+ $rowtotal ++;
if (($action eq 'autoupdate') || ($action eq 'rolecolors') ||
($action eq 'usercreation')) {
my $colspan = ($action eq 'rolecolors')?' colspan="2"':'';
- $r->print('
+ $output .= '
<tr>
<td>
<table class="LC_nested">
<tr class="LC_info_row">
<td class="LC_left_item"'.$colspan.'>'.$item->{'header'}->[0]->{'col1'}.'</td>
<td class="LC_right_item">'.$item->{'header'}->[0]->{'col2'}.'</td>
- </tr>');
+ </tr>';
+ $rowtotal ++;
if ($action eq 'autoupdate') {
- $r->print(&print_autoupdate('top',$dom,$settings));
+ $output .= &print_autoupdate('top',$dom,$settings,\$rowtotal);
} elsif ($action eq 'usercreation') {
- $r->print(&print_usercreation('top',$dom,$settings));
+ $output .= &print_usercreation('top',$dom,$settings,\$rowtotal);
} else {
- $r->print(&print_rolecolors($phase,'student',$dom,$confname,$settings));
+ $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
}
- $r->print('
+ $output .= '
</table>
</td>
</tr>
@@ -266,13 +355,14 @@
<tr class="LC_info_row">
<td class="LC_left_item"'.$colspan.'>'.$item->{'header'}->[1]->{'col1'}.'</td>
<td class="LC_right_item">'.$item->{'header'}->[1]->{'col2'}.'</td>
- </tr>');
+ </tr>';
+ $rowtotal ++;
if ($action eq 'autoupdate') {
- $r->print(&print_autoupdate('bottom',$dom,$settings));
+ $output .= &print_autoupdate('bottom',$dom,$settings,\$rowtotal);
} elsif ($action eq 'usercreation') {
- $r->print(&print_usercreation('bottom',$dom,$settings));
+ $output .= &print_usercreation('bottom',$dom,$settings,\$rowtotal);
} else {
- $r->print(&print_rolecolors($phase,'coordinator',$dom,$confname,$settings).'
+ $output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
</table>
</td>
</tr>
@@ -283,7 +373,7 @@
<td class="LC_left_item"'.$colspan.'>'.$item->{'header'}->[2]->{'col1'}.'</td>
<td class="LC_right_item">'.$item->{'header'}->[2]->{'col2'}.'</td>
</tr>'.
- &print_rolecolors($phase,'author',$dom,$confname,$settings).'
+ &print_rolecolors($phase,'author',$dom,$confname,$settings,\$rowtotal).'
</table>
</td>
</tr>
@@ -294,58 +384,99 @@
<td class="LC_left_item"'.$colspan.'>'.$item->{'header'}->[3]->{'col1'}.'</td>
<td class="LC_right_item">'.$item->{'header'}->[3]->{'col2'}.'</td>
</tr>'.
- &print_rolecolors($phase,'admin',$dom,$confname,$settings));
+ &print_rolecolors($phase,'admin',$dom,$confname,$settings,\$rowtotal);
+ $rowtotal += 2;
}
} else {
- $r->print('
+ $output .= '
<tr>
<td>
<table class="LC_nested">
- <tr class="LC_info_row">');
+ <tr class="LC_info_row">';
if (($action eq 'login') || ($action eq 'directorysrch')) {
- $r->print('
- <td class="LC_left_item" colspan="2">'.$item->{'header'}->[0]->{'col1'}.'</td>');
+ $output .= '
+ <td class="LC_left_item" colspan="2">'.$item->{'header'}->[0]->{'col1'}.'</td>';
} else {
- $r->print('
- <td class="LC_left_item">'.$item->{'header'}->[0]->{'col1'}.'</td>');
+ $output .= '
+ <td class="LC_left_item">'.$item->{'header'}->[0]->{'col1'}.'</td>';
}
- $r->print('
+ $output .= '
<td class="LC_right_item">'.$item->{'header'}->[0]->{'col2'}.'</td>
- </tr>');
+ </tr>';
+ $rowtotal ++;
if ($action eq 'login') {
- $r->print(&print_login($dom,$confname,$phase,$settings));
+ $output .= &print_login($dom,$confname,$phase,$settings,\$rowtotal);
} elsif ($action eq 'quotas') {
- $r->print(&print_quotas($dom,$settings));
+ $output .= &print_quotas($dom,$settings,\$rowtotal);
} elsif ($action eq 'autoenroll') {
- $r->print(&print_autoenroll($dom,$settings));
+ $output .= &print_autoenroll($dom,$settings,\$rowtotal);
} elsif ($action eq 'directorysrch') {
- $r->print(&print_directorysrch($dom,$settings));
+ $output .= &print_directorysrch($dom,$settings,\$rowtotal);
} elsif ($action eq 'contacts') {
- $r->print(&print_contacts($dom,$settings));
+ $output .= &print_contacts($dom,$settings,\$rowtotal);
}
}
- $r->print('
+ $output .= '
</table>
</td>
</tr>
-</table><br />');
- return;
+</table><br />';
+ return ($output,$rowtotal);
}
sub print_header {
my ($r,$phase) = @_;
+ my $alert = &mt('You must select at least one functionality type to display.');
my $js = '
<script type="text/javascript">
function changePage(formname,newphase) {
formname.phase.value = newphase;
+ numchecked = 0;
+ if (formname == document.pickactions) {
+ if (formname.actions.length > 0) {
+ for (var i = 0; i <formname.actions.length; i++) {
+ if (formname.actions[i].checked) {
+ numchecked ++;
+ }
+ }
+ } else {
+ if (formname.actions.checked) {
+ numchecked ++;
+ }
+ }
+ if (numchecked > 0) {
+ formname.submit();
+ } else {
+ alert("'.$alert.'");
+ return;
+ }
+ }
formname.submit();
-}
-'.
-&color_pick_js().'
+}'."\n";
+ if ($phase eq 'pickactions') {
+ $js .=
+ &Apache::lonhtmlcommon::set_form_elements({actions => 'checkbox',numcols => 'radio',})."\n".
+ &javascript_set_colnums();
+ } elsif ($phase eq 'display') {
+ $js .= &color_pick_js()."\n";
+ }
+ $js .= &Apache::lonhtmlcommon::javascript_window_dims().'
</script>
';
+ my $additem;
+ if ($phase eq 'pickactions') {
+ my %loaditems = (
+ 'onload' => "javascript:;getDimensions(document.$phase.width,document.$phase.height);setDisplayColumns();setFormElements(document.pickactions);",
+ );
+ $additem = {'add_entries' => \%loaditems,};
+ } else {
+ my %loaditems = (
+ 'onload' => "javascript:getDimensions(document.$phase.width,document.$phase.height)",
+ );
+ $additem = {'add_entries' => \%loaditems,};
+ }
$r->print(&Apache::loncommon::start_page('View/Modify Domain Settings',
- $js));
+ $js,$additem));
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Domain Settings'));
$r->print('
<form name="parmform" action="">
@@ -360,23 +491,42 @@
}
sub print_footer {
- my ($r,$phase,$newphase,$button_text) = @_;
+ my ($r,$phase,$newphase,$button_text,$actions) = @_;
$button_text = &mt($button_text);
- $r->print('<input type="hidden" name="phase" value="" />');
+ $r->print('<input type="hidden" name="phase" value="" />'.
+ '<input type="hidden" name="width" value="'.
+ $env{'form.width'}.'" />'.
+ '<input type="hidden" name="height" value="'.
+ $env{'form.height'}.'" />');
+ if (($phase eq 'display') || ($phase eq 'process')) {
+ if (ref($actions) eq 'ARRAY') {
+ foreach my $item (@{$actions}) {
+ $r->print('<input type="hidden" name="actions" value="'.$item.'" />')."\n";
+ }
+ }
+ $r->print('<input type="hidden" name="numcols" value="'.$env{'form.numcols'}.'" />');
+ }
my $dest='"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
if ($phase eq 'process') {
- $r->print('<a href='.$dest.'>'.$button_text.'</a>');
+ $r->print('<p><a href='.$dest.'>'.$button_text.'</a></p>');
} else {
- $r->print('<input type="button" name="store" value="'.
- $button_text.'" onclick='.$dest.' />');
+ my $onclick;
+ if ($phase eq 'display') {
+ $onclick = '"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
+ } else {
+ $onclick = '"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
+ }
+ $r->print('<p><input type="button" name="store" value="'.
+ $button_text.'" onclick='.$onclick.' /></p>');
+ }
+ if ($phase eq 'process') {
+ $r->print('</form>'.&Apache::loncommon::end_page());
}
- $r->print('</form>');
- $r->print('<br />'.&Apache::loncommon::end_page());
return;
}
sub print_login {
- my ($dom,$confname,$phase,$settings) = @_;
+ my ($dom,$confname,$phase,$settings,$rowtotal) = @_;
my %choices = &login_choices();
my ($catalogon,$catalogoff,$adminmailon,$adminmailoff);
$catalogon = ' checked="checked" ';
@@ -477,7 +627,7 @@
'<label><input type="radio" name="adminmail"'.
$adminmailoff.'value="0" />'.&mt('No').'</label></span></td></tr>';
$itemcount ++;
- $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text);
+ $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal);
$datatable .= '</tr></table></td></tr>';
return $datatable;
}
@@ -504,7 +654,7 @@
}
sub print_rolecolors {
- my ($phase,$role,$dom,$confname,$settings) = @_;
+ my ($phase,$role,$dom,$confname,$settings,$rowtotal) = @_;
my %choices = &color_font_choices();
my @bgs = ('pgbg','tabbg','sidebg');
my @links = ('link','alink','vlink');
@@ -570,19 +720,19 @@
}
}
my $itemcount = 1;
- my $datatable = &display_color_options($dom,$confname,$phase,$role,$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text);
+ my $datatable = &display_color_options($dom,$confname,$phase,$role,$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal);
$datatable .= '</tr></table></td></tr>';
return $datatable;
}
sub display_color_options {
my ($dom,$confname,$phase,$role,$itemcount,$choices,$is_custom,$defaults,$designs,
- $images,$bgs,$links,$alt_text) = @_;
+ $images,$bgs,$links,$alt_text,$rowtotal) = @_;
my $css_class = $itemcount%2?' class="LC_odd_row"':'';
my $datatable = '<tr'.$css_class.'>'.
'<td>'.$choices->{'font'}.'</td>';
if (!$is_custom->{'font'}) {
- $datatable .= '<td>'.&mt('Default in use:').' '.$defaults->{'font'}.'</td>';
+ $datatable .= '<td>'.&mt('Default in use:').' <span id="css_default_'.$role.'_font" style="color: '.$defaults->{'font'}.';">'.$defaults->{'font'}.'</span></td>';
} else {
$datatable .= '<td> </td>';
}
@@ -590,6 +740,8 @@
$datatable .= '<td><span class="LC_nobreak">'.
'<input type="text" size="10" name="'.$role.'_font"'.
' value="'.$designs->{'font'}.'" /> '.$fontlink.
+ ' <span id="css_'.$role.'_font" style="background-color: '.
+ $designs->{'font'}.';"> </span>'.
'</span></td></tr>';
my $switchserver = &check_switchserver($dom,$confname);
foreach my $img (@{$images}) {
@@ -685,7 +837,7 @@
my $bgs_def;
foreach my $item (@{$bgs}) {
if (!$is_custom->{$item}) {
- $bgs_def .= '<td>'.$choices->{$item}.'<br />'.$defaults->{'bgs'}{$item}.'</td>';
+ $bgs_def .= '<td>'.$choices->{$item}.' <span id="css_default_'.$role.'_'.$item.'" style="background-color: '.$defaults->{'bgs'}{$item}.';"> </span><br />'.$defaults->{'bgs'}{$item}.'</td>';
}
}
if ($bgs_def) {
@@ -699,10 +851,10 @@
my $link = &color_pick($phase,$role,$item,$choices->{$item},$designs->{'bgs'}{$item});
$datatable .= '<td align="center">'.$link;
if ($designs->{'bgs'}{$item}) {
- $datatable .= '<span style="background-color:'.$designs->{'bgs'}{$item}.'width: 10px"> </span>';
+ $datatable .= ' <span id="css_'.$role.'_'.$item.'" style="background-color: '.$designs->{'bgs'}{$item}.';"> </span>';
}
$datatable .= '<br /><input type="text" size="8" name="'.$role.'_'.$item.'" value="'.$designs->{'bgs'}{$item}.
- '" /></td>';
+ '" onblur = "javascript:document.display.css_'.$role.'_'.$item.'.style.background-color = document.display.'.$role.'_'.$item.'.value;"/></td>';
}
$datatable .= '</tr></table></td></tr>';
$itemcount ++;
@@ -712,7 +864,7 @@
my $links_def;
foreach my $item (@{$links}) {
if (!$is_custom->{$item}) {
- $links_def .= '<td>'.$choices->{$item}.'<br />'.$defaults->{'links'}{$item}.'</td>';
+ $links_def .= '<td>'.$choices->{$item}.'<br /><span id="css_default_'.$role.'_'.$item.'" style="color: '.$defaults->{'links'}{$item}.';">'.$defaults->{'links'}{$item}.'</span></td>';
}
}
if ($links_def) {
@@ -723,17 +875,16 @@
$datatable .= '<td class="LC_right_item">'.
'<table border="0"><tr>';
foreach my $item (@{$links}) {
- $datatable .= '<td align="center">';
- my $link = &color_pick($phase,$role,$item,$choices->{$item},$designs->{'links'}{$item});
+ $datatable .= '<td align="center">'."\n".
+ &color_pick($phase,$role,$item,$choices->{$item},
+ $designs->{'links'}{$item});
if ($designs->{'links'}{$item}) {
- $datatable.='<span style="color: '.$designs->{'links'}{$item}.';">'.
- $link.'</span>';
- } else {
- $datatable .= $link;
+ $datatable.=' <span id="css_'.$role.'_'.$item.'" style="background-color: '.$designs->{'links'}{$item}.';"> </span>';
}
$datatable .= '<br /><input type="text" size="8" name="'.$role.'_'.$item.'" value="'.$designs->{'links'}{$item}.
'" /></td>';
}
+ $$rowtotal += $itemcount;
return $datatable;
}
@@ -773,7 +924,7 @@
}
sub print_quotas {
- my ($dom,$settings) = @_;
+ my ($dom,$settings,$rowtotal) = @_;
my $datatable;
my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
my $typecount = 0;
@@ -805,11 +956,12 @@
'<td class="LC_right_item"><span class="LC_nobreak">'.
'<input type="text" name="defaultquota" value="'.
$defaultquota.'" size="5" /> Mb</span></td></tr>';
+ $$rowtotal += $typecount;
return $datatable;
}
sub print_autoenroll {
- my ($dom,$settings) = @_;
+ my ($dom,$settings,$rowtotal) = @_;
my $autorun = &Apache::lonnet::auto_run(undef,$dom),
my ($defdom,$runon,$runoff);
if (ref($settings) eq 'HASH') {
@@ -858,11 +1010,12 @@
$settings->{'sender_uname'}.
'" size="10" /> '.&mt('domain').
': '.$domform.'</span></td></tr>';
+ $$rowtotal += 2;
return $datatable;
}
sub print_autoupdate {
- my ($position,$dom,$settings) = @_;
+ my ($position,$dom,$settings,$rowtotal) = @_;
my $datatable;
if ($position eq 'top') {
my $updateon = ' ';
@@ -898,6 +1051,7 @@
'<label><input type="radio" name="classlists"'.
$classlistsoff.'value="0" />'.&mt('No').'</label></span></td>'.
'</tr>';
+ $$rowtotal += 2;
} else {
my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
my @fields = ('lastname','firstname','middlename','gen',
@@ -916,18 +1070,20 @@
$datatable =
&usertype_update_row($settings,$usertypes,\%fieldtitles,
\@fields,$types,\$numrows);
+ $$rowtotal += @{$types};
}
}
$datatable .=
&usertype_update_row($settings,{'default' => $othertitle},
\%fieldtitles,\@fields,['default'],
\$numrows);
+ $$rowtotal ++;
}
return $datatable;
}
sub print_directorysrch {
- my ($dom,$settings) = @_;
+ my ($dom,$settings,$rowtotal) = @_;
my $srchon = ' ';
my $srchoff = ' checked="checked" ';
my ($exacton,$containson,$beginson);
@@ -969,20 +1125,21 @@
my $numinrow = 4;
my $cansrchrow = 0;
my $datatable='<tr class="LC_odd_row">'.
- '<td colspan="2">'.&mt('Directory search available?').'</td>'.
+ '<td colspan="2"><span class ="LC_nobreak">'.&mt('Directory search available?').'</span></td>'.
'<td class="LC_right_item"><span class="LC_nobreak"><label>'.
'<input type="radio" name="dirsrch_available"'.
$srchon.' value="1" />'.&mt('Yes').'</label> '.
'<label><input type="radio" name="dirsrch_available"'.
$srchoff.' value="0" />'.&mt('No').'</label></span></td>'.
'</tr><tr>'.
- '<td colspan="2">'.&mt('Other domains can search?').'</td>'.
+ '<td colspan="2"><span class ="LC_nobreak">'.&mt('Other domains can search?').'</span></td>'.
'<td class="LC_right_item"><span class="LC_nobreak"><label>'.
'<input type="radio" name="dirsrch_localonly"'.
$localoff.' value="0" />'.&mt('Yes').'</label> '.
'<label><input type="radio" name="dirsrch_localonly"'.
$localon.' value="1" />'.&mt('No').'</label></span></td>'.
'</tr>';
+ $$rowtotal += 2;
if (ref($usertypes) eq 'HASH') {
if (keys(%{$usertypes}) > 0) {
$datatable .= &users_cansearch_row($settings,$types,$usertypes,$dom,
@@ -991,12 +1148,13 @@
}
}
if ($cansrchrow) {
+ $$rowtotal ++;
$datatable .= '<tr>';
} else {
$datatable .= '<tr class="LC_odd_row">';
}
- $datatable .= '<td>'.&mt('Supported search methods').
- '</td><td class="LC_left_item" colspan="2"><table><tr>';
+ $datatable .= '<td><span class ="LC_nobreak">'.&mt('Supported search methods').
+ '</span></td><td class="LC_left_item" colspan="2"><table><tr>';
foreach my $title (@{$titleorder}) {
if (defined($searchtitles->{$title})) {
my $check = ' ';
@@ -1013,12 +1171,13 @@
}
}
$datatable .= '</tr></table></td></tr>';
+ $$rowtotal ++;
if ($cansrchrow) {
$datatable .= '<tr class="LC_odd_row">';
} else {
$datatable .= '<tr>';
}
- $datatable .= '<td>'.&mt('Search latitude').'</td>'.
+ $datatable .= '<td><span class ="LC_nobreak">'.&mt('Search latitude').'</span></td>'.
'<td class="LC_left_item" colspan="2">'.
'<span class="LC_nobreak"><label>'.
'<input type="checkbox" name="searchtypes" '.
@@ -1030,11 +1189,12 @@
'<label><input type="checkbox" name="searchtypes" '.
$containson.' value="contains" />'.&mt('Contains').
'</label></span></td></tr>';
+ $$rowtotal ++;
return $datatable;
}
sub print_contacts {
- my ($dom,$settings) = @_;
+ my ($dom,$settings,$rowtotal) = @_;
my $datatable;
my @contacts = ('adminemail','supportemail');
my (%checked,%to,%otheremails);
@@ -1076,9 +1236,9 @@
} else {
$css_class = ' class="LC_odd_row" ';
}
- $datatable .= '<tr'.$css_class.' ">'.
- '<td>'.$titles->{$item}.'</td>'.
- '<td class="LC_right_item">'.
+ $datatable .= '<tr'.$css_class.'>'.
+ '<td><span class="LC_nobreak">'.$titles->{$item}.
+ '</span></td><td class="LC_right_item">'.
'<input type="text" name="'.$item.'" value="'.
$to{$item}.'" /></td></tr>';
$rownum ++;
@@ -1090,7 +1250,8 @@
$css_class = ' class="LC_odd_row" ';
}
$datatable .= '<tr'.$css_class.'>'.
- '<td>'.$titles->{$type}.': </td>'.
+ '<td><span class="LC_nobreak">'.
+ $titles->{$type}.': </span></td>'.
'<td class="LC_left_item">'.
'<span class="LC_nobreak">';
foreach my $item (@contacts) {
@@ -1106,6 +1267,7 @@
'</td></tr>'."\n";
$rownum ++;
}
+ $$rowtotal += $rownum;
return $datatable;
}
@@ -1125,9 +1287,8 @@
}
sub print_usercreation {
- my ($position,$dom,$settings) = @_;
+ my ($position,$dom,$settings,$rowtotal) = @_;
my $numinrow = 4;
- my $rowcount = 0;
my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom);
my $datatable;
my %lt = &Apache::lonlocal::texthash (
@@ -1145,8 +1306,8 @@
}
}
$datatable = '<tr class="LC_odd_row">'.
- '<td>'.$lt{'nondc'}.'</td>'.
- '<td class="LC_left_item"><table>';
+ '<td><span class="LC_nobreak">'.$lt{'nondc'}.
+ '</span></td><td class="LC_left_item"><table>';
foreach my $item ('author','course') {
$datatable .= '<tr><td><span class="LC_nobreak"><label>'.
'<input type="checkbox" name="can_createuser" '.
@@ -1154,12 +1315,12 @@
$lt{$item}.'</label><span></td></tr>';
}
$datatable .= '</table></td></tr>';
- $rowcount ++;
+ $$rowtotal ++;
if (ref($rules) eq 'HASH') {
if (keys(%{$rules}) > 0) {
$datatable .= &username_formats_row($settings,$rules,
$ruleorder,$numinrow);
- $rowcount ++;
+ $$rowtotal ++;
}
}
} else {
@@ -1190,7 +1351,7 @@
} else {
$css_class = ' class="LC_odd_row" ';
}
- $datatable .= '<tr'.$css_class.'">'.
+ $datatable .= '<tr'.$css_class.'>'.
'<td>'.$title{$item}.
'</td><td class="LC_left_item">'.
'<span class="LC_nobreak">';
@@ -1203,6 +1364,7 @@
$datatable .= '</span></td></tr>';
$rownum ++;
}
+ $$rowtotal += $rownum;
}
return $datatable;
}
@@ -1210,8 +1372,10 @@
sub username_formats_row {
my ($settings,$rules,$ruleorder,$numinrow) = @_;
my $output = '<tr>'.
- '<td>'.&mt('Format rules to check for new usernames: ').
- '</td><td class="LC_left_item" colspan="2"><table>';
+ '<td><span class="LC_nobreak">'.
+ &mt('Format rules to check for new usernames: ').
+ '</span></td>'.
+ '<td class="LC_left_item" colspan="2"><table>';
my $rem;
if (ref($ruleorder) eq 'ARRAY') {
for (my $i=0; $i<@{$ruleorder}; $i++) {
@@ -2009,6 +2173,18 @@
return $switchserver;
}
+sub javascript_set_colnums {
+ return <<END;
+function setDisplayColumns() {
+ if (document.pickactions.width.value > 1100) {
+ document.pickactions.numcols[1].checked = true;
+ } else {
+ document.pickactions.numcols[0].checked = true;
+ }
+}
+END
+}
+
sub modify_quotas {
my ($dom,%domconfig) = @_;
my ($resulttext,%changes);
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.162 loncom/interface/lonhtmlcommon.pm:1.163
--- loncom/interface/lonhtmlcommon.pm:1.162 Fri Sep 14 19:24:18 2007
+++ loncom/interface/lonhtmlcommon.pm Wed Sep 26 08:42:32 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.162 2007/09/14 23:24:18 banghart Exp $
+# $Id: lonhtmlcommon.pm,v 1.163 2007/09/26 12:42:32 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1879,6 +1879,52 @@
return $scripttag;
}
+##############################################
+##############################################
+
+# javascript_window_dims
+#
+# Generates javascript to get the dimensions of the user's browser window.
+
+sub javascript_window_dims {
+ my $scripttag .= <<'END';
+function getDimensions(width,height) {
+ width.value = getWindowWidth();
+ height.value = getWindowHeight();
+ return;
+}
+
+function getWindowWidth() {
+ var width = 0;
+ if( document.documentElement && document.documentElement.clientWidth ) {
+ width = document.documentElement.clientWidth;
+ }
+ else if( document.body && document.body.clientWidth ) {
+ width = document.body.clientWidth;
+ }
+ else if( window.innerWidth ) {
+ width = window.innerWidth - 18;
+ }
+ return width;
+}
+
+function getWindowHeight() {
+ var height = 0;
+ if( document.documentElement && document.documentElement.clientHeight ) {
+ height = document.documentElement.clientHeight;
+ }
+ else if( document.body && document.body.clientHeight ) {
+ height = document.body.clientHeight;
+ }
+ else if( window.innerHeight ) {
+ height = window.innerHeight - 18;
+ }
+ return height;
+}
+
+END
+ return $scripttag;
+}
1;
__END__
--raeburn1190810552--