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