Bug 24084: PlainMARC view broken on OPAC if other $.ajax calls produce errors
This patch removes the use of jQuery's ajaxSetup() and load() to get the "plain" MARC view and replaces it with $.get(). This allows for error-handling on this specific AJAX request rather than all on the page. To test, apply the patch and view a bibliographic record in the OPAC. - Click the "MARC view" tab. - Click the "view plain" link. - The plain-text MARC view should load. - Clicking "view labeled" should return you to the original view. To test error handling, edit opac-MARCdetail.tt line 185 and add a typo to the URL, e.g. "opac-showmark.pl." Repeat the above steps. Clicking the "view plain" link should trigger an error message: "Sorry, plain view is temporarily unavailable." Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
1ca7b6c40c
commit
770f24d4f7
1 changed files with 29 additions and 33 deletions
|
@ -172,42 +172,38 @@
|
|||
[% BLOCK jsinclude %]
|
||||
<script>
|
||||
[% IF ( OPACXSLTDetailsDisplay ) %]
|
||||
$(document).ready(function(){
|
||||
$.ajaxSetup({
|
||||
error:function(x,e){
|
||||
switch (x.status) {
|
||||
case 200: break;
|
||||
default:
|
||||
$('#switchview').parent().html("<div class=\"dialog alert\">"+_("Sorry, plain view is temporarily unavailable")+".</div>");
|
||||
$("#plainmarc").hide();
|
||||
$("#labeledmarc").show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var loaded = 0;
|
||||
var toggle = 0;
|
||||
$("#switchview").on("click",function(e){
|
||||
e.preventDefault();
|
||||
if( toggle == 0){
|
||||
$(this).text(_("view labeled"));
|
||||
$("#labeledmarc").hide();
|
||||
if(!loaded){
|
||||
$("#plainmarc").show().html("<div style=\"margin:1em;padding:1em;border:1px solid #EEE;font-size:150%;\"><img src=\"[% interface | html %]/[% theme | html %]/images/loading.gif\" /> "+_("Loading")+"...</div>").load("/cgi-bin/koha/opac-showmarc.pl","id=[% biblio.biblionumber | html %]&viewas=html");
|
||||
loaded = 1;
|
||||
$(document).ready(function(){
|
||||
var loaded = 0;
|
||||
var toggle = 0;
|
||||
$("#switchview").on("click",function(e){
|
||||
e.preventDefault();
|
||||
if( toggle == 0){
|
||||
$(this).text(_("view labeled"));
|
||||
$("#labeledmarc").hide();
|
||||
if(!loaded){
|
||||
$("#plainmarc").show().html("<div style=\"margin:1em;padding:1em;border:1px solid #EEE;font-size:150%;\"><img src=\"[% interface | html %]/[% theme | html %]/images/loading.gif\" /> "+_("Loading")+"...</div>");
|
||||
var plain_marc = $.get( "/cgi-bin/koha/opac-showmarc.pl", { id: "[% biblio.biblionumber | html %]", viewas: "html" })
|
||||
.done(function( data ) {
|
||||
$("#plainmarc").html( data );
|
||||
loaded = 1;
|
||||
})
|
||||
.fail(function() {
|
||||
$('#switchview').parent().html("<div class=\"dialog alert\">"+_("Sorry, plain view is temporarily unavailable")+".</div>");
|
||||
$("#plainmarc").hide();
|
||||
$("#labeledmarc").show();
|
||||
});
|
||||
} else {
|
||||
$("#plainmarc").show();
|
||||
}
|
||||
toggle = 1;
|
||||
} else {
|
||||
$("#plainmarc").show();
|
||||
$(this).text(_("view plain"));
|
||||
$("#labeledmarc").show();
|
||||
$("#plainmarc").hide();
|
||||
toggle = 0;
|
||||
}
|
||||
toggle = 1;
|
||||
} else {
|
||||
$(this).text(_("view plain"));
|
||||
$("#labeledmarc").show();
|
||||
$("#plainmarc").hide();
|
||||
toggle = 0;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
[% END %]
|
||||
</script>
|
||||
[% END %]
|
||||
|
|
Loading…
Reference in a new issue