--- loncom/interface/loncommon.pm 2025/02/25 16:33:39 1.1464 +++ loncom/interface/loncommon.pm 2025/03/22 21:18:30 1.1474 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1464 2025/02/25 16:33:39 raeburn Exp $ +# $Id: loncommon.pm,v 1.1474 2025/03/22 21:18:30 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -966,7 +966,9 @@ ENDSCRT sub select_timezone { my ($name,$selected,$onchange,$includeempty,$id,$disabled)=@_; - my $output='<select name="'.$name.'" '.$id.$onchange.$disabled.'>'."\n"; + my $labeltext = &HTML::Entities::encode(&mt('Select Time Zone')); + my $output='<select name="'.$name.'" '.$id.$onchange.$disabled. + ' aria-label="'.$labeltext.'">'."\n"; if ($includeempty) { $output .= '<option value=""'; if (($selected eq '') || ($selected eq 'local')) { @@ -1351,7 +1353,7 @@ sub help_open_topic { } $template.=' <a'.$target.' href="'.$link.'" title="'.$title.'">' .'<img src="'.$helpicon.'" border="0"' - .' alt="'.&mt('Help: [_1]',$topic).'"' + .' alt="'.&mt('Help icon').'"' .' title="'.$title.'" style="vertical-align:middle;"'.$imgid .' /></a>'; if ($text ne "") { @@ -2798,7 +2800,7 @@ sub create_text_file { # ------------------------------------------ sub domain_select { - my ($name,$value,$multiple,$incdoms,$excdoms)=@_; + my ($name,$value,$multiple,$incdoms,$excdoms,$id)=@_; my @possdoms; if (ref($incdoms) eq 'ARRAY') { @possdoms = @{$incdoms}; @@ -2819,10 +2821,10 @@ sub domain_select { if ($multiple) { $domains{''}=&mt('Any domain'); $domains{'select_form_order'} = [sort {lc($a) cmp lc($b) } (keys(%domains))]; - return &multiple_select_form($name,$value,4,\%domains); + return &multiple_select_form($name,$value,4,\%domains,undef,$id); } else { $domains{'select_form_order'} = [sort {lc($a) cmp lc($b) } (keys(%domains))]; - return &select_form($name,$value,\%domains); + return &select_form($name,$value,\%domains,'','',$id); } } @@ -2834,7 +2836,7 @@ sub domain_select { =over 4 -=item * &multiple_select_form($name,$value,$size,$hash,$order) +=item * &multiple_select_form($name,$value,$size,$hash,$order,$id) Returns a string containing a <select> element int multiple mode @@ -2846,12 +2848,13 @@ Args: $hash - the elements should be 'option' => 'shown text' (shown text should already have been &mt()) $order - (optional) array ref of the order to show the elements in + $id = (optional) id for <select> element =cut #------------------------------------------- sub multiple_select_form { - my ($name,$value,$size,$hash,$order)=@_; + my ($name,$value,$size,$hash,$order,$id)=@_; my %selected = map { $_ => 1 } ref($value)?@{$value}:($value); my $output=''; if (! defined($size)) { @@ -2860,7 +2863,10 @@ sub multiple_select_form { $size = scalar(keys(%$hash)); } } - $output.="\n".'<select name="'.$name.'" size="'.$size.'" multiple="multiple">'; + if ($id ne '') { + $id = ' id="'.$id.'"'; + } + $output.="\n".'<select name="'.$name.'" size="'.$size.'" multiple="multiple"'.$id.'>'; my @order; if (ref($order) eq 'ARRAY') { @order = @{$order}; @@ -2884,7 +2890,7 @@ sub multiple_select_form { =pod -=item * &select_form($defdom,$name,$hashref,$onchange,$readonly) +=item * &select_form($defdom,$name,$hashref,$onchange,$readonly,$id,$aria_labelledby) Returns a string containing a <select name='$name' size='1'> form to allow a user to select options from a ref to a hash containing: @@ -2892,7 +2898,10 @@ option_name => displayed text. An option a javascript onchange item, e.g., onchange="this.form.submit();". An optional arg -- $readonly -- if true will cause the select form to be disabled, e.g., for the case where an instructor has a section- -specific role, and is viewing/modifying parameters. +specific role, and is viewing/modifying parameters. An optional arg +-- $id -- will be used as the id attribute of the select element. An +optional arg -- $aria_labelledby -- will be included as the aria-labelledby +attribute of the select element. See lonrights.pm for an example invocation and use. @@ -2900,7 +2909,7 @@ See lonrights.pm for an example invocati #------------------------------------------- sub select_form { - my ($def,$name,$hashref,$onchange,$readonly) = @_; + my ($def,$name,$hashref,$onchange,$readonly,$id,$aria_labelledby) = @_; return unless (ref($hashref) eq 'HASH'); if ($onchange) { $onchange = ' onchange="'.$onchange.'"'; @@ -2909,7 +2918,13 @@ sub select_form { if ($readonly) { $disabled = ' disabled="disabled"'; } - my $selectform = "<select name=\"$name\" size=\"1\"$onchange$disabled>\n"; + if ($id ne '') { + $id = ' id="'.$id.'"'; + } + if ($aria_labelledby ne '') { + $aria_labelledby = ' aria-labelledby="'.$aria_labelledby.'"'; + } + my $selectform = "<select name=\"$name\" size=\"1\"$onchange$disabled$id$aria_labelledby>\n"; my @keys; if (exists($hashref->{'select_form_order'})) { @keys=@{$hashref->{'select_form_order'}}; @@ -2960,7 +2975,7 @@ sub display_filter { my $onchange = "javascript:toggleHistoryOptions(this,'containingphrase','$context', '$secondid','$thirdid')"; return '<span class="LC_nobreak"><label>'.&mt('Records: [_1]', - &Apache::lonmeta::selectbox('show',$env{'form.show'},'',undef, + &Apache::lonmeta::selectbox('show',$env{'form.show'},'','',undef, (&mt('all'),10,20,50,100,1000,10000))). '</label></span> <span class="LC_nobreak">'. &mt('Filter: [_1]', @@ -3062,9 +3077,12 @@ sub gradeleveldescription { } sub select_level_form { - my ($deflevel,$name)=@_; + my ($deflevel,$name,$id)=@_; + if ($id ne '') { + $id = ' id="'.$id.'"'; + } unless ($deflevel) { $deflevel=0; } - my $selectform = "<select name=\"$name\" size=\"1\">\n"; + my $selectform = "<select name=\"$name\" size=\"1\"$id>\n"; for (my $i=0; $i<=18; $i++) { $selectform.="<option value=\"$i\" ". ($i==$deflevel ? 'selected="selected" ' : ''). @@ -4859,9 +4877,10 @@ sub filemimetype { sub filecategoryselect { - my ($name,$value)=@_; + my ($name,$value,$id)=@_; return &select_form($value,$name, - {'' => &mt('Any category'), map { $_,$_ } sort(keys(%category_extensions))}); + {'' => &mt('Any category'), map { $_,$_ } sort(keys(%category_extensions))}, + '','',$id); } =pod @@ -7347,6 +7366,11 @@ form, .inline { font-size: 1.0em; } +h1.LC_search_results { + font-size: 1.0em; + font-weight: normal; +} + .LC_menus_content.shown{ display: block; } @@ -7359,6 +7383,10 @@ form, .inline { text-align:right; } +.LC_left { + text-align:left; +} + .LC_center { text-align:center; } @@ -7452,6 +7480,14 @@ div.LC_confirm_box .LC_success img { height: auto; } +div.LC_minheight { + min-height: 24px; + border: 0; + margin: 4px 0 0 0; + padding: 0; + vertical-align: middle; +} + .LC_textsize_mobile { \@media only screen and (max-device-width: 480px) { -webkit-text-size-adjust:100%; -moz-text-size-adjust:100%; -ms-text-size-adjust:100%; @@ -7506,9 +7542,10 @@ div.LC_confirm_box .LC_success img { padding: 4px; } -table.LC_pastsubmission { +.LC_pastsubmission { border: 1px solid black; margin: 2px; + padding: 2px; } table#LC_menubuttons { @@ -7743,11 +7780,13 @@ table.LC_data_table tr td.LC_leftcol_hea } table.LC_data_table tr.LC_empty_row td, -table.LC_nested tr.LC_empty_row td { +table.LC_nested tr.LC_empty_row td, +table.LC_nested tr.LC_empty_row th { font-weight: bold; font-style: italic; text-align: center; padding: 8px; + border: 0; } table.LC_data_table tr.LC_empty_row td, @@ -7755,15 +7794,19 @@ table.LC_data_table tr.LC_footer_row td background-color: $sidebg; } +table.LC_nested tr.LC_empty_row th, table.LC_nested tr.LC_empty_row td { + padding: 4ex; background-color: #FFFFFF; } table.LC_caption { } -table.LC_nested tr.LC_empty_row td { - padding: 4ex +caption.LC_caption_prefs { + font-weight: normal; + text-align: left; + padding-bottom: 0.8em; } table.LC_nested_outer tr th { @@ -7782,14 +7825,17 @@ table.LC_nested_outer tr td.LC_subheader text-align: right; } -table.LC_nested tr.LC_info_row td { +table.LC_nested tr.LC_info_row td, +table.LC_nested tr.LC_info_row th { background-color: #CCCCCC; font-weight: bold; font-size: small; text-align: center; + border: 0; } table.LC_nested tr.LC_info_row td.LC_left_item, +table.LC_nested tr.LC_info_row th.LC_left_item, table.LC_nested_outer tr th.LC_left_item { text-align: left; } @@ -7932,6 +7978,10 @@ table.LC_data_table tr > td.LC_roles_sel border-right: 8px solid #11CC55; } +table.LC_data_table tr.LC_prefs_row { + line-height: 250%; +} + span.LC_current_location { font-size:larger; background: $pgbg; @@ -8134,6 +8184,13 @@ table.LC_pick_box td.LC_oddrow_value { background-color: $data_table_light; } +td.LC_log_filter, +th.LC_log_filter { + vertical-align: top; + text-align: left; + padding: 0 4px; +} + span.LC_helpform_receipt_cat { font-weight: bold; } @@ -8296,12 +8353,27 @@ table.LC_prior_tries td { padding: 6px; } -.LC_prob_status { - margin-top: 5px; - padding-top: 0; - padding-left: 0; - padding-bottom: 0; - padding-right: 5px; +span.LC_prob_status { + margin: 5px 0 0 0; + padding: 0 5px 0 0; + vertical-align: middle; +} + +div.LC_prob_status_outer { + display: inline-block; + margin: -5px 0 0 0; + padding: 0; +} + +div.LC_prob_status_inner { + display: inline-block; + margin: 0 5px 0 0; + padding: 5px; +} + +caption.LC_filesub_status { + text-align: left; + font-weight: bold; } .LC_mail_actions { @@ -8666,6 +8738,20 @@ fieldset#LC_selectuser { border: 0; } +fieldset.LC_delete_slot { + display:inline; + margin: 0 4px 4px; + padding: 4px; +} + +fieldset.LC_delete_slot > legend { + font-weight: normal; +} + +p.LC_medium_line { + line-height: 0.85em; +} + article.geogebraweb div { margin: 0; } @@ -10889,6 +10975,11 @@ sub simple_error_page { return; } + sub set_data_table_count { + my ($count) = @_; + unshift(@row_count,$count); + } + sub start_data_table { my ($add_class,$id) = @_; my $css_class = (join(' ','LC_data_table',$add_class)); @@ -10936,7 +11027,11 @@ sub simple_error_page { } sub start_data_table_header_row { - return '<tr class="LC_header_row">'."\n";; + my ($add_class,$id) = @_; + my $css_class = 'LC_header_row'; + $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq ''); + $id = (' id="'.$id.'"') unless ($id eq ''); + return '<tr class="'.$css_class.'"'.$id.'>'."\n"; } sub end_data_table_header_row { @@ -10944,8 +11039,8 @@ sub simple_error_page { } sub data_table_caption { - my $caption = shift; - return "<caption class=\"LC_caption\">$caption</caption>"; + my ($caption,$css_class) = @_; + return "<caption class=\"LC_caption $css_class\">$caption</caption>"; } } @@ -15615,12 +15710,12 @@ sub upfile_select_html { tab => &mt('Tabulator separated'), # xml => &mt('HTML/XML'), ); - my $Str = '<input type="file" name="upfile" size="50" />'. - '<br />'.&mt('Type').': <select name="upfiletype">'; + my $Str = '<input type="file" name="upfile" id="upfile" size="50" />'. + '<br /><label>'.&mt('Type').': <select name="upfiletype">'; foreach my $type (sort(keys(%Types))) { $Str .= '<option value="'.$type.'" >'.$Types{$type}."</option>\n"; } - $Str .= "</select>\n"; + $Str .= "</select></label>\n"; return $Str; } @@ -15704,9 +15799,9 @@ sub csv_print_select_table { &end_data_table_header_row()."\n"); foreach my $array_ref (@$d) { my ($value,$display,$defaultcol)=@{ $array_ref }; - $r->print(&start_data_table_row().'<td>'.$display.'</td>'); + $r->print(&start_data_table_row().'<td><label for="f'.$i.'">'.$display.'</label></td>'); - $r->print('<td><select name="f'.$i.'"'. + $r->print('<td><select name="f'.$i.'" id="f'.$i.'"'. ' onchange="javascript:flip(this.form,'.$i.');">'); $r->print('<option value="none"></option>'); foreach my $sample (sort({$a <=> $b} keys(%{ $samples->[0] }))) { @@ -15751,8 +15846,10 @@ sub csv_samples_select_table { &end_data_table_header_row()); foreach my $key (sort(keys(%{ $samples->[0] }))) { + my $num = $i+1; + my $labeltext = &HTML::Entities::encode(&mt('Field for data in column [_1]',$num)); $r->print(&start_data_table_row().'<td><select name="f'.$i.'"'. - ' onchange="javascript:flip(this.form,'.$i.');">'); + ' onchange="javascript:flip(this.form,'.$i.');" aria-label="'.$labeltext.'">'); foreach my $option (@$d) { my ($value,$display,$defaultcol)=@{ $option }; $r->print('<option value="'.$value.'"'.