]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/opac/skin/default/js/sidebar.js
64ec2f7289269d3bfc76da40099d44352839e5a9
[working/Evergreen.git] / Open-ILS / web / opac / skin / default / js / sidebar.js
1 /* set up the colors in the sidebar 
2         Disables/Enables certain components based on various state data */
3
4 attachEvt("common", "init", initSideBar);
5 attachEvt("common", "init", setSidebarLinks);
6
7 function initSideBar() {
8         var page = findCurrentPage();
9         unHideMe(G.ui.sidebar[page]);
10         addCSSClass(G.ui.sidebar[page], config.css.color_2);
11         addCSSClass(G.ui.sidebar[page], config.css.encircled);
12
13         /* if we're logged in, show it and replace the Login link with the Logout link */
14         if(grabUser()) {
15                 G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
16                 unHideMe(G.ui.sidebar.logoutbox);
17                 unHideMe(G.ui.sidebar.logged_in_as);
18                 hideMe(G.ui.sidebar.loginbox);
19         }
20
21         if(G.ui.sidebar.login) G.ui.sidebar.login.onclick = initLogin;
22         if(G.ui.sidebar.logout) G.ui.sidebar.logout.onclick = doLogout; 
23 }
24
25 /* sets up the login ui components */
26 var loginBoxVisible = false;
27 function initLogin() {
28
29         var loginDance = function() {
30                 if(doLogin()) {
31                         showCanvas();
32                         G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
33                         unHideMe(G.ui.sidebar.logoutbox);
34                         unHideMe(G.ui.sidebar.logged_in_as);
35                         hideMe(G.ui.sidebar.loginbox);
36                 }
37         }
38
39         G.ui.login.button.onclick = loginDance;
40         G.ui.login.username.onkeydown = 
41                 function(evt) {if(userPressedEnter(evt)) loginDance();};
42         G.ui.login.password.onkeydown = 
43                 function(evt) {if(userPressedEnter(evt)) loginDance();};
44
45         if(loginBoxVisible) {
46                 showCanvas();
47         } else {
48                 swapCanvas(G.ui.login.box);
49                 G.ui.login.username.focus();
50         }
51
52         loginBoxVisible = !loginBoxVisible;
53         G.ui.login.cancel.onclick = showCanvas;
54 }
55
56 function setSidebarLinks() {
57         G.ui.sidebar.home_link.setAttribute("href", buildOPACLink({page:HOME}));
58         G.ui.sidebar.advanced_link.setAttribute("href", buildOPACLink({page:ADVANCED}));
59         G.ui.sidebar.myopac_link.setAttribute("href", buildOPACLink({page:MYOPAC}, false, true));
60 }
61
62