]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/js/ui/default/opac/staff.js
TPac: MFHD staff client actions integration
[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 window.onload = function() {
22     // record details page events
23     var rec = location.href.match(/\/opac\/record\/(\d+)/);
24     if(rec && rec[1]) { 
25         runEvt('rdetail', 'recordRetrieved', rec[1]); 
26         runEvt('rdetail', 'MFHDDrawn');
27     }
28 }
29
30 function rdetail_next_prev_actions(index, count, prev, next, start, end) {
31     /*  we get the relative URL from the template:  recid?query_args...
32         replace the recid and args on location.href to get the new URL  */
33     function fullurl(url) { return location.href.replace(/\/\d+\??.*/, '/' + url); }
34
35     if (index > 0) {
36         if(prev) 
37             window.rdetailPrev = function() { location.href = fullurl(prev); }
38         if(start) 
39             window.rdetailStart = function() { location.href = fullurl(start); }
40     }
41
42     if (index < count - 1) {
43         if(next) 
44             window.rdetailNext = function() { location.href = fullurl(next); }
45         if(end) 
46             window.rdetailEnd = function() { location.href = fullurl(end); }
47     }
48
49     ol = window.onload;
50     window.onload = function() {
51         if(ol) ol(); 
52         runEvt('rdetail', 'nextPrevDrawn', Number(index), Number(count)); 
53     };
54 }