]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/opac/common/js/init.js
LP1615805 No inputs after submit in patron search (AngularJS)
[Evergreen.git] / Open-ILS / web / opac / common / js / init.js
1
2 /* these events should be used by all */
3
4 window.onunload = windowUnload;
5
6 attachEvt("common", "init", loadUIObjects);
7 //attachEvt("common", "init", initParams);
8 attachEvt("common", "init", initCookies);
9
10 attachEvt("common", "unload", _tree_killer);
11 try{ attachEvt("common", "unload", cleanRemoteRequests);} catch(e){}
12
13 function init() {
14
15         initParams();
16
17         if( getLocation() == null && getOrigLocation() != null )
18                 LOCATION = getOrigLocation();
19
20         if( getLocation() == null && getOrigLocation() == null )
21                 LOCATION = globalOrgTree.id();
22
23         /* if they click on the home page and the origlocation is set
24                 take the opac back to the origlocation */
25         if( findCurrentPage() == HOME && getOrigLocation() != null )
26                 LOCATION = getOrigLocation();
27
28         if(getDepth() == null) DEPTH = findOrgDepth(getLocation());
29
30
31         runEvt('common','init');
32
33         var cgi = new CGI();
34         if( grabUser() ) {
35                 if( cgi.param(PARAM_LOCATION) == null ) {
36                         var org = G.user.prefs[PREF_DEF_LOCATION];
37                         var depth = G.user.prefs[PREF_DEF_DEPTH];
38
39                         if(org == null) org = G.user.ws_ou();
40                         if(depth == null) depth = findOrgDepth(org);
41
42                         LOCATION = org;
43                         DEPTH = depth;
44                 }
45         }
46
47         // show_login trumps normal page running
48         if(location.href.match(/&show_login=1/)) {
49                 function reload() {
50                         var src = location.href.replace(/&show_login=1/, '');
51                         // forceLoginSSL setting (indicated by show_login)
52                         // assumes we are not SSL on normal pages
53                         src = src.replace(/https:/, 'http:');
54                         goTo(src);
55                 }
56                 attachEvt("common", "loginCanceled", reload);
57                 initLogin();
58         } else {
59                 runEvt("common", "run");
60         }
61         //checkUserSkin();
62
63         var loc = findOrgLasso(getLasso());
64         if (!loc) loc = findOrgUnit(getLocation());
65
66         if (getLasso()) G.ui.common.now_searching.appendChild(text('Search group: '));
67         G.ui.common.now_searching.appendChild(text(loc.name()));
68 }
69
70 function windowUnload() { runEvt("common", "unload"); }