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