[LON-CAPA-cvs] cvs: loncom /interface coursecatalog.pm loncommon.pm

raeburn raeburn@source.lon-capa.org
Sat, 07 Feb 2009 20:45:27 -0000


raeburn		Sat Feb  7 20:45:27 2009 EDT

  Modified files:              
    /loncom/interface	coursecatalog.pm loncommon.pm 
  Log:
  loncommon.pm:
  &select_dom_form() takes a fifth argument - $autosubmit.  If this is true, the domain selector includes an onchange action which will submit the form containing it.
  
  coursecatalog.pm:
  Fifth argument (set to 1) passed to &Apache::loncommon::select_dom_form() unless 
   textual interface mode ("Change" button displayed in this case).
  
  
Index: loncom/interface/coursecatalog.pm
diff -u loncom/interface/coursecatalog.pm:1.46 loncom/interface/coursecatalog.pm:1.47
--- loncom/interface/coursecatalog.pm:1.46	Sat Feb  7 18:15:44 2009
+++ loncom/interface/coursecatalog.pm	Sat Feb  7 20:45:27 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler for displaying the course catalog interface
 #
-# $Id: coursecatalog.pm,v 1.46 2009/02/07 18:15:44 raeburn Exp $
+# $Id: coursecatalog.pm,v 1.47 2009/02/07 20:45:27 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -398,10 +398,17 @@
           text=>"Select courses"});
         $r->print(&Apache::lonhtmlcommon::breadcrumbs('Select courses'));
     }
+    my $onchange;
+    unless (($env{'browser.interface'} eq 'textual') || ($env{'form.interface'} eq 'textual')) {
+        $onchange = 1;
+    }
     $r->print('<form name="coursecatdom" method="post" action="/adm/coursecatalog">'.
               '<table border="0"><tr><td><b>'.&mt('Domain:').'</b></td><td>'.
-              &Apache::loncommon::select_dom_form($codedom,'showdom','',1).
-	      '&nbsp;<input type="submit" name="godom" value="'.&mt('Change').'" /></td></tr></table></form>'.
+              &Apache::loncommon::select_dom_form($codedom,'showdom','',1,$onchange));
+    if (!$onchange) {
+	   $r->print('&nbsp;<input type="submit" name="godom" value="'.&mt('Change').'" />');
+    }
+    $r->print('</td></tr></table></form>'.
 	      '<form name="coursecats" method="post" action="/adm/coursecatalog"'.
               ' onsubmit="check_selected()">'.
               '<table border="0"><tr>'.$catlinks.'</tr></table></form>');
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.742 loncom/interface/loncommon.pm:1.743
--- loncom/interface/loncommon.pm:1.742	Thu Feb  5 00:45:29 2009
+++ loncom/interface/loncommon.pm	Sat Feb  7 20:45:27 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.742 2009/02/05 00:45:29 raeburn Exp $
+# $Id: loncommon.pm,v 1.743 2009/02/07 20:45:27 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1746,7 +1746,7 @@
 
 =pod
 
-=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc)
+=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$autosubmit)
 
 Returns a string containing a <select name='$name' size='1'> form to 
 allow a user to select the domain to preform an operation in.  
@@ -1755,16 +1755,22 @@
 If the $includeempty flag is set, it also includes an empty choice ("no domain
 selected");
 
-If the $showdomdesc flag is set, the domain name is followed by the domain description. 
+If the $showdomdesc flag is set, the domain name is followed by the domain description.
+
+If the $autosubmit flag is set, the form containing the domain selector will be auto-submitted by an onchange action.  
 
 =cut
 
 #-------------------------------------------
 sub select_dom_form {
-    my ($defdom,$name,$includeempty,$showdomdesc) = @_;
+    my ($defdom,$name,$includeempty,$showdomdesc,$autosubmit) = @_;
+    my $onchange;
+    if ($autosubmit) {
+        $onchange = ' onchange="this.form.submit()"';
+    }
     my @domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains());
     if ($includeempty) { @domains=('',@domains); }
-    my $selectdomain = "<select name=\"$name\" size=\"1\">\n";
+    my $selectdomain = "<select name=\"$name\" size=\"1\"$onchange>\n";
     foreach my $dom (@domains) {
         $selectdomain.="<option value=\"$dom\" ".
             ($dom eq $defdom ? 'selected="selected" ' : '').'>'.$dom;