From 726a00fd7ea5378a478ca87b990da04b038c006d Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 5 Apr 2011 10:22:22 +0200 Subject: [PATCH] Bug 5546 Javascript driven ability to hide MARC documentation links Signed-off-by: fdurand Signed-off-by: Chris Cormack --- cataloguing/addbiblio.pl | 3 + .../en/modules/cataloguing/addbiblio.tmpl | 59 +++++++++++++++++-- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index d2a38414ef..7e146c0c8b 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -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; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl index ba59280e51..b39212c621 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl @@ -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_") == 'false'){ + hideMARCdocLinks(); + $("#marcDocsSelect").attr('checked',false); + } else { + /* reset cookie expire date */ + $.cookie("marcdocs_",'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_",'false', { path: "/", expires: 365 }); +} + +function showMARCdocLinks() { + unloadCSS("marcDocsCSS"); + $.cookie("marcdocs_",'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 ?

Editing (Record Number )

Add MARC Record +
Show MARC tag documentation links
@@ -788,7 +839,7 @@ function unHideSubfield(index,labelindex) { // FIXME :: is it used ? - Click to Expand this Tag" onclick="ExpandField('tag__'); return false;"> - ">">', ); return false;"> ? -- 2.39.5