--- loncom/interface/loncommon.pm 2025/03/07 02:13:40 1.1469 +++ loncom/interface/loncommon.pm 2025/03/20 15:46:05 1.1473 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1469 2025/03/07 02:13:40 raeburn Exp $ +# $Id: loncommon.pm,v 1.1473 2025/03/20 15:46:05 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2800,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}; @@ -2821,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); } } @@ -2836,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 @@ -2848,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)) { @@ -2862,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}; @@ -2886,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: @@ -2894,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. @@ -2902,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.'"'; @@ -2911,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'}}; @@ -2962,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]', @@ -3064,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" ' : ''). @@ -4861,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 @@ -7349,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; } @@ -7361,6 +7383,10 @@ form, .inline { text-align:right; } +.LC_left { + text-align:left; +} + .LC_center { text-align:center; } @@ -8147,6 +8173,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; } @@ -8694,6 +8727,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; } @@ -15652,12 +15699,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; } @@ -15741,9 +15788,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] }))) { @@ -15788,8 +15835,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.'"'.