Lines 55-519
function isNum(v,maybenull) {
Link Here
|
55 |
return true; |
55 |
return true; |
56 |
} |
56 |
} |
57 |
|
57 |
|
58 |
//======================================================================= |
|
|
59 |
|
60 |
//======================================================================= |
61 |
// Functions for drag-and-drop functionality |
62 |
|
63 |
if( typeof(YAHOO) === "object"){ |
64 |
(function() { |
65 |
|
66 |
var Dom = YAHOO.util.Dom; |
67 |
var Event = YAHOO.util.Event; |
68 |
var DDM = YAHOO.util.DragDropMgr; |
69 |
|
70 |
DDApp = { |
71 |
init: function() { |
72 |
var uls = document.getElementsByTagName('ul'); |
73 |
var i,j; |
74 |
var ddtarget; |
75 |
for (i=0; i<uls.length;i=i+1) { |
76 |
if (uls[i].className == "draglist" || uls[i].className == "draglist_alt") { |
77 |
ddtarget = YAHOO.util.DragDropMgr.getDDById(uls[i].id); |
78 |
// The yahoo drag and drop is written (broken or not) in such a way, that if an element is subscribed as a target multiple times, |
79 |
// it has to be unlinked multiple times, so we need to test whether it is allready a target, otherwise we'll have a problem when closing the group |
80 |
if( ! ddtarget ) { |
81 |
new YAHOO.util.DDTarget(uls[i].id); |
82 |
} |
83 |
var children = uls[i].getElementsByTagName('li'); |
84 |
for( j=0; j<children.length; j=j+1) { |
85 |
// The yahoo drag and drop is (broken or not) in such a way, that if an element is subscribed as a target multiple times, |
86 |
// it has to be unlinked multiple times, so we need to test whether it is allready a target, otherwise we'll have a problem when closing the group |
87 |
ddtarget = YAHOO.util.DragDropMgr.getDDById(children[j].id); |
88 |
if( ! ddtarget ) { |
89 |
new DDList(children[j].id); |
90 |
} |
91 |
} |
92 |
} |
93 |
} |
94 |
} |
95 |
}; |
96 |
|
97 |
|
98 |
// drag and drop implementation |
99 |
|
100 |
DDList = function(id, sGroup, config) { |
101 |
|
102 |
DDList.superclass.constructor.call(this, id, sGroup, config); |
103 |
|
104 |
this.logger = this.logger || YAHOO; |
105 |
var el = this.getDragEl(); |
106 |
Dom.setStyle(el, "opacity", 0.67); // The proxy is slightly transparent |
107 |
|
108 |
this.goingUp = false; |
109 |
this.lastY = 0; |
110 |
}; |
111 |
|
112 |
YAHOO.extend(DDList, YAHOO.util.DDProxy, { |
113 |
|
114 |
startDrag: function(x, y) { |
115 |
this.logger.log(this.id + " startDrag"); |
116 |
|
117 |
// make the proxy look like the source element |
118 |
var dragEl = this.getDragEl(); |
119 |
var clickEl = this.getEl(); |
120 |
Dom.setStyle(clickEl, "visibility", "hidden"); |
121 |
|
122 |
dragEl.innerHTML = clickEl.innerHTML; |
123 |
|
124 |
Dom.setStyle(dragEl, "color", Dom.getStyle(clickEl, "color")); |
125 |
Dom.setStyle(dragEl, "backgroundColor", Dom.getStyle(clickEl, "backgroundColor")); |
126 |
Dom.setStyle(dragEl, "border", "2px solid gray"); |
127 |
}, |
128 |
|
129 |
endDrag: function(e) { |
130 |
|
131 |
var srcEl = this.getEl(); |
132 |
var proxy = this.getDragEl(); |
133 |
|
134 |
// Show the proxy element and animate it to the src element's location |
135 |
Dom.setStyle(proxy, "visibility", ""); |
136 |
var a = new YAHOO.util.Motion( |
137 |
proxy, { |
138 |
points: { |
139 |
to: Dom.getXY(srcEl) |
140 |
} |
141 |
}, |
142 |
0.2, |
143 |
YAHOO.util.Easing.easeOut |
144 |
) |
145 |
var proxyid = proxy.id; |
146 |
var thisid = this.id; |
147 |
|
148 |
// Hide the proxy and show the source element when finished with the animation |
149 |
a.onComplete.subscribe(function() { |
150 |
Dom.setStyle(proxyid, "visibility", "hidden"); |
151 |
Dom.setStyle(thisid, "visibility", ""); |
152 |
}); |
153 |
a.animate(); |
154 |
// if we are in basketgrouping page, when finished moving, edit the basket's info to reflect new status |
155 |
if(typeof(basketgroups) != 'undefined') { |
156 |
a.onComplete.subscribe(function() { |
157 |
var reg = new RegExp("[-]+", "g"); |
158 |
// add a changed input to each moved basket, so we know which baskets to modify, |
159 |
// and so we don't need to modify each and every basket and basketgroup each time the page is loaded |
160 |
// FIXME: we shouldn't use getElementsByTagName, it's not explicit enough :-( |
161 |
srcEl.getElementsByTagName('input')[1].value = "1"; |
162 |
if ( srcEl.parentNode.parentNode.className == "workarea" ) { |
163 |
var dstbgroupid = srcEl.parentNode.parentNode.getElementsByTagName('input')[srcEl.parentNode.parentNode.getElementsByTagName('input').length-2].name.split(reg)[1]; |
164 |
srcEl.className="grouped"; |
165 |
srcEl.getElementsByTagName('input')[0].value = dstbgroupid; |
166 |
//FIXME: again, we shouldn't be using getElementsByTagName!! |
167 |
srcEl.parentNode.parentNode.getElementsByTagName('input')[srcEl.parentNode.parentNode.getElementsByTagName('input').length-1].value = 1; |
168 |
} |
169 |
else if ( srcEl.parentNode.parentNode.className == "workarea_alt" ){ |
170 |
srcEl.className="ungrouped"; |
171 |
srcEl.getElementsByTagName('input')[0].value = "0"; |
172 |
} |
173 |
}); |
174 |
} |
175 |
}, |
176 |
|
177 |
onDragDrop: function(e, id) { |
178 |
|
179 |
// If there is one drop interaction, the li was dropped either on the list, |
180 |
// or it was dropped on the current location of the source element. |
181 |
if (DDM.interactionInfo.drop.length === 1) { |
182 |
|
183 |
// The position of the cursor at the time of the drop (YAHOO.util.Point) |
184 |
var pt = DDM.interactionInfo.point; |
185 |
|
186 |
// The region occupied by the source element at the time of the drop |
187 |
var region = DDM.interactionInfo.sourceRegion; |
188 |
|
189 |
// Check to see if we are over the source element's location. We will |
190 |
// append to the bottom of the list once we are sure it was a drop in |
191 |
// the negative space (the area of the list without any list items) |
192 |
if (!region.intersect(pt)) { |
193 |
var destEl = Dom.get(id); |
194 |
var destDD = DDM.getDDById(id); |
195 |
destEl.appendChild(this.getEl()); |
196 |
destDD.isEmpty = false; |
197 |
DDM.refreshCache(); |
198 |
} |
199 |
} |
200 |
}, |
201 |
|
202 |
onDrag: function(e) { |
203 |
|
204 |
// Keep track of the direction of the drag for use during onDragOver |
205 |
var y = Event.getPageY(e); |
206 |
|
207 |
if (y < this.lastY) { |
208 |
this.goingUp = true; |
209 |
} else if (y > this.lastY) { |
210 |
this.goingUp = false; |
211 |
} |
212 |
this.lastY = y; |
213 |
}, |
214 |
|
215 |
onDragOver: function(e, id) { |
216 |
|
217 |
var srcEl = this.getEl(); |
218 |
var destEl = Dom.get(id); |
219 |
|
220 |
// We are only concerned with list items, we ignore the dragover |
221 |
// notifications for the list. |
222 |
if (destEl.nodeName.toLowerCase() == "li") { |
223 |
var orig_p = srcEl.parentNode; |
224 |
var p = destEl.parentNode; |
225 |
|
226 |
if (this.goingUp) { |
227 |
p.insertBefore(srcEl, destEl); // insert above |
228 |
} else { |
229 |
p.insertBefore(srcEl, destEl.nextSibling); // insert below |
230 |
} |
231 |
|
232 |
DDM.refreshCache(); |
233 |
} |
234 |
} |
235 |
}); |
236 |
})(); |
237 |
} |
238 |
|
239 |
|
240 |
|
241 |
//creates new group, parameter is the group's name |
242 |
function newGroup(event, name) { |
243 |
if (name == ''){ |
244 |
return 0; |
245 |
} |
246 |
if (!enterpressed(event) && event != "button"){ |
247 |
return false; |
248 |
} |
249 |
var pardiv = document.getElementById('groups'); |
250 |
var newdiv = document.createElement('div'); |
251 |
var newh3 = document.createElement('h3'); |
252 |
var newul = document.createElement('ul'); |
253 |
var newclose = document.createElement('a'); |
254 |
var newrename = document.createElement('a'); |
255 |
var newbasketgroupname = document.createElement('input'); |
256 |
var nbgclosed = document.createElement('input'); |
257 |
var newp = document.createElement('p'); |
258 |
var reg=new RegExp("[-]+", "g"); |
259 |
var i = 0; |
260 |
var maxid = 0; |
261 |
while( i < pardiv.getElementsByTagName('input').length ){ |
262 |
if (! isNaN(parseInt(pardiv.getElementsByTagName('input')[i].name.split(reg)[1])) && parseInt(pardiv.getElementsByTagName('input')[i].name.split(reg)[1]) > maxid){ |
263 |
maxid = parseInt(pardiv.getElementsByTagName('input')[i].name.split(reg)[1]); |
264 |
} |
265 |
++i; |
266 |
} |
267 |
// var bgid = parseInt(pardiv.getElementsByTagName('input')[pardiv.getElementsByTagName('input').length-2].name.split(reg)[1]) + 1; |
268 |
var bgid = maxid + 1; |
269 |
var newchanged = document.createElement('input'); |
270 |
|
271 |
newul.id="bg-"+bgid; |
272 |
newul.className='draglist'; |
273 |
|
274 |
newh3.innerHTML=name; |
275 |
// newh3.style.display="inline"; |
276 |
|
277 |
newclose.innerHTML="close"; |
278 |
newclose.href="javascript: closebasketgroup('"+bgid+"', 'bg-"+bgid+"');"; |
279 |
|
280 |
newrename.href="javascript:" + "renameinit("+bgid+");"; |
281 |
newrename.innerHTML="rename"; |
282 |
|
283 |
// newp.style.display="inline"; |
284 |
newp.innerHTML=" [ "; |
285 |
newp.appendChild(newrename); |
286 |
newp.innerHTML+=" / "; |
287 |
newp.appendChild(newclose); |
288 |
newp.innerHTML+=" ]"; |
289 |
|
290 |
newbasketgroupname.type="hidden"; |
291 |
newbasketgroupname.name="basketgroup-" + bgid + "-name"; |
292 |
newbasketgroupname.id = "basketgroup-" + bgid + "-name"; |
293 |
newbasketgroupname.value=name; |
294 |
|
295 |
nbgclosed.type="hidden"; |
296 |
nbgclosed.name="basketgroup-" + bgid + "-closed"; |
297 |
nbgclosed.value="0"; |
298 |
nbgclosed.id=nbgclosed.name; |
299 |
|
300 |
newchanged.type="hidden"; |
301 |
newchanged.id="basketgroup-"+bgid+"-changed"; |
302 |
newchanged.name=newchanged.id; |
303 |
newchanged.value="1"; |
304 |
|
305 |
newdiv.style.backgroundColor='red'; |
306 |
newdiv.appendChild(newh3); |
307 |
newdiv.appendChild(newp); |
308 |
newdiv.appendChild(newul); |
309 |
newdiv.appendChild(newbasketgroupname); |
310 |
newdiv.appendChild(nbgclosed); |
311 |
newdiv.appendChild(newchanged); |
312 |
newdiv.className='workarea'; |
313 |
pardiv.appendChild(newdiv); |
314 |
|
315 |
YAHOO.util.Event.onDOMReady(DDApp.init, DDApp, true); |
316 |
} |
317 |
|
318 |
//this traps enters in input fields |
319 |
function enterpressed(event){ |
320 |
var keycode; |
321 |
if (window.event) keycode = window.event.keyCode; |
322 |
else if (event) keycode = event.which; |
323 |
else return false; |
324 |
|
325 |
if (keycode == 13) |
326 |
{ |
327 |
return true; |
328 |
} |
329 |
else return false; |
330 |
} |
331 |
|
332 |
|
333 |
|
58 |
|
334 |
|
|
|
335 |
|
336 |
//Closes a basketgroup |
337 |
function closebasketgroup(bgid) { |
338 |
var answer=confirm(_("Are you sure you want to close this basketgroup?")); |
339 |
if(! answer){ |
340 |
return; |
341 |
} |
342 |
ulid = 'bg-'+bgid; |
343 |
var i = 0; |
344 |
tagname='basketgroup-'+bgid+'-closed'; |
345 |
var ddtarget; |
346 |
var closeinput = document.getElementById(tagname); |
347 |
closeinput.value = 1; |
348 |
var changed = document.getElementById("basketgroup-"+bgid+"-changed"); |
349 |
changed.value=1; |
350 |
|
351 |
var div = document.getElementById(tagname).parentNode; |
352 |
var stufftoremove = div.getElementsByTagName('p')[0]; |
353 |
var ul = document.getElementById(ulid); |
354 |
var lis = ul.getElementsByTagName('li'); |
355 |
if (lis.length == 0 ) { |
356 |
alert(_("Why close an empty basket?")); |
357 |
return; |
358 |
} |
359 |
var cantprint = document.createElement('p'); |
360 |
|
361 |
div.className = "closed"; |
362 |
ul.className="closed"; |
363 |
|
364 |
for(i=0; i<lis.length; ++i) { |
365 |
ddtarget = YAHOO.util.DragDropMgr.getDDById(lis[i].id); |
366 |
ddtarget.unreg(); |
367 |
} |
368 |
ddtarget = YAHOO.util.DragDropMgr.getDDById(ul.id); |
369 |
ddtarget.unreg(); |
370 |
div.removeChild(stufftoremove); |
371 |
// the print button is disabled because the page's content might (or is probably) not in sync with what the database contains |
372 |
cantprint.innerHTML=_("You need to save the page before printing"); |
373 |
cantprint.id = 'cantprint-' + bgid; |
374 |
var unclosegroup = document.createElement('a'); |
375 |
unclosegroup.href='javascript:unclosegroup('+bgid+');'; |
376 |
unclosegroup.innerHTML=_("reopen basketgroup"); |
377 |
unclosegroup.id = 'unclose-' + bgid; |
378 |
|
379 |
div.appendChild(cantprint); |
380 |
div.appendChild(unclosegroup); |
381 |
} |
382 |
|
383 |
function closeandprint(bg){ |
384 |
if(document.location = '/cgi-bin/koha/acqui/basketgroup.pl?op=closeandprint&basketgroupid=' + bg ){ |
385 |
setTimeout("window.location.reload();",3000); |
386 |
}else{ |
387 |
alert(_("Error downloading the file")); |
388 |
} |
389 |
} |
390 |
|
391 |
//function that lets the user unclose a basketgroup as long as he hasn't submitted the changes to the page. |
392 |
function unclosegroup(bgid){ |
393 |
var div = document.getElementById('basketgroup-'+bgid+'-closed').parentNode; |
394 |
var divtodel = document.getElementById('unclose-' + bgid); |
395 |
if (divtodel){ |
396 |
div.removeChild(divtodel); |
397 |
} |
398 |
divtodel = document.getElementById('unclose-' + bgid); |
399 |
if (divtodel){ |
400 |
div.removeChild(divtodel); |
401 |
} |
402 |
var closeinput = document.getElementById('basketgroup-'+bgid+'-closed'); |
403 |
var ul = document.getElementById('bg-'+bgid); |
404 |
|
405 |
var newclose = document.createElement('a'); |
406 |
var newrename = document.createElement('a'); |
407 |
var newp = document.createElement('p'); |
408 |
|
409 |
newclose.innerHTML="close"; |
410 |
newclose.href="javascript: closebasketgroup('"+bgid+"', 'bg-"+bgid+"');"; |
411 |
|
412 |
newrename.href="javascript:" + "renameinit("+bgid+");"; |
413 |
newrename.innerHTML="rename"; |
414 |
|
415 |
var todel = div.getElementsByTagName('p')[0]; |
416 |
div.removeChild(todel); |
417 |
|
418 |
var changed = document.getElementById("basketgroup-"+bgid+"-changed"); |
419 |
changed.value=1; |
420 |
|
421 |
newp.innerHTML=" [ "; |
422 |
newp.appendChild(newrename); |
423 |
newp.innerHTML+=" / "; |
424 |
newp.appendChild(newclose); |
425 |
newp.innerHTML+=" ]"; |
426 |
|
427 |
div.insertBefore(newp, ul); |
428 |
closeinput.value="0"; |
429 |
div.className = "workarea"; |
430 |
ul.className="draglist"; |
431 |
|
432 |
//rescan draglists, we have a new target (again :-) |
433 |
YAHOO.util.Event.onDOMReady(DDApp.init, DDApp, true); |
434 |
} |
435 |
|
436 |
//a function to filter basketgroups using a regex (javascript regex) |
437 |
function filterGroups(event, searchstring ){ |
438 |
if (!enterpressed(event) && event != "button"){ |
439 |
return false; |
440 |
} |
441 |
var reg = new RegExp(searchstring, "g"); |
442 |
var Dom = YAHOO.util.Dom; |
443 |
var divs = Dom.getElementsByClassName("workarea", "div"); |
444 |
|
445 |
for (var i = 0; i < divs.length; ++i){ |
446 |
if (! reg.exec(divs[i].innerHTML)){ |
447 |
divs[i].style.display='none'; |
448 |
} |
449 |
else { |
450 |
divs[i].style.display=''; |
451 |
} |
452 |
} |
453 |
divs = Dom.getElementsByClassName("closed", "div"); |
454 |
for (var i = 0; i < divs.length; ++i){ |
455 |
if (! reg.exec(divs[i].innerHTML)){ |
456 |
divs[i].style.display='none'; |
457 |
} |
458 |
else { |
459 |
divs[i].style.display=''; |
460 |
} |
461 |
} |
462 |
} |
463 |
|
464 |
//function to hide (or show) closed baskets (if show is true, it shows all the closed baskets) |
465 |
function showhideclosegroups(show){ |
466 |
var Dom = YAHOO.util.Dom; |
467 |
var divs = Dom.getElementsByClassName("closed", "div"); |
468 |
var display; |
469 |
if (show){ |
470 |
display = ''; |
471 |
} |
472 |
else display = 'none'; |
473 |
for(var i = 0; i < divs.length; ++i){ |
474 |
divs[i].style.display=display; |
475 |
} |
476 |
} |
477 |
|
478 |
function renameinit(bgid){ |
479 |
var ul = document.getElementById('bg-'+bgid); |
480 |
var div = ul.parentNode; |
481 |
var nameelm = div.getElementsByTagName('h3')[0]; |
482 |
var p = div.getElementsByTagName('p')[0]; |
483 |
|
484 |
|
485 |
var nameinput = document.createElement("input"); |
486 |
nameinput.type = "text"; |
487 |
nameinput.id="rename-"+bgid; |
488 |
nameinput.value = nameelm.innerHTML; |
489 |
nameinput.onkeypress = function(e){rename(e, bgid, document.getElementById('rename-'+bgid).value); }; |
490 |
// nameinput.setAttribute('onkeypress', 'rename(event, bgid, document.getElementById(rename-'+bgid+').value);'); |
491 |
|
492 |
div.removeChild(nameelm); |
493 |
div.insertBefore(nameinput, p); |
494 |
} |
495 |
|
496 |
function rename(event, bgid, name){ |
497 |
if (!enterpressed(event)){ |
498 |
return false; |
499 |
} |
500 |
var ul = document.getElementById('bg-'+bgid); |
501 |
var div = ul.parentNode; |
502 |
var p = div.getElementsByTagName('p')[0]; |
503 |
var nameinput = document.getElementById("rename-"+bgid); |
504 |
var changedinput = document.getElementById("basketgroup-"+bgid+"-changed"); |
505 |
var newh3 = document.createElement("h3"); |
506 |
var hiddenname = document.getElementById("basketgroup-"+bgid+"-name"); |
507 |
|
508 |
div.removeChild(nameinput); |
509 |
|
510 |
newh3.innerHTML=name; |
511 |
hiddenname.value=name; |
512 |
changedinput.value = 1; |
513 |
div.insertBefore(newh3, p); |
514 |
} |
515 |
|
516 |
//======================================================================= |
517 |
//a logging function (a bit buggy, might open millions of log pages when initializing, but works fine after... |
59 |
//a logging function (a bit buggy, might open millions of log pages when initializing, but works fine after... |
518 |
function log(message) { |
60 |
function log(message) { |
519 |
if (!log.window_ || log.window_.closed) { |
61 |
if (!log.window_ || log.window_.closed) { |
Lines 891-894
function hideAllColumns(){
Link Here
|
891 |
$("#selections span").removeClass("selected"); |
433 |
$("#selections span").removeClass("selected"); |
892 |
$("#plan td:nth-child(2),#plan th:nth-child(2)").nextUntil("th:nth-child("+(allCols-1)+"),td:nth-child("+(allCols-1)+")").hide(); // hide all but the last two columns |
434 |
$("#plan td:nth-child(2),#plan th:nth-child(2)").nextUntil("th:nth-child("+(allCols-1)+"),td:nth-child("+(allCols-1)+")").hide(); // hide all but the last two columns |
893 |
$("#hideall").attr("checked","checked").parent().addClass("selected"); |
435 |
$("#hideall").attr("checked","checked").parent().addClass("selected"); |
894 |
} |
436 |
} |