[Koha-patches] [PATCH] Steamlining javascript for cloning additem block and tweaking style.
Owen Leonard
oleonard at myacpl.org
Thu Oct 16 17:45:29 CEST 2008
---
koha-tmpl/intranet-tmpl/prog/en/js/additem.js | 53 ++++++--------------
.../prog/en/modules/acqui/orderreceive.tmpl | 22 +++++---
2 files changed, 30 insertions(+), 45 deletions(-)
diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/additem.js b/koha-tmpl/intranet-tmpl/prog/en/js/additem.js
index 43822a1..a1e3092 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/js/additem.js
+++ b/koha-tmpl/intranet-tmpl/prog/en/js/additem.js
@@ -1,40 +1,3 @@
-function countItemBlocks() {
- var outeritemblock = document.getElementById('outeritemblock');
- var quantityrec = document.getElementById('quantityrec');
- var origquantityrec = document.getElementById('origquantityrec');
- var itemblockcount = outeritemblock.getElementsByTagName('div');
- var num = parseFloat(origquantityrec.value) + itemblockcount.length;
- quantityrec.setAttribute('value',num);
-}
-function deleteItemBlock(index) {
- var aDiv = document.getElementById(index);
- aDiv.parentNode.removeChild(aDiv);
- countItemBlocks();
-}
-function cloneItemBlock(index) {
- var original = document.getElementById(index); //original <div>
- var clone = original.cloneNode(true);
- // set the attribute for the new 'div' subfields
- clone.setAttribute('id',index + index);//set another id.
- var NumTabIndex;
- NumTabIndex = parseInt(original.getAttribute('tabindex'));
- if(isNaN(NumTabIndex)) NumTabIndex = 0;
- clone.setAttribute('tabindex',NumTabIndex+1);
- var CloneButtonPlus;
- var CloneButtonMinus;
- // try{
- CloneButtonPlus = clone.getElementsByTagName('a')[0];
- CloneButtonPlus.setAttribute('onclick',"cloneItemBlock('" + index + index + "')");
- CloneButtonMinus = clone.getElementsByTagName('a')[1];
- CloneButtonMinus.setAttribute('onclick',"deleteItemBlock('" + index + index + "')");
- CloneButtonMinus.setAttribute('style',"display:inline");
- // }
- //catch(e){ // do nothig if ButtonPlus & CloneButtonPlus don't exist.
- //}
- // insert this line on the page
- original.parentNode.insertBefore(clone,original.nextSibling);
- countItemBlocks();
-}
function check_additem() {
var barcodes = document.getElementsByName('barcode');
var success = true;
@@ -51,3 +14,19 @@ function check_additem() {
// duplicates within the form.
return success;
}
+$(document).ready(function(){
+ $(".cloneItemBlock").click(function(){
+ $(this).parent().parent().clone(true).insertAfter($(this).parent().parent()).find("a.deleteItemBlock").show();
+ var quantityrec = parseFloat($("#quantityrec").attr("value"));
+ quantityrec++;
+ $("#quantityrec").attr("value",quantityrec);
+ return false;
+ });
+ $(".deleteItemBlock").click(function(){
+ $(this).parent().parent().remove();
+ var quantityrec = parseFloat($("#quantityrec").attr("value"));
+ quantityrec--;
+ $("#quantityrec").attr("value",quantityrec);
+ return false;
+ });
+});
\ No newline at end of file
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tmpl
index 66f4979..021b2d3 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tmpl
@@ -1,7 +1,13 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha › Acquisitions › Receipt summary for : <!-- TMPL_VAR NAME="name" --> <!-- TMPL_IF NAME="invoice" -->invoice, <!-- TMPL_VAR NAME="invoice" --><!-- /TMPL_IF --></title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
-<script type="text/javascript" src="<!-- TMPL_VAR NAME='themelang' -->/js/additem.js"></script>
+<script type="text/javascript" src="<!-- TMPL_VAR NAME='themelang' -->/js/additem.js">
+</script>
+<style type="text/css">
+a.cloneItemBlock { cursor: pointer; color: grey; font-size: 180%; padding:.5em;text-decoration:none;}
+a.deleteItemBlock { display:none; cursor: pointer; color: grey; font-size: 180%;padding:.5em;text-decoration:none; }
+fieldset.rows .itemblock fieldset.action { padding:.5em; }
+</style>
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
@@ -24,7 +30,7 @@
<fieldset class="rows">
<legend>Catalog Details</legend>
- <ul><li><span class="label">Title: </span><span class="title"><!-- TMPL_VAR NAME="title" escape="html" --></span></li>
+ <ol><li><span class="label">Title: </span><span class="title"><!-- TMPL_VAR NAME="title" escape="html" --></span></li>
<li> <span class="label">Author: </span>
<!-- TMPL_VAR NAME="author" --></li>
<li><span class="label">Copyright: </span>
@@ -33,12 +39,12 @@
<!-- TMPL_VAR NAME="isbn" --></li>
<li> <span class="label">Series: </span>
<!-- TMPL_VAR NAME="seriestitle" --></li>
- </ul>
+ </ol>
</fieldset>
<fieldset class="rows">
- <legend>Item details (n): (add to catalog)</legend>
+ <legend>Item details: (add to catalog)</legend>
<div id="outeritemblock">
- <div id="itemblock">
+ <div class="itemblock">
<ol>
<li> <label for="volinf">Volume/Copy (for serials): </label>
<input type="text" size="20" name="volinf" id="volinf" /></li>
@@ -82,9 +88,9 @@
<!-- /TMPL_LOOP -->
</select></li>
<!-- /TMPL_IF -->
- </ol>
-<a style="cursor: pointer; color: grey; font-size: 180%;" onclick="cloneItemBlock('itemblock<!-- TMPL_VAR name="itemBlockIndex" -->')">+</a>
- <a style="display:none; cursor: pointer; color: grey; font-size: 180%;" onclick="deleteItemBlock('itemblock<!-- TMPL_VAR name="itemBlockIndex" -->')">-</a>
+ </ol><!-- TMPL_VAR name="itemBlockIndex" -->
+<fieldset class="action"><a href="#" class="cloneItemBlock">[+]</a>
+ <a href="#" class="deleteItemBlock">[-]</a></fieldset>
</div>
</div>
<input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
--
1.5.5.GIT
More information about the Koha-patches
mailing list