--- loncom/interface/loncommon.pm 2012/04/25 21:22:01 1.1073 +++ loncom/interface/loncommon.pm 2012/05/06 22:09:14 1.1074 @@ -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 @@ sub select_form { # 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 @@ sub modal_link { 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 {