]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/js/ui/default/opac/staff.js
Merge branch 'master' of git://git.evergreen-ils.org/Evergreen into template-toolkit...
[Evergreen.git] / Open-ILS / web / js / ui / default / opac / staff.js
1 /* staff client integration functions */
2 function debug(msg){dump(msg+'\n')}
3 var eventCache={};
4 function attachEvt(scope, name, action) {
5     if(!eventCache[scope]) eventCache[scope] = {};
6     if(!eventCache[scope][name]) eventCache[scope][name] = [];
7     eventCache[scope][name].push(action);
8 }
9 function runEvt(scope, name) {
10     debug('running event '+scope+':'+name);
11     var args = Array.prototype.slice.call(arguments).slice(2);
12     if(eventCache[scope]) {
13         var evt = eventCache[scope][name];
14         for(var i in evt) {evt[i].apply(evt[i], args);}
15     } 
16 }
17 function staff_hold_usr_input_disabler(input) {
18     document.getElementById("hold_usr_input").disabled =
19         Boolean(Number(input.value));
20 }
21 function staff_hold_usr_prepop() {
22     if (xulG && xulG.patron_barcode) {
23         var sel = document.getElementById("pickup_lib");
24         for (var i = 0; i < sel.options.length; i++) {
25             if (sel.options[i].value == xulG.patron_home_ou) {
26                 sel.selectedIndex = i;
27                 break;
28             }
29         }
30         document.getElementById("hold_usr_input").value = xulG.patron_barcode;
31         document.getElementById("hold_usr_input").disabled = false;
32         document.getElementById("hold_usr_is_requestor_not").checked = true;
33
34         var kill_this =
35             document.getElementById("hold_usr_is_requestor").parentNode;
36         kill_this.parentNode.removeChild(kill_this);
37     }
38 }
39 window.onload = function() {
40     // record details page events
41     var rec = location.href.match(/\/opac\/record\/(\d+)/);
42     if(rec && rec[1]) { runEvt('rdetail', 'recordRetrieved', rec[1]); }
43
44     if (document.getElementById("hold_usr_input"))
45         staff_hold_usr_prepop();
46
47     // fire other events the staff client is expecting...
48 }