]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/opac/common/js/config.js
added a callback for recordDrawn so XUL can plug in actions
[Evergreen.git] / Open-ILS / web / opac / common / js / config.js
1 /* Export some constants  ----------------------------------------------------- */
2
3 /* URL params */
4 var PARAM_TERM                                  = "term";               /* search term */
5 var PARAM_STYPE                         = "stype";              /* search type */
6 var PARAM_LOCATION                      = "location"    /* current location */;
7 var PARAM_DEPTH                         = "depth";              /* search depth */
8 var PARAM_FORM                                  = "format";             /* search format */
9 var PARAM_OFFSET                                = "offset";             /* search offset */
10 var PARAM_COUNT                         = "count";              /* hits per page */
11 var PARAM_HITCOUNT                      = "hitcount";   /* hits per page */
12 var PARAM_MRID                                  = "mrid";               /* metarecord id */
13 var PARAM_RID                                   = "rid";                        /* record id */
14
15 /* cookies */
16 var COOKIE_SB = "sbe";
17 var COOKIE_SES = "ses";
18 var COOKIE_IDS  = "ids";
19 var COOKIE_FONT = "fnt";
20
21 /* these are the actual param values - set on page load */
22
23 /* pages */
24 var MRESULT             = "mresult";
25 var RRESULT             = "rresult";
26 var RDETAIL             = "rdetail";
27 var MYOPAC              = "myopac";
28 var ADVANCED    = "advanced";
29 var HOME                        = "home";
30
31 /* search type (STYPE) options */
32 STYPE_AUTHOR    = "author";
33 STYPE_TITLE             = "title";
34 STYPE_SUBJECT   = "subject";
35 STYPE_SERIES    = "series";
36 STYPE_KEYWORD   = "keyword";
37
38
39 /* container for global variables shared accross pages */
40 var G           = {};
41 G.user  = null; /* global user object */
42 G.ui            = {} /* cache of UI components */
43
44
45 /* call me after page init and I will load references 
46         to all of the ui object id's defined below 
47         They will be stored in G.ui.<page>.<thingy>
48  */
49 function loadUIObjects() {
50         for( var p in config.ids ) {
51                 G.ui[p] = {};
52                 for( var o in config.ids[p] ) 
53                         G.ui[p][o] = getId(config.ids[p][o]);
54         }
55 }
56
57 /* try our best to free memory */
58 function clearUIObjects() {
59         for( var p in config.ids ) {
60                 for( var o in config.ids[p] ) {
61                         if(G.ui[p][o]) {
62                                 G.ui[p][o].onclick = null;
63                                 G.ui[p][o].onkeydown = null;
64                                 G.ui[p][o] = null;
65                         }
66                 }
67                 G.ui[p] = null;
68         }
69 }
70
71 /* ---------------------------------------------------------------------------- 
72         Set up ID's and CSS classes 
73         Any new ids, css, etc. may be added by giving the unique names and putting 
74         them into the correct scope 
75 /* ---------------------------------------------------------------------------- */
76
77 var config = {};
78
79 /* Set up the page names */
80 config.page = {};
81 config.page[HOME]                       = "index.xml";
82 config.page[ADVANCED]   = "advanced.xml";
83 config.page[MRESULT]            = "mresult.xml";
84 config.page[RRESULT]            = "rresult.xml";
85 config.page[MYOPAC]             = "myopac.xml";
86 config.page[RDETAIL]            = "rdetail.xml";
87
88 /* themes */
89 config.themes = {};
90
91
92 /* set up images  */
93 config.images = {};
94 config.images.logo = "main_logo.jpg";
95
96
97 /* set up ID's, CSS, and node names */
98 config.ids                              = {};
99 config.ids.result               = {};
100 config.ids.mresult      = {};
101 config.ids.advanced     = {};
102 config.ids.rresult      = {};
103 config.ids.myopac               = {};
104 config.ids.rdetail      = {};
105
106 config.css                              = {};
107 config.css.result               = {};
108 config.css.mresult      = {};
109 config.css.advanced     = {};
110 config.css.rresult      = {};
111 config.css.myopac               = {};
112 config.css.rdetail      = {};
113
114 config.names                    = {};
115 config.names.result     = {};
116 config.names.mresult = {};
117 config.names.advanced = {};
118 config.names.rresult = {};
119 config.names.myopac     = {};
120 config.names.rdetail = {};
121
122
123 /* id's shared accross skins. These *must* be defined */
124 config.ids.common = {};
125 config.ids.common.loading                       = "loading_div";                
126 config.ids.common.canvas                        = "canvas";                             
127 config.ids.common.canvas_main           = "canvas_main";                
128 config.ids.common.org_tree                      = "org_tree";                   
129 config.ids.common.org_container = "org_container";
130
131 config.ids.xul = {};
132
133
134 /* shared CSS */
135 config.css.hide_me = "hide_me";
136
137
138 /* ---------------------------------------------------------------------------- */
139 /* These are pages that may replace the canvas */
140 /* ---------------------------------------------------------------------------- */
141 config.ids.altcanvas = {};
142
143
144
145 /* ---------------------------------------------------------------------------- */
146 /* Methods are defined as service:method 
147         An optional 3rd component is when a method is followed by a :1, such methods
148         have a staff counterpart and should have ".staff" appended to the method 
149         before the method is called when in XUL mode */
150
151 var FETCH_MRCOUNT                               = "open-ils.search:open-ils.search.biblio.class.count:1";
152 var FETCH_MRIDS                         = "open-ils.search:open-ils.search.biblio.class:1";
153 var FETCH_MRIDS_FULL                    = "open-ils.search:open-ils.search.biblio.class.full:1";
154 var FETCH_MRMODS                                = "open-ils.search:open-ils.search.biblio.metarecord.mods_slim.retrieve";
155 var FETCH_MR_COPY_COUNTS        = "open-ils.search:open-ils.search.biblio.metarecord.copy_count:1";
156 var FETCH_RIDS                                  = "open-ils.search:open-ils.search.biblio.metarecord_to_records:1";
157 var FETCH_RMODS                         = "open-ils.search:open-ils.search.biblio.record.mods_slim.retrieve";
158 var FETCH_R_COPY_COUNTS         = "open-ils.search:open-ils.search.biblio.record.copy_count";
159 var FETCH_FLESHED_USER          = "open-ils.actor:open-ils.actor.user.fleshed.retrieve";
160 var FETCH_SESSION                               = "open-ils.auth:open-ils.auth.session.retrieve";
161 var LOGIN_INIT                                  = "open-ils.auth:open-ils.auth.authenticate.init";
162 var LOGIN_COMPLETE                      = "open-ils.auth:open-ils.auth.authenticate.complete";
163 var LOGIN_DELETE                                = "open-ils.auth:open-ils.auth.session.delete";
164 /* ---------------------------------------------------------------------------- */
165
166
167
168 /* ---------------------------------------------------------------------------- */
169 /* event callback functions. Other functions may be appended to these vars to
170         for added functionality.  */
171
172 G.evt                           = {}; /* events container */
173
174 function runEvt(scope, name, a, b, c, d, e, f, g) {
175         var evt = G.evt[scope][name];
176         for( var i in evt ) {
177                 evt[i](a, b, c, d, e, f, g);    
178         }
179 }
180
181 /* creates a new event if it doesn't already exist */
182 function createEvt(scope, name) {
183         if(!G.evt[scope]) G.evt[scope] = {};
184         if(G.evt[scope][name] == null)
185                 G.evt[scope][name] = []; 
186 }
187
188 function attachEvt(scope, name, action) {
189         createEvt(scope, name);
190         G.evt[scope][name].push(action);
191 }
192
193 createEvt("common", "init");                                            /* f() : what happens on page init */
194 createEvt("common", "pageRendered");                    /* f() : what happens when the page is done (up to the skin to call this even)*/
195 createEvt("common", "unload");                                  /* f() : what happens on window unload (clean memory, etc.)*/
196 createEvt("common", "run");                                             /* f() : make the page do stuff */
197 createEvt("mresult", "idsReceived");                    /* f(ids) */
198 createEvt("rresult", "idsReceived");                    /* f(ids) */    
199 createEvt("rresult", "recordDrawn");                    /* f(recordid, linkDOMNode) : after record is drawn, allow others (xul) to plugin actions */
200
201 createEvt("result", "hitCountReceived");                /* f() : display hit info, pagination, etc. */
202 createEvt("result", "recordReceived");                  /* f(mvr, pagePosition, isMr) : display the record*/
203 createEvt("result", "recordDrawn");                             /* f(recordid, linkDOMNode) : after record is drawn, allow others (xul) to plugin actions */
204 createEvt("result", "copyCountsReceived");      /* f(mvr, pagePosition, copyCountInfo) : display copy counts*/
205 createEvt("result", "allRecordsReceived");      /* f(mvrsArray) : add other page stuff, sidebars, etc.*/
206
207 createEvt("rdetail", "recordDrawn");                    /* f() : the record has been drawn */
208
209
210
211
212