From 0fc7d9a0a4aa094c6295ee1f0d43d97831e322dc Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 28 Jun 2013 14:46:44 -0400 Subject: [PATCH] Bug 10522: fix Javascript error on acquisition pages: YAHOO is not defined acq.js includes an immediately invoked function expression, which means that it runs whether or not it is called. Because this function tries to reference the YAHOO object, it triggers an error on pages which don't include the main YAHOO assets. Only the basketgroups page uses this function and YAHOO assets. It's probably possible to make this a regular function, but I propose simply wrapping it in a check for the YAHOO object so that it only executes on pages where YAHOO exists--the basketgroups page. To test, apply the patch, clear your browser cache, and test on both the basketgroups page and at least one page which also includes acq.js (addorderiso2709.pl, neworderempty.pl, aqbudgets.pl, suggestion.pl, etc.) and confirm that the browser reports no JavaScript errors. Signed-off-by: Jonathan Druart Signed-off-by: Chris Cormack Signed-off-by: Galen Charlton --- koha-tmpl/intranet-tmpl/prog/en/js/acq.js | 280 +++++++++++----------- 1 file changed, 140 insertions(+), 140 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js b/koha-tmpl/intranet-tmpl/prog/en/js/acq.js index 067cd08642..b9039ea9a6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/acq.js @@ -60,181 +60,181 @@ function isNum(v,maybenull) { //======================================================================= // Functions for drag-and-drop functionality +if( typeof(YAHOO) === "object"){ + (function() { -(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; - }, + if (y < this.lastY) { + this.goingUp = true; + } else if (y > this.lastY) { + this.goingUp = false; + } + this.lastY = y; + }, - onDragOver: function(e, id) { + onDragOver: function(e, id) { - var srcEl = this.getEl(); - var destEl = Dom.get(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; + // 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 - } + if (this.goingUp) { + p.insertBefore(srcEl, destEl); // insert above + } else { + p.insertBefore(srcEl, destEl.nextSibling); // insert below + } - DDM.refreshCache(); + DDM.refreshCache(); + } } - } -}); -})(); - + }); + })(); +} -- 2.39.5