Bug 5546 Javascript driven ability to hide MARC documentation links

Signed-off-by: fdurand <frederic.durand@univ-lyon2.fr>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
Tomas Cohen Arazi 2011-04-05 10:22:22 +02:00 committed by Chris Cormack
parent 8902dadf06
commit 726a00fd7e
2 changed files with 58 additions and 4 deletions

View File

@ -1023,10 +1023,13 @@ $template->param( title => $record->title() ) if ( $record ne "-1" );
if (C4::Context->preference("marcflavour") eq "MARC21"){
$template->param(MARC21 => 1);
}
$template->param(
popup => $mode,
frameworkcode => $frameworkcode,
itemtype => $frameworkcode,
borrowernumber => $loggedinuser
);
output_html_with_http_headers $input, $cookie, $template->output;

View File

@ -26,9 +26,20 @@
fields_in_use[field_id] = 1;
}
});
});
$('#header_search > ul').tabs().bind('show.ui-tabs', function(e, ui) { $('#header_search > div:not(.ui-tabs-hide)').find('input').eq(0).focus(); });
/* check cookie to hide/show marcdocs*/
if($.cookie("marcdocs_<!-- TMPL_VAR NAME="borrowernumber" -->") == 'false'){
hideMARCdocLinks();
$("#marcDocsSelect").attr('checked',false);
} else {
/* reset cookie expire date */
$.cookie("marcdocs_<!-- TMPL_VAR NAME="borrowernumber" -->",'true',
{ path: "/", expires: 365 });
}
});
$('#header_search > ul').tabs().bind('show.ui-tabs', function(e, ui) { $('#header_search > div:not(.ui-tabs-hide)').find('input').eq(0).focus(); });
function confirmnotdup(redirect){
$("#confirm_not_duplicate").attr("value","1");
@ -101,6 +112,45 @@ function _UNIMARCFieldDoc(field, blocknumber) {
}
}
/*
* Functions to load/unload css from the head element
*/
function loadCSS(id,cssDef) {
var cssElem=document.createElement("style");
cssElem.setAttribute("type", "text/css");
cssElem.setAttribute("id", id);
cssElem.innerHTML = cssDef;
document.getElementsByTagName("head")[0].appendChild(cssElem);
}
function unloadCSS(id) {
var elem = document.getElementById(id);
elem.parentNode.removeChild(elem);
}
/*
* Functions to hide/show marc docs links
*/
function hideMARCdocLinks() {
loadCSS("marcDocsCSS",".marcdocs{display: none;}");
$.cookie("marcdocs_<!-- TMPL_VAR NAME="borrowernumber" -->",'false', { path: "/", expires: 365 });
}
function showMARCdocLinks() {
unloadCSS("marcDocsCSS");
$.cookie("marcdocs_<!-- TMPL_VAR NAME="borrowernumber" -->",'true', { path: "/", expires: 365 });
}
function toggleMARCDocs(checked) {
if (checked) {
showMARCdocLinks();
} else {
hideMARCdocLinks();
}
}
/**
* check if mandatory subfields are written
*/
@ -643,6 +693,7 @@ function unHideSubfield(index,labelindex) { // FIXME :: is it used ?
<h1><!-- TMPL_IF NAME="biblionumber" -->Editing <em><!-- TMPL_VAR NAME="title" escape="html" --></em> (Record Number <!-- TMPL_VAR name="biblionumber" -->)</h1><!-- TMPL_ELSE -->Add MARC Record</h1><!-- /TMPL_IF -->
<div><input type="checkbox" name="marcDocsSelect" id="marcDocsSelect" checked="true" onclick="toggleMARCDocs(this.checked)"/> Show MARC tag documentation links<br/></div>
<!-- TMPL_UNLESS name="number" -->
<!-- show duplicate warning on tab 0 only -->
@ -788,7 +839,7 @@ function unHideSubfield(index,labelindex) { // FIXME :: is it used ?
<!-- TMPL_IF NAME="advancedMARCEditor" -->
<a href="#" tabindex="1" class="tagnum" title="<!-- TMPL_VAR NAME="tag_lib"--> - Click to Expand this Tag" onclick="ExpandField('tag_<!-- TMPL_VAR NAME="tag"-->_<!-- TMPL_VAR NAME='index' --><!-- TMPL_VAR NAME="random" -->'); return false;"><!-- TMPL_VAR NAME="tag" --></a>
<!-- TMPL_ELSE -->
<span class="tagnum" title="<!-- TMPL_VAR NAME="tag_lib" -->"><!-- TMPL_VAR NAME="tag" --><a
<span class="tagnum" title="<!-- TMPL_VAR NAME="tag_lib" -->"><!-- TMPL_VAR NAME="tag" --><a class="marcdocs"
onclick="PopupMARCFieldDoc('<!-- TMPL_VAR NAME="tag" -->', <!-- TMPL_VAR NAME="number" -->); return false;">&nbsp;?</a></span>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="fixedfield" -->