View | Details | Raw Unified | Return to bug 10533
Collapse All | Expand All

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

Return to bug 10533