--- loncom/interface/lonsearchcat.pm 2015/06/12 21:11:07 1.345 +++ loncom/interface/lonsearchcat.pm 2016/04/22 17:22:29 1.348 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.345 2015/06/12 21:11:07 damieng Exp $ +# $Id: lonsearchcat.pm,v 1.348 2016/04/22 17:22:29 musolffc Exp $ # # Copyright Michigan State University Board of Trustees # @@ -144,7 +144,7 @@ sub handler { ## this once, so the pause indicator is deleted ## if (exists($env{'form.pause'})) { - Time::HiRes::sleep(0.1); + sleep(0.1); delete($env{'form.pause'}); } ## @@ -1912,10 +1912,11 @@ sub copyright_check { my (undef,undef,$resdom,$resname) = split('/', $Metadata->{'url'}); # Check for priv - if (($Metadata->{'copyright'} eq 'priv') && - (($env{'user.name'} ne $resname) && - ($env{'user.domain'} ne $resdom))) { - return 0; + if ($Metadata->{'copyright'} eq 'priv') { + unless (($env{'user.name'} eq $resname) && + ($env{'user.domain'} eq $resdom)) { + return 0; + } } # Check for domain if (($Metadata->{'copyright'} eq 'domain') && @@ -2051,19 +2052,7 @@ sub print_sort_form { &Apache::lonnet::logthis(&Apache::lonmysql::get_error()); return; } - # update results - my $newloc = '/adm/searchcat?phase=results&persistent_db_id='. - $env{'form.persistent_db_id'}; - my $js =< - var frame = parent.resultsframe; - var frameDoc = frame.document; - if (frameDoc.readyState == 'complete') - frame.location = "$newloc"; - -END - - my $start_page = &Apache::loncommon::start_page('Results',$js); + my $start_page = &Apache::loncommon::start_page('Results',undef); my $breadcrumbs= &Apache::lonhtmlcommon::breadcrumbs('Searching','Searching', $env{'form.catalogmode'} ne 'import'); @@ -2233,10 +2222,7 @@ sub reload_result_frame { $env{'form.persistent_db_id'}; $r->print(< - var frame = parent.resultsframe; - var frameDoc = frame.document; - if (frameDoc.readyState == 'complete') - frame.location = "$newloc"; + parent.update_results("$newloc"); SCRIPT @@ -2472,7 +2458,7 @@ END &update_status($r, &mt('waiting on [_1]',join(' ',keys(%Server_status)))); } - Time::HiRes::sleep(0.1); + sleep(0.1); } # # Loop through the servers we have contacted but do not @@ -3176,6 +3162,14 @@ SCRIPT SCRIPT + $js.=< + \$(document).ready(function() { + parent.done_loading_results(); + }); + +SCRIPT + my $start_page = &Apache::loncommon::start_page(undef,$js, {'only_body' =>1, 'add_wishlist' =>1, @@ -3206,10 +3200,28 @@ sub print_frames_interface { my $results_link = &results_link(); my $js = < -// + +var loading_results = true; +var need_reloading = false; +var new_location; +function update_results(newloc) { + if (loading_results) { + need_reloading = true; + new_location = newloc; + } else { + loading_results = true; + resultsframe.location = newloc; + } +} +function done_loading_results() { + loading_results = false; + if (need_reloading) { + need_reloading = false; + update_results(new_location); + } +} JS @@ -3321,7 +3333,7 @@ sub detailed_citation_view { ''.$prefix. ''.' '. ''.$values{'title'}."\n". + 'target="preview" onclick="openMyModal(this.href, 500, 500, \'yes\');return false;">'.$values{'title'}."\n". &display_tools($values{'title'}, $jumpurl). "

\n". ''.$values{'author'}.','. @@ -3454,7 +3466,7 @@ sub summary_view { my $link = '
'.&display_url($jumpurl,1).'
'; $result .= ''.$values{'title'}.''. + ' target="preview" onclick="openMyModal(this.href, 500, 500, \'yes\');return false;">'.$values{'title'}.''. &display_tools($values{'title'}, $jumpurl).< $link
@@ -3500,7 +3512,7 @@ sub compact_view { } $jumpurl = &HTML::Entities::encode($jumpurl,'<>&"'); $result.=' '. - ''. + ''. &HTML::Entities::encode($values{'title'},'<>&"').' '. &display_tools($values{'title'}, $jumpurl). $link.' '.$values{'author'}.' ('.$values{'domain'}.')'; @@ -3520,8 +3532,13 @@ sub display_url { $url, 'preview', '', - (($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''), + '', $skiplast).' '; + # replace the links to open in a new window + # (because the search opens in a new window, it gets + # confusing when the links open a tab in the + # parent window; ideally we should not force windows) + $link =~ s/(href="[^"]*")/\1 onclick="window.open(this.href, '_blank', 'toolbar=1,location=1,menubar=0');return false;"/g; } return $link; }