From b8f1b43966d178174583c7a3e0c36e58f988b161 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 3 Jul 2013 10:52:21 +0200 Subject: [PATCH] Bug 10533: move JavaScript functions for basket groups to a separate file This patch moves JavaScript functions used for managing basket groups to a file. This has the effect of putting the last (active) use of the YUI JavaScript library by the staff interface in one file: koha-tmpl/intranet-tmpl/prog/en/js/basketgroup.js Test plan: - Try all actions for basketgroup ( drag/drop, add, delete, close, print, reopen, edit, export as csv). - Check that there is no regression on others acquisition pages: * acqui/neworderempty.tt * acqui/uncertainprice.tt * acqui/addorderiso2709.tt * acqui/basketheader.tt * admin/aqbudgets.tt * admin/aqcontract.tt * admin/aqbudgetperiods.tt * admin/aqplan.tt * suggestion/suggestion.tt Signed-off-by: Galen Charlton Signed-off-by: Katrin Fischer Works as described, passes all tests and QA script. Signed-off-by: Galen Charlton --- koha-tmpl/intranet-tmpl/prog/en/js/acq.js | 458 ------------------ .../intranet-tmpl/prog/en/js/basketgroup.js | 327 +++++++++++++ .../prog/en/modules/acqui/basketgroup.tt | 2 +- 3 files changed, 328 insertions(+), 459 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/js/basketgroup.js diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js b/koha-tmpl/intranet-tmpl/prog/en/js/acq.js index 3fde6f1577..387e9a2abf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/acq.js @@ -49,465 +49,7 @@ function isNum(v,maybenull) { return true; } -//======================================================================= - -//======================================================================= -// Functions for drag-and-drop functionality - -if( typeof(YAHOO) === "object"){ - (function() { - - var Dom = YAHOO.util.Dom; - var Event = YAHOO.util.Event; - var DDM = YAHOO.util.DragDropMgr; - - DDApp = { - init: function() { - var uls = document.getElementsByTagName('ul'); - var i,j; - var ddtarget; - for (i=0; i this.lastY) { - this.goingUp = false; - } - this.lastY = y; - }, - - onDragOver: function(e, id) { - - var srcEl = this.getEl(); - var destEl = Dom.get(id); - - // We are only concerned with list items, we ignore the dragover - // notifications for the list. - if (destEl.nodeName.toLowerCase() == "li") { - var orig_p = srcEl.parentNode; - var p = destEl.parentNode; - - if (this.goingUp) { - p.insertBefore(srcEl, destEl); // insert above - } else { - p.insertBefore(srcEl, destEl.nextSibling); // insert below - } - - DDM.refreshCache(); - } - } - }); - })(); -} - - - -//creates new group, parameter is the group's name -function newGroup(event, name) { - if (name == ''){ - return 0; - } - if (!enterpressed(event) && event != "button"){ - return false; - } - var pardiv = document.getElementById('groups'); - var newdiv = document.createElement('div'); - var newh3 = document.createElement('h3'); - var newul = document.createElement('ul'); - var newclose = document.createElement('a'); - var newrename = document.createElement('a'); - var newbasketgroupname = document.createElement('input'); - var nbgclosed = document.createElement('input'); - var newp = document.createElement('p'); - var reg=new RegExp("[-]+", "g"); - var i = 0; - var maxid = 0; - while( i < pardiv.getElementsByTagName('input').length ){ - if (! isNaN(parseInt(pardiv.getElementsByTagName('input')[i].name.split(reg)[1])) && parseInt(pardiv.getElementsByTagName('input')[i].name.split(reg)[1]) > maxid){ - maxid = parseInt(pardiv.getElementsByTagName('input')[i].name.split(reg)[1]); - } - ++i; - } -// var bgid = parseInt(pardiv.getElementsByTagName('input')[pardiv.getElementsByTagName('input').length-2].name.split(reg)[1]) + 1; - var bgid = maxid + 1; - var newchanged = document.createElement('input'); - - newul.id="bg-"+bgid; - newul.className='draglist'; - - newh3.innerHTML=name; -// newh3.style.display="inline"; - - newclose.innerHTML="close"; - newclose.href="javascript: closebasketgroup('"+bgid+"', 'bg-"+bgid+"');"; - - newrename.href="javascript:" + "renameinit("+bgid+");"; - newrename.innerHTML="rename"; - -// newp.style.display="inline"; - newp.innerHTML=" [ "; - newp.appendChild(newrename); - newp.innerHTML+=" / "; - newp.appendChild(newclose); - newp.innerHTML+=" ]"; - - newbasketgroupname.type="hidden"; - newbasketgroupname.name="basketgroup-" + bgid + "-name"; - newbasketgroupname.id = "basketgroup-" + bgid + "-name"; - newbasketgroupname.value=name; - - nbgclosed.type="hidden"; - nbgclosed.name="basketgroup-" + bgid + "-closed"; - nbgclosed.value="0"; - nbgclosed.id=nbgclosed.name; - - newchanged.type="hidden"; - newchanged.id="basketgroup-"+bgid+"-changed"; - newchanged.name=newchanged.id; - newchanged.value="1"; - - newdiv.style.backgroundColor='red'; - newdiv.appendChild(newh3); - newdiv.appendChild(newp); - newdiv.appendChild(newul); - newdiv.appendChild(newbasketgroupname); - newdiv.appendChild(nbgclosed); - newdiv.appendChild(newchanged); - newdiv.className='workarea'; - pardiv.appendChild(newdiv); - - YAHOO.util.Event.onDOMReady(DDApp.init, DDApp, true); -} - -//this traps enters in input fields -function enterpressed(event){ - var keycode; - if (window.event) keycode = window.event.keyCode; - else if (event) keycode = event.which; - else return false; - - if (keycode == 13) - { - return true; - } - else return false; -} - - - - -//Closes a basketgroup -function closebasketgroup(bgid) { - var answer = confirm(MSG_CONFIRM_CLOSE_BASKETGROUP); - if(! answer){ - return; - } - ulid = 'bg-'+bgid; - var i = 0; - tagname='basketgroup-'+bgid+'-closed'; - var ddtarget; - var closeinput = document.getElementById(tagname); - closeinput.value = 1; - var changed = document.getElementById("basketgroup-"+bgid+"-changed"); - changed.value=1; - - var div = document.getElementById(tagname).parentNode; - var stufftoremove = div.getElementsByTagName('p')[0]; - var ul = document.getElementById(ulid); - var lis = ul.getElementsByTagName('li'); - if (lis.length == 0 ) { - alert(MSG_CLOSE_EMPTY_BASKET); - return; - } - var cantprint = document.createElement('p'); - - div.className = "closed"; - ul.className="closed"; - - for(i=0; i this.lastY) { + this.goingUp = false; + } + this.lastY = y; + }, + + onDragOver: function(e, id) { + + var srcEl = this.getEl(); + var destEl = Dom.get(id); + + // We are only concerned with list items, we ignore the dragover + // notifications for the list. + if (destEl.nodeName.toLowerCase() == "li") { + var orig_p = srcEl.parentNode; + var p = destEl.parentNode; + + if (this.goingUp) { + p.insertBefore(srcEl, destEl); // insert above + } else { + p.insertBefore(srcEl, destEl.nextSibling); // insert below + } + + DDM.refreshCache(); + } + } +}); + +//this traps enters in input fields +function enterpressed(event){ + var keycode; + if (window.event) keycode = window.event.keyCode; + else if (event) keycode = event.which; + else return false; + + if (keycode == 13) + { + return true; + } + else return false; +} + + +//Closes a basketgroup +function closebasketgroup(bgid) { + var answer=confirm(MSG_CONFIRM_CLOSE_BASKETGROUP); + if(! answer){ + return; + } + ulid = 'bg-'+bgid; + var i = 0; + tagname='basketgroup-'+bgid+'-closed'; + var ddtarget; + var closeinput = document.getElementById(tagname); + closeinput.value = 1; + var changed = document.getElementById("basketgroup-"+bgid+"-changed"); + changed.value=1; + + var div = document.getElementById(tagname).parentNode; + var stufftoremove = div.getElementsByTagName('p')[0]; + var ul = document.getElementById(ulid); + var lis = ul.getElementsByTagName('li'); + if (lis.length == 0 ) { + alert(MSG_CLOSE_EMPTY_BASKET); + return; + } + var cantprint = document.createElement('p'); + + div.className = "closed"; + ul.className="closed"; + + for(i=0; i - + [% IF ( grouping ) %] -- 2.39.5