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

raeburn raeburn at source.lon-capa.org
Sun May 6 18:09:14 EDT 2012


raeburn		Sun May  6 22:09:14 2012 EDT

  Modified files:              
    /loncom/interface	loncommon.pm londocs.pm lonparmset.pm 
  Log:
  - Usability improvements for display filter interface.
  (Used to Show Log for Content Editor and Parameter Settings).
    - textbox for phrase to use as filter only shown where filter option
      selected is "Containing phrase". 
      (same for "Include parameter types" checkbox in parmeterchangelog
  - loncommon::modal_link() only includes target attribute, if one is defined.
    - target attribute not included in xhtml strict for <a> tag. 
  
  
-------------- next part --------------
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1073 loncom/interface/loncommon.pm:1.1074
--- loncom/interface/loncommon.pm:1.1073	Wed Apr 25 21:22:01 2012
+++ loncom/interface/loncommon.pm	Sun May  6 22:09:14 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1073 2012/04/25 21:22:01 raeburn Exp $
+# $Id: loncommon.pm,v 1.1074 2012/05/06 22:09:14 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1981,19 +1981,112 @@
 # For display filters
 
 sub display_filter {
+    my ($context) = @_;
     if (!$env{'form.show'}) { $env{'form.show'}=10; }
     if (!$env{'form.displayfilter'}) { $env{'form.displayfilter'}='currentfolder'; }
-    return '<span class="LC_nobreak"><label>'.&mt('Records [_1]',
+    my $phraseinput = 'hidden';
+    my $includeinput = 'hidden';
+    my ($checked,$includetypestext);
+    if ($env{'form.displayfilter'} eq 'containing') {
+        $phraseinput = 'text'; 
+        if ($context eq 'parmslog') {
+            $includeinput = 'checkbox';
+            if ($env{'form.includetypes'}) {
+                $checked = ' checked="checked"';
+            }
+            $includetypestext = &mt('Include parameter types');
+        }
+    } else {
+        $includetypestext = ' ';
+    }
+    my ($additional,$secondid,$thirdid);
+    if ($context eq 'parmslog') {
+        $additional = 
+            '<label><input type="'.$includeinput.'" name="includetypes"'. 
+            $checked.' name="includetypes" value="1" id="includetypes" />'.
+            ' <span id="includetypestext">'.$includetypestext.'</span>'.
+            '</label>';
+        $secondid = 'includetypes';
+        $thirdid = 'includetypestext';
+    }
+    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,
 							   (&mt('all'),10,20,50,100,1000,10000))).
 	   '</label></span> <span class="LC_nobreak">'.
-           &mt('Filter [_1]',
+           &mt('Filter: [_1]',
 	   &select_form($env{'form.displayfilter'},
 			'displayfilter',
 			{'currentfolder' => 'Current folder/page',
 			 'containing' => 'Containing phrase',
-			 'none' => 'None'})).
-			 '<input type="text" name="containingphrase" size="30" value="'.&HTML::Entities::encode($env{'form.containingphrase'}).'" /></span>';
+			 'none' => 'None'},$onchange)).' '.
+			 '<input type="'.$phraseinput.'" name="containingphrase" id="containingphrase" size="30" value="'.
+                         &HTML::Entities::encode($env{'form.containingphrase'}).
+                         '" />'.$additional;
+}
+
+sub display_filter_js {
+    my $includetext = &mt('Include parameter types');
+    return <<"ENDJS";
+  
+function toggleHistoryOptions(setter,firstid,context,secondid,thirdid) {
+    var firstType = 'hidden';
+    if (setter.options[setter.selectedIndex].value == 'containing') {
+        firstType = 'text';
+    }
+    firstObject = document.getElementById(firstid);
+    if (typeof(firstObject) == 'object') {
+        if (firstObject.type != firstType) {
+            changeInputType(firstObject,firstType);
+        }
+    }
+    if (context == 'parmslog') {
+        var secondType = 'hidden';
+        if (firstType == 'text') {
+            secondType = 'checkbox';
+        }
+        secondObject = document.getElementById(secondid);  
+        if (typeof(secondObject) == 'object') {
+            if (secondObject.type != secondType) {
+                changeInputType(secondObject,secondType);
+            }
+        }
+        var textItem = document.getElementById(thirdid);
+        var currtext = textItem.innerHTML;
+        var newtext;
+        if (firstType == 'text') {
+            newtext = '$includetext';
+        } else {
+            newtext = ' ';
+        }
+        if (currtext != newtext) {
+            textItem.innerHTML = newtext;
+        }
+    }
+    return;
+}
+
+function changeInputType(oldObject,newType) {
+    var newObject = document.createElement('input');
+    newObject.type = newType;
+    if (oldObject.size) {
+        newObject.size = oldObject.size;
+    }
+    if (oldObject.value) {
+        newObject.value = oldObject.value;
+    }
+    if (oldObject.name) {
+        newObject.name = oldObject.name;
+    }
+    if (oldObject.id) {
+        newObject.id = oldObject.id;
+    }
+    oldObject.parentNode.replaceChild(newObject,oldObject);
+    return;
+}
+
+ENDJS
 }
 
 sub gradeleveldescription {
@@ -7307,8 +7400,14 @@
     unless ($width) { $width=480; }
     unless ($height) { $height=400; }
     unless ($scrolling) { $scrolling='yes'; }
-    return '<a href="'.$link.'" target="'.$target.'" title="'.$title.'" onclick="openMyModal(\''.$link.'\','.$width.','.$height.',\''.$scrolling.'\'); return false;">'.
-           $linktext.'</a>';
+    my $target_attr;
+    if (defined($target)) {
+        $target_attr = 'target="'.$target.'"';
+    }
+    return <<"ENDLINK";
+<a href="$link" $target_attr title="$title" onclick="javascript:openMyModal('$link',$width,$height,'$scrolling'); return false;">
+           $linktext</a>
+ENDLINK
 }
 
 sub modal_adhoc_script {
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.482 loncom/interface/londocs.pm:1.483
--- loncom/interface/londocs.pm:1.482	Mon Apr 16 19:31:57 2012
+++ loncom/interface/londocs.pm	Sun May  6 22:09:14 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.482 2012/04/16 19:31:57 raeburn Exp $
+# $Id: londocs.pm,v 1.483 2012/05/06 22:09:14 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -437,7 +437,13 @@
 sub docs_change_log {
     my ($r)=@_;
     my $folder=$env{'form.folder'};
-    $r->print(&Apache::loncommon::start_page('Course Document Change Log'));
+    my $js = '<script type="text/javascript">'."\n".
+             '// <![CDATA['."\n".
+             &Apache::loncommon::display_filter_js('docslog')."\n".
+             &history_tab_js()."\n".
+             '// ]]>'."\n".
+             '</script>'."\n";
+    $r->print(&Apache::loncommon::start_page('Course Document Change Log',$js));
     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Document Change Log'));
     my %docslog=&Apache::lonnet::dump('nohist_docslog',
                                       $env{'course.'.$env{'request.course.id'}.'.domain'},
@@ -461,7 +467,7 @@
 	    'randomorder'    => 'Randomly ordered',
 	    'set'            => 'set to',
 	    'del'            => 'deleted');
-    $r->print(&Apache::loncommon::display_filter().
+    $r->print(&Apache::loncommon::display_filter('docslog').
               '<input type="hidden" name="folder" value="'.$folder.'" />'.
               '<input type="submit" value="'.&mt('Display').'" /></form>');
     $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
@@ -3582,6 +3588,17 @@
 ENDNEWSCRIPT
 }
 
+sub history_tab_js {
+    return <<"ENDHIST";
+function toggleHistoryDisp(choice) {
+    document.docslogform.docslog.value = choice;
+    document.docslogform.submit();
+    return;
+}
+
+ENDHIST
+}
+
 sub resize_contentdiv_js {
     my ($tabidstr) = @_;
     my $viewport_js = &Apache::loncommon::viewport_geometry_js();
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.521 loncom/interface/lonparmset.pm:1.522
--- loncom/interface/lonparmset.pm:1.521	Tue Mar 13 05:37:49 2012
+++ loncom/interface/lonparmset.pm	Sun May  6 22:09:14 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.521 2012/03/13 05:37:49 raeburn Exp $
+# $Id: lonparmset.pm,v 1.522 2012/05/06 22:09:14 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4338,7 +4338,12 @@
     my ($r)=@_;
     &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
     text=>"Parameter Change Log"});
-    $r->print(&Apache::loncommon::start_page('Parameter Change Log'));
+    my $js = '<script type="text/javascript">'."\n".
+             '// <![CDATA['."\n".
+             &Apache::loncommon::display_filter_js('parmslog')."\n".
+             '// ]]>'."\n".
+             '</script>'."\n";
+    $r->print(&Apache::loncommon::start_page('Parameter Change Log',$js));
     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log'));
     &startSettingsScreen($r,'parmset');
     my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',
@@ -4347,7 +4352,9 @@
 
     if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); }
 
-    $r->print('<form action="/adm/parmset?action=parameterchangelog"
+    $r->print('<div class="LC_left_float">'.
+              '<fieldset><legend>'.&mt('Display of Changes').'</legend>'.
+              '<form action="/adm/parmset?action=parameterchangelog"
                      method="post" name="parameterlog">');
 
     my %saveable_parameters = ('show' => 'scalar',);
@@ -4355,10 +4362,9 @@
                                               \%saveable_parameters);
     &Apache::loncommon::restore_course_settings('parameter_log',
                                                 \%saveable_parameters);
-    $r->print(&Apache::loncommon::display_filter().
-              '<label>'.&Apache::lonhtmlcommon::checkbox('includetypes',$env{'form.includetypes'},'1').
-          ' '.&mt('Include parameter types').'</label>'.
-          '<input type="submit" value="'.&mt('Display').'" /></form>');
+    $r->print(&Apache::loncommon::display_filter('parmslog').' '."\n".
+              '<input type="submit" value="'.&mt('Display').'" />'.
+              '</form></fieldset></div><br clear="all" />');
 
     my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'},
                              $env{'course.'.$env{'request.course.id'}.'.domain'});


More information about the LON-CAPA-cvs mailing list